Package javax.ws.rs.core

Examples of javax.ws.rs.core.EntityTag


    }

    ClientResponse response = path.head();
    ActionResponse.verifyNoError( response );

    EntityTag entityTag = response.getEntityTag();
    if ( entityTag == null ) {
      throw new IllegalArgumentException( "No Etag found" );
    }
    return new Revision( entityTag.getValue() );
  }
View Full Code Here


         * runtime will quote the supplied value when creating the header. If
         * null any existing entity tag value will be removed.
         * @return the updated instance
         */
        public B tag(String tag) {
            return tag(tag == null ? null : new EntityTag(tag));
        }
View Full Code Here

                // 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 {
View Full Code Here

        String contentEncoding = (String) response.getHttpHeaders().getFirst(HttpHeaders.CONTENT_ENCODING);

        if (acceptEncoding != null && contentEncoding == null && acceptEncoding.contains("gzip")) {
            // Check EntityTag header
            if (response.getHttpHeaders().containsKey(HttpHeaders.ETAG)) {
                EntityTag entityTag = (EntityTag) response.getHttpHeaders().getFirst(HttpHeaders.ETAG);
                if (entityTag != null) {
                    response.getHttpHeaders().putSingle(HttpHeaders.ETAG, new EntityTag(entityTag.getValue()
                            + ENTITY_TAG_GZIP_SUFFIX_VALUE, entityTag.isWeak()));
                }
            }

            // wrap entity with gzip
            if (response.getEntity() != null) {
View Full Code Here

            return this;
        }

        @Override
        public javax.ws.rs.core.Response.ResponseBuilder tag(String tag) {
            return tag(tag == null ? null : new EntityTag(tag));
        }
View Full Code Here

        try {
            HttpHeaderReader reader = HttpHeaderReader.newInstance(header);
            Event e = reader.next(false);
            if (e == Event.QuotedString) {
                return new EntityTag(reader.getEventValue());
            } else if (e == Event.Token) {
                if (reader.getEventValue().equals("W")) {
                    reader.nextSeparator('/');
                    return new EntityTag(reader.nextQuotedString(), true);
                }
            }
        } catch (ParseException ex) {
            throw new IllegalArgumentException(
                    "Error parsing entity tag '" + header + "'", ex);
View Full Code Here

                // 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
View Full Code Here

        try {
            for (String value : ifMatch) {
                if ("*".equals(value)) {
                    return null;
                }
                EntityTag requestTag = EntityTag.valueOf(value);
                // must be a strong comparison
                if (!requestTag.isWeak() && !eTag.isWeak() && requestTag.equals(eTag)) {
                    return null;
                }
            }
        } catch (IllegalArgumentException ex) {
            // ignore
View Full Code Here

        boolean getOrHead = "GET".equals(method) || "HEAD".equals(method);
        try {
            for (String value : ifNonMatch) {
                boolean result = "*".equals(value);
                if (!result) {
                    EntityTag requestTag = EntityTag.valueOf(value);
                    result = getOrHead ? requestTag.equals(eTag)
                        : !requestTag.isWeak() && !eTag.isWeak() && requestTag.equals(eTag);
                }
                if (result) {
                    Response.Status status = getOrHead ? Response.Status.NOT_MODIFIED
                        : Response.Status.PRECONDITION_FAILED;
                    return Response.status(status).tag(eTag);
View Full Code Here

        assertSame(var, new RequestImpl(m).selectVariant(list));   
    }
   
    @Test
    public void testWeakEtags() {
        metadata.putSingle("If-Match", new EntityTag("123", true).toString());
       
        ResponseBuilder rb =
            new RequestImpl(m).evaluatePreconditions(new EntityTag("123"));
        assertNotNull("Strict compararison is required", rb);
        Response r = rb.build();
        assertEquals("If-Match precondition was not met", 412, r.getStatus());
        assertEquals("Response should include ETag",
                     "\"123\"", r.getMetadata().getFirst("ETag"));
View Full Code Here

TOP

Related Classes of javax.ws.rs.core.EntityTag

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.