/** * Creates a new {@link ListObjectsRequest} object using the previous object listing. * @return A new {@link ListObjectsRequest} object using the previous object listing. */ public ListObjectsRequest toListObjectsRequest() { return new ListObjectsRequest(previousObjectListing.getBucketName(), previousObjectListing.getPrefix(), previousObjectListing.getNextMarker(), previousObjectListing.getDelimiter(), Integer.valueOf(previousObjectListing.getMaxKeys())) .withEncodingType(previousObjectListing.getEncodingType()); }
@Mock public ObjectListing listNextBatchOfObjects(ObjectListing previousObjectListing) throws AmazonClientException { ObjectListing listing = new ObjectListing(); listing.setBucketName(previousObjectListing.getBucketName()); listing.setPrefix(previousObjectListing.getPrefix()); return new ObjectListing(); } }
@Override public ObjectListing listNextBatchOfObjects(ListNextBatchOfObjectsRequest listNextBatchOfObjectsRequest) throws SdkClientException, AmazonServiceException { listNextBatchOfObjectsRequest = beforeClientExecution(listNextBatchOfObjectsRequest); rejectNull(listNextBatchOfObjectsRequest, "The request object parameter must be specified when listing the next batch of objects in a bucket"); ObjectListing previousObjectListing = listNextBatchOfObjectsRequest.getPreviousObjectListing(); if (!previousObjectListing.isTruncated()) { ObjectListing emptyListing = new ObjectListing(); emptyListing.setBucketName(previousObjectListing.getBucketName()); emptyListing.setDelimiter(previousObjectListing.getDelimiter()); emptyListing.setMarker(previousObjectListing.getNextMarker()); emptyListing.setMaxKeys(previousObjectListing.getMaxKeys()); emptyListing.setPrefix(previousObjectListing.getPrefix()); emptyListing.setEncodingType(previousObjectListing.getEncodingType()); emptyListing.setTruncated(false); return emptyListing; } return listObjects(listNextBatchOfObjectsRequest.toListObjectsRequest()); }
/** * Creates a new {@link ListObjectsRequest} object using the previous object listing. * @return A new {@link ListObjectsRequest} object using the previous object listing. */ public ListObjectsRequest toListObjectsRequest() { return new ListObjectsRequest(previousObjectListing.getBucketName(), previousObjectListing.getPrefix(), previousObjectListing.getNextMarker(), previousObjectListing.getDelimiter(), Integer.valueOf(previousObjectListing.getMaxKeys())) .withEncodingType(previousObjectListing.getEncodingType()); }
@Override public ObjectListing listNextBatchOfObjects( ListNextBatchOfObjectsRequest listNextBatchOfObjectsRequest) throws AmazonClientException, AmazonServiceException { final ObjectListing previousObjectListing = listNextBatchOfObjectsRequest.getPreviousObjectListing(); if (!previousObjectListing.isTruncated()) { final ObjectListing emptyListing = new ObjectListing(); emptyListing.setBucketName(previousObjectListing.getBucketName()); emptyListing.setDelimiter(previousObjectListing.getDelimiter()); emptyListing.setMarker(previousObjectListing.getNextMarker()); emptyListing.setMaxKeys(previousObjectListing.getMaxKeys()); emptyListing.setPrefix(previousObjectListing.getPrefix()); emptyListing.setEncodingType(previousObjectListing.getEncodingType()); emptyListing.setTruncated(false); return emptyListing; } return listObjects(listNextBatchOfObjectsRequest.toListObjectsRequest()); }
private void addParentPaths(String[] keyParts) { if (keyParts.length <= 1) return; String[] subParts = Arrays.copyOf(keyParts, keyParts.length - 1); List<S3Path> parentPaths = new ArrayList<>(); while (subParts.length > 0) { S3Path path = new S3Path(fileSystem, "/" + fileStore.name(), subParts); String prefix = current.getPrefix(); String parentKey = path.getKey(); if (prefix.length() > parentKey.length() && prefix.contains(parentKey)) break; if (items.contains(path) || addedVirtualDirectories.contains(path)) { subParts = Arrays.copyOf(subParts, subParts.length - 1); continue; } parentPaths.add(path); addedVirtualDirectories.add(path); subParts = Arrays.copyOf(subParts, subParts.length - 1); } Collections.reverse(parentPaths); items.addAll(parentPaths); }
/** * This does one of two things. It either copies <code>/foo/bar/index.html to /foo/bar/</code> OR creates <code>/foo/bar/</code> from <code>html</code> */ public static TypedRequest getTypedRequest(String bucket, String cacheControl, String welcomeFileKey, ObjectListing listing, String html) { if (welcomeFileKey == null) { // Create s3://bucket/foo/bar/ PutObjectRequest put = getPutHtmlRequest(bucket, cacheControl, html, listing.getPrefix()); return new TypedRequest(put, AmazonWebServiceRequestType.PUT_OBJECT); } else { // Copy s3://bucket/foo/bar/index.html -> s3://bucket/foo/bar/ CopyObjectRequest copy = getCopyObjectRequest(bucket, welcomeFileKey, listing.getPrefix()); return new TypedRequest(copy, AmazonWebServiceRequestType.COPY_OBJECT); } }
public static PutObjectRequest getPutHtmlRequest(BucketContext context, String cacheControl, ObjectListing listing, String html) { return getPutHtmlRequest(context.getName(), cacheControl, html, listing.getPrefix()); } }
/** * An <code>ObjectListing</code> is the equivalent of typing <code>ls</code> in a directory on a file system. */ public static String getFirstMatchingKey(ObjectListing listing, List<String> filenames) { // Cycle through the list of files in this directory for (S3ObjectSummary summary : listing.getObjectSummaries()) { String objectKey = getFirstMatchingKey(summary.getKey(), listing.getPrefix(), filenames); if (objectKey != null) { return objectKey; } } return null; }
public static PutObjectRequest getPutHtmlRequestWithoutTrailingDelimiter(BucketContext context, String cacheControl, ObjectListing listing, String html) { String delimiter = context.getDelimiter(); String objectKey = Str.removeSuffix(listing.getPrefix(), delimiter); return getPutHtmlRequest(context.getName(), cacheControl, html, objectKey); }
/** * Creates a new {@link ListObjectsRequest} object using the previous object listing. * @return A new {@link ListObjectsRequest} object using the previous object listing. */ public ListObjectsRequest toListObjectsRequest() { return new ListObjectsRequest(previousObjectListing.getBucketName(), previousObjectListing.getPrefix(), previousObjectListing.getNextMarker(), previousObjectListing.getDelimiter(), Integer.valueOf(previousObjectListing.getMaxKeys())) .withEncodingType(previousObjectListing.getEncodingType()); }
/** * Creates a new {@link ListObjectsRequest} object using the previous object listing. * @return A new {@link ListObjectsRequest} object using the previous object listing. */ public ListObjectsRequest toListObjectsRequest() { return new ListObjectsRequest(previousObjectListing.getBucketName(), previousObjectListing.getPrefix(), previousObjectListing.getNextMarker(), previousObjectListing.getDelimiter(), Integer.valueOf(previousObjectListing.getMaxKeys())) .withEncodingType(previousObjectListing.getEncodingType()); }
String directory = getDirectory(listing.getPrefix(), context.getBucketContext().getDelimiter());
CustomObjectListing(ObjectListing rawListing, List<S3ObjectSummary> customListing, List<String> customPrefixes) { super(); this.customListing = customListing; this.customPrefixes = customPrefixes; this.setBucketName(rawListing.getBucketName()); this.setCommonPrefixes(rawListing.getCommonPrefixes()); this.setDelimiter(rawListing.getDelimiter()); this.setEncodingType(rawListing.getEncodingType()); this.setMarker(rawListing.getMarker()); this.setMaxKeys(rawListing.getMaxKeys()); this.setNextMarker(rawListing.getNextMarker()); this.setPrefix(rawListing.getPrefix()); this.setTruncated(rawListing.isTruncated()); }
@Override public ObjectListing listNextBatchOfObjects( ListNextBatchOfObjectsRequest listNextBatchOfObjectsRequest) throws AmazonClientException, AmazonServiceException { final ObjectListing previousObjectListing = listNextBatchOfObjectsRequest.getPreviousObjectListing(); if (!previousObjectListing.isTruncated()) { final ObjectListing emptyListing = new ObjectListing(); emptyListing.setBucketName(previousObjectListing.getBucketName()); emptyListing.setDelimiter(previousObjectListing.getDelimiter()); emptyListing.setMarker(previousObjectListing.getNextMarker()); emptyListing.setMaxKeys(previousObjectListing.getMaxKeys()); emptyListing.setPrefix(previousObjectListing.getPrefix()); emptyListing.setEncodingType(previousObjectListing.getEncodingType()); emptyListing.setTruncated(false); return emptyListing; } return listObjects(listNextBatchOfObjectsRequest.toListObjectsRequest()); }
@Override public ObjectListing listNextBatchOfObjects(ListNextBatchOfObjectsRequest listNextBatchOfObjectsRequest) throws SdkClientException, AmazonServiceException { listNextBatchOfObjectsRequest = beforeClientExecution(listNextBatchOfObjectsRequest); rejectNull(listNextBatchOfObjectsRequest, "The request object parameter must be specified when listing the next batch of objects in a bucket"); ObjectListing previousObjectListing = listNextBatchOfObjectsRequest.getPreviousObjectListing(); if (!previousObjectListing.isTruncated()) { ObjectListing emptyListing = new ObjectListing(); emptyListing.setBucketName(previousObjectListing.getBucketName()); emptyListing.setDelimiter(previousObjectListing.getDelimiter()); emptyListing.setMarker(previousObjectListing.getNextMarker()); emptyListing.setMaxKeys(previousObjectListing.getMaxKeys()); emptyListing.setPrefix(previousObjectListing.getPrefix()); emptyListing.setEncodingType(previousObjectListing.getEncodingType()); emptyListing.setTruncated(false); return emptyListing; } return listObjects(listNextBatchOfObjectsRequest.toListObjectsRequest()); }
private ObjectListing copyOf(com.amazonaws.services.s3.model.ObjectListing mutable) { ObjectListing.Builder builder = ObjectListing.builder(); builder.withBucket(mutable.getBucketName()); builder.withCommonPrefixes(mutable.getCommonPrefixes()); builder.withDelimiter(fromTrimToNull(mutable.getDelimiter())); builder.withEncoding(fromTrimToNull(mutable.getEncodingType())); builder.withIsTruncated(mutable.isTruncated()); builder.withMarker(fromTrimToNull(mutable.getMarker())); builder.withMaxKeys(mutable.getMaxKeys()); builder.withNextMarker(fromTrimToNull(mutable.getNextMarker())); builder.withPrefix(fromTrimToNull(mutable.getPrefix())); builder.withSummaries(getSummaries(mutable.getObjectSummaries())); return builder.build(); }