}
}
private Answer execute(UploadTemplateToS3FromSecondaryStorageCommand cmd) {
final S3TO s3 = cmd.getS3();
final Long accountId = cmd.getAccountId();
final Long templateId = cmd.getTemplateId();
try {
final String templatePath = determineStorageTemplatePath(
cmd.getStoragePath(), accountId, templateId);
if (s_logger.isDebugEnabled()) {
s_logger.debug("Found template id " + templateId
+ " account id " + accountId + " from directory "
+ templatePath + " to upload to S3.");
}
if (!_storage.isDirectory(templatePath)) {
final String errMsg = format("S3 Sync Failure: Directory %1$s"
+ "for template id %2$s does not exist.", templatePath,
templateId);
s_logger.error(errMsg);
return new Answer(cmd, false, errMsg);
}
if (!_storage.isFile(templatePath + "/template.properties")) {
final String errMsg = format("S3 Sync Failure: Template id "
+ "%1$s does not exist on the file system.",
templatePath);
s_logger.error(errMsg);
return new Answer(cmd, false, errMsg);
}
if (s_logger.isDebugEnabled()) {
s_logger.debug(format(
"Pushing template id %1$s from %2$s to S3...",
templateId, templatePath));
}
final String bucket = s3.getBucketName();
putDirectory(s3, bucket, _storage.getFile(templatePath),
new FilenameFilter() {
@Override
public boolean accept(final File directory,
final String fileName) {