Package org.jclouds.aws.s3

Examples of org.jclouds.aws.s3.S3Client


        try {
            if (b.getEntries().isEmpty()) {
                if (!connection.getConnection().deleteObject(rootS3Bucket, b.getBucketName()).get())
                    throw new S3ConnectionException(String.format("Could not delete object [%2s] in s3bucket [%1s] ", rootS3Bucket.getName(), b.getBucketName()));
            } else {
                S3Object s3Object = new S3Object();
                s3Object.setKey(b.getBucketName());
                s3Object.setContent(connection.marshaller.objectToByteBuffer(b));
                s3Object.setContentType("application/octet-string");
                String id = connection.getConnection().addObject(rootS3Bucket, s3Object).get();
                assert id != null : String.format("Should have received an id for entry %1s:%2s ", rootS3Bucket.getName(), b.getBucketName());
            }
        } catch (Exception ex) {
            throw connection.convertToS3ConnectionException("Exception while saving bucket " + b, ex);
View Full Code Here


   
    @Override
    public CloudStoreObjectMetadata sendRefreshMetadataRequest(
                CloudStoreObject obj )
    {
  S3Object jObj = getS3Object( obj );
  return convertToCloopMetadata( jObj.getMetadata( ) );
    }
View Full Code Here

    }
   
    @Override
    public void sendUploadRequest( CloudStoreFile file )
    {
  S3Object obj = new S3Object( file.getPath( ).getAbsolutePath( ), file
    .getStreamToStore( ) );
  if ( file.hasDirtyMetadata( ) )
  {
      obj
        .setMetadata( convertToJCloudMetadata( file.getPath( )
        .getAbsolutePath( ),
                 file
        .getDirtyMetadata( ) ) );
      file.setMetadata( file.getDirtyMetadata( ) );
View Full Code Here

    }
   
    private Metadata convertToJCloudMetadata( String key,
                CloudStoreObjectMetadata metadata )
    {
  Metadata jMeta = new Metadata( key );
  jMeta.setUserMetadata( convertMetadataToMap( metadata ) );
  return jMeta;
    }
View Full Code Here

            }
            if (!properties.containsKey("jclouds.aws.accesskeyid"))
                properties.put("jclouds.aws.accesskeyid", config.getAwsAccessKey());
            if (!properties.containsKey("jclouds.aws.secretaccesskey"))
                properties.put("jclouds.aws.secretaccesskey", config.getAwsSecretKey());
            this.s3Service = S3ConnectionFactory.getConnection(properties, new S3HttpNioConnectionPoolClientModule());
            if (this.s3Service == null) {
                throw new S3ConnectionException("Could not connect");
            }

        } catch (Exception ex) {
View Full Code Here

                        CONSTANT_DATE).put("Authorization", "AWS identity:ZWVz2v/jGB+ZMmijoyfH9mFMPo0=").build())
               .build();

      HttpResponse success = HttpResponse.builder().statusCode(200).build();

      S3Client clientWhenBucketExists = requestsSendResponses(bucketFooExists, redirectResponse, bucketFooExistsNowUsesGET, success);
     
      assert clientWhenBucketExists.bucketExists("foo");

   }
View Full Code Here

         Blob blob = blobStore.blobBuilder(blobName).payload("something").build();
         blobStore.putBlob(containerName, blob,
            storageClass(StorageClass.REDUCED_REDUNDANCY));

         S3Client s3Client = S3Client.class.cast(view.unwrap(AWSS3ApiMetadata.CONTEXT_TOKEN).getApi());
         ListBucketResponse response = s3Client.listBucket(containerName, withPrefix(blobName));

         ObjectMetadata metadata = response.iterator().next();
         assertEquals(metadata.getStorageClass(), StorageClass.REDUCED_REDUNDANCY);

      } finally {
View Full Code Here

         Blob blob = blobStore.blobBuilder(blobName).payload("something").build();
         blobStore.putBlob(containerName, blob,
            storageClass(StorageClass.REDUCED_REDUNDANCY));

         S3Client s3Client = S3Client.class.cast(view.unwrap(AWSS3ApiMetadata.CONTEXT_TOKEN).getApi());
         ListBucketResponse response = s3Client.listBucket(containerName, withPrefix(blobName));

         ObjectMetadata metadata = response.iterator().next();
         assertEquals(metadata.getStorageClass(), StorageClass.REDUCED_REDUNDANCY);

      } finally {
View Full Code Here

                        String.class, PutBucketOptions[].class), Lists.<Object> newArrayList(null, "bucket"))).build();
   }

   @Test
   void testBucketAlreadyOwnedByYouIsOk() throws Exception {
      S3Client client = createMock(S3Client.class);
      replay(client);

      Exception e = getErrorWithCode("BucketAlreadyOwnedByYou");
      assertFalse(getUnchecked(new FalseIfBucketAlreadyOwnedByYouOrOperationAbortedWhenBucketExists(client).setContext(
            putBucket).create(e)));
View Full Code Here

      verify(client);
   }

   @Test
   void testOperationAbortedIsOkWhenBucketExists() throws Exception {
      S3Client client = createMock(S3Client.class);
      expect(client.bucketExists("bucket")).andReturn(true);
      replay(client);
      Exception e = getErrorWithCode("OperationAborted");
      assertFalse(getUnchecked(new FalseIfBucketAlreadyOwnedByYouOrOperationAbortedWhenBucketExists(client).setContext(
            putBucket).create(e)));
      verify(client);
View Full Code Here

TOP

Related Classes of org.jclouds.aws.s3.S3Client

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.