Issue 2495: Response error codes handling for multi link request#2497
Issue 2495: Response error codes handling for multi link request#2497anayonkars wants to merge 8 commits intospring-projects:mainfrom
Conversation
In RepositoryPropertyReferenceController, handled response code for empty links. Instead of IllegalArgumentException and HTTP 500, now it throws HttpMessageNotReadableException and HTTP 400 Signed-off-by: Anayonkar Shivalkar <anayonkar.shivalkar@gmail.com>
In RepositoryPropertyReferenceController, handled response code for multiple links. Instead of IllegalArgumentException and HTTP 500, now it throws HttpMessageNotReadableException and HTTP 400 Signed-off-by: Anayonkar Shivalkar <anayonkar.shivalkar@gmail.com>
In RepositoryPropertyReferenceController, handled response code where no links are sent (List of Map). Instead of IllegalArgumentException and HTTP 500, now it throws HttpMessageNotReadableException and HTTP 400 Signed-off-by: Anayonkar Shivalkar <anayonkar.shivalkar@gmail.com>
Fixed test cases Signed-off-by: Anayonkar Shivalkar <anayonkar.shivalkar@gmail.com>
mp911de
left a comment
There was a problem hiding this comment.
Thanks for submitting a pull request. I added a few comments. Right now, the PR causes more work on our side than it actually helps. Please apply formatting and resolve the commented-out code issues.
Please also squash all commits into one, feel free to force-push.
| Class<?> propertyType = prop.property.getType(); | ||
|
|
||
| if (prop.property.isCollectionLike()) { | ||
| /*if(HttpMethod.PATCH.equals(requestMethod) |
There was a problem hiding this comment.
Why is new code here being commented out?
There was a problem hiding this comment.
It's supposed to handle multiple association issue (returning HTTP 204 in case of empty/incorrect header). I've removed the commented code.
| RootResourceInformation resourceInformation, HttpMethod requestMethod, | ||
| @RequestBody(required = false) CollectionModel<Object> incoming, @BackendId Serializable id, | ||
| @RequestBody(required = false) CollectionModel<Object> incoming, | ||
| @RequestHeader(required = false) HttpHeaders requestHeaders, |
There was a problem hiding this comment.
Nit: You can find formatting settings at https://github.com/spring-projects/spring-data-build/tree/main/etc/ide
|
|
||
| private static final String BASE_MAPPING = "/{repository}/{id}/{property}"; | ||
| private static final Collection<HttpMethod> AUGMENTING_METHODS = Arrays.asList(HttpMethod.PATCH, HttpMethod.POST); | ||
| private static final List<MediaType> SUPPORTED_CONTENT_TYPE = Arrays.asList(MediaType.APPLICATION_JSON, TEXT_URI_LIST); |
There was a problem hiding this comment.
Nit: We use tab indents, not spaces.
| } | ||
|
|
||
| /*@Test // GH-2495 | ||
| void rejectsInvalidContentTypeForSingleValuedAssociation() throws Exception { |
There was a problem hiding this comment.
It's supposed to handle multiple association issue (returning HTTP 204 in case of empty/incorrect header). I've removed the commented code.
Fixed merge conflicts Signed-off-by: Anayonkar Shivalkar <anayonkar.shivalkar@gmail.com> DATAREST-2495 Cleaned up unnecessary code Signed-off-by: Anayonkar Shivalkar <anayonkar.shivalkar@gmail.com> DATAREST-2495 Fixed test cases Signed-off-by: Anayonkar Shivalkar <anayonkar.shivalkar@gmail.com> DATAREST-2495 In RepositoryPropertyReferenceController, handled response code where no links are sent (List of Map). Instead of IllegalArgumentException and HTTP 500, now it throws HttpMessageNotReadableException and HTTP 400 Signed-off-by: Anayonkar Shivalkar <anayonkar.shivalkar@gmail.com> DATAREST-2495 In RepositoryPropertyReferenceController, handled response code for multiple links. Instead of IllegalArgumentException and HTTP 500, now it throws HttpMessageNotReadableException and HTTP 400 Signed-off-by: Anayonkar Shivalkar <anayonkar.shivalkar@gmail.com> DATAREST-2495 In RepositoryPropertyReferenceController, handled response code for empty links. Instead of IllegalArgumentException and HTTP 500, now it throws HttpMessageNotReadableException and HTTP 400 Signed-off-by: Anayonkar Shivalkar <anayonkar.shivalkar@gmail.com> # Conflicts: # spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryPropertyReferenceController.java # spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/RepositoryPropertyReferenceControllerUnitTests.java
Fixed merge conflicts Signed-off-by: Anayonkar Shivalkar <anayonkar.shivalkar@gmail.com> DATAREST-2495 Cleaned up unnecessary code Signed-off-by: Anayonkar Shivalkar <anayonkar.shivalkar@gmail.com> DATAREST-2495 Fixed test cases Signed-off-by: Anayonkar Shivalkar <anayonkar.shivalkar@gmail.com> DATAREST-2495 In RepositoryPropertyReferenceController, handled response code where no links are sent (List of Map). Instead of IllegalArgumentException and HTTP 500, now it throws HttpMessageNotReadableException and HTTP 400 Signed-off-by: Anayonkar Shivalkar <anayonkar.shivalkar@gmail.com> DATAREST-2495 In RepositoryPropertyReferenceController, handled response code for multiple links. Instead of IllegalArgumentException and HTTP 500, now it throws HttpMessageNotReadableException and HTTP 400 Signed-off-by: Anayonkar Shivalkar <anayonkar.shivalkar@gmail.com> DATAREST-2495 In RepositoryPropertyReferenceController, handled response code for empty links. Instead of IllegalArgumentException and HTTP 500, now it throws HttpMessageNotReadableException and HTTP 400 Signed-off-by: Anayonkar Shivalkar <anayonkar.shivalkar@gmail.com> # Conflicts: # spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryPropertyReferenceController.java # spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/RepositoryPropertyReferenceControllerUnitTests.java DATAREST-2495 Fixed test cases Signed-off-by: Anayonkar Shivalkar <anayonkar.shivalkar@gmail.com> DATAREST-2495 In RepositoryPropertyReferenceController, handled response code where no links are sent (List of Map). Instead of IllegalArgumentException and HTTP 500, now it throws HttpMessageNotReadableException and HTTP 400 Signed-off-by: Anayonkar Shivalkar <anayonkar.shivalkar@gmail.com> DATAREST-2495 In RepositoryPropertyReferenceController, handled response code for multiple links. Instead of IllegalArgumentException and HTTP 500, now it throws HttpMessageNotReadableException and HTTP 400 Signed-off-by: Anayonkar Shivalkar <anayonkar.shivalkar@gmail.com> DATAREST-2495 In RepositoryPropertyReferenceController, handled response code for empty links. Instead of IllegalArgumentException and HTTP 500, now it throws HttpMessageNotReadableException and HTTP 400 Signed-off-by: Anayonkar Shivalkar <anayonkar.shivalkar@gmail.com>
|
Apologies for formatting issues. I was able to configure eclipse formatter in intellij. However, couldn't fix import order. @mp911de, please review and let me know in case of any issues. |
…nse-handling-for-multi-link-request' into bug/spring-projectsGH-2495-Response-handling-for-multi-link-request
…esponse-handling-for-multi-link-request
This PR is to solve issue 2495.
It handles correction of error codes for single association resource. However, it doesn't (yet) handles multiple association resource.