Package com.emc.atmos

Examples of com.emc.atmos.AtmosException


        return RestUtil.parseObjectId( response.getLocation().getPath() );
    }

    @Override
    public ListDirectoryResponse listDirectory( ListDirectoryRequest request ) {
        if ( !request.getPath().isDirectory() ) throw new AtmosException( "Path must be a directory" );

        ClientResponse response = build( request ).get( ClientResponse.class );

        request.setToken( response.getHeaders().getFirst( RestUtil.XHEADER_TOKEN ) );
        if ( request.getToken() != null )
View Full Code Here


    }

    @Override
    public ListObjectsResponse listObjects( ListObjectsRequest request ) {
        if ( request.getMetadataName() == null )
            throw new AtmosException( "You must specify the name of a listable piece of metadata" );

        ClientResponse response;
        try {
            response = build( request ).get( ClientResponse.class );
        } catch ( AtmosException e ) {
View Full Code Here

            JerseyUtil.addFilters(client, config);

            return client;
        } catch (Exception e) {
            throw new AtmosException("Error configuring REST client", e);
        }
    }
View Full Code Here

    public static ObjectId parseObjectId( String path ) {
        Matcher matcher = OBJECTID_PATTERN.matcher( path );
        if ( matcher.find() )
            return new ObjectId( matcher.group( 1 ) );
        else
            throw new AtmosException( "Cannot find object ID in path" + path );
    }
View Full Code Here

                // in this case, the exception was wrapped by Jersey
                if ( t instanceof ClientHandlerException ) t = t.getCause();

                if ( t instanceof AtmosException ) {
                    AtmosException ae = (AtmosException) t;

                    // retry all 50x errors
                    if ( ae.getHttpCode() < 500 ) throw orig;

                    // add small delay to Atmos code 1040 (server busy)
                    if ( ae.getErrorCode() == 1040 ) {
                        try {
                            Thread.sleep( ATMOS_1040_DELAY_MS );
                        } catch ( InterruptedException e ) {
                            log.warn( "Interrupted while waiting after a 1040 response: " + e.getMessage() );
                        }
View Full Code Here

            Document d = null;
            try {
                d = sb.build( response.getEntityInputStream() );
            } catch ( Throwable t ) {
                throw new AtmosException( response.getClientResponseStatus().getReasonPhrase(), response.getStatus() );
            }

            String code = d.getRootElement().getChildText( "Code" );
            if ( code == null )
                code = d.getRootElement().getChildText( "Code", Namespace.getNamespace( "http://www.emc.com/cos/" ) );
            String message = d.getRootElement().getChildText( "Message" );
            if ( message == null )
                message = d.getRootElement().getChildText( "Message",
                                                           Namespace.getNamespace( "http://www.emc.com/cos/" ) );

            if ( code == null && message == null ) {
                // not an error from Atmos
                throw new AtmosException( response.getClientResponseStatus().getReasonPhrase(), response.getStatus() );
            }

            log.debug( "Error: " + code + " message: " + message );
            throw new AtmosException( message, response.getStatus(), Integer.parseInt( code ) );
        }

        return response;
    }
View Full Code Here

            JerseyUtil.addFilters(client, config);

            return client;
        } catch (Exception e) {
            throw new AtmosException("Error configuring REST client", e);
        }
    }
View Full Code Here

                        rawMeta = ef.rekey(rawMeta);
                        rekeyed = true;
                    } catch (DoesNotNeedRekeyException e) {
                        throw e;
                    } catch (TransformException e) {
                        throw new AtmosException("Error rekeying object: " + e, e);
                    }
                    found = true;
                    break;
                }
            }
            if(!found) {
                throw new AtmosException("No transformation found to handle '" + mode + "'");
            }
        }
       
        if(!rekeyed) {
            throw new DoesNotNeedRekeyException("Object was not rekeyed");
View Full Code Here

                OutputTransform ot = t.getOutputTransform(in, mMeta);
                appliedTransforms.add(ot);
                in = ot.getEncodedInputStream();
            }
        } catch(TransformException e) {
            throw new AtmosException("Could not transform data: " + e, e);
        } catch (IOException e) {
            throw new AtmosException("Error transforming data: " + e, e);
        }
       
        // Create the object
        int c = 0;
        int pos = 0;
        byte[] buffer = new byte[bufferSize];
       
        // Read the first chunk and send it with the create request.
        try {
            c = fillBuffer(buffer, in);
        } catch (IOException e) {
            throw new AtmosException("Error reading input data: " + e, e);
        }
        if(c == -1) {
            // EOF already
            request.setContent(null);
           
            // Optmization -- send metadata now with create request and return
            try {
                in.close();
            } catch (IOException e) {
                throw new AtmosException("Error closing input: " + e, e);
            }
            for(OutputTransform ot : appliedTransforms) {
                mMeta.putAll(ot.getEncodedMetadata());
            }
            Set<Metadata> metadata = request.getUserMetadata();
            if(metadata == null) {
                metadata = new HashSet<Metadata>();
            }
            updateMetadata(mMeta, metadata);
            request.setUserMetadata(metadata);
           
            return delegate.createObject(request);
        } else {
            request.setContent(new BufferSegment(buffer, 0, c));
        }
        CreateObjectResponse resp = delegate.createObject(request);
       
        pos = c;
       
        // Append until EOF.
        try {
            while((c = fillBuffer(buffer, in)) != -1) {
                UpdateObjectRequest uor = new UpdateObjectRequest();
                uor.setIdentifier(resp.getObjectId());
                uor.setContentType(request.getContentType());
                uor.setRange(new Range(pos, pos+c-1));
                uor.setContent(new BufferSegment(buffer, 0, c));
                pos += c;
                delegate.updateObject(uor);
            }
        } catch (IOException e) {
            throw new AtmosException("Error reading input data: " + e, e);
        }
       
        try {
            in.close();
        } catch (IOException e) {
            throw new AtmosException("Error closing stream: " + e, e);
        }
       
        String transformConfig = "";
        // Update the object with the transformed metadata.
        for(OutputTransform ot : appliedTransforms) {
View Full Code Here

                            InputTransform trans = f.getInputTransform(mode, streamToDecode, rawMeta);
                            streamToDecode = trans.getDecodedInputStream();
                            rawMeta = trans.getDecodedMetadata();
                            found = true;
                        } catch (TransformException e) {
                            throw new AtmosException("Error transforming object data: " + e, e);
                        }
                        continue;
                    }
                }
                if(!found) {
                    throw new AtmosException("No transformation found to handle '" + mode + "'");
                }
            }
           
            // Update response with decoded data
            rawResponse.setObject(streamToDecode);
View Full Code Here

TOP

Related Classes of com.emc.atmos.AtmosException

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.