Package org.jets3t.service

Examples of org.jets3t.service.S3ServiceException


            AWSCredentials awsCredentials = new AWSCredentials(keys.substring(0, delimOffset), keys
                .substring(delimOffset + KEYS_DELIMITER.length()), friendlyName);
           
            return awsCredentials;
        } catch (BadPaddingException bpe) {
            throw new S3ServiceException("Unable to decrypt AWS credentials. Is your password correct?", bpe);
        } catch (Throwable t) {
            throw new S3ServiceException("Failed to load AWS credentials", t);
        } finally {
            if (inputStream != null) {
                try {
                    inputStream.close();
                } catch (IOException e) {
View Full Code Here


        final String bucketName, String targetPath, final String delimiter, int toDepth)
        throws S3ServiceException
    {
        final List allObjects = Collections.synchronizedList(new ArrayList());
        final List lastCommonPrefixes = Collections.synchronizedList(new ArrayList());
        final S3ServiceException s3ServiceExceptions[] = new S3ServiceException[1];
       
        /*
         * Create a S3ServiceMulti object with an event listener that responds to
         * ListObjectsEvent notifications and populates a complete object listing.
         */
        final S3ServiceMulti s3Multi = new S3ServiceMulti(s3Service, new S3ServiceEventAdaptor() {
            public void s3ServiceEventPerformed(ListObjectsEvent event) {
                if (ListObjectsEvent.EVENT_IN_PROGRESS == event.getEventCode()) {
                    Iterator chunkIter = event.getChunkList().iterator();
                    while (chunkIter.hasNext()) {
                        S3ObjectsChunk chunk = (S3ObjectsChunk) chunkIter.next();
                       
                        if (log.isDebugEnabled()) {
                          log.debug("Listed " + chunk.getObjects().length
                            + " objects and " + chunk.getCommonPrefixes().length
                            + " common prefixes in bucket '" + bucketName
                            + "' using prefix=" + chunk.getPrefix()
                            + ", delimiter=" + chunk.getDelimiter());
                        }

                        allObjects.addAll(Arrays.asList(chunk.getObjects()));
                        lastCommonPrefixes.addAll(Arrays.asList(chunk.getCommonPrefixes()));
                    }
                } else if (ListObjectsEvent.EVENT_ERROR == event.getEventCode()) {
                    s3ServiceExceptions[0] = new S3ServiceException(
                        "Failed to list all objects in S3 bucket",
                        event.getErrorCause());                   
                }
            }
        })
View Full Code Here

        String bucketListingProperties = jets3tProperties.getStringProperty(
            "filecomparer.bucket-listing." + bucketName, null);
        if (bucketListingProperties != null) {
            String splits[] = bucketListingProperties.split(",");
            if (splits.length != 2) {
                throw new S3ServiceException(
                    "Invalid setting for bucket listing property "
                    + "filecomparer.bucket-listing." + bucketName + ": '" +
                    bucketListingProperties + "'");
            }           
            delimiter = splits[0].trim();
View Full Code Here

        if (skipMetadata) {
            s3Objects = s3ObjectsIncomplete;           
        } else {
            // 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

    /*
     * This method is a nasty hack - we should build the XML document in a more professional way...
     */
  public String toXml() throws S3ServiceException {
        if (owner == null) {
            throw new S3ServiceException("Invalid AccessControlList: missing an S3Owner");
        }
       
    StringBuffer sb = new StringBuffer();
    sb.append(
      "<AccessControlPolicy xmlns=\"" + Constants.XML_NAMESPACE + "\">" +
View Full Code Here

    private AmazonS3SoapBindingStub getSoapBinding() throws S3ServiceException {
        try {
            return (AmazonS3SoapBindingStub) locator.getAmazonS3();
        } catch (ServiceException e) {
            throw new S3ServiceException("Unable to initialise SOAP binding", e);
        }
    }
View Full Code Here

                AmazonCustomerByEmail customerByEmail = (AmazonCustomerByEmail) grantee;
                EmailAddressGrantee jets3tGrantee = new EmailAddressGrantee();
                jets3tGrantee.setIdentifier(customerByEmail.getEmailAddress());
                acl.grantPermission(jets3tGrantee, permission);               
            } else {
                throw new S3ServiceException("Unrecognised grantee type: " + grantee.getClass());
            }
        }
        return acl;
    }
View Full Code Here

    private Grant[] convertACLtoGrants(AccessControlList acl) throws S3ServiceException {
        if (acl == null) {
            return null;
        }
        if (acl.isCannedRestACL()) {
            throw new S3ServiceException("Cannot use canned REST ACLs with SOAP service");       
        }       
       
        Grant[] grants = new Grant[acl.getGrants().size()];
           
        Iterator grantIter = acl.getGrants().iterator();
        int index = 0;
        while (grantIter.hasNext()) {
            GrantAndPermission jets3tGaP = (GrantAndPermission) grantIter.next();
            GranteeInterface jets3tGrantee = jets3tGaP.getGrantee();
            Grant grant = new Grant();
           
            if (jets3tGrantee instanceof GroupGrantee) {
                GroupGrantee groupGrantee = (GroupGrantee) jets3tGrantee;
                Group group = new Group();
                group.setURI(groupGrantee.getIdentifier());
                grant.setGrantee(group);
            } else if (jets3tGrantee instanceof CanonicalGrantee) {
                CanonicalGrantee canonicalGrantee = (CanonicalGrantee) jets3tGrantee;
                CanonicalUser canonicalUser = new CanonicalUser();
                canonicalUser.setID(canonicalGrantee.getIdentifier());
                canonicalUser.setDisplayName(canonicalGrantee.getDisplayName());
                grant.setGrantee(canonicalUser);
            } else if (jets3tGrantee instanceof EmailAddressGrantee) {
                EmailAddressGrantee emailGrantee = (EmailAddressGrantee) jets3tGrantee;
                AmazonCustomerByEmail customerByEmail = new AmazonCustomerByEmail();
                customerByEmail.setEmailAddress(emailGrantee.getIdentifier());
                grant.setGrantee(customerByEmail);
            } else {
                throw new S3ServiceException("Unrecognised jets3t grantee type: "
                    + jets3tGrantee.getClass());
            }
            Permission permission = Permission.fromString(jets3tGaP.getPermission().toString());
            grant.setPermission(permission);
            grants[index++] = grant;
View Full Code Here

                buckets[index++] = bucket;
            }
        } catch (RuntimeException e) {
            throw e;
        } catch (Exception e) {
            throw new S3ServiceException("Unable to List Buckets", e);
        }
        return buckets;
    }
View Full Code Here

            return false;
        }
    }
   
    public int checkBucketStatus(String bucketName) throws S3ServiceException {
        throw new S3ServiceException("The method checkBucketStatus(String bucketName) "
            + "is not implemented in " + this.getClass().getName());
    }   
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.