message.setChecksumError(errorMD5);
message.setVerbose(verbose);
message.setNoOp(noOp);
// Post the file
DepositResponse resp = client.postFile(message);
// Set the status
Status status = client.getStatus();
request.setAttribute("status", status.toString());
if ((status.getCode() == 201) || (status.getCode() == 202)) {
// Set the debug response
String xml = resp.marshall();
String validateXml = xml;
validateXml = validateXml.replaceAll("&", "&");
validateXml = validateXml.replaceAll("<", "<");
validateXml = validateXml.replaceAll(">", ">");
validateXml = validateXml.replaceAll("\"", """);
validateXml = validateXml.replaceAll("'", "'");
request.setAttribute("xmlValidate", validateXml); // for passing to validation
xml = xml.replaceAll("<", "<");
xml = xml.replaceAll(">", ">");
request.setAttribute("xml", xml);
SWORDEntry se = resp.getEntry();
request.setAttribute("id", se.getId());
request.setAttribute("authors", se.getAuthors());
request.setAttribute("contributors", se.getContributors());
request.setAttribute("title", se.getTitle().getContent());
request.setAttribute("updated", se.getUpdated());
request.setAttribute("categories", se.getCategories());
request.setAttribute("treatment", se.getTreatment());
request.setAttribute("summary", se.getSummary().getContent());
request.setAttribute("generator", se.getGenerator().getContent());
request.setAttribute("userAgent", se.getUserAgent());
request.setAttribute("packaging", se.getPackaging());
request.setAttribute("links", se.getLinks());
request.setAttribute("location", resp.getLocation());
// Set the ServiceDocument and associated values
request.getRequestDispatcher("deposit.jsp").forward(request, response);
return;
} else {
String error = status.getCode() + " " + status.getMessage() + " - ";
try {
error += resp.getEntry().getSummary().getContent();
} catch (Exception e) {
// Do nothing - we have default error message
e.printStackTrace();
}
request.setAttribute("error", error);
// Try and get an error document in xml
String xml = resp.marshall();
xml = xml.replaceAll("<", "<");
xml = xml.replaceAll(">", ">");
request.setAttribute("xml", xml);
request.getRequestDispatcher("depositform.jsp").forward(request, response);