Package com.emc.atmos

Examples of com.emc.atmos.AtmosException


    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


                        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

       
        ReadObjectRequest request = new ReadObjectRequest().identifier(identifier);
        try {
            return readObject(request, InputStream.class);
        } catch (IOException e) {
            throw new AtmosException("Error getting response stream: " + e, e);
        }
    }
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);
        }

        // Overwrite 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.updateObject(request);
        } else {
            request.setContent(new BufferSegment(buffer, 0, c));
        }
        BasicResponse resp = delegate.updateObject(request);
       
        pos = c;
       
        // Append until EOF.
        try {
            while((c = fillBuffer(buffer, in)) != -1) {
                UpdateObjectRequest uor = new UpdateObjectRequest();
                uor.setIdentifier(request.getIdentifier());
                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

            addFilters( client, config );

            return client;

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

    @Override
    public long calculateServerClockSkew() {
        ClientResponse response = client.resource( config.resolvePath( "", null ) ).get( ClientResponse.class );

        if ( response.getResponseDate() == null )
            throw new AtmosException( "Response date is null", response.getStatus() );

        config.setServerClockSkew( System.currentTimeMillis() - response.getResponseDate().getTime() );

        response.close();
View Full Code Here

        builder.delete();
    }

    @Override
    public ObjectId createDirectory( ObjectPath path ) {
        if ( !path.isDirectory() ) throw new AtmosException( "Path must be a directory" );

        CreateObjectRequest request = new CreateObjectRequest().identifier( path );

        ClientResponse response = build( request ).post( ClientResponse.class );
View Full Code Here

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

    @Override
    public ObjectId createDirectory( ObjectPath path, Acl acl, Metadata... metadata ) {
        if ( !path.isDirectory() ) throw new AtmosException( "Path must be a directory" );

        CreateObjectRequest request = new CreateObjectRequest().identifier( path ).acl( acl );
        request.userMetadata( metadata );

        ClientResponse response = build( request ).post( ClientResponse.class );
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.