Search in sources :

Example 1 with RbacObjectNotFoundException

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

the class ArchivaRbacManager method removePermission.

@Override
public void removePermission(Permission permission) throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException {
    boolean allFailed = true;
    Exception lastException = null;
    for (RBACManager rbacManager : rbacManagersPerId.values()) {
        try {
            rbacManager.removePermission(permission);
            permissionsCache.remove(permission.getName());
            allFailed = false;
        } catch (Exception e) {
            lastException = e;
        }
    }
    if (lastException != null && allFailed) {
        throw new RbacManagerException(lastException.getMessage(), lastException);
    }
}
Also used : RbacManagerException(org.apache.archiva.redback.rbac.RbacManagerException) 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 RbacObjectNotFoundException

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

the class ArchivaRbacManager method getRole.

@Override
public Role getRole(String roleName) throws RbacObjectNotFoundException, RbacManagerException {
    Role el = rolesCache.get(roleName);
    if (el != null) {
        return el;
    }
    Exception lastException = null;
    for (RBACManager rbacManager : rbacManagersPerId.values()) {
        try {
            Role role = rbacManager.getRole(roleName);
            if (role != null) {
                rolesCache.put(role.getName(), role);
                return role;
            }
        } catch (Exception e) {
            lastException = e;
        }
    }
    log.debug("cannot find role for name: ‘{}", roleName);
    if (lastException != null) {
        throw new RbacManagerException(lastException.getMessage(), lastException);
    }
    return null;
}
Also used : Role(org.apache.archiva.redback.rbac.Role) RbacManagerException(org.apache.archiva.redback.rbac.RbacManagerException) 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 3 with RbacObjectNotFoundException

use of org.apache.archiva.redback.rbac.RbacObjectNotFoundException 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)

Example 4 with RbacObjectNotFoundException

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

the class ArchivaRbacManager method removeResource.

@Override
public void removeResource(Resource resource) throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException {
    boolean allFailed = true;
    Exception lastException = null;
    for (RBACManager rbacManager : rbacManagersPerId.values()) {
        try {
            rbacManager.removeResource(resource);
            resourcesCache.remove(resource.getIdentifier());
            allFailed = false;
        } catch (Exception e) {
            lastException = e;
        }
    }
    if (lastException != null && allFailed) {
        throw new RbacManagerException(lastException.getMessage(), lastException);
    }
}
Also used : RbacManagerException(org.apache.archiva.redback.rbac.RbacManagerException) 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 5 with RbacObjectNotFoundException

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

the class ArchivaRbacManager method getOperation.

@Override
public Operation getOperation(String operationName) throws RbacObjectNotFoundException, RbacManagerException {
    Operation el = operationsCache.get(operationName);
    if (el != null) {
        return el;
    }
    Exception lastException = null;
    for (RBACManager rbacManager : rbacManagersPerId.values()) {
        try {
            Operation o = rbacManager.getOperation(operationName);
            if (o != null) {
                operationsCache.put(operationName, o);
                return o;
            }
        } 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) AbstractRBACManager(org.apache.archiva.redback.rbac.AbstractRBACManager) RBACManager(org.apache.archiva.redback.rbac.RBACManager) Operation(org.apache.archiva.redback.rbac.Operation) 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

RbacObjectNotFoundException (org.apache.archiva.redback.rbac.RbacObjectNotFoundException)11 RepositoryAdminException (org.apache.archiva.admin.model.RepositoryAdminException)10 AbstractRBACManager (org.apache.archiva.redback.rbac.AbstractRBACManager)10 RBACManager (org.apache.archiva.redback.rbac.RBACManager)10 RbacManagerException (org.apache.archiva.redback.rbac.RbacManagerException)10 RbacObjectInvalidException (org.apache.archiva.redback.rbac.RbacObjectInvalidException)10 UserAssignment (org.apache.archiva.redback.rbac.UserAssignment)2 Operation (org.apache.archiva.redback.rbac.Operation)1 Permission (org.apache.archiva.redback.rbac.Permission)1 Resource (org.apache.archiva.redback.rbac.Resource)1 Role (org.apache.archiva.redback.rbac.Role)1