marmotta-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ja...@apache.org
Subject [2/3] git commit: MARMOTTA-532: Removed custom implementation for parsing EntityTags, since the bug was fixed upstream.
Date Tue, 16 Sep 2014 15:45:26 GMT
MARMOTTA-532: Removed custom implementation for parsing EntityTags, since the bug was fixed
upstream.


Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/87623b18
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/87623b18
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/87623b18

Branch: refs/heads/ldp
Commit: 87623b181f8726ab5eab52392e601a3556ad3495
Parents: 4061e34
Author: Jakob Frank <jakob@apache.org>
Authored: Mon Sep 15 10:17:42 2014 +0200
Committer: Jakob Frank <jakob@apache.org>
Committed: Tue Sep 16 17:45:07 2014 +0200

----------------------------------------------------------------------
 .../platform/ldp/util/EntityTagUtils.java       | 72 --------------------
 .../platform/ldp/webservices/LdpWebService.java |  5 +-
 .../ldp/webservices/LdpWebServiceTest.java      |  5 +-
 .../ldp/webservices/util/HeaderMatchers.java    |  8 ++-
 4 files changed, 9 insertions(+), 81 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/87623b18/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/util/EntityTagUtils.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/util/EntityTagUtils.java
b/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/util/EntityTagUtils.java
deleted file mode 100644
index a695096..0000000
--- a/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/util/EntityTagUtils.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.marmotta.platform.ldp.util;
-
-import javax.ws.rs.core.EntityTag;
-
-/**
- *
- * @deprecated this is a workaround for <a href="https://issues.jboss.org/browse/RESTEASY-1019">RESTEASY-1019</a>
- */
-@Deprecated
-public class EntityTagUtils {
-
-    /**
-     * This is a workaround for <a href="https://issues.jboss.org/browse/RESTEASY-1019">RESTEASY-1019</a>
-     *
-     * @see javax.ws.rs.core.EntityTag#equals(Object)
-     * @deprecated use {@link javax.ws.rs.core.EntityTag#equals(Object)} or {@link javax.ws.rs.core.Request#evaluatePreconditions(javax.ws.rs.core.EntityTag)}
when RESTEASY-1019 is fixed.
-     */
-    @Deprecated
-    public static boolean equals(EntityTag tag1, EntityTag tag2) {
-        if (tag1 == null || tag2 == null) return false;
-
-        // If it works, it's fine
-        if (tag1.equals(tag2)) {
-            return true;
-        } else {
-            // Weak-Tag comparison requires extra check because of RESTEASY-1019
-            if (tag1.isWeak() && tag2.isWeak()) {
-                return tag1.getValue().replaceAll("^\"", "").equals(
-                        tag2.getValue().replaceAll("^\"", "")
-                );
-            }
-            return false;
-        }
-    }
-
-    /**
-     * This is a workaround for <a href="https://issues.jboss.org/browse/RESTEASY-1019">RESTEASY-1019</a>
-     *
-     * @see javax.ws.rs.core.EntityTag#equals(Object)
-     * @deprecated use {@link javax.ws.rs.core.EntityTag#valueOf(String)} when RESTEASY-1019
is fixed.
-     */
-    @Deprecated
-    public static EntityTag parseEntityTag(String headerValue) {
-        boolean weak = false;
-        if (headerValue.startsWith("W/")) {
-            weak = true;
-            headerValue = headerValue.substring(2);
-        }
-        if (headerValue.startsWith("\"") && headerValue.endsWith("\"")) {
-            headerValue = headerValue.substring(1, headerValue.length() -1);
-        }
-        return new EntityTag(headerValue,weak);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/87623b18/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/webservices/LdpWebService.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/webservices/LdpWebService.java
b/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/webservices/LdpWebService.java
index b18f4e3..08599e0 100644
--- a/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/webservices/LdpWebService.java
+++ b/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/webservices/LdpWebService.java
@@ -32,7 +32,6 @@ import org.apache.marmotta.platform.ldp.exceptions.InvalidModificationException;
 import org.apache.marmotta.platform.ldp.patch.InvalidPatchDocumentException;
 import org.apache.marmotta.platform.ldp.patch.parser.ParseException;
 import org.apache.marmotta.platform.ldp.patch.parser.RdfPatchParser;
-import org.apache.marmotta.platform.ldp.util.EntityTagUtils;
 import org.apache.marmotta.platform.ldp.util.LdpUtils;
 import org.apache.marmotta.platform.ldp.util.ResponseBuilderImpl;
 import org.jboss.resteasy.spi.NoLogWebApplicationException;
@@ -478,7 +477,7 @@ public class LdpWebService {
                     // check ETag -> 412 Precondition Failed (Sec. 4.2.4.5)
                     log.trace("Checking If-Match: {}", eTag);
                     EntityTag hasTag = ldpService.generateETag(conn, resource);
-                    if (!EntityTagUtils.equals(eTag, hasTag)) {
+                    if (!eTag.equals(hasTag)) {
                         log.trace("If-Match header did not match, expected {}", hasTag);
                         resp = createResponse(conn, Response.Status.PRECONDITION_FAILED,
resource);
                         conn.rollback();
@@ -600,7 +599,7 @@ public class LdpWebService {
                 // check ETag if present
                 log.trace("Checking If-Match: {}", eTag);
                 EntityTag hasTag = ldpService.generateETag(con, resource);
-                if (!EntityTagUtils.equals(eTag, hasTag)) {
+                if (!eTag.equals(hasTag)) {
                     log.trace("If-Match header did not match, expected {}", hasTag);
                     final Response.ResponseBuilder resp = createResponse(con, Response.Status.PRECONDITION_FAILED,
resource);
                     con.rollback();

http://git-wip-us.apache.org/repos/asf/marmotta/blob/87623b18/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/LdpWebServiceTest.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/LdpWebServiceTest.java
b/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/LdpWebServiceTest.java
index d98cab1..81412e8 100644
--- a/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/LdpWebServiceTest.java
+++ b/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/LdpWebServiceTest.java
@@ -27,7 +27,6 @@ import org.apache.marmotta.commons.util.HashUtils;
 import org.apache.marmotta.commons.vocabulary.LDP;
 import org.apache.marmotta.platform.core.exception.io.MarmottaImportException;
 import org.apache.marmotta.platform.core.test.base.JettyMarmotta;
-import org.apache.marmotta.platform.ldp.util.EntityTagUtils;
 import org.apache.marmotta.platform.ldp.util.LdpUtils;
 import org.apache.marmotta.platform.ldp.webservices.util.HeaderMatchers;
 import org.hamcrest.CoreMatchers;
@@ -347,7 +346,7 @@ public class LdpWebServiceTest {
         final URI uri = new URIImpl(resource);
 
         // Check the data is there
-        EntityTag etag = EntityTagUtils.parseEntityTag(RestAssured
+        EntityTag etag = EntityTag.valueOf(RestAssured
             .given()
                 .header(HttpHeaders.ACCEPT, RDFFormat.RDFXML.getDefaultMIMEType())
             .expect()
@@ -391,7 +390,7 @@ public class LdpWebServiceTest {
             .put(resource);
 
         // Check the new data is there
-        etag = EntityTagUtils.parseEntityTag(RestAssured
+        etag = EntityTag.valueOf(RestAssured
             .given()
                 .header(HttpHeaders.ACCEPT, RDFFormat.RDFXML.getDefaultMIMEType())
             .expect()

http://git-wip-us.apache.org/repos/asf/marmotta/blob/87623b18/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/util/HeaderMatchers.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/util/HeaderMatchers.java
b/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/util/HeaderMatchers.java
index 80f4026..f2c90f8 100644
--- a/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/util/HeaderMatchers.java
+++ b/platform/marmotta-ldp/src/test/java/org/apache/marmotta/platform/ldp/webservices/util/HeaderMatchers.java
@@ -18,8 +18,10 @@
 package org.apache.marmotta.platform.ldp.webservices.util;
 
 import org.apache.commons.lang3.StringUtils;
-import org.apache.marmotta.platform.ldp.util.EntityTagUtils;
-import org.hamcrest.*;
+import org.hamcrest.BaseMatcher;
+import org.hamcrest.CustomTypeSafeMatcher;
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
 import org.jboss.resteasy.plugins.delegates.EntityTagDelegate;
 import org.jboss.resteasy.plugins.delegates.LinkDelegate;
 
@@ -90,7 +92,7 @@ public class HeaderMatchers {
         return new CustomTypeSafeMatcher<String>(String.format("an EntityTag %s", expected))
{
             @Override
             protected boolean matchesSafely(String item) {
-                return EntityTagUtils.equals(expected, new EntityTagDelegate().fromString(item));
+                return expected.equals(new EntityTagDelegate().fromString(item));
             }
         };
     }


Mime
View raw message