Search in sources :

Example 6 with UserResourceManager

use of org.wso2.charon3.core.protocol.endpoints.UserResourceManager in project charon by wso2.

the class UserResource method createUser.

@ApiOperation(value = "Return the user which was created", notes = "Returns HTTP 201 if the user is successfully created.")
@POST
@Produces({ "application/json", "application/scim+json" })
@Consumes("application/scim+json")
@ApiResponses(value = { @ApiResponse(code = 201, message = "Valid user is created"), @ApiResponse(code = 404, message = "User is not found") })
public Response createUser(@ApiParam(value = SCIMProviderConstants.ATTRIBUTES_DESC, required = false) @QueryParam(SCIMProviderConstants.ATTRIBUTES) String attribute, @ApiParam(value = SCIMProviderConstants.EXCLUDED_ATTRIBUTES_DESC, required = false) @QueryParam(SCIMProviderConstants.EXCLUDE_ATTRIBUTES) String excludedAttributes, String resourceString) throws CharonException, FormatNotSupportedException {
    try {
        // obtain the user store manager
        UserManager userManager = DefaultCharonManager.getInstance().getUserManager();
        // create charon-SCIM user endpoint and hand-over the request.
        UserResourceManager userResourceManager = new UserResourceManager();
        SCIMResponse response = userResourceManager.create(resourceString, userManager, attribute, excludedAttributes);
        return buildResponse(response);
    } catch (CharonException e) {
        throw new CharonException(e.getDetail(), e);
    }
}
Also used : UserManager(org.wso2.charon3.core.extensions.UserManager) CharonException(org.wso2.charon3.core.exceptions.CharonException) UserResourceManager(org.wso2.charon3.core.protocol.endpoints.UserResourceManager) SCIMResponse(org.wso2.charon3.core.protocol.SCIMResponse) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) Consumes(javax.ws.rs.Consumes) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 7 with UserResourceManager

use of org.wso2.charon3.core.protocol.endpoints.UserResourceManager in project charon by wso2.

the class UserResource method deleteUser.

@DELETE
@Path("/{id}")
@Produces({ "application/json", "application/scim+json" })
@ApiOperation(value = "Delete the user with the given id", notes = "Returns HTTP 204 if the user is successfully deleted.")
@ApiResponses(value = { @ApiResponse(code = 204, message = "User is deleted"), @ApiResponse(code = 404, message = "Valid user is not found") })
public Response deleteUser(@ApiParam(value = SCIMProviderConstants.ID_DESC, required = true) @PathParam(SCIMProviderConstants.ID) String id) throws FormatNotSupportedException, CharonException {
    try {
        // obtain the user store manager
        UserManager userManager = DefaultCharonManager.getInstance().getUserManager();
        // create charon-SCIM user resource manager and hand-over the request.
        UserResourceManager userResourceManager = new UserResourceManager();
        SCIMResponse scimResponse = userResourceManager.delete(id, userManager);
        // appropriately.
        return buildResponse(scimResponse);
    } catch (CharonException e) {
        throw new CharonException(e.getDetail(), e);
    }
}
Also used : UserManager(org.wso2.charon3.core.extensions.UserManager) CharonException(org.wso2.charon3.core.exceptions.CharonException) UserResourceManager(org.wso2.charon3.core.protocol.endpoints.UserResourceManager) SCIMResponse(org.wso2.charon3.core.protocol.SCIMResponse) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Produces(javax.ws.rs.Produces) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

ApiOperation (io.swagger.annotations.ApiOperation)6 ApiResponses (io.swagger.annotations.ApiResponses)6 Produces (javax.ws.rs.Produces)6 CharonException (org.wso2.charon3.core.exceptions.CharonException)6 UserManager (org.wso2.charon3.core.extensions.UserManager)6 SCIMResponse (org.wso2.charon3.core.protocol.SCIMResponse)6 UserResourceManager (org.wso2.charon3.core.protocol.endpoints.UserResourceManager)6 Path (javax.ws.rs.Path)4 Consumes (javax.ws.rs.Consumes)3 GET (javax.ws.rs.GET)2 POST (javax.ws.rs.POST)2 DELETE (javax.ws.rs.DELETE)1 PUT (javax.ws.rs.PUT)1 BulkRequestContent (org.wso2.charon3.core.objects.bulk.BulkRequestContent)1 BulkResponseData (org.wso2.charon3.core.objects.bulk.BulkResponseData)1