Return-Path: X-Original-To: apmail-cxf-commits-archive@www.apache.org Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id AF3EE7834 for ; Wed, 20 Jul 2011 23:07:19 +0000 (UTC) Received: (qmail 78066 invoked by uid 500); 20 Jul 2011 23:07:19 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 77956 invoked by uid 500); 20 Jul 2011 23:07:18 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 77948 invoked by uid 99); 20 Jul 2011 23:07:18 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 20 Jul 2011 23:07:18 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 20 Jul 2011 23:07:16 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id B971F2388A2C for ; Wed, 20 Jul 2011 23:06:56 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1148967 - in /cxf/branches/2.3.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/ Date: Wed, 20 Jul 2011 23:06:56 -0000 To: commits@cxf.apache.org From: sergeyb@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110720230656.B971F2388A2C@eris.apache.org> Author: sergeyb Date: Wed Jul 20 23:06:55 2011 New Revision: 1148967 URL: http://svn.apache.org/viewvc?rev=1148967&view=rev Log: Merged revisions 1148964 via svnmerge from https://svn.apache.org/repos/asf/cxf/branches/2.4.x-fixes ................ r1148964 | sergeyb | 2011-07-21 00:01:47 +0100 (Thu, 21 Jul 2011) | 9 lines Merged revisions 1148962 via svnmerge from https://svn.apache.org/repos/asf/cxf/trunk ........ r1148962 | sergeyb | 2011-07-20 23:56:12 +0100 (Wed, 20 Jul 2011) | 1 line [CXF-3673] Make ResponseBuilder.tag methods produce consistent header values ........ ................ Modified: cxf/branches/2.3.x-fixes/ (props changed) cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/EntityTagHeaderProvider.java cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseBuilderImpl.java cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/ResponseBuilderImplTest.java Propchange: cxf/branches/2.3.x-fixes/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Wed Jul 20 23:06:55 2011 @@ -1,2 +1,2 @@ -/cxf/branches/2.4.x-fixes:1144979,1147505 -/cxf/trunk:1144977,1147504 +/cxf/branches/2.4.x-fixes:1144979,1147505,1148964 +/cxf/trunk:1144977,1147504,1148962 Propchange: cxf/branches/2.3.x-fixes/ ------------------------------------------------------------------------------ Binary property 'svnmerge-integrated' - no diff available. Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/EntityTagHeaderProvider.java URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/EntityTagHeaderProvider.java?rev=1148967&r1=1148966&r2=1148967&view=diff ============================================================================== --- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/EntityTagHeaderProvider.java (original) +++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/EntityTagHeaderProvider.java Wed Jul 20 23:06:55 2011 @@ -50,6 +50,9 @@ public class EntityTagHeaderProvider imp } else { tag = header; } + if (tag.length() > 0 && !tag.startsWith("\"") && !tag.endsWith("\"")) { + return new EntityTag(tag, weak); + } if (tag.length() < 2 || !tag.startsWith("\"") || !tag.endsWith("\"")) { throw new IllegalArgumentException("Misformatted ETag : " + header); } @@ -62,7 +65,12 @@ public class EntityTagHeaderProvider imp if (tag.isWeak()) { sb.append(WEAK_PREFIX); } - sb.append("\"").append(tag.getValue()).append("\""); + String tagValue = tag.getValue(); + if (!tagValue.startsWith("\"")) { + sb.append("\"").append(tagValue).append("\""); + } else { + sb.append(tagValue); + } return sb.toString(); } Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseBuilderImpl.java URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseBuilderImpl.java?rev=1148967&r1=1148966&r2=1148967&view=diff ============================================================================== --- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseBuilderImpl.java (original) +++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseBuilderImpl.java Wed Jul 20 23:06:55 2011 @@ -113,11 +113,13 @@ public final class ResponseBuilderImpl e } public ResponseBuilder tag(EntityTag tag) { - return tag(tag == null ? null : tag.toString()); + return setHeader(HttpHeaders.ETAG, tag == null ? null : tag.toString()); } public ResponseBuilder tag(String tag) { - return setHeader(HttpHeaders.ETAG, tag); + // String tag value needs to be parsed as it may + // contain parameters indicating it's a weak tag, etc + return tag(tag == null ? null : EntityTag.valueOf(tag)); } public ResponseBuilder lastModified(Date date) { Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/ResponseBuilderImplTest.java URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/ResponseBuilderImplTest.java?rev=1148967&r1=1148966&r2=1148967&view=diff ============================================================================== --- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/ResponseBuilderImplTest.java (original) +++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/ResponseBuilderImplTest.java Wed Jul 20 23:06:55 2011 @@ -25,6 +25,7 @@ import java.util.Date; import java.util.List; import java.util.Locale; +import javax.ws.rs.core.EntityTag; import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.NewCookie; @@ -83,6 +84,34 @@ public class ResponseBuilderImplTest ext } @Test + public void testTagString() { + Response r = Response.ok().tag("foo").build(); + String eTag = r.getMetadata().getFirst("ETag").toString(); + assertEquals("\"foo\"", eTag); + } + + @Test + public void testTagStringWithQuotes() { + Response r = Response.ok().tag("\"foo\"").build(); + String eTag = r.getMetadata().getFirst("ETag").toString(); + assertEquals("\"foo\"", eTag); + } + + @Test + public void testEntityTag() { + Response r = Response.ok().tag(new EntityTag("foo")).build(); + String eTag = r.getMetadata().getFirst("ETag").toString(); + assertEquals("\"foo\"", eTag); + } + + @Test + public void testEntityTag2() { + Response r = Response.ok().tag(new EntityTag("\"foo\"")).build(); + String eTag = r.getMetadata().getFirst("ETag").toString(); + assertEquals("\"foo\"", eTag); + } + + @Test public void testExpires() throws Exception { MetadataMap m = new MetadataMap(); m.putSingle("Expires", "Tue, 21 Oct 2008 17:00:00 GMT");