Package com.dotmarketing.business

Examples of com.dotmarketing.business.Permissionable


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

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

    } catch (DotDataException e) {
      HibernateUtil.rollbackTransaction();
      throw e;
View Full Code Here


  @SuppressWarnings("unchecked")
  private Permissionable retrievePermissionable (String assetId, Long language, User user, boolean respectFrontendRoles) throws DotDataException, DotSecurityException {
   
    HostAPI hostAPI = APILocator.getHostAPI();
    Permissionable perm = null;

    //Determining the type
    try{
      //Host?
      perm = hostAPI.find(assetId, user, respectFrontendRoles);
    }
    catch(Exception e){

    }
   
    if(perm == null) {
      //Content?
      ContentletAPI contAPI = APILocator.getContentletAPI();
     
      try {
        if(language == null || language <= 0){
          language=APILocator.getLanguageAPI().getDefaultLanguage().getId();
        }
        perm = contAPI.findContentletByIdentifier(assetId, false, language, user, respectFrontendRoles);
      } catch (DotContentletStateException e) {

      }
    }

    if(perm == null) {

      DotConnect dc = new DotConnect();
      ArrayList results = new ArrayList();
      String assetType ="";
      dc.setSQL("Select asset_type from identifier where id =?");
      dc.addParam(assetId);
      ArrayList assetResult = dc.loadResults();
     
      if(assetResult.size()>0){
        assetType = (String) ((Map)assetResult.get(0)).get("asset_type");
      }
     
      if(UtilMethods.isSet(assetType)){
        dc.setSQL("select i.inode, type from inode i,"+assetType+" a where i.inode = a.inode and a.identifier = ?");
        dc.addParam(assetId);
        results = dc.loadResults();
      }
     
      if(results.size() > 0) {
        String type =  (String) ((Map)results.get(0)).get("type");
        String inode = (String) ((Map)results.get(0)).get("inode");
        perm = InodeFactory.getInode(inode, InodeUtils.getClassByDBType(type));
      }
    }

    if(perm == null || !UtilMethods.isSet(perm.getPermissionId())) {
      perm = InodeFactory.getInode(assetId, Inode.class);
    }
   
    return perm;
  }
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, languageId, user, respectFrontendRoles);
          Permissionable parentPermissionable = APILocator.getPermissionAPI().findParentPermissionable(asset);

          if(parentPermissionable!=null){
            permissionAPI.permissionIndividually(parentPermissionable, asset, user, respectFrontendRoles);
          }
          HibernateUtil.commitTransaction();
View Full Code Here

    UserWebAPI userWebAPI = WebAPILocator.getUserWebAPI();
    WebContext ctx = WebContextFactory.get();
    HttpServletRequest request = ctx.getHttpServletRequest();
    PermissionableObjectDWR asset = new PermissionableObjectDWR();
    PermissionAPI permAPI = APILocator.getPermissionAPI();
    Permissionable p = null;

    asset.setId(inodeOrIdentifier);

    try {
      // Retrieving the current user
      User user = userWebAPI.getLoggedInUser(request);
      Structure hostStrucuture = StructureCache.getStructureByVelocityVarName("Host");

      if (InodeFactory.isInode(inodeOrIdentifier)) {
        Inode inode = InodeFactory.find(inodeOrIdentifier);
        p = inode;
        asset.setType(((Permissionable) inode).getClass().getName());
      } else {
        ContentletAPI contAPI = APILocator.getContentletAPI();
        Contentlet content = contAPI.find(inodeOrIdentifier, user, false);

        if (UtilMethods.isSet(content) && content.getStructureInode().equals(hostStrucuture.getInode())) {
          p = content;
          asset.setType(Host.class.getName());
        }
      }

      if(p==null) return null;

      asset.setIsFolder(p instanceof Folder);
      asset.setIsHost((p instanceof Host) || ((p instanceof Contentlet) && ((Contentlet)p).getStructureInode().equals(hostStrucuture.getInode())));
      asset.setIsParentPermissionable(p.isParentPermissionable());
      asset.setDoesUserHavePermissionsToEdit(permAPI.doesUserHavePermission(p, PermissionAPI.PERMISSION_EDIT_PERMISSIONS, user));
    } catch(DotHibernateException de) {
      throw de;
    } catch (Exception e) {
      e.printStackTrace();
View Full Code Here

    boolean EDIT_MODE = ((session.getAttribute(com.dotmarketing.util.WebKeys.EDIT_MODE_SESSION) != null) && ADMIN_MODE);
    User u = user;
    if(EDIT_MODE){
      u = backEndUser;
    }
    Permissionable fileAsset = null;
    Identifier ident = getIdentifierByInode(fileInode);
    if(ident.getAssetType().equals("contentlet")){
      try {
        fileAsset = APILocator.getContentletAPI().find(fileInode, u, false);
      } catch (DotSecurityException e) {
View Full Code Here

    permissionAPI.clearCache();
    String permissionableId = (String) map.get("permissionableId");
    String roleId = (String) map.get("roleId");
    try {
      RoleAPI roleAPI = APILocator.getRoleAPI();
      Permissionable permissionable = (Permissionable) retrievePermissionable(permissionableId);
      Role role = (Role) roleAPI.loadRoleById(roleId);
      permissionAPI.cascadePermissionUnder(permissionable, role);
    } catch (DotDataException e) {
      Logger.error(this, e.getMessage(), e);
      permissionAPI.clearCache();
View Full Code Here

  private Permissionable retrievePermissionable (String assetId) throws DotDataException, DotSecurityException {
   
    UserAPI userAPI = APILocator.getUserAPI();
    HostAPI hostAPI = APILocator.getHostAPI();
   
    Permissionable perm = null;
   
    //Determining the type
   
    //Host?
    perm = hostAPI.find(assetId, userAPI.getSystemUser(), false);
   
    if(perm == null) {
      //Content?
      ContentletAPI contAPI = APILocator.getContentletAPI();
      try {
        perm = contAPI.findContentletByIdentifier(assetId, false, APILocator.getLanguageAPI().getDefaultLanguage().getId(), userAPI.getSystemUser(), false);
      } catch (DotContentletStateException e) {
      }
    }
   
    if(perm == null) {
      // is it an identifier?
      Identifier ident=APILocator.getIdentifierAPI().find(assetId);
      if(ident!=null && UtilMethods.isSet(ident.getId())) {
          if(ident.getAssetType().equals("folder"))
              perm = APILocator.getFolderAPI()
                      .findFolderByPath(ident.getURI(), ident.getHostId(), APILocator.getUserAPI().getSystemUser(), false);
          else
              perm = (Permissionable)
                      APILocator.getVersionableAPI()
                       .findWorkingVersion(assetId, APILocator.getUserAPI().getSystemUser(), false);
      }
    }

    if(perm == null || !UtilMethods.isSet(perm.getPermissionId())) {
        // is it an inode?
       
      perm = InodeFactory.getInode(assetId, Inode.class);
    }
    return perm;
View Full Code Here

    PermissionAPI permissionAPI = APILocator.getPermissionAPI();
   
    String permissionableId = (String) map.get("permissionableId");
    try {
      HibernateUtil.startTransaction();
      Permissionable permissionable = (Permissionable) retrievePermissionable(permissionableId);
      permissionAPI.resetPermissionsUnder(permissionable);
      HibernateUtil.commitTransaction();
    } catch (Exception e) {
      Logger.error(this, e.getMessage(), e);
      try {
View Full Code Here

  private Permissionable retrievePermissionable (String assetId) throws DotDataException, DotSecurityException {
   
    UserAPI userAPI = APILocator.getUserAPI();
    HostAPI hostAPI = APILocator.getHostAPI();
   
    Permissionable perm = null;
   
    //Determining the type
   
    //Host?
    perm = hostAPI.find(assetId, userAPI.getSystemUser(), false);
   
    if(perm == null) {
      //Content?
      ContentletAPI contAPI = APILocator.getContentletAPI();
      try {
        perm = contAPI.findContentletByIdentifier(assetId, false, APILocator.getLanguageAPI().getDefaultLanguage().getId(), userAPI.getSystemUser(), false);
      } catch (DotContentletStateException e) {
      }
    }
   
    if(perm == null) {
     
      DotConnect dc = new DotConnect();
      ArrayList results = new ArrayList();
      String assetType ="";
      dc.setSQL("Select asset_type from identifier where id =?");
      dc.addParam(assetId);
      ArrayList assetResult = dc.loadResults();
      if(assetResult.size()>0){
        assetType = (String) ((Map)assetResult.get(0)).get("asset_type");
      }
      if(UtilMethods.isSet(assetType)){
        dc.setSQL("select i.inode, type from inode i,"+assetType+" a where i.inode = a.inode and a.identifier = ?");
        dc.addParam(assetId);
        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);
    }
    return perm;
  }
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.