Search in sources :

Example 1 with Resource

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

the class ArchivaRbacManager method getAllResources.

@Override
public List<Resource> getAllResources() throws RbacManagerException {
    Map<String, Resource> allResources = new HashMap<>();
    boolean allFailed = true;
    Exception lastException = null;
    for (RBACManager rbacManager : rbacManagersPerId.values()) {
        try {
            List<Resource> resources = rbacManager.getAllResources();
            for (Resource r : resources) {
                allResources.put(r.getIdentifier(), r);
            }
            allFailed = false;
        } catch (Exception e) {
            lastException = e;
        }
    }
    if (lastException != null && allFailed) {
        throw new RbacManagerException(lastException.getMessage(), lastException);
    }
    return new ArrayList<>(allResources.values());
}
Also used : RbacManagerException(org.apache.archiva.redback.rbac.RbacManagerException) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Resource(org.apache.archiva.redback.rbac.Resource) 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 Resource

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

the class ArchivaRbacManager method getResource.

@Override
public Resource getResource(String resourceIdentifier) throws RbacObjectNotFoundException, RbacManagerException {
    Resource el = resourcesCache.get(resourceIdentifier);
    if (el != null) {
        return el;
    }
    Exception lastException = null;
    for (RBACManager rbacManager : rbacManagersPerId.values()) {
        try {
            Resource r = rbacManager.getResource(resourceIdentifier);
            if (r != null) {
                resourcesCache.put(resourceIdentifier, r);
                return r;
            }
        } 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) Resource(org.apache.archiva.redback.rbac.Resource) 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 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 Resource (org.apache.archiva.redback.rbac.Resource)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1