use of org.apache.sling.jackrabbit.usermanager.DeleteGroup in project sling by apache.
the class DeleteAuthorizableServlet method deleteGroup.
/* (non-Javadoc)
* @see org.apache.sling.jackrabbit.usermanager.DeleteGroup#deleteGroup(javax.jcr.Session, java.lang.String, java.util.List)
*/
public void deleteGroup(Session jcrSession, String name, List<Modification> changes) throws RepositoryException {
Group group;
UserManager userManager = AccessControlUtil.getUserManager(jcrSession);
Authorizable authorizable = userManager.getAuthorizable(name);
if (authorizable instanceof Group) {
group = (Group) authorizable;
} else {
throw new ResourceNotFoundException("Group to delete could not be determined");
}
String groupPath = AuthorizableResourceProvider.SYSTEM_USER_MANAGER_GROUP_PREFIX + group.getID();
group.remove();
changes.add(Modification.onDeleted(groupPath));
}
use of org.apache.sling.jackrabbit.usermanager.DeleteGroup in project sling by apache.
the class DeleteAuthorizableServlet method handleOperation.
/*
* (non-Javadoc)
* @see
* org.apache.sling.jackrabbit.usermanager.post.AbstractAuthorizablePostServlet
* #handleOperation(org.apache.sling.api.SlingHttpServletRequest,
* org.apache.sling.api.servlets.HtmlResponse, java.util.List)
*/
@Override
protected void handleOperation(SlingHttpServletRequest request, AbstractPostResponse response, List<Modification> changes) throws RepositoryException {
Session session = request.getResourceResolver().adaptTo(Session.class);
Resource resource = request.getResource();
String[] applyTo = request.getParameterValues(SlingPostConstants.RP_APPLY_TO);
if (applyTo != null) {
deleteAuthorizables(session, resource, applyTo, changes);
} else {
Authorizable item = resource.adaptTo(Authorizable.class);
if (item == null) {
String msg = "Missing source " + resource.getPath() + " for delete";
response.setStatus(HttpServletResponse.SC_NOT_FOUND, msg);
throw new ResourceNotFoundException(msg);
} else {
if (item instanceof User) {
deleteUser(session, item.getID(), changes);
} else if (item instanceof Group) {
deleteGroup(session, item.getID(), changes);
}
}
}
}
Aggregations