-
Notifications
You must be signed in to change notification settings - Fork 13
Get object parsing overload #389
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
Get object parsing overload #389
Conversation
| * @param <T> function input | ||
| * @param <R> function output | ||
| */ | ||
| public interface Function<T, R> { |
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.
Move this method to the utils package
| .response(this.netClient.getResponse(request)); | ||
| } | ||
|
|
||
| @Override |
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.
Missing final on the Function param
| /** | ||
| * Creates a custom parser which is used in {@link com.spectralogic.ds3client.Ds3Client#getObject(GetObjectRequest, Function)} )} | ||
| */ | ||
| public class GetObjectCustomParser extends AbstractResponseParser<GetObjectResponse> { |
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.
This should probably be package private
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.
I can't make it package-private because then the client impl can't see it
| } | ||
|
|
||
| @Override | ||
| public GetObjectResponse parseXmlResponse(WebResponse response) throws IOException { |
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.
Missing final
| try { | ||
| client.getObject(request, new Function<GetObjectCustomParserParameters, GetObjectResponse>() { | ||
| @Override | ||
| public GetObjectResponse apply(GetObjectCustomParserParameters getObjectParserParams) { |
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.
My assumption is that the call would have failed before getting to this point. If that's not the case, the GetObjectCustomParser needs to handle this.
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.
Checking status code is done the the parseXmlResponse function, so its not done in the AbstractResponseParser. I can add the status code check to the GetObjectCustomParser before calling the user specified function
| return null; | ||
| } | ||
| }); | ||
| fail(); |
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.
You don't need this fail check since you have the @Test (expected = ...) annotation
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.
Good point, I will remove
Changes
GetObjectCustomParserwhich takes a function as a parametergetObjectwhich takes in a function and creates aGetObjectCustomParser