S3PutObjectInlineResponse response = new S3PutObjectInlineResponse();
String bucketName = request.getBucketName();
String key = request.getKey();
S3MetaDataEntry[] meta = request.getMetaEntries();
SBucketVO bucket = bucketDao.getByName(bucketName);
if (bucket == null) {
logger.error("completeMultipartUpload( failed since " + bucketName
+ " does not exist");
response.setResultCode(404);
}
// [B] Now we need to create the final re-assembled object
// -> the allocObjectItem checks for the bucket policy PutObject
// permissions
OrderedPair<SObjectVO, SObjectItemVO> object_objectitem_pair = allocObjectItem(
bucket, key, meta, null, request.getCannedAccess());
OrderedPair<SHostVO, String> host_storagelocation_pair = getBucketStorageHost(bucket);
S3BucketAdapter bucketAdapter = getStorageHostBucketAdapter(host_storagelocation_pair
.getFirst());
String itemFileName = object_objectitem_pair.getSecond()
.getStoredPath();
// -> Amazon defines that we must return a 200 response immediately to
// the client, but
// -> we don't know the version header until we hit here
httpResp.setStatus(200);
httpResp.setContentType("text/xml; charset=UTF-8");
String version = object_objectitem_pair.getSecond().getVersion();
if (null != version)
httpResp.addHeader("x-amz-version-id", version);
httpResp.flushBuffer();
Transaction txn = Transaction.open(Transaction.AWSAPI_DB);
// [C] Re-assemble the object from its uploaded file parts
try {
// explicit transaction control to avoid holding transaction during
// long file concatenation process
txn.start();
OrderedPair<String, Long> result = bucketAdapter
.concatentateObjects(host_storagelocation_pair.getSecond(),
bucket.getName(), itemFileName, ServiceProvider
.getInstance().getMultipartDir(), parts,
outputStream);
response.setETag(result.getFirst());
response.setLastModified(DateHelper.toCalendar(object_objectitem_pair.getSecond().getLastModifiedTime()));