From 30e2b03b7eb533abd77129ef18edf075e9a8c85b Mon Sep 17 00:00:00 2001 From: Richard Millet Date: Mon, 25 Feb 2019 14:42:09 -0800 Subject: [PATCH] CC-331: Added fallback support for using default Nuxeo file importer when other importers fail. --- .../common/imaging/nuxeo/NuxeoBlobUtils.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/services/common/src/main/java/org/collectionspace/services/common/imaging/nuxeo/NuxeoBlobUtils.java b/services/common/src/main/java/org/collectionspace/services/common/imaging/nuxeo/NuxeoBlobUtils.java index 5cbc10a67..b922307c1 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/imaging/nuxeo/NuxeoBlobUtils.java +++ b/services/common/src/main/java/org/collectionspace/services/common/imaging/nuxeo/NuxeoBlobUtils.java @@ -57,6 +57,7 @@ import org.nuxeo.ecm.platform.filemanager.utils.FileManagerUtils; import org.nuxeo.ecm.platform.types.TypeManager; import org.nuxeo.ecm.core.api.CoreSession; import org.nuxeo.ecm.core.api.IdRef; +import org.nuxeo.ecm.core.api.NuxeoException; import org.nuxeo.ecm.core.api.blobholder.BlobHolder; import org.nuxeo.ecm.core.api.blobholder.DocumentBlobHolder; import org.nuxeo.ecm.core.api.impl.blob.FileBlob; @@ -673,7 +674,8 @@ public class NuxeoBlobUtils { boolean useNuxeoAdaptors) throws Exception { DocumentModel result = null; - if (useNuxeoAdaptors == true) { + boolean createdFromAdaptor = false; + if (useNuxeoAdaptors == true) try { // // Use Nuxeo's high-level create method which looks for plugin adapters that match the MIME type. For example, // for image blobs, Nuxeo's file manager will pick a special image plugin that will automatically generate @@ -681,7 +683,13 @@ public class NuxeoBlobUtils { // result = getFileManager().createDocumentFromBlob( repoSession.getCoreSession(), inputStreamBlob, blobLocation, overwrite, blobName); - } else { + createdFromAdaptor = true; + } catch (NuxeoException ne) { + logger.warn(String.format("Tried but failed to use Nuxeo import adaptor to download '%s'. Falling back to generic file importer", + blobName)); + } + + if (createdFromAdaptor == false) { // // User Nuxeo's default file importer/adapter explicitly. This avoids specialized functionality from happening like // image derivative creation. @@ -1281,3 +1289,4 @@ public class NuxeoBlobUtils { * Blob blob = document.getProperty("file:content"); htmlDoc = blob.getString(); * // the content is decoded from UTF-8 into a java string */ + -- 2.47.3