Search in sources :

Example 1 with MatchingEntityTag

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;
    }
}
Also used : MatchingEntityTag(org.glassfish.jersey.message.internal.MatchingEntityTag) ResourceContext(javax.ws.rs.container.ResourceContext) MatchingEntityTag(org.glassfish.jersey.message.internal.MatchingEntityTag)

Aggregations

ResourceContext (javax.ws.rs.container.ResourceContext)1 MatchingEntityTag (org.glassfish.jersey.message.internal.MatchingEntityTag)1