use of org.gluu.oxtrust.model.GluuGroup in project oxTrust by GluuFederation.
the class GroupWebService method getGroupById.
@Path("{id}")
@GET
@Produces({ MEDIA_TYPE_SCIM_JSON + UTF8_CHARSET_FRAGMENT, MediaType.APPLICATION_JSON + UTF8_CHARSET_FRAGMENT })
@HeaderParam("Accept")
@DefaultValue(MEDIA_TYPE_SCIM_JSON)
@ProtectedApi
@RefAdjusted
@ApiOperation(value = "Find group by id", notes = "Returns a group by id as path param (https://tools.ietf.org/html/rfc7644#section-3.4.2.1)", response = GroupResource.class)
public Response getGroupById(@PathParam("id") String id, @QueryParam(QUERY_PARAM_ATTRIBUTES) String attrsList, @QueryParam(QUERY_PARAM_EXCLUDED_ATTRS) String excludedAttrsList) {
Response response;
try {
log.debug("Executing web service method. getGroupById");
GroupResource group = new GroupResource();
// gluuGroup is not null (check associated decorator method)
GluuGroup gluuGroup = groupService.getGroupByInum(id);
scim2GroupService.transferAttributesToGroupResource(gluuGroup, group, endpointUrl, userWebService.getEndpointUrl());
String json = resourceSerializer.serialize(group, attrsList, excludedAttrsList);
response = Response.ok(new URI(group.getMeta().getLocation())).entity(json).build();
} catch (Exception e) {
log.error("Failure at getGroupById method", e);
response = getErrorResponse(Response.Status.INTERNAL_SERVER_ERROR, "Unexpected error: " + e.getMessage());
}
return response;
}
use of org.gluu.oxtrust.model.GluuGroup in project oxTrust by GluuFederation.
the class CleanUpTest method cleanUpGroups.
/**
* Test search
*
* @throws Exception
*/
// @Test
@Parameters(value = "test.keep.persons")
public void cleanUpGroups(String usedGroups) throws Exception {
System.out.println("cleanup person Test initialted ");
assertNotNull(usedGroups);
List<String> usedGroupsList = Arrays.asList(StringHelper.split(usedGroups, ",", true, false));
System.out.println("Used Groups: " + usedGroupsList);
int groupsResultSetSize = 50;
int countResults = 0;
int countRemoved = 0;
boolean existsMoreGroups = true;
while (existsMoreGroups && countResults < 10000) {
List<GluuGroup> groups = groupsService.getAllGroups();
existsMoreGroups = groups.size() == groupsResultSetSize;
countResults += groups.size();
assertNotNull(groups);
System.out.println("Found groups: " + groups.size());
System.out.println("Total groups: " + countResults);
for (GluuGroup group : groups) {
// String clientId = person.getClientId();
if (!usedGroupsList.contains(group.getInum())) {
try {
groupsService.removeGroup(group);
countRemoved++;
} catch (EntryPersistenceException ex) {
System.out.println("Failed to remove group: " + ex.getMessage());
}
}
}
}
System.out.println("Removed Persons: " + countRemoved);
}
Aggregations