-
Notifications
You must be signed in to change notification settings - Fork 566
Issue 2495: Response error codes handling for multi link request #2497
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Issue 2495: Response error codes handling for multi link request #2497
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>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
|
||
Function<ReferencedProperty, RepresentationModel<?>> handler = prop -> { | ||
|
||
Class<?> propertyType = prop.property.getType(); | ||
|
||
if (prop.property.isCollectionLike()) { | ||
/*if(HttpMethod.PATCH.equals(requestMethod) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is new code here being commented out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's supposed to handle multiple association issue (returning HTTP 204 in case of empty/incorrect header). I've removed the commented code.
@@ -237,17 +237,35 @@ public ResponseEntity<RepresentationModel<?>> followPropertyReferenceCompact(Roo | |||
consumes = { MediaType.APPLICATION_JSON_VALUE, SPRING_DATA_COMPACT_JSON_VALUE, TEXT_URI_LIST_VALUE }) | |||
public ResponseEntity<? extends RepresentationModel<?>> createPropertyReference( | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: You can find formatting settings at https://github.com/spring-projects/spring-data-build/tree/main/etc/ide
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -78,6 +77,7 @@ class RepositoryPropertyReferenceController /*extends AbstractRepositoryRestCont | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: We use tab indents, not spaces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
} | ||
|
||
/*@Test // GH-2495 | ||
void rejectsInvalidContentTypeForSingleValuedAssociation() throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding new commented-out code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. 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
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.