0% found this document useful (0 votes)
3 views

Rest Controller

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Rest Controller

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

@RestController

@Slf4j
@Api(tags = "UserOperations", value = "UserService", description = "Operations
pertaining to User ")
public class UserController {

@Autowired
private UserService userService;

/**
* @param userDto
* @param authBearer
* @param xRemoteUser
* @param xImpersonateUser
* @return
* @throws
*/
@PostMapping(value = "/", produces =
{ MediaType.APPLICATION_JSON_UTF8_VALUE })
public ResponseEntity<ApiResponseDto> createUser(@Valid @RequestBody
CreateUserDto userDto,
@RequestHeader(value = CommonConstants.AUTHORIZATION_HEADER)
String authBearer,
@RequestHeader(value = CommonConstants.XREMOTE_USER_HEADER)
String xRemoteUser,
@RequestHeader(value = CommonConstants.XIMPERSONATE_USER_HEADER,
required = false) String xImpersonateUser)
throws {

if (validateUserAccessNRoles(authBearer, xRemoteUser,
xImpersonateUser)) {
ApiResponseDto response = new ApiResponseDto();
response.addData(ApplicationConstants.ID,
userService.createUser(userDto));
response.addData(ApplicationConstants.MESSAGE,
ApplicationConstants.CREATE_USER_MESSAGE);
return new ResponseEntity<>(response, HttpStatus.CREATED);
} else {
throw new
UserUnauthorizedException(ApplicationConstants.USER_ACCESS_AND_ROLES_VALIDATTION_FA
ILED,
"User is not authorized to access user create API",
UserServiceErrorCode.USER_UNAUTHORIZED_ERROR);
}
}

You might also like