You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by ja...@apache.org on 2014/11/12 16:30:16 UTC

marmotta git commit: MARMOTTA-569: Fixed getContainer method that caused resources created by PUT not to be added to their container.

Repository: marmotta
Updated Branches:
  refs/heads/develop d3f9ff540 -> 4f5394857


MARMOTTA-569: Fixed getContainer method that caused resources created by PUT not to be added to their container.


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

Branch: refs/heads/develop
Commit: 4f53948572b9f28b8e6f6f56f7ce02d5f6a3273d
Parents: d3f9ff5
Author: Jakob Frank <ja...@apache.org>
Authored: Wed Nov 12 16:16:30 2014 +0100
Committer: Jakob Frank <ja...@apache.org>
Committed: Wed Nov 12 16:16:30 2014 +0100

----------------------------------------------------------------------
 .../org/apache/marmotta/platform/ldp/util/LdpUtils.java   | 10 ++++++----
 .../marmotta/platform/ldp/webservices/LdpWebService.java  |  2 +-
 2 files changed, 7 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/4f539485/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/util/LdpUtils.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/util/LdpUtils.java b/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/util/LdpUtils.java
index 5e539a8..326f55f 100644
--- a/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/util/LdpUtils.java
+++ b/platform/marmotta-ldp/src/main/java/org/apache/marmotta/platform/ldp/util/LdpUtils.java
@@ -148,13 +148,15 @@ public class LdpUtils {
     }
 
     public static String getContainer(String resource) throws MalformedURLException, URISyntaxException {
-        java.net.URI uri = new java.net.URI(resource);
-        java.net.URI parent = uri.getPath().endsWith("/") ? uri.resolve("..") : uri.resolve(".");
-        return parent.toASCIIString();
+        final int fragmentIndex = resource.indexOf('#');
+        if (fragmentIndex >= 0) {
+            return resource.substring(0, fragmentIndex);
+        }
+        return resource.substring(0, resource.lastIndexOf('/', resource.length() - 1));
     }
 
     public static URI getContainer(URI resource) throws MalformedURLException, URISyntaxException {
-        return new URIImpl(resource.getNamespace());
+        return new URIImpl(getContainer(resource.stringValue()));
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/marmotta/blob/4f539485/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 d2a0c7c..92a799e 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
@@ -407,7 +407,7 @@ public class LdpWebService {
                 uriGenerator = new SlugUriGenerator(ldpService, container, slug, conn);
             }
 
-            String newResource = uriGenerator.generateResourceUri();
+            final String newResource = uriGenerator.generateResourceUri();
 
             log.debug("POST to <{}> will create new LDP-R <{}>", container, newResource);
             // connection is closed by buildPostResponse