Provide-Package: org.collectionspace.collectionspace_core\r
Nuxeo-Component: OSGI-INF/core-types-contrib.xml,\r
OSGI-INF/ecm-types-contrib.xml,\r
- OSGI-INF/layouts-contrib.xml\r
+ OSGI-INF/layouts-contrib.xml,\r
+ OSGI-INF/querymodel-contrib.xml\r
+\r
\r
--- /dev/null
+<?xml version="1.0"?>\r
+\r
+<component name="com.myexample.query.model.override">\r
+ <require>org.nuxeo.ecm.webapp.querymodel.DefaultQueryModels</require>\r
+ <extension\r
+ target="org.nuxeo.ecm.core.search.api.client.querymodel.QueryModelService"\r
+ point="model">\r
+ <queryModel name="CURRENT_DOC_CHILDREN">\r
+ <pattern>\r
+ SELECT * FROM Document WHERE ecm:parentId = ? AND\r
+ ecm:isCheckedInVersion = 0 AND ecm:mixinType != 'HiddenInNavigation'\r
+ AND ecm:currentLifeCycleState != 'deleted' AND ecm:isProxy = 0 \r
+ </pattern>\r
+ <sortable value="true" defaultSortColumn="dc:created"\r
+ defaultSortAscending="false" />\r
+ <max>50</max>\r
+ </queryModel>\r
+ \r
+</extension>\r
+</component>\r
+\r
}
@Override
- public void fillAllParts(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
+ public void fillAllParts(DocumentWrapper<DocumentModel> wrapDoc, Action action) throws Exception {
- super.fillAllParts(wrapDoc);
+ super.fillAllParts(wrapDoc, action);
fillDublinCoreObject(wrapDoc); //dublincore might not be needed in future
}
* @see org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl#fillAllParts(org.collectionspace.services.common.document.DocumentWrapper)
*/
@Override
- public void fillAllParts(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
+ public void fillAllParts(DocumentWrapper<DocumentModel> wrapDoc, Action action) throws Exception {
- super.fillAllParts(wrapDoc);
+ super.fillAllParts(wrapDoc, action);
fillDublinCoreObject(wrapDoc); //dublincore might not be needed in future
}
throws Exception;
@Override
- public abstract void fillAllParts(DocumentWrapper<WT> wrapDoc)
+ public abstract void fillAllParts(DocumentWrapper<WT> wrapDoc, Action action)
throws Exception;
@Override
*/
package org.collectionspace.services.common.document;
+import org.collectionspace.services.common.document.DocumentHandler.Action;
+
/**
* MultipartDocumentHandler is a DocumentHandler provides document processing
* methods for entities using schema extension that are mapped to multipart
* repository. Called in handle CREATE/UPDATE actions.
* @param obj input object
* @param docWrap target document
+ * @param action one of Action.CREATE or Action.UPDATE
* @throws Exception
*/
- public void fillAllParts(DocumentWrapper<WT> docWrap) throws Exception;
+ public void fillAllParts(DocumentWrapper<WT> docWrap, Action action) throws Exception;
}
\ No newline at end of file
--- /dev/null
+/**\r
+ * This document is a part of the source code and related artifacts\r
+ * for CollectionSpace, an open source collections management system\r
+ * for museums and related institutions:\r
+\r
+ * http://www.collectionspace.org\r
+ * http://wiki.collectionspace.org\r
+\r
+ * Copyright 2009 University of California at Berkeley\r
+\r
+ * Licensed under the Educational Community License (ECL), Version 2.0.\r
+ * You may not use this file except in compliance with this License.\r
+\r
+ * You may obtain a copy of the ECL 2.0 License at\r
+\r
+ * https://source.collectionspace.org/collection-space/LICENSE.txt\r
+\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+package org.collectionspace.services.common.vocabulary;\r
+\r
+/**\r
+ * @author pschmitz\r
+ *\r
+ */\r
+public interface AuthorityItemJAXBSchema {\r
+ final static String DISPLAY_NAME = "displayName";\r
+ final static String IN_AUTHORITY = "inAuthority";\r
+ final static String REF_NAME = "refName";\r
+ final static String SHORT_IDENTIFIER = "shortIdentifier";\r
+ final static String STATUS = "status";\r
+ final static String CSID = "csid";\r
+}\r
+\r
+\r
--- /dev/null
+/**\r
+ * This document is a part of the source code and related artifacts\r
+ * for CollectionSpace, an open source collections management system\r
+ * for museums and related institutions:\r
+\r
+ * http://www.collectionspace.org\r
+ * http://wiki.collectionspace.org\r
+\r
+ * Copyright 2009 University of California at Berkeley\r
+\r
+ * Licensed under the Educational Community License (ECL), Version 2.0.\r
+ * You may not use this file except in compliance with this License.\r
+\r
+ * You may obtain a copy of the ECL 2.0 License at\r
+\r
+ * https://source.collectionspace.org/collection-space/LICENSE.txt\r
+\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+package org.collectionspace.services.common.vocabulary;\r
+\r
+public interface AuthorityItemListItemJAXBSchema {\r
+ final static String DISPLAY_NAME = "displayName";\r
+ final static String REF_NAME = "refName";\r
+ final static String SHORT_IDENTIFIER = "shortIdentifier";\r
+ final static String CSID = "csid";\r
+ final static String URI = "url";\r
+}\r
--- /dev/null
+/**\r
+ * This document is a part of the source code and related artifacts\r
+ * for CollectionSpace, an open source collections management system\r
+ * for museums and related institutions:\r
+\r
+ * http://www.collectionspace.org\r
+ * http://wiki.collectionspace.org\r
+\r
+ * Copyright 2009 University of California at Berkeley\r
+\r
+ * Licensed under the Educational Community License (ECL), Version 2.0.\r
+ * You may not use this file except in compliance with this License.\r
+\r
+ * You may obtain a copy of the ECL 2.0 License at\r
+\r
+ * https://source.collectionspace.org/collection-space/LICENSE.txt\r
+\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+package org.collectionspace.services.common.vocabulary;\r
+\r
+/**\r
+ * @author pschmitz\r
+ *\r
+ */\r
+public interface AuthorityJAXBSchema {\r
+ final static String DISPLAY_NAME = "displayName";\r
+ final static String SHORT_IDENTIFIER = "shortIdentifier";\r
+ final static String REF_NAME = "refName";\r
+ final static String VOCAB_TYPE = "vocabType";\r
+ final static String CSID = "csid";\r
+}\r
+\r
+\r
--- /dev/null
+/**\r
+ * This document is a part of the source code and related artifacts\r
+ * for CollectionSpace, an open source collections management system\r
+ * for museums and related institutions:\r
+\r
+ * http://www.collectionspace.org\r
+ * http://wiki.collectionspace.org\r
+\r
+ * Copyright 2009 University of California at Berkeley\r
+\r
+ * Licensed under the Educational Community License (ECL), Version 2.0.\r
+ * You may not use this file except in compliance with this License.\r
+\r
+ * You may obtain a copy of the ECL 2.0 License at\r
+\r
+ * https://source.collectionspace.org/collection-space/LICENSE.txt\r
+\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+package org.collectionspace.services.common.vocabulary;\r
+\r
+public interface AuthorityListItemJAXBSchema {\r
+ final static String DISPLAY_NAME = "displayName";\r
+ final static String REF_NAME = "refName";\r
+ final static String SHORT_IDENTIFIER = "shortIdentifier";\r
+ final static String VOCAB_TYPE = "vocabType";\r
+ final static String CSID = "csid";\r
+ final static String URI = "url";\r
+}\r
--- /dev/null
+/**
+ * This document is a part of the source code and related artifacts
+ * for CollectionSpace, an open source collections management system
+ * for museums and related institutions:
+
+ * http://www.collectionspace.org
+ * http://wiki.collectionspace.org
+
+ * Copyright 2009 University of California at Berkeley
+
+ * Licensed under the Educational Community License (ECL), Version 2.0.
+ * You may not use this file except in compliance with this License.
+
+ * You may obtain a copy of the ECL 2.0 License at
+
+ * https://source.collectionspace.org/collection-space/LICENSE.txt
+
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.collectionspace.services.common.vocabulary.nuxeo;
+
+import org.collectionspace.services.common.document.DocumentWrapper;
+
+import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
+import org.nuxeo.ecm.core.api.DocumentModel;
+
+/**
+ * AuthorityDocumentModelHandler
+ *
+ * $LastChangedRevision: $
+ * $LastChangedDate: $
+ */
+public abstract class AuthorityDocumentModelHandler<AuthCommon, AuthCommonList>
+ extends RemoteDocumentModelHandlerImpl<AuthCommon, AuthCommonList> {
+
+ /**
+ * authority is used to stash JAXB object to use when handle is called
+ * for Action.CREATE, Action.UPDATE or Action.GET
+ */
+ private AuthCommon authority;
+ /**
+ * authorityList is stashed when handle is called
+ * for ACTION.GET_ALL
+ */
+ private AuthCommonList authorityList;
+
+
+ /**
+ * getCommonPart get associated authority
+ * @return
+ */
+ @Override
+ public AuthCommon getCommonPart() {
+ return authority;
+ }
+
+ /**
+ * setCommonPart set associated authority
+ * @param authority
+ */
+ @Override
+ public void setCommonPart(AuthCommon authority) {
+ this.authority = authority;
+ }
+
+ /**
+ * getCommonPartList get associated authority (for index/GET_ALL)
+ * @return
+ */
+ @Override
+ public AuthCommonList getCommonPartList() {
+ return authorityList;
+ }
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#setCommonPartList(java.lang.Object)
+ */
+ @Override
+ public void setCommonPartList(AuthCommonList authorityList) {
+ this.authorityList = authorityList;
+ }
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPart(org.collectionspace.services.common.document.DocumentWrapper)
+ */
+ @Override
+ public AuthCommon extractCommonPart(DocumentWrapper<DocumentModel> wrapDoc)
+ throws Exception {
+ throw new UnsupportedOperationException();
+ }
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#fillCommonPart(java.lang.Object, org.collectionspace.services.common.document.DocumentWrapper)
+ */
+ @Override
+ public void fillCommonPart(AuthCommon vocabularyObject, DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
+ throw new UnsupportedOperationException();
+ }
+
+}
+
--- /dev/null
+/**
+ * This document is a part of the source code and related artifacts
+ * for CollectionSpace, an open source collections management system
+ * for museums and related institutions:
+
+ * http://www.collectionspace.org
+ * http://wiki.collectionspace.org
+
+ * Copyright 2009 University of California at Berkeley
+
+ * Licensed under the Educational Community License (ECL), Version 2.0.
+ * You may not use this file except in compliance with this License.
+
+ * You may obtain a copy of the ECL 2.0 License at
+
+ * https://source.collectionspace.org/collection-space/LICENSE.txt
+
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+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.common.vocabulary.AuthorityItemJAXBSchema;
+import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
+import org.nuxeo.ecm.core.api.DocumentModel;
+
+/**
+ * AuthorityItemDocumentModelHandler
+ *
+ * $LastChangedRevision: $
+ * $LastChangedDate: $
+ */
+public abstract class AuthorityItemDocumentModelHandler<AICommon, AICommonList>
+ extends RemoteDocumentModelHandlerImpl<AICommon, AICommonList> {
+
+ //private final Logger logger = LoggerFactory.getLogger(AuthorityItemDocumentModelHandler.class);
+ /**
+ * item is used to stash JAXB object to use when handle is called
+ * for Action.CREATE, Action.UPDATE or Action.GET
+ */
+ protected AICommon item;
+ /**
+ * itemList is stashed when handle is called
+ * for ACTION.GET_ALL
+ */
+ protected AICommonList itemList;
+
+ /**
+ * inVocabulary is the parent Authority for this context
+ */
+ protected String inAuthority;
+
+ public String getInAuthority() {
+ return inAuthority;
+ }
+
+ public void setInAuthority(String inAuthority) {
+ this.inAuthority = inAuthority;
+ }
+
+
+ /**
+ * getCommonPart get associated item
+ * @return
+ */
+ @Override
+ public AICommon getCommonPart() {
+ return item;
+ }
+
+ /**
+ * setCommonPart set associated item
+ * @param vocabularyItem
+ */
+ @Override
+ public void setCommonPart(AICommon item) {
+ this.item = item;
+ }
+
+ /**
+ * getCommonPartList get associated item (for index/GET_ALL)
+ * @return
+ */
+ @Override
+ public AICommonList getCommonPartList() {
+ return itemList;
+ }
+
+ @Override
+ public void setCommonPartList(AICommonList itemList) {
+ this.itemList = itemList;
+ }
+
+ @Override
+ public AICommon extractCommonPart(DocumentWrapper<DocumentModel> wrapDoc)
+ throws Exception {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void fillCommonPart(AICommon itemObject, DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Filters out AuthorityItemJAXBSchema.IN_AUTHORITY, to ensure that
+ * the parent link remains untouched.
+ * @param objectProps the properties parsed from the update payload
+ * @param partMeta metadata for the object to fill
+ */
+ @Override
+ public void filterReadOnlyPropertiesForPart(
+ Map<String, Object> objectProps, ObjectPartType partMeta) {
+ super.filterReadOnlyPropertiesForPart(objectProps, partMeta);
+ objectProps.remove(AuthorityItemJAXBSchema.IN_AUTHORITY);
+ }
+
+}
+
import org.collectionspace.services.common.document.AbstractMultipartDocumentHandlerImpl;
import org.collectionspace.services.common.document.DocumentFilter;
import org.collectionspace.services.common.document.DocumentWrapper;
+import org.collectionspace.services.common.document.DocumentHandler.Action;
import org.collectionspace.services.nuxeo.client.*;
import org.nuxeo.ecm.core.api.DocumentModel;
import org.nuxeo.ecm.core.api.DocumentModelList;
public void handleCreate(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
// TODO for sub-docs - check to see if the current service context is a multipart input,
// OR a docfragment, and call a variant to fill the DocModel.
- fillAllParts(wrapDoc);
+ fillAllParts(wrapDoc, Action.CREATE);
}
// TODO for sub-docs - Add completeCreate in which we look for set-aside doc fragments
public void handleUpdate(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
// TODO for sub-docs - check to see if the current service context is a multipart input,
// OR a docfragment, and call a variant to fill the DocModel.
- fillAllParts(wrapDoc);
+ fillAllParts(wrapDoc, Action.UPDATE);
}
@Override
public abstract T extractCommonPart(DocumentWrapper<DocumentModel> wrapDoc) throws Exception;
@Override
- public abstract void fillAllParts(DocumentWrapper<DocumentModel> wrapDoc) throws Exception;
+ public abstract void fillAllParts(DocumentWrapper<DocumentModel> wrapDoc, Action action) throws Exception;
@Override
public abstract void fillCommonPart(T obj, DocumentWrapper<DocumentModel> wrapDoc) throws Exception;
import org.collectionspace.services.common.document.DocumentUtils;
import org.collectionspace.services.common.document.DocumentWrapper;
import org.collectionspace.services.common.document.DocumentFilter;
+import org.collectionspace.services.common.document.DocumentHandler.Action;
import org.collectionspace.services.common.service.ObjectPartType;
import org.collectionspace.services.common.vocabulary.RefNameUtils;
* @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#fillAllParts(org.collectionspace.services.common.document.DocumentWrapper)
*/
@Override
- public void fillAllParts(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
+ public void fillAllParts(DocumentWrapper<DocumentModel> wrapDoc, Action action) throws Exception {
//TODO filling extension parts should be dynamic
//Nuxeo APIs lack to support stream/byte[] input, get/setting properties is
}
//skip if the part is not in metadata
- if(!partsMetaMap.containsKey(partLabel)){
+ ObjectPartType partMeta = partsMetaMap.get(partLabel);
+ if(partMeta==null){
continue;
}
- ObjectPartType partMeta = partsMetaMap.get(partLabel);
- fillPart(part, docModel, partMeta);
+ fillPart(part, docModel, partMeta, action);
}//rof
}
* @param partMeta metadata for the object to fill
* @throws Exception
*/
- protected void fillPart(InputPart part, DocumentModel docModel, ObjectPartType partMeta)
+ protected void fillPart(InputPart part, DocumentModel docModel, ObjectPartType partMeta, Action action)
throws Exception {
InputStream payload = part.getBody(InputStream.class, null);
//TODO: callback to handler if registered to validate the
//document
Map<String, Object> objectProps = DocumentUtils.parseProperties(document.getFirstChild());
+ if(action==Action.UPDATE) {
+ this.filterReadOnlyPropertiesForPart(objectProps, partMeta);
+ }
docModel.setProperties(partMeta.getLabel(), objectProps);
}
}
}
+ /**
+ * Filters out read only properties, so they cannot be set on update.
+ * TODO: add configuration support to do this generally
+ * @param objectProps the properties parsed from the update payload
+ * @param partMeta metadata for the object to fill
+ */
+ public void filterReadOnlyPropertiesForPart(
+ Map<String, Object> objectProps, ObjectPartType partMeta) {
+ // Currently a no-op, but can be overridden in Doc handlers.
+ }
+
/**
* extractPart extracts an XML object from given DocumentModel
* @param docModel
* @throws Exception\r
*/\r
@Override\r
- protected void fillPart(InputPart part, DocumentModel docModel, ObjectPartType partMeta)\r
+ protected void fillPart(InputPart part, DocumentModel docModel, \r
+ ObjectPartType partMeta, Action action)\r
throws Exception {\r
InputStream payload = part.getBody(InputStream.class, null);\r
\r
/* (non-Javadoc)
* @see org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl#fillAllParts(org.collectionspace.services.common.document.DocumentWrapper)
- */
@Override
public void fillAllParts(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
super.fillAllParts(wrapDoc);
}
+ */
/**
* Gets the relation list item.
<rows>
<row><widget>displayName</widget></row>
<row><widget>shortIdentifier</widget></row>
- <row><widget>refName</widget></row>
+ <row><widget>CSID</widget></row>
+ <row><widget>refName</widget></row>
<row><widget>vocabType</widget></row>
</rows>
</properties>
</widget>
+ <widget name="CSID" type="text">
+ <labels>
+ <label mode="any">CSID</label>
+ </labels>
+ <translated>true</translated>
+ <fields>
+ <field>ecm:name</field>
+ </fields>
+ <properties widgetMode="edit">
+ <property name="styleClass">dataInputText</property>
+ </properties>
+ </widget>
+
<widget name="refName" type="text">
<labels>
<label mode="any">RefName</label>
<row><widget>displayName</widget></row>
<row><widget>shortIdentifier</widget></row>
<row><widget>refName</widget></row>
- <row><widget>inVocabulary</widget></row>
+ <row><widget>inAuthority</widget></row>
<row><widget>status</widget></row>
</rows>
</properties>
</widget>
- <widget name="inVocabulary" type="text">
+ <widget name="inAuthority" type="text">
<labels>
- <label mode="any">Vocab</label>
+ <label mode="any">inAuthority</label>
</labels>
<translated>true</translated>
<fields>
- <field schema="vocabularyitems_common">inVocabulary</field>
+ <field schema="vocabularyitems_common">inAuthority</field>
</fields>
<properties widgetMode="edit">
<property name="styleClass">dataInputText</property>
<!-- VocabularyItem Information Group -->
<!-- inVocabulary is the csid of the owning Vocabulary -->
- <xs:element name="inVocabulary" type="xs:string" />
+ <xs:element name="inAuthority" type="xs:string" />
<xs:element name="refName" type="xs:string"/>
<xs:element name="shortIdentifier" type="xs:string"/>
<xs:element name="displayName" type="xs:string"/>
import javax.ws.rs.core.MultivaluedMap;\r
import javax.ws.rs.core.Response;\r
\r
-import org.collectionspace.services.VocabularyItemJAXBSchema;\r
+import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema;\r
import org.collectionspace.services.client.test.ServiceRequestType;\r
import org.collectionspace.services.vocabulary.VocabularyitemsCommon;\r
import org.collectionspace.services.vocabulary.VocabulariesCommon;\r
\r
// Note that we do not use the map, but we will once we add more info to the \r
// items\r
- public static MultipartOutput createVocabularyItemInstance(String inVocabulary, \r
+ public static MultipartOutput createVocabularyItemInstance(String inAuthority, \r
String vocabularyRefName, Map<String, String> vocabItemInfo, String headerLabel){\r
VocabularyitemsCommon vocabularyItem = new VocabularyitemsCommon();\r
- vocabularyItem.setInVocabulary(inVocabulary);\r
- String shortId = vocabItemInfo.get(VocabularyItemJAXBSchema.SHORT_IDENTIFIER);\r
- String displayName = vocabItemInfo.get(VocabularyItemJAXBSchema.DISPLAY_NAME);\r
+ vocabularyItem.setInAuthority(inAuthority);\r
+ String shortId = vocabItemInfo.get(AuthorityItemJAXBSchema.SHORT_IDENTIFIER);\r
+ String displayName = vocabItemInfo.get(AuthorityItemJAXBSchema.DISPLAY_NAME);\r
vocabularyItem.setShortIdentifier(shortId);\r
vocabularyItem.setDisplayName(displayName);\r
String refName = createVocabularyItemRefName(vocabularyRefName, shortId, displayName);\r
ServiceRequestType REQUEST_TYPE = ServiceRequestType.CREATE;\r
\r
if(logger.isDebugEnabled()){\r
- logger.debug("Import: Create Item: \""+itemMap.get(VocabularyItemJAXBSchema.DISPLAY_NAME)\r
- +"\" in personAuthorityulary: \"" + vocabularyRefName +"\"");\r
+ logger.debug("Import: Create Item: \""+itemMap.get(AuthorityItemJAXBSchema.SHORT_IDENTIFIER)\r
+ +"\" in personAuthority: \"" + vcsid +"\"");\r
}\r
MultipartOutput multipart = \r
createVocabularyItemInstance( vcsid, vocabularyRefName,\r
int statusCode = res.getStatus();\r
\r
if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {\r
- throw new RuntimeException("Could not create Item: \""+itemMap.get(VocabularyItemJAXBSchema.DISPLAY_NAME)\r
+ throw new RuntimeException("Could not create Item: \""+itemMap.get(AuthorityItemJAXBSchema.DISPLAY_NAME)\r
+"\" in personAuthority: \"" + vocabularyRefName\r
+"\" "+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));\r
}\r
if(statusCode != EXPECTED_STATUS_CODE) {\r
- throw new RuntimeException("Unexpected Status when creating Item: \""+itemMap.get(VocabularyItemJAXBSchema.DISPLAY_NAME)\r
+ throw new RuntimeException("Unexpected Status when creating Item: \""+itemMap.get(AuthorityItemJAXBSchema.DISPLAY_NAME)\r
+"\" in personAuthority: \"" + vocabularyRefName +"\", Status:"+ statusCode);\r
}\r
\r
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import org.collectionspace.services.VocabularyItemJAXBSchema;
+import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema;
import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.client.VocabularyClient;
import org.collectionspace.services.client.VocabularyClientUtils;
private String knownResourceRefName = null;
private String knownResourceFullRefName = null;
private String knownItemResourceId = null;
- private int nItemsToCreateInList = 3;
+ private int nItemsToCreateInList = 5;
private List<String> allResourceIdsCreated = new ArrayList<String>();
private Map<String, String> allResourceItemIdsCreated =
new HashMap<String, String>();
dependsOnMethods = {"create"})
public void createItem(String testName) {
- if (logger.isDebugEnabled()) {
+ if (null!=testName && logger.isDebugEnabled()) {
logger.debug(testBanner(testName, CLASS_NAME));
}
// Perform setup.
VocabularyClient client = new VocabularyClient();
HashMap<String, String> itemInfo = new HashMap<String, String>();
String shortId = createIdentifier();
- itemInfo.put(VocabularyItemJAXBSchema.SHORT_IDENTIFIER, shortId);
- itemInfo.put(VocabularyItemJAXBSchema.DISPLAY_NAME, "display-"+shortId);
+ itemInfo.put(AuthorityItemJAXBSchema.SHORT_IDENTIFIER, shortId);
+ itemInfo.put(AuthorityItemJAXBSchema.DISPLAY_NAME, "display-"+shortId);
String newID = VocabularyClientUtils.createItemInVocabulary(knownResourceId,
knownResourceRefName, itemInfo, client);
// for additional tests below.
if (knownItemResourceId == null){
knownItemResourceId = newID;
- if (logger.isDebugEnabled()) {
+ if (null!=testName && logger.isDebugEnabled()) {
logger.debug(testName + ": knownItemResourceId=" + knownItemResourceId);
}
}
for (int i = 0; i < 3; i++) {
// Force create to reset the known resource info
setKnownResource(null, null, null, null);
+ knownItemResourceId = null;
create(testName);
// Add nItemsToCreateInList items to each vocab
for (int j = 0; j < nItemsToCreateInList; j++) {
- createItem(testName);
+ createItem(null);
}
}
}
// Submit the request to the service and store the response.
VocabularyClient client = new VocabularyClient();
HashMap<String, String> itemInfo = new HashMap<String, String>();
- itemInfo.put(VocabularyItemJAXBSchema.SHORT_IDENTIFIER, "Bad Item Short Id!");
- itemInfo.put(VocabularyItemJAXBSchema.DISPLAY_NAME, "Bad Item!");
+ itemInfo.put(AuthorityItemJAXBSchema.SHORT_IDENTIFIER, "Bad Item Short Id!");
+ itemInfo.put(AuthorityItemJAXBSchema.DISPLAY_NAME, "Bad Item!");
MultipartOutput multipart =
VocabularyClientUtils.createVocabularyItemInstance( knownResourceId, knownResourceRefName,
itemInfo, client.getItemCommonPartName() );
int statusCode = res.getStatus();
if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {
- throw new RuntimeException("Could not create Item: \""+itemInfo.get(VocabularyItemJAXBSchema.DISPLAY_NAME)
+ throw new RuntimeException("Could not create Item: \""+itemInfo.get(AuthorityItemJAXBSchema.DISPLAY_NAME)
+"\" in personAuthority: \"" + knownResourceRefName
+"\" "+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
}
if(statusCode != EXPECTED_STATUS_CODE) {
- throw new RuntimeException("Unexpected Status when creating Item: \""+itemInfo.get(VocabularyItemJAXBSchema.DISPLAY_NAME)
+ throw new RuntimeException("Unexpected Status when creating Item: \""+itemInfo.get(AuthorityItemJAXBSchema.DISPLAY_NAME)
+"\" in personAuthority: \"" + knownResourceRefName +"\", Status:"+ statusCode);
}
}
VocabularyitemsCommon vocabularyItem = (VocabularyitemsCommon) extractPart(input,
client.getItemCommonPartName(), VocabularyitemsCommon.class);
Assert.assertNotNull(vocabularyItem);
- Assert.assertEquals(vocabularyItem.getInVocabulary(), knownResourceId);
+ Assert.assertEquals(vocabularyItem.getInAuthority(), knownResourceId);
}
// Failure outcomes
List<VocabularyitemsCommonList.VocabularyitemListItem> items =
list.getVocabularyitemListItem();
int nItemsReturned = items.size();
+ long nItemsTotal = list.getTotalItems();
if(logger.isDebugEnabled()){
logger.debug(" " + testName + ": Expected "
- + nItemsToCreateInList+" items; got: "+nItemsReturned);
+ + nItemsToCreateInList+" items; got: "+nItemsReturned+" of: "+nItemsTotal);
}
- Assert.assertEquals( nItemsReturned, nItemsToCreateInList);
+ Assert.assertEquals( nItemsTotal, nItemsToCreateInList);
// Optionally output additional data about list members for debugging.
boolean iterateThroughList = true;
}
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- dependsOnMethods = {"readItem", "update"})
+ dependsOnMethods = {"readItem", "update", "verifyIgnoredUpdateWithInAuthority"})
public void updateItem(String testName) throws Exception {
if (logger.isDebugEnabled()) {
"Data in updated VocabularyItem did not match submitted data.");
}
+ @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+ dependsOnMethods = {"readItem"})
+ public void verifyIgnoredUpdateWithInAuthority(String testName) throws Exception {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(testBanner(testName, CLASS_NAME));
+ }
+ // Perform setup.
+ setupUpdate();
+
+ // Submit the request to the service and store the response.
+ VocabularyClient client = new VocabularyClient();
+ ClientResponse<MultipartInput> res = client.readItem(knownResourceId, knownItemResourceId);
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + " read Vocab:"+knownResourceId+"/Item:"
+ +knownItemResourceId+" status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, Response.Status.OK.getStatusCode());
+
+ MultipartInput input = (MultipartInput) res.getEntity();
+ VocabularyitemsCommon vitem = (VocabularyitemsCommon) extractPart(input,
+ client.getItemCommonPartName(), VocabularyitemsCommon.class);
+ Assert.assertNotNull(vitem);
+ // Try to Update with new parent vocab (use self, for test).
+ Assert.assertEquals(vitem.getInAuthority(),
+ knownResourceId,
+ "VocabularyItem inAuthority does not match knownResourceId.");
+ vitem.setInAuthority(knownItemResourceId);
+
+ // Submit the updated resource to the service and store the response.
+ MultipartOutput output = new MultipartOutput();
+ OutputPart commonPart = output.addPart(vitem, MediaType.APPLICATION_XML_TYPE);
+ commonPart.getHeaders().add("label", client.getItemCommonPartName());
+ res = client.updateItem(knownResourceId, knownItemResourceId, output);
+ statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ // Retrieve the updated resource and verify that the parent did not change
+ res = client.readItem(knownResourceId, knownItemResourceId);
+ input = (MultipartInput) res.getEntity();
+ VocabularyitemsCommon updatedVocabularyItem =
+ (VocabularyitemsCommon) extractPart(input,
+ client.getItemCommonPartName(), VocabularyitemsCommon.class);
+ Assert.assertNotNull(updatedVocabularyItem);
+
+ // Verify that the updated resource received the correct data.
+ Assert.assertEquals(updatedVocabularyItem.getInAuthority(),
+ knownResourceId,
+ "VocabularyItem allowed update to the parent (inAuthority).");
+ }
+
// Failure outcomes
// Placeholders until the three tests below can be uncommented.
// See Issue CSPACE-401.
// The only relevant ID may be the one used in update(), below.
VocabularyClient client = new VocabularyClient();
HashMap<String, String> itemInfo = new HashMap<String, String>();
- itemInfo.put(VocabularyItemJAXBSchema.SHORT_IDENTIFIER, "nonex");
- itemInfo.put(VocabularyItemJAXBSchema.DISPLAY_NAME, "display-nonex");
+ itemInfo.put(AuthorityItemJAXBSchema.SHORT_IDENTIFIER, "nonex");
+ itemInfo.put(AuthorityItemJAXBSchema.DISPLAY_NAME, "display-nonex");
MultipartOutput multipart =
VocabularyClientUtils.createVocabularyItemInstance(knownResourceId,
VocabularyClientUtils.createVocabularyRefName(NON_EXISTENT_ID, null),
// Success outcomes
@Override
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"})
+ dependsOnMethods = {"create", "readList", "testSubmitRequest", "update", "deleteItem"})
public void delete(String testName) throws Exception {
if (logger.isDebugEnabled()) {
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
dependsOnMethods = {"createItem", "readItemList", "testItemSubmitRequest",
- "updateItem", "verifyIllegalItemDisplayName"})
+ "updateItem", "verifyIllegalItemDisplayName", "verifyIgnoredUpdateWithInAuthority"})
public void deleteItem(String testName) throws Exception {
if (logger.isDebugEnabled()) {
}
for (String itemName : enumValues) {
HashMap<String, String> itemInfo = new HashMap<String, String>();
- itemInfo.put(VocabularyItemJAXBSchema.DISPLAY_NAME, itemName);
+ itemInfo.put(AuthorityItemJAXBSchema.DISPLAY_NAME, itemName);
VocabularyClientUtils.createItemInVocabulary(newVocabId,
baseVocabRefName, itemInfo, client);
}
<name>services.vocabulary.jaxb</name>
<dependencies>
+ <!-- CollectionSpace dependencies -->
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <!-- External dependencies -->
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
+++ /dev/null
-/**\r
- * \r
- */\r
-package org.collectionspace.services;\r
-\r
-/**\r
- * @author pschmitz\r
- *\r
- */\r
-public interface VocabularyItemJAXBSchema {\r
- final static String VOCABULARYITEMS_COMMON="vocabularyitems_common";\r
- final static String DISPLAY_NAME = "displayName";\r
- final static String IN_VOCABULARY = "inVocabulary";\r
- final static String REF_NAME = "refName";\r
- final static String SHORT_IDENTIFIER = "shortIdentifier";\r
- final static String STATUS = "status";\r
- final static String CSID = "csid";\r
-}\r
-\r
-\r
+++ /dev/null
-package org.collectionspace.services;\r
-\r
-public interface VocabularyItemListItemJAXBSchema {\r
- final static String DISPLAY_NAME = "displayName";\r
- final static String REF_NAME = "refName";\r
- final static String CSID = "csid";\r
- final static String URI = "url";\r
-}\r
+++ /dev/null
-/**\r
- * \r
- */\r
-package org.collectionspace.services;\r
-\r
-/**\r
- * @author pschmitz\r
- *\r
- */\r
-public interface VocabularyJAXBSchema {\r
- final static String VOCABULARIES_COMMON = "vocabularies_common";\r
- final static String DISPLAY_NAME = "displayName";\r
- final static String SHORT_IDENTIFIER = "shortIdentifier";\r
- final static String REF_NAME = "refName";\r
- final static String VOCAB_TYPE = "vocabType";\r
- final static String CSID = "csid";\r
-}\r
-\r
-\r
+++ /dev/null
-package org.collectionspace.services;\r
-\r
-public interface VocabularyListItemJAXBSchema {\r
- final static String DISPLAY_NAME = "displayName";\r
- final static String REF_NAME = "refName";\r
- final static String SHORT_IDENTIFIER = "shortIdentifier";\r
- final static String VOCAB_TYPE = "vocabType";\r
- final static String CSID = "csid";\r
- final static String URI = "url";\r
-}\r
<!-- See http://wiki.collectionspace.org/display/collectionspace/Vocabulary+Schema -->
<!-- Vocabularyitem -->
- <xs:element name="vocabularyitems_common">
- <xs:complexType>
- <xs:sequence>
- <!-- Common identifier -->
- <xs:element name="csid" type="xs:string" />
-
- <!-- Vocabularyitem Information Group -->
- <xs:element name="inVocabulary" type="xs:string" />
- <xs:element name="displayName" type="xs:string"/>
- <xs:element name="shortIdentifier" type="xs:string"/>
- <xs:element name="refName" type="xs:string"/>
- <xs:element name="status" type="xs:string"/>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
+ <xs:element name="vocabularyitems_common">
+ <xs:complexType>
+ <xs:sequence>
+ <!-- Common identifier -->
+ <xs:element name="csid" type="xs:string" />
+
+ <!-- Vocabularyitem Information Group -->
+ <xs:element name="inAuthority" type="xs:string" />
+ <xs:element name="displayName" type="xs:string" />
+ <xs:element name="shortIdentifier" type="xs:string" />
+ <xs:element name="refName" type="xs:string" />
+ <xs:element name="status" type="xs:string" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
<!-- This is the base class for paginated lists -->
<xs:complexType name="abstractCommonListItem">
import javax.ws.rs.core.UriBuilder;
import javax.ws.rs.core.UriInfo;
-import org.collectionspace.services.VocabularyJAXBSchema;
-import org.collectionspace.services.VocabularyItemJAXBSchema;
+import org.collectionspace.services.common.vocabulary.AuthorityJAXBSchema;
+import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema;
import org.collectionspace.services.common.AbstractMultiPartCollectionSpaceResourceImpl;
import org.collectionspace.services.common.ClientType;
import org.collectionspace.services.common.ServiceMain;
/** The Constant vocabularyServiceName. */
private final static String vocabularyServiceName = "vocabularies";
+ private final static String VOCABULARIES_COMMON = "vocabularies_common";
/** The Constant vocabularyItemServiceName. */
private final static String vocabularyItemServiceName = "vocabularyitems";
+ private final static String VOCABULARYITEMS_COMMON = "vocabularyitems_common";
/** The logger. */
final Logger logger = LoggerFactory.getLogger(VocabularyResource.class);
docHandler = (VocabularyItemDocumentModelHandler)createDocumentHandler(ctx,
ctx.getCommonPartLabel(getItemServiceName()),
- VocabularyitemsCommon.class);
- docHandler.setInVocabulary(inVocabulary);
+ VocabularyitemsCommon.class);
+ docHandler.setInAuthority(inVocabulary);
return docHandler;
}
throw new WebApplicationException(response);
}
String whereClause =
- VocabularyJAXBSchema.VOCABULARIES_COMMON+
- ":"+VocabularyJAXBSchema.SHORT_IDENTIFIER+
+ VOCABULARIES_COMMON+
+ ":"+AuthorityJAXBSchema.SHORT_IDENTIFIER+
"='"+specifier+"'";
// We only get a single doc - if there are multiple,
// it is an error in use.
DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
DocumentFilter myFilter = handler.getDocumentFilter();
myFilter.setWhereClause(
- VocabularyItemJAXBSchema.VOCABULARYITEMS_COMMON + ":"
- + VocabularyItemJAXBSchema.IN_VOCABULARY + "="
+ VOCABULARYITEMS_COMMON + ":"
+ + AuthorityItemJAXBSchema.IN_AUTHORITY + "="
+ "'" + parentcsid + "'");
// AND vocabularyitems_common:displayName LIKE '%partialTerm%'
if (partialTerm != null && !partialTerm.isEmpty()) {
- String ptClause = VocabularyItemJAXBSchema.VOCABULARYITEMS_COMMON + ":"
- + VocabularyItemJAXBSchema.DISPLAY_NAME
+ String ptClause = VOCABULARYITEMS_COMMON + ":"
+ + AuthorityItemJAXBSchema.DISPLAY_NAME
+ IQueryManager.SEARCH_LIKE
+ "'%" + partialTerm + "%'";
myFilter.appendWhereClause(ptClause, IQueryManager.SEARCH_QUALIFIER_AND);
try {
MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
String whereClause =
- VocabularyJAXBSchema.VOCABULARIES_COMMON+
- ":"+VocabularyJAXBSchema.SHORT_IDENTIFIER+
+ VOCABULARIES_COMMON+
+ ":"+AuthorityJAXBSchema.SHORT_IDENTIFIER+
"='"+specifier+"'";
// Need to get an Authority by name
ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(queryParams);
import java.util.Iterator;
import java.util.List;
-import org.collectionspace.services.VocabularyJAXBSchema;
-import org.collectionspace.services.common.document.DocumentHandler.Action;
-import org.collectionspace.services.common.document.DocumentFilter;
+import org.collectionspace.services.common.vocabulary.AuthorityJAXBSchema;
+import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityDocumentModelHandler;
import org.collectionspace.services.common.document.DocumentWrapper;
import org.collectionspace.services.vocabulary.VocabulariesCommon;
import org.collectionspace.services.vocabulary.VocabulariesCommonList;
import org.collectionspace.services.vocabulary.VocabulariesCommonList.VocabularyListItem;
-import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
import org.collectionspace.services.nuxeo.util.NuxeoUtils;
import org.nuxeo.ecm.core.api.DocumentModel;
import org.nuxeo.ecm.core.api.DocumentModelList;
* $LastChangedDate: $
*/
public class VocabularyDocumentModelHandler
- extends RemoteDocumentModelHandlerImpl<VocabulariesCommon, VocabulariesCommonList> {
+ extends AuthorityDocumentModelHandler<VocabulariesCommon, VocabulariesCommonList> {
/** The logger. */
private final Logger logger = LoggerFactory.getLogger(VocabularyDocumentModelHandler.class);
* vocabulary is used to stash JAXB object to use when handle is called
* for Action.CREATE, Action.UPDATE or Action.GET
*/
- private VocabulariesCommon vocabulary;
+ //private VocabulariesCommon vocabulary;
/**
* vocabularyList is stashed when handle is called
* for ACTION.GET_ALL
*/
- private VocabulariesCommonList vocabularyList;
+ //private VocabulariesCommonList vocabularyList;
/**
* getCommonPart get associated vocabulary
* @return
- */
@Override
public VocabulariesCommon getCommonPart() {
return vocabulary;
}
+ */
/**
* setCommonPart set associated vocabulary
* @param vocabulary
- */
@Override
public void setCommonPart(VocabulariesCommon vocabulary) {
this.vocabulary = vocabulary;
}
+ */
/**
* getCommonPartList get associated vocabulary (for index/GET_ALL)
* @return
- */
@Override
public VocabulariesCommonList getCommonPartList() {
return vocabularyList;
}
+ */
/* (non-Javadoc)
* @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#setCommonPartList(java.lang.Object)
- */
@Override
public void setCommonPartList(VocabulariesCommonList vocabularyList) {
this.vocabularyList = vocabularyList;
}
+ */
/* (non-Javadoc)
* @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPart(org.collectionspace.services.common.document.DocumentWrapper)
- */
@Override
public VocabulariesCommon extractCommonPart(DocumentWrapper<DocumentModel> wrapDoc)
throws Exception {
throw new UnsupportedOperationException();
}
+ */
/* (non-Javadoc)
* @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#fillCommonPart(java.lang.Object, org.collectionspace.services.common.document.DocumentWrapper)
- */
@Override
public void fillCommonPart(VocabulariesCommon vocabularyObject, DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
throw new UnsupportedOperationException();
}
+ */
/* (non-Javadoc)
* @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPartList(org.collectionspace.services.common.document.DocumentWrapper)
@Override
public VocabulariesCommonList extractCommonPartList(
DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
+ String label = getServiceContext().getCommonPartLabel();
VocabulariesCommonList coList = extractPagingInfo(new VocabulariesCommonList(), wrapDoc);
List<VocabulariesCommonList.VocabularyListItem> list = coList.getVocabularyListItem();
Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
while(iter.hasNext()){
DocumentModel docModel = iter.next();
VocabularyListItem ilistItem = new VocabularyListItem();
- ilistItem.setDisplayName((String) docModel.getProperty(getServiceContext().getCommonPartLabel(),
- VocabularyJAXBSchema.DISPLAY_NAME));
- ilistItem.setRefName((String) docModel.getProperty(getServiceContext().getCommonPartLabel(),
- VocabularyJAXBSchema.REF_NAME));
- ilistItem.setShortIdentifier((String) docModel.getProperty(getServiceContext().getCommonPartLabel(),
- VocabularyJAXBSchema.SHORT_IDENTIFIER));
- ilistItem.setVocabType((String) docModel.getProperty(getServiceContext().getCommonPartLabel(),
- VocabularyJAXBSchema.VOCAB_TYPE));
+ ilistItem.setDisplayName((String) docModel.getProperty(label,
+ AuthorityJAXBSchema.DISPLAY_NAME));
+ ilistItem.setRefName((String) docModel.getProperty(label,
+ AuthorityJAXBSchema.REF_NAME));
+ ilistItem.setShortIdentifier((String) docModel.getProperty(label,
+ AuthorityJAXBSchema.SHORT_IDENTIFIER));
+ ilistItem.setVocabType((String) docModel.getProperty(label,
+ AuthorityJAXBSchema.VOCAB_TYPE));
String id = NuxeoUtils.extractId(docModel.getPathAsString());
ilistItem.setUri(getServiceContextPath() + id);
ilistItem.setCsid(id);
import java.util.Iterator;
import java.util.List;
+//import java.util.Map;
-import org.collectionspace.services.VocabularyItemJAXBSchema;
-import org.collectionspace.services.common.document.DocumentFilter;
+import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema;
+//import org.collectionspace.services.common.document.DocumentFilter;
import org.collectionspace.services.common.document.DocumentWrapper;
-import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
+//import org.collectionspace.services.common.service.ObjectPartType;
+//import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
+import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityItemDocumentModelHandler;
import org.collectionspace.services.nuxeo.util.NuxeoUtils;
import org.collectionspace.services.vocabulary.VocabularyitemsCommon;
import org.collectionspace.services.vocabulary.VocabularyitemsCommonList;
* $LastChangedDate: $
*/
public class VocabularyItemDocumentModelHandler
- extends RemoteDocumentModelHandlerImpl<VocabularyitemsCommon, VocabularyitemsCommonList> {
+ extends AuthorityItemDocumentModelHandler<VocabularyitemsCommon, VocabularyitemsCommonList> {
private final Logger logger = LoggerFactory.getLogger(VocabularyItemDocumentModelHandler.class);
- /**
- * vocabularyItem is used to stash JAXB object to use when handle is called
- * for Action.CREATE, Action.UPDATE or Action.GET
- */
- private VocabularyitemsCommon vocabularyItem;
- /**
- * vocabularyItemList is stashed when handle is called
- * for ACTION.GET_ALL
- */
- private VocabularyitemsCommonList vocabularyItemList;
- /**
- * inVocabulary is the parent vocabulary for this context
- */
- private String inVocabulary;
-
- public String getInVocabulary() {
- return inVocabulary;
- }
-
- public void setInVocabulary(String inVocabulary) {
- this.inVocabulary = inVocabulary;
- }
-
-
- /**
- * getCommonPart get associated vocabularyItem
- * @return
- */
- @Override
- public VocabularyitemsCommon getCommonPart() {
- return vocabularyItem;
- }
-
- /**
- * setCommonPart set associated vocabularyItem
- * @param vocabularyItem
- */
- @Override
- public void setCommonPart(VocabularyitemsCommon vocabularyItem) {
- this.vocabularyItem = vocabularyItem;
- }
-
- /**
- * getCommonPartList get associated vocabularyItem (for index/GET_ALL)
- * @return
- */
- @Override
- public VocabularyitemsCommonList getCommonPartList() {
- return vocabularyItemList;
- }
-
- @Override
- public void setCommonPartList(VocabularyitemsCommonList vocabularyItemList) {
- this.vocabularyItemList = vocabularyItemList;
- }
-
- @Override
- public VocabularyitemsCommon extractCommonPart(DocumentWrapper wrapDoc)
- throws Exception {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void fillCommonPart(VocabularyitemsCommon vocabularyItemObject, DocumentWrapper wrapDoc) throws Exception {
- throw new UnsupportedOperationException();
- }
-
@Override
public VocabularyitemsCommonList extractCommonPartList(
DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
VocabularyitemsCommonList coList = extractPagingInfo(new VocabularyitemsCommonList(), wrapDoc);
- // FIXME: iterating over a long list of documents is not a long term
- // strategy...need to change to more efficient iterating in future
List<VocabularyitemsCommonList.VocabularyitemListItem> list = coList.getVocabularyitemListItem();
Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
while (iter.hasNext()) {
VocabularyitemListItem ilistItem = new VocabularyitemListItem();
ilistItem.setDisplayName((String) docModel.getProperty(
getServiceContext().getCommonPartLabel("vocabularyItems"),
- VocabularyItemJAXBSchema.DISPLAY_NAME));
+ AuthorityItemJAXBSchema.DISPLAY_NAME));
ilistItem.setRefName((String) docModel.getProperty(
getServiceContext().getCommonPartLabel("vocabularyItems"),
- VocabularyItemJAXBSchema.REF_NAME));
+ AuthorityItemJAXBSchema.REF_NAME));
String id = NuxeoUtils.extractId(docModel.getPathAsString());
- ilistItem.setUri("/vocabularies/" + inVocabulary + "/items/" + id);
+ ilistItem.setUri("/vocabularies/" + inAuthority + "/items/" + id);
ilistItem.setCsid(id);
list.add(ilistItem);
}