]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
DRYD-573: Changed code to store uploaded Nuxeo Blob/File record into a /Blobs workspa...
authorRichard Millet <remillet@gmail.com>
Tue, 12 Feb 2019 00:40:49 +0000 (16:40 -0800)
committerRichard Millet <remillet@gmail.com>
Tue, 12 Feb 2019 00:40:49 +0000 (16:40 -0800)
services/common/src/main/java/org/collectionspace/services/common/imaging/nuxeo/NuxeoBlobUtils.java
services/common/src/main/java/org/collectionspace/services/nuxeo/util/NuxeoUtils.java

index 8b2bd79e1d9978f306bc6f169e80a16476dbf3be..34c3af8575966e536cf482be83048532c699b7d3 100644 (file)
@@ -40,6 +40,7 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.UUID;
 
 import org.nuxeo.runtime.api.Framework;
 import org.nuxeo.ecm.platform.picture.api.ImageInfo;
@@ -766,7 +767,6 @@ public class NuxeoBlobUtils {
                        // We'll store the blob inside the workspace directory of the calling service
                        String nuxeoWspaceId = ctx.getRepositoryWorkspaceId();
                        DocumentRef nuxeoWspace = new IdRef(nuxeoWspaceId);
-                       DocumentModel wspaceDoc = repoSession.getDocument(nuxeoWspace);
                        //
                        // If the original file's name contains "illegal" characters, then we create a copy of the file to give Nuxeo.
                        //
@@ -779,9 +779,12 @@ public class NuxeoBlobUtils {
                                }
                        }                       
                        
+                       DocumentModel wspaceDoc = repoSession.getDocument(nuxeoWspace);
+                       DocumentModel newBlobFolder = NuxeoUtils.createFolder(wspaceDoc, UUID.randomUUID().toString());
+                       
                        result = createBlobInRepository(ctx,
                                        repoSession,
-                                       wspaceDoc,
+                                       newBlobFolder,
                                        purgeOriginal,
                                        targetFile,
                                        blobInput.isTemporaryFile(),
index 66c53b116fb2724f5b37df4f6880b771e822cbb1..377cfee38622f899565e856fdd2765137eeaac64 100644 (file)
@@ -50,6 +50,7 @@ import org.collectionspace.services.common.vocabulary.RefNameServiceUtils;
 import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.AuthorityItemSpecifier;
 import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.Specifier;
 import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.SpecifierForm;
+import org.collectionspace.services.config.tenant.RepositoryDomainType;
 import org.collectionspace.services.lifecycle.Lifecycle;
 import org.collectionspace.services.lifecycle.State;
 import org.collectionspace.services.lifecycle.StateList;
@@ -58,6 +59,7 @@ import org.collectionspace.services.lifecycle.TransitionDefList;
 import org.collectionspace.services.lifecycle.TransitionList;
 import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentException;
 import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface;
+import org.collectionspace.services.nuxeo.client.java.CoreSessionWrapper;
 import org.dom4j.Document;
 import org.dom4j.io.SAXReader;
 import org.nuxeo.ecm.core.NXCore;
@@ -94,7 +96,7 @@ public class NuxeoUtils {
     // Base document type in Nuxeo is "Document"
     //
     public static final String BASE_DOCUMENT_TYPE = "Document";
-    public static final String WORKSPACE_DOCUMENT_TYPE = "Workspace";
+    public static final String WORKSPACE_DOCUMENT_TYPE = "Workspace"; // public static final String WORKSPACE_FOLDER_TYPE = "Folder";
     
     public static final String Workspaces = "Workspaces";
     public static final String workspaces = "workspaces"; // to make it easier to migrate older versions of the CollectionSpace services -i.e., pre v2.0.
@@ -163,6 +165,33 @@ public class NuxeoUtils {
        return result;
     }
     
+    /**
+     * Create a Nuxeo 'Folder' inside the passed in 'parentDoc'.
+     * 
+     * @param parentDoc
+     * @param folderName
+     * @return
+     * @throws Exception
+     */
+    static public DocumentModel createFolder(DocumentModel parentDoc, String folderName) throws Exception {
+       CoreSessionInterface repoSession = new CoreSessionWrapper(parentDoc.getCoreSession());
+
+        DocumentModel folder = repoSession.createDocumentModel(parentDoc.getPathAsString(),
+                folderName, NuxeoUtils.WORKSPACE_DOCUMENT_TYPE);
+        folder.setPropertyValue("dc:title", folderName);
+        folder.setPropertyValue("dc:description", "A CollectionSpace folder of "
+                + parentDoc.getName());
+        folder = repoSession.createDocument(folder);
+
+        repoSession.save();
+        
+        if (logger.isDebugEnabled()) {
+            logger.debug("Created folder name=" + folderName
+                    + " Nuxeo ID=" + folder.getId());
+        }
+
+        return folder;
+    }
     
     /*
      * Map Nuxeo's life cycle object to our JAX-B based life cycle object
@@ -873,6 +902,7 @@ public class NuxeoUtils {
     }
     */
 
+    
     /**
      * createPathRef creates a PathRef for given service context using given id
      * @param ctx