From 45b97b4f5f837f1adb274405a6bfdcd79e01a231 Mon Sep 17 00:00:00 2001 From: Patrick Schmitz Date: Mon, 23 Aug 2010 20:56:21 +0000 Subject: [PATCH] CSPACE-2675 Add CSID to payload of Authority documents, since may be retrieved via refname, and not CSID. --- .../nuxeo/AuthorityDocumentModelHandler.java | 27 +++++++++++++++++++ ...LocationAuthorityDocumentModelHandler.java | 9 +++++++ .../OrgAuthorityDocumentModelHandler.java | 9 ++++++- .../PersonAuthorityDocumentModelHandler.java | 11 ++++++-- .../nuxeo/VocabularyDocumentModelHandler.java | 12 ++++++--- 5 files changed, 62 insertions(+), 6 deletions(-) diff --git a/services/common/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityDocumentModelHandler.java b/services/common/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityDocumentModelHandler.java index a3df7b584..666631a6d 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityDocumentModelHandler.java +++ b/services/common/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityDocumentModelHandler.java @@ -23,9 +23,13 @@ */ package org.collectionspace.services.common.vocabulary.nuxeo; +import java.util.Map; + import org.collectionspace.services.common.document.DocumentWrapper; +import org.collectionspace.services.common.service.ObjectPartType; import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl; +import org.collectionspace.services.nuxeo.util.NuxeoUtils; import org.nuxeo.ecm.core.api.DocumentModel; /** @@ -37,6 +41,8 @@ import org.nuxeo.ecm.core.api.DocumentModel; public abstract class AuthorityDocumentModelHandler extends RemoteDocumentModelHandlerImpl { + private String authorityCommonSchemaName; + /** * authority is used to stash JAXB object to use when handle is called * for Action.CREATE, Action.UPDATE or Action.GET @@ -49,6 +55,10 @@ public abstract class AuthorityDocumentModelHandler private AuthCommonList authorityList; + public AuthorityDocumentModelHandler(String authorityCommonSchemaName) { + this.authorityCommonSchemaName = authorityCommonSchemaName; + } + /** * getCommonPart get associated authority * @return @@ -101,5 +111,22 @@ public abstract class AuthorityDocumentModelHandler throw new UnsupportedOperationException(); } + /* (non-Javadoc) + * @see org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl#extractPart(org.nuxeo.ecm.core.api.DocumentModel, java.lang.String, org.collectionspace.services.common.service.ObjectPartType) + */ + @Override + protected Map extractPart(DocumentModel docModel, String schema, ObjectPartType partMeta) + throws Exception { + Map unQObjectProperties = super.extractPart(docModel, schema, partMeta); + + // Add the CSID to the common part + if (partMeta.getLabel().equalsIgnoreCase(authorityCommonSchemaName)) { + String csid = NuxeoUtils.extractId(docModel.getPathAsString()); + unQObjectProperties.put("csid", csid); + } + + return unQObjectProperties; + } + } diff --git a/services/location/service/src/main/java/org/collectionspace/services/location/nuxeo/LocationAuthorityDocumentModelHandler.java b/services/location/service/src/main/java/org/collectionspace/services/location/nuxeo/LocationAuthorityDocumentModelHandler.java index 9917dff16..d228da68c 100644 --- a/services/location/service/src/main/java/org/collectionspace/services/location/nuxeo/LocationAuthorityDocumentModelHandler.java +++ b/services/location/service/src/main/java/org/collectionspace/services/location/nuxeo/LocationAuthorityDocumentModelHandler.java @@ -51,6 +51,15 @@ import org.slf4j.LoggerFactory; public class LocationAuthorityDocumentModelHandler extends AuthorityDocumentModelHandler { + /** + * Common part schema label + */ + private static final String COMMON_PART_LABEL = "locationauthorities_common"; + + public LocationAuthorityDocumentModelHandler() { + super(COMMON_PART_LABEL); + } + @Override public LocationauthoritiesCommonList extractCommonPartList(DocumentWrapper wrapDoc) throws Exception { LocationauthoritiesCommonList coList = extractPagingInfo(new LocationauthoritiesCommonList(), diff --git a/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrgAuthorityDocumentModelHandler.java b/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrgAuthorityDocumentModelHandler.java index 97f6de58b..6c33ac988 100644 --- a/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrgAuthorityDocumentModelHandler.java +++ b/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrgAuthorityDocumentModelHandler.java @@ -48,8 +48,15 @@ import org.nuxeo.ecm.core.api.DocumentModelList; public class OrgAuthorityDocumentModelHandler extends AuthorityDocumentModelHandler { - //private final Logger logger = LoggerFactory.getLogger(OrgAuthorityDocumentModelHandler.class); + /** + * Common part schema label + */ + private static final String COMMON_PART_LABEL = "orgauthorities_common"; + public OrgAuthorityDocumentModelHandler() { + super(COMMON_PART_LABEL); + } + /* (non-Javadoc) * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPartList(org.collectionspace.services.common.document.DocumentWrapper) */ diff --git a/services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonAuthorityDocumentModelHandler.java b/services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonAuthorityDocumentModelHandler.java index 188cdbfc8..3e5bee782 100644 --- a/services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonAuthorityDocumentModelHandler.java +++ b/services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonAuthorityDocumentModelHandler.java @@ -48,8 +48,15 @@ import org.slf4j.LoggerFactory; public class PersonAuthorityDocumentModelHandler extends AuthorityDocumentModelHandler { - private final Logger logger = LoggerFactory.getLogger(PersonAuthorityDocumentModelHandler.class); - + /** + * Common part schema label + */ + private static final String COMMON_PART_LABEL = "personauthorities_common"; + + public PersonAuthorityDocumentModelHandler() { + super(COMMON_PART_LABEL); + } + @Override public PersonauthoritiesCommonList extractCommonPartList(DocumentWrapper wrapDoc) throws Exception { PersonauthoritiesCommonList coList = extractPagingInfo(new PersonauthoritiesCommonList(), diff --git a/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyDocumentModelHandler.java b/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyDocumentModelHandler.java index 1ee7ed359..81bc5b5b4 100644 --- a/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyDocumentModelHandler.java +++ b/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyDocumentModelHandler.java @@ -48,9 +48,15 @@ import org.slf4j.LoggerFactory; public class VocabularyDocumentModelHandler extends AuthorityDocumentModelHandler { - /** The logger. */ - private final Logger logger = LoggerFactory.getLogger(VocabularyDocumentModelHandler.class); - + /** + * Common part schema label + */ + private static final String COMMON_PART_LABEL = "vocabularies_common"; + + public VocabularyDocumentModelHandler() { + super(COMMON_PART_LABEL); + } + /* (non-Javadoc) * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPartList(org.collectionspace.services.common.document.DocumentWrapper) */ -- 2.47.3