Package com.cloud.bridge.service.core.s3

Examples of com.cloud.bridge.service.core.s3.S3ConditionFactory


    request.setKey(getObjectExtended.getKey());
    request.setReturnData(getObjectExtended.getGetData());
    request.setReturnMetadata(getObjectExtended.getGetMetadata());
    request.setInlineData(getObjectExtended.getInlineData());
   
    S3ConditionalHeaders conds = new S3ConditionalHeaders();
    conds.setModifiedSince(getObjectExtended.getIfModifiedSince());
    conds.setUnModifiedSince(getObjectExtended.getIfUnmodifiedSince());
    conds.setMatch(getObjectExtended.getIfMatch());
    conds.setNoneMatch(getObjectExtended.getIfNoneMatch());
    request.setConditions(conds);

    request.setByteRangeStart(getObjectExtended.getByteRangeStart());
    request.setByteRangeEnd(getObjectExtended.getByteRangeEnd());
    request.setReturnCompleteObjectOnConditionFailure(getObjectExtended.getReturnCompleteObjectOnConditionFailure());
View Full Code Here


        return engineRequest;
    }

    private S3ConditionalHeaders conditionalRequest( HttpServletRequest request, boolean isCopy )
    {
        S3ConditionalHeaders headers = new S3ConditionalHeaders();

        if (isCopy) {
            headers.setModifiedSince( request.getHeader( "x-amz-copy-source-if-modified-since" ))
            headers.setUnModifiedSince( request.getHeader( "x-amz-copy-source-if-unmodified-since" ))
            headers.setMatch( request.getHeader( "x-amz-copy-source-if-match" ))
            headers.setNoneMatch( request.getHeader( "x-amz-copy-source-if-none-match" ))
        }
        else {
            headers.setModifiedSince( request.getHeader( "If-Modified-Since" ));
            headers.setUnModifiedSince( request.getHeader( "If-Unmodified-Since" ));
            headers.setMatch( request.getHeader( "If-Match" ));
            headers.setNoneMatch( request.getHeader( "If-None-Match" ));
        }
        return headers;
    }
View Full Code Here

        return headers;
    }

    private boolean conditionPassed( HttpServletRequest request, HttpServletResponse response, Date lastModified, String ETag )
    { 
        S3ConditionalHeaders ifCond = conditionalRequest( request, false );

        if (0 > ifCond.ifModifiedSince( lastModified )) {
            response.setStatus( 304 );
            return false;
        }
        if (0 > ifCond.ifUnmodifiedSince( lastModified )) {
            response.setStatus( 412 );
            return false;
        }
        if (0 > ifCond.ifMatchEtag( ETag )) {
            response.setStatus( 412 );
            return false;
        }
        if (0 > ifCond.ifNoneMatchEtag( ETag )) {
            response.setStatus( 412 );
            return false;
       
        return true;
    }
View Full Code Here

  public SetBucketLoggingStatusResponse setBucketLoggingStatus(SetBucketLoggingStatus setBucketLoggingStatus) {
        throw new UnsupportedOperationException("Unsupported API");
    }
      
  public CopyObjectResponse copyObject(CopyObject copyObject) throws AxisFault {
        S3CopyObjectRequest request = new S3CopyObjectRequest();
       
        request.setSourceBucketName(copyObject.getSourceBucket());
        request.setSourceKey(copyObject.getSourceKey());
        request.setDestinationBucketName(copyObject.getDestinationBucket());
        request.setDestinationKey(copyObject.getDestinationKey());
   
        MetadataDirective mdd = copyObject.getMetadataDirective();
        if (null != mdd) request.setDataDirective(mdd.getValue());

    request.setMetaEntries(toEngineMetaEntries(copyObject.getMetadata()));
    request.setAcl(toEngineAccessControlList(copyObject.getAccessControlList()));
   
    S3ConditionalHeaders conds = new S3ConditionalHeaders();
    conds.setModifiedSince(copyObject.getCopySourceIfModifiedSince());
    conds.setUnModifiedSince(copyObject.getCopySourceIfUnmodifiedSince());
    conds.setMatch(copyObject.getCopySourceIfMatch());
    conds.setNoneMatch(copyObject.getCopySourceIfNoneMatch());
    request.setConditions(conds);
   
      return toCopyObjectResponse(engine.handleRequest(request));
   }
View Full Code Here


    private void executeCopyObject(HttpServletRequest request, HttpServletResponse response, String copy)
            throws IOException, XMLStreamException
            {
        S3CopyObjectRequest engineRequest = new S3CopyObjectRequest();
        String versionId = null;

        String bucketName = (String)request.getAttribute(S3Constants.BUCKET_ATTR_KEY);
        String key        = (String)request.getAttribute(S3Constants.OBJECT_ATTR_KEY);
        String sourceBucketName = null;
        String sourceKey        = null;

        // [A] Parse the x-amz-copy-source header into usable pieces
        // Check to find a ?versionId= value if any
        int index = copy.indexOf( '?' );
        if (-1 != index)
        {
            versionId = copy.substring( index+1 );
            if (versionId.startsWith( "versionId=" )) engineRequest.setVersion( versionId.substring( 10 ));
            copy = copy.substring( 0, index );
        }

        // The value of copy should look like: "bucket-name/object-name"
        index = copy.indexOf( '/' );

        // In case it looks like "/bucket-name/object-name" discard a leading '/' if it exists
        if ( 0 == index )
        {
            copy = copy.substring(1);
            index = copy.indexOf( '/' );
        }

        if ( -1 == index )
            throw new IllegalArgumentException( "Invalid x-amz-copy-source header value [" + copy + "]" );

        sourceBucketName = copy.substring( 0, index );
        sourceKey        = copy.substring( index+1 );


        // [B] Set the object used in the SOAP request so it can do the bulk of the work for us
        engineRequest.setSourceBucketName( sourceBucketName );
        engineRequest.setSourceKey( sourceKey );
        engineRequest.setDestinationBucketName( bucketName );
        engineRequest.setDestinationKey( key );

        engineRequest.setDataDirective( request.getHeader( "x-amz-metadata-directive" ));
        engineRequest.setMetaEntries( extractMetaData( request ));
        engineRequest.setCannedAccess( request.getHeader( "x-amz-acl" ));
        engineRequest.setConditions( conditionalRequest( request, true ));


        // [C] Do the actual work and return the result
        S3CopyObjectResponse engineResponse = ServiceProvider.getInstance().getS3Engine().handleRequest( engineRequest );   
View Full Code Here

        engineRequest.setCannedAccess( request.getHeader( "x-amz-acl" ));
        engineRequest.setConditions( conditionalRequest( request, true ));


        // [C] Do the actual work and return the result
        S3CopyObjectResponse engineResponse = ServiceProvider.getInstance().getS3Engine().handleRequest( engineRequest );   

        versionId = engineResponse.getCopyVersion();
        if (null != versionId) response.addHeader( "x-amz-copy-source-version-id", versionId );
        versionId = engineResponse.getPutVersion();
        if (null != versionId) response.addHeader( "x-amz-version-id", versionId );

        // To allow the copy object result to be serialized via Axiom classes
        CopyObjectResponse allBuckets = S3SerializableServiceImplementation.toCopyObjectResponse( engineResponse );
View Full Code Here

  public CreateBucketResponse createBucket (CreateBucket createBucket) {
    return toCreateBucketResponse(engine.handleRequest(toEngineCreateBucketRequest(createBucket)));
    }
 
  private S3CreateBucketRequest toEngineCreateBucketRequest(CreateBucket createBucket) {
    S3CreateBucketRequest request = new S3CreateBucketRequest();
    request.setAccessKey(createBucket.getAWSAccessKeyId());
    request.setRequestTimestamp(createBucket.getTimestamp());
    request.setSignature(createBucket.getSignature());
    request.setBucketName(createBucket.getBucket());
    request.setAcl(toEngineAccessControlList(createBucket.getAccessControlList()));
    return request;
  }
View Full Code Here

            finally {
                if(is != null) is.close();
            }
        }

        S3CreateBucketRequest engineRequest = new S3CreateBucketRequest();
        engineRequest.setBucketName((String)request.getAttribute(S3Constants.BUCKET_ATTR_KEY));
        engineRequest.setConfig((S3CreateBucketConfiguration)objectInContent);
        try {
            S3CreateBucketResponse engineResponse = ServiceProvider.getInstance().getS3Engine().handleRequest(engineRequest);
            response.addHeader("Location", "/" + engineResponse.getBucketName());
            response.setContentLength(0);
            response.setStatus(200);
View Full Code Here

        S3CreateBucketRequest engineRequest = new S3CreateBucketRequest();
        engineRequest.setBucketName((String)request.getAttribute(S3Constants.BUCKET_ATTR_KEY));
        engineRequest.setConfig((S3CreateBucketConfiguration)objectInContent);
        try {
            S3CreateBucketResponse engineResponse = ServiceProvider.getInstance().getS3Engine().handleRequest(engineRequest);
            response.addHeader("Location", "/" + engineResponse.getBucketName());
            response.setContentLength(0);
            response.setStatus(200);
            response.flushBuffer();
        } catch (ObjectAlreadyExistsException oaee) {
            response.setStatus(409);
View Full Code Here

  public DeleteBucketResponse deleteBucket(DeleteBucket deleteBucket) {
    return toDeleteBucketResponse(engine.handleRequest(toEngineDeleteBucketRequest(deleteBucket)));
    }
 
  private S3DeleteBucketRequest toEngineDeleteBucketRequest(DeleteBucket deleteBucket) {
    S3DeleteBucketRequest request = new S3DeleteBucketRequest();
    request.setAccessKey(deleteBucket.getAWSAccessKeyId());
    request.setRequestTimestamp(deleteBucket.getTimestamp());
    request.setSignature(deleteBucket.getSignature());
    request.setBucketName(deleteBucket.getBucket());
    return request;
  }
View Full Code Here

TOP

Related Classes of com.cloud.bridge.service.core.s3.S3ConditionFactory

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.