Package com.amazon.s3

Examples of com.amazon.s3.ListBucketResult$Factory


  request.addQueryArg( "marker", String.valueOf( marker ) );
  request.addQueryArg( "prefix", prefix );
 
  request.setBucket( _bucket );
 
  ListBucketResult resp = null;
  InputStream is = request.execute( );
  try
  {
      StreamSource stream = new StreamSource( is );
      JAXBElement<ListBucketResult> root = LIST_BUCKET_RESPONSE_UNMARSHALLER
View Full Code Here


    ListOperation listOp = new ListOperation(getBucketName(), getPrefixName());
   
    String marker = null;
   
    /* Get the list of files from S3 */
    ListBucketResult listResult = null;
   
    /* This do while loop deals with the paging of s3 lists */
    do
    {
      /* Get a page of results */
      listResult = listOp.getBucketObjectList(marker, getBucketName(), getPrefixName(), MAX_KEYS_PER_LIST);
     
      if (listResult.getContents() != null)
      {
        /* Process this list of keys */
        for (ListEntry listEntry : listResult.getContents())
        {
          marker = listEntry.getKey();
          restoreS3Object(listEntry.getKey());
         
        }
       
      }
         
    }
    while(listResult.isIsTruncated());
   
   
    if (this.kBytesProcessed_ > 10000)
    {
      Log.info(String.format("%.2fM transfered\n", (this.kBytesProcessed_ / 1000.0)));
View Full Code Here

          return;
        }
        else
        {
          /* Look for our prefix.  If it exists, then throw an error */
          ListBucketResult bucketList = listOperation.getBucketObjectList(null, getBucketName(), getPrefixName(), 1);
         
          if ((bucketList.getContents() != null) && (bucketList.getContents().length > 0))
          {
            Log.error("Bucket: " + getBucketName() + " Prefix: " + getPrefixName() + " already exists.\nWe cannot send data to an existing bucket:prefix, please specify a new bucket:prefix name\n");
            return;
          }
         
View Full Code Here

    Log.info("Deleting...\n");
   
    String marker = null;
   
    /* Get the list of files from S3 */
    ListBucketResult listResult = null;

   
    /* This do while loop deals with the paging of s3 lists */
    do
    {
      /* Get a page of results */
      listResult = getBucketKeyList(marker);
     
      if (listResult.getContents() != null)
      {
     
        /* Get the marker in case there are more pages of keys */
        marker = listResult.getMarker();
           
       
        /* Process this list of keys */
        for (ListEntry listEntry : listResult.getContents())
        {
          deleteS3Object(listEntry.getKey());
          count++;
        }
       
        Log.info(count + " blocks deleted from archive so far\n");
         
      }
     
    }
    while(listResult.isIsTruncated());


    /* Delete the bucket, only if the user did not specify a prefix */
    if (getPrefixName() == null)
    {
View Full Code Here

  public ListBucketResult getBucketKeyList(String marker) throws Exception
  {
    Access access = new Access();
   
    /* Get the list of files from S3 */
    ListBucketResult listResult = null;
   
    String prefix = null;
   
    if (getPrefixName() != null)
    {
View Full Code Here

     
      /* If a bucket is specified, then list the files in the bucket */
      String marker = null;
     
      /* Get the list of files from S3 */
      ListBucketResult listResult = null;
     
      /* This do while loop deals with the paging of s3 lists */
      do
      {
        /* Get a page of results */
        listResult = getBucketObjectList(marker, getBucketName(), getPrefixName(), MAX_KEYS_PER_LIST);
       
        if (listResult.getContents() != null)
        {
          /* Process this list of keys */
          for (ListEntry listEntry : listResult.getContents())
          {
            marker = listEntry.getKey();
            processListEntry(listEntry);
           
          }
         
        }
           
      }
      while(listResult.isIsTruncated());
     
     
      /* Now that each object has been processed, dump the results to the screen */
      Iterator keyIterator = this.archives_.keySet().iterator();
      while (keyIterator.hasNext())
View Full Code Here

  public ListBucketResult getBucketObjectList(String marker, String bucket, String prefix, int size) throws Exception
  {
    Access access = new Access();
   
    /* Get the list of files from S3 */
    ListBucketResult listResult = null;
   
    if (prefix != null)
    {
      prefix += OBJECT_PREFIX_SEPARATOR;
    }
View Full Code Here

            while (incompleteListing) {
                AmazonS3SoapBindingStub s3SoapBinding = getSoapBinding();
                Calendar timestamp = getTimeStamp( System.currentTimeMillis() );
                String signature = ServiceUtils.signWithHmacSha1(getAWSSecretKey(),
                    Constants.SOAP_SERVICE_NAME + "ListBucket" + convertDateToString(timestamp));
                ListBucketResult result = s3SoapBinding.listBucket(
                    bucketName, prefix, priorLastKey, new Integer((int)maxListingLength),
                    delimiter, getAWSAccessKey(), timestamp, signature, null);
               
                ListEntry[] entries = result.getContents();
                S3Object[] partialObjects = new S3Object[
                   (entries == null? 0 : entries.length)];
               
                log.debug("Found " + partialObjects.length + " objects in one batch");
                for (int i = 0; entries != null && i < entries.length; i++) {
                    ListEntry entry = entries[i];
                    S3Object object = new S3Object(entry.getKey());
                    object.setLastModifiedDate(entry.getLastModified().getTime());
                    object.setETag(entry.getETag());
                    object.setContentLength(entry.getSize());
                    object.setStorageClass(entry.getStorageClass().toString());
                    object.setOwner(convertOwner(entry.getOwner()));
                    partialObjects[i] = object;
                   
                    // This shouldn't be necessary, but result.getNextMarker() doesn't work as expected.
                    priorLastKey = object.getKey();
                }
               
                objects.addAll(Arrays.asList(partialObjects));
               
                PrefixEntry[] prefixEntries = result.getCommonPrefixes();
                if (prefixEntries != null) {
                    log.debug("Found " + prefixEntries.length + " common prefixes in one batch");                   
                }
                for (int i = 0; prefixEntries != null && i < prefixEntries.length; i++ ) {
                    PrefixEntry entry = prefixEntries[i];
                    commonPrefixes.add(entry.getPrefix());
                }
               
                incompleteListing = result.isIsTruncated();
                if (incompleteListing) {
                  if (result.getNextMarker() != null) {
                    // Use NextMarker as the marker for where subsequent listing should start
                      priorLastKey = result.getNextMarker();
                  } else {
                    // Use the prior last key instead of NextMarker if it isn't available.
                  }
                    log.debug("Yet to receive complete listing of bucket contents, "
                        + "last key for prior chunk: " + priorLastKey);
View Full Code Here

            while (incompleteListing) {
                AmazonS3SoapBindingStub s3SoapBinding = getSoapBinding();
                Calendar timestamp = getTimeStamp( System.currentTimeMillis() );
                String signature = ServiceUtils.signWithHmacSha1(getAWSSecretKey(),
                    Constants.SOAP_SERVICE_NAME + "ListBucket" + convertDateToString(timestamp));
                ListBucketResult result = s3SoapBinding.listBucket(
                    bucketName, prefix, priorLastKey, new Integer((int)maxListingLength),
                    delimiter, getAWSAccessKey(), timestamp, signature, null);
               
                ListEntry[] entries = result.getContents();
                S3Object[] partialObjects = new S3Object[
                   (entries == null? 0 : entries.length)];
               
                if (log.isDebugEnabled()) {
                  log.debug("Found " + partialObjects.length + " objects in one batch");
                }
                for (int i = 0; entries != null && i < entries.length; i++) {
                    ListEntry entry = entries[i];
                    S3Object object = new S3Object(entry.getKey());
                    object.setLastModifiedDate(entry.getLastModified().getTime());
                    object.setETag(entry.getETag());
                    object.setContentLength(entry.getSize());
                    object.setStorageClass(entry.getStorageClass().toString());
                    object.setOwner(convertOwner(entry.getOwner()));
                    partialObjects[i] = object;
                   
                    // This shouldn't be necessary, but result.getNextMarker() doesn't work as expected.
                    priorLastKey = object.getKey();
                }
               
                objects.addAll(Arrays.asList(partialObjects));
               
                PrefixEntry[] prefixEntries = result.getCommonPrefixes();
                if (prefixEntries != null) {
                  if (log.isDebugEnabled()) {
                    log.debug("Found " + prefixEntries.length + " common prefixes in one batch");
                  }
                }
                for (int i = 0; prefixEntries != null && i < prefixEntries.length; i++ ) {
                    PrefixEntry entry = prefixEntries[i];
                    commonPrefixes.add(entry.getPrefix());
                }
               
                incompleteListing = result.isIsTruncated();
                if (incompleteListing) {
                  if (result.getNextMarker() != null) {
                    // Use NextMarker as the marker for where subsequent listing should start
                      priorLastKey = result.getNextMarker();
                  } else {
                    // Use the prior last key instead of NextMarker if it isn't available.
                  }
                  if (log.isDebugEnabled()) {
                      log.debug("Yet to receive complete listing of bucket contents, "
View Full Code Here

            while (incompleteListing) {
                AmazonS3SoapBindingStub s3SoapBinding = getSoapBinding();
                Calendar timestamp = getTimeStamp( System.currentTimeMillis() );
                String signature = ServiceUtils.signWithHmacSha1(getAWSSecretKey(),
                    Constants.SOAP_SERVICE_NAME + "ListBucket" + convertDateToString(timestamp));
                ListBucketResult result = s3SoapBinding.listBucket(
                    bucketName, prefix, priorLastKey, new Integer((int)maxListingLength),
                    delimiter, getAWSAccessKey(), timestamp, signature, null);
               
                ListEntry[] entries = result.getContents();
                S3Object[] partialObjects = new S3Object[
                   (entries == null? 0 : entries.length)];
               
                if (log.isDebugEnabled()) {
                  log.debug("Found " + partialObjects.length + " objects in one batch");
                }
                for (int i = 0; entries != null && i < entries.length; i++) {
                    ListEntry entry = entries[i];
                    S3Object object = new S3Object(entry.getKey());
                    object.setLastModifiedDate(entry.getLastModified().getTime());
                    object.setETag(entry.getETag());
                    object.setContentLength(entry.getSize());
                    object.setStorageClass(entry.getStorageClass().toString());
                    object.setOwner(convertOwner(entry.getOwner()));
                    partialObjects[i] = object;
                   
                    // This shouldn't be necessary, but result.getNextMarker() doesn't work as expected.
                    priorLastKey = object.getKey();
                }
               
                objects.addAll(Arrays.asList(partialObjects));
               
                PrefixEntry[] prefixEntries = result.getCommonPrefixes();
                if (prefixEntries != null) {
                  if (log.isDebugEnabled()) {
                    log.debug("Found " + prefixEntries.length + " common prefixes in one batch");
                  }
                }
                for (int i = 0; prefixEntries != null && i < prefixEntries.length; i++ ) {
                    PrefixEntry entry = prefixEntries[i];
                    commonPrefixes.add(entry.getPrefix());
                }
               
                incompleteListing = result.isIsTruncated();
                if (incompleteListing) {
                  if (result.getNextMarker() != null) {
                    // Use NextMarker as the marker for where subsequent listing should start
                      priorLastKey = result.getNextMarker();
                  } else {
                    // Use the prior last key instead of NextMarker if it isn't available.
                  }
                  if (log.isDebugEnabled()) {
                      log.debug("Yet to receive complete listing of bucket contents, "
View Full Code Here

TOP

Related Classes of com.amazon.s3.ListBucketResult$Factory

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.