From: Richard Millet Date: Tue, 23 Mar 2010 23:28:14 +0000 (+0000) Subject: CSPACE-1273: REVERTED THIS CHANGE: CSID should be in the payload of term items for... X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=7647c4cf5fee719ff26d9f444b01200ac9c616f8;p=tmp%2Fjakarta-migration.git CSPACE-1273: REVERTED THIS CHANGE: CSID should be in the payload of term items for Person and Org services. --- 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 0149ce943..435e2ae1d 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 @@ -84,29 +84,20 @@ public abstract class RemoteDocumentModelHandlerImpl } } - @Override - public void extractAllParts(DocumentWrapper wrapDoc) - throws Exception { - - DocumentModel docModel = wrapDoc.getWrappedObject(); - String[] schemas = docModel.getDeclaredSchemas(); - Map partsMetaMap = getServiceContext().getPartsMetadata(); - for (String schema : schemas) { - ObjectPartType partMeta = partsMetaMap.get(schema); - if (partMeta == null) { - continue; // unknown part, ignore - } - Map unQObjectProperties = extractPart(docModel, - schema, partMeta); - Document doc = DocumentUtils.buildDocument(partMeta, schema, - unQObjectProperties); - if (logger.isDebugEnabled()) { - DocumentUtils.writeDocument(doc, System.out); - } - MultipartServiceContext ctx = (MultipartServiceContext) getServiceContext(); - ctx.addOutputPart(schema, doc, partMeta.getContent().getContentType()); - } - } + @Override + public void extractAllParts(DocumentWrapper wrapDoc) throws Exception { + + DocumentModel docModel = wrapDoc.getWrappedObject(); + String[] schemas = docModel.getDeclaredSchemas(); + Map partsMetaMap = getServiceContext().getPartsMetadata(); + for(String schema : schemas){ + ObjectPartType partMeta = partsMetaMap.get(schema); + if(partMeta == null){ + continue; //unknown part, ignore + } + extractPart(docModel, schema, partMeta); + } + } @Override public void fillAllParts(DocumentWrapper wrapDoc) throws Exception { @@ -176,12 +167,10 @@ public abstract class RemoteDocumentModelHandlerImpl * @param partMeta metadata for the object to extract * @throws Exception */ - protected Map extractPart(DocumentModel docModel, String schema, ObjectPartType partMeta) + protected void extractPart(DocumentModel docModel, String schema, ObjectPartType partMeta) throws Exception { - Map result = null; - MediaType mt = MediaType.valueOf(partMeta.getContent().getContentType()); - if (mt.equals(MediaType.APPLICATION_XML_TYPE)){ + if(mt.equals(MediaType.APPLICATION_XML_TYPE)){ Map objectProps = docModel.getProperties(schema); //unqualify properties before sending the doc over the wire (to save bandwidh) //FIXME: is there a better way to avoid duplication of a collection? @@ -191,10 +180,13 @@ public abstract class RemoteDocumentModelHandlerImpl String unqProp = getUnQProperty(entry.getKey()); unQObjectProperties.put(unqProp, entry.getValue()); } - result = unQObjectProperties; + Document doc = DocumentUtils.buildDocument(partMeta, schema, unQObjectProperties); + if(logger.isDebugEnabled()){ + DocumentUtils.writeDocument(doc, System.out); + } + MultipartServiceContext ctx = (MultipartServiceContext) getServiceContext(); + ctx.addOutputPart(schema, doc, partMeta.getContent().getContentType()); } //TODO: handle other media types - - return result; } public AuthorityRefList getAuthorityRefs( diff --git a/services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonDocumentModelHandler.java b/services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonDocumentModelHandler.java index e77d5de3f..2bf96742d 100644 --- a/services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonDocumentModelHandler.java +++ b/services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonDocumentModelHandler.java @@ -27,12 +27,10 @@ import java.util.Iterator; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.Map; import org.collectionspace.services.PersonJAXBSchema; import org.collectionspace.services.common.document.DocumentFilter; 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.collectionspace.services.person.PersonsCommon; @@ -57,11 +55,6 @@ public class PersonDocumentModelHandler extends RemoteDocumentModelHandlerImpl { private final Logger logger = LoggerFactory.getLogger(PersonDocumentModelHandler.class); - /** - * Common part schema label - */ - private static final String COMMON_PART_LABEL = "persons_common"; - /** * person is used to stash JAXB object to use when handle is called * for Action.CREATE, Action.UPDATE or Action.GET @@ -202,20 +195,6 @@ public class PersonDocumentModelHandler this.personList = personList; } - @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(COMMON_PART_LABEL)) { - String csid = NuxeoUtils.extractId(docModel.getPathAsString()); - unQObjectProperties.put("csid", csid); - } - - return unQObjectProperties; - } - @Override public PersonsCommon extractCommonPart(DocumentWrapper wrapDoc) throws Exception {