You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by rw...@apache.org on 2011/04/07 14:25:49 UTC

svn commit: r1089854 - /incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/impl/MainDataFileProvider.java

Author: rwesten
Date: Thu Apr  7 12:25:48 2011
New Revision: 1089854

URL: http://svn.apache.org/viewvc?rev=1089854&view=rev
Log:
- Changed the default for the DataFileFolder form "datafiles" to "sling/datafilde"
- The DataFileFolder is now created if it not already exists
- If the DataFileFolder can not be created a ConfigurationException is thrown
- If the DataFileFolder exists, but is not a Directory a ConfigurationException is thrown
- Exceptions of other DataFileProviders do no longer break the processing of the MainDataFileProvider

Modified:
    incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/impl/MainDataFileProvider.java

Modified: incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/impl/MainDataFileProvider.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/impl/MainDataFileProvider.java?rev=1089854&r1=1089853&r2=1089854&view=diff
==============================================================================
--- incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/impl/MainDataFileProvider.java (original)
+++ incubator/stanbol/trunk/commons/stanboltools/datafileprovider/src/main/java/org/apache/stanbol/commons/stanboltools/datafileprovider/impl/MainDataFileProvider.java Thu Apr  7 12:25:48 2011
@@ -58,7 +58,7 @@ import org.slf4j.LoggerFactory;
 @Property(name=Constants.SERVICE_RANKING, intValue=Integer.MAX_VALUE)
 public class MainDataFileProvider implements DataFileProvider, DataFileProviderLog {
 
-    @Property(value="datafiles")
+    @Property(value="sling/datafiles")
     public static final String DATA_FILES_FOLDER_PROP = "data.files.folder";
 
     @Property(intValue=100)
@@ -79,6 +79,13 @@ public class MainDataFileProvider implem
     @Activate
     protected void activate(ComponentContext ctx) throws ConfigurationException {
         dataFilesFolder = new File(requireProperty(ctx.getProperties(), DATA_FILES_FOLDER_PROP, String.class));
+        if(!dataFilesFolder.exists()){
+            if(!dataFilesFolder.mkdirs()){
+                throw new ConfigurationException(DATA_FILES_FOLDER_PROP, "Unable to create the configured Directory "+dataFilesFolder);
+            }
+        } else if(!dataFilesFolder.isDirectory()){
+            throw new ConfigurationException(DATA_FILES_FOLDER_PROP, "The configured DataFile directory "+dataFilesFolder+" does already exists but is not a directory!");
+        } //else exists and is a directory!
         maxEvents = requireProperty(ctx.getProperties(), MAX_EVENTS_PROP, Integer.class).intValue();
         
         providersTracker = new ServiceTracker(ctx.getBundleContext(), DataFileProvider.class.getName(), null);
@@ -168,7 +175,14 @@ public class MainDataFileProvider implem
                     continue;
                 }
                 final DataFileProvider dfp = (DataFileProvider)o;
-                result = dfp.getInputStream(bundleSymbolicName, filename, comments);
+                try {
+                    result = dfp.getInputStream(bundleSymbolicName, filename, comments);
+                } catch (Exception e) {
+                    //Exceptions thrown by an implementation should never
+                    //affect the MainDataFileProvider
+                    log.debug(String.format("Eception while searching DataFile %s by using provider %s (ignore)",
+                        filename,dfp),e);
+                }
                 if(result == null) {
                     log.debug("{} does not provide file {}", dfp, filename);
                 } else {