Java Code Examples for com.amazonaws.services.s3.model.S3VersionSummary#setBucketName()
The following examples show how to use
com.amazonaws.services.s3.model.S3VersionSummary#setBucketName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ListS3.java From localization_nifi with Apache License 2.0 | 6 votes |
@Override public VersionListing listVersions() { VersionListing versionListing = new VersionListing(); this.objectListing = client.listObjects(listObjectsRequest); for(S3ObjectSummary objectSummary : objectListing.getObjectSummaries()) { S3VersionSummary versionSummary = new S3VersionSummary(); versionSummary.setBucketName(objectSummary.getBucketName()); versionSummary.setETag(objectSummary.getETag()); versionSummary.setKey(objectSummary.getKey()); versionSummary.setLastModified(objectSummary.getLastModified()); versionSummary.setOwner(objectSummary.getOwner()); versionSummary.setSize(objectSummary.getSize()); versionSummary.setStorageClass(objectSummary.getStorageClass()); versionSummary.setIsLatest(true); versionListing.getVersionSummaries().add(versionSummary); } return versionListing; }
Example 2
Source File: ListS3.java From nifi with Apache License 2.0 | 6 votes |
@Override public VersionListing listVersions() { VersionListing versionListing = new VersionListing(); this.objectListing = client.listObjects(listObjectsRequest); for(S3ObjectSummary objectSummary : objectListing.getObjectSummaries()) { S3VersionSummary versionSummary = new S3VersionSummary(); versionSummary.setBucketName(objectSummary.getBucketName()); versionSummary.setETag(objectSummary.getETag()); versionSummary.setKey(objectSummary.getKey()); versionSummary.setLastModified(objectSummary.getLastModified()); versionSummary.setOwner(objectSummary.getOwner()); versionSummary.setSize(objectSummary.getSize()); versionSummary.setStorageClass(objectSummary.getStorageClass()); versionSummary.setIsLatest(true); versionListing.getVersionSummaries().add(versionSummary); } return versionListing; }
Example 3
Source File: ListS3.java From nifi with Apache License 2.0 | 6 votes |
@Override public VersionListing listVersions() { VersionListing versionListing = new VersionListing(); this.objectListing = client.listObjectsV2(listObjectsRequest); for(S3ObjectSummary objectSummary : objectListing.getObjectSummaries()) { S3VersionSummary versionSummary = new S3VersionSummary(); versionSummary.setBucketName(objectSummary.getBucketName()); versionSummary.setETag(objectSummary.getETag()); versionSummary.setKey(objectSummary.getKey()); versionSummary.setLastModified(objectSummary.getLastModified()); versionSummary.setOwner(objectSummary.getOwner()); versionSummary.setSize(objectSummary.getSize()); versionSummary.setStorageClass(objectSummary.getStorageClass()); versionSummary.setIsLatest(true); versionListing.getVersionSummaries().add(versionSummary); } return versionListing; }
Example 4
Source File: MockS3OperationsImpl.java From herd with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} * <p/> * If the bucket does not exist, returns a listing with an empty list. If a prefix is specified in listVersionsRequest, only versions starting with the * prefix will be returned. */ @Override public VersionListing listVersions(ListVersionsRequest listVersionsRequest, AmazonS3 s3Client) { LOGGER.debug("listVersions(): listVersionsRequest.getBucketName() = " + listVersionsRequest.getBucketName()); String bucketName = listVersionsRequest.getBucketName(); if (MOCK_S3_BUCKET_NAME_NO_SUCH_BUCKET_EXCEPTION.equals(bucketName)) { AmazonS3Exception amazonS3Exception = new AmazonS3Exception(MOCK_S3_BUCKET_NAME_NO_SUCH_BUCKET_EXCEPTION); amazonS3Exception.setErrorCode("NoSuchBucket"); throw amazonS3Exception; } else if (MOCK_S3_BUCKET_NAME_INTERNAL_ERROR.equals(bucketName)) { throw new AmazonServiceException(S3Operations.ERROR_CODE_INTERNAL_ERROR); } VersionListing versionListing = new VersionListing(); versionListing.setBucketName(bucketName); MockS3Bucket mockS3Bucket = mockS3Buckets.get(bucketName); if (mockS3Bucket != null) { for (MockS3Object mockS3Object : mockS3Bucket.getVersions().values()) { String s3ObjectKey = mockS3Object.getKey(); if (listVersionsRequest.getPrefix() == null || s3ObjectKey.startsWith(listVersionsRequest.getPrefix())) { S3VersionSummary s3VersionSummary = new S3VersionSummary(); s3VersionSummary.setBucketName(bucketName); s3VersionSummary.setKey(s3ObjectKey); s3VersionSummary.setVersionId(mockS3Object.getVersion()); s3VersionSummary.setSize(mockS3Object.getData().length); s3VersionSummary.setStorageClass(mockS3Object.getObjectMetadata() != null ? mockS3Object.getObjectMetadata().getStorageClass() : null); versionListing.getVersionSummaries().add(s3VersionSummary); } } } return versionListing; }
Example 5
Source File: TestListS3.java From nifi with Apache License 2.0 | 4 votes |
@Test public void testListVersions() { runner.setProperty(ListS3.REGION, "eu-west-1"); runner.setProperty(ListS3.BUCKET, "test-bucket"); runner.setProperty(ListS3.USE_VERSIONS, "true"); Date lastModified = new Date(); VersionListing versionListing = new VersionListing(); S3VersionSummary versionSummary1 = new S3VersionSummary(); versionSummary1.setBucketName("test-bucket"); versionSummary1.setKey("test-key"); versionSummary1.setVersionId("1"); versionSummary1.setLastModified(lastModified); versionListing.getVersionSummaries().add(versionSummary1); S3VersionSummary versionSummary2 = new S3VersionSummary(); versionSummary2.setBucketName("test-bucket"); versionSummary2.setKey("test-key"); versionSummary2.setVersionId("2"); versionSummary2.setLastModified(lastModified); versionListing.getVersionSummaries().add(versionSummary2); Mockito.when(mockS3Client.listVersions(Mockito.any(ListVersionsRequest.class))).thenReturn(versionListing); runner.run(); ArgumentCaptor<ListVersionsRequest> captureRequest = ArgumentCaptor.forClass(ListVersionsRequest.class); Mockito.verify(mockS3Client, Mockito.times(1)).listVersions(captureRequest.capture()); ListVersionsRequest request = captureRequest.getValue(); assertEquals("test-bucket", request.getBucketName()); Mockito.verify(mockS3Client, Mockito.never()).listObjects(Mockito.any(ListObjectsRequest.class)); runner.assertAllFlowFilesTransferred(ListS3.REL_SUCCESS, 2); List<MockFlowFile> flowFiles = runner.getFlowFilesForRelationship(ListS3.REL_SUCCESS); MockFlowFile ff0 = flowFiles.get(0); ff0.assertAttributeEquals("filename", "test-key"); ff0.assertAttributeEquals("s3.bucket", "test-bucket"); ff0.assertAttributeEquals("s3.lastModified", String.valueOf(lastModified.getTime())); ff0.assertAttributeEquals("s3.version", "1"); MockFlowFile ff1 = flowFiles.get(1); ff1.assertAttributeEquals("filename", "test-key"); ff1.assertAttributeEquals("s3.bucket", "test-bucket"); ff1.assertAttributeEquals("s3.lastModified", String.valueOf(lastModified.getTime())); ff1.assertAttributeEquals("s3.version", "2"); }