Examples of PermissionAPI


Examples of com.dotmarketing.business.PermissionAPI

      while(!done) {
        dh.setFirstResult(internalOffset);
        dh.setMaxResults(internalLimit);
        resultList = dh.list();
        PermissionAPI permAPI = APILocator.getPermissionAPI();
        toReturn.addAll(permAPI.filterCollection(resultList, PermissionAPI.PERMISSION_READ, false, user));
        if(countLimit > 0 && toReturn.size() >= countLimit + offset)
          done = true;
        else if(resultList.size() < internalLimit)
          done = true;
View Full Code Here

Examples of com.dotmarketing.business.PermissionAPI

        boolean EDIT_MODE = false;
        boolean PREVIEW_MODE = false;

        LogFactory.getLog(this.getClass()).debug("CMS Filter URI = " + uri);

        PermissionAPI permissionAPI = APILocator.getPermissionAPI();

        if (session != null) {
            // struts crappy messages have to be retrived from session
            if (session.getAttribute(Globals.ERROR_KEY) != null) {
                request.setAttribute(Globals.ERROR_KEY, session.getAttribute(Globals.ERROR_KEY));
                session.removeAttribute(Globals.ERROR_KEY);
            }
            if (session.getAttribute(Globals.MESSAGE_KEY) != null) {
                request.setAttribute(Globals.MESSAGE_KEY, session.getAttribute(Globals.MESSAGE_KEY));
                session.removeAttribute(Globals.MESSAGE_KEY);
            }
            // set the preview mode
            ADMIN_MODE = (session.getAttribute(com.dotmarketing.util.WebKeys.ADMIN_MODE_SESSION) != null);
            PREVIEW_MODE = (session.getAttribute(com.dotmarketing.util.WebKeys.PREVIEW_MODE_SESSION) != null && ADMIN_MODE);
            EDIT_MODE = (session.getAttribute(com.dotmarketing.util.WebKeys.EDIT_MODE_SESSION) != null && ADMIN_MODE);

            if (request.getParameter("livePage") != null && request.getParameter("livePage").equals("1")) {
                PREVIEW_MODE = false;
                EDIT_MODE = false;
                session.setAttribute(com.dotmarketing.util.WebKeys.PREVIEW_MODE_SESSION, null);
                request.setAttribute(com.dotmarketing.util.WebKeys.PREVIEW_MODE_SESSION, null);
                session.setAttribute(com.dotmarketing.util.WebKeys.EDIT_MODE_SESSION, null);
                request.setAttribute(com.dotmarketing.util.WebKeys.EDIT_MODE_SESSION, null);
                LogFactory.getLog(this.getClass()).debug("CMS FILTER Cleaning PREVIEW_MODE_SESSION LIVE!!!!");

            }

            if (request.getParameter("previewPage") != null && request.getParameter("previewPage").equals("1")) {
                PREVIEW_MODE = false;
                EDIT_MODE = true;
                session.setAttribute(com.dotmarketing.util.WebKeys.PREVIEW_MODE_SESSION, null);
                request.setAttribute(com.dotmarketing.util.WebKeys.PREVIEW_MODE_SESSION, null);
                session.setAttribute(com.dotmarketing.util.WebKeys.EDIT_MODE_SESSION, "true");
                request.setAttribute(com.dotmarketing.util.WebKeys.EDIT_MODE_SESSION, "true");
                LogFactory.getLog(this.getClass()).debug("CMS FILTER Cleaning EDIT_MODE_SESSION PREVIEW!!!!");
            }

            if (request.getParameter("previewPage") != null && request.getParameter("previewPage").equals("2")) {
                PREVIEW_MODE = true;
                EDIT_MODE = false;
                session.setAttribute(com.dotmarketing.util.WebKeys.PREVIEW_MODE_SESSION, "true");
                request.setAttribute(com.dotmarketing.util.WebKeys.PREVIEW_MODE_SESSION, "true");
                session.setAttribute(com.dotmarketing.util.WebKeys.EDIT_MODE_SESSION, null);
                request.setAttribute(com.dotmarketing.util.WebKeys.EDIT_MODE_SESSION, null);
                LogFactory.getLog(this.getClass()).debug("CMS FILTER Cleaning PREVIEW_MODE_SESSION PREVIEW!!!!");
            }
        }

        /*
         * Getting host object form the session
         */
        HostWebAPI hostWebAPI = WebAPILocator.getHostWebAPI();
        Host host;
    try {
      host = hostWebAPI.getCurrentHost(request);
    } catch (PortalException e) {
        Logger.error(this, "Unable to retrieve current request host for URI " + uri);
        throw new ServletException(e.getMessage(), e);
    } catch (SystemException e) {
        Logger.error(this, "Unable to retrieve current request host for URI  " + uri);
        throw new ServletException(e.getMessage(), e);
    } catch (DotDataException e) {
        Logger.error(this, "Unable to retrieve current request host for URI  " + uri);
        throw new ServletException(e.getMessage(), e);
    } catch (DotSecurityException e) {
        Logger.error(this, "Unable to retrieve current request host for URI  " + uri);
        throw new ServletException(e.getMessage(), e);
    }

        /*
         * If someone is trying to go right to an asset without going through
         * the cms, give them a 404
         */

        if (UtilMethods.isSet(ASSET_PATH) && uri.startsWith(ASSET_PATH)) {
            response.sendError(403, "Forbidden");
            return;
        }

        String pointer = null;
       
        boolean isVanityURL = UtilMethods.isSet(VirtualLinksCache.getPathFromCache(host.getHostname() + ":" + uri));
        if (!isVanityURL)
          isVanityURL = UtilMethods.isSet(VirtualLinksCache.getPathFromCache(uri));

        if(!uri.equals(pointer) && !uri.endsWith("/")
            && ! RegEX.contains(uri, folderPathRegEx)
            && uri.indexOf("/dotCMS/") == -1
            && !isVanityURL ) {
          Enumeration enm = req.getParameterNames();
          StringBuffer params = new StringBuffer("");
            for (; enm.hasMoreElements(); ) {
              String name = (String)enm.nextElement();
              params.append(name + "=" + req.getParameter(name));
              if(enm.hasMoreElements())
                params.append(StringPool.AMPERSAND);
            }
      response.sendRedirect(uri + "/" + (params.length() > 0 ? "?" + params : ""));
      return;
    }

        //Verify if the request is for a specific language
        Long languageId;
        if ( !UtilMethods.isSet( req.getParameter( "language_id" ) ) ) {
            languageId = APILocator.getLanguageAPI().getDefaultLanguage().getId();
        } else {
            languageId = Long.parseLong( req.getParameter( "language_id" ) );
        }

        /* if edit mode */
        if (PREVIEW_MODE || EDIT_MODE) {
      try {
        pointer = WorkingCache.getPathFromCache(uri, host);

        if(!UtilMethods.isSet(pointer)){//DOTCMS-7062
          pointer = LiveCache.getPathFromCache(uri, host);
        }

            if (!UtilMethods.isSet(pointer)
                && !uri.equals("/")
                && (uri.endsWith(dotExtension)
                    || InodeUtils.isSet(APILocator
                        .getFolderAPI().findFolderByPath(uri, host,APILocator.getUserAPI().getSystemUser(),false)
                        .getInode()))) {
               
              String url = uri;
                if (!uri.endsWith(dotExtension)) {
                    url += "index" + dotExtension;
                }
                request.getRequestDispatcher("/html/portlet/ext/htmlpages/page_not_found_404.jsp?url=" + url + "&hostId=" + host.getIdentifier()).forward(
                        req, res);
                return;
            }
            LogFactory.getLog(this.getClass()).debug("CMS preview pointer = " + uri + ":" + pointer);
      } catch (Exception e) {
        Logger.debug(this.getClass(), "Can't find pointer " + uri);
      }
            /* if live mode */
        } else {

      try {
                pointer = LiveCache.getPathFromCache( uri, host, languageId );
            } catch (Exception e) {
        Logger.debug(this.getClass(), "Can't find pointer " + uri);
        try {
          if(WebAPILocator.getUserWebAPI().isLoggedToBackend(request)){
            response.setHeader( "Pragma", "no-cache" );
            response.setHeader( "Cache-Control", "no-cache" );
            response.setDateHeader( "Expires", 0 );
            response.sendError(404);
            return;
          }
        } catch (Exception e1) {
          Logger.debug(this.getClass(), "Can't find pointer " + uri);
        }
      }
            // If the cache hits the db the connection needs to be manually
            // closed
            try {
        HibernateUtil.closeSession();
      } catch (DotHibernateException e) {
        Logger.error(CMSFilter.class, e.getMessage(), e);
      }
            LogFactory.getLog(this.getClass()).debug("CMS live pointer = " + uri + ":" + pointer);

        }

        /*
         * Checking if host is active
         */
        boolean hostlive;
        try {
            hostlive = APILocator.getVersionableAPI().hasLiveVersion(host);
        } catch (Exception e1) {
            throw new ServletException(e1);
        }
        if(!ADMIN_MODE && !hostlive) {
          //Checking if it has a maintenance virtual link
          pointer = (String) VirtualLinksCache.getPathFromCache(host.getHostname() + ":/cmsMaintenancePage");
          if(pointer == null) {
            try {
          response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, LanguageUtil.get(company.getCompanyId(), company.getLocale(), "server-unavailable-error-message"));
        } catch (LanguageException e) {
          Logger.error(CMSFilter.class, e.getMessage(), e);
          response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE);
        }
            return;
          }

        }

        // if absolute link somewhere else
        if (UtilMethods.isSet(pointer) && (pointer.startsWith(httpProtocol) || pointer.startsWith(httpsProtocol))) {
            response.sendRedirect(pointer);
            return;
        }

        // virtual links only after other links
        if (!UtilMethods.isSet(pointer)) {
            if (uri.endsWith("/"))
                uri = uri.substring(0, uri.length() - 1);
            pointer = VirtualLinksCache.getPathFromCache(host.getHostname() + ":" + uri);

            if (!UtilMethods.isSet(pointer)) {
                pointer = VirtualLinksCache.getPathFromCache(uri);
            }

            if (UtilMethods.isSet(pointer)) { // is it a virtual link?
                LogFactory.getLog(this.getClass()).debug("CMS found virtual link pointer = " + uri + ":" + pointer);
                boolean external = false;
                String auxPointer = pointer;
                if(auxPointer.indexOf("http://") != -1 || auxPointer.indexOf("https://") != -1)
                {
                  try {
                    User systemUser = APILocator.getUserAPI().getSystemUser();

                    auxPointer = auxPointer.replace("https://","");
                    auxPointer = auxPointer.replace("http://","");
                    int startIndex = 0;
                    int endIndex = auxPointer.indexOf("/");
                    if(startIndex < endIndex)
                    {
                      String localHostName = auxPointer.substring(startIndex,endIndex);
                      Host localHost = hostWebAPI.findByName(localHostName, systemUser, false);
                      if(localHost ==null || !InodeUtils.isSet(localHost.getInode())){
                        external=true;
                      }
                    }
                    else
                    {
                      external = true;
                    }
                  } catch (DotSecurityException e) {
                    Logger.error(this, "Unable to retrieve host were the virtual link " + uri + " is pointing.", e);
                    throw new ServletException(e.getMessage(), e);
                  } catch (DotDataException e) {
                    Logger.error(this, "Unable to retrieve host were the virtual link " + uri + " is pointing.", e);
                    throw new ServletException(e.getMessage(), e);
          }
                }
                if (!external) {
                  String ext = Config.getStringProperty("VELOCITY_PAGE_EXTENSION");
                  if (!pointer.contains("." + ext + "?")) {
                    boolean isDotPage = true;
                    if(!pointer.contains("." + ext) && !pointer.endsWith("/") && pointer.contains("/")){

                      if(pointer.substring(pointer.lastIndexOf("/")).contains(".")){
                        uri = pointer;
                        try {
                  pointer = LiveCache.getPathFromCache(uri, host);
                } catch (Exception e) {
                  Logger.debug(this.getClass(), "Can't find pointer " + uri);
                }
                isDotPage = false;
                      }
                    }

                    if(isDotPage){
                      if (pointer.contains("?") && !pointer.contains("#")) {
                        int index = pointer.indexOf('?');
                        String indexPage = "index." + ext;
                        if ((0 < index) && (pointer.charAt(index-1) != '/'))
                          indexPage = "/" + indexPage;

                        pointer = pointer.substring(0, index) + indexPage + pointer.substring(index);
                      } else {
                        if(pointer.endsWith("/")){
                          pointer = pointer.substring(0, pointer.lastIndexOf("/"));
                        }
                        if(!pointer.startsWith("/") && !(pointer.indexOf("http://") != -1 || pointer.indexOf("https://")!=-1)){
                          pointer = "/" + pointer;
                        }
                        String endSlash = pointer.substring(pointer.lastIndexOf("/"));
                        if (!pointer.endsWith("." + ext) && !endSlash.contains("#")) {
                          if (!pointer.endsWith("/"))
                            pointer += "/";
                          pointer += "index." + ext;
                        }else if(endSlash.contains("#") && !(pointer.indexOf("http://") != -1 || pointer.indexOf("https://")!=-1)){
                          String reqUrl = request.getRequestURL().toString();
                          pointer = reqUrl.replaceAll(uri.endsWith("/")?uri:uri+"/", pointer);
                        }
                      }
                    }

                  }else if(pointer.contains("#") && !(pointer.indexOf("http://") != -1 || pointer.indexOf("https://")!=-1)){
                    String endSlash = pointer.substring(pointer.lastIndexOf("/"));
                    if(endSlash.contains("#")){
                      String reqUrl = request.getRequestURL().toString();
                      pointer = reqUrl.replaceAll(uri.endsWith("/")?uri:uri+"/", pointer);
                    }

                  }
                }
          /*
           * Apply Rules to pointer
           */
        JBossRulesUtils.checkObjectRulesFromXML(request);
            }

        }
        if (UtilMethods.isSet(pointer) && (pointer.startsWith(httpProtocol) || pointer.startsWith(httpsProtocol))) {
            response.sendRedirect(pointer);
            return;
        }

        if (UtilMethods.isSet(pointer)) {

            if (!endInTheVelocityPageExtension(pointer)) {
                // Validate the permission
                User user = null;
                try {
                    if (session != null)
                        user = (com.liferay.portal.model.User) session.getAttribute(com.dotmarketing.util.WebKeys.CMS_USER);
                } catch (Exception nsue) {
                    Logger.warn(this, "Exception trying to getUser: " + nsue.getMessage(), nsue);
                }

                if(user==null) {
                  try {
            user = com.liferay.portal.util.PortalUtil.getUser(request);
          } catch (Exception nsue) {
                      Logger.warn(this, "Exception trying to getUser: " + nsue.getMessage(), nsue);
                  }
                }

                boolean signedIn = false;
                if (user != null) {
                    signedIn = true;
                }

                Identifier ident = null;

                try {
                  ident =APILocator.getIdentifierAPI().find(host,uri);
                  /**
                   * Build a fake proxy file object so we
                   * can get inheritable permissions on it
                   * without having to hit cache or db
                   */
                  boolean canRead = false;
                  if(ident.getAssetType().equals("contentlet")){
                    try{
                            ContentletVersionInfo cinfo = APILocator.getVersionableAPI().getContentletVersionInfo( ident.getId(), languageId );
                            //If we did not find a version with for given language lets try with the default language
                            if ( !UtilMethods.isSet( cinfo.getIdentifier() ) && !languageId.equals( APILocator.getLanguageAPI().getDefaultLanguage().getId() ) ) {
                                languageId = APILocator.getLanguageAPI().getDefaultLanguage().getId();
                                cinfo = APILocator.getVersionableAPI().getContentletVersionInfo( ident.getId(), languageId );
                            }

                            Contentlet proxy  = new Contentlet();
                      if(UtilMethods.isSet(cinfo.getLiveInode()))
                        proxy = APILocator.getContentletAPI().find(cinfo.getLiveInode(), user, true);
                      else if(WebAPILocator.getUserWebAPI().isLoggedToBackend(request))
                        proxy = APILocator.getContentletAPI().find(cinfo.getWorkingInode(), user, true);
                      canRead = UtilMethods.isSet(proxy.getInode());
                    }catch(Exception e){
                Logger.warn(this, "Unable to find file asset contentlet with identifier " + ident.getId(), e);
                    }

                  }else{
                    com.dotmarketing.portlets.files.model.File f = new com.dotmarketing.portlets.files.model.File();
                        (f).setIdentifier(ident.getInode());
                        canRead = permissionAPI.doesUserHavePermission(f, PermissionAPI.PERMISSION_READ, user, true);
              f = null;
                  }

          if (!canRead) {

View Full Code Here

Examples of com.dotmarketing.business.PermissionAPI

  //Adding / Saving User Filter
  private void _save(ActionForm form, ActionRequest req, ActionResponse res)
  throws Exception {
    User user = _getUser(req);
    PermissionAPI perAPI = APILocator.getPermissionAPI();
    UserManagerListSearchForm mlForm = (UserManagerListSearchForm) form;
    UserFilter uf;
    if (InodeUtils.isSet(mlForm.getUserFilterListInode())) {
      uf = (UserFilter) InodeFactory.getInode(mlForm.getUserFilterListInode(), UserFilter.class);

      //removing permissions on the user filter\
      perAPI.removePermissions(uf);
    }
    else {
      uf = new UserFilter();
    }

    BeanUtils.copyProperties(uf, mlForm);
    uf.setCategories(mlForm.getCategoriesStr());
    HibernateUtil.startTransaction();
    HibernateUtil.saveOrUpdate(uf);
    HibernateUtil.commitTransaction();

    // read permission
    String[] readPermissions = req.getParameterValues("readRole");
    // write permission
    String[] writePermissions = req.getParameterValues("writeRole");
    //adding roles to user filter
    Permission permission = null;
    if (readPermissions != null) {
      for (int n = 0; n < readPermissions.length; n++) {
        permission = new Permission(uf.getInode(), readPermissions[n], PERMISSION_READ);
        perAPI.save(permission, uf, user, false);
      }
    }

    if (writePermissions != null) {
      for (int n = 0; n < writePermissions.length; n++) {
        permission = new Permission(uf.getInode(), writePermissions[n],  PERMISSION_WRITE);
        perAPI.save(permission, uf, user, false);
      }
    }
    mlForm.setUserFilterListInode(uf.getInode());
    SessionMessages.add(req, "message", "message.userfilter.save");
  }
View Full Code Here

Examples of com.dotmarketing.business.PermissionAPI

    UserFilter uf;
    if (InodeUtils.isSet(mlForm.getUserFilterListInode())) {
      uf = (UserFilter) InodeFactory.getInode(mlForm.getUserFilterListInode(), UserFilter.class);

      //removing permissions on the user filter
      PermissionAPI perAPI = APILocator.getPermissionAPI();
      perAPI.removePermissions(uf);
     
      InodeFactory.deleteInode(uf);
      HibernateUtil.flush();
      HibernateUtil.closeSession();
      SessionMessages.add(req, "message", "message.userfilter.success.delete");
View Full Code Here

Examples of com.dotmarketing.business.PermissionAPI

            TagFactory.deleteTagInode(tag);
            TagFactory.deleteTag(retrievedTag.getTagId());
        }

        if(InodeUtils.isSet(userProxy.getInode())) {
          PermissionAPI perAPI = APILocator.getPermissionAPI();
          perAPI.removePermissions(userProxy);
          // deletes user proxy
          InodeFactory.deleteInode(userProxy);
        }
        // deletes liferay user
        APILocator.getUserAPI().delete(APILocator.getUserAPI().loadUserById(userId,APILocator.getUserAPI().getSystemUser(),false),com.dotmarketing.business.APILocator.getUserAPI().getSystemUser(), false);
View Full Code Here

Examples of com.dotmarketing.business.PermissionAPI

      while(!done) {
        dh.setFirstResult(internalOffset);
        dh.setMaxResults(internalLimit);
        resultList = dh.list();
        PermissionAPI permAPI = APILocator.getPermissionAPI();
        toReturn.addAll(permAPI.filterCollection(resultList, PermissionAPI.PERMISSION_READ, false, user));
        if(countLimit > 0 && toReturn.size() >= countLimit + offset)
          done = true;
        else if(resultList.size() < internalLimit)
          done = true;
View Full Code Here

Examples of com.dotmarketing.business.PermissionAPI

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

    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

Examples of com.dotmarketing.business.PermissionAPI

      //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);
      }
      HibernateUtil.commitTransaction();
    } catch (Exception e) {
        Logger.warn(this, e.getMessage(), e);
      HibernateUtil.rollbackTransaction();
View Full Code Here

Examples of com.dotmarketing.business.PermissionAPI

      //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

Examples of com.dotmarketing.business.PermissionAPI

          //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();
        } catch (Exception e) {
          HibernateUtil.rollbackTransaction();
          throw e;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.