Skip to content

Conversation

@RachelTucker
Copy link
Contributor

Changes

  • created GetObjectCustomParser which takes a function as a parameter
  • added overload in client for getObject which takes in a function and creates a GetObjectCustomParser
  • added integration test to verify overload works properly

* @param <T> function input
* @param <R> function output
*/
public interface Function<T, R> {
Copy link
Contributor

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
Copy link
Contributor

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> {
Copy link
Contributor

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

Copy link
Contributor Author

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 {
Copy link
Contributor

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) {
Copy link
Contributor

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.

Copy link
Contributor Author

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();
Copy link
Contributor

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

Copy link
Contributor Author

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

@rpmoore rpmoore merged commit 2433d90 into SpectraLogic:master Nov 15, 2016
@RachelTucker RachelTucker deleted the get_object_parsing_overload branch November 15, 2016 22:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants