Skip to content

Commit

Permalink
Merge pull request #1426 from /issues/1425-requestMapping-annotations
Browse files Browse the repository at this point in the history
Fix #1425: Prefer specialized RequestMapping annotations
  • Loading branch information
banterCZ authored Sep 20, 2023
2 parents e9120c0 + e3d07e5 commit 593036c
Show file tree
Hide file tree
Showing 37 changed files with 228 additions and 243 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public ApplicationController(ApplicationService applicationService) {
@ApiResponse(responseCode = "400", description = "Invalid request, error codes: REQUEST_VALIDATION_FAILED, APPLICATION_ALREADY_EXISTS"),
@ApiResponse(responseCode = "500", description = "Unexpected error")
})
@RequestMapping(method = RequestMethod.POST)
@PostMapping
public ObjectResponse<CreateApplicationResponse> createApplication(@Valid @RequestBody ObjectRequest<CreateApplicationRequest> request) throws ApplicationAlreadyExistsException {
logger.info("Received createApplication request, application name: {}", request.getRequestObject().getApplicationName());
final CreateApplicationResponse response = applicationService.createApplication(request.getRequestObject());
Expand All @@ -95,7 +95,7 @@ public ObjectResponse<CreateApplicationResponse> createApplication(@Valid @Reque
@ApiResponse(responseCode = "400", description = "Invalid request, error codes: REQUEST_VALIDATION_FAILED, APPLICATION_NOT_FOUND"),
@ApiResponse(responseCode = "500", description = "Unexpected error")
})
@RequestMapping(method = RequestMethod.PUT)
@PutMapping
public ObjectResponse<UpdateApplicationResponse> updateApplication(@Valid @RequestBody ObjectRequest<UpdateApplicationRequest> request) throws ApplicationNotFoundException {
logger.info("Received updateApplication request, application name: {}", request.getRequestObject().getApplicationName());
final UpdateApplicationResponse response = applicationService.updateApplication(request.getRequestObject());
Expand All @@ -115,7 +115,7 @@ public ObjectResponse<UpdateApplicationResponse> updateApplication(@Valid @Reque
@ApiResponse(responseCode = "400", description = "Invalid request, error codes: REQUEST_VALIDATION_FAILED, APPLICATION_NOT_FOUND"),
@ApiResponse(responseCode = "500", description = "Unexpected error")
})
@RequestMapping(value = "update", method = RequestMethod.POST)
@PostMapping("update")
public ObjectResponse<UpdateApplicationResponse> updateApplicationPost(@Valid @RequestBody ObjectRequest<UpdateApplicationRequest> request) throws ApplicationNotFoundException {
logger.info("Received updateApplicationPost request, application name: {}", request.getRequestObject().getApplicationName());
final UpdateApplicationResponse response = applicationService.updateApplication(request.getRequestObject());
Expand All @@ -134,7 +134,7 @@ public ObjectResponse<UpdateApplicationResponse> updateApplicationPost(@Valid @R
@ApiResponse(responseCode = "400", description = "Invalid request"),
@ApiResponse(responseCode = "500", description = "Unexpected error")
})
@RequestMapping(method = RequestMethod.GET)
@GetMapping
public ObjectResponse<GetApplicationListResponse> getApplicationList(@RequestParam boolean includeRemoved) {
logger.info("Received getApplicationList request");
GetApplicationListRequest request = new GetApplicationListRequest();
Expand All @@ -155,7 +155,7 @@ public ObjectResponse<GetApplicationListResponse> getApplicationList(@RequestPar
@ApiResponse(responseCode = "400", description = "Invalid request, error codes: REQUEST_VALIDATION_FAILED"),
@ApiResponse(responseCode = "500", description = "Unexpected error")
})
@RequestMapping(value = "list", method = RequestMethod.POST)
@PostMapping("list")
public ObjectResponse<GetApplicationListResponse> getApplicationListPost(@Valid @RequestBody ObjectRequest<GetApplicationListRequest> request) {
logger.info("Received getApplicationListPost request");
final GetApplicationListResponse response = applicationService.getApplicationList(request.getRequestObject());
Expand All @@ -175,7 +175,7 @@ public ObjectResponse<GetApplicationListResponse> getApplicationListPost(@Valid
@ApiResponse(responseCode = "400", description = "Invalid request, error codes: REQUEST_VALIDATION_FAILED, APPLICATION_NOT_FOUND"),
@ApiResponse(responseCode = "500", description = "Unexpected error")
})
@RequestMapping(value = "delete", method = RequestMethod.POST)
@PostMapping("delete")
public ObjectResponse<DeleteApplicationResponse> deleteApplication(@Valid @RequestBody ObjectRequest<DeleteApplicationRequest> request) throws ApplicationNotFoundException {
logger.info("Received deleteApplication request, application name: {}", request.getRequestObject().getApplicationName());
final DeleteApplicationResponse response = applicationService.deleteApplication(request.getRequestObject());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public AuthMethodController(AuthMethodService authMethodService) {
@ApiResponse(responseCode = "400", description = "Invalid request, error codes: REQUEST_VALIDATION_FAILED, AUTH_METHOD_ALREADY_EXISTS"),
@ApiResponse(responseCode = "500", description = "Unexpected error")
})
@RequestMapping(value = "auth-method", method = RequestMethod.POST)
@PostMapping("auth-method")
public ObjectResponse<CreateAuthMethodResponse> createAuthMethod(@Valid @RequestBody ObjectRequest<CreateAuthMethodRequest> request) throws AuthMethodAlreadyExistsException {
logger.info("Received createAuthMethod request, authentication method: {}", request.getRequestObject().getAuthMethod());
final CreateAuthMethodResponse response = authMethodService.createAuthMethod(request.getRequestObject());
Expand All @@ -97,7 +97,7 @@ public ObjectResponse<CreateAuthMethodResponse> createAuthMethod(@Valid @Request
@ApiResponse(responseCode = "400", description = "Invalid request, error codes: REQUEST_VALIDATION_FAILED, INVALID_CONFIGURATION"),
@ApiResponse(responseCode = "500", description = "Unexpected error")
})
@RequestMapping(value = "auth-method", method = RequestMethod.GET)
@GetMapping("auth-method")
public ObjectResponse<GetAuthMethodsResponse> getAuthMethodList() throws InvalidConfigurationException {
logger.info("Received getAuthMethodList request");
final List<AuthMethodDetail> authMethods = authMethodService.listAuthMethods();
Expand All @@ -124,7 +124,7 @@ public ObjectResponse<GetAuthMethodsResponse> getAuthMethodList() throws Invalid
@ApiResponse(responseCode = "400", description = "Invalid request, error codes: REQUEST_VALIDATION_FAILED, INVALID_CONFIGURATION"),
@ApiResponse(responseCode = "500", description = "Unexpected error")
})
@RequestMapping(value = "auth-method/list", method = RequestMethod.POST)
@PostMapping("auth-method/list")
public ObjectResponse<GetAuthMethodsResponse> getAuthMethodListPost(@Valid @RequestBody ObjectRequest<GetAuthMethodListRequest> request) throws InvalidConfigurationException {
logger.info("Received getAuthMethodListPost request");
final List<AuthMethodDetail> authMethods = authMethodService.listAuthMethods();
Expand All @@ -151,7 +151,7 @@ public ObjectResponse<GetAuthMethodsResponse> getAuthMethodListPost(@Valid @Requ
@ApiResponse(responseCode = "400", description = "Invalid request, error codes: REQUEST_VALIDATION_FAILED, INVALID_CONFIGURATION"),
@ApiResponse(responseCode = "500", description = "Unexpected error")
})
@RequestMapping(value = "user/auth-method", method = RequestMethod.GET)
@GetMapping("user/auth-method")
public ObjectResponse<GetUserAuthMethodsResponse> getAuthMethodsEnabledForUser(@RequestParam @Nullable @Size(min = 1, max = 256) String userId) throws InvalidConfigurationException {
// Log level is FINE to avoid flooding logs, this endpoint is used all the time.
logger.debug("Received getAuthMethodsEnabledForUser request, user ID: {}", userId);
Expand All @@ -176,7 +176,7 @@ public ObjectResponse<GetUserAuthMethodsResponse> getAuthMethodsEnabledForUser(@
@ApiResponse(responseCode = "400", description = "Invalid request, error codes: REQUEST_VALIDATION_FAILED, INVALID_CONFIGURATION"),
@ApiResponse(responseCode = "500", description = "Unexpected error")
})
@RequestMapping(value = "user/auth-method/list", method = RequestMethod.POST)
@PostMapping("user/auth-method/list")
public ObjectResponse<GetUserAuthMethodsResponse> getAuthMethodsEnabledForUserPost(@Valid @RequestBody ObjectRequest<GetUserAuthMethodsRequest> request) throws InvalidConfigurationException {
// Log level is FINE to avoid flooding logs, this endpoint is used all the time.
logger.debug("Received getAuthMethodsEnabledForUserPost request, user ID: {}", request.getRequestObject().getUserId());
Expand Down Expand Up @@ -204,7 +204,7 @@ public ObjectResponse<GetUserAuthMethodsResponse> getAuthMethodsEnabledForUserPo
@ApiResponse(responseCode = "400", description = "Invalid request, error codes: REQUEST_VALIDATION_FAILED, INVALID_REQUEST, INVALID_CONFIGURATION"),
@ApiResponse(responseCode = "500", description = "Unexpected error")
})
@RequestMapping(value = "user/auth-method", method = RequestMethod.POST)
@PostMapping("user/auth-method")
public ObjectResponse<GetUserAuthMethodsResponse> enableAuthMethodForUser(@Valid @RequestBody ObjectRequest<UpdateAuthMethodRequest> request) throws InvalidRequestException, InvalidConfigurationException {
logger.info("Received enableAuthMethodForUser request, user ID: {}, authentication method: {}", request.getRequestObject().getUserId(), request.getRequestObject().getAuthMethod().toString());
final UpdateAuthMethodRequest requestObject = request.getRequestObject();
Expand Down Expand Up @@ -241,7 +241,7 @@ public ObjectResponse<GetUserAuthMethodsResponse> enableAuthMethodForUser(@Valid
@ApiResponse(responseCode = "400", description = "Invalid request, error codes: REQUEST_VALIDATION_FAILED, INVALID_REQUEST, INVALID_CONFIGURATION"),
@ApiResponse(responseCode = "500", description = "Unexpected error")
})
@RequestMapping(value = "user/auth-method/delete", method = RequestMethod.POST)
@PostMapping("user/auth-method/delete")
public ObjectResponse<GetUserAuthMethodsResponse> disableAuthMethodForUser(@Valid @RequestBody ObjectRequest<UpdateAuthMethodRequest> request) throws InvalidRequestException, InvalidConfigurationException {
return disableAuthMethodForUserImpl(request);
}
Expand Down Expand Up @@ -281,7 +281,7 @@ private ObjectResponse<GetUserAuthMethodsResponse> disableAuthMethodForUserImpl(
@ApiResponse(responseCode = "400", description = "Invalid request, error codes: REQUEST_VALIDATION_FAILED, INVALID_CONFIGURATION"),
@ApiResponse(responseCode = "500", description = "Unexpected error")
})
@RequestMapping(value = "user/auth-method/enabled", method = RequestMethod.GET)
@GetMapping("user/auth-method/enabled")
public ObjectResponse<GetEnabledMethodListResponse> getEnabledMethodList(@RequestParam @NotBlank @Size(min = 1, max = 256) String userId, @RequestParam @NotBlank @Size(min = 2, max = 256) String operationName) throws InvalidConfigurationException {
// Log level is FINE to avoid flooding logs, this endpoint is used all the time.
logger.debug("Received getEnabledMethodList request, user ID: {}", userId);
Expand All @@ -305,7 +305,7 @@ public ObjectResponse<GetEnabledMethodListResponse> getEnabledMethodList(@Reques
@ApiResponse(responseCode = "400", description = "Invalid request, error codes: REQUEST_VALIDATION_FAILED, INVALID_CONFIGURATION"),
@ApiResponse(responseCode = "500", description = "Unexpected error")
})
@RequestMapping(value = "user/auth-method/enabled/list", method = RequestMethod.POST)
@PostMapping("user/auth-method/enabled/list")
public ObjectResponse<GetEnabledMethodListResponse> getEnabledMethodListPost(@Valid @RequestBody ObjectRequest<GetEnabledMethodListRequest> request) throws InvalidConfigurationException {
// Log level is FINE to avoid flooding logs, this endpoint is used all the time.
logger.debug("Received getEnabledMethodListPost request, user ID: {}", request.getRequestObject().getUserId());
Expand All @@ -327,7 +327,7 @@ public ObjectResponse<GetEnabledMethodListResponse> getEnabledMethodListPost(@Va
@ApiResponse(responseCode = "400", description = "Invalid request, error codes: REQUEST_VALIDATION_FAILED, AUTH_METHOD_NOT_FOUND, DELETE_NOT_ALLOWED"),
@ApiResponse(responseCode = "500", description = "Unexpected error")
})
@RequestMapping(value = "auth-method/delete", method = RequestMethod.POST)
@PostMapping("auth-method/delete")
public ObjectResponse<DeleteAuthMethodResponse> deleteAuthMethod(@Valid @RequestBody ObjectRequest<DeleteAuthMethodRequest> request) throws AuthMethodNotFoundException, DeleteNotAllowedException {
logger.info("Received deleteAuthMethod request, authentication method: {}", request.getRequestObject().getAuthMethod());
final DeleteAuthMethodResponse response = authMethodService.deleteAuthMethod(request.getRequestObject());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
Expand Down Expand Up @@ -87,7 +87,7 @@ public AuthenticationController(AuthenticationService authenticationService) {
@ApiResponse(responseCode = "400", description = "Invalid request, error codes: REQUEST_VALIDATION_FAILED, INVALID_REQUEST, USER_IDENTITY_NOT_FOUND, OPERATION_NOT_FOUND, CREDENTIAL_NOT_FOUND, CREDENTIAL_DEFINITION_NOT_FOUND, INVALID_CONFIGURATION, OPERATION_ALREADY_FINISHED, OPERATION_ALREADY_CANCELED, OPERATION_ALREADY_FAILED, OPERATION_NOT_VALID, AUTH_METHOD_NOT_FOUND, ENCRYPTION_FAILED"),
@ApiResponse(responseCode = "500", description = "Unexpected error")
})
@RequestMapping(value = "credential", method = RequestMethod.POST)
@PostMapping("credential")
public ObjectResponse<CredentialAuthenticationResponse> authenticateWithCredential(@Valid @RequestBody ObjectRequest<CredentialAuthenticationRequest> request) throws InvalidRequestException, UserNotFoundException, OperationNotFoundException, CredentialNotFoundException, CredentialDefinitionNotFoundException, InvalidConfigurationException, OperationAlreadyFinishedException, OperationAlreadyCanceledException, OperationAlreadyFailedException, OperationNotValidException, AuthMethodNotFoundException, EncryptionException {
logger.info("Received authenticateWithCredential request, user ID: {}, operation ID: {}", request.getRequestObject().getUserId(), request.getRequestObject().getOperationId());
final CredentialAuthenticationResponse response = authenticationService.authenticateWithCredential(request.getRequestObject());
Expand Down Expand Up @@ -117,7 +117,7 @@ public ObjectResponse<CredentialAuthenticationResponse> authenticateWithCredenti
@ApiResponse(responseCode = "400", description = "Invalid request, error codes: REQUEST_VALIDATION_FAILED, INVALID_REQUEST, AUTH_METHOD_NOT_FOUND, OPERATION_ALREADY_FAILED, OPERATION_ALREADY_FINISHED, OPERATION_ALREADY_CANCELED, INVALID_CONFIGURATION, CREDENTIAL_NOT_FOUND, OPERATION_NOT_FOUND, OTP_NOT_FOUND, OPERATION_NOT_VALID, ENCRYPTION_FAILED"),
@ApiResponse(responseCode = "500", description = "Unexpected error")
})
@RequestMapping(value = "otp", method = RequestMethod.POST)
@PostMapping("otp")
public ObjectResponse<OtpAuthenticationResponse> authenticateWithOtp(@Valid @RequestBody ObjectRequest<OtpAuthenticationRequest> request) throws InvalidRequestException, AuthMethodNotFoundException, OperationAlreadyFailedException, OperationAlreadyFinishedException, OperationAlreadyCanceledException, InvalidConfigurationException, CredentialNotFoundException, OperationNotFoundException, OtpNotFoundException, OperationNotValidException, EncryptionException {
logger.info("Received authenticateWithOtp request, OTP ID: {}, operation ID: {}", request.getRequestObject().getOtpId(), request.getRequestObject().getOperationId());
final OtpAuthenticationResponse response = authenticationService.authenticateWithOtp(request.getRequestObject());
Expand Down Expand Up @@ -148,7 +148,7 @@ public ObjectResponse<OtpAuthenticationResponse> authenticateWithOtp(@Valid @Req
@ApiResponse(responseCode = "400", description = "Invalid request, error codes: REQUEST_VALIDATION_FAILED, INVALID_REQUEST, AUTH_METHOD_NOT_FOUND, INVALID_CONFIGURATION, USER_IDENTITY_NOT_FOUND, OPERATION_ALREADY_FINISHED, OPERATION_ALREADY_CANCELED, OPERATION_ALREADY_FAILED, CREDENTIAL_NOT_FOUND, OPERATION_NOT_FOUND, OTP_NOT_FOUND, OPERATION_NOT_VALID, ENCRYPTION_FAILED"),
@ApiResponse(responseCode = "500", description = "Unexpected error")
})
@RequestMapping(value = "combined", method = RequestMethod.POST)
@PostMapping("combined")
public ObjectResponse<CombinedAuthenticationResponse> authenticateCombined(@Valid @RequestBody ObjectRequest<CombinedAuthenticationRequest> request) throws InvalidRequestException, AuthMethodNotFoundException, InvalidConfigurationException, UserNotFoundException, OperationAlreadyFinishedException, OperationAlreadyCanceledException, OperationAlreadyFailedException, CredentialNotFoundException, OperationNotFoundException, OtpNotFoundException, OperationNotValidException, EncryptionException {
logger.info("Received authenticateCombined request, user ID: {}, OTP ID: {}, operation ID: {}", request.getRequestObject().getUserId(), request.getRequestObject().getOperationId(), request.getRequestObject().getOtpId());
final CombinedAuthenticationResponse response = authenticationService.authenticateCombined(request.getRequestObject());
Expand Down
Loading

0 comments on commit 593036c

Please sign in to comment.