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
\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