Package org.jets3t.service

Examples of org.jets3t.service.ServiceException


            if(!validAscii) {
                String message =
                        "User metadata name is incompatible with the S3 REST interface, " +
                                "only ASCII characters are allowed in HTTP headers: " + key;
                if(encodingException == null) {
                    throw new ServiceException(message);
                }
                else {
                    throw new ServiceException(message, encodingException);
                }
            }

            // Fail early if user-supplied metadata cannot be represented as valid HTTP headers,
            // rather than waiting for a SignatureDoesNotMatch error.
            // NOTE: These checks are very much incomplete.
            if(value.indexOf('\n') >= 0 || value.indexOf('\r') >= 0) {
                throw new ServiceException("The value of metadata item " + key
                        + " cannot be represented as an HTTP header for the REST S3 interface: "
                        + value);
            }

            // Ensure each AMZ header is uniquely identified according to the lowercase name.
            String duplicateValue = (String) headersAlreadySeenMap.get(key.toLowerCase(Locale.ENGLISH));
            if(duplicateValue != null && !duplicateValue.equals(value)) {
                throw new ServiceException(
                        "HTTP header name occurs multiple times in request with different values, " +
                                "probably due to mismatched capitalization when setting metadata names. " +
                                "Duplicate metadata name: '" + key + "', All metadata: " + metadata);
            }
View Full Code Here


            return;
        }

        // Compare our locally-calculated hash with the ETag returned by S3.
        if(!expectedETag.equals(uploadedObject.getETag())) {
            throw new ServiceException("Mismatch between MD5 hash of uploaded data ("
                    + expectedETag + ") and ETag returned by S3 ("
                    + uploadedObject.getETag() + ") for object key: "
                    + uploadedObject.getKey());
        }
        else {
View Full Code Here

            String xml = builder.asString(null);
            return performRestPut(bucketName, objectKey, metadata, requestParameters,
                    new StringEntity(xml, ContentType.create("text/plain", Constants.DEFAULT_ENCODING)), true);
        }
        catch(TransformerException e) {
            throw new ServiceException("Failed to PUT request containing an XML document", e);
        }
    }
View Full Code Here

        catch(Exception e) {
            if(e instanceof ServiceException) {
                throw (ServiceException) e;
            }
            else {
                throw new ServiceException("Failed to POST request containing an XML document", e);
            }
        }
    }
View Full Code Here

     *
     */
    protected HttpUriRequest setupConnection(HTTP_METHOD method, String bucketName,
                                             String objectKey, Map<String, String> requestParameters) throws ServiceException {
        if(bucketName == null) {
            throw new ServiceException("Cannot connect to S3 Service with a null path");
        }

        boolean disableDnsBuckets = this.getDisableDnsBuckets();
        String endPoint = this.getEndpoint();
        String hostname = ServiceUtils.generateS3HostnameForBucket(
View Full Code Here

        String bucketName = ""; // Root path of S3 service lists the user's buckets.
        HttpResponse httpResponse = performRestGet(bucketName, null, null, headers);
        String contentType = httpResponse.getFirstHeader("Content-Type").getValue();

        if(!isXmlContentType(contentType)) {
            throw new ServiceException("Expected XML document response from S3 but received content type " +
                    contentType);
        }

        return getXmlResponseSaxParser()
                .parseListMyBucketsResponse(
View Full Code Here

        String bucketName = ""; // Root path of S3 service lists the user's buckets.
        HttpResponse httpResponse = performRestGet(bucketName, null, null, null);
        String contentType = httpResponse.getFirstHeader("Content-Type").getValue();

        if(!isXmlContentType(contentType)) {
            throw new ServiceException("Expected XML document response from S3 but received content type " +
                    contentType);
        }

        return getXmlResponseSaxParser()
                .parseListMyBucketsResponse(
View Full Code Here

                String configXml = config.toXml();
                metadata.put("Content-Length", String.valueOf(configXml.length()));
                requestEntity = new StringEntity(configXml, ContentType.create("text/plain", Constants.DEFAULT_ENCODING));
            }
            catch(ParserConfigurationException e) {
                throw new ServiceException("Unable to encode CreateBucketConfiguration XML document", e);
            }
            catch(TransformerException e) {
                throw new ServiceException("Unable to encode CreateBucketConfiguration XML document", e);
            }
        }

        Map<String, Object> map = createObjectImpl(bucketName, null, null,
                requestEntity, metadata, null, acl, null, null);
View Full Code Here

        String statusAsXml;
        try {
            statusAsXml = status.toXml();
        }
        catch(Exception e) {
            throw new ServiceException("Unable to generate LoggingStatus XML document", e);
        }
        try {
            performRestPut(bucketName, null, metadata, requestParameters,
                    new StringEntity(statusAsXml, ContentType.create("text/plain", Constants.DEFAULT_ENCODING)),
                    true);
        }
        catch(ServiceException se) {
            throw new ServiceException(se);
        }
    }
View Full Code Here

                basicHttpEntity.setContent(object.getDataInputStream());
                try {
                    requestEntity = new BufferedHttpEntity(basicHttpEntity);
                }
                catch(IOException ioe) {
                    throw new ServiceException("Unable to read data stream of unknown length", ioe);
                }
            }
        }
        putObjectWithRequestEntityImpl(bucketName, object, requestEntity, null);
View Full Code Here

TOP

Related Classes of org.jets3t.service.ServiceException

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.