use of org.glassfish.jersey.message.internal.MatchingEntityTag in project gravitee-management-rest-api by gravitee-io.
the class ApiResource method evaluateIfMatch.
private Response.ResponseBuilder evaluateIfMatch(final HttpHeaders headers, final String etagValue) {
String ifMatch = headers.getHeaderString(HttpHeaders.IF_MATCH);
if (ifMatch == null || ifMatch.isEmpty()) {
return null;
}
// Handle case for -gzip appended automatically (and sadly) by Apache
ifMatch = ifMatch.replaceAll("-gzip", "");
try {
Set<MatchingEntityTag> matchingTags = HttpHeaderReader.readMatchingEntityTag(ifMatch);
MatchingEntityTag ifMatchHeader = matchingTags.iterator().next();
EntityTag eTag = new EntityTag(etagValue, ifMatchHeader.isWeak());
return matchingTags != MatchingEntityTag.ANY_MATCH && !matchingTags.contains(eTag) ? Response.status(Status.PRECONDITION_FAILED) : null;
} catch (java.text.ParseException e) {
return null;
}
}
Aggregations