]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - org.argeo.slc.core/src/main/java/org/argeo/slc/spring/SpringUtils.java
Restructure example
[gpl/argeo-slc.git] / org.argeo.slc.core / src / main / java / org / argeo / slc / spring / SpringUtils.java
index 73f1ffde37647b9465267ef4cec4316e6dcd17c5..8ef13560cf2695a84139c91ad9d77dafe67b2d8b 100644 (file)
@@ -27,7 +27,7 @@ public class SpringUtils {
                try {\r
                        if (res.getURL().getPath().equals("/"))\r
                                return null;\r
-\r
+                       \r
                        String urlStr = res.getURL().toString();\r
                        if (urlStr.charAt(urlStr.length() - 1) == '/')\r
                                urlStr = urlStr.substring(0, urlStr.length() - 2);\r
@@ -42,14 +42,8 @@ public class SpringUtils {
 \r
        public static String extractRelativePath(Resource ancestor, Resource child) {\r
                try {\r
-                       String childPath = child.getURL().getPath();\r
-                       String ancestorPath = ancestor.getURL().getPath();\r
-\r
-                       if (log.isTraceEnabled())\r
-                               log.trace("extractRelativePath(): childPath=" + childPath\r
-                                               + ", ancestorPath=" + ancestorPath);\r
-\r
-                       return childPath.substring(ancestorPath.length());\r
+                       \r
+                       return ancestor.getURI().relativize(child.getURI()).toString();\r
                } catch (IOException e) {\r
                        throw new SlcException("Cannot extract relative path of " + child\r
                                        + " based on " + ancestor, e);\r