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

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


        xml.append( "<IsTruncated>" ).append( engineResponse.isTruncated()).append( "</IsTruncated>" );
       
        S3ListBucketObjectEntry[] versions = engineResponse.getContents();
        for( int i=0; null != versions && i < versions.length; i++ )
        {
           S3CanonicalUser owner    = versions[i].getOwner();
           boolean isDeletionMarker = versions[i].getIsDeletionMarker();
           String displayName       = owner.getDisplayName();
           String id                = owner.getID();
          
           if ( isDeletionMarker )
           {    
              xml.append( "<DeleteMarker>" );    
                  xml.append( "<Key>" ).append( versions[i].getKey()).append( "</Key>" );
                  xml.append( "<VersionId>" ).append( versions[i].getVersion()).append( "</VersionId>" );
                  xml.append( "<IsLatest>" ).append( versions[i].getIsLatest()).append( "</IsLatest>" );
                  xml.append( "<LastModified>" ).append( DatatypeConverter.printDateTime( versions[i].getLastModified())).append( "</LastModified>" );
           }
           else
           {     xml.append( "<Version>" );    
                  xml.append( "<Key>" ).append( versions[i].getKey()).append( "</Key>" );
                  xml.append( "<VersionId>" ).append( versions[i].getVersion()).append( "</VersionId>" );
                  xml.append( "<IsLatest>" ).append( versions[i].getIsLatest()).append( "</IsLatest>" );
                  xml.append( "<LastModified>" ).append( DatatypeConverter.printDateTime( versions[i].getLastModified())).append( "</LastModified>" );
                  xml.append( "<ETag>" ).append( versions[i].getETag()).append( "</ETag>" );
                  xml.append( "<Size>" ).append( versions[i].getSize()).append( "</Size>" );
                  xml.append( "<StorageClass>" ).append( versions[i].getStorageClass()).append( "</StorageClass>" );
           }
          
             xml.append( "<Owner>" );
             xml.append( "<ID>" ).append( id ).append( "</ID>" );
             if ( null == displayName )
                  xml.append( "<DisplayName/>" );
             else xml.append( "<DisplayName>" ).append( owner.getDisplayName()).append( "</DisplayName>" );
             xml.append( "</Owner>" );
          
             if ( isDeletionMarker )
                xml.append( "</DeleteMarker>" );
             else xml.append( "</Version>" );
View Full Code Here


        xml.append( "<IsTruncated>" ).append( engineResponse.isTruncated()).append( "</IsTruncated>" );

        S3ListBucketObjectEntry[] versions = engineResponse.getContents();
        for( int i=0; null != versions && i < versions.length; i++ )
        {
            S3CanonicalUser owner    = versions[i].getOwner();
            boolean isDeletionMarker = versions[i].getIsDeletionMarker();
            String displayName       = owner.getDisplayName();
            String id                = owner.getID();

            if ( isDeletionMarker )
            {    
                xml.append( "<DeleteMarker>" );    
                xml.append( "<Key>" ).append( versions[i].getKey()).append( "</Key>" );
                xml.append( "<VersionId>" ).append( versions[i].getVersion()).append( "</VersionId>" );
                xml.append( "<IsLatest>" ).append( versions[i].getIsLatest()).append( "</IsLatest>" );
                xml.append( "<LastModified>" ).append( DatatypeConverter.printDateTime( versions[i].getLastModified())).append( "</LastModified>" );
            }
            else
            {     xml.append( "<Version>" );    
            xml.append( "<Key>" ).append( versions[i].getKey()).append( "</Key>" );
            xml.append( "<VersionId>" ).append( versions[i].getVersion()).append( "</VersionId>" );
            xml.append( "<IsLatest>" ).append( versions[i].getIsLatest()).append( "</IsLatest>" );
            xml.append( "<LastModified>" ).append( DatatypeConverter.printDateTime( versions[i].getLastModified())).append( "</LastModified>" );
            xml.append( "<ETag>" ).append( versions[i].getETag()).append( "</ETag>" );
            xml.append( "<Size>" ).append( versions[i].getSize()).append( "</Size>" );
            xml.append( "<StorageClass>" ).append( versions[i].getStorageClass()).append( "</StorageClass>" );
            }

            xml.append( "<Owner>" );
            xml.append( "<ID>" ).append( id ).append( "</ID>" );
            if ( null == displayName )
                xml.append( "<DisplayName/>" );
            else xml.append( "<DisplayName>" ).append( owner.getDisplayName()).append( "</DisplayName>" );
            xml.append( "</Owner>" );

            if ( isDeletionMarker )
                xml.append( "</DeleteMarker>" );
            else xml.append( "</Version>" );
View Full Code Here

 
 
  public PolicyParser()
  {
    jparser = new JSONParser();
    condFactory = new S3ConditionFactory();
  }
View Full Code Here

        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

    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

TOP

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

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.