Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2012-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
   *
   * Licensed under the Apache License, Version 2.0 (the "License").
   * You may not use this file except in compliance with the License.
   * A copy of the License is located at
   *
   *  http://aws.amazon.com/apache2.0
   *
  * or in the "license" file accompanying this file. This file is distributed
  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  * express or implied. See the License for the specific language governing
  * permissions and limitations under the License.
  */
 package com.amazonaws.services.s3.transfer.internal;
 
 import java.io.File;
 
 
 public class DownloadImpl extends AbstractTransfer implements Download {
     private S3Object s3Object;

    
Information to resume if the download is paused.
 
     private final PersistableDownload persistableDownload;
 
     public DownloadImpl(String descriptionTransferProgress transferProgress,
             ProgressListenerChain progressListenerChainS3Object s3Object,
             TransferStateChangeListener listener,
             GetObjectRequest getObjectRequestFile file) {
         super(descriptiontransferProgressprogressListenerChainlistener);
         this. = s3Object;
         this. = captureDownloadState(getObjectRequestfile);
         S3ProgressPublisher.publishTransferPersistable(progressListenerChain,
                 );
     }

    
Returns the ObjectMetadata for the object being downloaded.

Returns:
The ObjectMetadata for the object being downloaded.
 
     public ObjectMetadata getObjectMetadata() {
         return .getObjectMetadata();
     }

    
The name of the bucket where the object is being downloaded from.

Returns:
The name of the bucket where the object is being downloaded from.
 
     public String getBucketName() {
         return .getBucketName();
     }

    
The key under which this object was stored in Amazon S3.

Returns:
The key under which this object was stored in Amazon S3.
 
     public String getKey() {
         return .getKey();
     }

    
Cancels this download.

 
     public synchronized void abort() throws IOException {
 
         this..getFuture().cancel(true);
 
         if (  != null ) {
               .getObjectContent().abort();
         }
         setState(.);
     }

    
Cancels this download, but skip notifying the state change listeners.

 
     public synchronized void abortWithoutNotifyingStateChangeListener() throws IOException {
         this..getFuture().cancel(true);
         this. = .;
     }

    
Set the S3 object to download.
    public synchronized void setS3Object(S3Object s3Object) {
        this. = s3Object;
    }

    
This method is also responsible for firing COMPLETED signal to the listeners.
    @Override
    public void setState(TransferState state) {
        super.setState(state);
        if (state == .) {
        }
    }

    
Returns the captured state of the download; or null if it should not be captured (for security reason).
            final GetObjectRequest getObjectRequestfinal File file) {
        if (getObjectRequest.getSSECustomerKey() == null) {
            return new PersistableDownload(
                    getObjectRequest.getBucketName(),
                    getObjectRequest.getKey(), getObjectRequest.getVersionId(),
                    getObjectRequest.getRange(),
                    getObjectRequest.getResponseHeaders(),
                    getObjectRequest.isRequesterPays(), file.getAbsolutePath());
        }
        return null;
    }
    /*
     * (non-Javadoc)
     *
     * @see com.amazonaws.services.s3.transfer.Download#pause()
     */
    @Override
    public PersistableDownload pause() throws PauseException {
        boolean forceCancel = true;
        TransferState currentState = getState();
        this..getFuture().cancel(true);
        if ( == null) {
            throw new PauseException(TransferManagerUtils.determinePauseStatus(
                    currentStateforceCancel));
        }
        return ;
    }
New to GrepCode? Check out our FAQ X