class UserRolesMappingController {

	@ApiOperation(httpMethod = "POST", value = "API to allocate user roles", response = Response.class,  consumes = MediaType.APPLICATION_JSON_VALUE)
	@RequestMapping(path = "/allocate", method = RequestMethod.POST,  consumes = MediaType.APPLICATION_JSON_VALUE)
	public ResponseEntity<Object> allocateUserRole(@AuthenticationPrincipal Principal user,
			@ApiParam(value = "provide valid role details", required = true)
			@RequestBody(required = true) UserRoleConfigRequest userRoleConfigRequest) {
		try {
			return ResponseUtils.buildSucessResponse(userRolesMappingService.allocateUserRole(userRoleConfigRequest, user.getName()));
		} catch (Exception exception) {
			log.error(UNEXPECTED_ERROR_OCCURRED, exception);
			return ResponseUtils.buildFailureResponse(new Exception(UNEXPECTED_ERROR_OCCURRED), exception.getMessage());
		}
	}

}