Examples of GetObjectResult


Examples of com.amazon.s3.GetObjectResult

 
  private GetObjectResponse toGetObjectResponse(S3GetObjectResponse engineResponse) {
    GetObjectResponse response = new GetObjectResponse();
    int resultCode = engineResponse.getResultCode();

    GetObjectResult result = new GetObjectResult();
    Status param1 = new Status();
    param1.setCode( resultCode);
    param1.setDescription( engineResponse.getResultDescription());
    result.setStatus( param1 );
   
    if ( 200 == resultCode )
    {
         result.setData(engineResponse.getData());
         result.setETag( engineResponse.getETag());
         result.setMetadata(toMetadataEntry(engineResponse.getMetaEntries()));
         result.setLastModified( engineResponse.getLastModified());
    }
    else
    {    result.setETag( "" );
       result.setLastModified( Calendar.getInstance())
    }
     
    response.setGetObjectResponse(result);
    return response;
  }
View Full Code Here

Examples of com.amazon.s3.GetObjectResult

 
  private GetObjectExtendedResponse toGetObjectExtendedResponse(S3GetObjectResponse engineResponse) {
    GetObjectExtendedResponse response = new GetObjectExtendedResponse();
    int resultCode = engineResponse.getResultCode();

    GetObjectResult result = new GetObjectResult();
    Status param1 = new Status();
    param1.setCode( resultCode );
    param1.setDescription( engineResponse.getResultDescription());
    result.setStatus( param1 );

    if ( 200 == resultCode || 206 == resultCode )
    {
         result.setData(engineResponse.getData());
         result.setETag( engineResponse.getETag());
         result.setMetadata(toMetadataEntry(engineResponse.getMetaEntries()));
         result.setLastModified( engineResponse.getLastModified());
    }
    else
    {    result.setETag( "" );
       result.setLastModified( Calendar.getInstance())
    }
   
    response.setGetObjectResponse(result);
    return response;
  }
View Full Code Here

Examples of com.amazon.s3.GetObjectResult

    private GetObjectResponse toGetObjectResponse(S3GetObjectResponse engineResponse) {
        GetObjectResponse response = new GetObjectResponse();
        int resultCode = engineResponse.getResultCode();

        GetObjectResult result = new GetObjectResult();
        Status param1 = new Status();
        param1.setCode(resultCode);
        param1.setDescription(engineResponse.getResultDescription());
        result.setStatus(param1);

        if (200 == resultCode) {
            result.setData(engineResponse.getData());
            result.setETag(engineResponse.getETag());
            result.setMetadata(toMetadataEntry(engineResponse.getMetaEntries()));
            result.setLastModified(engineResponse.getLastModified());
        } else {
            result.setETag("");
            result.setLastModified(Calendar.getInstance());
        }

        response.setGetObjectResponse(result);
        return response;
    }
View Full Code Here

Examples of com.amazon.s3.GetObjectResult

    private GetObjectExtendedResponse toGetObjectExtendedResponse(S3GetObjectResponse engineResponse) {
        GetObjectExtendedResponse response = new GetObjectExtendedResponse();
        int resultCode = engineResponse.getResultCode();

        GetObjectResult result = new GetObjectResult();
        Status param1 = new Status();
        param1.setCode(resultCode);
        param1.setDescription(engineResponse.getResultDescription());
        result.setStatus(param1);

        if (200 == resultCode || 206 == resultCode) {
            result.setData(engineResponse.getData());
            result.setETag(engineResponse.getETag());
            result.setMetadata(toMetadataEntry(engineResponse.getMetaEntries()));
            result.setLastModified(engineResponse.getLastModified());
        } else {
            result.setETag("");
            result.setLastModified(Calendar.getInstance());
        }

        response.setGetObjectResponse(result);
        return response;
    }
View Full Code Here

Examples of com.amazon.s3.GetObjectResult

 
  private GetObjectResponse toGetObjectResponse(S3GetObjectResponse engineResponse) {
    GetObjectResponse response = new GetObjectResponse();
    int resultCode = engineResponse.getResultCode();

    GetObjectResult result = new GetObjectResult();
    Status param1 = new Status();
    param1.setCode( resultCode);
    param1.setDescription( engineResponse.getResultDescription());
    result.setStatus( param1 );
   
    if ( 200 == resultCode )
    {
         result.setData(engineResponse.getData());
         result.setETag( engineResponse.getETag());
         result.setMetadata(toMetadataEntry(engineResponse.getMetaEntries()));
         result.setLastModified( engineResponse.getLastModified());
    }
    else
    {    result.setETag( "" );
       result.setLastModified( Calendar.getInstance())
    }
     
    response.setGetObjectResponse(result);
    return response;
  }
View Full Code Here

Examples of com.amazon.s3.GetObjectResult

 
  private GetObjectExtendedResponse toGetObjectExtendedResponse(S3GetObjectResponse engineResponse) {
    GetObjectExtendedResponse response = new GetObjectExtendedResponse();
    int resultCode = engineResponse.getResultCode();

    GetObjectResult result = new GetObjectResult();
    Status param1 = new Status();
    param1.setCode( resultCode );
    param1.setDescription( engineResponse.getResultDescription());
    result.setStatus( param1 );

    if ( 200 == resultCode || 206 == resultCode )
    {
         result.setData(engineResponse.getData());
         result.setETag( engineResponse.getETag());
         result.setMetadata(toMetadataEntry(engineResponse.getMetaEntries()));
         result.setLastModified( engineResponse.getLastModified());
    }
    else
    {    result.setETag( "" );
       result.setLastModified( Calendar.getInstance())
    }
   
    response.setGetObjectResponse(result);
    return response;
  }
View Full Code Here

Examples of com.amazonaws.s3.doc._2006_03_01.GetObjectResult

    }
   
    Access access = new Access();
   
    /* Get the metadata for the given file */
    GetObjectResult result = null;
   
   
    /* Try a few times to get the object */
    /* Put the file, We'll try a few times */
    int attemptCount = 0;
    while (attemptCount < MAX_S3_READWRITE_ATTEMPTS)
    {
      attemptCount++;
     
      try
      {
       
        long startTime = System.currentTimeMillis();
       
       
        AmazonS3_ServiceLocator locator = new AmazonS3_ServiceLocator();
        AmazonS3SoapBindingStub binding = new AmazonS3SoapBindingStub(new URL(locator.getAmazonS3Address()), locator);
       
        result = binding.getObject(getBucketName(),
                      key,
                      false,
                      true,
                      false,
                      access.getAccessKey(),
                      access.getAccessCalendar(),
                      access.generateSignature("GetObject"),
                      null);
       
       
        long endTime = System.currentTimeMillis();
       
               
        /* Get the attachments. Note, the getAttachments() method will ONLY return the object[] on the first call.  Subsiquent calls will return null */
        Object[] attachments = binding.getAttachments();
        if (attachments.length != 1)
        {
          throw new Exception("The S3 Object returned [" + attachments.length + "] when we expected exactly 1");
        }
       
        /* Setup the MD5 digest */
        MessageDigest messageDigest = MessageDigest.getInstance("MD5");
       
        /* Get the attachment, and pipe it's data to the buffer */
        OutputStream os = createBufferOutputStream();
        AttachmentPart part = (AttachmentPart) attachments[0];
        InputStream attachmentStream = part.getDataHandler().getInputStream();
        long byteCount = 0;
        int b = 0;
        while ((b = attachmentStream.read()) != -1)
        {
          byteCount++;
          messageDigest.update((byte)b);
          os.write(b);
         
          if (byteCount % 1000 == 0)
          {
            Log.info("\r" + byteCount + " bytes read...");
          }
        }
       
        Log.info("\r" + byteCount + " bytes read...");
       
        os.flush();
        os.close();
       
        this.kBytesProcessed_ += ((double)byteCount / 1000.0);
       
        Log.info(String.format("%6.02f Kb/s\n", (((double)((double)byteCount * (double)Byte.SIZE)) / 1000D) / ((endTime - startTime) / 1000)));
        Log.debug(byteCount + " bytes written to buffer\n");

       
        /* Calculate the MD5 value */
        String md5 =  Common.toHex(messageDigest.digest());
       
        /* compare md5 hashes */
        if (md5.equals(result.getETag().replaceAll("\"", "")) == false)
        {
          throw new Exception("After getting the S3 object [" + key + "], we compared the md5 hash codes. They did not match\n" + "original: [" + md5 + "]\nS3: [" + result.getETag() + "]");
        }
       
        /* Now, stream the file to stdout */
        byteCount = 0;
        InputStream is = createBufferInputStream();
View Full Code Here

Examples of com.amazonaws.s3.doc._2006_03_01.GetObjectResult

      arch.lastModifiedDate = timestamp;
     
      /* Given this is the first object found with this prefix, we'll use this
       * key to get it's metadata for the TAG value */
      Access access = new Access();
      GetObjectResult result = new AmazonS3_ServiceLocator().getAmazonS3().getObject(getBucketName(),
                                              key,
                                              true,
                                              false,
                                              false,
                                              access.getAccessKey(),
                                              access.getAccessCalendar(),
                                              access.generateSignature("GetObject"),
                                              null);
     
      /* get the meta data TAG value */
      for (int index = 0; index < result.getMetadata().length; index++)
      {
        if (META_DATA_TAG.equals(result.getMetadata()[index].getName()))
        {
          arch.tag = result.getMetadata()[index].getValue();
          break;
        }
      }
     
      /* Add this archive object to our map */
 
View Full Code Here

Examples of org.jets3t.service.impl.soap.axis._2006_03_01.GetObjectResult

            || byteRangeStart != null || byteRangeEnd != null;
       
        try {
            AmazonS3SoapBindingStub s3SoapBinding = getSoapBinding();
            Calendar timestamp = getTimeStamp( System.currentTimeMillis() );
            GetObjectResult result = null;
           
            if (useExtendedGet) {
                log.debug("Using Extended GET to apply constraints: "
                    + "ifModifiedSince=" + (ifModifiedSince != null? ifModifiedSince.getTime().toString() : "null")
                    + ", ifUnmodifiedSince=" + (ifUnmodifiedSince != null? ifUnmodifiedSince.getTime().toString() : "null")
                    + ", ifMatchTags=" + (ifMatchTags != null? Arrays.asList(ifMatchTags).toString() : "null")
                    + ", ifNoneMatchTags=" + (ifNoneMatchTags != null? Arrays.asList(ifNoneMatchTags).toString() : "null")
                    + ", byteRangeStart=" + byteRangeStart + ", byteRangeEnd=" + byteRangeEnd);
               
                String signature = ServiceUtils.signWithHmacSha1(getAWSSecretKey(),
                    Constants.SOAP_SERVICE_NAME + "GetObjectExtended" + convertDateToString(timestamp));
                result = s3SoapBinding.getObjectExtended(
                    bucketName, objectKey, true, withData, false, byteRangeStart, byteRangeEnd,
                    ifModifiedSince, ifUnmodifiedSince, ifMatchTags, ifNoneMatchTags,
                    Boolean.FALSE, getAWSAccessKey(), timestamp, signature, null);
               
                // Throw an exception if the preconditions failed.
                int expectedStatusCode = 200;
                if (byteRangeStart != null || byteRangeEnd != null) {
                    // Partial data responses have a status code of 206.
                    expectedStatusCode = 206;
                }
                if (result.getStatus().getCode() != expectedStatusCode) {
                    throw new S3ServiceException("Precondition failed when getting object "
                        + objectKey + ": " + result.getStatus().getDescription());
                }
            } else {
                log.debug("Using standard GET (no constraints to apply)");
                String signature = ServiceUtils.signWithHmacSha1(getAWSSecretKey(),
                    Constants.SOAP_SERVICE_NAME + "GetObject" + convertDateToString(timestamp));
                result = s3SoapBinding.getObject(
                    bucketName, objectKey, true, withData, false,               
                    getAWSAccessKey(), timestamp, signature, null);               
            }
           
            S3Object object = new S3Object(objectKey);
            object.setETag(result.getETag());
            object.setLastModifiedDate(result.getLastModified().getTime());
            object.setBucketName(bucketName);
           
            // Get data details from the SOAP attachment.
            if (withData) {
                Object[] attachments = s3SoapBinding.getAttachments();
                log.debug("SOAP attachment count for " + object.getKey() + ": " + attachments.length);
                for (int i = 0; i < attachments.length; i++) {
                    if (i > 0) {
                        throw new S3ServiceException(
                            "Received multiple SOAP attachment parts, this shouldn't happen");
                    }
                    AttachmentPart part = (AttachmentPart) attachments[i];
                    object.setContentType(part.getContentType());
                    object.setContentLength(part.getSize());
                    object.setDataInputStream(part.getDataHandler().getInputStream());
                }
            }
           
            // Populate object's metadata details.
            MetadataEntry[] metadata = result.getMetadata();
            for (int i = 0; i < metadata.length; i++) {
                MetadataEntry entry = metadata[i];
                object.addMetadata(entry.getName(), entry.getValue());
            }
            object.setMetadataComplete(true);
View Full Code Here

Examples of org.jets3t.service.impl.soap.axis._2006_03_01.GetObjectResult

            || byteRangeStart != null || byteRangeEnd != null;
       
        try {
            AmazonS3SoapBindingStub s3SoapBinding = getSoapBinding();
            Calendar timestamp = getTimeStamp( System.currentTimeMillis() );
            GetObjectResult result = null;
           
            if (useExtendedGet) {
              if (log.isDebugEnabled()) {
                  log.debug("Using Extended GET to apply constraints: "
                      + "ifModifiedSince=" + (ifModifiedSince != null? ifModifiedSince.getTime().toString() : "null")
                      + ", ifUnmodifiedSince=" + (ifUnmodifiedSince != null? ifUnmodifiedSince.getTime().toString() : "null")
                      + ", ifMatchTags=" + (ifMatchTags != null? Arrays.asList(ifMatchTags).toString() : "null")
                      + ", ifNoneMatchTags=" + (ifNoneMatchTags != null? Arrays.asList(ifNoneMatchTags).toString() : "null")
                      + ", byteRangeStart=" + byteRangeStart + ", byteRangeEnd=" + byteRangeEnd);
              }
             
                String signature = ServiceUtils.signWithHmacSha1(getAWSSecretKey(),
                    Constants.SOAP_SERVICE_NAME + "GetObjectExtended" + convertDateToString(timestamp));
                result = s3SoapBinding.getObjectExtended(
                    bucketName, objectKey, true, withData, false, byteRangeStart, byteRangeEnd,
                    ifModifiedSince, ifUnmodifiedSince, ifMatchTags, ifNoneMatchTags,
                    Boolean.FALSE, getAWSAccessKey(), timestamp, signature, null);
               
                // Throw an exception if the preconditions failed.
                int expectedStatusCode = 200;
                if (byteRangeStart != null || byteRangeEnd != null) {
                    // Partial data responses have a status code of 206.
                    expectedStatusCode = 206;
                }
                if (result.getStatus().getCode() != expectedStatusCode) {
                    throw new S3ServiceException("Precondition failed when getting object "
                        + objectKey + ": " + result.getStatus().getDescription());
                }
            } else {
              if (log.isDebugEnabled()) {
                log.debug("Using standard GET (no constraints to apply)");
              }
                String signature = ServiceUtils.signWithHmacSha1(getAWSSecretKey(),
                    Constants.SOAP_SERVICE_NAME + "GetObject" + convertDateToString(timestamp));
                result = s3SoapBinding.getObject(
                    bucketName, objectKey, true, withData, false,               
                    getAWSAccessKey(), timestamp, signature, null);               
            }
           
            S3Object object = new S3Object(objectKey);
            object.setETag(result.getETag());
            object.setLastModifiedDate(result.getLastModified().getTime());
            object.setBucketName(bucketName);
           
            // Get data details from the SOAP attachment.
            if (withData) {
                Object[] attachments = s3SoapBinding.getAttachments();
                if (log.isDebugEnabled()) {
                  log.debug("SOAP attachment count for " + object.getKey() + ": " + attachments.length);
                }
                for (int i = 0; i < attachments.length; i++) {
                    if (i > 0) {
                        throw new S3ServiceException(
                            "Received multiple SOAP attachment parts, this shouldn't happen");
                    }
                    AttachmentPart part = (AttachmentPart) attachments[i];
                    object.setContentType(part.getContentType());
                    object.setContentLength(part.getSize());
                    object.setDataInputStream(part.getDataHandler().getInputStream());
                }
            }
           
            // Populate object's metadata details.
            MetadataEntry[] metadata = result.getMetadata();
            for (int i = 0; i < metadata.length; i++) {
                MetadataEntry entry = metadata[i];
                object.addMetadata(entry.getName(), entry.getValue());
            }
            object.setMetadataComplete(true);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.