Examples of AmazonS3SoapBindingStub


Examples of com.amazonaws.s3.doc._2006_03_01.AmazonS3SoapBindingStub

       
        long startTime = System.currentTimeMillis();
       
       
        AmazonS3_ServiceLocator locator = new AmazonS3_ServiceLocator();
        AmazonS3SoapBindingStub binding = new AmazonS3SoapBindingStub(new URL(locator.getAmazonS3Address()), locator);
       
        result = binding.getObject(getBucketName(),
                      key,
                      false,
                      true,
                      false,
                      access.getAccessKey(),
                      access.getAccessCalendar(),
                      access.generateSignature("GetObject"),
                      null);
       
       
        long endTime = System.currentTimeMillis();
       
               
        /* Get the attachments. Note, the getAttachments() method will ONLY return the object[] on the first call.  Subsiquent calls will return null */
        Object[] attachments = binding.getAttachments();
        if (attachments.length != 1)
        {
          throw new Exception("The S3 Object returned [" + attachments.length + "] when we expected exactly 1");
        }
       
View Full Code Here

Examples of com.amazonaws.s3.doc._2006_03_01.AmazonS3SoapBindingStub

   
      long startTime = System.currentTimeMillis();
     
     
      AmazonS3_ServiceLocator locator = new AmazonS3_ServiceLocator();
      AmazonS3SoapBindingStub binding = new AmazonS3SoapBindingStub(new URL(locator.getAmazonS3Address()), locator);
      DataHandler dataHandler = new DataHandler(new SourceDataSource(null, MIMETYPE_OCTET_STREAM, new StreamSource(is)));
            binding.addAttachment(dataHandler);
     
      PutObjectResult result = binding.putObject(getBucketName(),
                            key,
                            metaData ,
                            length,
                            null,
                            storageClass,
View Full Code Here

Examples of org.jets3t.service.impl.soap.axis._2006_03_01.AmazonS3SoapBindingStub

    protected S3Bucket[] listAllBucketsImpl() throws S3ServiceException {
        log.debug("Listing all buckets for AWS user: " + getAWSCredentials().getAccessKey());
       
        S3Bucket[] buckets = null;
        try {
            AmazonS3SoapBindingStub s3SoapBinding = getSoapBinding();
            Calendar timestamp = getTimeStamp( System.currentTimeMillis() );           
            String signature = ServiceUtils.signWithHmacSha1(getAWSSecretKey(),
                Constants.SOAP_SERVICE_NAME + "ListAllMyBuckets" + convertDateToString(timestamp));
            ListAllMyBucketsResult result = s3SoapBinding.listAllMyBuckets(
                getAWSAccessKey(), timestamp, signature);

            ListAllMyBucketsEntry[] entries = result.getBuckets();           
            buckets = new S3Bucket[entries.length];
            int index = 0;
View Full Code Here

Examples of org.jets3t.service.impl.soap.axis._2006_03_01.AmazonS3SoapBindingStub

    }

    public boolean isBucketAccessible(String bucketName) throws S3ServiceException {
        log.debug("Checking existence of bucket: " + bucketName);
        try {
            AmazonS3SoapBindingStub s3SoapBinding = getSoapBinding();
            Calendar timestamp = getTimeStamp( System.currentTimeMillis() );
            String signature = ServiceUtils.signWithHmacSha1(getAWSSecretKey(),
                        Constants.SOAP_SERVICE_NAME + "ListBucket" + convertDateToString(timestamp));
            s3SoapBinding.listBucket(
                bucketName, null, null, new Integer(0),
                null, getAWSAccessKey(), timestamp, signature, null);
           
            // If we get this far, the bucket exists.
            return true;
View Full Code Here

Examples of org.jets3t.service.impl.soap.axis._2006_03_01.AmazonS3SoapBindingStub

        boolean incompleteListing = true;           

        try {
            while (incompleteListing) {
                AmazonS3SoapBindingStub s3SoapBinding = getSoapBinding();
                Calendar timestamp = getTimeStamp( System.currentTimeMillis() );
                String signature = ServiceUtils.signWithHmacSha1(getAWSSecretKey(),
                    Constants.SOAP_SERVICE_NAME + "ListBucket" + convertDateToString(timestamp));
                ListBucketResult result = s3SoapBinding.listBucket(
                    bucketName, prefix, priorLastKey, new Integer((int)maxListingLength),
                    delimiter, getAWSAccessKey(), timestamp, signature, null);
               
                ListEntry[] entries = result.getContents();
                S3Object[] partialObjects = new S3Object[
View Full Code Here

Examples of org.jets3t.service.impl.soap.axis._2006_03_01.AmazonS3SoapBindingStub

        Grant[] grants = null;
        if (acl != null) {
            grants = convertACLtoGrants(acl);       
        }
        try {
            AmazonS3SoapBindingStub s3SoapBinding = getSoapBinding();
            Calendar timestamp = getTimeStamp( System.currentTimeMillis() );
            String signature = ServiceUtils.signWithHmacSha1(getAWSSecretKey(),
                Constants.SOAP_SERVICE_NAME + "CreateBucket" + convertDateToString(timestamp));
            s3SoapBinding.createBucket(
                bucketName, grants, getAWSAccessKey(), timestamp, signature);
           
            S3Bucket bucket = new S3Bucket(bucketName);
            bucket.setAcl(acl);
            return bucket;           
View Full Code Here

Examples of org.jets3t.service.impl.soap.axis._2006_03_01.AmazonS3SoapBindingStub

    }

   
    protected void deleteBucketImpl(String bucketName) throws S3ServiceException {
        try {
            AmazonS3SoapBindingStub s3SoapBinding = getSoapBinding();
            Calendar timestamp = getTimeStamp( System.currentTimeMillis() );
            String signature = ServiceUtils.signWithHmacSha1(getAWSSecretKey(),
                Constants.SOAP_SERVICE_NAME + "DeleteBucket" + convertDateToString(timestamp));
            s3SoapBinding.deleteBucket(
                bucketName, getAWSAccessKey(), timestamp, signature, null);
        } catch (RuntimeException e) {
            throw e;
        } catch (Exception e) {
            throw new S3ServiceException("Unable to Delete Bucket: " + bucketName, e);  
View Full Code Here

Examples of org.jets3t.service.impl.soap.axis._2006_03_01.AmazonS3SoapBindingStub

            grants = convertACLtoGrants(object.getAcl());
        }
        MetadataEntry[] metadata = convertMetadata(object.getMetadataMap());
       
        try {
            AmazonS3SoapBindingStub s3SoapBinding = getSoapBinding();
            long contentLength = object.getContentLength();
            String contentType = object.getContentType();
            if (contentType == null) {
                // Set default content type.
                contentType = Mimetypes.MIMETYPE_OCTET_STREAM;
            }
           
            if (object.getDataInputStream() != null) {               
                log.debug("Uploading data input stream for S3Object: " + object.getKey());
               
                if (contentLength == 0 && object.getDataInputStream().available() > 0) {
                   
                    log.warn("S3Object " + object.getKey()
                        + " - Content-Length was set to 0 despite having a non-empty data"
                        + " input stream. The Content-length will be determined in memory.");
                   
                    // Read all data into memory to determine it's length.
                    BufferedInputStream bis = new BufferedInputStream(object.getDataInputStream());
                    ByteArrayOutputStream baos = new ByteArrayOutputStream();
                    BufferedOutputStream bos = new BufferedOutputStream(baos);
                    try {
                        byte[] buffer = new byte[8192];
                        int read = -1;
                        while ((read = bis.read(buffer)) != -1) {
                            bos.write(buffer, 0, read);
                        }
                    } finally {
                        if (bis != null) {
                            bis.close();                           
                        }
                        if (bos != null) {
                            bos.close();                       
                        }
                    }

                    contentLength = baos.size();
                    object.setDataInputStream(new ByteArrayInputStream(baos.toByteArray()));
                   
                    log.debug("Content-Length value has been reset to " + contentLength);
                }               
               
                DataHandler dataHandler = new DataHandler(
                    new SourceDataSource(
                        null, contentType, new StreamSource(object.getDataInputStream())));          
                s3SoapBinding.addAttachment(dataHandler);               
            } else {
                DataHandler dataHandler = new DataHandler(
                    new SourceDataSource(
                        null, contentType, new StreamSource()));
                s3SoapBinding.addAttachment(dataHandler);               
            }
           
            Calendar timestamp = getTimeStamp( System.currentTimeMillis() );
            String signature = ServiceUtils.signWithHmacSha1(getAWSSecretKey(),
                Constants.SOAP_SERVICE_NAME + "PutObject" + convertDateToString(timestamp));
            PutObjectResult result =
                s3SoapBinding.putObject(bucketName, object.getKey(), metadata,
                    contentLength, grants, null, getAWSAccessKey(),
                    timestamp, signature, null);
           
            // Ensure no data was corrupted, if we have the MD5 hash available to check.
            String eTag = result.getETag().substring(1, result.getETag().length() - 1);
View Full Code Here

Examples of org.jets3t.service.impl.soap.axis._2006_03_01.AmazonS3SoapBindingStub

        return object;
    }

    protected void deleteObjectImpl(String bucketName, String objectKey) throws S3ServiceException {
        try {
            AmazonS3SoapBindingStub s3SoapBinding = getSoapBinding();
            Calendar timestamp = getTimeStamp( System.currentTimeMillis() );
            String signature = ServiceUtils.signWithHmacSha1(getAWSSecretKey(),
                Constants.SOAP_SERVICE_NAME + "DeleteObject" + convertDateToString(timestamp));
            s3SoapBinding.deleteObject(bucketName, objectKey,
                getAWSAccessKey(), timestamp, signature, null);
        } catch (RuntimeException e) {
            throw e;
        } catch (Exception e) {
            throw new S3ServiceException("Unable to Delete Object: " + objectKey, e);  
View Full Code Here

Examples of org.jets3t.service.impl.soap.axis._2006_03_01.AmazonS3SoapBindingStub

            ifModifiedSince != null || ifUnmodifiedSince != null
            || ifMatchTags != null || ifNoneMatchTags != null
            || byteRangeStart != null || byteRangeEnd != null;
       
        try {
            AmazonS3SoapBindingStub s3SoapBinding = getSoapBinding();
            Calendar timestamp = getTimeStamp( System.currentTimeMillis() );
            GetObjectResult result = null;
           
            if (useExtendedGet) {
                log.debug("Using Extended GET to apply constraints: "
                    + "ifModifiedSince=" + (ifModifiedSince != null? ifModifiedSince.getTime().toString() : "null")
                    + ", ifUnmodifiedSince=" + (ifUnmodifiedSince != null? ifUnmodifiedSince.getTime().toString() : "null")
                    + ", ifMatchTags=" + (ifMatchTags != null? Arrays.asList(ifMatchTags).toString() : "null")
                    + ", ifNoneMatchTags=" + (ifNoneMatchTags != null? Arrays.asList(ifNoneMatchTags).toString() : "null")
                    + ", byteRangeStart=" + byteRangeStart + ", byteRangeEnd=" + byteRangeEnd);
               
                String signature = ServiceUtils.signWithHmacSha1(getAWSSecretKey(),
                    Constants.SOAP_SERVICE_NAME + "GetObjectExtended" + convertDateToString(timestamp));
                result = s3SoapBinding.getObjectExtended(
                    bucketName, objectKey, true, withData, false, byteRangeStart, byteRangeEnd,
                    ifModifiedSince, ifUnmodifiedSince, ifMatchTags, ifNoneMatchTags,
                    Boolean.FALSE, getAWSAccessKey(), timestamp, signature, null);
               
                // Throw an exception if the preconditions failed.
                int expectedStatusCode = 200;
                if (byteRangeStart != null || byteRangeEnd != null) {
                    // Partial data responses have a status code of 206.
                    expectedStatusCode = 206;
                }
                if (result.getStatus().getCode() != expectedStatusCode) {
                    throw new S3ServiceException("Precondition failed when getting object "
                        + objectKey + ": " + result.getStatus().getDescription());
                }
            } else {
                log.debug("Using standard GET (no constraints to apply)");
                String signature = ServiceUtils.signWithHmacSha1(getAWSSecretKey(),
                    Constants.SOAP_SERVICE_NAME + "GetObject" + convertDateToString(timestamp));
                result = s3SoapBinding.getObject(
                    bucketName, objectKey, true, withData, false,               
                    getAWSAccessKey(), timestamp, signature, null);               
            }
           
            S3Object object = new S3Object(objectKey);
            object.setETag(result.getETag());
            object.setLastModifiedDate(result.getLastModified().getTime());
            object.setBucketName(bucketName);
           
            // Get data details from the SOAP attachment.
            if (withData) {
                Object[] attachments = s3SoapBinding.getAttachments();
                log.debug("SOAP attachment count for " + object.getKey() + ": " + attachments.length);
                for (int i = 0; i < attachments.length; i++) {
                    if (i > 0) {
                        throw new S3ServiceException(
                            "Received multiple SOAP attachment parts, this shouldn't happen");
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.