Package com.baasbox.exception

Examples of com.baasbox.exception.RoleNotFoundException



    public static ODocument grantPermissionToRole(String id,Permissions permission, String rolename)
        throws RoleNotFoundException, FileNotFoundException, SqlInjectionException, InvalidModelException {
      ORole role=RoleDao.getRole(rolename);
      if (role==null) throw new RoleNotFoundException(rolename);
      ODocument doc = getById(id);
      if (doc==null) throw new FileNotFoundException(id);
      return PermissionsHelper.grant(doc, permission, role);
    }
View Full Code Here



    public static ODocument revokePermissionToRole(String id,
        Permissions permission, String rolename) throws RoleNotFoundException, FileNotFoundException, SqlInjectionException, InvalidModelException  {
      ORole role=RoleDao.getRole(rolename);
      if (role==null) throw new RoleNotFoundException(rolename);
      ODocument doc = getById(id);
      if (doc==null) throw new FileNotFoundException(id);
      return PermissionsHelper.revoke(doc, permission, role);
   
View Full Code Here

    return PermissionsHelper.revoke(doc, permission, user);
  }

  public static ODocument grantPermissionToRole(String collectionName, String rid, Permissions permission, String rolename) throws RoleNotFoundException, IllegalArgumentException, InvalidCollectionException, InvalidModelException, DocumentNotFoundException {
    ORole role=RoleDao.getRole(rolename);
    if (role==null) throw new RoleNotFoundException(rolename);
    ODocument doc = get(collectionName, rid);
    if (doc==null) throw new DocumentNotFoundException(rid);
        return PermissionsHelper.grant(doc, permission, role);
  }
View Full Code Here

        return PermissionsHelper.grant(doc, permission, role);
  }

  public static ODocument revokePermissionToRole(String collectionName, String rid, Permissions permission, String rolename) throws  IllegalArgumentException, InvalidCollectionException, InvalidModelException, DocumentNotFoundException, RoleNotFoundException {
    ORole role=RoleDao.getRole(rolename);
    if (role==null) throw new RoleNotFoundException(rolename);
    ODocument doc = get(collectionName, rid);
    if (doc==null) throw new DocumentNotFoundException(rid);
    return PermissionsHelper.revoke(doc, permission, role);
  }
View Full Code Here

   * @throws RoleNotFoundException if inehritedRole does not exist
   * @throws RoleAlreadyExistsException if the 'name' role already exists
   */
  public static void createRole(String name, String inheritedRole, String description) throws RoleNotFoundException, RoleAlreadyExistsException{
    if (!RoleDao.exists(inheritedRole)) {
      RoleNotFoundException e = new RoleNotFoundException(inheritedRole + " role does not exist!");
      e.setInehrited(true);
      throw e;
    }
    if (RoleDao.exists(name)) throw new RoleAlreadyExistsException(name + " role already exists!");
    ORole newRole = RoleDao.createRole(name, inheritedRole);
    newRole.getDocument().field(FIELD_INTERNAL,false);
View Full Code Here

   * @return
   */
  public static void editRole(String name, String inheritedRole,
      String description, String newName) throws RoleNotFoundException, RoleNotModifiableException {

    if (!RoleDao.exists(name)) throw new RoleNotFoundException(name + " role does not exist!");
    ORole role = RoleDao.getRole(name);
    ODocument roleDoc=role.getDocument();
    if (roleDoc.field(FIELD_MODIFIABLE)==Boolean.FALSE) throw new RoleNotModifiableException(name + " role is not modifiable");
    if (!StringUtils.isEmpty(inheritedRole)) {
      if (!RoleDao.exists(inheritedRole)) {
        RoleNotFoundException e = new RoleNotFoundException(inheritedRole + " role does not exist!");
        e.setInehrited(true);
        throw e;
      }
      ORole roleIn=RoleDao.getRole(inheritedRole);
      roleDoc.field(RoleDao.FIELD_INHERITED,roleIn.getDocument().getRecord());
    }
View Full Code Here

    if (description!=null) roleDoc.field(FIELD_DESCRIPTION,description);
    roleDoc.save();
  }

  public static void delete(String name) throws RoleNotFoundException, RoleNotModifiableException {
    if (!RoleDao.exists(name)) throw new RoleNotFoundException(name + " role does not exist!");
    ORole role = RoleDao.getRole(name);
    if (role.getDocument().field(FIELD_INTERNAL)==Boolean.TRUE) throw new RoleNotModifiableException("Role " + name + " cannot be deleted. It is declared like 'internal'");
    //retrieve the users belonging to that role
    UserService.moveUsersToRole(name,DefaultRoles.REGISTERED_USER.toString());
    //delete the role
View Full Code Here

TOP

Related Classes of com.baasbox.exception.RoleNotFoundException

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.