use of org.gluu.oxtrust.model.GluuGroup in project oxTrust by GluuFederation.
the class GroupWebService method deleteGroup.
@Path("{id}")
@DELETE
@Produces({ MEDIA_TYPE_SCIM_JSON + UTF8_CHARSET_FRAGMENT, MediaType.APPLICATION_JSON + UTF8_CHARSET_FRAGMENT })
@HeaderParam("Accept")
@DefaultValue(MEDIA_TYPE_SCIM_JSON)
@ProtectedApi
@ApiOperation(value = "Delete group", notes = "Delete group (https://tools.ietf.org/html/rfc7644#section-3.6)")
public Response deleteGroup(@PathParam("id") String id) {
Response response;
try {
log.debug("Executing web service method. deleteGroup");
// group cannot be null (check associated decorator method)
GluuGroup gr = groupService.getGroupByInum(id);
scim2GroupService.deleteGroup(gr);
response = Response.noContent().build();
} catch (Exception e) {
log.error("Failure at deleteGroup 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 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);
}
use of org.gluu.oxtrust.model.GluuGroup in project oxTrust by GluuFederation.
the class GroupService method generateInumForNewGroup.
/*
* (non-Javadoc)
*
* @see org.gluu.oxtrust.ldap.service.IGroupService#generateInumForNewGroup()
*/
@Override
public String generateInumForNewGroup() throws Exception {
GluuGroup group = new GluuGroup();
String newInum = null;
String newDn = null;
do {
newInum = generateInumForNewGroupImpl();
newDn = getDnForGroup(newInum);
group.setDn(newDn);
} while (persistenceEntryManager.contains(newDn, GluuCustomPerson.class));
return newInum;
}
use of org.gluu.oxtrust.model.GluuGroup in project oxTrust by GluuFederation.
the class UpdateGroupAction method add.
public String add() throws Exception {
if (this.group != null) {
return OxTrustConstants.RESULT_SUCCESS;
}
this.update = false;
this.group = new GluuGroup();
this.group.setOwner(identity.getUser().getDn());
this.group.setOrganization(organizationService.getOrganization().getDn());
this.group.setStatus(GluuStatus.ACTIVE);
try {
this.members = getMemberDisplayNameEntiries();
} catch (BasePersistenceException ex) {
log.error("Failed to prepare lists", ex);
facesMessages.add(FacesMessage.SEVERITY_ERROR, "Failed to add new group");
conversationService.endConversation();
return OxTrustConstants.RESULT_FAILURE;
}
return OxTrustConstants.RESULT_SUCCESS;
}
Aggregations