From 76c6cd24a29ec2be2c84427852fb8aca33b4fe4d Mon Sep 17 00:00:00 2001 From: Patrick Schmitz Date: Fri, 26 Oct 2012 10:05:15 -0700 Subject: [PATCH] CSPACE-5664 - Added support to services config to use the Nuxeo versioning support on a per-service, per tenant basis. Added support to filter versions from normal search and list queries. Did not add support for a query param to control this - that is a future feature as needed. Made lifesci tenant Movement use versioning, to test and demo this functionality. Performed basic testing, but needs additional test development. --- .../services/client/IQueryManager.java | 16 ++++++++++ .../tenants/lifesci/tenant-bindings.delta.xml | 9 ++++++ .../AbstractMultipartDocumentHandlerImpl.java | 7 +++++ .../client/java/DocumentModelHandler.java | 4 +++ .../java/RemoteDocumentModelHandlerImpl.java | 24 +++++++++++++++ .../client/java/RepositoryJavaClientImpl.java | 29 +++++++++++++++++++ .../services/nuxeo/util/NuxeoUtils.java | 12 ++++++-- .../config/src/main/resources/service.xsd | 1 + 8 files changed, 100 insertions(+), 2 deletions(-) diff --git a/services/client/src/main/java/org/collectionspace/services/client/IQueryManager.java b/services/client/src/main/java/org/collectionspace/services/client/IQueryManager.java index 3f227cd7b..ddcb4d245 100644 --- a/services/client/src/main/java/org/collectionspace/services/client/IQueryManager.java +++ b/services/client/src/main/java/org/collectionspace/services/client/IQueryManager.java @@ -42,6 +42,18 @@ public interface IQueryManager { final static String SEARCH_TYPE_INVOCATION = "inv"; final static String SEARCH_QUALIFIER_AND = SEARCH_TERM_SEPARATOR + "AND" + SEARCH_TERM_SEPARATOR; final static String SEARCH_QUALIFIER_OR = SEARCH_TERM_SEPARATOR + "OR" + SEARCH_TERM_SEPARATOR; + + // + // Nuxeo pseudo-values (and filters) for special document properties. + // + final static String NUXEO_IS_PROXY = "ecm:isProxy"; + final static String NUXEO_IS_PROXY_FILTER = NUXEO_IS_PROXY + " = 0"; + final static String NUXEO_IS_VERSION = "ecm:isCheckedInVersion"; + final static String NUXEO_IS_VERSION_FILTER = NUXEO_IS_VERSION + " = 0"; + // In the CMIS context, the prefix is nuxeo, not ecm + final static String NUXEO_CMIS_IS_VERSION = "nuxeo:isVersion"; + final static String NUXEO_CMIS_IS_VERSION_FILTER = NUXEO_CMIS_IS_VERSION + " = false"; + // // Query params for CMIS queries on the relationship (Relation) table. // @@ -70,6 +82,10 @@ public interface IQueryManager { // Relations CMIS property mapping constants final static String CMIS_RELATIONS_PREFIX = "REL"; + final static String CMIS_JOIN_NUXEO_IS_VERSION_FILTER = + IQueryManager.CMIS_TARGET_PREFIX + "." + IQueryManager.NUXEO_CMIS_IS_VERSION_FILTER; + + final static String CMIS_TARGET_NUXEO_ID = CMIS_TARGET_PREFIX + "." + CMIS_NUXEO_ID; final static String CMIS_TARGET_CSID = CMIS_TARGET_PREFIX + "." + CMIS_NUXEO_NAME; final static String CMIS_TARGET_TITLE = CMIS_TARGET_PREFIX + "." + CMIS_NUXEO_TITLE; diff --git a/services/common/src/main/cspace/config/services/tenants/lifesci/tenant-bindings.delta.xml b/services/common/src/main/cspace/config/services/tenants/lifesci/tenant-bindings.delta.xml index b9c0a76e3..6938663af 100644 --- a/services/common/src/main/cspace/config/services/tenants/lifesci/tenant-bindings.delta.xml +++ b/services/common/src/main/cspace/config/services/tenants/lifesci/tenant-bindings.delta.xml @@ -55,6 +55,15 @@ + + + + true + + + + + diff --git a/services/common/src/main/java/org/collectionspace/services/common/document/AbstractMultipartDocumentHandlerImpl.java b/services/common/src/main/java/org/collectionspace/services/common/document/AbstractMultipartDocumentHandlerImpl.java index a30a45eef..6436951f4 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/document/AbstractMultipartDocumentHandlerImpl.java +++ b/services/common/src/main/java/org/collectionspace/services/common/document/AbstractMultipartDocumentHandlerImpl.java @@ -56,6 +56,13 @@ public abstract class AbstractMultipartDocumentHandlerImpl return false; } + /* + * By default we won't support object versioning + */ + public boolean supportsVersioning() { + return false; + } + /* (non-Javadoc) * @see org.collectionspace.services.common.document.AbstractDocumentHandlerImpl#handleCreate(org.collectionspace.services.common.document.DocumentWrapper) */ diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocumentModelHandler.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocumentModelHandler.java index 1000f7b7a..a11a0b9d5 100644 --- a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocumentModelHandler.java +++ b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocumentModelHandler.java @@ -517,6 +517,10 @@ public abstract class DocumentModelHandler + " IN " + matchObjDocTypes + ")"; } + // This could later be in control of a queryParam, to omit if we want to see versions, or to + // only see old versions. + theWhereClause += IQueryManager.SEARCH_QUALIFIER_AND + IQueryManager.CMIS_JOIN_NUXEO_IS_VERSION_FILTER; + StringBuilder query = new StringBuilder(); // assemble the query from the string arguments query.append("SELECT "); diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteDocumentModelHandlerImpl.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteDocumentModelHandlerImpl.java index 5af6540c6..7fd63f622 100644 --- a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteDocumentModelHandlerImpl.java +++ b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteDocumentModelHandlerImpl.java @@ -170,6 +170,30 @@ public abstract class RemoteDocumentModelHandlerImpl return result; } + + @Override + public boolean supportsVersioning() { + boolean result = false; + + DocHandlerParams.Params params = null; + try { + ServiceContext ctx = this.getServiceContext(); + params = ServiceConfigUtils.getDocHandlerParams(ctx); + Boolean bool = params.isSupportsVersioning(); + if (bool != null) { + result = bool.booleanValue(); + } + } catch (DocumentException e) { + // TODO Auto-generated catch block + String errMsg = String.format("Could not get document handler params from config bindings for class %s", this.getClass().getName()); + if (logger.isWarnEnabled() == true) { + logger.warn(errMsg); + } + } + + return result; + } + @Override public void handleWorkflowTransition(DocumentWrapper wrapDoc, TransitionDef transitionDef) diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryJavaClientImpl.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryJavaClientImpl.java index 7c186f17d..154c429a5 100644 --- a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryJavaClientImpl.java +++ b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryJavaClientImpl.java @@ -53,6 +53,7 @@ import org.nuxeo.ecm.core.api.ClientException; import org.nuxeo.ecm.core.api.DocumentModel; import org.nuxeo.ecm.core.api.DocumentModelList; import org.nuxeo.ecm.core.api.IterableQueryResult; +import org.nuxeo.ecm.core.api.VersioningOption; import org.nuxeo.ecm.core.api.impl.DocumentModelListImpl; import org.nuxeo.ecm.core.api.DocumentRef; import org.nuxeo.ecm.core.api.IdRef; @@ -163,6 +164,13 @@ public class RepositoryJavaClientImpl implements RepositoryClient wrapDoc = new DocumentWrapperImpl(doc); handler.handle(Action.CREATE, wrapDoc); @@ -985,6 +993,27 @@ public class RepositoryJavaClientImpl implements RepositoryClient + -- 2.47.3