]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
NOJIRA: Testing Nuxeo Importer service to see if we can replace our custom importer...
authorremillet <remillet@yahoo.com>
Mon, 9 Oct 2017 17:19:15 +0000 (10:19 -0700)
committerremillet <remillet@yahoo.com>
Mon, 9 Oct 2017 17:19:15 +0000 (10:19 -0700)
3rdparty/nuxeo/nuxeo-server/7.10-HF17/bundles/nuxeo-importer-core-7.10-HF17.jar [new file with mode: 0644]
3rdparty/nuxeo/nuxeo-server/7.10-HF17/bundles/nuxeo-importer-xml-parser-7.10-HF17.jar [new file with mode: 0644]
services/imports/service/pom.xml
services/imports/service/src/main/java/org/collectionspace/services/imports/nuxeo/ImportCommand.java

diff --git a/3rdparty/nuxeo/nuxeo-server/7.10-HF17/bundles/nuxeo-importer-core-7.10-HF17.jar b/3rdparty/nuxeo/nuxeo-server/7.10-HF17/bundles/nuxeo-importer-core-7.10-HF17.jar
new file mode 100644 (file)
index 0000000..857256f
Binary files /dev/null and b/3rdparty/nuxeo/nuxeo-server/7.10-HF17/bundles/nuxeo-importer-core-7.10-HF17.jar differ
diff --git a/3rdparty/nuxeo/nuxeo-server/7.10-HF17/bundles/nuxeo-importer-xml-parser-7.10-HF17.jar b/3rdparty/nuxeo/nuxeo-server/7.10-HF17/bundles/nuxeo-importer-xml-parser-7.10-HF17.jar
new file mode 100644 (file)
index 0000000..82aedf5
Binary files /dev/null and b/3rdparty/nuxeo/nuxeo-server/7.10-HF17/bundles/nuxeo-importer-xml-parser-7.10-HF17.jar differ
index 7ee3d0bed56519771ed956dd6b112dc6a85e6c34..0d291f283b8a59246cc8849046f15edd406a1746 100644 (file)
             <artifactId>resteasy-multipart-provider</artifactId>
         </dependency>
         
+        <!-- Nuxeo -->
 
         <dependency>
             <groupId>org.nuxeo.shell</groupId>
             <artifactId>nuxeo-shell-core</artifactId>
             <version>${nuxeo.shell.version}</version>
         </dependency>
+        <dependency>
+               <groupId>org.nuxeo.ecm.platform</groupId>
+                       <artifactId>nuxeo-importer-core</artifactId>
+                       <version>${nuxeo.platform.version}</version>
+        </dependency>
+        <dependency>
+               <groupId>org.nuxeo.ecm.platform</groupId>
+                       <artifactId>nuxeo-importer-xml-parser</artifactId>
+                       <version>${nuxeo.platform.version}</version>
+               </dependency>
+        
         <dependency>
             <groupId>org.nuxeo.ecm.core</groupId>
             <artifactId>nuxeo-core-api</artifactId>
index 20bf0a45d36cf7d356ae8e9052ffa9317be5447b..b22e5cf097e2845ec915ecbed4285c5a6847bf01 100644 (file)
@@ -1,6 +1,7 @@
 package org.collectionspace.services.imports.nuxeo;
 
 import java.io.File;
+import java.io.IOException;
 import java.util.Calendar;
 import java.util.HashMap;
 import java.util.Map;
@@ -9,15 +10,21 @@ import java.util.TreeSet;
 import org.collectionspace.services.nuxeo.client.java.NuxeoClientEmbedded;
 import org.collectionspace.services.nuxeo.client.java.NuxeoConnectorEmbedded;
 import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface;
-
+import org.nuxeo.common.utils.FileUtils;
 import org.nuxeo.ecm.core.api.DocumentModel;
 import org.nuxeo.ecm.core.api.DocumentRef;
+import org.nuxeo.ecm.core.api.IdRef;
+import org.nuxeo.ecm.core.api.PathRef;
 import org.nuxeo.ecm.core.io.DocumentPipe;
 import org.nuxeo.ecm.core.io.DocumentReader;
 import org.nuxeo.ecm.core.io.DocumentTranslationMap;
 import org.nuxeo.ecm.core.io.DocumentWriter;
 import org.nuxeo.ecm.core.io.impl.DocumentPipeImpl;
 import org.nuxeo.ecm.core.io.impl.plugins.DocumentModelWriter;
+import org.nuxeo.ecm.platform.importer.service.DefaultImporterService;
+import org.nuxeo.ecm.platform.importer.service.DefaultImporterServiceImpl;
+import org.nuxeo.ecm.platform.importer.xml.parser.XMLImporterService;
+import org.nuxeo.runtime.api.Framework;
 // we use our own override of this: import org.nuxeo.ecm.core.io.impl.plugins.XMLDirectoryReader;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -38,7 +45,7 @@ public class ImportCommand {
                 String msg = String.format("Start of import is Local time: %tT", Calendar.getInstance());
                 logger.debug(msg);
             }
-            return importTree(repoSession, file, workspacesPath, timeout);
+            return newImportTree(repoSession, file, workspacesPath, timeout);
         } catch (Exception e) {
             throw e;
         } finally {
@@ -49,6 +56,26 @@ public class ImportCommand {
             client.releaseRepository(repoSession);
         }
     }
+    
+//    DocumentModel root = session.getRootDocument();
+//    File xml = File("/where/is/my/umbrella");
+//    XMLImporterService importer = Framework.getLocalService(XMLImporterService.class);
+//    importer.importDocuments(root, xml);
+    
+    private String newImportTree(CoreSessionInterface repoSession, File file, String toPath, int timeout) throws IOException {
+        File source = new File("C:/dev/tools/apache-tomcat-7.0.64/temp/imports-2014210770025398386/Personauthorities.zip");
+        if (source.exists()) {
+               String targetPath = "/core-domain/Workspaces/Personauthorities/"; ///core-domain/Workspaces/Personauthorities
+               DocumentRef docRef = new PathRef(targetPath);
+               DocumentModel root = repoSession.getDocument(docRef);
+               XMLImporterService importerService = Framework.getLocalService(XMLImporterService.class);
+            importerService.importDocuments(root, source);
+        } else {
+               System.err.println("Could not find file: " + source.getAbsolutePath());
+        }
+        
+        return "New Import Service Run";
+    }
 
     /*
      * If the import exceeds the number of seconds in 'timeout', we'll thrown an exception and rollback all import work