Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 25 additions & 13 deletions org.restlet/src/main/java/org/restlet/resource/ServerResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -281,19 +281,7 @@ protected Representation doConditionalHandle() throws ResourceException {

RepresentationInfo resultInfo = null;
if (existing) {
Status before = getStatus();
resultInfo = doGetInfoAndHandleErrors();

if (resultInfo != null) {
doConditionalHandle(resultInfo);
} else if (isGetNotAllowed()) {
// The resource supports the method but cannot be read, so no validator is known
// (#1753): the 405 of the missing GET does not concern this request. The
// preconditions are evaluated as for a resource with no known representation.
setStatus(before);
getAllowedMethods().clear();
doConditionalHandle((RepresentationInfo) null);
}
resultInfo = retrieveValidatorsAndEvaluate();
} else {
doConditionalHandle(resultInfo);
}
Expand All @@ -315,6 +303,30 @@ protected Representation doConditionalHandle() throws ResourceException {
return result;
}

/**
* Retrieves the validators of the current representation of an existing resource and evaluates
* the preconditions against them.
*
* @return The current representation, or null if it could not be retrieved.
*/
private RepresentationInfo retrieveValidatorsAndEvaluate() {
Status before = getStatus();
RepresentationInfo resultInfo = doGetInfoAndHandleErrors();

if (resultInfo != null) {
doConditionalHandle(resultInfo);
} else if (isGetNotAllowed()) {
// The resource supports the method but cannot be read, so no validator is known
// (#1753): the 405 of the missing GET does not concern this request. The
// preconditions are evaluated as for a resource with no known representation.
setStatus(before);
getAllowedMethods().clear();
doConditionalHandle((RepresentationInfo) null);
}

return resultInfo;
}

/**
* Handles a call by first verifying the optional request conditions.
*
Expand Down
Loading