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;
// 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.
//
}
}
+ DocumentModel wspaceDoc = repoSession.getDocument(nuxeoWspace);
+ DocumentModel newBlobFolder = NuxeoUtils.createFolder(wspaceDoc, UUID.randomUUID().toString());
+
result = createBlobInRepository(ctx,
repoSession,
- wspaceDoc,
+ newBlobFolder,
purgeOriginal,
targetFile,
blobInput.isTemporaryFile(),
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;
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;
// 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.
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
}
*/
+
/**
* createPathRef creates a PathRef for given service context using given id
* @param ctx