log.debug("Computing MD5 hash for file: " + file);
byte[] fileHash = ServiceUtils.computeMD5Hash(
new ProgressMonitoredInputStream( // Report on MD5 hash progress.
new FileInputStream(file), progressWatcher));
S3Object object = new S3Object(null, file);
object.setMd5Hash(fileHash);
objectsForUpload[i] = object;
}
// Obtain Gatekeeper response.
SwingUtilities.invokeLater(new Runnable() {
public void run() {
progressStatusTextLabel.setText(
replaceMessageVariables(uploaderProperties.getStringProperty("screen.4.connectingMessage",
"Missing property 'screen.4.connectingMessage'")));
progressBar.setValue(0);
};
});
GatekeeperMessage gatekeeperMessage = null;
try {
gatekeeperMessage = retrieveGatekeeperResponse(objectsForUpload);
} catch (Exception e) {
log.info("Upload request was denied", e);
failWithFatalError(ERROR_CODE__UPLOAD_REQUEST_DECLINED);
return;
}
// If we get a null response, presume the error has already been handled.
if (gatekeeperMessage == null) {
return;
}
log.debug("Gatekeeper response properties: " + gatekeeperMessage.encodeToProperties());
XmlGenerator xmlGenerator = new XmlGenerator();
xmlGenerator.addApplicationProperties(gatekeeperMessage.getApplicationProperties());
xmlGenerator.addMessageProperties(gatekeeperMessage.getMessageProperties());
SignedUrlAndObject[] uploadItems = prepareSignedObjects(
objectsForUpload, gatekeeperMessage.getSignatureRequests(), xmlGenerator);
if (s3ServiceMulti == null) {
s3ServiceMulti = new S3ServiceMulti(
new RestS3Service(null, APPLICATION_DESCRIPTION, this), this);
}
/*
* Prepare XML Summary document for upload, if the summary option is set.
*/
includeXmlSummaryDoc = uploaderProperties.getBoolProperty("xmlSummary", false);
S3Object summaryXmlObject = null;
if (includeXmlSummaryDoc) {
String priorTransactionId = gatekeeperMessage.getMessageProperties().getProperty(
GatekeeperMessage.PROPERTY_TRANSACTION_ID);
if (priorTransactionId == null) {
failWithFatalError(ERROR_CODE__TRANSACTION_ID_REQUIRED_TO_CREATE_XML_SUMMARY);
return;
}
summaryXmlObject = new S3Object(
null, priorTransactionId + ".xml", xmlGenerator.generateXml());
summaryXmlObject.setContentType(Mimetypes.MIMETYPE_XML);
summaryXmlObject.addMetadata(GatekeeperMessage.PROPERTY_TRANSACTION_ID, priorTransactionId);
summaryXmlObject.addMetadata(GatekeeperMessage.SUMMARY_DOCUMENT_METADATA_FLAG, "true");
}
// PUT the user's selected files in S3.
uploadCancelled = false;
uploadingFinalObject = (!includeXmlSummaryDoc);