Hi,
On 30/08/13 11:09, Jakob Frank wrote:
What I don't like with the url-encoded-directory names is that it
requires the detection of absolute URIs vs. relative URIs for contexts
to be hard coded.
But this would keep the implementation much more simpler (see attached a
draft patch for solving MARMOTTA-293 using url-encoded directories). I
agree that a config file would be much more flexible, but this of course
complicates the watch process introducing exceptions for some special
file names and so.
Not sure...
--
Sergio Fernández
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/importer/ImportWatchServiceImpl.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/importer/ImportWatchServiceImpl.java
index 54f16c1..0e42a93 100644
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/importer/ImportWatchServiceImpl.java
+++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/importer/ImportWatchServiceImpl.java
@@ -20,6 +20,8 @@ package org.apache.marmotta.platform.core.services.importer;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -194,7 +196,16 @@ public class ImportWatchServiceImpl implements ImportWatchService {
if (StringUtils.isBlank(subdir)) {
return contextService.getDefaultContext();
} else {
- return contextService.createContext(configurationService.getBaseContext() + subdir.substring(1));
+ if (StringUtils.startsWith(subdir, "http%3A%2F%2F")) {
+ try {
+ return contextService.createContext(URLDecoder.decode(subdir, "UTF-8"));
+ } catch (UnsupportedEncodingException e) {
+ log.error("Error url-decoding context name '{}', so using the default one: {}", subdir, e.getMessage());
+ return contextService.getDefaultContext();
+ }
+ } else {
+ return contextService.createContext(configurationService.getBaseContext() + subdir.substring(1));
+ }
}
}