]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-3332, CSPACE-3784 Updated Movement to use DocHandlerBase. Refactored some...
authorPatrick Schmitz <pschmitz@berkeley.edu>
Fri, 22 Jul 2011 19:44:36 +0000 (19:44 +0000)
committerPatrick Schmitz <pschmitz@berkeley.edu>
Fri, 22 Jul 2011 19:44:36 +0000 (19:44 +0000)
15 files changed:
services/acquisition/client/src/test/java/org/collectionspace/services/client/test/AcquisitionServiceTest.java
services/client/src/main/java/org/collectionspace/services/client/test/AbstractServiceTestImpl.java
services/common/src/main/java/org/collectionspace/services/common/AbstractCommonListUtils.java [new file with mode: 0644]
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteDocumentModelHandlerImpl.java
services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeServiceTest.java
services/loanin/client/src/test/java/org/collectionspace/services/client/test/LoaninServiceTest.java
services/loanout/client/src/test/java/org/collectionspace/services/client/test/LoanoutServiceTest.java
services/movement/client/src/main/java/org/collectionspace/services/client/MovementClient.java
services/movement/client/src/main/java/org/collectionspace/services/client/MovementProxy.java
services/movement/client/src/test/java/org/collectionspace/services/client/test/MovementServiceTest.java
services/movement/client/src/test/java/org/collectionspace/services/client/test/MovementSortByTest.java
services/movement/jaxb/src/main/resources/movements-common.xsd
services/movement/service/src/main/java/org/collectionspace/services/movement/nuxeo/MovementDocumentModelHandler.java
services/objectexit/client/src/test/java/org/collectionspace/services/client/test/ObjectExitServiceTest.java
services/report/client/src/test/java/org/collectionspace/services/client/test/ReportServiceTest.java

index 2bc8e65ce23e5dcc8405549b0cafc8c6c5c29e23..c43ef9ec794155d235464dc556e946f53959c868 100644 (file)
@@ -31,6 +31,7 @@ import org.collectionspace.services.client.CollectionSpaceClient;
 import org.collectionspace.services.client.PayloadOutputPart;
 import org.collectionspace.services.client.PoxPayloadIn;
 import org.collectionspace.services.client.PoxPayloadOut;
+import org.collectionspace.services.common.AbstractCommonListUtils;
 import org.collectionspace.services.jaxb.AbstractCommonList;
 
 import org.collectionspace.services.acquisition.AcquisitionsCommon;
@@ -81,15 +82,6 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl {
        return new AcquisitionClient();
     }
     
-    /* (non-Javadoc)
-     * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
-     */
-    @Override
-       protected AbstractCommonList getAbstractCommonList(
-                       ClientResponse<AbstractCommonList> response) {
-        return response.getEntity(AbstractCommonList.class);
-    }
-
     // ---------------------------------------------------------------
     // CRUD tests : CREATE tests
     // ---------------------------------------------------------------
@@ -412,9 +404,8 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl {
         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
 
         // Optionally output additional data about list members for debugging.
-        boolean iterateThroughList = true;
-        if(iterateThroughList && logger.isDebugEnabled()){
-               ListItemsInAbstractCommonList(list, logger, testName);
+        if(logger.isTraceEnabled()){
+               AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
         }
 
     }
index d9423b90d78128dad2951bdc43b9e6e1ca9b6c43..4363ffaa8e34f0e1be48ea1ba3d958cf0d414659 100644 (file)
@@ -96,35 +96,6 @@ public abstract class AbstractServiceTestImpl extends BaseServiceTest implements
 
     }
     
-    protected void ListItemsInAbstractCommonList(
-               AbstractCommonList list, Logger logger, String testName) {
-       List<AbstractCommonList.ListItem> items =
-               list.getListItem();
-       int i = 0;
-       for(AbstractCommonList.ListItem item : items){
-               List<Element> elList = item.getAny();
-               StringBuilder elementStrings = new StringBuilder();
-               for(Element el : elList) {
-                       Node textEl = el.getFirstChild();
-                               elementStrings.append("["+el.getNodeName()+":"+((textEl!=null)?textEl.getNodeValue():"NULL")+"] ");
-               }
-               logger.debug(testName + ": list-item[" + i + "]: "+elementStrings.toString());
-               i++;
-       }
-    }
-
-    protected static String ListItemGetCSID(AbstractCommonList.ListItem item) {
-               List<Element> elList = item.getAny();
-               for(Element el : elList) {
-                       if("csid".equalsIgnoreCase(el.getNodeName())) {
-                       Node textEl = el.getFirstChild();
-                       return textEl.getNodeValue();
-                       }
-               }
-               return null;
-       }
-
-
     /* Use this to keep track of resources to delete */
     protected List<String> allResourceIdsCreated = new ArrayList<String>();
     /* Use this to track authority items */
diff --git a/services/common/src/main/java/org/collectionspace/services/common/AbstractCommonListUtils.java b/services/common/src/main/java/org/collectionspace/services/common/AbstractCommonListUtils.java
new file mode 100644 (file)
index 0000000..8430e56
--- /dev/null
@@ -0,0 +1,46 @@
+package org.collectionspace.services.common;\r
+\r
+import java.util.List;\r
+\r
+import org.collectionspace.services.jaxb.AbstractCommonList;\r
+import org.slf4j.Logger;\r
+import org.w3c.dom.Element;\r
+import org.w3c.dom.Node;\r
+\r
+public class AbstractCommonListUtils {\r
+    public static void ListItemsInAbstractCommonList(\r
+               AbstractCommonList list, Logger logger, String testName) {\r
+       List<AbstractCommonList.ListItem> items =\r
+               list.getListItem();\r
+       int i = 0;\r
+       for(AbstractCommonList.ListItem item : items){\r
+               List<Element> elList = item.getAny();\r
+               StringBuilder elementStrings = new StringBuilder();\r
+               for(Element el : elList) {\r
+                       Node textEl = el.getFirstChild();\r
+                               elementStrings.append("["+el.getNodeName()+":"+((textEl!=null)?textEl.getNodeValue():"NULL")+"] ");\r
+               }\r
+               logger.debug(testName + ": list-item[" + i + "]: "+elementStrings.toString());\r
+               i++;\r
+       }\r
+    }\r
+\r
+    public static String ListItemGetCSID(AbstractCommonList.ListItem item) {\r
+               return ListItemGetElementValue(item, "csid");\r
+       }\r
+\r
+    public static String ListItemGetElementValue(AbstractCommonList.ListItem item,\r
+               String elName) {\r
+               List<Element> elList = item.getAny();\r
+               for(Element el : elList) {\r
+                       if(elName.equalsIgnoreCase(el.getNodeName())) {\r
+                       Node textEl = el.getFirstChild();\r
+                       return textEl.getNodeValue();\r
+                       }\r
+               }\r
+               return null;\r
+       }\r
+\r
+\r
+\r
+}\r
index d4fb4359663113f4c8c5702e09efb1238acc43bf..7bf5fa25d8f6044aa00aef65bdfa06780b035349 100644 (file)
@@ -23,8 +23,8 @@
  */
 package org.collectionspace.services.nuxeo.client.java;
 
-import java.io.InputStream;
 import java.util.Collection;
+import java.util.GregorianCalendar;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -43,26 +43,21 @@ import org.collectionspace.services.client.PoxPayloadIn;
 import org.collectionspace.services.client.PoxPayloadOut;
 import org.collectionspace.services.client.workflow.WorkflowClient;
 import org.collectionspace.services.common.authorityref.AuthorityRefList;
-import org.collectionspace.services.common.authorization_mgt.AuthorizationCommon;
 import org.collectionspace.services.common.context.JaxRsContext;
 import org.collectionspace.services.common.context.MultipartServiceContext;
 import org.collectionspace.services.common.context.ServiceContext;
+import org.collectionspace.services.common.datetime.DateTimeFormatUtils;
 import org.collectionspace.services.common.document.BadRequestException;
-import org.collectionspace.services.common.document.DocumentNotFoundException;
 import org.collectionspace.services.common.document.DocumentUtils;
 import org.collectionspace.services.common.document.DocumentWrapper;
 import org.collectionspace.services.common.document.DocumentFilter;
 import org.collectionspace.services.common.document.DocumentHandler.Action;
 import org.collectionspace.services.common.security.SecurityUtils;
-import org.collectionspace.services.common.security.UnauthorizedException;
 import org.collectionspace.services.common.service.ObjectPartType;
 import org.collectionspace.services.common.storage.jpa.JpaStorageUtils;
 import org.collectionspace.services.common.vocabulary.RefNameUtils;
 import org.dom4j.Element;
 
-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.Property;
@@ -72,7 +67,6 @@ import org.nuxeo.ecm.core.schema.types.Schema;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.dom4j.Document;
 
 /**
  * RemoteDocumentModelHandler
@@ -273,8 +267,6 @@ public abstract class   RemoteDocumentModelHandlerImpl<T, TL>
             throws Exception {
         //check if this is an xml part
         if (part.getMediaType().equals(MediaType.APPLICATION_XML_TYPE)) {
-//                Document document = DocumentUtils.parseDocument(payload, partMeta,
-//                        false /*don't validate*/);
                Element element = part.getElementBody();
             Map<String, Object> objectProps = DocumentUtils.parseProperties(partMeta, element, ctx);
                 if (action == Action.UPDATE) {
@@ -681,7 +673,16 @@ public abstract class   RemoteDocumentModelHandlerImpl<T, TL>
     protected static String getXPathStringValue(DocumentModel docModel, String schema, String xpath) {
        xpath = schema+":"+xpath;
        try {
-               return (String)docModel.getPropertyValue(xpath);
+               Object value = docModel.getPropertyValue(xpath);
+               String returnVal = null;
+               if(value==null) {
+                       // Nothing to do - leave returnVal null
+               } else if(value instanceof GregorianCalendar) {
+                       returnVal = DateTimeFormatUtils.formatAsISO8601Timestamp((GregorianCalendar)value);
+               } else {
+                       returnVal = value.toString();
+               }
+               return returnVal;
        } catch(PropertyException pe) {
                throw new RuntimeException("Problem retrieving property {"+xpath+"}. Bad XPath spec?"
                                +pe.getLocalizedMessage());
index 766d0c5b92267806df16bd157227e2c35485916c..534c1e5766e5546fe0590558d596820a2b2afa22 100644 (file)
@@ -32,6 +32,7 @@ import org.collectionspace.services.client.PayloadInputPart;
 import org.collectionspace.services.client.PayloadOutputPart;
 import org.collectionspace.services.client.PoxPayloadIn;
 import org.collectionspace.services.client.PoxPayloadOut;
+import org.collectionspace.services.common.AbstractCommonListUtils;
 import org.collectionspace.services.intake.EntryMethodList;
 import org.collectionspace.services.intake.FieldCollectionEventNameList;
 import org.collectionspace.services.intake.CurrentLocationGroup;
@@ -410,7 +411,7 @@ public class IntakeServiceTest extends AbstractServiceTestImpl {
         // Optionally output additional data about list members for debugging.
         boolean iterateThroughList = true;
         if (iterateThroughList && logger.isDebugEnabled()) {
-            ListItemsInAbstractCommonList(list, logger, testName);
+            AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
         }
 
     }
index af9b62c68c26d5aa15f1b2c5b60d07020c0e319b..a101f882307788277cb52d478cf0867a44aad9e2 100644 (file)
@@ -33,6 +33,7 @@ import org.collectionspace.services.client.PayloadInputPart;
 import org.collectionspace.services.client.PayloadOutputPart;
 import org.collectionspace.services.client.PoxPayloadIn;
 import org.collectionspace.services.client.PoxPayloadOut;
+import org.collectionspace.services.common.AbstractCommonListUtils;
 import org.collectionspace.services.jaxb.AbstractCommonList;
 import org.collectionspace.services.loanin.LenderGroup;
 import org.collectionspace.services.loanin.LenderGroupList;
@@ -420,7 +421,7 @@ public class LoaninServiceTest extends AbstractServiceTestImpl {
         // Optionally output additional data about list members for debugging.
         boolean iterateThroughList = true;
         if(iterateThroughList && logger.isDebugEnabled()){
-               ListItemsInAbstractCommonList(list, logger, testName);
+               AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
         }
 
     }
index 8d8a993f875514c673b112fbe914beace8d6bdfb..960397b6468a3d7472fa1f6eda3e885c6763a453 100644 (file)
@@ -32,6 +32,7 @@ import org.collectionspace.services.client.PayloadInputPart;
 import org.collectionspace.services.client.PayloadOutputPart;
 import org.collectionspace.services.client.PoxPayloadIn;
 import org.collectionspace.services.client.PoxPayloadOut;
+import org.collectionspace.services.common.AbstractCommonListUtils;
 import org.collectionspace.services.jaxb.AbstractCommonList;
 import org.collectionspace.services.loanout.LoanedObjectStatusGroup;
 import org.collectionspace.services.loanout.LoanedObjectStatusGroupList;
@@ -387,7 +388,7 @@ public class LoanoutServiceTest extends AbstractServiceTestImpl {
         // Optionally output additional data about list members for debugging.
         boolean iterateThroughList = true;
         if(iterateThroughList && logger.isDebugEnabled()){
-               ListItemsInAbstractCommonList(list, logger, testName);
+               AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
         }
 
     }
index fe0a52ae441871eccac692ceac689fb11ca8e708..544d0fcf604a5ed4f444f9280b9e664a8f8ff52f 100644 (file)
@@ -17,8 +17,8 @@
 
 package org.collectionspace.services.client;
 
+import org.collectionspace.services.jaxb.AbstractCommonList;
 import org.jboss.resteasy.client.ClientResponse;
-import org.collectionspace.services.movement.MovementsCommonList;
 
 /**
  * MovementClient.java
@@ -27,7 +27,7 @@ import org.collectionspace.services.movement.MovementsCommonList;
  * $LastChangedDate$
  *
  */
-public class MovementClient extends AbstractPoxServiceClientImpl<MovementsCommonList, MovementProxy> {
+public class MovementClient extends AbstractCommonListPoxServiceClientImpl<MovementProxy> {
     public static final String SERVICE_NAME = "movements";
        public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;       
        public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT;
@@ -49,24 +49,13 @@ public class MovementClient extends AbstractPoxServiceClientImpl<MovementsCommon
                return MovementProxy.class;
        }
 
-       /*
-        * Proxied service calls
-        */
-       
-    /**
-     * @return
-     * @see org.collectionspace.services.client.MovementProxy#readList()
-     */
-    public ClientResponse<MovementsCommonList> readList() {
-        return getProxy().readList();
-    }
 
     /**
      * @param sortFieldName
      * @return
      * @see org.collectionspace.services.client.MovementProxy#readList(java.lang.String)
      */
-    public ClientResponse<MovementsCommonList> readListSortedBy(String sortFieldName) {
+    public ClientResponse<AbstractCommonList> readListSortedBy(String sortFieldName) {
         return getProxy().readListSortedBy(sortFieldName);
     }
 
@@ -76,7 +65,7 @@ public class MovementClient extends AbstractPoxServiceClientImpl<MovementsCommon
      * @return
      * @see org.collectionspace.services.client.MovementProxy#keywordSearchSortedBy(java.lang.String, java.lang.String)
      */
-    public ClientResponse<MovementsCommonList> keywordSearchSortedBy(String keywords, String sortFieldName) {
+    public ClientResponse<AbstractCommonList> keywordSearchSortedBy(String keywords, String sortFieldName) {
         return getProxy().keywordSearchSortedBy(keywords, sortFieldName);
     }    
 }
index bdaf3a2c8f07c4b3b323d1955ef11c9d6f3902fb..3c8ed92ff5d715408324aff257c4b1e1beb4c1a9 100644 (file)
@@ -32,7 +32,7 @@ import javax.ws.rs.Produces;
 import javax.ws.rs.QueryParam;
 
 import org.collectionspace.services.client.workflow.WorkflowClient;
-import org.collectionspace.services.movement.MovementsCommonList;
+import org.collectionspace.services.jaxb.AbstractCommonList;
 
 /**
  * MovementProxy.java
@@ -43,35 +43,30 @@ import org.collectionspace.services.movement.MovementsCommonList;
 @Path("/movements/")
 @Produces("application/xml")
 @Consumes("application/xml")
-public interface MovementProxy extends CollectionSpacePoxProxy<MovementsCommonList> {
+public interface MovementProxy extends CollectionSpaceCommonListPoxProxy {
 
-    // List
-    @GET
-    @Produces({"application/xml"})
-    ClientResponse<MovementsCommonList> readList();
-    
     // Sorted list
     @GET
     @Produces({"application/xml"})
-    ClientResponse<MovementsCommonList> readListSortedBy(
+    ClientResponse<AbstractCommonList> readListSortedBy(
         @QueryParam(IClientQueryParams.SORT_BY_PARAM) String sortFieldName);
     
     @Override
        @GET
     @Produces({"application/xml"})
-    ClientResponse<MovementsCommonList> readIncludeDeleted(
+    ClientResponse<AbstractCommonList> readIncludeDeleted(
             @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted);
 
     @Override
     @GET
     @Produces({"application/xml"})
-    ClientResponse<MovementsCommonList> keywordSearchIncludeDeleted(
+    ClientResponse<AbstractCommonList> keywordSearchIncludeDeleted(
                @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords,
             @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted);
 
     @GET
     @Produces({"application/xml"})
-    ClientResponse<MovementsCommonList> keywordSearchSortedBy(
+    ClientResponse<AbstractCommonList> keywordSearchSortedBy(
         @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords,
         @QueryParam(IClientQueryParams.SORT_BY_PARAM) String sortFieldName);
 }
index c550bedb33a7a7314adb29863e56a5679fd08b97..a2619f28de619ad9ee0c148973b81985bcd1efd0 100644 (file)
@@ -31,12 +31,12 @@ import java.util.TimeZone;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 
+import org.collectionspace.services.common.AbstractCommonListUtils;
 import org.collectionspace.services.common.datetime.GregorianCalendarDateTimeUtils;
 import org.collectionspace.services.client.CollectionSpaceClient;
 import org.collectionspace.services.client.MovementClient;
 import org.collectionspace.services.jaxb.AbstractCommonList;
 import org.collectionspace.services.movement.MovementsCommon;
-import org.collectionspace.services.movement.MovementsCommonList;
 import org.collectionspace.services.movement.MovementMethodsList;
 
 import org.jboss.resteasy.client.ClientResponse;
@@ -79,15 +79,6 @@ public class MovementServiceTest extends AbstractServiceTestImpl {
        return new MovementClient();
     }
     
-    /* (non-Javadoc)
-     * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
-     */
-    @Override
-       protected AbstractCommonList getAbstractCommonList(
-                       ClientResponse<AbstractCommonList> response) {
-        return response.getEntity(MovementsCommonList.class);
-    }
     // ---------------------------------------------------------------
     // CRUD tests : CREATE tests
     // ---------------------------------------------------------------
@@ -383,8 +374,8 @@ public class MovementServiceTest extends AbstractServiceTestImpl {
 
         // Submit the request to the service and store the response.
         MovementClient client = new MovementClient();
-        ClientResponse<MovementsCommonList> res = client.readList();
-        MovementsCommonList list = res.getEntity();
+        ClientResponse<AbstractCommonList> res = client.readList();
+        AbstractCommonList list = res.getEntity();
         int statusCode = res.getStatus();
 
         // Check the status code of the response: does it match
@@ -397,24 +388,9 @@ public class MovementServiceTest extends AbstractServiceTestImpl {
         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
 
         // Optionally output additional data about list members for debugging.
-        boolean iterateThroughList = true;
-        if(iterateThroughList && logger.isDebugEnabled()){
-            List<MovementsCommonList.MovementListItem> items =
-                    list.getMovementListItem();
-            int i = 0;
-            for(MovementsCommonList.MovementListItem item : items){
-                logger.debug(testName + ": list-item[" + i + "] csid=" +
-                        item.getCsid());
-                logger.debug(testName + ": list-item[" + i + "] movementReferenceNumber=" +
-                        item.getMovementReferenceNumber());
-                logger.debug(testName + ": list-item[" + i + "] locationDate=" +
-                        item.getLocationDate());
-                logger.debug(testName + ": list-item[" + i + "] URI=" +
-                        item.getUri());
-                i++;
-            }
+        if(logger.isTraceEnabled()){
+               AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
         }
-
     }
 
     // Failure outcomes
index ab59c59008d3e9e511a86f3a7acf2531f1da682f..c2c8a795401e50b73be69fb2afe198804cd66500 100644 (file)
@@ -37,8 +37,8 @@ import org.collectionspace.services.client.PayloadInputPart;
 import org.collectionspace.services.client.PayloadOutputPart;
 import org.collectionspace.services.client.PoxPayloadIn;
 import org.collectionspace.services.client.PoxPayloadOut;
+import org.collectionspace.services.common.AbstractCommonListUtils;
 import org.collectionspace.services.movement.MovementsCommon;
-import org.collectionspace.services.movement.MovementsCommonList;
 import org.collectionspace.services.jaxb.AbstractCommonList;
 
 import org.jboss.resteasy.client.ClientResponse;
@@ -72,6 +72,7 @@ public class MovementSortByTest extends BaseServiceTest {
     private List<String> movementIdsCreated = new ArrayList<String>();
     private final String SORT_FIELD_SEPARATOR = ", ";
     private final Locale LOCALE = Locale.US;
+    private final String LOCATION_DATE_EL_NAME = "locationDate";
 
     /* (non-Javadoc)
      * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
@@ -112,20 +113,20 @@ public class MovementSortByTest extends BaseServiceTest {
         if (logger.isDebugEnabled()) {
             logger.debug("Sorting on field name=" + sortFieldName);
         }
-        MovementsCommonList list = readSortedList(sortFieldName);
-        List<MovementsCommonList.MovementListItem> items =
-                list.getMovementListItem();
+        AbstractCommonList list = readSortedList(sortFieldName);
+        List<AbstractCommonList.ListItem> items =
+                list.getListItem();
 
         ArrayList<String> values = new ArrayList<String>();
         Collator localeSpecificCollator = Collator.getInstance(LOCALE);
         int i = 0;
-        for (MovementsCommonList.MovementListItem item : items) {
+        for (AbstractCommonList.ListItem item : items) {
             // Because movementNote is not currently a summary field
             // (returned in summary list items), we will need to verify
             // sort order by retrieving full records, using the
             // IDs provided in the summary list items. amd then retriving
             // the value of that field from each of those records.
-            MovementsCommon movement = read(item.getCsid());
+            MovementsCommon movement = read(AbstractCommonListUtils.ListItemGetCSID(item));
             values.add(i, movement.getMovementNote());
             if (logger.isDebugEnabled()) {
                 logger.debug("list-item[" + i + "] movementNote=" + values.get(i));
@@ -165,20 +166,20 @@ public class MovementSortByTest extends BaseServiceTest {
         if (logger.isDebugEnabled()) {
             logger.debug("Sorting on field name=" + sortFieldName);
         }
-        MovementsCommonList list = keywordSearchSortedBy(TEST_SPECIFIC_KEYWORD, sortFieldName);
-        List<MovementsCommonList.MovementListItem> items =
-                list.getMovementListItem();
+        AbstractCommonList list = keywordSearchSortedBy(TEST_SPECIFIC_KEYWORD, sortFieldName);
+        List<AbstractCommonList.ListItem> items =
+                list.getListItem();
 
         ArrayList<String> values = new ArrayList<String>();
         Collator localeSpecificCollator = Collator.getInstance(LOCALE);
         int i = 0;
-        for (MovementsCommonList.MovementListItem item : items) {
+        for (AbstractCommonList.ListItem item : items) {
             // Because movementNote is not currently a summary field
             // (returned in summary list items), we will need to verify
             // sort order by retrieving full records, using the
             // IDs provided in the summary list items. amd then retriving
             // the value of that field from each of those records.
-            MovementsCommon movement = read(item.getCsid());
+            MovementsCommon movement = read(AbstractCommonListUtils.ListItemGetCSID(item));
             values.add(i, movement.getMovementNote());
             if (logger.isDebugEnabled()) {
                 logger.debug("list-item[" + i + "] movementNote=" + values.get(i));
@@ -216,20 +217,20 @@ public class MovementSortByTest extends BaseServiceTest {
         if (logger.isDebugEnabled()) {
             logger.debug("Sorting on field name=" + sortFieldName);
         }
-        MovementsCommonList list = readSortedList(sortFieldName);
-        List<MovementsCommonList.MovementListItem> items =
-                list.getMovementListItem();
+        AbstractCommonList list = readSortedList(sortFieldName);
+        List<AbstractCommonList.ListItem> items =
+                list.getListItem();
 
         ArrayList<String> values = new ArrayList<String>();
         Collator localeSpecificCollator = Collator.getInstance(LOCALE);
         int i = 0;
-        for (MovementsCommonList.MovementListItem item : items) {
+        for (AbstractCommonList.ListItem item : items) {
             // Because movementNote is not currently a summary field
             // (returned in summary list items), we will need to verify
             // sort order by retrieving full records, using the
             // IDs provided in the summary list items. amd then retriving
             // the value of that field from each of those records.
-            MovementsCommon movement = read(item.getCsid());
+            MovementsCommon movement = read(AbstractCommonListUtils.ListItemGetCSID(item));
             values.add(i, movement.getMovementNote());
             if (logger.isDebugEnabled()) {
                 logger.debug("list-item[" + i + "] movementNote=" + values.get(i));
@@ -266,15 +267,17 @@ public class MovementSortByTest extends BaseServiceTest {
         if (logger.isDebugEnabled()) {
             logger.debug("Sorting on field name=" + sortFieldName);
         }
-        MovementsCommonList list = readSortedList(sortFieldName);
-        List<MovementsCommonList.MovementListItem> items =
-                list.getMovementListItem();
+        AbstractCommonList list = readSortedList(sortFieldName);
+        List<AbstractCommonList.ListItem> items =
+                list.getListItem();
 
         ArrayList<String> values = new ArrayList<String>();
         Comparator<String> comparator = String.CASE_INSENSITIVE_ORDER;
         int i = 0;
-        for (MovementsCommonList.MovementListItem item : items) {
-            values.add(i, item.getLocationDate());
+        for (AbstractCommonList.ListItem item : items) {
+               String locDate = 
+                       AbstractCommonListUtils.ListItemGetElementValue(item, LOCATION_DATE_EL_NAME);
+               values.add(i, locDate);
             if (logger.isDebugEnabled()) {
                 logger.debug("list-item[" + i + "] locationDate=" + values.get(i));
             }
@@ -304,15 +307,17 @@ public class MovementSortByTest extends BaseServiceTest {
         if (logger.isDebugEnabled()) {
             logger.debug("Sorting on field name=" + sortFieldName);
         }
-        MovementsCommonList list = readSortedList(sortFieldName);
-        List<MovementsCommonList.MovementListItem> items =
-                list.getMovementListItem();
+        AbstractCommonList list = readSortedList(sortFieldName);
+        List<AbstractCommonList.ListItem> items =
+                list.getListItem();
 
         ArrayList<String> values = new ArrayList<String>();
         Comparator<String> comparator = String.CASE_INSENSITIVE_ORDER;
         int i = 0;
-        for (MovementsCommonList.MovementListItem item : items) {
-            values.add(i, item.getLocationDate());
+        for (AbstractCommonList.ListItem item : items) {
+               String locDate = 
+                       AbstractCommonListUtils.ListItemGetElementValue(item, LOCATION_DATE_EL_NAME);
+               values.add(i, locDate);
             if (logger.isDebugEnabled()) {
                 logger.debug("list-item[" + i + "] locationDate=" + values.get(i));
             }
@@ -343,22 +348,22 @@ public class MovementSortByTest extends BaseServiceTest {
             logger.debug("Sorting on field names=" + firstSortFieldName + " and " + secondSortFieldName);
         }
         String sortExpression = firstSortFieldName + SORT_FIELD_SEPARATOR + secondSortFieldName;
-        MovementsCommonList list = readSortedList(sortExpression);
-        List<MovementsCommonList.MovementListItem> items =
-                list.getMovementListItem();
+        AbstractCommonList list = readSortedList(sortExpression);
+        List<AbstractCommonList.ListItem> items =
+                list.getListItem();
 
         ArrayList<String> firstFieldValues = new ArrayList<String>();
         ArrayList<String> secondFieldValues = new ArrayList<String>();
         Collator localeSpecificCollator = Collator.getInstance(LOCALE);
         Comparator<String> comparator = String.CASE_INSENSITIVE_ORDER;
         int i = 0;
-        for (MovementsCommonList.MovementListItem item : items) {
+        for (AbstractCommonList.ListItem item : items) {
             // Because movementNote is not currently a summary field
             // (returned in summary list items), we will need to verify
             // sort order by retrieving full records, using the
             // IDs provided in the summary list items. amd then retriving
             // the value of that field from each of those records.
-            MovementsCommon movement = read(item.getCsid());
+            MovementsCommon movement = read(AbstractCommonListUtils.ListItemGetCSID(item));
             firstFieldValues.add(i, movement.getMovementNote());
             secondFieldValues.add(i, movement.getLocationDate());
             if (logger.isDebugEnabled()) {
@@ -402,22 +407,22 @@ public class MovementSortByTest extends BaseServiceTest {
             logger.debug("Sorting on field names=" + firstSortFieldName + " and " + secondSortFieldName);
         }
         String sortExpression = firstSortFieldName + SORT_FIELD_SEPARATOR + secondSortFieldName;
-        MovementsCommonList list = readSortedList(sortExpression);
-        List<MovementsCommonList.MovementListItem> items =
-                list.getMovementListItem();
+        AbstractCommonList list = readSortedList(sortExpression);
+        List<AbstractCommonList.ListItem> items =
+                list.getListItem();
 
         ArrayList<String> firstFieldValues = new ArrayList<String>();
         ArrayList<String> secondFieldValues = new ArrayList<String>();
         Collator localeSpecificCollator = Collator.getInstance(LOCALE);
         Comparator<String> comparator = String.CASE_INSENSITIVE_ORDER;
         int i = 0;
-        for (MovementsCommonList.MovementListItem item : items) {
+        for (AbstractCommonList.ListItem item : items) {
             // Because movementNote is not currently a summary field
             // (returned in summary list items), we will need to verify
             // sort order by retrieving full records, using the
             // IDs provided in the summary list items. amd then retriving
             // the value of that field from each of those records.
-            MovementsCommon movement = read(item.getCsid());
+            MovementsCommon movement = read(AbstractCommonListUtils.ListItemGetCSID(item));
             firstFieldValues.add(i, movement.getLocationDate());
             secondFieldValues.add(i, movement.getMovementNote());
             if (logger.isDebugEnabled()) {
@@ -459,7 +464,7 @@ public class MovementSortByTest extends BaseServiceTest {
         // Submit the request to the service and store the response.
         MovementClient client = new MovementClient();
         final String EMPTY_SORT_FIELD_NAME = "";
-        ClientResponse<MovementsCommonList> res =
+        ClientResponse<AbstractCommonList> res =
                 client.readListSortedBy(EMPTY_SORT_FIELD_NAME);
         int statusCode = res.getStatus();
 
@@ -491,7 +496,7 @@ public class MovementSortByTest extends BaseServiceTest {
 
         // Submit the request to the service and store the response.
         MovementClient client = new MovementClient();
-        ClientResponse<MovementsCommonList> res =
+        ClientResponse<AbstractCommonList> res =
                 client.readListSortedBy(MovementJAXBSchema.LOCATION_DATE);
         int statusCode = res.getStatus();
 
@@ -521,7 +526,7 @@ public class MovementSortByTest extends BaseServiceTest {
         // Submit the request to the service and store the response.
         MovementClient client = new MovementClient();
         final String INVALID_SORT_ORDER_IDENTIFIER = "NO_DIRECTION";
-        ClientResponse<MovementsCommonList> res =
+        ClientResponse<AbstractCommonList> res =
                 client.readListSortedBy(MovementJAXBSchema.LOCATION_DATE
                 + " " + INVALID_SORT_ORDER_IDENTIFIER);
         int statusCode = res.getStatus();
@@ -749,7 +754,7 @@ public class MovementSortByTest extends BaseServiceTest {
         return multipart;
     }
 
-    private MovementsCommonList readSortedList(String sortFieldName) throws Exception {
+    private AbstractCommonList readSortedList(String sortFieldName) throws Exception {
 
         String testName = "readSortedList";
         testSetup(STATUS_OK, ServiceRequestType.READ);
@@ -757,9 +762,9 @@ public class MovementSortByTest extends BaseServiceTest {
         // Submit the request to the service and store the response.
         MovementClient client = new MovementClient();
 
-        ClientResponse<MovementsCommonList> res =
+        ClientResponse<AbstractCommonList> res =
                 client.readListSortedBy(sortFieldName);
-        MovementsCommonList list = res.getEntity();
+        AbstractCommonList list = res.getEntity();
         int statusCode = res.getStatus();
 
         // Check the status code of the response: does it match
@@ -775,7 +780,7 @@ public class MovementSortByTest extends BaseServiceTest {
 
     }
 
-    private MovementsCommonList keywordSearchSortedBy(String keywords,
+    private AbstractCommonList keywordSearchSortedBy(String keywords,
             String sortFieldName) throws Exception {
 
         String testName = "keywordSearchSortedBy";
@@ -784,9 +789,9 @@ public class MovementSortByTest extends BaseServiceTest {
         // Submit the request to the service and store the response.
         MovementClient client = new MovementClient();
 
-        ClientResponse<MovementsCommonList> res =
+        ClientResponse<AbstractCommonList> res =
                 client.keywordSearchSortedBy(keywords, sortFieldName);
-        MovementsCommonList list = res.getEntity();
+        AbstractCommonList list = res.getEntity();
         int statusCode = res.getStatus();
 
         // Check the status code of the response: does it match
index 66ea554416ae2df738bc3d355a887b4c682a41ed..51184609296e88b62ed4908494daf6e354e89ced 100644 (file)
         </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>
-    
-    <!-- movements records, as in nuxeo repository -->
-    <xs:element name="movements-common-list">
-        <xs:complexType>
-            <xs:complexContent>
-                <xs:extension base="abstractCommonList">                    
-                    <xs:sequence>
-                        <xs:element name="movement-list-item" maxOccurs="unbounded">
-                            <xs:complexType>
-                                <xs:sequence>
-                                    <xs:element name="movementReferenceNumber" type="xs:string"
-                                        minOccurs="1" />
-                                    <xs:element name="currentLocation" type="xs:string"
-                                        minOccurs="1" />
-                                    <xs:element name="locationDate" 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>
-    
 </xs:schema>
 
index 4bb538d31a59eed4dc163dddd936e0af8e5a6096..989d15e97ed8468c5b9b1d0e6ec3e8f04e11ad5b 100644 (file)
  */
 package org.collectionspace.services.movement.nuxeo;
 
-import java.util.GregorianCalendar;
-import java.util.Iterator;
-import java.util.List;
-
-import org.collectionspace.services.MovementJAXBSchema;
-import org.collectionspace.services.common.datetime.DateTimeFormatUtils;
-import org.collectionspace.services.common.document.DocumentWrapper;
-import org.collectionspace.services.jaxb.AbstractCommonList;
 import org.collectionspace.services.movement.MovementsCommon;
-import org.collectionspace.services.movement.MovementsCommonList;
-import org.collectionspace.services.movement.MovementsCommonList.MovementListItem;
-import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
-import org.collectionspace.services.nuxeo.util.NuxeoUtils;
-import org.nuxeo.ecm.core.api.DocumentModel;
-import org.nuxeo.ecm.core.api.DocumentModelList;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.collectionspace.services.nuxeo.client.java.DocHandlerBase;
 
 /**
  * The Class MovementDocumentModelHandler.
@@ -48,126 +33,7 @@ import org.slf4j.LoggerFactory;
  * $LastChangedDate$
  */
 public class MovementDocumentModelHandler
-        extends RemoteDocumentModelHandlerImpl<MovementsCommon, MovementsCommonList> {
-
-    /** The logger. */
-    private final Logger logger = LoggerFactory.getLogger(MovementDocumentModelHandler.class);
-    
-    /** The Movement. */
-    private MovementsCommon Movement;
-    
-    /** The Movement list. */
-    private MovementsCommonList MovementList;
-
-    /**
-     * Gets the common part.
-     *
-     * @return the common part
-     */
-    @Override
-    public MovementsCommon getCommonPart() {
-        return Movement;
-    }
-
-    /**
-     * Sets the common part.
-     *
-     * @param Movement the new common part
-     */
-    @Override
-    public void setCommonPart(MovementsCommon Movement) {
-        this.Movement = Movement;
-    }
-
-    /**
-     * Gets the common part list.
-     *
-     * @return the common part list
-     */
-    @Override
-    public MovementsCommonList getCommonPartList() {
-        return MovementList;
-    }
-
-    /**
-     * Sets the common part list.
-     *
-     * @param MovementList the new common part list
-     */
-    @Override
-    public void setCommonPartList(MovementsCommonList MovementList) {
-        this.MovementList = MovementList;
-    }
-
-    /**
-     * Extract common part.
-     *
-     * @param wrapDoc the wrap doc
-     * @return the Movements common
-     * @throws Exception the exception
-     */
-    @Override
-    public MovementsCommon extractCommonPart(DocumentWrapper<DocumentModel> wrapDoc)
-            throws Exception {
-        throw new UnsupportedOperationException();
-    }
-
-    /**
-     * Fill common part.
-     *
-     * @param MovementObject the Movement object
-     * @param wrapDoc the wrap doc
-     * @throws Exception the exception
-     */
-    @Override
-    public void fillCommonPart(MovementsCommon MovementObject, DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
-        throw new UnsupportedOperationException();
-    }
-
-    /**
-     * Extract common part list.
-     *
-     * @param wrapDoc the wrap doc
-     * @return the Movements common list
-     * @throws Exception the exception
-     */
-    @Override
-    public MovementsCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
-        MovementsCommonList coList = extractPagingInfo(new MovementsCommonList(), wrapDoc);
-        AbstractCommonList commonList = (AbstractCommonList) coList;
-        commonList.setFieldsReturned("movementReferenceNumber|currentLocation|locationDate|uri|csid");
-        List<MovementsCommonList.MovementListItem> list = coList.getMovementListItem();
-        Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
-        String label = getServiceContext().getCommonPartLabel();
-        while(iter.hasNext()){
-            DocumentModel docModel = iter.next();
-            MovementListItem ilistItem = new MovementListItem();
-            ilistItem.setMovementReferenceNumber((String) docModel.getProperty(label,
-                    MovementJAXBSchema.MOVEMENT_REFERENCE_NUMBER));
-            ilistItem.setCurrentLocation((String) docModel.getProperty(label,
-                    MovementJAXBSchema.CURRENT_LOCATION));
-            GregorianCalendar gcal = (GregorianCalendar) docModel.getProperty(label,
-                    MovementJAXBSchema.LOCATION_DATE);
-            ilistItem.setLocationDate(DateTimeFormatUtils.formatAsISO8601Timestamp(gcal));
-            String id = getCsid(docModel);//NuxeoUtils.extractId(docModel.getPathAsString());
-            ilistItem.setUri(getServiceContextPath() + id);
-            ilistItem.setCsid(id);
-            list.add(ilistItem);
-        }
-
-        return coList;
-    }
-
-    /**
-     * Gets the q property.
-     *
-     * @param prop the prop
-     * @return the q property
-     */
-    @Override
-    public String getQProperty(String prop) {
-        return MovementConstants.NUXEO_SCHEMA_NAME + ":" + prop;
-    }
+        extends DocHandlerBase<MovementsCommon> {
 
 }
 
index f72ef4bc203da20ea37f571e139da5baeb45ccde..5722e26c41e8722bbb14689a857512c212c03d7b 100644 (file)
@@ -30,6 +30,7 @@ import org.collectionspace.services.client.ObjectExitClient;
 import org.collectionspace.services.client.PayloadOutputPart;
 import org.collectionspace.services.client.PoxPayloadIn;
 import org.collectionspace.services.client.PoxPayloadOut;
+import org.collectionspace.services.common.AbstractCommonListUtils;
 import org.collectionspace.services.jaxb.AbstractCommonList;
 import org.collectionspace.services.objectexit.ObjectexitCommon;
 
@@ -130,7 +131,7 @@ public class ObjectExitServiceTest extends AbstractServiceTestImpl {
         // Optionally output additional data about list members for debugging.
         boolean iterateThroughList = true;
         if(iterateThroughList && logger.isDebugEnabled()){
-               ListItemsInAbstractCommonList(list, logger, testName);
+               AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
         }
         
     }
index 673b14f47edd5ced955972d46da88ee06a78f12d..bfbf7a9ae67eee12aab9d745fb853f2948800d30 100644 (file)
@@ -33,6 +33,7 @@ import org.collectionspace.services.client.PayloadOutputPart;
 import org.collectionspace.services.client.PoxPayloadIn;
 import org.collectionspace.services.client.PoxPayloadOut;
 import org.collectionspace.services.client.ReportClient;
+import org.collectionspace.services.common.AbstractCommonListUtils;
 import org.collectionspace.services.report.ReportsCommon;
 import org.collectionspace.services.jaxb.AbstractCommonList;
 
@@ -286,9 +287,8 @@ public class ReportServiceTest extends AbstractServiceTestImpl {
         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
 
         // Optionally output additional data about list members for debugging.
-        boolean iterateThroughList = false;
-        if (iterateThroughList && logger.isDebugEnabled()) {
-               ListItemsInAbstractCommonList(list, logger, testName);
+        if(logger.isTraceEnabled()){
+               AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
         }
     }
 
@@ -322,7 +322,7 @@ public class ReportServiceTest extends AbstractServiceTestImpl {
        // We must find the basic one we created
        boolean fFoundBaseItem = false;
                for (AbstractCommonList.ListItem item : items) {
-                       if(knownResourceId.equalsIgnoreCase(ListItemGetCSID(item))) {
+                       if(knownResourceId.equalsIgnoreCase(AbstractCommonListUtils.ListItemGetCSID(item))) {
                                fFoundBaseItem = true;
                                break;
                        }
@@ -347,7 +347,7 @@ public class ReportServiceTest extends AbstractServiceTestImpl {
        items = list.getListItem();
        // We must NOT find the basic one we created
                for (AbstractCommonList.ListItem item : items) {
-                       Assert.assertNotSame(ListItemGetCSID(item), knownResourceId, 
+                       Assert.assertNotSame(AbstractCommonListUtils.ListItemGetCSID(item), knownResourceId, 
                                "readListFiltered(\"Intake\", \"single\") incorrectly returned base item");
                }
                
@@ -368,7 +368,7 @@ public class ReportServiceTest extends AbstractServiceTestImpl {
        items = list.getListItem();
        // We must NOT find the basic one we created
                for (AbstractCommonList.ListItem item : items) {
-                       Assert.assertNotSame(ListItemGetCSID(item), knownResourceId, 
+                       Assert.assertNotSame(AbstractCommonListUtils.ListItemGetCSID(item), knownResourceId, 
                                "readListFiltered(\""+testDocType+"\", \"group\") incorrectly returned base item");
                }
     }