marmotta-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wik...@apache.org
Subject [1/3] git commit: MARMOTTA-526: fixed potential invalid regex-pattern with Windows-paths for the FileSystemContentReader/-Writer
Date Thu, 11 Sep 2014 07:03:43 GMT
Repository: marmotta
Updated Branches:
  refs/heads/ldp d80cd6421 -> 37a228490


MARMOTTA-526: fixed potential invalid regex-pattern with Windows-paths for the FileSystemContentReader/-Writer


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

Branch: refs/heads/ldp
Commit: 3960741c269a4d9e5f247cf0b5c5cda0ff624aed
Parents: 30ef267
Author: Jakob Frank <jakob@apache.org>
Authored: Thu Sep 4 15:09:11 2014 +0200
Committer: Jakob Frank <jakob@apache.org>
Committed: Thu Sep 4 15:09:11 2014 +0200

----------------------------------------------------------------------
 .../config/ConfigurationServiceImpl.java        | 21 ++++++++++++++++++++
 .../services/content/ContentServiceImpl.java    |  1 +
 .../main/resources/config-defaults.properties   |  2 +-
 3 files changed, 23 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/3960741c/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/config/ConfigurationServiceImpl.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/config/ConfigurationServiceImpl.java
b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/config/ConfigurationServiceImpl.java
index 416d9c4..cece731 100644
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/config/ConfigurationServiceImpl.java
+++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/config/ConfigurationServiceImpl.java
@@ -20,6 +20,8 @@ package org.apache.marmotta.platform.core.services.config;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
 import org.apache.commons.configuration.*;
+import org.apache.commons.configuration.interpol.ConfigurationInterpolator;
+import org.apache.commons.lang.text.StrLookup;
 import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.marmotta.platform.core.api.config.ConfigurationService;
@@ -42,8 +44,10 @@ import javax.management.ObjectName;
 import javax.servlet.ServletContext;
 import java.io.File;
 import java.io.IOException;
+import java.io.UnsupportedEncodingException;
 import java.lang.reflect.Array;
 import java.net.URL;
+import java.net.URLEncoder;
 import java.net.UnknownHostException;
 import java.nio.file.AtomicMoveNotSupportedException;
 import java.nio.file.Files;
@@ -244,6 +248,23 @@ public class ConfigurationServiceImpl implements ConfigurationService
{
                 saveMetadata      = new MapConfiguration(new HashMap<String, Object>());
             }
             config = new FallbackConfiguration();
+            final ConfigurationInterpolator _int = config.getInterpolator();
+            _int.registerLookup("pattern.quote", new StrLookup() {
+                @Override
+                public String lookup(String key) {
+                    return Pattern.quote(_int.getDefaultLookup().lookup(key));
+                }
+            });
+            _int.registerLookup("urlencode", new StrLookup() {
+                @Override
+                public String lookup(String key) {
+                    try {
+                        return URLEncoder.encode(_int.getDefaultLookup().lookup(key), "utf8");
+                    } catch (UnsupportedEncodingException e) {
+                        return _int.getDefaultLookup().lookup(key);
+                    }
+                }
+            });
             config.addConfiguration(saveConfiguration,true);
 
             // load all default-config.properties

http://git-wip-us.apache.org/repos/asf/marmotta/blob/3960741c/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/content/ContentServiceImpl.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/content/ContentServiceImpl.java
b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/content/ContentServiceImpl.java
index e756c31..6f7aa00 100644
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/content/ContentServiceImpl.java
+++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/content/ContentServiceImpl.java
@@ -101,6 +101,7 @@ public class ContentServiceImpl implements ContentService {
             String enabledStr  = configurationService.getStringConfiguration("content."+configName+".enabled");
 
             if(Boolean.parseBoolean(enabledStr)) {
+                log.debug("Initializing content provider {}", configName);
                 ContentReader reader = null;
                 ContentWriter writer = null;
                 Pattern pattern = null;

http://git-wip-us.apache.org/repos/asf/marmotta/blob/3960741c/platform/marmotta-core/src/main/resources/config-defaults.properties
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/resources/config-defaults.properties b/platform/marmotta-core/src/main/resources/config-defaults.properties
index 6e0f91b..3073c5b 100644
--- a/platform/marmotta-core/src/main/resources/config-defaults.properties
+++ b/platform/marmotta-core/src/main/resources/config-defaults.properties
@@ -124,7 +124,7 @@ logging.file.debug.keep    = 30
 # to only enable reading but disable writing, remove the content.filesystem.writer property
 content.filesystem.reader=org.apache.marmotta.platform.core.services.content.FileSystemContentReader
 content.filesystem.writer=org.apache.marmotta.platform.core.services.content.FileSystemContentWriter
-content.filesystem.pattern=(${marmotta.home}/resources|${kiwi.context}resource/|urn:).*
+content.filesystem.pattern=(${pattern.quote:marmotta.home}/resources|${pattern.quote:kiwi.context}resource/|urn:).*
 #content.filesystem.pattern=file:/tmp/.*
 content.filesystem.enabled=true
 # if enabled allow only access to resources stored in the work directory


Mime
View raw message