]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-1349, 1422, 1428, 1429, 1469, 1465, 1466, 1468, 1470, 1473: Adding pagination...
authorRichard Millet <richard.millet@berkeley.edu>
Wed, 28 Apr 2010 08:50:27 +0000 (08:50 +0000)
committerRichard Millet <richard.millet@berkeley.edu>
Wed, 28 Apr 2010 08:50:27 +0000 (08:50 +0000)
Passes *ALL* current tests and merged with the latest set of sources.

43 files changed:
services/acquisition/jaxb/pom.xml
services/acquisition/jaxb/src/main/resources/acquisitions_common.xsd
services/acquisition/service/src/main/java/org/collectionspace/services/acquisition/nuxeo/AcquisitionDocumentModelHandler.java
services/collectionobject/jaxb/.classpath
services/collectionobject/jaxb/.project
services/collectionobject/jaxb/.settings/org.eclipse.jdt.core.prefs
services/collectionobject/jaxb/pom.xml
services/collectionobject/jaxb/src/main/resources/collectionobjects_common.xsd
services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/nuxeo/CollectionObjectDocumentModelHandler.java
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteDocumentModelHandlerImpl.java
services/contact/jaxb/pom.xml
services/contact/jaxb/src/main/resources/contacts-common.xsd
services/contact/service/src/main/java/org/collectionspace/services/contact/nuxeo/ContactDocumentModelHandler.java
services/dimension/jaxb/pom.xml
services/dimension/jaxb/src/main/resources/dimensions-common.xsd
services/dimension/service/src/main/java/org/collectionspace/services/dimension/nuxeo/DimensionDocumentModelHandler.java
services/intake/jaxb/pom.xml
services/intake/jaxb/src/main/resources/intakes-common.xsd
services/intake/service/src/main/java/org/collectionspace/services/intake/nuxeo/IntakeDocumentModelHandler.java
services/jaxb/src/main/resources/relations_common.xsd
services/loanin/jaxb/pom.xml
services/loanin/jaxb/src/main/resources/loansin-common.xsd
services/loanin/service/src/main/java/org/collectionspace/services/loanin/nuxeo/LoaninDocumentModelHandler.java
services/loanout/jaxb/pom.xml
services/loanout/jaxb/src/main/resources/loansout-common.xsd
services/loanout/service/src/main/java/org/collectionspace/services/loanout/nuxeo/LoanoutDocumentModelHandler.java
services/organization/jaxb/pom.xml
services/organization/jaxb/src/main/resources/organization_common.xsd
services/organization/jaxb/src/main/resources/orgauthority_common.xsd
services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrgAuthorityDocumentModelHandler.java
services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrganizationDocumentModelHandler.java
services/person/jaxb/pom.xml
services/person/jaxb/src/main/resources/person_common.xsd
services/person/jaxb/src/main/resources/personauthority_common.xsd
services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonAuthorityDocumentModelHandler.java
services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonDocumentModelHandler.java
services/relation/service/src/main/java/org/collectionspace/services/relation/nuxeo/RelationDocumentModelHandler.java
services/vocabulary/jaxb/.classpath
services/vocabulary/jaxb/pom.xml
services/vocabulary/jaxb/src/main/resources/vocabulary_common.xsd
services/vocabulary/jaxb/src/main/resources/vocabularyitem_common.xsd
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 6951c50220b32d0d0c8315f8f800ab04edd7f65e..b9c6e686736cf618707c63bd5a98f92cf23703a1 100644 (file)
             <groupId>org.jvnet.jaxb2_commons</groupId>
             <artifactId>runtime</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.collectionspace.services</groupId>
+            <artifactId>org.collectionspace.services.jaxb</artifactId>
+            <version>${project.version}</version>
+        </dependency>        
     </dependencies>
     
     <build>
index 04fd09a6e218b8535fd276a08a4ff2b7671cc042..db4f19f547edb909dc741cd9b5a6427c0d2059c0 100644 (file)
 
 <xs:schema 
   xmlns:xs="http://www.w3.org/2001/XMLSchema"
+  xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
+  jaxb:version="1.0" elementFormDefault="unqualified"
   xmlns:ns="http://collectionspace.org/services/acquisition"
   xmlns="http://collectionspace.org/services/acquisition"
   targetNamespace="http://collectionspace.org/services/acquisition"
-  version="0.1"
->
+  version="0.1">
 
 
 <!--
         </xs:sequence>
     </xs:complexType>
     
+    <!-- This is the base class for paginated lists -->
+    <xs:complexType name="abstractCommonList">
+        <xs:annotation>
+            <xs:appinfo>
+                <jaxb:class ref="org.collectionspace.services.jaxb.AbstractCommonList"/>
+            </xs:appinfo>
+        </xs:annotation>
+    </xs:complexType>
+
     <!-- acquisition records, as in nuxeo repository -->
     <xs:element name="acquisitions-common-list">
         <xs:complexType>
-            <xs:sequence>
-                <xs:element name="acquisition-list-item" maxOccurs="unbounded">
-                    <xs:complexType>
-                        <xs:sequence>
-                            <xs:element name="acquisitionReferenceNumber" type="xs:string"
-                                minOccurs="1" />
-                            <xs:element name="acquisitionSources" type="acquisitionSourceList"
-                                minOccurs="1" />
-                            <!-- uri to retrive acquisition details -->
-                            <xs:element name="uri" type="xs:anyURI"
-                                minOccurs="1" />
-                            <xs:element name="csid" type="xs:string"
-                                minOccurs="1" />
-                        </xs:sequence>
-                    </xs:complexType>
-                </xs:element>
-            </xs:sequence>
+            <xs:complexContent>
+                <xs:extension base="abstractCommonList">                    
+                    <xs:sequence>
+                        <xs:element name="acquisition-list-item" maxOccurs="unbounded">
+                            <xs:complexType>
+                                <xs:sequence>
+                                    <xs:element name="acquisitionReferenceNumber" type="xs:string"
+                                        minOccurs="1" />
+                                    <xs:element name="acquisitionSources" type="acquisitionSourceList"
+                                        minOccurs="1" />
+                                    <!-- uri to retrive acquisition details -->
+                                    <xs:element name="uri" type="xs:anyURI"
+                                        minOccurs="1" />
+                                    <xs:element name="csid" type="xs:string"
+                                        minOccurs="1" />
+                                </xs:sequence>
+                            </xs:complexType>
+                        </xs:element>
+                    </xs:sequence>
+                </xs:extension>
+            </xs:complexContent>                    
         </xs:complexType>
     </xs:element>
     
index df4958b0a64f340eecef70dd0bc130fd95e347f4..ca01cc5eefd3839fa00c69331a13cb1ff7c33711 100644 (file)
@@ -108,13 +108,9 @@ public class AcquisitionDocumentModelHandler
 
     @Override
     public AcquisitionsCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
-        DocumentModelList docList = wrapDoc.getWrappedObject();
-        AcquisitionsCommonList coList = new AcquisitionsCommonList();
+        AcquisitionsCommonList coList = this.extractPagingInfo(new AcquisitionsCommonList(), wrapDoc);
         List<AcquisitionsCommonList.AcquisitionListItem> list = coList.getAcquisitionListItem();
-
-        //FIXME: iterating over a long list of documents is not a long term
-        //strategy...need to change to more efficient iterating in future
-        Iterator<DocumentModel> iter = docList.iterator();
+        Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
         while (iter.hasNext()) {
             DocumentModel docModel = iter.next();
             AcquisitionListItem listItem = new AcquisitionListItem();
index 557f8a4e07f9616882b7ea73418b64a2bb068cb6..8f8348dc2d079c9aef46f7f69e5da779bc3c4590 100644 (file)
@@ -6,5 +6,6 @@
        <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>\r
        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>\r
        <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>\r
+       <classpathentry combineaccessrules="false" kind="src" path="/org.collectionspace.services.jaxb"/>\r
        <classpathentry kind="output" path="target/classes"/>\r
 </classpath>\r
index d210da4667d2202576272ec9d2308c908a0e7609..6079d9391b0dfc137f15ea62941accf5c702740a 100644 (file)
@@ -3,6 +3,7 @@
        <name>org.collectionspace.services.collectionobject.jaxb</name>\r
        <comment></comment>\r
        <projects>\r
+               <project>org.collectionspace.services.jaxb</project>\r
        </projects>\r
        <buildSpec>\r
                <buildCommand>\r
index 25d00994a024f1ee34666b41ed45dc9b860187b5..7d255d4d32b05b1d1fdf6e13cef46fc4d6f8482d 100644 (file)
@@ -1,5 +1,6 @@
-#Wed Feb 10 17:35:27 PST 2010\r
+#Tue Apr 27 13:04:23 PDT 2010\r
 eclipse.preferences.version=1\r
 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6\r
 org.eclipse.jdt.core.compiler.compliance=1.6\r
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning\r
 org.eclipse.jdt.core.compiler.source=1.6\r
index 1417f3a158d3b0103c114dee97af176df4e28eee..da8c113b8c6d3a13d7fa31b7f80d34ddc812b9de 100644 (file)
             <groupId>org.jvnet.jaxb2_commons</groupId>
             <artifactId>runtime</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.collectionspace.services</groupId>
+            <artifactId>org.collectionspace.services.jaxb</artifactId>
+            <version>${project.version}</version>
+        </dependency>        
     </dependencies>
 
     <build>
index 9cec1b41a4915bbaa7421b585c401853409e1175..20fbbaed84ae674f0a2687578bd246707398984e 100644 (file)
 
 <xs:schema 
   xmlns:xs="http://www.w3.org/2001/XMLSchema"
+  xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
+  jaxb:version="1.0" elementFormDefault="unqualified"
   xmlns:ns="http://collectionspace.org/services/collectionobject"
   xmlns="http://collectionspace.org/services/collectionobject"
   targetNamespace="http://collectionspace.org/services/collectionobject"
-  version="0.1"
->
-
+  version="0.1">
+            
 <!--
     Avoid XmlRootElement nightmare:
     See http://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html
         </xs:sequence>
     </xs:complexType>
     
-    <!-- collection objects as in nuxeo repository -->
+    <!-- This is the base class for paginated lists -->
+    <xs:complexType name="abstractCommonList">
+        <xs:annotation>
+            <xs:appinfo>
+                <jaxb:class ref="org.collectionspace.services.jaxb.AbstractCommonList"/>
+            </xs:appinfo>
+        </xs:annotation>
+    </xs:complexType>
+    
     <xs:element name="collectionobjects-common-list">
         <xs:complexType>
-            <xs:sequence>
-                <xs:element name="collection-object-list-item" maxOccurs="unbounded">
-                    <xs:complexType>
-                        <xs:sequence>
-                            <xs:element name="objectNumber" type="xs:string"
-                                minOccurs="1" />
-                            <xs:element name="title" type="xs:string"
-                                minOccurs="1" />
-                            <!-- uri to retrive collection object details -->
-                            <xs:element name="uri" type="xs:anyURI"
-                                minOccurs="1" />
-                            <xs:element name="csid" type="xs:string"
-                                minOccurs="1" />
-                        </xs:sequence>
-                    </xs:complexType>
-                </xs:element>
-            </xs:sequence>
+            <xs:complexContent>
+                <xs:extension base="abstractCommonList">
+                    <xs:sequence>
+                        <xs:element name="collection-object-list-item" maxOccurs="unbounded">
+                            <xs:complexType>
+                                <xs:sequence>
+                                    <xs:element name="objectNumber" type="xs:string"
+                                        minOccurs="1" />
+                                    <xs:element name="title" type="xs:string"
+                                        minOccurs="1" />
+                                    <!-- uri to retrive collection object details -->
+                                    <xs:element name="uri" type="xs:anyURI"
+                                        minOccurs="1" />
+                                    <xs:element name="csid" type="xs:string"
+                                        minOccurs="1" />
+                                </xs:sequence>
+                            </xs:complexType>
+                        </xs:element>
+                    </xs:sequence>
+                </xs:extension>
+            </xs:complexContent>        
         </xs:complexType>
     </xs:element>
-    
+        
 </xs:schema>
 
index 3194e3937bb0a1b95e853170762b89073e9497cb..b2d93487667ca11b124a4a0d5210ca151cbf41ea 100644 (file)
@@ -26,6 +26,8 @@ package org.collectionspace.services.collectionobject.nuxeo;
 import java.util.Iterator;
 import java.util.List;
 
+//import org.collectionspace.services.jaxb.AbstractCommonList;
+
 import org.collectionspace.services.CollectionObjectListItemJAXBSchema;
 import org.collectionspace.services.collectionobject.CollectionobjectsCommon;
 import org.collectionspace.services.collectionobject.CollectionobjectsCommonList;
@@ -47,6 +49,7 @@ import org.slf4j.LoggerFactory;
 public class CollectionObjectDocumentModelHandler
         extends RemoteDocumentModelHandlerImpl<CollectionobjectsCommon, CollectionobjectsCommonList> {
 
+    /** The logger. */
     private final Logger logger = LoggerFactory.getLogger(CollectionObjectDocumentModelHandler.class);
     /**
      * collectionObject is used to stash JAXB object to use when handle is called
@@ -86,32 +89,40 @@ public class CollectionObjectDocumentModelHandler
         return collectionObjectList;
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#setCommonPartList(java.lang.Object)
+     */
     @Override
     public void setCommonPartList(CollectionobjectsCommonList collectionObjectList) {
         this.collectionObjectList = collectionObjectList;
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPart(org.collectionspace.services.common.document.DocumentWrapper)
+     */
     @Override
     public CollectionobjectsCommon 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(CollectionobjectsCommon co, 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 CollectionobjectsCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
-        DocumentModelList docList = wrapDoc.getWrappedObject();
-
-        CollectionobjectsCommonList coList = new CollectionobjectsCommonList();
+        CollectionobjectsCommonList coList = this.extractPagingInfo(new CollectionobjectsCommonList(),
+                       wrapDoc);
         List<CollectionobjectsCommonList.CollectionObjectListItem> list = coList.getCollectionObjectListItem();
-
-        //FIXME: iterating over a long list of documents is not a long term
-        //strategy...need to change to more efficient iterating in future
-        Iterator<DocumentModel> iter = docList.iterator();
+        Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
         while(iter.hasNext()){
             DocumentModel docModel = iter.next();
             CollectionObjectListItem coListItem = new CollectionObjectListItem();
@@ -128,6 +139,9 @@ public class CollectionObjectDocumentModelHandler
         return coList;
     }
 
+    /* (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 {
 
@@ -135,6 +149,12 @@ public class CollectionObjectDocumentModelHandler
         fillDublinCoreObject(wrapDoc); //dublincore might not be needed in future
     }
 
+    /**
+     * Fill dublin core object.
+     *
+     * @param wrapDoc the wrap doc
+     * @throws Exception the exception
+     */
     private void fillDublinCoreObject(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
         DocumentModel docModel = wrapDoc.getWrappedObject();
         //FIXME property setter should be dynamically set using schema inspection
@@ -143,6 +163,9 @@ public class CollectionObjectDocumentModelHandler
         docModel.setPropertyValue("dublincore:title", CollectionObjectConstants.NUXEO_DC_TITLE);
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.common.document.AbstractMultipartDocumentHandlerImpl#getQProperty(java.lang.String)
+     */
     @Override
     public String getQProperty(String prop) {
         return CollectionObjectConstants.NUXEO_SCHEMA_NAME + ":" + prop;
index 4ea6e9309204242703d49b64458d00141d1c7802..dbcb98eb51e704de76690a508100fe85ea536b83 100644 (file)
@@ -34,17 +34,21 @@ import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 
+import org.collectionspace.services.jaxb.AbstractCommonList;
 import org.collectionspace.services.common.authorityref.AuthorityRefList;
 import org.collectionspace.services.common.context.MultipartServiceContext;
 import org.collectionspace.services.common.context.ServiceContext;
 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.service.ObjectPartType;
 import org.collectionspace.services.common.vocabulary.RefNameUtils;
+//import org.collectionspace.services.vocabulary.VocabulariesCommonList;
 import org.jboss.resteasy.plugins.providers.multipart.InputPart;
 import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
 import org.nuxeo.ecm.core.api.DocumentModel;
+import org.nuxeo.ecm.core.api.DocumentModelList;
 import org.nuxeo.ecm.core.api.model.PropertyException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -98,6 +102,32 @@ public abstract class RemoteDocumentModelHandlerImpl<T, TL>
                ctx.addOutputPart(schema, doc, partMeta.getContent().getContentType());
     }
     
+    
+    /**
+     * Extract paging info.
+     *
+     * @param commonsList the commons list
+     * @return the tL
+     * @throws Exception the exception
+     */
+    protected TL extractPagingInfo(TL theCommonList, DocumentWrapper<DocumentModelList> wrapDoc)
+       throws Exception {
+       AbstractCommonList commonList = (AbstractCommonList)theCommonList;
+       
+       DocumentFilter docFilter = this.getDocumentFilter();
+       long pageSize = docFilter.getPageSize();
+       long pageNum = docFilter.getOffset() / pageSize;
+       // set the page size and page numer
+       commonList.setPageNum(pageNum);
+       commonList.setPageSize(pageSize);
+       // set the total result size
+       DocumentModelList docList = wrapDoc.getWrappedObject();
+       commonList.setTotalItems(docList.totalSize());
+       
+       return (TL)commonList;
+    }
+    
+    
        @Override
        public void extractAllParts(DocumentWrapper<DocumentModel> wrapDoc)
                        throws Exception {
index 1f3efc861fee7a79441c19439167d2bfa8f4617c..9449813d625bea044cc50f1921007a6e9c8f162f 100644 (file)
             <groupId>org.jvnet.jaxb2_commons</groupId>
             <artifactId>runtime</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.collectionspace.services</groupId>
+            <artifactId>org.collectionspace.services.jaxb</artifactId>
+            <version>${project.version}</version>
+        </dependency>        
     </dependencies>
     
     <build>
index dd669e7d1e4a8d939b7c0ba4d5ce8529ec0101cd..c1913871b06fbb0bb86d06534c3e6d47e83976a4 100644 (file)
@@ -13,6 +13,8 @@
 
 <xs:schema 
   xmlns:xs="http://www.w3.org/2001/XMLSchema"
+  xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
+  jaxb:version="1.0" elementFormDefault="unqualified"
   xmlns:ns="http://collectionspace.org/services/contact"
   xmlns="http://collectionspace.org/services/contact"
   targetNamespace="http://collectionspace.org/services/contact"
         </xs:complexType>
     </xs:element>
     
-    <!-- contact records, as in nuxeo repository -->
+    <!-- This is the base class for paginated lists -->
+    <xs:complexType name="abstractCommonList">
+        <xs:annotation>
+            <xs:appinfo>
+                <jaxb:class ref="org.collectionspace.services.jaxb.AbstractCommonList"/>
+            </xs:appinfo>
+        </xs:annotation>
+    </xs:complexType>
+    
+    <!-- contact records, as in Nuxeo repository -->
     <xs:element name="contacts-common-list">
         <xs:complexType>
-            <xs:sequence>
-                <xs:element name="contact-list-item" maxOccurs="unbounded">
-                    <xs:complexType>
-                        <xs:sequence>
-                            <xs:element name="addressPlace" type="xs:string"
-                                minOccurs="1" />
-                            <!-- uri to retrive contact details -->
-                            <xs:element name="uri" type="xs:anyURI"
-                                minOccurs="1" />
-                            <xs:element name="csid" type="xs:string"
-                                minOccurs="1" />
-                        </xs:sequence>
-                    </xs:complexType>
-                </xs:element>
-            </xs:sequence>
+            <xs:complexContent>
+                <xs:extension base="abstractCommonList">                    
+                    <xs:sequence>
+                        <xs:element name="contact-list-item" maxOccurs="unbounded">
+                            <xs:complexType>
+                                <xs:sequence>
+                                    <xs:element name="addressPlace" type="xs:string"
+                                        minOccurs="1" />
+                                    <!-- uri to retrive contact details -->
+                                    <xs:element name="uri" type="xs:anyURI"
+                                        minOccurs="1" />
+                                    <xs:element name="csid" type="xs:string"
+                                        minOccurs="1" />
+                                </xs:sequence>
+                            </xs:complexType>
+                        </xs:element>
+                    </xs:sequence>
+                </xs:extension>
+            </xs:complexContent>                    
         </xs:complexType>
     </xs:element>
     
index 0149e4cfd053648e55211f492b6793bb757d8db5..90ad4e972c7f2ba2240661d19805aae6933e47b5 100644 (file)
@@ -41,99 +41,119 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * ContactDocumentModelHandler
- *
- * $LastChangedRevision: $
- * $LastChangedDate: $
+ * The Class ContactDocumentModelHandler.
  */
 public class ContactDocumentModelHandler
         extends RemoteDocumentModelHandlerImpl<ContactsCommon, ContactsCommonList> {
 
+    /** The logger. */
     private final Logger logger = LoggerFactory.getLogger(ContactDocumentModelHandler.class);
-    /**
-     * contact is used to stash JAXB object to use when handle is called
-     * for Action.CREATE, Action.UPDATE or Action.GET
-     */
+    
+    /** The contact. */
     private ContactsCommon contact;
-    /**
-     * contactList is stashed when handle is called
-     * for ACTION.GET_ALL
-     */
+    
+    /** The contact list. */
     private ContactsCommonList contactList;
 
+    /** The in authority. */
     private String inAuthority;
 
+    /**
+     * Gets the in authority.
+     *
+     * @return the in authority
+     */
     public String getInAuthority() {
         return inAuthority;
     }
 
+    /**
+     * Sets the in authority.
+     *
+     * @param inAuthority the new in authority
+     */
     public void setInAuthority(String inAuthority) {
         this.inAuthority = inAuthority;
     }
 
+    /** The in item. */
     private String inItem;
 
+    /**
+     * Gets the in item.
+     *
+     * @return the in item
+     */
     public String getInItem() {
         return inItem;
     }
 
+    /**
+     * Sets the in item.
+     *
+     * @param inItem the new in item
+     */
     public void setInItem(String inItem) {
         this.inItem = inItem;
     }
 
-    /**
-     * getCommonPart get associated contact
-     * @return
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#getCommonPart()
      */
     @Override
     public ContactsCommon getCommonPart() {
         return contact;
     }
 
-    /**
-     * setCommonPart set associated contact
-     * @param contact
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#setCommonPart(java.lang.Object)
      */
     @Override
     public void setCommonPart(ContactsCommon contact) {
         this.contact = contact;
     }
 
-    /**
-     * getCommonPartList get associated contact (for index/GET_ALL)
-     * @return
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#getCommonPartList()
      */
     @Override
     public ContactsCommonList getCommonPartList() {
         return contactList;
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#setCommonPartList(java.lang.Object)
+     */
     @Override
     public void setCommonPartList(ContactsCommonList contactList) {
         this.contactList = contactList;
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPart(org.collectionspace.services.common.document.DocumentWrapper)
+     */
     @Override
     public ContactsCommon 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(ContactsCommon contactObject, 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 ContactsCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
-        DocumentModelList docList = wrapDoc.getWrappedObject();
-
-        ContactsCommonList coList = new ContactsCommonList();
+        ContactsCommonList coList = extractPagingInfo(new ContactsCommonList(), wrapDoc);
         List<ContactsCommonList.ContactListItem> list = coList.getContactListItem();
-
-        //FIXME: iterating over a long list of documents is not a long term
-        //strategy...need to change to more efficient iterating in future
-        Iterator<DocumentModel> iter = docList.iterator();
+        Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
         while(iter.hasNext()){
             DocumentModel docModel = iter.next();
             ContactListItem clistItem = new ContactListItem();
@@ -151,10 +171,8 @@ public class ContactDocumentModelHandler
         return coList;
     }
 
-    /**
-     * getQProperty converts the given property to qualified schema property
-     * @param prop
-     * @return
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.common.document.AbstractMultipartDocumentHandlerImpl#getQProperty(java.lang.String)
      */
     @Override
     public String getQProperty(String prop) {
index 29ed8baf50da386c5c0a3774fb4a37ae5afb2ac6..ccd5849d4f94c22926f54e3a94ecc74ae4bd680f 100644 (file)
             <groupId>org.jvnet.jaxb2_commons</groupId>
             <artifactId>runtime</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.collectionspace.services</groupId>
+            <artifactId>org.collectionspace.services.jaxb</artifactId>
+            <version>${project.version}</version>
+        </dependency>        
     </dependencies>
     
     <build>
index 5d5c25357f9a4781d3ebd1fe1848456d590deb07..ddbdb0caee78b3372c8f3e1ec2c5add17916d4bf 100644 (file)
 
 <xs:schema 
   xmlns:xs="http://www.w3.org/2001/XMLSchema"
+  xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
+  jaxb:version="1.0" elementFormDefault="unqualified"
   xmlns:ns="http://collectionspace.org/services/dimension"
   xmlns="http://collectionspace.org/services/dimension"
   targetNamespace="http://collectionspace.org/services/dimension"
-  version="0.1"
->
+  version="0.1">
 
 <!--
     Avoid XmlRootElement nightmare:
         </xs:complexType>
     </xs:element>
     
+    <!-- This is the base class for paginated lists -->
+    <xs:complexType name="abstractCommonList">
+        <xs:annotation>
+            <xs:appinfo>
+                <jaxb:class ref="org.collectionspace.services.jaxb.AbstractCommonList"/>
+            </xs:appinfo>
+        </xs:annotation>
+    </xs:complexType>
+    
     <!-- dimension records, as in nuxeo repository -->
     <xs:element name="dimensions-common-list">
         <xs:complexType>
-            <xs:sequence>
-                <xs:element name="dimension-list-item" maxOccurs="unbounded">
-                    <xs:complexType>
-                        <xs:sequence>
-                            <xs:element name="dimension" type="xs:string"
-                                minOccurs="1" />
-                            <!-- uri to retrive dimension details -->
-                            <xs:element name="uri" type="xs:anyURI"
-                                minOccurs="1" />
-                            <xs:element name="csid" type="xs:string"
-                                minOccurs="1" />
-                        </xs:sequence>
-                    </xs:complexType>
-                </xs:element>
-            </xs:sequence>
+            <xs:complexContent>
+                <xs:extension base="abstractCommonList">                    
+                    <xs:sequence>
+                        <xs:element name="dimension-list-item" maxOccurs="unbounded">
+                            <xs:complexType>
+                                <xs:sequence>
+                                    <xs:element name="dimension" type="xs:string"
+                                        minOccurs="1" />
+                                    <!-- uri to retrive dimension details -->
+                                    <xs:element name="uri" type="xs:anyURI"
+                                        minOccurs="1" />
+                                    <xs:element name="csid" type="xs:string"
+                                        minOccurs="1" />
+                                </xs:sequence>
+                            </xs:complexType>
+                        </xs:element>
+                    </xs:sequence>
+                </xs:extension>
+            </xs:complexContent>                    
         </xs:complexType>
     </xs:element>
     
index cf36a1868e59fec27d8d4ef36f277b2fb18f23eb..4f2d68c6f1b5bf8cb15bc2ee9371e934a3bae7b3 100644 (file)
@@ -107,14 +107,9 @@ public class DimensionDocumentModelHandler
 
     @Override
     public DimensionsCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
-        DocumentModelList docList = wrapDoc.getWrappedObject();
-
-        DimensionsCommonList coList = new DimensionsCommonList();
+        DimensionsCommonList coList = extractPagingInfo(new DimensionsCommonList(), wrapDoc) ;
         List<DimensionsCommonList.DimensionListItem> list = coList.getDimensionListItem();
-
-        //FIXME: iterating over a long list of documents is not a long term
-        //strategy...need to change to more efficient iterating in future
-        Iterator<DocumentModel> iter = docList.iterator();
+        Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
         while(iter.hasNext()){
             DocumentModel docModel = iter.next();
             DimensionListItem ilistItem = new DimensionListItem();
index 302fc9260c69056899a1f1bc09c5224d5a46fec6..c20ccf711f3d4af16970fb123428045bd34fcfae 100644 (file)
             <groupId>org.jvnet.jaxb2_commons</groupId>
             <artifactId>runtime</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.collectionspace.services</groupId>
+            <artifactId>org.collectionspace.services.jaxb</artifactId>
+            <version>${project.version}</version>
+        </dependency>        
     </dependencies>
     
     <build>
index 1d2c578e70fc4259d687868ffae47b06ef66d391..862d1c8d452bd159fcd36a429481df85c72a0453 100644 (file)
@@ -13,6 +13,8 @@
 
 <xs:schema 
   xmlns:xs="http://www.w3.org/2001/XMLSchema"
+  xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
+  jaxb:version="1.0" elementFormDefault="unqualified"
   xmlns:ns="http://collectionspace.org/services/intake"
   xmlns="http://collectionspace.org/services/intake"
   targetNamespace="http://collectionspace.org/services/intake"
         </xs:complexType>
     </xs:element>
     
+    <!-- This is the base class for paginated lists -->
+    <xs:complexType name="abstractCommonList">
+        <xs:annotation>
+            <xs:appinfo>
+                <jaxb:class ref="org.collectionspace.services.jaxb.AbstractCommonList"/>
+            </xs:appinfo>
+        </xs:annotation>
+    </xs:complexType>
+    
     <!-- intake records, as in nuxeo repository -->
     <xs:element name="intakes-common-list">
         <xs:complexType>
-            <xs:sequence>
-                <xs:element name="intake-list-item" maxOccurs="unbounded">
-                    <xs:complexType>
-                        <xs:sequence>
-                            <xs:element name="entryNumber" type="xs:string"
-                                minOccurs="1" />
-                            <xs:element name="depositor" type="xs:string"
-                                minOccurs="1" />
-                            <!-- uri to retrive intake details -->
-                            <xs:element name="uri" type="xs:anyURI"
-                                minOccurs="1" />
-                            <xs:element name="csid" type="xs:string"
-                                minOccurs="1" />
-                        </xs:sequence>
-                    </xs:complexType>
-                </xs:element>
-            </xs:sequence>
+            <xs:complexContent>
+                <xs:extension base="abstractCommonList">                    
+                    <xs:sequence>
+                        <xs:element name="intake-list-item" maxOccurs="unbounded">
+                            <xs:complexType>
+                                <xs:sequence>
+                                    <xs:element name="entryNumber" type="xs:string"
+                                        minOccurs="1" />
+                                    <xs:element name="depositor" type="xs:string"
+                                        minOccurs="1" />
+                                    <!-- uri to retrive intake details -->
+                                    <xs:element name="uri" type="xs:anyURI"
+                                        minOccurs="1" />
+                                    <xs:element name="csid" type="xs:string"
+                                        minOccurs="1" />
+                                </xs:sequence>
+                            </xs:complexType>
+                        </xs:element>
+                    </xs:sequence>
+                </xs:extension>
+            </xs:complexContent>        
         </xs:complexType>
     </xs:element>
     
index 30107afa31e52a503f839767a37e4303b6c1ccb1..39e77383be2489d7abe62ad03c258623c4775580 100644 (file)
@@ -47,6 +47,7 @@ import org.slf4j.LoggerFactory;
 public class IntakeDocumentModelHandler
         extends RemoteDocumentModelHandlerImpl<IntakesCommon, IntakesCommonList> {
 
+    /** The logger. */
     private final Logger logger = LoggerFactory.getLogger(IntakeDocumentModelHandler.class);
     /**
      * intake is used to stash JAXB object to use when handle is called
@@ -87,32 +88,39 @@ public class IntakeDocumentModelHandler
         return intakeList;
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#setCommonPartList(java.lang.Object)
+     */
     @Override
     public void setCommonPartList(IntakesCommonList intakeList) {
         this.intakeList = intakeList;
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPart(org.collectionspace.services.common.document.DocumentWrapper)
+     */
     @Override
     public IntakesCommon 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(IntakesCommon intakeObject, 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 IntakesCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
-        DocumentModelList docList = wrapDoc.getWrappedObject();
-
-        IntakesCommonList coList = new IntakesCommonList();
+        IntakesCommonList coList = this.extractPagingInfo(new IntakesCommonList(), wrapDoc);
         List<IntakesCommonList.IntakeListItem> list = coList.getIntakeListItem();
-
-        //FIXME: iterating over a long list of documents is not a long term
-        //strategy...need to change to more efficient iterating in future
-        Iterator<DocumentModel> iter = docList.iterator();
+        Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
         while(iter.hasNext()){
             DocumentModel docModel = iter.next();
             IntakeListItem ilistItem = new IntakeListItem();
index 9ab41ebc629a49e71b002bf180e01dbe454f5ae1..f4ff97616914b2aac728bc9dde71fa6dfc67fc64 100644 (file)
 \r
 <xs:schema\r
     xmlns:xs="http://www.w3.org/2001/XMLSchema"\r
+    xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"\r
+    jaxb:version="1.0" elementFormDefault="unqualified"\r
     xmlns="http://collectionspace.org/services/relation"\r
     xmlns:rel="http://collectionspace.org/services/relation"\r
-    targetNamespace="http://collectionspace.org/services/relation"\r
-    >\r
+    targetNamespace="http://collectionspace.org/services/relation">\r
 \r
     <!-- Relation -->\r
     <xs:element name="relations_common">\r
         </xs:restriction>\r
     </xs:simpleType>\r
 \r
+    <!-- This is the base class for paginated lists -->\r
+    <xs:complexType name="abstractCommonList">\r
+        <xs:annotation>\r
+            <xs:appinfo>\r
+                <jaxb:class ref="org.collectionspace.services.jaxb.AbstractCommonList"/>\r
+            </xs:appinfo>\r
+        </xs:annotation>\r
+    </xs:complexType>\r
+    \r
     <!-- collection objects as in nuxeo repository -->\r
     <xs:element name="relations-common-list">\r
         <xs:complexType>\r
-            <xs:sequence>\r
-                <xs:element name="relation-list-item" maxOccurs="unbounded">\r
-                    <xs:complexType>\r
-                        <xs:sequence>\r
-                            <!-- uri to retrive collection object details -->\r
-                            <xs:element name="uri" type="xs:anyURI" minOccurs="1"/>\r
-                            <xs:element name="csid" type="xs:string" minOccurs="1"/>\r
-                            <xs:element name="subjectCsid" type="xs:string" minOccurs="1"/>\r
-                            <xs:element name="objectCsid" type="xs:string" minOccurs="1"/>\r
-                        </xs:sequence>\r
-                    </xs:complexType>\r
-                </xs:element>\r
-            </xs:sequence>\r
+            <xs:complexContent>\r
+                <xs:extension base="abstractCommonList">                    \r
+                    <xs:sequence>\r
+                        <xs:element name="relation-list-item" maxOccurs="unbounded">\r
+                            <xs:complexType>\r
+                                <xs:sequence>\r
+                                    <!-- uri to retrive collection object details -->\r
+                                    <xs:element name="uri" type="xs:anyURI" minOccurs="1"/>\r
+                                    <xs:element name="csid" type="xs:string" minOccurs="1"/>\r
+                                    <xs:element name="subjectCsid" type="xs:string" minOccurs="1"/>\r
+                                    <xs:element name="objectCsid" type="xs:string" minOccurs="1"/>\r
+                                </xs:sequence>\r
+                            </xs:complexType>\r
+                        </xs:element>\r
+                    </xs:sequence>\r
+                </xs:extension>\r
+            </xs:complexContent>                    \r
         </xs:complexType>\r
     </xs:element>\r
-\r
+    \r
 </xs:schema>\r
 \r
 \r
index 4bbc8dd6f3c553edcfc38a7dc3113a64fa37cf87..3cf6146fb42a7f9f36d0b271fa1041bb75fcdb02 100644 (file)
             <groupId>org.jvnet.jaxb2_commons</groupId>
             <artifactId>runtime</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.collectionspace.services</groupId>
+            <artifactId>org.collectionspace.services.jaxb</artifactId>
+            <version>${project.version}</version>
+        </dependency>        
     </dependencies>
     
     <build>
index d4af271a124080ddae5614b0abfc095c658d0c61..5cda4133368f6fa4ac64b4578ce7ae7a179948df 100644 (file)
@@ -13,6 +13,8 @@
 
 <xs:schema 
   xmlns:xs="http://www.w3.org/2001/XMLSchema"
+  xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
+  jaxb:version="1.0" elementFormDefault="unqualified"
   xmlns:ns="http://collectionspace.org/services/loanin"
   xmlns="http://collectionspace.org/services/loanin"
   targetNamespace="http://collectionspace.org/services/loanin"
         </xs:sequence>
     </xs:complexType>
     
+    <!-- This is the base class for paginated lists -->
+    <xs:complexType name="abstractCommonList">
+        <xs:annotation>
+            <xs:appinfo>
+                <jaxb:class ref="org.collectionspace.services.jaxb.AbstractCommonList"/>
+            </xs:appinfo>
+        </xs:annotation>
+    </xs:complexType>
+    
     <!-- loansin records, as in nuxeo repository -->
     <xs:element name="loansin-common-list">
         <xs:complexType>
-            <xs:sequence>
-                <xs:element name="loanin-list-item" maxOccurs="unbounded">
-                    <xs:complexType>
-                        <xs:sequence>
-                            <xs:element name="loanInNumber" type="xs:string"
-                                minOccurs="1" />
-                            <xs:element name="loanReturnDate" type="xs:string"
-                                minOccurs="1" />
-                            <!-- uri to retrive details -->
-                            <xs:element name="uri" type="xs:anyURI"
-                                minOccurs="1" />
-                            <xs:element name="csid" type="xs:string"
-                                minOccurs="1" />
-                        </xs:sequence>
-                    </xs:complexType>
-                </xs:element>
-            </xs:sequence>
+            <xs:complexContent>
+                <xs:extension base="abstractCommonList">
+                    <xs:sequence>
+                        <xs:element name="loanin-list-item" maxOccurs="unbounded">
+                            <xs:complexType>
+                                <xs:sequence>
+                                    <xs:element name="loanInNumber" type="xs:string"
+                                        minOccurs="1" />
+                                    <xs:element name="loanReturnDate" type="xs:string"
+                                        minOccurs="1" />
+                                    <!-- uri to retrive details -->
+                                    <xs:element name="uri" type="xs:anyURI"
+                                        minOccurs="1" />
+                                    <xs:element name="csid" type="xs:string"
+                                        minOccurs="1" />
+                                </xs:sequence>
+                            </xs:complexType>
+                        </xs:element>
+                    </xs:sequence>
+                </xs:extension>
+            </xs:complexContent>        
         </xs:complexType>
     </xs:element>
     
index 0aebab8a79bf57ef0ef45b18b343dc0cba7679c5..0b9ce11a4bc917a2a0aa7e1093fa45f1e54c650f 100644 (file)
@@ -47,6 +47,7 @@ import org.slf4j.LoggerFactory;
 public class LoaninDocumentModelHandler
         extends RemoteDocumentModelHandlerImpl<LoansinCommon, LoansinCommonList> {
 
+    /** The logger. */
     private final Logger logger = LoggerFactory.getLogger(LoaninDocumentModelHandler.class);
     /**
      * loanin is used to stash JAXB object to use when handle is called
@@ -59,7 +60,6 @@ public class LoaninDocumentModelHandler
      */
     private LoansinCommonList loaninList;
 
-
     /**
      * getCommonPart get associated loanin
      * @return
@@ -84,35 +84,42 @@ public class LoaninDocumentModelHandler
      */
     @Override
     public LoansinCommonList getCommonPartList() {
-        return loaninList;
+        return this.loaninList;
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#setCommonPartList(java.lang.Object)
+     */
     @Override
-    public void setCommonPartList(LoansinCommonList loaninList) {
-        this.loaninList = loaninList;
+    public void setCommonPartList(LoansinCommonList theLoaninList) {
+        this.loaninList = theLoaninList;
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPart(org.collectionspace.services.common.document.DocumentWrapper)
+     */
     @Override
     public LoansinCommon 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(LoansinCommon loaninObject, 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 LoansinCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
-        DocumentModelList docList = wrapDoc.getWrappedObject();
-
-        LoansinCommonList coList = new LoansinCommonList();
+        LoansinCommonList coList = extractPagingInfo(new LoansinCommonList(), wrapDoc);
         List<LoansinCommonList.LoaninListItem> list = coList.getLoaninListItem();
-
-        //FIXME: iterating over a long list of documents is not a long term
-        //strategy...need to change to more efficient iterating in future
-        Iterator<DocumentModel> iter = docList.iterator();
+        Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
         while(iter.hasNext()){
             DocumentModel docModel = iter.next();
             LoaninListItem ilistItem = new LoaninListItem();
index 6d5fd0293b56699da9d2373e537d52ca3050021d..601164f0662aaa269858d4b1479a75ffa7ef0973 100644 (file)
             <groupId>org.jvnet.jaxb2_commons</groupId>
             <artifactId>runtime</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.collectionspace.services</groupId>
+            <artifactId>org.collectionspace.services.jaxb</artifactId>
+            <version>${project.version}</version>
+        </dependency>        
     </dependencies>
     
     <build>
index 6591ef4d0536df218bf23ea7048513ad6d0fd8c3..2201fed2f15ec68d64dc540c049e2ff6a1105545 100644 (file)
@@ -13,6 +13,8 @@
 
 <xs:schema 
   xmlns:xs="http://www.w3.org/2001/XMLSchema"
+  xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
+  jaxb:version="1.0" elementFormDefault="unqualified"
   xmlns:ns="http://collectionspace.org/services/loanout"
   xmlns="http://collectionspace.org/services/loanout"
   targetNamespace="http://collectionspace.org/services/loanout"
         </xs:complexType>
     </xs:element>
  
+    <!-- This is the base class for paginated lists -->
+    <xs:complexType name="abstractCommonList">
+        <xs:annotation>
+            <xs:appinfo>
+                <jaxb:class ref="org.collectionspace.services.jaxb.AbstractCommonList"/>
+            </xs:appinfo>
+        </xs:annotation>
+    </xs:complexType>
+    
     <!-- loansout records, as in nuxeo repository -->
     <xs:element name="loansout-common-list">
         <xs:complexType>
-            <xs:sequence>
-                <xs:element name="loanout-list-item" maxOccurs="unbounded">
-                    <xs:complexType>
-                        <xs:sequence>
-                            <xs:element name="loanOutNumber" type="xs:string"
-                                minOccurs="1" />
-                            <xs:element name="loanReturnDate" type="xs:string"
-                                minOccurs="1" />
-                            <!-- uri to retrive details -->
-                            <xs:element name="uri" type="xs:anyURI"
-                                minOccurs="1" />
-                            <xs:element name="csid" type="xs:string"
-                                minOccurs="1" />
-                        </xs:sequence>
-                    </xs:complexType>
-                </xs:element>
-            </xs:sequence>
+            <xs:complexContent>
+                <xs:extension base="abstractCommonList">                    
+                    <xs:sequence>
+                        <xs:element name="loanout-list-item" maxOccurs="unbounded">
+                            <xs:complexType>
+                                <xs:sequence>
+                                    <xs:element name="loanOutNumber" type="xs:string"
+                                        minOccurs="1" />
+                                    <xs:element name="loanReturnDate" type="xs:string"
+                                        minOccurs="1" />
+                                    <!-- uri to retrive details -->
+                                    <xs:element name="uri" type="xs:anyURI"
+                                        minOccurs="1" />
+                                    <xs:element name="csid" type="xs:string"
+                                        minOccurs="1" />
+                                </xs:sequence>
+                            </xs:complexType>
+                        </xs:element>
+                    </xs:sequence>
+                </xs:extension>
+            </xs:complexContent>                    
         </xs:complexType>
     </xs:element>
     
index a14ce2a070abb9d8ae8999c5f56a9b0045931fc4..bbf1deb94f07ce02187a3e3adaa8747667df46b1 100644 (file)
@@ -39,30 +39,25 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * LoanoutDocumentModelHandler
- *
- * $LastChangedRevision: $
- * $LastChangedDate: $
+ * The Class LoanoutDocumentModelHandler.
  */
 public class LoanoutDocumentModelHandler
         extends RemoteDocumentModelHandlerImpl<LoansoutCommon, LoansoutCommonList> {
 
+    /** The logger. */
     private final Logger logger = LoggerFactory.getLogger(LoanoutDocumentModelHandler.class);
-    /**
-     * loanout is used to stash JAXB object to use when handle is called
-     * for Action.CREATE, Action.UPDATE or Action.GET
-     */
+    
+    /** The loanout. */
     private LoansoutCommon loanout;
-    /**
-     * loanoutList is stashed when handle is called
-     * for ACTION.GET_ALL
-     */
+    
+    /** The loanout list. */
     private LoansoutCommonList loanoutList;
 
 
     /**
-     * getCommonPart get associated loanout
-     * @return
+     * Gets the common part.
+     *
+     * @return the common part
      */
     @Override
     public LoansoutCommon getCommonPart() {
@@ -70,8 +65,9 @@ public class LoanoutDocumentModelHandler
     }
 
     /**
-     * setCommonPart set associated loanout
-     * @param loanout
+     * Sets the common part.
+     *
+     * @param loanout the new common part
      */
     @Override
     public void setCommonPart(LoansoutCommon loanout) {
@@ -79,40 +75,62 @@ public class LoanoutDocumentModelHandler
     }
 
     /**
-     * getCommonPartList get associated loanout (for index/GET_ALL)
-     * @return
+     * Gets the common part list.
+     *
+     * @return the common part list
      */
     @Override
     public LoansoutCommonList getCommonPartList() {
         return loanoutList;
     }
 
+    /**
+     * Sets the common part list.
+     *
+     * @param loanoutList the new common part list
+     */
     @Override
     public void setCommonPartList(LoansoutCommonList loanoutList) {
         this.loanoutList = loanoutList;
     }
 
+    /**
+     * Extract common part.
+     *
+     * @param wrapDoc the wrap doc
+     * @return the loansout common
+     * @throws Exception the exception
+     */
     @Override
     public LoansoutCommon extractCommonPart(DocumentWrapper<DocumentModel> wrapDoc)
             throws Exception {
         throw new UnsupportedOperationException();
     }
 
+    /**
+     * Fill common part.
+     *
+     * @param loanoutObject the loanout object
+     * @param wrapDoc the wrap doc
+     * @throws Exception the exception
+     */
     @Override
     public void fillCommonPart(LoansoutCommon loanoutObject, DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
         throw new UnsupportedOperationException();
     }
 
+    /**
+     * Extract common part list.
+     *
+     * @param wrapDoc the wrap doc
+     * @return the loansout common list
+     * @throws Exception the exception
+     */
     @Override
     public LoansoutCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
-        DocumentModelList docList = wrapDoc.getWrappedObject();
-
-        LoansoutCommonList coList = new LoansoutCommonList();
+        LoansoutCommonList coList = extractPagingInfo(new LoansoutCommonList(), wrapDoc);
         List<LoansoutCommonList.LoanoutListItem> list = coList.getLoanoutListItem();
-
-        //FIXME: iterating over a long list of documents is not a long term
-        //strategy...need to change to more efficient iterating in future
-        Iterator<DocumentModel> iter = docList.iterator();
+        Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
         while(iter.hasNext()){
             DocumentModel docModel = iter.next();
             LoanoutListItem ilistItem = new LoanoutListItem();
@@ -130,9 +148,10 @@ public class LoanoutDocumentModelHandler
     }
 
     /**
-     * getQProperty converts the given property to qualified schema property
-     * @param prop
-     * @return
+     * Gets the q property.
+     *
+     * @param prop the prop
+     * @return the q property
      */
     @Override
     public String getQProperty(String prop) {
index ca12bdb900e3586507179091a354eca8110391b8..18ffc00e7fa3c90fc1b65e67ccde9dc54630c81f 100644 (file)
             <groupId>org.jvnet.jaxb2_commons</groupId>
             <artifactId>runtime</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.collectionspace.services</groupId>
+            <artifactId>org.collectionspace.services.jaxb</artifactId>
+            <version>${project.version}</version>
+        </dependency>        
     </dependencies>
     
     <build>
index 9fd20e108b412cf7bc5a3a0d632d10406b4cc887..82caef84c550ab6eb730fab3f4c2845e1cac18ff 100644 (file)
@@ -1,17 +1,18 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <xs:schema 
     xmlns:xs="http://www.w3.org/2001/XMLSchema"
+    xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
+    jaxb:version="1.0" elementFormDefault="unqualified"
     xmlns:ns="http://collectionspace.org/services/organization"
     xmlns="http://collectionspace.org/services/organization"
     targetNamespace="http://collectionspace.org/services/organization"
-    version="0.1"
-    >
-
+    version="0.1">
+    
     <!-- avoid XmlRootElement nightnmare, see http://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html-->
-
+    
     <!-- See http://wiki.collectionspace.org/display/collectionspace/Name+Authority+Schema -->
     <!-- See http://wiki.collectionspace.org/display/collectionspace/Organization+Service+Home -->
-
+    
     <!-- Organization -->
     <xs:element name="organizations_common">
         <xs:complexType>
         </xs:complexType>
     </xs:element>
     
+    <!-- This is the base class for paginated lists -->
+    <xs:complexType name="abstractCommonListItem">
+        <xs:annotation>
+            <xs:appinfo>
+                <jaxb:class ref="org.collectionspace.services.jaxb.AbstractCommonList"/>
+            </xs:appinfo>
+        </xs:annotation>
+    </xs:complexType>
+    
     <!-- Organization instances, as in nuxeo repository -->
     <xs:element name="organizations-common-list">
         <xs:complexType>
-            <xs:sequence>
-                <xs:element name="pageNum" type="xs:unsignedInt" />
-                <xs:element name="pageSize" type="xs:unsignedInt" />
-                <xs:element name="totalItems" type="xs:unsignedInt" />
-                <xs:element name="organization_list_item" maxOccurs="unbounded">
-                    <xs:complexType>
-                        <xs:sequence>
-                            <xs:element name="displayName" type="xs:string"
-                                minOccurs="1" />
-                            <!-- uri to retrieve organization details -->
-                            <xs:element name="uri" type="xs:anyURI"
-                                minOccurs="1" />
-                            <xs:element name="refName" type="xs:string"
-                                minOccurs="1" />
-                            <xs:element name="csid" type="xs:string"
-                                minOccurs="1" />
-                        </xs:sequence>
-                    </xs:complexType>
-                </xs:element>
-            </xs:sequence>
+            <xs:complexContent>
+                <xs:extension base="abstractCommonListItem">                    
+                    <xs:sequence>
+                        <xs:element name="organization_list_item" maxOccurs="unbounded">
+                            <xs:complexType>
+                                <xs:sequence>
+                                    <xs:element name="displayName" type="xs:string"
+                                        minOccurs="1" />
+                                    <!-- uri to retrieve organization details -->
+                                    <xs:element name="uri" type="xs:anyURI"
+                                        minOccurs="1" />
+                                    <xs:element name="refName" type="xs:string"
+                                        minOccurs="1" />
+                                    <xs:element name="csid" type="xs:string"
+                                        minOccurs="1" />
+                                </xs:sequence>
+                            </xs:complexType>
+                        </xs:element>
+                    </xs:sequence>
+                </xs:extension>
+            </xs:complexContent>                    
         </xs:complexType>
     </xs:element>
     
index 42e179aa9dd15db11bfae19484bfaf3eef5901cc..32eb77317f301ea8b9e9ee674e9bb647efb2edc1 100644 (file)
 -->
 
 <xs:schema 
-  xmlns:xs="http://www.w3.org/2001/XMLSchema"
-  xmlns:ns="http://collectionspace.org/services/organization"
-  xmlns="http://collectionspace.org/services/organization"
-  targetNamespace="http://collectionspace.org/services/organization"
-  version="0.1"
->
-
-<!--
-    Avoid XmlRootElement nightmare:
-    See http://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html
--->
-<!-- See http://wiki.collectionspace.org/display/collectionspace/Organization+Service+Home -->    
+    xmlns:xs="http://www.w3.org/2001/XMLSchema"
+    xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
+    jaxb:version="1.0" elementFormDefault="unqualified"
+    xmlns:ns="http://collectionspace.org/services/organization"
+    xmlns="http://collectionspace.org/services/organization"
+    targetNamespace="http://collectionspace.org/services/organization"
+    version="0.1">
+    
+    <!--
+        Avoid XmlRootElement nightmare:
+        See http://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html
+    -->
+    <!-- See http://wiki.collectionspace.org/display/collectionspace/Organization+Service+Home -->    
     
     <!-- OrgAuthority  -->
     <xs:element name="orgauthorities_common">
                 <!--  OrgAuthority Information Group -->
                 <xs:element name="displayName" type="xs:string"/>
                 <xs:element name="refName" type="xs:string"/>
-                <xs:element name="vocabType" type="xs:string"/>
-
+                <xs:element name="vocabType" type="xs:string"/>                
             </xs:sequence>
         </xs:complexType>
     </xs:element>
     
+    <!-- This is the base class for paginated lists -->
+    <xs:complexType name="abstractCommonList">
+        <xs:annotation>
+            <xs:appinfo>
+                <jaxb:class ref="org.collectionspace.services.jaxb.AbstractCommonList"/>
+            </xs:appinfo>
+        </xs:annotation>
+    </xs:complexType>
+    
     <!-- OrgAuthority instances, as in nuxeo repository -->
     <xs:element name="orgauthorities-common-list">
         <xs:complexType>
-            <xs:sequence>
-                                                               <xs:element name="pageNum" type="xs:unsignedInt" />
-                                                               <xs:element name="pageSize" type="xs:unsignedInt" />
-                                                               <xs:element name="totalItems" type="xs:unsignedInt" />
-                 <xs:element name="orgauthority-list-item" maxOccurs="unbounded">
-                    <xs:complexType>
-                        <xs:sequence>
-                            <xs:element name="displayName" type="xs:string"
-                                minOccurs="1" />
-                            <xs:element name="refName" type="xs:string"
-                                minOccurs="1" />
-                            <xs:element name="vocabType" type="xs:string"
-                                minOccurs="1" />
-                            <!-- uri to retrieve orgauthority details -->
-                            <xs:element name="uri" type="xs:anyURI"
-                                minOccurs="1" />
-                            <xs:element name="csid" type="xs:string"
-                                minOccurs="1" />
-                        </xs:sequence>
-                    </xs:complexType>
-                </xs:element>
-            </xs:sequence>
+            <xs:complexContent>
+                <xs:extension base="abstractCommonList">                    
+                    <xs:sequence>
+                        <xs:element name="orgauthority-list-item" maxOccurs="unbounded">
+                            <xs:complexType>
+                                <xs:sequence>
+                                    <xs:element name="displayName" type="xs:string"
+                                        minOccurs="1" />
+                                    <xs:element name="refName" type="xs:string"
+                                        minOccurs="1" />
+                                    <xs:element name="vocabType" type="xs:string"
+                                        minOccurs="1" />
+                                    <!-- uri to retrieve orgauthority details -->
+                                    <xs:element name="uri" type="xs:anyURI"
+                                        minOccurs="1" />
+                                    <xs:element name="csid" type="xs:string"
+                                        minOccurs="1" />
+                                </xs:sequence>
+                            </xs:complexType>
+                        </xs:element>
+                    </xs:sequence>
+                </xs:extension>
+            </xs:complexContent>
         </xs:complexType>
     </xs:element>
-
+    
 </xs:schema>
 
index c4a4f346af8a120d43f478bcc0d4ea91709df084..4e6dbabd00de4c182784225deb856139a37e175c 100644 (file)
@@ -50,6 +50,7 @@ import org.slf4j.LoggerFactory;
 public class OrgAuthorityDocumentModelHandler
         extends RemoteDocumentModelHandlerImpl<OrgauthoritiesCommon, OrgauthoritiesCommonList> {
 
+    /** The logger. */
     private final Logger logger = LoggerFactory.getLogger(OrgAuthorityDocumentModelHandler.class);
     /**
      * orgAuthority is used to stash JAXB object to use when handle is called
@@ -90,44 +91,40 @@ public class OrgAuthorityDocumentModelHandler
         return orgAuthorityList;
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#setCommonPartList(java.lang.Object)
+     */
     @Override
     public void setCommonPartList(OrgauthoritiesCommonList orgAuthorityList) {
         this.orgAuthorityList = orgAuthorityList;
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPart(org.collectionspace.services.common.document.DocumentWrapper)
+     */
     @Override
     public OrgauthoritiesCommon 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(OrgauthoritiesCommon orgAuthorityObject, DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
+    public void fillCommonPart(OrgauthoritiesCommon orgAuthorityObject, 
+               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 OrgauthoritiesCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
-        DocumentModelList docList = wrapDoc.getWrappedObject();
-
-        OrgauthoritiesCommonList coList = new OrgauthoritiesCommonList();
-        List<OrgauthoritiesCommonList.OrgauthorityListItem> list = coList.getOrgauthorityListItem();
-
-        DocumentFilter filter = getDocumentFilter();
-        long pageNum, pageSize;
-        if(filter==null) {
-               pageNum = 0;
-               pageSize = 0;
-        } else {
-               pageSize = filter.getPageSize();
-               pageNum = filter.getOffset()/pageSize;
-        }
-        coList.setPageNum(pageNum);
-        coList.setPageSize(pageSize);
-       coList.setTotalItems(docList.totalSize());
-        //FIXME: iterating over a long list of documents is not a long term
-        //strategy...need to change to more efficient iterating in future
-        Iterator<DocumentModel> iter = docList.iterator();
+        OrgauthoritiesCommonList coList = this.extractPagingInfo(new OrgauthoritiesCommonList(), wrapDoc);
+       List<OrgauthoritiesCommonList.OrgauthorityListItem> list = coList.getOrgauthorityListItem();
+       Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
         while(iter.hasNext()){
             DocumentModel docModel = iter.next();
             OrgauthorityListItem ilistItem = new OrgauthorityListItem();
index 0465abe3e9319209622eb9cdede6300341d447c8..9977af8adbafb29b475d371dcaac8b1ade9f524f 100644 (file)
@@ -51,6 +51,7 @@ import org.slf4j.LoggerFactory;
 public class OrganizationDocumentModelHandler
         extends RemoteDocumentModelHandlerImpl<OrganizationsCommon, OrganizationsCommonList> {
 
+    /** The logger. */
     private final Logger logger = LoggerFactory.getLogger(OrganizationDocumentModelHandler.class);
     /**
      * Common part schema label
@@ -72,15 +73,28 @@ public class OrganizationDocumentModelHandler
      */
     private String inAuthority;
 
+    /**
+     * Gets the in authority.
+     *
+     * @return the in authority
+     */
     public String getInAuthority() {
                return inAuthority;
        }
 
+       /**
+        * Sets the in authority.
+        *
+        * @param inAuthority the new in authority
+        */
        public void setInAuthority(String inAuthority) {
                this.inAuthority = inAuthority;
        }
 
        
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#handleCreate(org.collectionspace.services.common.document.DocumentWrapper)
+     */
     @Override
     public void handleCreate(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
        // first fill all the parts of the document
@@ -88,6 +102,9 @@ public class OrganizationDocumentModelHandler
        handleDisplayName(wrapDoc.getWrappedObject());
     }
     
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#handleUpdate(org.collectionspace.services.common.document.DocumentWrapper)
+     */
     @Override
     public void handleUpdate(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
        super.handleUpdate(wrapDoc);
@@ -170,11 +187,17 @@ public class OrganizationDocumentModelHandler
         return organizationList;
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#setCommonPartList(java.lang.Object)
+     */
     @Override
     public void setCommonPartList(OrganizationsCommonList organizationList) {
         this.organizationList = organizationList;
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl#extractPart(org.nuxeo.ecm.core.api.DocumentModel, java.lang.String, org.collectionspace.services.common.service.ObjectPartType)
+     */
     @Override
     protected Map<String, Object> extractPart(DocumentModel docModel, String schema, ObjectPartType partMeta)
             throws Exception {
@@ -189,61 +212,46 @@ public class OrganizationDocumentModelHandler
        return unQObjectProperties;
     }
     
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPart(org.collectionspace.services.common.document.DocumentWrapper)
+     */
     @Override
     public OrganizationsCommon extractCommonPart(DocumentWrapper 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(OrganizationsCommon organizationObject, DocumentWrapper wrapDoc) throws Exception {
+    public void fillCommonPart(OrganizationsCommon organizationObject, 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 OrganizationsCommonList extractCommonPartList(DocumentWrapper wrapDoc) 
-       throws Exception {
-        OrganizationsCommonList coList = new OrganizationsCommonList();
-        try{
-               DocumentModelList docList = (DocumentModelList) wrapDoc.getWrappedObject();
-       
-               List<OrganizationsCommonList.OrganizationListItem> list = 
-                       coList.getOrganizationListItem();
-       
-               DocumentFilter filter = getDocumentFilter();
-               long pageNum, pageSize;
-               if(filter==null) {
-                       pageNum = 0;
-                       pageSize = 0;
-               } else {
-                       pageSize = filter.getPageSize();
-                       pageNum = filter.getOffset()/pageSize;
-               }
-               coList.setPageNum(pageNum);
-               coList.setPageSize(pageSize);
-               coList.setTotalItems(docList.totalSize());
-               //FIXME: iterating over a long list of documents is not a long term
-               //strategy...need to change to more efficient iterating in future
-               Iterator<DocumentModel> iter = docList.iterator();
-               String commonPartLabel = getServiceContext().getCommonPartLabel("organizations");
-               while(iter.hasNext()){
-                   DocumentModel docModel = iter.next();
-                   OrganizationListItem ilistItem = new OrganizationListItem();
-                   ilistItem.setDisplayName((String)
-                               docModel.getProperty(commonPartLabel,OrganizationJAXBSchema.DISPLAY_NAME ));
-                               ilistItem.setRefName((String) 
-                                               docModel.getProperty(commonPartLabel, OrganizationJAXBSchema.REF_NAME));
-                               String id = NuxeoUtils.extractId(docModel.getPathAsString());
-                   ilistItem.setUri("/orgauthorities/"+inAuthority+"/items/" + id);
-                   ilistItem.setCsid(id);
-                   list.add(ilistItem);
-               }
-        }catch(Exception e){
-            if(logger.isDebugEnabled()){
-                logger.debug("Caught exception in extractCommonPartList", e);
-            }
-            throw e;
+    public OrganizationsCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) 
+               throws Exception {
+        OrganizationsCommonList coList = this.extractPagingInfo(new OrganizationsCommonList(), wrapDoc);
+        List<OrganizationsCommonList.OrganizationListItem> list = coList.getOrganizationListItem();
+        Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
+        String commonPartLabel = getServiceContext().getCommonPartLabel("organizations");
+        while(iter.hasNext()){
+            DocumentModel docModel = iter.next();
+            OrganizationListItem ilistItem = new OrganizationListItem();
+            ilistItem.setDisplayName((String)
+                       docModel.getProperty(commonPartLabel,OrganizationJAXBSchema.DISPLAY_NAME ));
+                       ilistItem.setRefName((String) 
+                                       docModel.getProperty(commonPartLabel, OrganizationJAXBSchema.REF_NAME));
+                       String id = NuxeoUtils.extractId(docModel.getPathAsString());
+            ilistItem.setUri("/orgauthorities/" + this.inAuthority + "/items/" + id);
+            ilistItem.setCsid(id);
+            list.add(ilistItem);
         }
+
         return coList;
     }
 
index bfc4524cbf799d8163963568830af327877cb463..59ccc89d7d185fd8661f922ad4e4e71c7a443cae 100644 (file)
             <groupId>org.jvnet.jaxb2_commons</groupId>
             <artifactId>runtime</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.collectionspace.services</groupId>
+            <artifactId>org.collectionspace.services.jaxb</artifactId>
+            <version>${project.version}</version>
+        </dependency>        
     </dependencies>
 
     <build>
index c2c52ba06d71ab5e6db77022aa226969f1291e3e..bb15d83ed120a56474655987d9fc09792dd4a50d 100644 (file)
@@ -1,15 +1,17 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <xs:schema 
-  xmlns:xs="http://www.w3.org/2001/XMLSchema"
-  xmlns:ns="http://collectionspace.org/services/person"
-  xmlns="http://collectionspace.org/services/person"
-  targetNamespace="http://collectionspace.org/services/person"
-  version="0.1"
->
-
-
-<!-- avoid XmlRootElement nightnmare, see http://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html-->
-<!-- See http://wiki.collectionspace.org/display/collectionspace/Person+Service+Home -->    
+    xmlns:xs="http://www.w3.org/2001/XMLSchema"
+    xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
+    jaxb:version="1.0" elementFormDefault="unqualified"
+    xmlns:ns="http://collectionspace.org/services/person"
+    xmlns="http://collectionspace.org/services/person"
+    targetNamespace="http://collectionspace.org/services/person"
+    version="0.1"
+    >
+    
+    
+    <!-- avoid XmlRootElement nightnmare, see http://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html-->
+    <!-- See http://wiki.collectionspace.org/display/collectionspace/Person+Service+Home -->    
     
     <!-- Person -->
     <xs:element name="persons_common">
         </xs:complexType>
     </xs:element>
     
+    <!-- This is the base class for paginated lists -->
+    <xs:complexType name="abstractCommonListItem">
+        <xs:annotation>
+            <xs:appinfo>
+                <jaxb:class ref="org.collectionspace.services.jaxb.AbstractCommonList"/>
+            </xs:appinfo>
+        </xs:annotation>
+    </xs:complexType>
+    
     <!-- Person instances, as in nuxeo repository -->
     <xs:element name="persons-common-list">
         <xs:complexType>
-            <xs:sequence>
-                <xs:element name="pageNum" type="xs:unsignedInt" />
-                <xs:element name="pageSize" type="xs:unsignedInt" />
-                <xs:element name="totalItems" type="xs:unsignedInt" />
-                 <xs:element name="person_list_item" maxOccurs="unbounded">
-                    <xs:complexType>
-                        <xs:sequence>
-                            <xs:element name="displayName" type="xs:string"
-                                minOccurs="1" />
-                            <!-- uri to retrieve person details -->
-                            <xs:element name="uri" type="xs:anyURI"
-                                minOccurs="1" />
-                            <xs:element name="refName" type="xs:string"
-                                minOccurs="1" />
-                            <xs:element name="csid" type="xs:string"
-                                minOccurs="1" />
-                        </xs:sequence>
-                    </xs:complexType>
-                </xs:element>
-            </xs:sequence>
+            <xs:complexContent>
+                <xs:extension base="abstractCommonListItem">                    
+                    <xs:sequence>
+                        <xs:element name="person_list_item" maxOccurs="unbounded">
+                            <xs:complexType>
+                                <xs:sequence>
+                                    <xs:element name="displayName" type="xs:string"
+                                        minOccurs="1" />
+                                    <!-- uri to retrieve person details -->
+                                    <xs:element name="uri" type="xs:anyURI"
+                                        minOccurs="1" />
+                                    <xs:element name="refName" type="xs:string"
+                                        minOccurs="1" />
+                                    <xs:element name="csid" type="xs:string"
+                                        minOccurs="1" />
+                                </xs:sequence>
+                            </xs:complexType>
+                        </xs:element>
+                    </xs:sequence>
+                </xs:extension>
+            </xs:complexContent>
         </xs:complexType>
     </xs:element>
     
index 69751b37e1546c6c92264626bded270cc67edc7b..7ff8dcd40d088e814e4a9ae73616b73f0096c791 100644 (file)
 -->
 
 <xs:schema 
-  xmlns:xs="http://www.w3.org/2001/XMLSchema"
-  xmlns:ns="http://collectionspace.org/services/person"
-  xmlns="http://collectionspace.org/services/person"
-  targetNamespace="http://collectionspace.org/services/person"
-  version="0.1"
->
-
-<!--
-    Avoid XmlRootElement nightmare:
-    See http://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html
--->
-<!-- See http://wiki.collectionspace.org/display/collectionspace/Person+Service+Home -->    
+    xmlns:xs="http://www.w3.org/2001/XMLSchema"
+    xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
+    jaxb:version="1.0" elementFormDefault="unqualified"
+    xmlns:ns="http://collectionspace.org/services/person"
+    xmlns="http://collectionspace.org/services/person"
+    targetNamespace="http://collectionspace.org/services/person"
+    version="0.1"
+    >
+    
+    <!--
+        Avoid XmlRootElement nightmare:
+        See http://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html
+    -->
+    <!-- See http://wiki.collectionspace.org/display/collectionspace/Person+Service+Home -->    
     
     <!-- PersonAuthority  -->
     <xs:element name="personauthorities_common">
                 <xs:element name="displayName" type="xs:string"/>
                 <xs:element name="refName" type="xs:string"/>
                 <xs:element name="vocabType" type="xs:string"/>
-
+                
             </xs:sequence>
         </xs:complexType>
     </xs:element>
     
+    <!-- This is the base class for paginated lists -->
+    <xs:complexType name="abstractCommonList">
+        <xs:annotation>
+            <xs:appinfo>
+                <jaxb:class ref="org.collectionspace.services.jaxb.AbstractCommonList"/>
+            </xs:appinfo>
+        </xs:annotation>
+    </xs:complexType>
+    
+    
     <!-- PersonAuthority instances, as in nuxeo repository -->
     <xs:element name="personauthorities-common-list">
         <xs:complexType>
-            <xs:sequence>
-                                                               <xs:element name="pageNum" type="xs:unsignedInt" />
-                                                               <xs:element name="pageSize" type="xs:unsignedInt" />
-                                                               <xs:element name="totalItems" type="xs:unsignedInt" />
-                 <xs:element name="personauthority-list-item" maxOccurs="unbounded">
-                    <xs:complexType>
-                        <xs:sequence>
-                            <xs:element name="displayName" type="xs:string"
-                                minOccurs="1" />
-                            <xs:element name="refName" type="xs:string"
-                                minOccurs="1" />
-                            <xs:element name="vocabType" type="xs:string"
-                                minOccurs="1" />
-                            <!-- uri to retrieve personauthority details -->
-                            <xs:element name="uri" type="xs:anyURI"
-                                minOccurs="1" />
-                            <xs:element name="csid" type="xs:string"
-                                minOccurs="1" />
-                        </xs:sequence>
-                    </xs:complexType>
-                </xs:element>
-            </xs:sequence>
+            <xs:complexContent>
+                <xs:extension base="abstractCommonList">                    
+                    <xs:sequence>
+                        <xs:element name="personauthority-list-item" maxOccurs="unbounded">
+                            <xs:complexType>
+                                <xs:sequence>
+                                    <xs:element name="displayName" type="xs:string"
+                                        minOccurs="1" />
+                                    <xs:element name="refName" type="xs:string"
+                                        minOccurs="1" />
+                                    <xs:element name="vocabType" type="xs:string"
+                                        minOccurs="1" />
+                                    <!-- uri to retrieve personauthority details -->
+                                    <xs:element name="uri" type="xs:anyURI"
+                                        minOccurs="1" />
+                                    <xs:element name="csid" type="xs:string"
+                                        minOccurs="1" />
+                                </xs:sequence>
+                            </xs:complexType>
+                        </xs:element>
+                    </xs:sequence>
+                </xs:extension>
+            </xs:complexContent>                    
         </xs:complexType>
     </xs:element>
-
+    
 </xs:schema>
 
index 09fb34fd1ade2abb506932de20d43b685ff2dba2..533f38e32daea59d4479a3dee5786b699e1a4f4d 100644 (file)
@@ -108,26 +108,13 @@ public class PersonAuthorityDocumentModelHandler
 
     @Override
     public PersonauthoritiesCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
-        DocumentModelList docList = wrapDoc.getWrappedObject();
+        PersonauthoritiesCommonList coList = extractPagingInfo(new PersonauthoritiesCommonList(),
+                       wrapDoc);
 
-        PersonauthoritiesCommonList coList = new PersonauthoritiesCommonList();
-        List<PersonauthoritiesCommonList.PersonauthorityListItem> list = coList.getPersonauthorityListItem();
-
-        DocumentFilter filter = getDocumentFilter();
-        long pageNum, pageSize;
-        if(filter==null) {
-               pageNum = 0;
-               pageSize = 0;
-        } else {
-               pageSize = filter.getPageSize();
-               pageNum = filter.getOffset()/pageSize;
-        }
-        coList.setPageNum(pageNum);
-        coList.setPageSize(pageSize);
-       coList.setTotalItems(docList.totalSize());
         //FIXME: iterating over a long list of documents is not a long term
         //strategy...need to change to more efficient iterating in future
-        Iterator<DocumentModel> iter = docList.iterator();
+        List<PersonauthoritiesCommonList.PersonauthorityListItem> list = coList.getPersonauthorityListItem();
+        Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
         while(iter.hasNext()){
             DocumentModel docModel = iter.next();
             PersonauthorityListItem ilistItem = new PersonauthorityListItem();
index e77d5de3f0138211466ab70c0c74b85cfce4850b..67b1f3b9831f78ae56c4f6730eceb1d445a827b2 100644 (file)
@@ -56,6 +56,7 @@ import org.slf4j.LoggerFactory;
 public class PersonDocumentModelHandler
         extends RemoteDocumentModelHandlerImpl<PersonsCommon, PersonsCommonList> {
 
+    /** The logger. */
     private final Logger logger = LoggerFactory.getLogger(PersonDocumentModelHandler.class);
     /**
      * Common part schema label
@@ -78,15 +79,28 @@ public class PersonDocumentModelHandler
      */
     private String inAuthority;
 
+    /**
+     * Gets the in authority.
+     *
+     * @return the in authority
+     */
     public String getInAuthority() {
                return inAuthority;
        }
 
+       /**
+        * Sets the in authority.
+        *
+        * @param inAuthority the new in authority
+        */
        public void setInAuthority(String inAuthority) {
                this.inAuthority = inAuthority;
        }
 
        
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#handleCreate(org.collectionspace.services.common.document.DocumentWrapper)
+     */
     @Override
     public void handleCreate(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
        // first fill all the parts of the document
@@ -94,12 +108,21 @@ public class PersonDocumentModelHandler
        handleDisplayName(wrapDoc.getWrappedObject());
     }
     
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#handleUpdate(org.collectionspace.services.common.document.DocumentWrapper)
+     */
     @Override
     public void handleUpdate(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
        super.handleUpdate(wrapDoc);
        handleDisplayName(wrapDoc.getWrappedObject());
     }
 
+    /**
+     * Handle display name.
+     *
+     * @param docModel the doc model
+     * @throws Exception the exception
+     */
     private void handleDisplayName(DocumentModel docModel) throws Exception {
        String commonPartLabel = getServiceContext().getCommonPartLabel("persons");
        Boolean displayNameComputed = (Boolean) docModel.getProperty(commonPartLabel,
@@ -197,11 +220,17 @@ public class PersonDocumentModelHandler
         return personList;
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#setCommonPartList(java.lang.Object)
+     */
     @Override
     public void setCommonPartList(PersonsCommonList personList) {
         this.personList = personList;
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl#extractPart(org.nuxeo.ecm.core.api.DocumentModel, java.lang.String, org.collectionspace.services.common.service.ObjectPartType)
+     */
     @Override
     protected Map<String, Object> extractPart(DocumentModel docModel, String schema, ObjectPartType partMeta)
             throws Exception {
@@ -216,63 +245,50 @@ public class PersonDocumentModelHandler
        return unQObjectProperties;
     }
     
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPart(org.collectionspace.services.common.document.DocumentWrapper)
+     */
     @Override
     public PersonsCommon extractCommonPart(DocumentWrapper 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(PersonsCommon personObject, DocumentWrapper 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 PersonsCommonList extractCommonPartList(DocumentWrapper wrapDoc) 
-       throws Exception {
-        PersonsCommonList coList = new PersonsCommonList();
-        try{
-               DocumentModelList docList = (DocumentModelList) wrapDoc.getWrappedObject();
-       
-               List<PersonsCommonList.PersonListItem> list = 
-                       coList.getPersonListItem();
-       
-               DocumentFilter filter = getDocumentFilter();
-               long pageNum, pageSize;
-               if(filter==null) {
-                       pageNum = 0;
-                       pageSize = 0;
-               } else {
-                       pageSize = filter.getPageSize();
-                       pageNum = filter.getOffset()/pageSize;
-               }
-               coList.setPageNum(pageNum);
-               coList.setPageSize(pageSize);
-               coList.setTotalItems(docList.totalSize());
-               //FIXME: iterating over a long list of documents is not a long term
-               //strategy...need to change to more efficient iterating in future
-               Iterator<DocumentModel> iter = docList.iterator();
-               String commonPartLabel = getServiceContext().getCommonPartLabel("persons");
-               while(iter.hasNext()){
-                   DocumentModel docModel = iter.next();
-                   PersonListItem ilistItem = new PersonListItem();
-                               ilistItem.setDisplayName((String) 
-                               docModel.getProperty(commonPartLabel, PersonJAXBSchema.DISPLAY_NAME));
-                   ilistItem.setRefName((String) 
-                       docModel.getProperty(commonPartLabel, PersonJAXBSchema.REF_NAME));
-                               String id = NuxeoUtils.extractId(docModel.getPathAsString());
-                   ilistItem.setUri("/personauthorities/"+inAuthority+"/items/" + id);
-                   ilistItem.setCsid(id);
-                   list.add(ilistItem);
-               }
-        }catch(Exception e){
-            if(logger.isDebugEnabled()){
-                logger.debug("Caught exception in extractCommonPartList", e);
-            }
-            throw e;
-        }
-        return coList;
-    }
+       public PersonsCommonList extractCommonPartList(
+                       DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
+               PersonsCommonList coList = extractPagingInfo(new PersonsCommonList(), wrapDoc);
+               List<PersonsCommonList.PersonListItem> list = coList.getPersonListItem();
+               Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
+               String commonPartLabel = getServiceContext().getCommonPartLabel(
+                               "persons");
+               while (iter.hasNext()) {
+                       DocumentModel docModel = iter.next();
+                       PersonListItem ilistItem = new PersonListItem();
+                       ilistItem.setDisplayName((String) docModel.getProperty(
+                                       commonPartLabel, PersonJAXBSchema.DISPLAY_NAME));
+                       ilistItem.setRefName((String) docModel.getProperty(commonPartLabel,
+                                       PersonJAXBSchema.REF_NAME));
+                       String id = NuxeoUtils.extractId(docModel.getPathAsString());
+                       ilistItem.setUri("/personauthorities/" + inAuthority + "/items/"
+                                       + id);
+                       ilistItem.setCsid(id);
+                       list.add(ilistItem);
+               }
+
+               return coList;
+       }
 
     /**
      * getQProperty converts the given property to qualified schema property
index c1524552cd605b40815c9f41f53227a8f3487dad..9f4f631b4ec439b05b2ad9715041568cfbcb3ff1 100644 (file)
@@ -52,6 +52,7 @@ import org.slf4j.LoggerFactory;
 public class RelationDocumentModelHandler
         extends RemoteDocumentModelHandlerImpl<RelationsCommon, RelationsCommonList> {
 
+    /** The logger. */
     private final Logger logger = LoggerFactory.getLogger(RelationDocumentModelHandler.class);
     /**
      * relation is used to stash JAXB object to use when handle is called
@@ -92,40 +93,49 @@ public class RelationDocumentModelHandler
         return relationList;
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#setCommonPartList(java.lang.Object)
+     */
     @Override
     public void setCommonPartList(RelationsCommonList relationList) {
         this.relationList = relationList;
     }
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPart(org.collectionspace.services.common.document.DocumentWrapper)
+     */
     @Override
     public RelationsCommon 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(RelationsCommon relation, 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 RelationsCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
-        DocumentModelList docList = wrapDoc.getWrappedObject();
-
         Map propsFromResource = this.getProperties();
         String subjectCsid = (String) propsFromResource.get(IRelationsManager.SUBJECT);
         String predicate = (String) propsFromResource.get(IRelationsManager.PREDICATE);
         String objectCsid = (String) propsFromResource.get(IRelationsManager.OBJECT);
 
-        RelationsCommonList relList = new RelationsCommonList();
+        //FIXME - Need to change this into a NXQL on subject, predicate, object terms.  Currently,
+        //FIXME - we're performing a post query filter which is far from ideal and not scalable.
+        RelationsCommonList relList = this.extractPagingInfo(new RelationsCommonList(), wrapDoc) ;
         List<RelationsCommonList.RelationListItem> itemList = relList.getRelationListItem();
-
-        //FIXME: iterating over a long itemList of documents is not a long term
-        //strategy...need to change to more efficient iterating in future
-        Iterator<DocumentModel> iter = docList.iterator();
+        Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
         while(iter.hasNext()){
             DocumentModel docModel = iter.next();
-            if(RelationsUtils.isQueryMatch(docModel, subjectCsid,
+            if (RelationsUtils.isQueryMatch(docModel, subjectCsid,
                     predicate, objectCsid) == true){
                 RelationListItem relListItem = RelationsUtils.getRelationListItem(getServiceContext(),
                         docModel, getServiceContextPath());
@@ -137,12 +147,21 @@ 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);
         fillDublinCoreObject(wrapDoc); //dublincore might not be needed in future
     }
 
+    /**
+     * Fill dublin core object.
+     *
+     * @param wrapDoc the wrap doc
+     * @throws Exception the exception
+     */
     private void fillDublinCoreObject(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
         DocumentModel docModel = wrapDoc.getWrappedObject();
         //FIXME property setter should be dynamically set using schema inspection
@@ -152,6 +171,9 @@ public class RelationDocumentModelHandler
     }
 
 
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.common.document.AbstractMultipartDocumentHandlerImpl#getQProperty(java.lang.String)
+     */
     @Override
     public String getQProperty(String prop) {
         return "/" + RelationConstants.NUXEO_SCHEMA_ROOT_ELEMENT + "/" + prop;
index fef07b28ff3f38fb3dc27493cc3193d435038c23..8eabc24912b38b16d13386aa687cf99086dedb63 100644 (file)
@@ -5,5 +5,6 @@
        <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>\r
        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>\r
        <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>\r
+       <classpathentry combineaccessrules="false" kind="src" path="/org.collectionspace.services.jaxb"/>\r
        <classpathentry kind="output" path="target/classes"/>\r
 </classpath>\r
index b9bacd68cd28114c1419ffeb54c8168dd75c7c57..d5939a6a3ee01a10fda9785f01cc40e961419ecc 100644 (file)
             <groupId>org.jvnet.jaxb2_commons</groupId>
             <artifactId>runtime</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.collectionspace.services</groupId>
+            <artifactId>org.collectionspace.services.jaxb</artifactId>
+            <version>${project.version}</version>
+        </dependency>        
     </dependencies>
     <build>
         <finalName>collectionspace-services-vocabulary-jaxb</finalName>
index b165863ee386c91650ebe1558b24a77de3ddc532..a478cdd54dd4829f41498d0af0110575f4d28974 100644 (file)
 -->
 
 <xs:schema 
-  xmlns:xs="http://www.w3.org/2001/XMLSchema"
-  xmlns:ns="http://collectionspace.org/services/vocabulary"
-  xmlns="http://collectionspace.org/services/vocabulary"
-  targetNamespace="http://collectionspace.org/services/vocabulary"
-  version="0.1"
->
-
-<!--
-    Avoid XmlRootElement nightmare:
-    See http://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html
--->
-<!-- See http://wiki.collectionspace.org/display/collectionspace/Vocabulary+Schema -->    
+    xmlns:xs="http://www.w3.org/2001/XMLSchema"
+    xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
+    jaxb:version="1.0" elementFormDefault="unqualified"
+    xmlns:ns="http://collectionspace.org/services/vocabulary"
+    xmlns="http://collectionspace.org/services/vocabulary"
+    targetNamespace="http://collectionspace.org/services/vocabulary"
+    version="0.1"
+    >
+    
+    <!--
+        Avoid XmlRootElement nightmare:
+        See http://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html
+    -->
+    <!-- See http://wiki.collectionspace.org/display/collectionspace/Vocabulary+Schema -->    
     
     <!-- Vocabulary  -->
     <xs:element name="vocabularies_common">
                 <!--  Vocabulary Information Group -->
                 <xs:element name="displayName" type="xs:string"/>
                 <xs:element name="refName" type="xs:string"/>
-                <xs:element name="vocabType" type="xs:string"/>
-
+                <xs:element name="vocabType" type="xs:string"/>                
             </xs:sequence>
         </xs:complexType>
     </xs:element>
     
+    <!-- This is the base class for paginated lists -->
+    <xs:complexType name="abstractCommonList">
+        <xs:annotation>
+            <xs:appinfo>
+                <jaxb:class ref="org.collectionspace.services.jaxb.AbstractCommonList"/>
+            </xs:appinfo>
+        </xs:annotation>
+    </xs:complexType>
+    
     <!-- Vocabulary instances, as in nuxeo repository -->
     <xs:element name="vocabularies-common-list">
         <xs:complexType>
-            <xs:sequence>
-                                                               <xs:element name="pageNum" type="xs:unsignedInt" />
-                                                               <xs:element name="pageSize" type="xs:unsignedInt" />
-                                                               <xs:element name="totalItems" type="xs:unsignedInt" />
-                <xs:element name="vocabulary-list-item" maxOccurs="unbounded">
-                    <xs:complexType>
-                        <xs:sequence>
-                            <xs:element name="displayName" type="xs:string"
-                                minOccurs="1" />
-                            <xs:element name="refName" type="xs:string"
-                                minOccurs="1" />
-                            <xs:element name="vocabType" type="xs:string"
-                                minOccurs="1" />
-                            <!-- uri to retrieve vocabulary details -->
-                            <xs:element name="uri" type="xs:anyURI"
-                                minOccurs="1" />
-                            <xs:element name="csid" type="xs:string"
-                                minOccurs="1" />
-                        </xs:sequence>
-                    </xs:complexType>
-                </xs:element>
-            </xs:sequence>
+            <xs:complexContent>
+                <xs:extension base="abstractCommonList">                    
+                    <xs:sequence>
+                        <xs:element name="vocabulary-list-item" maxOccurs="unbounded">
+                            <xs:complexType>
+                                <xs:sequence>
+                                    <xs:element name="displayName" type="xs:string"
+                                        minOccurs="1" />
+                                    <xs:element name="refName" type="xs:string"
+                                        minOccurs="1" />
+                                    <xs:element name="vocabType" type="xs:string"
+                                        minOccurs="1" />
+                                    <!-- uri to retrieve vocabulary details -->
+                                    <xs:element name="uri" type="xs:anyURI"
+                                        minOccurs="1" />
+                                    <xs:element name="csid" type="xs:string"
+                                        minOccurs="1" />
+                                </xs:sequence>
+                            </xs:complexType>
+                        </xs:element>
+                    </xs:sequence>
+                </xs:extension>
+            </xs:complexContent>                    
         </xs:complexType>
     </xs:element>
-
+    
 </xs:schema>
 
index 8c01a3f27a19d0ff912ed16b7dc2447e784289bf..fe732caceb76ba883a04b3d476ded3e2503d0a80 100644 (file)
@@ -1,6 +1,8 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <xs:schema 
   xmlns:xs="http://www.w3.org/2001/XMLSchema"
+  xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
+  jaxb:version="1.0" elementFormDefault="unqualified"  
   xmlns:ns="http://collectionspace.org/services/vocabulary"
   xmlns="http://collectionspace.org/services/vocabulary"
   targetNamespace="http://collectionspace.org/services/vocabulary"
         </xs:complexType>
     </xs:element>
     
+    <!-- This is the base class for paginated lists -->
+    <xs:complexType name="abstractCommonListItem">
+        <xs:annotation>
+            <xs:appinfo>
+                <jaxb:class ref="org.collectionspace.services.jaxb.AbstractCommonList"/>
+            </xs:appinfo>
+        </xs:annotation>
+    </xs:complexType>
+
     <!-- Vocabularyitem instances, as in nuxeo repository -->
     <xs:element name="vocabularyitems-common-list">
         <xs:complexType>
-            <xs:sequence>
-                                                               <xs:element name="pageNum" type="xs:unsignedInt" />
-                                                               <xs:element name="pageSize" type="xs:unsignedInt" />
-                                                               <xs:element name="totalItems" type="xs:unsignedInt" />
-                 <xs:element name="vocabularyitem_list_item" maxOccurs="unbounded">
-                    <xs:complexType>
-                        <xs:sequence>
-                            <xs:element name="displayName" type="xs:string"
-                                minOccurs="1" />
-                            <!-- uri to retrieve vocabularyitem details -->
-                            <xs:element name="uri" type="xs:anyURI"
-                                minOccurs="1" />
-                            <xs:element name="refName" type="xs:string"
-                                minOccurs="1" />
-                            <xs:element name="csid" type="xs:string"
-                                minOccurs="1" />
-                        </xs:sequence>
-                    </xs:complexType>
-                </xs:element>
-            </xs:sequence>
+            <xs:complexContent>
+                <xs:extension base="abstractCommonListItem">                                        
+                    <xs:sequence>
+                        <xs:element name="vocabularyitem_list_item" maxOccurs="unbounded">
+                            <xs:complexType>
+                                <xs:sequence>
+                                    <xs:element name="displayName" type="xs:string"
+                                        minOccurs="1" />
+                                    <!-- uri to retrieve vocabularyitem details -->
+                                    <xs:element name="uri" type="xs:anyURI"
+                                        minOccurs="1" />
+                                    <xs:element name="refName" type="xs:string"
+                                        minOccurs="1" />
+                                    <xs:element name="csid" type="xs:string"
+                                        minOccurs="1" />
+                                </xs:sequence>
+                            </xs:complexType>
+                        </xs:element>
+                    </xs:sequence>
+                </xs:extension>
+            </xs:complexContent>                    
         </xs:complexType>
     </xs:element>
     
index 9aa292ba1116868e5537a327aa7c427b2c2966fe..2b22d6bdec7693f05c74a740211d39ace40ff051 100644 (file)
@@ -50,6 +50,7 @@ import org.slf4j.LoggerFactory;
 public class VocabularyDocumentModelHandler
         extends RemoteDocumentModelHandlerImpl<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
@@ -90,44 +91,40 @@ public class VocabularyDocumentModelHandler
         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 {
-        DocumentModelList docList = wrapDoc.getWrappedObject();
-
-        VocabulariesCommonList coList = new VocabulariesCommonList();
+    public VocabulariesCommonList extractCommonPartList(
+               DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
+        VocabulariesCommonList coList = extractPagingInfo(new VocabulariesCommonList(), wrapDoc);
         List<VocabulariesCommonList.VocabularyListItem> list = coList.getVocabularyListItem();
-
-        DocumentFilter filter = getDocumentFilter();
-        long pageNum, pageSize;
-        if(filter==null) {
-               pageNum = 0;
-               pageSize = 0;
-        } else {
-               pageSize = filter.getPageSize();
-               pageNum = filter.getOffset()/pageSize;
-        }
-        coList.setPageNum(pageNum);
-        coList.setPageSize(pageSize);
-       coList.setTotalItems(docList.totalSize());
-        //FIXME: iterating over a long list of documents is not a long term
-        //strategy...need to change to more efficient iterating in future
-        Iterator<DocumentModel> iter = docList.iterator();
+        Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
         while(iter.hasNext()){
             DocumentModel docModel = iter.next();
             VocabularyListItem ilistItem = new VocabularyListItem();
index f163ac4be40bfff2132389a394bbf8f87ccfd576..9609083b39a43754047a7d23a803b253c1a8d11f 100644 (file)
@@ -118,51 +118,30 @@ public class VocabularyItemDocumentModelHandler
     }
 
     @Override
-    public VocabularyitemsCommonList extractCommonPartList(DocumentWrapper wrapDoc) 
-       throws Exception {
-        VocabularyitemsCommonList coList = new VocabularyitemsCommonList();
-        try{
-               DocumentModelList docList = (DocumentModelList) wrapDoc.getWrappedObject();
-       
-               List<VocabularyitemsCommonList.VocabularyitemListItem> list = 
-                       coList.getVocabularyitemListItem();
-       
-               DocumentFilter filter = getDocumentFilter();
-               long pageNum, pageSize;
-               if(filter==null) {
-                       pageNum = 0;
-                       pageSize = 0;
-               } else {
-                       pageSize = filter.getPageSize();
-                       pageNum = filter.getOffset()/pageSize;
-               }
-               coList.setPageNum(pageNum);
-               coList.setPageSize(pageSize);
-               coList.setTotalItems(docList.totalSize());
-               //FIXME: iterating over a long list of documents is not a long term
-               //strategy...need to change to more efficient iterating in future
-               Iterator<DocumentModel> iter = docList.iterator();
-               while(iter.hasNext()){
-                   DocumentModel docModel = iter.next();
-                   VocabularyitemListItem ilistItem = new VocabularyitemListItem();
-                   ilistItem.setDisplayName(
-                                                                       (String) docModel.getProperty(getServiceContext().getCommonPartLabel("vocabularyItems"),
-                                                                       VocabularyItemJAXBSchema.DISPLAY_NAME));
-                   ilistItem.setRefName(
-                                                                       (String) docModel.getProperty(getServiceContext().getCommonPartLabel("vocabularyItems"),
-                                                                       VocabularyItemJAXBSchema.REF_NAME));
-                                                       String id = NuxeoUtils.extractId(docModel.getPathAsString());
-                   ilistItem.setUri("/vocabularies/"+inVocabulary+"/items/" + id);
-                   ilistItem.setCsid(id);
-                   list.add(ilistItem);
-               }
-        }catch(Exception e){
-            if(logger.isDebugEnabled()){
-                logger.debug("Caught exception in extractCommonPartList", e);
-            }
-            throw e;
-        }
-        return coList;
+       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()) {
+                       DocumentModel docModel = iter.next();
+                       VocabularyitemListItem ilistItem = new VocabularyitemListItem();
+                       ilistItem.setDisplayName((String) docModel.getProperty(
+                                       getServiceContext().getCommonPartLabel("vocabularyItems"),
+                                       VocabularyItemJAXBSchema.DISPLAY_NAME));
+                       ilistItem.setRefName((String) docModel.getProperty(
+                                       getServiceContext().getCommonPartLabel("vocabularyItems"),
+                                       VocabularyItemJAXBSchema.REF_NAME));
+                       String id = NuxeoUtils.extractId(docModel.getPathAsString());
+                       ilistItem.setUri("/vocabularies/" + inVocabulary + "/items/" + id);
+                       ilistItem.setCsid(id);
+                       list.add(ilistItem);
+               }
+
+               return coList;
     }
 
     /**