/** * Test SCIM delete. * * @param id The ID of the resource to delete. * @throws ScimException if an error occurs. */ @Path("{id}") @DELETE public void delete(@PathParam("id") final String id) throws ScimException { UserResource found = users.remove(id); if(found == null) { throw new ResourceNotFoundException("No resource with ID " + id); } }
/** * Test SCIM retrieve by ID. * * @param id The ID of the resource to retrieve. * @param uriInfo The UriInfo. * @return The result. * @throws ScimException if an error occurs. */ @Path("{id}") @GET @Produces({MEDIA_TYPE_SCIM, MediaType.APPLICATION_JSON}) public ScimResource retrieve( @PathParam("id") final String id, @Context final UriInfo uriInfo) throws ScimException { UserResource found = users.get(id); if(found == null) { throw new ResourceNotFoundException("No resource with ID " + id); } ResourcePreparer<UserResource> resourcePreparer = new ResourcePreparer<UserResource>(RESOURCE_TYPE_DEFINITION, uriInfo); return resourcePreparer.trimRetrievedResource(found); }
/** * Test SCIM replace. * * @param id the ID of the resource to replace. * @param resource The resource to create. * @param uriInfo The UriInfo. * @return The result. * @throws ScimException if an error occurs. */ @Path("{id}") @PUT @Consumes({MEDIA_TYPE_SCIM, MediaType.APPLICATION_JSON}) @Produces({MEDIA_TYPE_SCIM, MediaType.APPLICATION_JSON}) public ScimResource replace(@PathParam("id") final String id, final UserResource resource, @Context final UriInfo uriInfo) throws ScimException { if(!users.containsKey(id)) { throw new ResourceNotFoundException("No resource with ID " + id); } users.put(id, resource); ResourcePreparer<UserResource> resourcePreparer = new ResourcePreparer<UserResource>(RESOURCE_TYPE_DEFINITION, uriInfo); return resourcePreparer.trimReplacedResource(resource, resource); }
throw new ResourceNotFoundException("No schema defined with ID " + id);
throw new ResourceNotFoundException( "No resource type defined with ID or name " + id);
/** * Test SCIM retrieve by ID. * * @param id The ID of the resource to retrieve. * @param uriInfo The UriInfo. * @return The result. * @throws ScimException if an error occurs. */ @Path("{id}") @GET @Produces({MEDIA_TYPE_SCIM, MediaType.APPLICATION_JSON}) public ScimResource retrieve( @PathParam("id") final String id, @Context final UriInfo uriInfo) throws ScimException { if(id.equals("123")) { UserResource resource = new UserResource().setUserName("test"); resource.setId("123"); resource.setDisplayName("UserDisplayName"); resource.setNickName("UserNickName"); ResourcePreparer<UserResource> resourcePreparer = new ResourcePreparer<UserResource>(RESOURCE_TYPE_DEFINITION, uriInfo); return resourcePreparer.trimRetrievedResource(resource); } throw new ResourceNotFoundException("No resource with ID " + id); } }
if(found == null) throw new ResourceNotFoundException("No resource with ID " + id);
case 401 : return new UnauthorizedException(scimError, cause); case 403 : return new ForbiddenException(scimError, cause); case 404 : return new ResourceNotFoundException(scimError, cause); case 405 : return new MethodNotAllowedException(scimError, cause); case 409 : return new ResourceConflictException(scimError, cause);
case 401 : return new UnauthorizedException(scimError, cause); case 403 : return new ForbiddenException(scimError, cause); case 404 : return new ResourceNotFoundException(scimError, cause); case 405 : return new MethodNotAllowedException(scimError, cause); case 409 : return new ResourceConflictException(scimError, cause);