use of io.jans.scim.model.scim2.group.GroupResource 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 io.jans.scim.model.scim2.group.GroupResource in project jans by JanssenProject.
the class GroupAssignUserTest method deleteGroups.
@Test(dependsOnMethods = "alterMemberships", alwaysRun = true)
public void deleteGroups() {
// Dismantle sanitarium...
for (GroupResource gr : Arrays.asList(group, group2)) if (gr != null) {
Response response = client.deleteGroup(gr.getId());
if (response.getStatus() == NO_CONTENT.getStatusCode())
logger.info("Group '{}' removed", gr.getDisplayName());
else
logger.error("Error removing group '{}'", gr.getDisplayName());
}
}
use of io.jans.scim.model.scim2.group.GroupResource in project jans by JanssenProject.
the class GroupAssignUserTest method assignToSecondGroup.
@Test(dependsOnMethods = "assignToGroup")
public void assignToSecondGroup() {
// Creates a new group with only the first patient on it
Member m = new Member();
m.setValue(friends.get(0).getId());
group2 = new GroupResource();
group2.setDisplayName("Auxiliary asylum");
group2.setMembers(Collections.singleton(m));
logger.info("Creating a secondary group...");
Response response = client.createGroup(group2, null, null);
assertEquals(response.getStatus(), CREATED.getStatusCode());
group2 = response.readEntity(GroupResource.class);
}
use of io.jans.scim.model.scim2.group.GroupResource in project jans by JanssenProject.
the class PatchGroupTest method patch1.
@Parameters("group_patch")
@Test(dependsOnMethods = "createGroup")
public void patch1(String jsonPatch) {
Response response = client.patchGroup(jsonPatch, group.getId(), null, null);
assertEquals(response.getStatus(), OK.getStatusCode());
GroupResource newerGroup = response.readEntity(groupCls);
// Verify displayName changed
assertNotEquals(newerGroup.getDisplayName(), group.getDisplayName());
// Verify externalId appeared
assertNotNull(newerGroup.getExternalId());
}
use of io.jans.scim.model.scim2.group.GroupResource in project jans by JanssenProject.
the class Scim2GroupService method updateGroup.
public GroupResource updateGroup(GluuGroup gluuGroup, GroupResource group, boolean skipMembersValidation, boolean fillMembersDisplay, String groupsUrl, String usersUrl) throws Exception {
GroupResource tmpGroup = new GroupResource();
transferAttributesToGroupResource(gluuGroup, tmpGroup, !skipMembersValidation, groupsUrl, usersUrl);
GroupResource res = (GroupResource) ScimResourceUtil.transferToResourceReplace(group, tmpGroup, extService.getResourceExtensions(group.getClass()));
res.getMeta().setLastModified(DateUtil.millisToISOString(System.currentTimeMillis()));
if (fillMembersDisplay) {
restoreMembersDisplay(tmpGroup, res);
}
replaceGroupInfo(gluuGroup, res, skipMembersValidation, fillMembersDisplay, groupsUrl, usersUrl);
return res;
}
Aggregations