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());
result.setName("updated-" + batchCommon.getName());
result.setNotes("updated-" + batchCommon.getNotes());
+ result.setClassName("org.collectionspace.services.batch.nuxeo.TestBatchJob");
return result;
}
//
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
//
// 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);
}
}
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;
// 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.
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";
errorMsg = "Validation exception occurred in: "
+ this.getClass().getName();
}
+ logger.error(errorMsg);
throw new AssertionError(errorMsg);
}
}
*/
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;
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
private DocumentBuilder parser;
@XmlTransient
private Document doc;
-
+
public CommonList()
throws javax.xml.parsers.ParserConfigurationException {
super();
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);
}
}