Package com.dotmarketing.business

Examples of com.dotmarketing.business.Permissionable


        //gets menu items for this folder
        java.util.Iterator itemsChildrenListIter = itemsChildrenList.iterator();

        while (itemsChildrenListIter.hasNext()) {

            Permissionable childItem = (Permissionable) itemsChildrenListIter.next();

            if (childItem instanceof Folder) {
                if ((level == 0) && (totalCount != 0) && (totalCount % numberToBreak) == 0) {
                    stringbuf.append("</td>\n<td valign=top width=\"" + percent + "%\">\n");
                    totalCount = 0;
View Full Code Here


        // ### Copy the permission ###
        // Source
        boolean live = false;

        Identifier identifier  = APILocator.getIdentifierAPI().find(children[i].getHost(), destinationPath + "/" + children[i].getName());
        Permissionable destinationFile = null;
         if(identifier!=null && identifier.getAssetType().equals("contentlet")){
           destinationFile = APILocator.getContentletAPI().findContentletByIdentifier(identifier.getId(), live, APILocator.getLanguageAPI().getDefaultLanguage().getId(), user, false);
        }else{
          destinationFile = fileAPI.getFileByURI(destinationPath + "/" + children[i].getName(), children[i].getHost(), live, user, false);
        }
View Full Code Here

    Host host = hostAPI.find(folderHostId, systemUser, false);
    Folder folder = null;
    if(host == null) {
      folder =APILocator.getFolderAPI().find(folderHostId, APILocator.getUserAPI().getSystemUser(), false);
    }
    Permissionable permissionable = host == null?folder:host;
    List<Permission> permissionsToSave = new ArrayList<Permission>();

    if(APILocator.getPermissionAPI().isInheritingPermissions(permissionable)){
      Permissionable parentPermissionable = permissionAPI.findParentPermissionable(permissionable);
      permissionAPI.permissionIndividually(parentPermissionable, permissionable, systemUser, respectFrontendRoles);
    }

    if(permissions.get("individual") != null) {
      int permission = Integer.parseInt(permissions.get("individual"));
View Full Code Here

    User user = userWebAPI.getLoggedInUser(request);
    boolean respectFrontendRoles = !userWebAPI.isLoggedToBackend(request);

        HostAPI hostAPI = APILocator.getHostAPI();

    Permissionable perm = null;

    //Determining the type

    //Host?
    perm = hostAPI.find(assetId, user, respectFrontendRoles);
    if(perm == null) {
      //Content?
      ContentletAPI contAPI = APILocator.getContentletAPI();
      try {
        perm = contAPI.findContentletByIdentifier(assetId, false, APILocator.getLanguageAPI().getDefaultLanguage().getId(), user, respectFrontendRoles);
      } catch (DotContentletStateException e) {
      }
    }
    if(perm == null) {
      DotConnect dc = new DotConnect();
      String assetType ="";
      dc.setSQL("select asset_type as type from identifier where id = ?");
      dc.addParam(assetId);
      ArrayList idResults = dc.loadResults();
      if(idResults.size()>0){
         assetType = (String)((Map)idResults.get(0)).get("type");

         dc.setSQL("select inode, type from inode,"+assetType+" asset,identifier where inode.inode = asset.inode and " +
                "asset.identifier = identifier.id and asset.identifier = ?");
         dc.addParam(assetId);
         ArrayList results = dc.loadResults();

        if(results.size() > 0) {
          String inode = (String) ((Map)results.get(0)).get("inode");
          perm = InodeFactory.getInode(inode, Inode.class);
        }
      }
    }

    if(perm == null || !UtilMethods.isSet(perm.getPermissionId())) {
      perm = InodeFactory.getInode(assetId, Inode.class);
    }

    if(perm!=null && UtilMethods.isSet(perm.getPermissionId())){
      boolean isInheriting=APILocator.getPermissionAPI().isInheritingPermissions(perm);
      if(isInheriting){
        ret.put("isInheriting", true);
      }
    }
View Full Code Here

      throw new DotStateException("folder must already have an identifier before saving");
    }

    Host host = APILocator.getHostAPI().find(folder.getHostId(), user, respectFrontEndPermissions);
    Folder parentFolder = findFolderByPath(id.getParentPath(), id.getHostId(), user, respectFrontEndPermissions);
    Permissionable parent = id.getParentPath().equals("/")?host:parentFolder;
    String name = id.getParentPath().equals("/")?host.getHostname():parentFolder.getName();


    if(parent ==null){
      throw new DotStateException("No Folder Found for id: " + id.getParentPath());
View Full Code Here

    counter.setCounter(++internalCounter);

    sb.append("<ul id='" + id + "' >\n");
    Iterator itemsIter = items.iterator();
    while (itemsIter.hasNext()) {
      Permissionable item = (Permissionable) itemsIter.next();
      String title = "";
      String inode = "";
      if (item instanceof Folder) {
        Folder folder = ((Folder) item);
        title = folder.getTitle();
View Full Code Here

    sb.append("<ul id='" + id + "' >\n");
    if (items != null) {
      Iterator itemsIter = items.iterator();
      while (itemsIter.hasNext()) {
        Permissionable item = (Permissionable) itemsIter.next();
        String title = "";
        String inode = "";
        if (item instanceof Folder) {
          Folder folder = ((Folder) item);
          title = folder.getTitle();
View Full Code Here

    PermissionAPI permAPI = APILocator.getPermissionAPI();

    List<Map<String, Object>> toReturn = new ArrayList<Map<String,Object>>();
    Map<String, Map<String, Object>> roles = new TreeMap<String, Map<String, Object>>();

    Permissionable perm = retrievePermissionable(assetId, languageId, user, respectFrontendRoles);

    List<Permission> assetPermissions = permAPI.getPermissions(perm, true);
    for(Permission p : assetPermissions) {
      addPermissionToRoleList(perm, p, roles, false);
    }
    if(perm.isParentPermissionable()) {
      List<Permission> iheritablePermissions = permAPI.getInheritablePermissions(perm, true);
      for(Permission p : iheritablePermissions) {
        addPermissionToRoleList(perm, p, roles, true);
      }
    }
View Full Code Here

        } else {
          roleMap.put("inherited", true);
          String assetInode = p.getInode();

          //try from the cache
          Permissionable permParent = inodeCache.get(p.getInode());
          if(permParent == null) {
            // because identifiers are not Inodes, we need to do a double lookup
            permParent = InodeFactory.getInode(assetInode, Inode.class);
            if(permParent !=null || InodeUtils.isSet(permParent.getPermissionId())){
              inodeCache.put(permParent.getPermissionId(), permParent);

            }
            else{
              permParent = APILocator.getIdentifierAPI().find(assetInode);
              if(permParent != null && InodeUtils.isSet(permParent.getPermissionId())){
                inodeCache.put(permParent.getPermissionId(), permParent);
              }
            }
          }
          if(permParent instanceof Folder) {
            roleMap.put("inheritedFromType", "folder");
View Full Code Here

      //Retrieving the current user
      User user = userWebAPI.getLoggedInUser(request);
      boolean respectFrontendRoles = !userWebAPI.isLoggedToBackend(request);

      PermissionAPI permissionAPI = APILocator.getPermissionAPI();
      Permissionable asset = retrievePermissionable(assetId, language, user, respectFrontendRoles);

      List<Permission> newSetOfPermissions = new ArrayList<Permission>();
      for(Map<String, String> permission: permissions) {
        String roleId = permission.get("roleId");
        String individualPermission = permission.get("individualPermission");
        if(individualPermission != null ) {
          newSetOfPermissions.add(new Permission(asset.getPermissionId(), roleId, Integer.parseInt(individualPermission), true));
          //If a structure we need to save permissions inheritable by children content
          if(asset instanceof Structure) {
            newSetOfPermissions.add(new Permission(Contentlet.class.getCanonicalName(), asset.getPermissionId(), roleId,
                Integer.parseInt(individualPermission), true));
          }
          //If a category we need to save permissions inheritable by children categories
          if(asset instanceof Category) {
            newSetOfPermissions.add(new Permission(Category.class.getCanonicalName(), asset.getPermissionId(), roleId,
                Integer.parseInt(individualPermission), true));
          }
        }
        String containersPermission = permission.get("containersPermission");
        if(containersPermission != null) {
          newSetOfPermissions.add(new Permission(Container.class.getCanonicalName(), asset.getPermissionId(),
              roleId, Integer.parseInt(containersPermission), true));
        }
        String filesPermission = permission.get("filesPermission");
        if(filesPermission != null) {
          newSetOfPermissions.add(new Permission(File.class.getCanonicalName(), asset.getPermissionId(), roleId,
              Integer.parseInt(filesPermission), true));
        }
        String pagesPermission = permission.get("pagesPermission");
        if(pagesPermission != null) {
          newSetOfPermissions.add(new Permission(HTMLPage.class.getCanonicalName(), asset.getPermissionId(), roleId,
              Integer.parseInt(pagesPermission), true));
        }
        String foldersPermission = permission.get("foldersPermission");
        if(foldersPermission != null) {
          newSetOfPermissions.add(new Permission(Folder.class.getCanonicalName(), asset.getPermissionId(), roleId,
              Integer.parseInt(foldersPermission), true));
        }
        String contentPermission = permission.get("contentPermission");
        if(contentPermission != null) {
          newSetOfPermissions.add(new Permission(Contentlet.class.getCanonicalName(), asset.getPermissionId(), roleId,
              Integer.parseInt(contentPermission), true));
        }
        String linksPermission = permission.get("linksPermission");
        if(linksPermission != null) {
          newSetOfPermissions.add(new Permission(Link.class.getCanonicalName(), asset.getPermissionId(), roleId,
              Integer.parseInt(linksPermission), true));
        }
        String templatesPermission = permission.get("templatesPermission");
        if(templatesPermission != null) {
          newSetOfPermissions.add(new Permission(Template.class.getCanonicalName(), asset.getPermissionId(), roleId,
              Integer.parseInt(templatesPermission), true));
        }
        String templateLayoutsPermission = permission.get("templateLayoutsPermission");
        if(templateLayoutsPermission != null) {
          newSetOfPermissions.add(new Permission(Template.TEMPLATE_LAYOUTS_CANONICAL_NAME, asset.getPermissionId(), roleId,
              Integer.parseInt(templateLayoutsPermission), true));
        }
        String structurePermission = permission.get("structurePermission");
        if(structurePermission != null) {
          newSetOfPermissions.add(new Permission(Structure.class.getCanonicalName(), asset.getPermissionId(), roleId,
              Integer.parseInt(structurePermission), true));
        }
        String categoriesPermissions = permission.get("categoriesPermissions");
        if(categoriesPermissions != null) {
          newSetOfPermissions.add(new Permission(Category.class.getCanonicalName(), asset.getPermissionId(), roleId,
              Integer.parseInt(categoriesPermissions), true));
        }
      }

      if(newSetOfPermissions.size() > 0) {
        permissionAPI.assignPermissions(newSetOfPermissions, asset, user, respectFrontendRoles);

        if(reset && asset.isParentPermissionable()) {
          ResetPermissionsJob.triggerJobImmediately(asset);
        }
      } else {
        permissionAPI.removePermissions(asset);
      }
View Full Code Here

TOP

Related Classes of com.dotmarketing.business.Permissionable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.