public void removeAllProfiles() throws NotFoundServiceEx { List<ShortGroup> list = userGroupAdminService.getList(null, null, null); for (ShortGroup item : list) { LOGGER.warn("Removing " + item); boolean ret = userGroupAdminService.delete(item.getId()); if ( !ret ) { LOGGER.error("Could not remove " + item); } } long count = userGroupAdminService.getCount(null); if ( count > 0 ) { LOGGER.error("Items not removed"); } }
@Override public Response delete(String name, boolean cascade) throws ConflictRestEx, NotFoundRestEx, InternalErrorRestEx { try { if ( cascade ) { ruleAdminService.deleteRulesByRole(name); } else { RuleFilter filter = new RuleFilter(SpecialFilterType.ANY); filter.setRole(name); filter.getUser().setIncludeDefault(false); long cnt = ruleAdminService.count(filter); if ( cnt > 0 ) { throw new ConflictRestEx("Existing rules reference the role " + name); } } UserGroup role = userGroupAdminService.get(name); if ( ! userGroupAdminService.delete(role.getId())) { LOGGER.warn("Role not found: " + name); throw new NotFoundRestEx("Role not found: " + name); } return Response.status(Status.OK).entity("OK\n").build(); } catch (GeoFenceRestEx ex) { // already handled throw ex; } catch (NotFoundServiceEx ex) { LOGGER.warn("Role not found: " + name); throw new NotFoundRestEx("Role not found: " + name); } catch (Exception ex) { LOGGER.error(ex.getMessage(), ex); throw new InternalErrorRestEx(ex.getMessage()); } }
public void deleteProfile(UserGroupModel profile) { org.geoserver.geofence.core.model.UserGroup remote_profile = null; try { remote_profile = geofenceRemoteService.getUserGroupAdminService().get(profile.getId()); geofenceRemoteService.getUserGroupAdminService().delete(remote_profile.getId()); } catch (NotFoundServiceEx e) { logger.error(e.getLocalizedMessage(), e.getCause()); throw new ApplicationException(e.getLocalizedMessage(), e.getCause()); } }