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, "