Search in sources :

Example 1 with DataAbortMultipartUpload

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);
}
Also used : ObjMultipart(com.pspace.ifs.ksan.objmanager.ObjMultipart) S3ObjectOperation(com.pspace.ifs.ksan.gw.object.S3ObjectOperation) S3Bucket(com.pspace.ifs.ksan.gw.identity.S3Bucket) DataAbortMultipartUpload(com.pspace.ifs.ksan.gw.data.DataAbortMultipartUpload) Part(com.pspace.ifs.ksan.gw.object.multipart.Part) Metadata(com.pspace.ifs.ksan.objmanager.Metadata) GWException(com.pspace.ifs.ksan.gw.exception.GWException) GWException(com.pspace.ifs.ksan.gw.exception.GWException)

Aggregations

DataAbortMultipartUpload (com.pspace.ifs.ksan.gw.data.DataAbortMultipartUpload)1 GWException (com.pspace.ifs.ksan.gw.exception.GWException)1 S3Bucket (com.pspace.ifs.ksan.gw.identity.S3Bucket)1 S3ObjectOperation (com.pspace.ifs.ksan.gw.object.S3ObjectOperation)1 Part (com.pspace.ifs.ksan.gw.object.multipart.Part)1 Metadata (com.pspace.ifs.ksan.objmanager.Metadata)1 ObjMultipart (com.pspace.ifs.ksan.objmanager.ObjMultipart)1