private Response.ResponseBuilder evaluateIfNoneMatch( EntityTag eTag, Set<? extends EntityTag> matchingTags, boolean isGetOrHead) { if (isGetOrHead) { if (matchingTags == MatchingEntityTag.ANY_MATCH) { // 304 Not modified return Response.notModified(eTag); } // The weak comparison function may be used to compare entity tags if (matchingTags.contains(eTag) || matchingTags.contains(new EntityTag(eTag.getValue(), !eTag.isWeak()))) { // 304 Not modified return Response.notModified(eTag); } } else { // The strong comparison function must be used to compare the entity // tags. Thus if the entity tag of the entity is weak then matching // of entity tags in the If-None-Match header should fail if the // HTTP method is not GET or not HEAD. if (eTag.isWeak()) { return null; } if (matchingTags == MatchingEntityTag.ANY_MATCH || matchingTags.contains(eTag)) { // 412 Precondition Failed return Response.status(Response.Status.PRECONDITION_FAILED); } } return null; }
// Private methods private Response.ResponseBuilder evaluateIfMatch(EntityTag eTag) { Set<? extends EntityTag> matchingTags = getIfMatch(); if (matchingTags == null) { return null; } // The strong comparison function must be used to compare the entity // tags. Thus if the entity tag of the entity is weak then matching // of entity tags in the If-Match header should fail. if (eTag.isWeak()) { return Response.status(Response.Status.PRECONDITION_FAILED); } if (matchingTags != MatchingEntityTag.ANY_MATCH && !matchingTags.contains(eTag)) { // 412 Precondition Failed return Response.status(Response.Status.PRECONDITION_FAILED); } return null; }