]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-600, preparation for CSPACE-849, and fixed CSPACE-2291. This refactors the...
authorPatrick Schmitz <pschmitz@berkeley.edu>
Tue, 29 Jun 2010 16:33:18 +0000 (16:33 +0000)
committerPatrick Schmitz <pschmitz@berkeley.edu>
Tue, 29 Jun 2010 16:33:18 +0000 (16:33 +0000)
30 files changed:
3rdparty/nuxeo/nuxeo-platform-collectionspace/src/main/resources/META-INF/MANIFEST.MF
3rdparty/nuxeo/nuxeo-platform-collectionspace/src/main/resources/OSGI-INF/querymodel-contrib.xml [new file with mode: 0644]
services/acquisition/service/src/main/java/org/collectionspace/services/acquisition/nuxeo/AcquisitionDocumentModelHandler.java
services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/nuxeo/CollectionObjectDocumentModelHandler.java
services/common/src/main/java/org/collectionspace/services/common/document/AbstractMultipartDocumentHandlerImpl.java
services/common/src/main/java/org/collectionspace/services/common/document/MultipartDocumentHandler.java
services/common/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityItemJAXBSchema.java [new file with mode: 0644]
services/common/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityItemListItemJAXBSchema.java [new file with mode: 0644]
services/common/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityJAXBSchema.java [new file with mode: 0644]
services/common/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityListItemJAXBSchema.java [new file with mode: 0644]
services/common/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityDocumentModelHandler.java [new file with mode: 0644]
services/common/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java [new file with mode: 0644]
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocumentModelHandler.java
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteDocumentModelHandlerImpl.java
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteSubItemDocumentModelHandlerImpl.java
services/relation/service/src/main/java/org/collectionspace/services/relation/nuxeo/RelationDocumentModelHandler.java
services/vocabulary/3rdparty/nuxeo-platform-cs-vocabulary/src/main/resources/OSGI-INF/layouts-contrib.xml
services/vocabulary/3rdparty/nuxeo-platform-cs-vocabulary/src/main/resources/schemas/vocabularyitems_common.xsd
services/vocabulary/client/src/main/java/org/collectionspace/services/client/VocabularyClientUtils.java
services/vocabulary/client/src/test/java/org/collectionspace/services/client/test/VocabularyServiceTest.java
services/vocabulary/import/src/main/java/org/collectionspace/services/vocabulary/importer/VocabularyBaseImport.java
services/vocabulary/jaxb/pom.xml
services/vocabulary/jaxb/src/main/java/org/collectionspace/services/VocabularyItemJAXBSchema.java [deleted file]
services/vocabulary/jaxb/src/main/java/org/collectionspace/services/VocabularyItemListItemJAXBSchema.java [deleted file]
services/vocabulary/jaxb/src/main/java/org/collectionspace/services/VocabularyJAXBSchema.java [deleted file]
services/vocabulary/jaxb/src/main/java/org/collectionspace/services/VocabularyListItemJAXBSchema.java [deleted file]
services/vocabulary/jaxb/src/main/resources/vocabularyitem_common.xsd
services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/VocabularyResource.java
services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyDocumentModelHandler.java
services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyItemDocumentModelHandler.java

index 716581666a5946e8ca278fae39320475dc163796..2c0df61dd83122dde8cdba5e6cc6d35730ae9cdc 100644 (file)
@@ -18,5 +18,7 @@ Require-Bundle: org.nuxeo.runtime,
 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
diff --git a/3rdparty/nuxeo/nuxeo-platform-collectionspace/src/main/resources/OSGI-INF/querymodel-contrib.xml b/3rdparty/nuxeo/nuxeo-platform-collectionspace/src/main/resources/OSGI-INF/querymodel-contrib.xml
new file mode 100644 (file)
index 0000000..ecbed6c
--- /dev/null
@@ -0,0 +1,21 @@
+<?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
index ca01cc5eefd3839fa00c69331a13cb1ff7c33711..f0e54a5c12928b74479fe61278ceb962275f95c6 100644 (file)
@@ -142,9 +142,9 @@ public class AcquisitionDocumentModelHandler
     }
 
     @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
     }
 
index b2d93487667ca11b124a4a0d5210ca151cbf41ea..1f763a4bde9d74e130c374e3dfd7732c795322f7 100644 (file)
@@ -143,9 +143,9 @@ public class CollectionObjectDocumentModelHandler
      * @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
     }
 
index 847055dbf575c6bca64fa4daff469215ab08fde7..322c40bbe8ba54aff25e8583e9c00cd73626473b 100644 (file)
@@ -68,7 +68,7 @@ public abstract class AbstractMultipartDocumentHandlerImpl<T, TL, WT, WTL>
             throws Exception;
 
     @Override
-    public abstract void fillAllParts(DocumentWrapper<WT> wrapDoc)
+    public abstract void fillAllParts(DocumentWrapper<WT> wrapDoc, Action action)
             throws Exception;
 
     @Override
index 2a84a045ffed55c7300ce2552c28d7acb69fa130..7617e7c68d60ff2150b7f7fed4b8b47f747bc30a 100644 (file)
@@ -17,6 +17,8 @@
  */
 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
@@ -45,7 +47,8 @@ public interface MultipartDocumentHandler<T, TL, WT, WTL>
      * 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
diff --git a/services/common/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityItemJAXBSchema.java b/services/common/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityItemJAXBSchema.java
new file mode 100644 (file)
index 0000000..8b71d64
--- /dev/null
@@ -0,0 +1,39 @@
+/**\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
diff --git a/services/common/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityItemListItemJAXBSchema.java b/services/common/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityItemListItemJAXBSchema.java
new file mode 100644 (file)
index 0000000..f9ccecc
--- /dev/null
@@ -0,0 +1,32 @@
+/**\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
diff --git a/services/common/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityJAXBSchema.java b/services/common/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityJAXBSchema.java
new file mode 100644 (file)
index 0000000..456ea65
--- /dev/null
@@ -0,0 +1,38 @@
+/**\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
diff --git a/services/common/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityListItemJAXBSchema.java b/services/common/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityListItemJAXBSchema.java
new file mode 100644 (file)
index 0000000..b02c59a
--- /dev/null
@@ -0,0 +1,33 @@
+/**\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
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
new file mode 100644 (file)
index 0000000..a3df7b5
--- /dev/null
@@ -0,0 +1,105 @@
+/**
+ *  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();
+    }
+
+}
+
diff --git a/services/common/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java b/services/common/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java
new file mode 100644 (file)
index 0000000..3901cc4
--- /dev/null
@@ -0,0 +1,126 @@
+/**
+ *  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);
+    }
+
+}
+
index b88b4d85e9f18a5f80c024545d75cdfa43dce234..a99dec8594707e16d26ce5da0e6405175c672cfd 100644 (file)
@@ -30,6 +30,7 @@ import org.collectionspace.services.common.context.ServiceContext;
 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;
@@ -75,7 +76,7 @@ public abstract class DocumentModelHandler<T, TL>
     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 
@@ -87,7 +88,7 @@ public abstract class DocumentModelHandler<T, TL>
     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
@@ -110,7 +111,7 @@ public abstract class DocumentModelHandler<T, TL>
     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;
index 14bfe0cce5b1178ea4118969b40113ba632fff75..25efd1c35bd9f740abce1aff4c44989de223bbfb 100644 (file)
@@ -42,6 +42,7 @@ import org.collectionspace.services.common.document.BadRequestException;
 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;
 
@@ -171,7 +172,7 @@ public abstract class RemoteDocumentModelHandlerImpl<T, TL>
      * @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
@@ -199,11 +200,11 @@ public abstract class RemoteDocumentModelHandlerImpl<T, TL>
             }
             
             //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
 
     }
@@ -215,7 +216,7 @@ public abstract class RemoteDocumentModelHandlerImpl<T, TL>
      * @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);
         
@@ -229,11 +230,25 @@ public abstract class RemoteDocumentModelHandlerImpl<T, TL>
                 //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
index 4685928db4b2bfa7e6985ae74130d79cba8d0ab1..9ebc7cd57bc197bd032cb7e6ffe41538064026dc 100644 (file)
@@ -65,7 +65,8 @@ public abstract class RemoteSubItemDocumentModelHandlerImpl<T, TL> extends
      * @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
index dafee918147f57d62ab2164f25660f8b306dfcb2..b3d0ced6970109167fbbcc9a5c7acf442ad1ae76 100644 (file)
@@ -139,11 +139,11 @@ public class RelationDocumentModelHandler
 
     /* (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.
index e7601154375b0ee58236b45716a042a28e50e9fa..4171bb9dac515fec3ba2a691961b920f5f27eda5 100644 (file)
@@ -12,7 +12,8 @@
       <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>
@@ -81,7 +95,7 @@
         <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>
index 09bf431f4951e4e50c43cfe5c1cee1e2ea67850d..0f920f11170ff2cadea4a37050a81689dc4b3608 100644 (file)
@@ -22,7 +22,7 @@
 
                <!--  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"/>
index b564c9fb50002239414c612648855aa83d68eeac..ec6c338abcee0de864bef8a87e03f4a61c8ecd5a 100644 (file)
@@ -7,7 +7,7 @@ import javax.ws.rs.core.MediaType;
 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
@@ -43,12 +43,12 @@ public class VocabularyClientUtils {
 \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
@@ -74,8 +74,8 @@ public class VocabularyClientUtils {
        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
@@ -85,12 +85,12 @@ public class VocabularyClientUtils {
        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
index 01c402e22e90c146158b57c8eb2dac18fe9c5ae3..e47ff29f7f84ed0bd63f2bf3c5b3b6144b4b363e 100644 (file)
@@ -29,7 +29,7 @@ import java.util.Map;
 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;
@@ -69,7 +69,7 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl {
     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>();
@@ -157,7 +157,7 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl {
         dependsOnMethods = {"create"})
     public void createItem(String testName) {
 
-        if (logger.isDebugEnabled()) {
+        if (null!=testName && logger.isDebugEnabled()) {
             logger.debug(testBanner(testName, CLASS_NAME));
         }
         // Perform setup.
@@ -166,8 +166,8 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl {
         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);
 
@@ -175,7 +175,7 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl {
         // for additional tests below.
         if (knownItemResourceId == null){
             knownItemResourceId = newID;
-            if (logger.isDebugEnabled()) {
+            if (null!=testName && logger.isDebugEnabled()) {
                 logger.debug(testName + ": knownItemResourceId=" + knownItemResourceId);
             }
         }
@@ -192,10 +192,11 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl {
         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);
             }
         }
     }
@@ -257,8 +258,8 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl {
         // 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() );
@@ -267,12 +268,12 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl {
        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);
        }
     }
@@ -514,7 +515,7 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl {
         VocabularyitemsCommon vocabularyItem = (VocabularyitemsCommon) extractPart(input,
                 client.getItemCommonPartName(), VocabularyitemsCommon.class);
         Assert.assertNotNull(vocabularyItem);
-        Assert.assertEquals(vocabularyItem.getInVocabulary(), knownResourceId);
+        Assert.assertEquals(vocabularyItem.getInAuthority(), knownResourceId);
     }
 
     // Failure outcomes
@@ -730,11 +731,12 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl {
         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;
@@ -824,7 +826,7 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl {
     }
 
     @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
-        dependsOnMethods = {"readItem", "update"})
+        dependsOnMethods = {"readItem", "update", "verifyIgnoredUpdateWithInAuthority"})
     public void updateItem(String testName) throws Exception {
 
         if (logger.isDebugEnabled()) {
@@ -888,6 +890,70 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl {
                 "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.
@@ -1040,8 +1106,8 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl {
         // 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),
@@ -1066,7 +1132,7 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl {
     // 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()) {
@@ -1092,7 +1158,7 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl {
 
    @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()) {
index 96e8d13463e45782a09f7cbcbfd93adc5e20de48..3a41051d3eec12d8bf4debe98fe6af10f49b3696 100644 (file)
@@ -88,7 +88,7 @@ public class VocabularyBaseImport {
         }
         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);
         }
index 39114cfb105fefb535c4d6fa4981f7a821d78fb0..bb222abc2ee8241a258be1c432b6c5c658b8156c 100644 (file)
     <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>
diff --git a/services/vocabulary/jaxb/src/main/java/org/collectionspace/services/VocabularyItemJAXBSchema.java b/services/vocabulary/jaxb/src/main/java/org/collectionspace/services/VocabularyItemJAXBSchema.java
deleted file mode 100644 (file)
index ff9c9bd..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-/**\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
diff --git a/services/vocabulary/jaxb/src/main/java/org/collectionspace/services/VocabularyItemListItemJAXBSchema.java b/services/vocabulary/jaxb/src/main/java/org/collectionspace/services/VocabularyItemListItemJAXBSchema.java
deleted file mode 100644 (file)
index 204a487..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-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
diff --git a/services/vocabulary/jaxb/src/main/java/org/collectionspace/services/VocabularyJAXBSchema.java b/services/vocabulary/jaxb/src/main/java/org/collectionspace/services/VocabularyJAXBSchema.java
deleted file mode 100644 (file)
index 9f3c8f2..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-/**\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
diff --git a/services/vocabulary/jaxb/src/main/java/org/collectionspace/services/VocabularyListItemJAXBSchema.java b/services/vocabulary/jaxb/src/main/java/org/collectionspace/services/VocabularyListItemJAXBSchema.java
deleted file mode 100644 (file)
index 38dbf48..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-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
index e9fb1a95f988b39aa1e8a70d6ad496875db505a9..77211d048303f6ce117ab8a2c25bc811b048cfac 100644 (file)
 <!-- 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">
index 522b3aca3cd952de8b62b82f60806bc94c0dddbd..6f285fb76dbeee8f9b1efbb45469adff210fc405 100644 (file)
@@ -39,8 +39,8 @@ import javax.ws.rs.core.Response;
 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;
@@ -69,9 +69,11 @@ public class VocabularyResource extends
 
     /** 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);
@@ -139,8 +141,8 @@ public class VocabularyResource extends
        
        docHandler = (VocabularyItemDocumentModelHandler)createDocumentHandler(ctx,
                        ctx.getCommonPartLabel(getItemServiceName()),
-                       VocabularyitemsCommon.class);           
-        docHandler.setInVocabulary(inVocabulary);
+                       VocabularyitemsCommon.class);   
+        docHandler.setInAuthority(inVocabulary);
 
         return docHandler;
     }
@@ -257,8 +259,8 @@ public class VocabularyResource extends
             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.
@@ -562,14 +564,14 @@ public class VocabularyResource extends
             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);
@@ -615,8 +617,8 @@ public class VocabularyResource extends
         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);
index 1e5a605d43fdf1d6e3cef05da753520462b50e18..ecb3222d3fd9a7688aae0e7c740edf46ebbcdacb 100644 (file)
@@ -26,15 +26,13 @@ package org.collectionspace.services.vocabulary.nuxeo;
 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;
@@ -48,7 +46,7 @@ import org.slf4j.LoggerFactory;
  * $LastChangedDate: $
  */
 public class VocabularyDocumentModelHandler
-        extends RemoteDocumentModelHandlerImpl<VocabulariesCommon, VocabulariesCommonList> {
+               extends AuthorityDocumentModelHandler<VocabulariesCommon, VocabulariesCommonList> {
 
     /** The logger. */
     private final Logger logger = LoggerFactory.getLogger(VocabularyDocumentModelHandler.class);
@@ -56,65 +54,65 @@ public class VocabularyDocumentModelHandler
      * 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)
@@ -122,20 +120,21 @@ public class VocabularyDocumentModelHandler
     @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);
index 9609083b39a43754047a7d23a803b253c1a8d11f..d759a2e681311dac891089f96eabd65b5687f495 100644 (file)
@@ -25,11 +25,14 @@ package org.collectionspace.services.vocabulary.nuxeo;
 
 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;
@@ -46,84 +49,15 @@ import org.slf4j.LoggerFactory;
  * $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()) {
@@ -131,12 +65,12 @@ public class VocabularyItemDocumentModelHandler
                        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);
                }