From: remillet Date: Mon, 9 Oct 2017 17:19:15 +0000 (-0700) Subject: NOJIRA: Testing Nuxeo Importer service to see if we can replace our custom importer... X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=d4b1558ff52355470ae811b3c73123b40f1ba0d6;p=tmp%2Fjakarta-migration.git NOJIRA: Testing Nuxeo Importer service to see if we can replace our custom importer code with theirs. --- 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 index 000000000..857256f66 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 index 000000000..82aedf59f Binary files /dev/null and b/3rdparty/nuxeo/nuxeo-server/7.10-HF17/bundles/nuxeo-importer-xml-parser-7.10-HF17.jar differ diff --git a/services/imports/service/pom.xml b/services/imports/service/pom.xml index 7ee3d0bed..0d291f283 100644 --- a/services/imports/service/pom.xml +++ b/services/imports/service/pom.xml @@ -89,12 +89,24 @@ resteasy-multipart-provider + org.nuxeo.shell nuxeo-shell-core ${nuxeo.shell.version} + + org.nuxeo.ecm.platform + nuxeo-importer-core + ${nuxeo.platform.version} + + + org.nuxeo.ecm.platform + nuxeo-importer-xml-parser + ${nuxeo.platform.version} + + org.nuxeo.ecm.core nuxeo-core-api diff --git a/services/imports/service/src/main/java/org/collectionspace/services/imports/nuxeo/ImportCommand.java b/services/imports/service/src/main/java/org/collectionspace/services/imports/nuxeo/ImportCommand.java index 20bf0a45d..b22e5cf09 100644 --- a/services/imports/service/src/main/java/org/collectionspace/services/imports/nuxeo/ImportCommand.java +++ b/services/imports/service/src/main/java/org/collectionspace/services/imports/nuxeo/ImportCommand.java @@ -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