use of com.pspace.ifs.ksan.gw.data.DataAbortMultipartUpload in project ksan by infinistor.
the class AbortMultipartUpload method process.
@Override
public void process() throws GWException {
logger.info(GWConstants.LOG_ABORT_MULTIPART_UPLOAD_START);
String bucket = s3Parameter.getBucketName();
initBucketInfo(bucket);
String object = s3Parameter.getObjectName();
S3Bucket s3Bucket = new S3Bucket();
s3Bucket.setCors(getBucketInfo().getCors());
s3Bucket.setAccess(getBucketInfo().getAccess());
s3Parameter.setBucket(s3Bucket);
GWUtils.checkCors(s3Parameter);
if (s3Parameter.isPublicAccess() && GWUtils.isIgnorePublicAcls(s3Parameter)) {
throw new GWException(GWErrorCode.ACCESS_DENIED, s3Parameter);
}
DataAbortMultipartUpload dataAbortMultipartUpload = new DataAbortMultipartUpload(s3Parameter);
dataAbortMultipartUpload.extract();
String uploadId = dataAbortMultipartUpload.getUploadId();
s3Parameter.setUploadId(uploadId);
ObjMultipart objMultipart = null;
SortedMap<Integer, Part> listPart = null;
boolean isUploadId = true;
try {
objMultipart = new ObjMultipart(bucket);
if (!objMultipart.isUploadId(uploadId)) {
isUploadId = false;
throw new GWException(GWErrorCode.NO_SUCH_UPLOAD, s3Parameter);
}
listPart = objMultipart.getParts(uploadId);
} catch (Exception e) {
if (!isUploadId) {
throw new GWException(GWErrorCode.NO_SUCH_UPLOAD, s3Parameter);
}
PrintStack.logging(logger, e);
throw new GWException(GWErrorCode.SERVER_ERROR, s3Parameter);
}
// get Paths
Metadata objMeta = createLocal(bucket, object);
S3ObjectOperation objectOperation = new S3ObjectOperation(objMeta, null, s3Parameter, null, null);
objectOperation.abortMultipart(listPart);
objMultipart.abortMultipartUpload(uploadId);
s3Parameter.getResponse().setStatus(HttpServletResponse.SC_NO_CONTENT);
}
Aggregations