From: Patrick Schmitz Date: Wed, 17 Aug 2011 21:05:05 +0000 (+0000) Subject: CSPACE-4328 Added support for createdBy and updatedBy to the collectionspace_core... X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=9e039784a831fc13eadb7f198e4118948e73bf1b;p=tmp%2Fjakarta-migration.git CSPACE-4328 Added support for createdBy and updatedBy to the collectionspace_core schema. These fields are now set and maintained by all of the nuxeo repository services (i.e., they are not maintained for AuthN and AuthZ services: user, account, role, perms, etc.). The values are the userId of the currently authenticated user. This changes requires a complete (create_db) rebuild of a repository. --- diff --git a/3rdparty/nuxeo/nuxeo-platform-collectionspace/src/main/resources/schemas/collectionspace_core.xsd b/3rdparty/nuxeo/nuxeo-platform-collectionspace/src/main/resources/schemas/collectionspace_core.xsd index 7e5416d30..3a557f64e 100644 --- a/3rdparty/nuxeo/nuxeo-platform-collectionspace/src/main/resources/schemas/collectionspace_core.xsd +++ b/3rdparty/nuxeo/nuxeo-platform-collectionspace/src/main/resources/schemas/collectionspace_core.xsd @@ -20,4 +20,6 @@ + + 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 3f518cfbd..54e9db8f7 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 @@ -65,6 +65,8 @@ public abstract class DocumentModelHandler public final static String COLLECTIONSPACE_CORE_URI = "uri"; public final static String COLLECTIONSPACE_CORE_CREATED_AT = "createdAt"; public final static String COLLECTIONSPACE_CORE_UPDATED_AT = "updatedAt"; + public final static String COLLECTIONSPACE_CORE_CREATED_BY = "createdBy"; + public final static String COLLECTIONSPACE_CORE_UPDATED_BY = "updatedBy"; /* * We're using the "name" field of Nuxeo's DocumentModel to store @@ -181,14 +183,15 @@ public abstract class DocumentModelHandler Action action) throws ClientException { DocumentModel documentModel = docWrapper.getWrappedObject(); String now = GregorianCalendarDateTimeUtils.timestampUTC(); + ServiceContext ctx = getServiceContext(); + String userId = ctx.getUserId(); if(action==Action.CREATE) { - String tenantId = getServiceContext().getTenantId(); // // Add the tenant ID value to the new entity // + String tenantId = ctx.getTenantId(); documentModel.setProperty(COLLECTIONSPACE_CORE_SCHEMA, - COLLECTIONSPACE_CORE_TENANTID, - getServiceContext().getTenantId()); + COLLECTIONSPACE_CORE_TENANTID, tenantId); // // Add the uri value to the new entity // @@ -209,10 +212,14 @@ public abstract class DocumentModelHandler } documentModel.setProperty(COLLECTIONSPACE_CORE_SCHEMA, COLLECTIONSPACE_CORE_CREATED_AT, now); + documentModel.setProperty(COLLECTIONSPACE_CORE_SCHEMA, + COLLECTIONSPACE_CORE_CREATED_BY, userId); } if(action==Action.CREATE || action==Action.UPDATE) { documentModel.setProperty(COLLECTIONSPACE_CORE_SCHEMA, COLLECTIONSPACE_CORE_UPDATED_AT, now); + documentModel.setProperty(COLLECTIONSPACE_CORE_SCHEMA, + COLLECTIONSPACE_CORE_UPDATED_BY, userId); } }