Examples of SBucketDao


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

    if (PersistContext.acquireNamedLock("bucket.creation", LOCK_ACQUIRING_TIMEOUT_SECONDS))
    {
      Tuple<SHost, String> shostTuple = null;
      boolean success = false;
      try {
        SBucketDao bucketDao = new SBucketDao();
        SAclDao    aclDao    = new SAclDao();
       
        if (bucketDao.getByName(request.getBucketName()) != null)
          throw new ObjectAlreadyExistsException("Bucket already exists");
         
        shostTuple = allocBucketStorageHost(request.getBucketName(), null);
       
        SBucket sbucket = new SBucket();
        sbucket.setName(request.getBucketName());
        sbucket.setCreateTime(DateHelper.currentGMTTime());
        sbucket.setOwnerCanonicalId( UserContext.current().getCanonicalUserId());
        sbucket.setShost(shostTuple.getFirst());
        shostTuple.getFirst().getBuckets().add(sbucket);
        bucketDao.save(sbucket);

        S3AccessControlList acl = request.getAcl();
       
        if ( null != cannedAccessPolicy )
           setCannedAccessControls( cannedAccessPolicy, "SBucket", sbucket.getId(), sbucket );
View Full Code Here

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

    }
   
    public S3Response handleRequest( S3DeleteBucketRequest request )
    {
      S3Response response  = new S3Response();    
    SBucketDao bucketDao = new SBucketDao();
    String bucketName = request.getBucketName();
    SBucket sbucket   = bucketDao.getByName( bucketName );
   
    if ( sbucket != null )
    {      
       S3PolicyContext context = new S3PolicyContext( PolicyActions.DeleteBucket, bucketName );
       switch( verifyPolicy( context )) {
       case ALLOW:
          // -> bucket policy can give users permission to delete a bucket while ACLs cannot
          break;
         
       case DENY:
                throw new PermissionDeniedException( "Access Denied - bucket policy DENY result" );
         
       case DEFAULT_DENY:
       default:
          // -> does not matter what the ACLs say only the owner can delete a bucket
          String client = UserContext.current().getCanonicalUserId();
          if (!client.equals( sbucket.getOwnerCanonicalId())) {
              throw new PermissionDeniedException( "Access Denied - only the owner can delete a bucket" );
          }
          break;
       }

      
       // -> delete the file
       Tuple<SHost, String> tupleBucketHost = getBucketStorageHost(sbucket);
       S3BucketAdapter bucketAdapter = getStorageHostBucketAdapter(tupleBucketHost.getFirst());     
       bucketAdapter.deleteContainer(tupleBucketHost.getSecond(), request.getBucketName());
     
       // -> cascade-deleting can delete related SObject/SObjectItem objects, but not SAcl, SMeta and policy objects. We
       //    need to perform deletion of these objects related to bucket manually.
       //    Delete SMeta & SAcl objects: (1)Get all the objects in the bucket, (2)then all the items in each object, (3) then all meta & acl data for each item
       Set<SObject> objectsInBucket = sbucket.getObjectsInBucket();
       Iterator it = objectsInBucket.iterator();
       while( it.hasNext())
       {
         SObject oneObject = (SObject)it.next();
        Set<SObjectItem> itemsInObject = oneObject.getItems();
        Iterator is = itemsInObject.iterator();
        while( is.hasNext())
        {
          SObjectItem oneItem = (SObjectItem)is.next();
            deleteMetaData( oneItem.getId());
            deleteObjectAcls( "SObjectItem", oneItem.getId());
        }       
       }
        
       // -> delete all the policy state associated with the bucket
       try {
                ServiceProvider.getInstance().deleteBucketPolicy( bucketName );
             BucketPolicyDao policyDao = new BucketPolicyDao();
             policyDao.deletePolicy( bucketName );
       }
       catch( Exception e ) {
                logger.error("When deleting a bucket we must try to delete its policy: ", e);
       }
      
       deleteBucketAcls( sbucket.getId());
       bucketDao.delete( sbucket );   
       response.setResultCode(204);
       response.setResultDescription("OK");
    }
    else
    {    response.setResultCode(404);
View Full Code Here

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

     
    String delimiter = request.getDelimiter();
    int maxKeys = request.getMaxKeys();
    if(maxKeys <= 0) maxKeys = 1000;
   
    SBucketDao bucketDao = new SBucketDao();
    SBucket sbucket = bucketDao.getByName(bucketName);
    if (sbucket == null) throw new NoSuchObjectException("Bucket " + bucketName + " does not exist");
   
    PolicyActions action = (includeVersions ? PolicyActions.ListBucketVersions : PolicyActions.ListBucket);
    S3PolicyContext context = new S3PolicyContext( action, bucketName );
    context.setEvalParam( ConditionKeys.MaxKeys, new String( "" + maxKeys ));
View Full Code Here

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

     * @return
     */
    public S3ListAllMyBucketsResponse handleRequest(S3ListAllMyBucketsRequest request)
    {
      S3ListAllMyBucketsResponse response = new S3ListAllMyBucketsResponse();    
      SBucketDao bucketDao = new SBucketDao();
     
      // -> "...you can only list buckets for which you are the owner."
      List<SBucket> buckets = bucketDao.listBuckets(UserContext.current().getCanonicalUserId());
      S3CanonicalUser owner = new S3CanonicalUser();
      owner.setID(UserContext.current().getCanonicalUserId());
      owner.setDisplayName("");
      response.setOwner(owner);
     
View Full Code Here

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

    }
   
    public S3Response handleRequest(S3SetBucketAccessControlPolicyRequest request)
    {
      S3Response response = new S3Response()
      SBucketDao bucketDao = new SBucketDao();
      String bucketName = request.getBucketName();
      SBucket sbucket = bucketDao.getByName(bucketName);
      if(sbucket == null) {
        response.setResultCode(404);
        response.setResultDescription("Bucket does not exist");
        return response;
      }
View Full Code Here

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

    }
   
    public S3AccessControlPolicy handleRequest(S3GetBucketAccessControlPolicyRequest request)
    {
      S3AccessControlPolicy policy = new S3AccessControlPolicy();    
      SBucketDao bucketDao = new SBucketDao();
      String bucketName = request.getBucketName();
      SBucket sbucket = bucketDao.getByName( bucketName );
      if (sbucket == null)
        throw new NoSuchObjectException("Bucket " + bucketName + " does not exist");
     
      S3CanonicalUser owner = new S3CanonicalUser();
      owner.setID(sbucket.getOwnerCanonicalId());
View Full Code Here

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

     * @return
     */
    public int freeUploadParts(String bucketName, int uploadId, boolean verifyPermission)
    {
    // -> we need to look up the final bucket to figure out which mount point to use to save the part in
    SBucketDao bucketDao = new SBucketDao();
    SBucket bucket = bucketDao.getByName(bucketName);
    if (bucket == null) {
      logger.error( "initiateMultipartUpload failed since " + bucketName + " does not exist" );
      return 404;
    }
 
View Full Code Here

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

      S3PutObjectInlineResponse response = new S3PutObjectInlineResponse()
    String bucketName = request.getBucketName();
    String nameKey = request.getKey();

    // -> does the bucket exist and can we write to it?
    SBucketDao bucketDao = new SBucketDao();
    SBucket bucket = bucketDao.getByName(bucketName);
    if (bucket == null) {
      logger.error( "initiateMultipartUpload failed since " + bucketName + " does not exist" );
      response.setResultCode(404);
    }
     
View Full Code Here

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

    {
      S3PutObjectInlineResponse response = new S3PutObjectInlineResponse()
    String bucketName = request.getBucketName();

    // -> we need to look up the final bucket to figure out which mount point to use to save the part in
    SBucketDao bucketDao = new SBucketDao();
    SBucket bucket = bucketDao.getByName(bucketName);
    if (bucket == null) {
      logger.error( "saveUploadedPart failed since " + bucketName + " does not exist" );
      response.setResultCode(404);
    }
    S3PolicyContext context = new S3PolicyContext( PolicyActions.PutObject, bucketName );
View Full Code Here

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

      S3PutObjectInlineResponse response = new S3PutObjectInlineResponse()
    String bucketName = request.getBucketName();
    String key = request.getKey();
    S3MetaDataEntry[] meta = request.getMetaEntries();
   
    SBucketDao bucketDao = new SBucketDao();
    SBucket bucket = bucketDao.getByName(bucketName);
    if (bucket == null) {
      logger.error( "completeMultipartUpload( failed since " + bucketName + " does not exist" );
      response.setResultCode(404);
    }   
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.