// Update the content of this resource.
acquisition.setAccessionDate("updated-" + acquisition.getAccessionDate());
if(logger.isDebugEnabled()){
- verbose("updated object", acquisition, AcquisitionsCommon.class);
+ logger.debug("updated object");
+ logger.debug(objectAsXmlString(acquisition, AcquisitionsCommon.class));
}
// Submit the request to the service and store the response.
MultipartOutput output = new MultipartOutput();
commonPart.getHeaders().add("label", client.getCommonPartName());
if(logger.isDebugEnabled()){
- verbose("to be created, acquisition common ",
- acquisition, AcquisitionsCommon.class);
+ logger.debug("to be created, acquisition common");
+ logger.debug(objectAsXmlString(acquisition, AcquisitionsCommon.class));
}
return multipart;
}
package org.collectionspace.services.client.test;
import java.io.ByteArrayInputStream;
+import java.io.StringWriter;
import java.lang.reflect.Method;
import java.util.ArrayList;
import javax.ws.rs.core.MultivaluedMap;
// to be moved to a utilities module, suitable for use
// by both client-side and server-side code.
- protected void verbose(String msg) {
- if(logger.isDebugEnabled()){
- logger.debug(msg);
- }
- }
-
- protected void verbose(String msg, Object o, Class clazz) {
+ protected String objectAsXmlString(Object o, Class clazz) {
+ StringWriter sw = new StringWriter();
try{
- if(logger.isDebugEnabled()){
- logger.debug(msg);
- }
JAXBContext jc = JAXBContext.newInstance(clazz);
Marshaller m = jc.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,
Boolean.TRUE);
- m.marshal(o, System.out);
+ m.marshal(o, sw);
}catch(Exception e){
e.printStackTrace();
}
+ return sw.toString();
}
-
- protected void verboseMap(MultivaluedMap map) {
+
+ protected String mapAsString(MultivaluedMap map) {
+ StringBuffer sb = new StringBuffer();
for(Object entry : map.entrySet()){
MultivaluedMap.Entry mentry = (MultivaluedMap.Entry) entry;
- if(logger.isDebugEnabled()){
- logger.debug(" name=" + mentry.getKey() +
- " value=" + mentry.getValue());
- }
+ sb.append(" name=" + mentry.getKey());
+ sb.append(" value=" + mentry.getValue() + "\n");
}
+ return sb.toString();
}
private void banner(String label) {
collectionObject.setObjectNumber("updated-" + collectionObject.getObjectNumber());
collectionObject.setObjectName("updated-" + collectionObject.getObjectName());
if (logger.isDebugEnabled()) {
- verbose("updated object", collectionObject,
- CollectionobjectsCommon.class);
+ logger.debug("updated object");
+ logger.debug(objectAsXmlString(collectionObject,
+ CollectionobjectsCommon.class));
}
+
// Submit the request to the service and store the response.
MultipartOutput output = new MultipartOutput();
OutputPart commonPart = output.addPart(collectionObject, MediaType.APPLICATION_XML_TYPE);
commonPart.getHeaders().add("label", commonPartName);
if (logger.isDebugEnabled()) {
- verbose("to be created, collectionobject common ",
- collectionObject, CollectionobjectsCommon.class);
+ logger.debug("to be created, collectionobject common");
+ logger.debug(objectAsXmlString(collectionObject,
+ CollectionobjectsCommon.class));
}
CollectionObjectNaturalhistory conh = new CollectionObjectNaturalhistory();
nhPart.getHeaders().add("label", getNHPartName());
if (logger.isDebugEnabled()) {
- verbose("to be created, collectionobject nhistory",
- conh, CollectionObjectNaturalhistory.class);
+ logger.debug("to be created, collectionobject nhistory");
+ logger.debug(objectAsXmlString(conh,
+ CollectionObjectNaturalhistory.class));
}
return multipart;
intake.setEntryNumber("updated-" + intake.getEntryNumber());
intake.setEntryDate("updated-" + intake.getEntryDate());
if(logger.isDebugEnabled()){
- verbose("to be updated object", intake, IntakesCommon.class);
+ logger.debug("to be updated object");
+ logger.debug(objectAsXmlString(intake, IntakesCommon.class));
}
// Submit the request to the service and store the response.
MultipartOutput output = new MultipartOutput();
commonPart.getHeaders().add("label", client.getCommonPartName());
if(logger.isDebugEnabled()){
- verbose("to be created, intake common ", intake, IntakesCommon.class);
+ logger.debug("to be created, intake common");
+ logger.debug(objectAsXmlString(intake, IntakesCommon.class));
}
return multipart;
relation.setDocumentId2("updated-" + relation.getDocumentId2());
relation.setDocumentType2("updated-" + relation.getDocumentType2());
if(logger.isDebugEnabled()){
- verbose("updated object", relation, RelationsCommon.class);
+ logger.debug("updated object");
+ logger.debug(objectAsXmlString(relation, RelationsCommon.class));
}
// Submit the request to the service and store the response.
multipart.addPart(relation, MediaType.APPLICATION_XML_TYPE);
commonPart.getHeaders().add("label", client.getCommonPartName());
if(logger.isDebugEnabled()){
- verbose("to be created, relation common ", relation,
- RelationsCommon.class);
+ logger.debug("to be created, relation common");
+ logger.debug(objectAsXmlString(relation, RelationsCommon.class));
}
return multipart;
}
vocabulary.setDisplayName("updated-" + vocabulary.getDisplayName());
vocabulary.setVocabType("updated-" + vocabulary.getVocabType());
if(logger.isDebugEnabled()){
- verbose("to be updated Vocabulary", vocabulary, VocabulariesCommon.class);
+ logger.debug("to be updated Vocabulary");
+ logger.debug(objectAsXmlString(vocabulary, VocabulariesCommon.class));
}
// Submit the updated resource to the service and store the response.
// Update the contents of this resource.
vocabularyItem.setDisplayName("updated-" + vocabularyItem.getDisplayName());
if(logger.isDebugEnabled()){
- verbose("to be updated VocabularyItem", vocabularyItem,
- VocabularyitemsCommon.class);
+ logger.debug("to be updated VocabularyItem");
+ logger.debug(objectAsXmlString(vocabularyItem,
+ VocabularyitemsCommon.class));
}
// Submit the updated resource to the service and store the response.
commonPart.getHeaders().add("label", client.getCommonPartName());
if(logger.isDebugEnabled()) {
- verbose("to be created, vocabulary common ", vocabulary, VocabulariesCommon.class);
+ logger.debug("to be created, vocabulary common");
+ logger.debug(objectAsXmlString(vocabulary, VocabulariesCommon.class));
}
return multipart;
}
commonPart.getHeaders().add("label", client.getItemCommonPartName());
if(logger.isDebugEnabled()){
- verbose("to be created, vocabularyitem common ", vocabularyItem,
- VocabularyitemsCommon.class);
+ logger.debug("to be created, vocabularyitem common");
+ logger.debug(objectAsXmlString(vocabularyItem,
+ VocabularyitemsCommon.class));
}
return multipart;