]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CC-331: Added fallback support for using default Nuxeo file importer when other impor...
authorRichard Millet <remillet@gmail.com>
Mon, 25 Feb 2019 22:42:09 +0000 (14:42 -0800)
committerRichard Millet <remillet@gmail.com>
Mon, 25 Feb 2019 22:42:09 +0000 (14:42 -0800)
services/common/src/main/java/org/collectionspace/services/common/imaging/nuxeo/NuxeoBlobUtils.java

index 5cbc10a676fa706ccbf4362200e812abd2cca58e..b922307c1fedffa4f41da7a39ab79e804d274cae 100644 (file)
@@ -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
  */
+