*/
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;
/**
public abstract class AuthorityDocumentModelHandler<AuthCommon, AuthCommonList>
extends RemoteDocumentModelHandlerImpl<AuthCommon, AuthCommonList> {
+ private String authorityCommonSchemaName;
+
/**
* authority is used to stash JAXB object to use when handle is called
* for Action.CREATE, Action.UPDATE or Action.GET
private AuthCommonList authorityList;
+ public AuthorityDocumentModelHandler(String authorityCommonSchemaName) {
+ this.authorityCommonSchemaName = authorityCommonSchemaName;
+ }
+
/**
* getCommonPart get associated authority
* @return
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<String, Object> extractPart(DocumentModel docModel, String schema, ObjectPartType partMeta)
+ throws Exception {
+ Map<String, Object> 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;
+ }
+
}
public class LocationAuthorityDocumentModelHandler
extends AuthorityDocumentModelHandler<LocationauthoritiesCommon, LocationauthoritiesCommonList> {
+ /**
+ * Common part schema label
+ */
+ private static final String COMMON_PART_LABEL = "locationauthorities_common";
+
+ public LocationAuthorityDocumentModelHandler() {
+ super(COMMON_PART_LABEL);
+ }
+
@Override
public LocationauthoritiesCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
LocationauthoritiesCommonList coList = extractPagingInfo(new LocationauthoritiesCommonList(),
public class OrgAuthorityDocumentModelHandler
extends AuthorityDocumentModelHandler<OrgauthoritiesCommon, OrgauthoritiesCommonList> {
- //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)
*/
public class PersonAuthorityDocumentModelHandler
extends AuthorityDocumentModelHandler<PersonauthoritiesCommon, PersonauthoritiesCommonList> {
- 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<DocumentModelList> wrapDoc) throws Exception {
PersonauthoritiesCommonList coList = extractPagingInfo(new PersonauthoritiesCommonList(),
public class VocabularyDocumentModelHandler
extends AuthorityDocumentModelHandler<VocabulariesCommon, VocabulariesCommonList> {
- /** 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)
*/