Search in sources :

Example 16 with RbacManagerException

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

the class ArchivaRbacManager method getAllOperations.

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

Example 17 with RbacManagerException

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

the class ArchivaRbacManager method removeOperation.

@Override
public void removeOperation(Operation operation) throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException {
    boolean allFailed = true;
    Exception lastException = null;
    for (RBACManager rbacManager : rbacManagersPerId.values()) {
        try {
            rbacManager.removeOperation(operation);
            operationsCache.remove(operation.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 18 with RbacManagerException

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

the class ArchivaRbacManager method saveRole.

@Override
public Role saveRole(Role role) throws RbacObjectInvalidException, RbacManagerException {
    Exception lastException = null;
    boolean allFailed = true;
    for (RBACManager rbacManager : rbacManagersPerId.values()) {
        try {
            if (!rbacManager.isReadOnly()) {
                role = rbacManager.saveRole(role);
                allFailed = false;
            }
        } catch (Exception e) {
            lastException = e;
        }
    }
    if (lastException != null && allFailed) {
        throw new RbacManagerException(lastException.getMessage(), lastException);
    }
    return role;
}
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 19 with RbacManagerException

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

the class ArchivaRbacManager method removeRole.

@Override
public void removeRole(Role role) throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException {
    boolean allFailed = true;
    Exception lastException = null;
    for (RBACManager rbacManager : rbacManagersPerId.values()) {
        try {
            rbacManager.removeRole(role);
            rolesCache.remove(role.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 20 with RbacManagerException

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

the class ArchivaRbacManager method saveUserAssignment.

@Override
public UserAssignment saveUserAssignment(UserAssignment userAssignment) throws RbacObjectInvalidException, RbacManagerException {
    boolean allFailed = true;
    Exception lastException = null;
    for (RBACManager rbacManager : rbacManagersPerId.values()) {
        try {
            if (!rbacManager.isReadOnly()) {
                userAssignment = rbacManager.saveUserAssignment(userAssignment);
                allFailed = false;
            }
        } catch (Exception e) {
            lastException = e;
        }
    }
    if (lastException != null && allFailed) {
        throw new RbacManagerException(lastException.getMessage(), lastException);
    }
    return userAssignment;
}
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)

Aggregations

RbacManagerException (org.apache.archiva.redback.rbac.RbacManagerException)25 RepositoryAdminException (org.apache.archiva.admin.model.RepositoryAdminException)23 AbstractRBACManager (org.apache.archiva.redback.rbac.AbstractRBACManager)23 RBACManager (org.apache.archiva.redback.rbac.RBACManager)23 RbacObjectInvalidException (org.apache.archiva.redback.rbac.RbacObjectInvalidException)23 RbacObjectNotFoundException (org.apache.archiva.redback.rbac.RbacObjectNotFoundException)23 ArrayList (java.util.ArrayList)7 HashMap (java.util.HashMap)5 LinkedHashMap (java.util.LinkedHashMap)5 UserAssignment (org.apache.archiva.redback.rbac.UserAssignment)5 Role (org.apache.archiva.redback.rbac.Role)3 Operation (org.apache.archiva.redback.rbac.Operation)2 Permission (org.apache.archiva.redback.rbac.Permission)2 Resource (org.apache.archiva.redback.rbac.Resource)2 ManagedRepositoryConfiguration (org.apache.archiva.configuration.ManagedRepositoryConfiguration)1 User (org.apache.archiva.redback.users.User)1 UserManager (org.apache.archiva.redback.users.UserManager)1 UserManagerException (org.apache.archiva.redback.users.UserManagerException)1 UserNotFoundException (org.apache.archiva.redback.users.UserNotFoundException)1