Package com.dotmarketing.business

Examples of com.dotmarketing.business.Role


    }
    if(userId ==null){
      return false;
    }
    User mu = APILocator.getUserAPI().loadUserById(userId, APILocator.getUserAPI().getSystemUser(), true);
    Role scripting = APILocator.getRoleAPI().loadRoleByKey("Scripting Developer");
    return APILocator.getRoleAPI().doesUserHaveRole(mu, scripting);
  }
View Full Code Here


      for (String perm : whoCanUse) {
        if(!UtilMethods.isSet(perm)){
          continue;
        }

        Role test = resolveRole(perm);
        Permission p = new Permission(environment.getId(), test.getId(), PermissionAPI.PERMISSION_USE);

        boolean exists=false;
        for(Permission curr : permissions)
            exists=exists || curr.getRoleId().equals(p.getRoleId());
View Full Code Here

      for (String perm : whoCanUse) {
        if(!UtilMethods.isSet(perm)){
          continue;
        }

        Role test = resolveRole(perm);
        Permission p = new Permission(environment.getId(), test.getId(), PermissionAPI.PERMISSION_USE);

        boolean exists=false;
        for(Permission curr : permissions)
            exists=exists || curr.getRoleId().equals(p.getRoleId());
View Full Code Here

      throw new DotRuntimeException(e.getMessage());
    }
  }

  private Role resolveRole(String id) throws DotDataException{
    Role test = null;

    String newid = id.substring(id.indexOf("-") + 1, id.length());

    if(id.startsWith("user-")){
      test = APILocator.getRoleAPI().loadRoleByKey(newid);
View Full Code Here

    if ( user == null ) {
            //return responseResource.response( "{}" );
      return responseResource.response(jsonLoggedUserObject.toString());
        }

    Role myRole  = APILocator.getRoleAPI().getUserRole(user);

    //Adding logged user information to the object
    jsonLoggedUserObject.put("userId", user.getUserId());
    jsonLoggedUserObject.put("firstName", UtilMethods.escapeSingleQuotes(user.getFirstName()));
    jsonLoggedUserObject.put("lastName", UtilMethods.escapeSingleQuotes(user.getLastName()));
    jsonLoggedUserObject.put("roleId", myRole.getId());

        return responseResource.response(jsonLoggedUserObject.toString());
  }
View Full Code Here

     
      User limited=APILocator.getUserAPI().createUser(System.currentTimeMillis()+"", System.currentTimeMillis()+"@dotcms.com");
      limited.setPasswordEncrypted(true);
      limited.setPassword(Encryptor.digest("123"));
      APILocator.getUserAPI().save(limited, user, false);
      Role role=APILocator.getRoleAPI().getUserRole(limited);
     
      HibernateUtil.startTransaction();
      try {
          APILocator.getPermissionAPI().save(
              new Permission(demo.getIdentifier(),role.getId(),
              PermissionAPI.PERMISSION_CAN_ADD_CHILDREN | PermissionAPI.PERMISSION_EDIT | PermissionAPI.PERMISSION_USE),demo,user,false);
     
          APILocator.getPermissionAPI().save(
              new Permission(PermissionAPI.permissionTypes.get("FOLDERS"),demo.getIdentifier(),role.getId(),
              PermissionAPI.PERMISSION_CAN_ADD_CHILDREN|PermissionAPI.PERMISSION_EDIT|PermissionAPI.PERMISSION_USE),demo,user,false);
     
          APILocator.getPermissionAPI().save(
              new Permission(PermissionAPI.permissionTypes.get("FILES"),demo.getIdentifier(),role.getId(),
                PermissionAPI.PERMISSION_EDIT|PermissionAPI.PERMISSION_USE),demo,user,false);
     
          APILocator.getPermissionAPI().save(
              new Permission(PermissionAPI.permissionTypes.get("CONTENTLETS"),demo.getIdentifier(),role.getId(),
                PermissionAPI.PERMISSION_EDIT|PermissionAPI.PERMISSION_USE),demo,user,false);
         
          HibernateUtil.commitTransaction();
      }
      catch(Exception ex) {
View Full Code Here

            String conInode = fieldResourceName.substring(fieldResourceName.indexOf("/") + 1, fieldResourceName.indexOf("_"));

            Contentlet con = APILocator.getContentletAPI().find(conInode, APILocator.getUserAPI().getSystemUser(), true);

            User mu = userAPI.loadUserById(con.getModUser(), APILocator.getUserAPI().getSystemUser(), true);
            Role scripting =APILocator.getRoleAPI().loadRoleByKey("Scripting Developer");
            return APILocator.getRoleAPI().doesUserHaveRole(mu, scripting);
    }
    catch(Exception e){
      Logger.warn(this.getClass(), "Scripting called with error" + e);
      return false
View Full Code Here

    // loadchildren - root roles
    String response = webResource.path("/loadchildren/user/admin@dotcms.com/password/admin").get(String.class);
    assertTrue(isValidJSONArray(response));

    // loadchildren - role with children
    Role roleWithChildren = null;
    List<Role> rootRoles = null;
    try {
      rootRoles = APILocator.getRoleAPI().findRootRoles();
    } catch (DotDataException e) {
      Logger.warn(this.getClass(), "Could not validate well-formed JSON in api/role/loadchildren. Error loading root roles", e);
    }

    if(rootRoles!=null) {
      for (Role role : rootRoles) {
        if(role.getRoleChildren()!=null && !role.getRoleChildren().isEmpty()) {
          roleWithChildren = role;
          break;
        }
      }
      response = webResource.path("/loadchildren/user/admin@dotcms.com/password/admin/id/"+roleWithChildren.getId()).get(String.class);
      assertTrue(isValidJSONObject(response));
    }

  }
View Full Code Here

  }

  @Test
  public void testWellFormedJSONloadById() {
    Role intranet = null;

    try {
      intranet = APILocator.getRoleAPI().findRoleByName("Intranet", null);
    } catch (DotDataException e) {
      Logger.warn(this.getClass(), "Could not validate well-formed JSON in api/role/loadbyid. Error loading role", e);
    }

    String response = webResource.path("/loadbyid/user/admin@dotcms.com/password/admin/id/"+intranet.getId()).get(String.class);
    assertTrue(isValidJSONObject(response));
  }
View Full Code Here

    Environment environment = new Environment();
    environment.setName( "TestEnvironment_" + String.valueOf( new Date().getTime() ) );
    environment.setPushToAll( false );

    //Find the roles of the admin user
    Role role = APILocator.getRoleAPI().loadRoleByKey( adminUser.getUserId() );

    //Create the permissions for the environment
    List<Permission> permissions = new ArrayList<Permission>();
    Permission p = new Permission( environment.getId(), role.getId(), PermissionAPI.PERMISSION_USE );
    permissions.add( p );

    //Create a environment
    environmentAPI.saveEnvironment( environment, permissions );
View Full Code Here

TOP

Related Classes of com.dotmarketing.business.Role

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.