Package org.jets3t.service

Examples of org.jets3t.service.S3ServiceException


        S3Object[] s3ObjectsIncomplete, S3ServiceEventListener s3ServiceEventListener)
        throws S3ServiceException
    {
        // Retrieve the complete information about all objects listed via GetObjectsHeads.
        final ArrayList s3ObjectsCompleteList = new ArrayList(s3ObjectsIncomplete.length);
        final S3ServiceException s3ServiceExceptions[] = new S3ServiceException[1];
        S3ServiceMulti s3ServiceMulti = new S3ServiceMulti(s3Service, new S3ServiceEventAdaptor() {
            public void s3ServiceEventPerformed(GetObjectHeadsEvent event) {
                if (GetObjectHeadsEvent.EVENT_IN_PROGRESS == event.getEventCode()) {
                    S3Object[] finishedObjects = event.getCompletedObjects();
                    if (finishedObjects.length > 0) {
                        s3ObjectsCompleteList.addAll(Arrays.asList(finishedObjects));
                    }
                } else if (GetObjectHeadsEvent.EVENT_ERROR == event.getEventCode()) {
                    s3ServiceExceptions[0] = new S3ServiceException(
                        "Failed to retrieve detailed information about all S3 objects",
                        event.getErrorCause());                   
                }
            }
        });
View Full Code Here


    protected S3Bucket createBucketImpl(String bucketName, String location,
        AccessControlList acl) throws S3ServiceException
    {
        if (location != S3Bucket.LOCATION_US) {
            throw new S3ServiceException("The SOAP API interface for S3 does " +
                "not allow you to create buckets located anywhere other than " +
                "the US");
        }
       
        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;           
        } catch (RuntimeException e) {
            throw e;
        } catch (Exception e) {
            throw new S3ServiceException("Unable to Create Bucket: " + bucketName, e);  
        }
    }
View Full Code Here

    }
   
    protected String getBucketLocationImpl(String bucketName)
        throws S3ServiceException
    {
        throw new S3ServiceException("The SOAP API interface for S3 does " +
            "not allow you to retrieve location information for a bucket");   
    }
View Full Code Here

            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

            String eTag = result.getETag().substring(1, result.getETag().length() - 1);
            String eTagAsBase64 = ServiceUtils.toBase64(
                ServiceUtils.fromHex(eTag));
            String md5HashAsBase64 = object.getMd5HashAsBase64();           
            if (md5HashAsBase64 != null && !eTagAsBase64.equals(md5HashAsBase64)) {
                throw new S3ServiceException(
                    "Object created but ETag returned by S3 does not match MD5 hash value of object");
            }
           
            object.setETag(result.getETag());
            object.setContentLength(contentLength);
            object.setContentType(contentType);
        } catch (RuntimeException e) {
            throw e;
        } catch (Exception e) {
            throw new S3ServiceException("Unable to Create Object: " + object.getKey(), e);  
        }
        return object;
    }
View Full Code Here

            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

                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");
                    }
                    AttachmentPart part = (AttachmentPart) attachments[i];
                    object.setContentType(part.getContentType());
                    object.setContentLength(part.getSize());
                    object.setDataInputStream(part.getDataHandler().getInputStream());
                }
            }
           
            // Populate object's metadata details.
            MetadataEntry[] metadata = result.getMetadata();
            for (int i = 0; i < metadata.length; i++) {
                MetadataEntry entry = metadata[i];
                object.addMetadata(entry.getName(), entry.getValue());
            }
            object.setMetadataComplete(true);
           
            return object;
        } catch (RuntimeException e) {
            throw e;
        } catch (Exception e) {
            throw new S3ServiceException("Unable to Get Object: " + objectKey, e);  
        }
    }
View Full Code Here

            s3SoapBinding.setObjectAccessControlPolicy(bucketName, objectKey, grants,
                getAWSAccessKey(), timestamp, signature, null);
        } catch (RuntimeException e) {
            throw e;
        } catch (Exception e) {
            throw new S3ServiceException("Unable to Put Object ACL", e);  
        }
    }
View Full Code Here

            s3SoapBinding.setBucketAccessControlPolicy(bucketName, grants,
                getAWSAccessKey(), timestamp, signature, null);
        } catch (RuntimeException e) {
            throw e;
        } catch (Exception e) {
            throw new S3ServiceException("Unable to Put Bucket ACL", e);  
        }       
    }
View Full Code Here

                timestamp, signature, null);
            return convertAccessControlTypes(result);
        } catch (RuntimeException e) {
            throw e;
        } catch (Exception e) {
            throw new S3ServiceException("Unable to Get ACL", e);  
        }
    }
View Full Code Here

TOP

Related Classes of org.jets3t.service.S3ServiceException

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.