]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-5985: Making fixes for failed test results.
authorremillet <remillet@yahoo.com>
Mon, 27 Mar 2017 20:39:17 +0000 (13:39 -0700)
committerremillet <remillet@yahoo.com>
Mon, 27 Mar 2017 20:39:17 +0000 (13:39 -0700)
services/batch/client/src/test/java/org/collectionspace/services/client/test/BatchServiceTest.java
services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/BatchValidatorHandler.java
services/client/src/main/java/org/collectionspace/services/client/PoxPayload.java
services/common/src/main/java/org/collectionspace/services/common/document/ValidatorHandlerImpl.java
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/CommonList.java
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteDocumentModelHandlerImpl.java

index aa8e2c0b2a859912d80b0f4572c543cebff00724..c6c4618dd7db3f2f1514313ade35249e4ff82e51 100644 (file)
@@ -87,6 +87,7 @@ public class BatchServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonL
         String identifier = "batchNumber-" + exitNumber;
         BatchCommon batch = new BatchCommon();
         batch.setName(identifier);
+        batch.setClassName("org.collectionspace.services.batch.nuxeo.TestBatchJob");
         PoxPayloadOut multipart = new PoxPayloadOut(BatchClient.SERVICE_PAYLOAD_NAME);
         PayloadOutputPart commonPart = multipart.addPart(batch, MediaType.APPLICATION_XML_TYPE);
         commonPart.setLabel(new BatchClient().getCommonPartName());
@@ -105,6 +106,7 @@ public class BatchServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonL
                
                result.setName("updated-" + batchCommon.getName());
                result.setNotes("updated-" + batchCommon.getNotes());
+               result.setClassName("org.collectionspace.services.batch.nuxeo.TestBatchJob");
                
                return result;
        }
index c864a662ede4a7daadaa0fe068bf4fa942384c00..d7486adf3eecf33b623f2d28f805091d6baf700b 100644 (file)
@@ -19,6 +19,7 @@ public class BatchValidatorHandler extends ValidatorHandlerImpl<PoxPayloadIn, Po
     //
     private static final String VALIDATION_ERROR = "The batch record payload was invalid. See log file for more details.";
     private static final String NAME_NULL_ERROR = "The batch record field \"name\" cannot be empty or missing.";
+    private static final String CLASSNAME_NULL_ERROR = "The batch record field \"className\" cannot be empty or missing.";
        private static final String MISSING_CLASS_ERROR = "The Java class '%s' (fully qualified with package name) for the batch job named '%s' cannot be found.";
 
        @Override
@@ -105,14 +106,14 @@ public class BatchValidatorHandler extends ValidatorHandlerImpl<PoxPayloadIn, Po
        //
        // Ensure a batch class
         String batchClassName = batchCommon.getClassName();
-        CS_ASSERT(batchName != null, NAME_NULL_ERROR);
-        CS_ASSERT(batchName.isEmpty() == false, NAME_NULL_ERROR);
+        CS_ASSERT(batchClassName != null, CLASSNAME_NULL_ERROR);
+        CS_ASSERT(batchClassName.isEmpty() == false, CLASSNAME_NULL_ERROR);
         
         //
         // Ensure we can find and load the batch Java class
         if (canFindClass(batchClassName) == false) {
                String msg = String.format(MISSING_CLASS_ERROR, batchClassName, batchCommon.getName());
-               CS_ASSERT(false, batchClassName);
+               CS_ASSERT(false, msg);
         }
     }
        
index af3648d4c51bdf2ac2a87385f657e09d5e29548e..b495d1848708d6963b87929372d8a94311ea18c0 100644 (file)
@@ -5,8 +5,11 @@ import java.io.File;
 import java.io.IOException;
 import java.io.StringReader;
 import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Set;
 
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBElement;
@@ -47,7 +50,10 @@ public abstract class PoxPayload<PT extends PayloadPart> {
        
        // The list of POX parts contained in the xmlText payload
        /** The parts. */
-       private List<PT> parts = new ArrayList<PT>();   
+       private List<PT> parts = new ArrayList<PT>();
+       
+       // Valid root element labels
+       private static Set<String> validRootElementLabels = new HashSet<String>(Arrays.asList("document", "abstract-common-list"));
        
        /**
         * Instantiates a new pox payload.
@@ -60,10 +66,19 @@ public abstract class PoxPayload<PT extends PayloadPart> {
                this.payloadName = name;
        }
        
+       /**
+        * Returns a list of valid root element labels for payloads.
+        * 
+        * @return
+        */
+       public Set<String> getValidRootElementLables() {
+               return validRootElementLabels;
+       }
+       
        private void setDomDocument(Document dom) throws DocumentException {
                this.domDocument = dom;
-               String label = domDocument.getRootElement().getName();
-               if (label != null && label.equalsIgnoreCase("document")) {
+               String label = domDocument.getRootElement().getName().toLowerCase();
+               if (label != null && getValidRootElementLables().contains(label)) {
                        this.payloadName = label;
                } else {
                        String msg = "The following incoming request payload is missing the root <document> element or is otherwise malformed.  For example valid payloads, see https://wiki.collectionspace.org/display/DOC/Common+Services+REST+API+documentation";
index 0239eee10b939cb084280c1fe026bd6f69f8c920..3028c32fa5302b0a56fb3504cb71ba68d3f58cc1 100644 (file)
@@ -48,6 +48,7 @@ public abstract class ValidatorHandlerImpl<IT, OT> implements ValidatorHandler<I
                 errorMsg = "Validation exception occurred in: "
                         + this.getClass().getName();
             }
+            logger.error(errorMsg);
             throw new AssertionError(errorMsg);
         }
     }
index 14d1f69e1a7e65debb96c47deadfc606e7aab38c..b096964a910659248a63b7b76ed601258ffe2f98 100644 (file)
  */
 package org.collectionspace.services.nuxeo.client.java;
 
-import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 
 import org.collectionspace.services.common.api.Tools;
 import org.collectionspace.services.jaxb.AbstractCommonList;
 
-import org.apache.commons.lang.builder.ToStringBuilder;
-import org.jvnet.jaxb2_commons.lang.ToString;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 
@@ -43,13 +39,8 @@ import org.w3c.dom.Element;
 
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlTransient;
-import javax.xml.bind.annotation.XmlType;
-import javax.xml.bind.annotation.XmlSeeAlso;
-
-import org.slf4j.LoggerFactory;
 
 /**
  * This class allows us to generically represent and marshall a set of list
@@ -76,7 +67,7 @@ public class CommonList extends AbstractCommonList {
        private DocumentBuilder parser;
        @XmlTransient
        private Document doc;
-    
+           
     public CommonList()
        throws javax.xml.parsers.ParserConfigurationException {
        super();
index 68c64bbcd5fff32ad659d0a6d3e0c62adf583d87..78c134e5200e2a8ea6f4a1a2c030916c2cd60896 100644 (file)
@@ -408,11 +408,10 @@ public abstract class   RemoteDocumentModelHandlerImpl<T, TL>
             werePartsFilled = true;
         }
         
-        if (werePartsFilled == false) {
-               String msg = String.format("%s request failed because there were no XML payload parts in the request.", 
+        if (logger.isTraceEnabled() && werePartsFilled == false) {
+               String msg = String.format("%s request had no XML payload parts processed in the request.  Could be a payload with only relations-common-list request.", 
                                action.toString());
-               logger.error(msg);
-               throw new BadRequestException(msg);
+               logger.trace(msg);
         }
     }