final static String SEARCH_TYPE_INVOCATION = "inv";\r
final static String SEARCH_QUALIFIER_AND = SEARCH_TERM_SEPARATOR + "AND" + SEARCH_TERM_SEPARATOR;\r
final static String SEARCH_QUALIFIER_OR = SEARCH_TERM_SEPARATOR + "OR" + SEARCH_TERM_SEPARATOR;\r
+\r
+ //\r
+ // Nuxeo pseudo-values (and filters) for special document properties.\r
+ //\r
+ final static String NUXEO_IS_PROXY = "ecm:isProxy";\r
+ final static String NUXEO_IS_PROXY_FILTER = NUXEO_IS_PROXY + " = 0";\r
+ final static String NUXEO_IS_VERSION = "ecm:isCheckedInVersion";\r
+ final static String NUXEO_IS_VERSION_FILTER = NUXEO_IS_VERSION + " = 0";\r
+ // In the CMIS context, the prefix is nuxeo, not ecm\r
+ final static String NUXEO_CMIS_IS_VERSION = "nuxeo:isVersion";\r
+ final static String NUXEO_CMIS_IS_VERSION_FILTER = NUXEO_CMIS_IS_VERSION + " = false";\r
+ \r
//\r
// Query params for CMIS queries on the relationship (Relation) table.\r
//\r
// Relations CMIS property mapping constants\r
final static String CMIS_RELATIONS_PREFIX = "REL";\r
\r
+ final static String CMIS_JOIN_NUXEO_IS_VERSION_FILTER = \r
+ IQueryManager.CMIS_TARGET_PREFIX + "." + IQueryManager.NUXEO_CMIS_IS_VERSION_FILTER;\r
+\r
+ \r
final static String CMIS_TARGET_NUXEO_ID = CMIS_TARGET_PREFIX + "." + CMIS_NUXEO_ID;\r
final static String CMIS_TARGET_CSID = CMIS_TARGET_PREFIX + "." + CMIS_NUXEO_NAME;\r
final static String CMIS_TARGET_TITLE = CMIS_TARGET_PREFIX + "." + CMIS_NUXEO_TITLE;\r
</tenant:serviceBindings>
+ <tenant:serviceBindings merge:matcher="id" id="Movements">
+ <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/config/service">
+ <service:params>
+ <service:SupportsVersioning>true</service:SupportsVersioning>
+ <service:ListResultsFields merge:action="preserve" />
+ </service:params>
+ </service:DocHandlerParams>
+ </tenant:serviceBindings>
+
<tenant:serviceBindings merge:matcher="id" id="Persons">
<service:DocHandlerParams xmlns:service="http://collectionspace.org/services/config/service">
<service:params>
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)
*/
+ " 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 ");
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<DocumentModel> wrapDoc, TransitionDef transitionDef)
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;
String id = IdUtils.generateId(UUID.randomUUID().toString());
// create document model
DocumentModel doc = repoSession.createDocumentModel(wspacePath, id, docType);
+ /* Check for a versioned document, and check In and Out before we proceed.
+ * This does not work as we do not have the uid schema on our docs.
+ if(((DocumentModelHandler) handler).supportsVersioning()) {
+ doc.setProperty("uid","major_version",1);
+ doc.setProperty("uid","minor_version",0);
+ }
+ */
((DocumentModelHandler) handler).setRepositorySession(repoSession);
DocumentWrapper<DocumentModel> wrapDoc = new DocumentWrapperImpl<DocumentModel>(doc);
handler.handle(Action.CREATE, wrapDoc);
String msg = logException(ce, "Could not find document to update with CSID=" + csid);
throw new DocumentNotFoundException(msg, ce);
}
+ // Check for a versioned document, and check In and Out before we proceed.
+ if(((DocumentModelHandler) handler).supportsVersioning()) {
+ /* Once we advance to 5.5 or later, we can add this.
+ * See also https://jira.nuxeo.com/browse/NXP-8506
+ if(!doc.isVersionable()) {
+ throw new DocumentException("Configuration for: "
+ +handler.getServiceContextPath()+" supports versioning, but Nuxeo config does not!");
+ }
+ */
+ /* Force a version number - Not working. Apparently we need to configure the uid schema??
+ if(doc.getProperty("uid","major_version") == null) {
+ doc.setProperty("uid","major_version",1);
+ }
+ if(doc.getProperty("uid","minor_version") == null) {
+ doc.setProperty("uid","minor_version",0);
+ }
+ */
+ doc.checkIn(VersioningOption.MINOR, null);
+ doc.checkOut();
+ }
+
//
// Set reposession to handle the document
//
* @param queryContext The query context, which provides the WHERE clause to append.
*/
static private final void appendNXQLWhere(StringBuilder query, QueryContext queryContext) {
+
+ // Filter documents that are proxies (speeds up the query) and filter checked in versions
+ // for services that are using versioning.
+ // TODO This should really be handled as a default query param so it can be overridden,
+ // allowing clients to find versions, just as they can find soft-deleted items.
+ final String PROXY_AND_VERSION_FILTER =
+ IQueryManager.SEARCH_QUALIFIER_AND + IQueryManager.NUXEO_IS_PROXY_FILTER
+ + IQueryManager.SEARCH_QUALIFIER_AND + IQueryManager.NUXEO_IS_VERSION_FILTER;
//
// Restrict search to a specific Nuxeo domain
// TODO This is a slow method for tenant-filter
query.append(IQueryManager.SEARCH_QUALIFIER_AND + "(" + whereClause + ")");
}
//
- // Please lookup this use in Nuxeo support and document here
+ // See "Special NXQL Properties" at http://doc.nuxeo.com/display/NXDOC/NXQL
//
- query.append(IQueryManager.SEARCH_QUALIFIER_AND + "ecm:isProxy = 0");
+ query.append(PROXY_AND_VERSION_FILTER);
}
/**
<xs:element name="SchemaName" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="RefnameDisplayNameField" type="ListResultField" minOccurs="0" maxOccurs="1"/> <!-- Should rename 'ListResultField' to a more generic name -->
<xs:element name="SupportsHierarchy" type="xs:boolean" minOccurs="0" maxOccurs="1" default="false"/>
+ <xs:element name="SupportsVersioning" type="xs:boolean" minOccurs="0" maxOccurs="1" default="false"/>
<xs:element name="DublinCoreTitle" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="SummaryFields" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="AbstractCommonListClassname" type="xs:string" minOccurs="0" maxOccurs="1"/>