Search in sources :

Example 1 with Permission

use of org.apache.archiva.redback.rbac.Permission in project archiva by apache.

the class ArchivaRbacManager method getAllPermissions.

@Override
public List<Permission> getAllPermissions() throws RbacManagerException {
    Map<String, Permission> allPermissions = new HashMap<>();
    boolean allFailed = true;
    Exception lastException = null;
    for (RBACManager rbacManager : rbacManagersPerId.values()) {
        try {
            List<Permission> permissions = rbacManager.getAllPermissions();
            for (Permission p : permissions) {
                allPermissions.put(p.getName(), p);
            }
            allFailed = false;
        } catch (Exception e) {
            lastException = e;
        }
    }
    if (lastException != null && allFailed) {
        throw new RbacManagerException(lastException.getMessage(), lastException);
    }
    return new ArrayList<>(allPermissions.values());
}
Also used : RbacManagerException(org.apache.archiva.redback.rbac.RbacManagerException) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Permission(org.apache.archiva.redback.rbac.Permission) ArrayList(java.util.ArrayList) AbstractRBACManager(org.apache.archiva.redback.rbac.AbstractRBACManager) RBACManager(org.apache.archiva.redback.rbac.RBACManager) RbacObjectNotFoundException(org.apache.archiva.redback.rbac.RbacObjectNotFoundException) RbacManagerException(org.apache.archiva.redback.rbac.RbacManagerException) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException) RbacObjectInvalidException(org.apache.archiva.redback.rbac.RbacObjectInvalidException)

Example 2 with Permission

use of org.apache.archiva.redback.rbac.Permission in project archiva by apache.

the class ArchivaRbacManager method getPermission.

@Override
public Permission getPermission(String permissionName) throws RbacObjectNotFoundException, RbacManagerException {
    Permission el = permissionsCache.get(permissionName);
    if (el != null) {
        return el;
    }
    Exception lastException = null;
    for (RBACManager rbacManager : rbacManagersPerId.values()) {
        try {
            Permission p = rbacManager.getPermission(permissionName);
            if (p != null) {
                permissionsCache.put(permissionName, p);
                return p;
            }
        } catch (Exception e) {
            lastException = e;
        }
    }
    if (lastException != null) {
        throw new RbacManagerException(lastException.getMessage(), lastException);
    }
    return null;
}
Also used : RbacManagerException(org.apache.archiva.redback.rbac.RbacManagerException) Permission(org.apache.archiva.redback.rbac.Permission) AbstractRBACManager(org.apache.archiva.redback.rbac.AbstractRBACManager) RBACManager(org.apache.archiva.redback.rbac.RBACManager) RbacObjectNotFoundException(org.apache.archiva.redback.rbac.RbacObjectNotFoundException) RbacManagerException(org.apache.archiva.redback.rbac.RbacManagerException) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException) RbacObjectInvalidException(org.apache.archiva.redback.rbac.RbacObjectInvalidException)

Aggregations

RepositoryAdminException (org.apache.archiva.admin.model.RepositoryAdminException)2 AbstractRBACManager (org.apache.archiva.redback.rbac.AbstractRBACManager)2 Permission (org.apache.archiva.redback.rbac.Permission)2 RBACManager (org.apache.archiva.redback.rbac.RBACManager)2 RbacManagerException (org.apache.archiva.redback.rbac.RbacManagerException)2 RbacObjectInvalidException (org.apache.archiva.redback.rbac.RbacObjectInvalidException)2 RbacObjectNotFoundException (org.apache.archiva.redback.rbac.RbacObjectNotFoundException)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1