Package com.cloud.bridge.persist.dao

Examples of com.cloud.bridge.persist.dao.MultipartLoadDao


    S3Engine.verifyAccess( context, "SBucket", bucket.getId(), SAcl.PERMISSION_READ );

       
    // [B] Query the multipart table to get the list of current uploads
      try {
          MultipartLoadDao uploadDao = new MultipartLoadDao();
          Tuple<S3MultipartUpload[],Boolean> result = uploadDao.getInitiatedUploads( bucketName, maxUploads, prefix, keyMarker, uploadIdMarker );
          uploads = result.getFirst();
          isTruncated = result.getSecond().booleanValue();
      }
    catch( Exception e ) {
      logger.error("List Multipart Uploads failed due to " + e.getMessage(), e)
View Full Code Here


  OrderedPair<SHostVO, String> host_storagelocation_pair = getBucketStorageHost(bucket);
  S3BucketAdapter bucketAdapter = getStorageHostBucketAdapter(host_storagelocation_pair.getFirst());

  try {
      MultipartLoadDao uploadDao = new MultipartLoadDao();
      OrderedPair<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(host_storagelocation_pair.getSecond(), ServiceProvider.getInstance()
      .getMultipartDir(), parts[i].getPath());
      }
      uploadDao.deleteUpload(uploadId);
      return 204;

  } catch (PermissionDeniedException e) {
      logger.error("freeUploadParts failed due to [" + e.getMessage()
        + "]", e);
View Full Code Here

    verifyAccess( context, "SBucket", bucket.getId(), SAcl.PERMISSION_WRITE );

    createUploadFolder( bucketName );

        try {
          MultipartLoadDao uploadDao = new MultipartLoadDao();
          int uploadId = uploadDao.initiateUpload( UserContext.current().getAccessKey(), bucketName, nameKey, request.getCannedAccess(), request.getMetaEntries());
          response.setUploadId( uploadId );
          response.setResultCode(200);
         
        } catch( Exception e ) {
            logger.error("initiateMultipartUpload exception: ", e);
View Full Code Here

    try {
        is = request.getDataInputStream();
        String md5Checksum = bucketAdapter.saveObject(is, host_storagelocation_pair.getSecond(), ServiceProvider.getInstance().getMultipartDir(), itemFileName);
        response.setETag(md5Checksum);
              MultipartLoadDao uploadDao = new MultipartLoadDao();
              uploadDao.savePart(uploadId, partNumber, md5Checksum, itemFileName,(int) request.getContentLength());
              response.setResultCode(200);
             
    } catch (IOException e) {
      logger.error("UploadPart failed due to " + e.getMessage(), e);
      response.setResultCode(500);
View Full Code Here

  S3Engine.verifyAccess(context, "SBucket", bucket.getId(),
    SAcl.PERMISSION_READ);

  // [B] Query the multipart table to get the list of current uploads
  try {
      MultipartLoadDao uploadDao = new MultipartLoadDao();
      OrderedPair<S3MultipartUpload[], Boolean> result = uploadDao
        .getInitiatedUploads(bucketName, maxUploads, prefix,
          keyMarker, uploadIdMarker);
      uploads = result.getFirst();
      isTruncated = result.getSecond().booleanValue();
  } catch (Exception e) {
View Full Code Here

      if (null != temp) uploadId = Integer.parseInt( temp );
     
   
    // [B] Look up all the uploaded body parts and related info
    try {
          MultipartLoadDao uploadDao = new MultipartLoadDao();
          if (null == uploadDao.multipartExits( uploadId )) {
            response.setStatus(404);
          returnErrorXML( 404, "NotFound", outputStream );
            return;
          }
         
          // -> another requirement is that only the upload initiator can upload parts
          String initiator = uploadDao.getInitiator( uploadId );
          if (null == initiator || !initiator.equals( UserContext.current().getAccessKey())) {
            response.setStatus(403);
          returnErrorXML( 403, "Forbidden", outputStream );
            return;          
          }
         
          parts = uploadDao.getParts( uploadId, 10000, 0 );
          meta  = uploadDao.getMeta( uploadId );
          cannedAccess = uploadDao.getCannedAccess( uploadId );
    }
    catch( Exception e ) {
        logger.error("executeCompleteMultipartUpload failed due to " + e.getMessage(), e)
      response.setStatus(500);
      returnErrorXML( 500, "InternalError", outputStream );
View Full Code Here

        response.setStatus(404);
        return;
    }
 
      try {
          MultipartLoadDao uploadDao = new MultipartLoadDao();
          OrderedPair<String,String> exists = uploadDao.multipartExits( uploadId );
          if (null == exists) {
           response.setStatus(404);
           return;
          }
          owner = exists.getFirst();
         
          // -> the multipart initiator or bucket owner can do this action
          initiator = uploadDao.getInitiator( uploadId );
          if (null == initiator || !initiator.equals( UserContext.current().getAccessKey()))
          {
            try {
                // -> write permission on a bucket allows a PutObject / DeleteObject action on any object in the bucket
              S3PolicyContext context = new S3PolicyContext( PolicyActions.ListMultipartUploadParts, bucketName );
              context.setKeyName( exists.getSecond());
              S3Engine.verifyAccess( context, "SBucket", bucket.getId(), SAcl.PERMISSION_WRITE );
            }
            catch (PermissionDeniedException e) {
              response.setStatus(403);
              return;
            }
          }
     
          parts = uploadDao.getParts( uploadId, maxParts, partMarker );
          remaining = uploadDao.numParts( uploadId, partMarker+maxParts );
      }
    catch( Exception e ) {
      logger.error("List Uploads failed due to " + e.getMessage(), e)
      response.setStatus(500);
    }
View Full Code Here

            return;
      }
     
      // -> verification
    try {
          MultipartLoadDao uploadDao = new MultipartLoadDao();
          if (null == uploadDao.multipartExits( uploadId )) {
            response.setStatus(404);
            return;
          }
         
          // -> another requirement is that only the upload initiator can upload parts
          String initiator = uploadDao.getInitiator( uploadId );
          if (null == initiator || !initiator.equals( UserContext.current().getAccessKey())) {
            response.setStatus(403);
            return;          
          }
    }
View Full Code Here

        S3Engine.verifyAccess(context, "SBucket", bucket.getId(),
                SAcl.PERMISSION_READ);

        // [B] Query the multipart table to get the list of current uploads
        try {
            MultipartLoadDao uploadDao = new MultipartLoadDao();
            OrderedPair<S3MultipartUpload[], Boolean> result = uploadDao
                    .getInitiatedUploads(bucketName, maxUploads, prefix,
                            keyMarker, uploadIdMarker);
            uploads = result.getFirst();
            isTruncated = result.getSecond().booleanValue();
        } catch (Exception e) {
View Full Code Here

        OrderedPair<SHostVO, String> host_storagelocation_pair = getBucketStorageHost(bucket);
        S3BucketAdapter bucketAdapter = getStorageHostBucketAdapter(host_storagelocation_pair.getFirst());

        try {
            MultipartLoadDao uploadDao = new MultipartLoadDao();
            OrderedPair<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(host_storagelocation_pair.getSecond(), ServiceProvider.getInstance()
                        .getMultipartDir(), parts[i].getPath());
            }
            uploadDao.deleteUpload(uploadId);
            return 204;

        } catch (PermissionDeniedException e) {
            logger.error("freeUploadParts failed due to [" + e.getMessage()
                    + "]", e);
View Full Code Here

TOP

Related Classes of com.cloud.bridge.persist.dao.MultipartLoadDao

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.