Tuple<SHost, String> tupleBucketHost = getBucketStorageHost(bucket);
S3BucketAdapter bucketAdapter = getStorageHostBucketAdapter(tupleBucketHost.getFirst());
try {
MultipartLoadDao uploadDao = new MultipartLoadDao();
Tuple<String,String> exists = uploadDao.multipartExits( uploadId );
if (null == exists) {
logger.error( "initiateMultipartUpload failed since multipart upload" + uploadId + " does not exist" );
return 404;
}
// -> the multipart initiator or bucket owner can do this action by default
if (verifyPermission)
{
String initiator = uploadDao.getInitiator( uploadId );
if (null == initiator || !initiator.equals( UserContext.current().getAccessKey()))
{
// -> write permission on a bucket allows a PutObject / DeleteObject action on any object in the bucket
S3PolicyContext context = new S3PolicyContext( PolicyActions.AbortMultipartUpload, bucketName );
context.setKeyName( exists.getSecond());
verifyAccess( context, "SBucket", bucket.getId(), SAcl.PERMISSION_WRITE );
}
}
// -> first get a list of all the uploaded files and delete one by one
S3MultipartPart[] parts = uploadDao.getParts( uploadId, 10000, 0 );
for( int i=0; i < parts.length; i++ )
{
bucketAdapter.deleteObject( tupleBucketHost.getSecond(), ServiceProvider.getInstance().getMultipartDir(), parts[i].getPath());
}
uploadDao.deleteUpload( uploadId );
return 204;
}
catch( PermissionDeniedException e ) {
logger.error("freeUploadParts failed due to [" + e.getMessage() + "]", e);