From: Richard Millet Date: Mon, 25 Feb 2019 22:42:09 +0000 (-0800) Subject: CC-331: Added fallback support for using default Nuxeo file importer when other impor... X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=30e2b03b7eb533abd77129ef18edf075e9a8c85b;p=tmp%2Fjakarta-migration.git CC-331: Added fallback support for using default Nuxeo file importer when other importers fail. --- 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 */ +