use of org.apache.archiva.redback.rbac.Role 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;
}
use of org.apache.archiva.redback.rbac.Role 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.Role 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;
}
Aggregations