Package ch.iterate.openstack.swift.handler

Examples of ch.iterate.openstack.swift.handler.DefaultResponseHandler


    public String copyObject(Region region, String sourceContainer,
                             String sourceObjName, String destContainer, String destObjName)
            throws IOException {
        HttpPut method = new HttpPut(region.getStorageUrl(destContainer, destObjName));
        method.setHeader(Constants.X_COPY_FROM, encode(sourceContainer) + "/" + encode(sourceObjName));
        Response response = this.execute(method, new DefaultResponseHandler());
        if(response.getStatusCode() == HttpStatus.SC_CREATED) {
            return response.getResponseHeader(HttpHeaders.ETAG).getValue();
        }
        else {
            throw new GenericException(response);
View Full Code Here


     * @throws ch.iterate.openstack.swift.exception.NotFoundException
     *                          The file was not found
     */
    public void deleteObject(Region region, String container, String object) throws IOException {
        HttpDelete method = new HttpDelete(region.getStorageUrl(container, object));
        this.execute(method, new DefaultResponseHandler());
    }
View Full Code Here

        for(String object : objects) {
            final String path = region.getStorageUrl(container, object).getRawPath();
            body.append(path.substring(region.getStorageUrl().getRawPath().length() + 1)).append('\n');
        }
        method.setEntity(new StringEntity(body.toString(), "UTF-8"));
        this.execute(method, new DefaultResponseHandler());
    }
View Full Code Here

            method.setHeader(Constants.MANIFEST_HEADER, manifest);
        }
        for(Map.Entry<String, String> key : this.renameObjectMetadata(metadata).entrySet()) {
            method.setHeader(key.getKey(), key.getValue());
        }
        this.execute(method, new DefaultResponseHandler());
    }
View Full Code Here

                                        Map<String, String> metadata) throws IOException {
        HttpPost method = new HttpPost(region.getStorageUrl(container));
        for(Map.Entry<String, String> key : this.renameContainerMetadata(metadata).entrySet()) {
            method.setHeader(key.getKey(), key.getValue());
        }
        this.execute(method, new DefaultResponseHandler());
    }
View Full Code Here

    public void updateAccountMetadata(Region region, Map<String, String> metadata) throws IOException {
        HttpPost method = new HttpPost(region.getStorageUrl());
        for(Map.Entry<String, String> key : metadata.entrySet()) {
            method.setHeader(key.getKey(), key.getValue());
        }
        this.execute(method, new DefaultResponseHandler());
    }
View Full Code Here

    private Response execute(final HttpRequestBase method) throws IOException {
        try {
            method.setHeader(Constants.X_AUTH_TOKEN, authenticationResponse.getAuthToken());
            try {
                return new DefaultResponseHandler().handleResponse(client.execute(method));
            }
            catch(AuthorizationException e) {
                method.abort();
                // Re-authenticate with previous authentication request
                authenticationResponse = this.authenticate(authenticationRequest);
                method.reset();
                // Add new auth token retrieved
                method.setHeader(Constants.X_AUTH_TOKEN, authenticationResponse.getAuthToken());
                // Retry
                return new DefaultResponseHandler().handleResponse(client.execute(method));
            }
        }
        catch(IOException e) {
            // In case of an IOException the connection will be released back to the connection manager automatically
            method.abort();
View Full Code Here

    private Response execute(final HttpRequestBase method) throws IOException {
        try {
            method.setHeader(Constants.X_AUTH_TOKEN, authenticationResponse.getAuthToken());
            try {
                return new DefaultResponseHandler().handleResponse(client.execute(method));
            }
            catch(AuthorizationException e) {
                method.abort();
                // Re-authenticate with previous authentication request
                authenticationResponse = this.authenticate(authenticationRequest);
                method.reset();
                // Add new auth token retrieved
                method.setHeader(Constants.X_AUTH_TOKEN, authenticationResponse.getAuthToken());
                // Retry
                return new DefaultResponseHandler().handleResponse(client.execute(method));
            }
        }
        catch(IOException e) {
            // In case of an IOException the connection will be released back to the connection manager automatically
            method.abort();
View Full Code Here

     *                                Unexpected response
     * @throws AuthorizationException The openstack was not property logged in
     */
    public void createContainer(Region region, String name) throws IOException {
        HttpPut method = new HttpPut(region.getStorageUrl(name));
        Response response = this.execute(method, new DefaultResponseHandler());
        if(response.getStatusCode() == HttpStatus.SC_CREATED) {
            return;
        }
        else if(response.getStatusCode() == HttpStatus.SC_ACCEPTED) {
            throw new ContainerExistsException(response);
View Full Code Here

     * @throws ch.iterate.openstack.swift.exception.ContainerNotEmptyException
     *                                The container was not empty
     */
    public void deleteContainer(Region region, String name) throws IOException {
        HttpDelete method = new HttpDelete(region.getStorageUrl(name));
        Response response = this.execute(method, new DefaultResponseHandler());
        if(response.getStatusCode() == HttpStatus.SC_CONFLICT) {
            throw new ContainerNotEmptyException(response);
        }
    }
View Full Code Here

TOP

Related Classes of ch.iterate.openstack.swift.handler.DefaultResponseHandler

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.