Search in sources :

Example 16 with GroupResource

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;
}
Also used : ListResponse(org.gluu.oxtrust.model.scim2.ListResponse) Response(javax.ws.rs.core.Response) ListViewResponse(org.gluu.persist.model.ListViewResponse) GluuGroup(org.gluu.oxtrust.model.GluuGroup) URI(java.net.URI) GroupResource(org.gluu.oxtrust.model.scim2.group.GroupResource) SCIMException(org.gluu.oxtrust.model.exception.SCIMException) InvalidAttributeValueException(javax.management.InvalidAttributeValueException) Path(javax.ws.rs.Path) DefaultValue(javax.ws.rs.DefaultValue) HeaderParam(javax.ws.rs.HeaderParam) RefAdjusted(org.gluu.oxtrust.service.scim2.interceptor.RefAdjusted) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(com.wordnik.swagger.annotations.ApiOperation) ProtectedApi(org.gluu.oxtrust.service.filter.ProtectedApi)

Example 17 with GroupResource

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());
    }
}
Also used : Response(javax.ws.rs.core.Response) ListResponse(io.jans.scim.model.scim2.ListResponse) GroupResource(io.jans.scim.model.scim2.group.GroupResource) UserBaseTest(io.jans.scim2.client.UserBaseTest) Test(org.testng.annotations.Test)

Example 18 with GroupResource

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);
}
Also used : Response(javax.ws.rs.core.Response) ListResponse(io.jans.scim.model.scim2.ListResponse) Member(io.jans.scim.model.scim2.group.Member) GroupResource(io.jans.scim.model.scim2.group.GroupResource) UserBaseTest(io.jans.scim2.client.UserBaseTest) Test(org.testng.annotations.Test)

Example 19 with GroupResource

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());
}
Also used : Response(javax.ws.rs.core.Response) GroupResource(io.jans.scim.model.scim2.group.GroupResource) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test) BaseTest(io.jans.scim2.client.BaseTest)

Example 20 with GroupResource

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;
}
Also used : GroupResource(io.jans.scim.model.scim2.group.GroupResource)

Aggregations

GroupResource (io.jans.scim.model.scim2.group.GroupResource)13 Response (javax.ws.rs.core.Response)13 URI (java.net.URI)6 InvalidAttributeValueException (javax.management.InvalidAttributeValueException)6 DefaultValue (javax.ws.rs.DefaultValue)6 HeaderParam (javax.ws.rs.HeaderParam)6 Path (javax.ws.rs.Path)6 Produces (javax.ws.rs.Produces)6 GroupResource (org.gluu.oxtrust.model.scim2.group.GroupResource)6 GluuGroup (io.jans.scim.model.GluuGroup)5 Member (io.jans.scim.model.scim2.group.Member)5 UserResource (io.jans.scim.model.scim2.user.UserResource)5 BaseScimResource (io.jans.scim.model.scim2.BaseScimResource)4 ArrayList (java.util.ArrayList)4 Consumes (javax.ws.rs.Consumes)4 WebApplicationException (javax.ws.rs.WebApplicationException)4 GluuGroup (org.gluu.oxtrust.model.GluuGroup)4 ListViewResponse (org.gluu.persist.model.ListViewResponse)4 ApiOperation (com.wordnik.swagger.annotations.ApiOperation)3 DuplicateEntryException (io.jans.orm.exception.operation.DuplicateEntryException)3