use of com.cognifide.cq.cqsm.api.exceptions.ActionExecutionException in project APM by Cognifide.
the class AuthorizablesUtils method getGroupIfExists.
// *************************** GROUP UTILS *************************************
public static Group getGroupIfExists(Context context, String id) throws RepositoryException, ActionExecutionException {
if (checkIfRemoved(context, id)) {
return null;
}
Authorizable authorizable = context.getAuthorizables().get(id);
if (authorizable == null) {
authorizable = context.getUserManager().getAuthorizable(id);
}
if (authorizable == null) {
return null;
}
if (authorizable instanceof User) {
throw new ActionExecutionException("Authorizable with id " + id + " exists but is a user not a group");
}
context.getAuthorizables().put(id, authorizable);
return (Group) authorizable;
}
use of com.cognifide.cq.cqsm.api.exceptions.ActionExecutionException in project APM by Cognifide.
the class AuthorizablesUtils method getUser.
public static User getUser(Context context, String id) throws ActionExecutionException, RepositoryException {
if (checkIfRemoved(context, id)) {
throw new ActionExecutionException("User with id " + id + " not found");
}
Authorizable authorizable = context.getAuthorizables().get(id);
if (authorizable == null) {
authorizable = context.getUserManager().getAuthorizable(id);
}
if (authorizable == null) {
throw new ActionExecutionException("User with id " + id + " not found");
}
if (authorizable instanceof Group) {
throw new ActionExecutionException("Authorizable with id " + id + " exists but is a group not a user");
}
context.getAuthorizables().put(id, authorizable);
return (User) authorizable;
}
Aggregations