Search in sources :

Example 46 with SCIMResponse

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

the class GroupResource method createGroup.

@ApiOperation(value = "Return the group which was created", notes = "Returns HTTP 201 if the group is successfully created.")
@POST
@Produces({ "application/json", "application/scim+json" })
@Consumes("application/scim+json")
@ApiResponses(value = { @ApiResponse(code = 201, message = "Valid group is created"), @ApiResponse(code = 404, message = "Group is not found") })
public Response createGroup(@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 group endpoint and hand-over the request.
        GroupResourceManager groupResourceManager = new GroupResourceManager();
        SCIMResponse response = groupResourceManager.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) GroupResourceManager(org.wso2.charon3.core.protocol.endpoints.GroupResourceManager) CharonException(org.wso2.charon3.core.exceptions.CharonException) 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)

Aggregations

BadRequestException (org.wso2.charon3.core.exceptions.BadRequestException)31 CharonException (org.wso2.charon3.core.exceptions.CharonException)31 SCIMResponse (org.wso2.charon3.core.protocol.SCIMResponse)31 HashMap (java.util.HashMap)19 NotFoundException (org.wso2.charon3.core.exceptions.NotFoundException)18 SCIMResourceTypeSchema (org.wso2.charon3.core.schema.SCIMResourceTypeSchema)18 InternalErrorException (org.wso2.charon3.core.exceptions.InternalErrorException)16 JSONEncoder (org.wso2.charon3.core.encoder.JSONEncoder)15 UserManager (org.wso2.charon3.core.extensions.UserManager)15 JSONDecoder (org.wso2.charon3.core.encoder.JSONDecoder)13 ApiOperation (io.swagger.annotations.ApiOperation)12 ApiResponses (io.swagger.annotations.ApiResponses)12 Produces (javax.ws.rs.Produces)12 NotImplementedException (org.wso2.charon3.core.exceptions.NotImplementedException)12 Path (javax.ws.rs.Path)8 User (org.wso2.charon3.core.objects.User)8 Consumes (javax.ws.rs.Consumes)6 GroupResourceManager (org.wso2.charon3.core.protocol.endpoints.GroupResourceManager)6 UserResourceManager (org.wso2.charon3.core.protocol.endpoints.UserResourceManager)6 GET (javax.ws.rs.GET)4