Ejemplo n.º 1
0
 public void endElement(String uri, String name, String qName) {
   String elementText = this.currText.toString();
   // Listing details.
   if (name.equals("ID")) {
     bucketsOwner.setId(elementText);
   } else if (name.equals("DisplayName")) {
     bucketsOwner.setDisplayName(elementText);
   }
   // Bucket item details.
   else if (name.equals("Bucket")) {
     if (log.isDebugEnabled()) {
       log.debug("Created new bucket from listing: " + currentBucket);
     }
     currentBucket.setOwner(bucketsOwner);
     buckets.add(currentBucket);
   } else if (name.equals("Name")) {
     currentBucket.setName(elementText);
   } else if (name.equals("CreationDate")) {
     try {
       currentBucket.setCreationDate(ServiceUtils.parseIso8601Date(elementText));
     } catch (ParseException e) {
       throw new RuntimeException("Unexpected date format in list bucket output", e);
     }
   }
   this.currText = new StringBuffer();
 }
Ejemplo n.º 2
0
 public void endElement(String uri, String name, String qName) {
   String elementText = this.currText.toString();
   // Owner details.
   if (name.equals("ID") && !insideACL) {
     owner.setId(elementText);
   } else if (name.equals("DisplayName") && !insideACL) {
     owner.setDisplayName(elementText);
   }
   // ACL details.
   else if (name.equals("ID")) {
     currentGrantee.setIdentifier(elementText);
   } else if (name.equals("EmailAddress")) {
     currentGrantee.setIdentifier(elementText);
   } else if (name.equals("URI")) {
     currentGrantee.setIdentifier(elementText);
   } else if (name.equals("DisplayName")) {
     ((CanonicalGrantee) currentGrantee).setDisplayName(elementText);
   } else if (name.equals("Permission")) {
     currentPermission = Permission.parsePermission(elementText);
   } else if (name.equals("Grant")) {
     accessControlList.grantPermission(currentGrantee, currentPermission);
   } else if (name.equals("AccessControlList")) {
     insideACL = false;
   }
   this.currText = new StringBuffer();
 }
Ejemplo n.º 3
0
    public void endElement(String uri, String name, String qName) {
      String elementText = this.currText.toString();
      // Listing details
      if (name.equals("Name")) {
        bucketName = elementText;
        if (log.isDebugEnabled()) {
          log.debug("Examining listing for bucket: " + bucketName);
        }
      } else if (!insideCommonPrefixes && name.equals("Prefix")) {
        requestPrefix = elementText;
      } else if (name.equals("Marker")) {
        requestMarker = elementText;
      } else if (name.equals("NextMarker")) {
        nextMarker = elementText;
      } else if (name.equals("MaxKeys")) {
        requestMaxKeys = Long.parseLong(elementText);
      } else if (name.equals("IsTruncated")) {
        String isTruncatedStr = elementText.toLowerCase(Locale.getDefault());
        if (isTruncatedStr.startsWith("false")) {
          listingTruncated = false;
        } else if (isTruncatedStr.startsWith("true")) {
          listingTruncated = true;
        } else {
          throw new RuntimeException("Invalid value for IsTruncated field: " + isTruncatedStr);
        }
      }
      // Object details.
      else if (name.equals("Contents")) {
        objects.add(currentObject);
        if (log.isDebugEnabled()) {
          log.debug("Created new S3Object from listing: " + currentObject);
        }
      } else if (name.equals("Key")) {
        currentObject.setKey(elementText);
        lastKey = elementText;
      } else if (name.equals("LastModified")) {
        try {
          currentObject.setLastModifiedDate(ServiceUtils.parseIso8601Date(elementText));
        } catch (ParseException e) {
          throw new RuntimeException("Unexpected date format in list bucket output", e);
        }
      } else if (name.equals("ETag")) {
        currentObject.setETag(elementText);
      } else if (name.equals("Size")) {
        currentObject.setContentLength(Long.parseLong(elementText));
      } else if (name.equals("StorageClass")) {
        currentObject.setStorageClass(elementText);
      }
      // Owner details.
      else if (name.equals("ID")) {
        // Work-around to support Eucalyptus responses, which do not
        // contain Owner elements.
        if (currentOwner == null) {
          currentOwner = new S3Owner();
          currentObject.setOwner(currentOwner);
        }

        currentOwner.setId(elementText);
      } else if (name.equals("DisplayName")) {
        currentOwner.setDisplayName(elementText);
      }
      // Common prefixes.
      else if (insideCommonPrefixes && name.equals("Prefix")) {
        commonPrefixes.add(elementText);
      } else if (name.equals("CommonPrefixes")) {
        insideCommonPrefixes = false;
      }

      this.currText = new StringBuffer();
    }