use of org.apache.archiva.redback.rbac.RbacManagerException in project archiva by apache.
the class ArchivaRbacManager method savePermission.
@Override
public Permission savePermission(Permission permission) throws RbacObjectInvalidException, RbacManagerException {
boolean allFailed = true;
Exception lastException = null;
for (RBACManager rbacManager : rbacManagersPerId.values()) {
try {
if (rbacManager.isReadOnly()) {
permission = rbacManager.savePermission(permission);
allFailed = false;
}
} catch (Exception e) {
lastException = e;
}
}
if (lastException != null && allFailed) {
throw new RbacManagerException(lastException.getMessage(), lastException);
}
return permission;
}
use of org.apache.archiva.redback.rbac.RbacManagerException in project archiva by apache.
the class ArchivaRbacManager method getAllUserAssignments.
@Override
public List<UserAssignment> getAllUserAssignments() throws RbacManagerException {
Map<String, UserAssignment> allUserAssignments = new HashMap<>();
boolean allFailed = true;
Exception lastException = null;
for (RBACManager rbacManager : rbacManagersPerId.values()) {
try {
List<UserAssignment> userAssignments = rbacManager.getAllUserAssignments();
for (UserAssignment ua : userAssignments) {
UserAssignment userAssignment = allUserAssignments.get(ua.getPrincipal());
if (userAssignment != null) {
for (String roleName : ua.getRoleNames()) {
userAssignment.addRoleName(roleName);
}
}
allUserAssignments.put(ua.getPrincipal(), ua);
}
allFailed = false;
} catch (Exception e) {
lastException = e;
}
}
if (lastException != null && allFailed) {
throw new RbacManagerException(lastException.getMessage(), lastException);
}
return new ArrayList<>(allUserAssignments.values());
}
use of org.apache.archiva.redback.rbac.RbacManagerException in project archiva by apache.
the class ArchivaRbacManager method getAllRoles.
@Override
public List<Role> getAllRoles() throws RbacManagerException {
Map<String, Role> allRoles = new HashMap<>();
boolean allFailed = true;
Exception lastException = null;
for (RBACManager rbacManager : rbacManagersPerId.values()) {
try {
List<Role> roles = rbacManager.getAllRoles();
for (Role role : roles) {
allRoles.put(role.getName(), role);
}
allFailed = false;
} catch (Exception e) {
lastException = e;
}
}
if (lastException != null && allFailed) {
throw new RbacManagerException(lastException.getMessage(), lastException);
}
return new ArrayList<>(allRoles.values());
}
use of org.apache.archiva.redback.rbac.RbacManagerException in project archiva by apache.
the class ArchivaRbacManager method roleExists.
@Override
public boolean roleExists(String name) throws RbacManagerException {
Role r = rolesCache.get(name);
if (r != null) {
return true;
}
boolean allFailed = true;
Exception lastException = null;
for (RBACManager rbacManager : rbacManagersPerId.values()) {
try {
boolean exists = rbacManager.roleExists(name);
if (exists) {
return true;
}
} catch (Exception e) {
lastException = e;
}
}
if (lastException != null && allFailed) {
throw new RbacManagerException(lastException.getMessage(), lastException);
}
return false;
}
use of org.apache.archiva.redback.rbac.RbacManagerException 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;
}
Aggregations