use of org.wso2.charon3.core.extensions.UserManager in project charon by wso2.
the class BulkRequestProcessor method getBulkResponseContent.
private BulkResponseContent getBulkResponseContent(BulkRequestContent bulkRequestContent, ResourceManager resourceManager) throws BadRequestException {
BulkResponseContent bulkResponseContent = null;
SCIMResponse response;
if (bulkRequestContent.getMethod().equals(SCIMConstants.OperationalConstants.POST)) {
response = resourceManager.create(bulkRequestContent.getData(), userManager, null, null);
bulkResponseContent = createBulkResponseContent(response, SCIMConstants.OperationalConstants.POST, bulkRequestContent);
errorsCheck(response);
} else if (bulkRequestContent.getMethod().equals(SCIMConstants.OperationalConstants.PUT)) {
String resourceId = extractIDFromPath(bulkRequestContent.getPath());
response = resourceManager.updateWithPUT(resourceId, bulkRequestContent.getData(), userManager, null, null);
bulkResponseContent = createBulkResponseContent(response, SCIMConstants.OperationalConstants.PUT, bulkRequestContent);
errorsCheck(response);
} else if (bulkRequestContent.getMethod().equals(SCIMConstants.OperationalConstants.PATCH)) {
String resourceId = extractIDFromPath(bulkRequestContent.getPath());
response = resourceManager.updateWithPATCH(resourceId, bulkRequestContent.getData(), userManager, null, null);
bulkResponseContent = createBulkResponseContent(response, SCIMConstants.OperationalConstants.PATCH, bulkRequestContent);
errorsCheck(response);
} else if (bulkRequestContent.getMethod().equals(SCIMConstants.OperationalConstants.DELETE)) {
String resourceId = extractIDFromPath(bulkRequestContent.getPath());
response = resourceManager.delete(resourceId, userManager);
bulkResponseContent = createBulkResponseContent(response, SCIMConstants.OperationalConstants.DELETE, bulkRequestContent);
errorsCheck(response);
}
return bulkResponseContent;
}
use of org.wso2.charon3.core.extensions.UserManager in project charon by wso2.
the class UserResource method updateUser.
@PUT
@Path("{id}")
@Produces({ "application/json", "application/scim+json" })
@Consumes("application/scim+json")
@ApiOperation(value = "Return the updated user", notes = "Returns HTTP 404 if the user is not found.")
@ApiResponses(value = { @ApiResponse(code = 200, message = "User is updated"), @ApiResponse(code = 404, message = "Valid user is not found") })
public Response updateUser(@ApiParam(value = SCIMProviderConstants.ID_DESC, required = true) @PathParam(SCIMProviderConstants.ID) String id, @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 FormatNotSupportedException, CharonException {
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.updateWithPUT(id, resourceString, userManager, attribute, excludedAttributes);
return buildResponse(response);
} catch (CharonException e) {
throw new CharonException(e.getDetail(), e);
}
}
use of org.wso2.charon3.core.extensions.UserManager 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);
}
}
use of org.wso2.charon3.core.extensions.UserManager 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);
}
}
use of org.wso2.charon3.core.extensions.UserManager in project charon by wso2.
the class GroupResource method getGroup.
@GET
@Path("/{id}")
@Produces({ "application/json", "application/scim+json" })
@ApiOperation(value = "Return the group with the given id", notes = "Returns HTTP 200 if the group is found.")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Valid group is found"), @ApiResponse(code = 404, message = "Valid group is not found") })
public Response getGroup(@ApiParam(value = SCIMProviderConstants.ID_DESC, required = true) @PathParam(SCIMProviderConstants.ID) String id, @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) throws FormatNotSupportedException, CharonException {
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 scimResponse = groupResourceManager.get(id, userManager, attribute, excludedAttributes);
// appropriately.
return buildResponse(scimResponse);
} catch (CharonException e) {
throw new CharonException(e.getDetail(), e);
}
}
Aggregations