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

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


        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

    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

        } else
            throw new IllegalArgumentException("Unsupported method in REST request");
    }

    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);

        versionId = engineResponse.getCopyVersion();
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
    // -> is there a ?versionId= value
    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( '/' );
    if ( 0 != index )
       throw new IllegalArgumentException( "Invalid x-amz-copy-sourse header value [" + copy + "]" );
    else copy = copy.substring( 1 );
   
    index = copy.indexOf( '/' );
    if ( -1 == index )
       throw new IllegalArgumentException( "Invalid x-amz-copy-sourse 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

 
  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

TOP

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

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.