Updated Branches:
  refs/heads/develop f53b62551 -> 9589f1ca4

support loading a directory of archives


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

Branch: refs/heads/develop
Commit: 9589f1ca4a742ea75e0b0643b7ec13e1b000b884
Parents: f53b625
Author: Sebastian Schaffert <[email protected]>
Authored: Wed Feb 5 18:23:03 2014 +0100
Committer: Sebastian Schaffert <[email protected]>
Committed: Wed Feb 5 18:23:03 2014 +0100

----------------------------------------------------------------------
 .../marmotta/loader/core/MarmottaLoader.java    | 23 ++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/9589f1ca/loader/marmotta-loader-core/src/main/java/org/apache/marmotta/loader/core/MarmottaLoader.java
----------------------------------------------------------------------
diff --git 
a/loader/marmotta-loader-core/src/main/java/org/apache/marmotta/loader/core/MarmottaLoader.java
 
b/loader/marmotta-loader-core/src/main/java/org/apache/marmotta/loader/core/MarmottaLoader.java
index cceb297..fc9ef1a 100644
--- 
a/loader/marmotta-loader-core/src/main/java/org/apache/marmotta/loader/core/MarmottaLoader.java
+++ 
b/loader/marmotta-loader-core/src/main/java/org/apache/marmotta/loader/core/MarmottaLoader.java
@@ -256,8 +256,12 @@ public class MarmottaLoader {
         if(directory.exists() && directory.isDirectory()) {
             for(File f : directory.listFiles(new DirectoryFilter())) {
                 try {
-                    loadFile(f, handler,format,compression);
-                } catch (RDFParseException | IOException e) {
+                    if(isArchive(f)) {
+                        loadArchive(f, handler, format);
+                    } else {
+                        loadFile(f, handler,format,compression);
+                    }
+                } catch (RDFParseException | IOException | ArchiveException e) 
{
                     log.warn("error importing file {}: {}", f, e.getMessage());
                 }
             }
@@ -398,6 +402,21 @@ public class MarmottaLoader {
         }
     }
 
+    private boolean isArchive(File file) {
+        if(file.getName().endsWith(".zip")) {
+            return true;
+        } else if(file.getName().endsWith(".7z")) {
+            return true;
+        } else if(file.getName().endsWith(".tar.gz")) {
+            return true;
+        } else if(file.getName().endsWith(".tar.bz2")) {
+            return true;
+        } else if(file.getName().endsWith(".tar")) {
+            return true;
+        }
+        return false;
+    }
+
     /**
      * Detect the compression format from the filename, or null in case 
auto-detection failed.
      * @param file

Reply via email to