-
Notifications
You must be signed in to change notification settings - Fork 1
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
Fix response status if not found (#39) #40
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,7 +93,6 @@ public static <T> T readEntityIfOk(Response response, Class<T> entityType) { | |
} else { | ||
throw createUnexpectedResponseStatus(status); | ||
} | ||
|
||
} | ||
|
||
public static <T> T readEntityIfOk(Response response, GenericType<T> entityType) { | ||
|
@@ -114,16 +113,13 @@ public static <T> T readEntityIfOk(Response response, GenericType<T> entityType) | |
|
||
public static <T> Optional<T> readOptionalEntityIfOk(Response response, Class<T> entityType) { | ||
Response.Status status = Response.Status.fromStatusCode(response.getStatus()); | ||
if (status == Response.Status.OK) { | ||
return Optional.of(readEntityAndLog(response, entityType)); | ||
} else if (status == Response.Status.NO_CONTENT) { | ||
// the NO_CONTENT case is for backwards compatibility. | ||
// The remote AppStorageServer may still runs on an old version which response with 204 if it not found resources. | ||
if (status == Response.Status.NO_CONTENT || status == Response.Status.NOT_FOUND) { | ||
LOGGER.trace(" --> null"); | ||
return Optional.empty(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you remove the INTERNAL_SERVER_ERROR case ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and the UnexpectedResponse case ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these cases are still checked in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah yes sorry, didn't see it. |
||
} else if (status == Response.Status.INTERNAL_SERVER_ERROR) { | ||
throw createServerErrorException(response); | ||
} else { | ||
throw createUnexpectedResponseStatus(status); | ||
} | ||
return Optional.of(readEntityIfOk(response, entityType)); | ||
} | ||
|
||
public static UserSession authenticate(URI baseUri, String login, String password) { | ||
|
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.
Maybe add a comment that the NO_CONTENT is for backwards compatibility with afs-server < version XX