Package com.dotmarketing.business

Examples of com.dotmarketing.business.RoleAPI


  public List<Map<String, Object>> loadRoleLayouts(String roleId) throws DotDataException {
    List<Map<String, Object>> list = new ArrayList<Map<String,Object>>();

    LayoutAPI layoutAPI = APILocator.getLayoutAPI();
    RoleAPI roleAPI = APILocator.getRoleAPI();
    Role role = roleAPI.loadRoleById(roleId);

    List<Layout> layouts = layoutAPI.loadLayoutsForRole(role);
    for(Layout l : layouts) {
      list.add(l.toMap());
    }
View Full Code Here


  }

  public void saveRoleLayouts(String roleId, String[] layoutIds) throws DotDataException {

    LayoutAPI layoutAPI = APILocator.getLayoutAPI();
    RoleAPI roleAPI = APILocator.getRoleAPI();
    Role role = roleAPI.loadRoleById(roleId);

    List<Layout> layouts = layoutAPI.loadLayoutsForRole(role);

    //Looking for removed layouts
    for(Layout l : layouts) {
      boolean found = false;
      for(String changedLayout: layoutIds) {
        if(changedLayout.equals(l.getId())) {
          found = true;
          break;
        }
      }
      if(!found) {
        roleAPI.removeLayoutFromRole(l, role);
      }
    }

    //Looking for added layouts
    for(String changedLayout : layoutIds) {
      boolean found = false;
      for(Layout l : layouts) {
        if(changedLayout.equals(l.getId())) {
          found = true;
          break;
        }
      }
      Layout layout = layoutAPI.loadLayout(changedLayout);
      if(!found) {
        roleAPI.addLayoutToRole(layout, role);
      }
    }
  }
View Full Code Here

    boolean respectFrontendRoles = !userWebAPI.isLoggedToBackend(request);

    Set<Object> permAssets = new HashSet<Object>();
    HashMap<String, List<Permission>> permByInode = new HashMap<String, List<Permission>>();

    RoleAPI roleAPI = APILocator.getRoleAPI();
    PermissionAPI permAPI = APILocator.getPermissionAPI();
    Host systemHost = hostAPI.findSystemHost(systemUser, false);

    Role role = roleAPI.loadRoleById(roleId);

    List<Permission> perms = permAPI.getPermissionsByRole(role, true, true);

    for(Permission p : perms) {
      List<Permission> permList = permByInode.get(p.getInode());
View Full Code Here

  }

  public List<Map<String, Object>> getCurrentCascadePermissionsJobs () throws DotDataException, DotSecurityException {
    HostAPI hostAPI = APILocator.getHostAPI();
    FolderAPI folderAPI = APILocator.getFolderAPI();
    RoleAPI roleAPI = APILocator.getRoleAPI();
    List<ScheduledTask> tasks = CascadePermissionsJob.getCurrentScheduledJobs();
    List<Map<String, Object>> scheduled = new ArrayList<Map<String, Object>>();
    for (ScheduledTask task : tasks) {
      Map<String, Object> taskMap = new HashMap<String, Object>();
      Map<String, Object> props = task.getProperties();
      String permissionableId = (String) props.get("permissionableId");
      String roleId = (String) props.get("roleId");
      if(permissionableId == null || roleId == null)
        continue;
      Host host = hostAPI.find(permissionableId, APILocator.getUserAPI().getSystemUser(), false);
      if(host == null) {
        Folder folder = APILocator.getFolderAPI().find(permissionableId, APILocator.getUserAPI().getSystemUser(), false);
        if(folder == null)
          continue;
        taskMap.put("folder", folder.getMap());
        host = hostAPI.findParentHost(folder,APILocator.getUserAPI().getSystemUser(), false);
        taskMap.put("host", host.getMap());
      } else {
        taskMap.put("host", host.getMap());
      }
      Role role = roleAPI.loadRoleById(roleId);
      if(role == null)
        continue;
      taskMap.put("role", role.toMap());
      scheduled.add(taskMap);
    }
View Full Code Here

    return scheduled;
  }

  public Map<String, Object> getRole(String roleId) throws DotDataException, DotSecurityException, PortalException, SystemException {

    RoleAPI roleAPI = APILocator.getRoleAPI();
    return roleAPI.loadRoleById(roleId).toMap();

  }
View Full Code Here

    Map<String, Object> toReturn = new HashMap<String, Object>();

    if(UtilMethods.isSet(userId)){
      UserAPI userAPI = APILocator.getUserAPI();
      User userForRole = userAPI.loadUserById(userId);
      RoleAPI roleAPI = APILocator.getRoleAPI();
      toReturn = roleAPI.getUserRole(userForRole).toMap();
    }
    return toReturn;

  }
View Full Code Here

  @SuppressWarnings("unchecked")
  private void addPermissionToRoleList(Permissionable perm, Permission p, Map<String, Map<String, Object>> roles, boolean inheritable) throws DotDataException, DotSecurityException {
    Map<String, Permissionable> inodeCache = new HashMap<String, Permissionable>();

    RoleAPI roleAPI = APILocator.getRoleAPI();
    HostAPI hostAPI = APILocator.getHostAPI();
    User systemUser = APILocator.getUserAPI().getSystemUser();
    String roleId = p.getRoleId();
    Map<String, Object> roleMap = roles.get(roleId);
    if(roleMap == null) {
      Role role = roleAPI.loadRoleById(roleId);
      if(role == null)
        return;
      roleMap = role.toMap();
      roles.put(role.getId(), roleMap);
      if(!inheritable) {
View Full Code Here

        String searchName = request.getParameter( "searchName" );

        if ( searchName == null ) searchName = "";
        String roleId = request.getParameter( "roleId" );
        RoleAPI rapi = APILocator.getRoleAPI();

        int start = 0;
        int count = 20;
        try {
            start = Integer.parseInt( request.getParameter( "start" ) );
        } catch ( Exception e ) {

        }
        try {
            count = Integer.parseInt( request.getParameter( "count" ) );
        } catch ( Exception e ) {

        }

        boolean includeFake = UtilMethods.isSet(request.getParameter( "includeFake" ))&&request.getParameter( "includeFake" ).equals("true");

        try {
            Role cmsAnon = APILocator.getRoleAPI().loadCMSAnonymousRole();

            String cmsAnonName = LanguageUtil.get( getUser(), "current-user" );
            cmsAnon.setName( cmsAnonName );
            boolean addSystemUser = false;
            if ( searchName.length() > 0 && cmsAnonName.startsWith( searchName ) ) {
                addSystemUser = true;
            }

            List<Role> roleList = new ArrayList<Role>();
            if ( UtilMethods.isSet( roleId ) ) {
                try {
                    Role r = rapi.loadRoleById( roleId );
                    if ( r != null ) {
                        if ( r.getId().equals( cmsAnon.getId() ) )
                            roleList.add( cmsAnon );
                        else
                            roleList.add( r );
                        response.getWriter().write( rolesToJson( roleList, includeFake ) );
                        return;
                    }
                } catch ( Exception e ) {

                }

            }

            while ( roleList.size() < count ) {
                List<Role> roles = rapi.findRolesByFilterLeftWildcard( searchName, start, count );
                if ( roles.size() == 0 ) {
                    break;
                }
                for ( Role role : roles ) {
                    if ( role.isUser() ) {
View Full Code Here

    PermissionAPI permissionAPI = APILocator.getPermissionAPI();
    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();
      throw new DotRuntimeException(e.getMessage(), e);
View Full Code Here

            SecurityLogger.logInfo(UserAjax.class, "unauthorized attempt to call getUserRoles by user "+loggedInUser!=null?loggedInUser.getUserId():"[not logged in]");
            throw new DotSecurityException("not authorized");
        }

    if(UtilMethods.isSet(userId)){
      RoleAPI roleAPI = APILocator.getRoleAPI();
      List<com.dotmarketing.business.Role> roles = roleAPI.loadRolesForUser(userId, false);
      for(com.dotmarketing.business.Role r : roles) {

        String DBFQN =  r.getDBFQN();

        if(DBFQN.contains(userRole.getId())) {
View Full Code Here

TOP

Related Classes of com.dotmarketing.business.RoleAPI

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.