Java 类com.amazonaws.services.s3.model.GetObjectMetadataRequest 实例源码

项目:ibm-cos-sdk-java    文件:AmazonS3Client.java   
@Override
public ObjectMetadata getObjectMetadata(GetObjectMetadataRequest getObjectMetadataRequest)
        throws SdkClientException, AmazonServiceException {
    getObjectMetadataRequest = beforeClientExecution(getObjectMetadataRequest);
    rejectNull(getObjectMetadataRequest, "The GetObjectMetadataRequest parameter must be specified when requesting an object's metadata");

    String bucketName = getObjectMetadataRequest.getBucketName();
    String key = getObjectMetadataRequest.getKey();
    String versionId = getObjectMetadataRequest.getVersionId();

    rejectNull(bucketName, "The bucket name parameter must be specified when requesting an object's metadata");
    rejectNull(key, "The key parameter must be specified when requesting an object's metadata");

    Request<GetObjectMetadataRequest> request = createRequest(bucketName, key, getObjectMetadataRequest, HttpMethodName.HEAD);

    if (versionId != null) request.addParameter("versionId", versionId);

    populateRequesterPaysHeader(request, getObjectMetadataRequest.isRequesterPays());
    addPartNumberIfNotNull(request, getObjectMetadataRequest.getPartNumber());

    populateSSE_C(request, getObjectMetadataRequest.getSSECustomerKey());

    return invoke(request, new S3MetadataResponseHandler(), bucketName, key);
}
项目:S3Mock    文件:AmazonClientUploadIT.java   
/**
 * Tests if Object can be uploaded with KMS
 */
@Test
public void shouldUploadWithEncryption() {
  final File uploadFile = new File(UPLOAD_FILE_NAME);
  final String objectKey = UPLOAD_FILE_NAME;
  s3Client.createBucket(BUCKET_NAME);
  final PutObjectRequest putObjectRequest =
      new PutObjectRequest(BUCKET_NAME, objectKey, uploadFile);
  putObjectRequest.setSSEAwsKeyManagementParams(new SSEAwsKeyManagementParams(TEST_ENC_KEYREF));

  s3Client.putObject(putObjectRequest);

  final GetObjectMetadataRequest getObjectMetadataRequest =
      new GetObjectMetadataRequest(BUCKET_NAME, objectKey);

  final ObjectMetadata objectMetadata = s3Client.getObjectMetadata(getObjectMetadataRequest);

  assertThat(objectMetadata.getContentLength(), is(uploadFile.length()));
}
项目:digdag    文件:S3WaitOperatorFactoryTest.java   
@Test
public void testVersionId()
        throws Exception
{
    Config config = newConfig();
    config.set("_command", BUCKET + "/" + KEY);
    config.set("version_id", VERSION_ID);
    when(taskRequest.getConfig()).thenReturn(config);

    when(s3Secrets.getSecretOptional("region")).thenReturn(Optional.of(REGION));

    when(s3Client.getObjectMetadata(objectMetadataRequestCaptor.capture())).thenThrow(NOT_FOUND_EXCEPTION);

    Operator operator = factory.newOperator(newContext(projectPath, taskRequest));

    try {
        operator.run();
        fail();
    }
    catch (TaskExecutionException ignore) {
    }

    GetObjectMetadataRequest objectMetadataRequest = objectMetadataRequestCaptor.getValue();

    assertThat(objectMetadataRequest.getVersionId(), is(VERSION_ID));
}
项目:digdag    文件:S3WaitOperatorFactoryTest.java   
@Test
public void testSSEC()
        throws Exception
{
    Config config = newConfig();
    config.set("_command", BUCKET + "/" + KEY);
    when(taskRequest.getConfig()).thenReturn(config);

    when(s3Secrets.getSecretOptional("sse_c_key")).thenReturn(Optional.of(SSE_C_KEY));

    when(s3Client.getObjectMetadata(objectMetadataRequestCaptor.capture())).thenThrow(NOT_FOUND_EXCEPTION);

    Operator operator = factory.newOperator(newContext(projectPath, taskRequest));

    try {
        operator.run();
        fail();
    }
    catch (TaskExecutionException ignore) {
    }

    GetObjectMetadataRequest objectMetadataRequest = objectMetadataRequestCaptor.getValue();
    assertThat(objectMetadataRequest.getSSECustomerKey().getKey(), is(SSE_C_KEY));
    assertThat(objectMetadataRequest.getSSECustomerKey().getAlgorithm(), is("AES256"));
    assertThat(objectMetadataRequest.getSSECustomerKey().getMd5(), is(nullValue()));
}
项目:bfs3    文件:AmazonS3Handle.java   
public AmazonS3Handle(final AWSCredentials c,
    final String bucketName, final String key, final Regions regions)
    throws IOException
{
    super(false);
    this.bucketName = bucketName;
    this.key = key;

    s3 = c == null ? new AmazonS3Client() : new AmazonS3Client(c);
    final Region usEast1 = Region.getRegion(regions);
    s3.setRegion(usEast1);

    // get the object metadata
    objectMetadata =
        s3.getObjectMetadata(new GetObjectMetadataRequest(bucketName, key));

    seek(0);
}
项目:spring-cloud-aws    文件:SimpleStorageResource.java   
private ObjectMetadata getObjectMetadata() {
    if (this.objectMetadata == null) {
        try {
            GetObjectMetadataRequest metadataRequest = new GetObjectMetadataRequest(this.bucketName, this.objectName);
            if (this.versionId != null) {
                metadataRequest.setVersionId(this.versionId);
            }
            this.objectMetadata = this.amazonS3.getObjectMetadata(metadataRequest);
        } catch (AmazonS3Exception e) {
            // Catch 404 (object not found) and 301 (bucket not found, moved permanently)
            if (e.getStatusCode() == 404 || e.getStatusCode() == 301) {
                this.objectMetadata = null;
            } else {
                throw e;
            }
        }
    }
    return this.objectMetadata;
}
项目:spring-cloud-aws    文件:SimpleStorageResourceTest.java   
@Test
public void getInputStream_existingObject_returnsInputStreamWithContent() throws Exception {
    //Arrange
    AmazonS3 amazonS3 = mock(AmazonS3.class);
    ObjectMetadata objectMetadata = mock(ObjectMetadata.class);
    when(amazonS3.getObjectMetadata(any(GetObjectMetadataRequest.class))).thenReturn(objectMetadata);

    S3Object s3Object = new S3Object();
    s3Object.setObjectMetadata(objectMetadata);
    s3Object.setObjectContent(new ByteArrayInputStream(new byte[]{42}));
    when(amazonS3.getObject(any(GetObjectRequest.class))).thenReturn(s3Object);

    //Act
    SimpleStorageResource simpleStorageResource = new SimpleStorageResource(amazonS3, "bucket", "object", new SyncTaskExecutor());

    //Assert
    assertTrue(simpleStorageResource.exists());
    assertEquals(42, simpleStorageResource.getInputStream().read());
}
项目:spring-cloud-aws    文件:PathMatchingSimpleStorageResourcePatternResolverTest.java   
private AmazonS3 prepareMockForTestWildcardInBucketName() {
    AmazonS3 amazonS3 = mock(AmazonS3.class);
    when(amazonS3.listBuckets()).thenReturn(Arrays.asList(new Bucket("myBucketOne"), new Bucket("myBucketTwo"),
            new Bucket("anotherBucket"), new Bucket("myBuckez")));

    // Mocks for the '**' case
    ObjectListing objectListingWithOneFile = createObjectListingMock(Collections.singletonList(createS3ObjectSummaryWithKey("test.txt")), Collections.emptyList(), false);
    ObjectListing emptyObjectListing = createObjectListingMock(Collections.emptyList(), Collections.emptyList(), false);
    when(amazonS3.listObjects(argThat(new ListObjectsRequestMatcher("myBucketOne", null, null)))).thenReturn(objectListingWithOneFile);
    when(amazonS3.listObjects(argThat(new ListObjectsRequestMatcher("myBucketTwo", null, null)))).thenReturn(emptyObjectListing);
    when(amazonS3.listObjects(argThat(new ListObjectsRequestMatcher("anotherBucket", null, null)))).thenReturn(objectListingWithOneFile);
    when(amazonS3.listObjects(argThat(new ListObjectsRequestMatcher("myBuckez", null, null)))).thenReturn(emptyObjectListing);

    when(amazonS3.getObjectMetadata(any(GetObjectMetadataRequest.class))).thenReturn(new ObjectMetadata());
    return amazonS3;
}
项目:cloudata    文件:S3ObjectStore.java   
@Override
public ObjectInfo getInfo(final String path) throws IOException {
  log.debug("Get object info for {}/{}", bucket, path);

  GetObjectMetadataRequest request = new GetObjectMetadataRequest(bucket, path);
  final ObjectMetadata metadata = s3Client.getObjectMetadata(request);

  return new ObjectInfo() {

    @Override
    public long getLength() {
      return metadata.getContentLength();
    }

    @Override
    public String getPath() {
      return path;
    }

    @Override
    public boolean isSubdir() {
      return false;
    }

  };
}
项目:elasticsearch_my    文件:MockAmazonS3.java   
@Override
public ObjectMetadata getObjectMetadata(
        GetObjectMetadataRequest getObjectMetadataRequest)
        throws AmazonClientException, AmazonServiceException {
    String blobName = getObjectMetadataRequest.getKey();

    if (!blobs.containsKey(blobName)) {
        throw new AmazonS3Exception("[" + blobName + "] does not exist.");
    }

    return new ObjectMetadata(); // nothing is done with it
}
项目:opentest    文件:GetS3Metadata.java   
@Override
public void run() {
    super.run();

    String awsCredentialsProfile = this.readStringArgument("awsProfile", "default");
    String bucket = this.readStringArgument("bucket");
    String objectKey = this.readStringArgument("objectKey");

    AmazonS3 s3Client = new AmazonS3Client(new ProfileCredentialsProvider(awsCredentialsProfile));
    ObjectMetadata metadata = s3Client.getObjectMetadata(
            new GetObjectMetadataRequest(bucket, objectKey));

    try {
        Date expirationTime = metadata.getExpirationTime();
        if (expirationTime != null) {
            this.writeOutput("expirationTime", metadata.getExpirationTime().getTime());
        } else {
            this.writeOutput("expirationTime", null);
        }
        this.writeOutput("lastModified", metadata.getLastModified().getTime());
        this.writeOutput("userMetadata", metadata.getUserMetadata());
        this.writeOutput("size", metadata.getContentLength());
        this.writeOutput("storageClass", metadata.getStorageClass());
        this.writeOutput("versionId", metadata.getVersionId());
    } catch (Exception ex) {
        throw new RuntimeException(String.format(
                "Failed to get object metadata for object key %s in bucket %s",
                objectKey,
                bucket), ex);
    }
}
项目:ecs-samples    文件:_06_ReadObjectWithMetadata.java   
public static void main(String[] args) throws Exception {
    // create the AWS S3 Client
    AmazonS3 s3 = AWSS3Factory.getS3Client();

    // retrieve the object key from user
    System.out.println( "Enter the object key:" );
    String key = new BufferedReader( new InputStreamReader( System.in ) ).readLine();

    //GetObjectMetadataRequest gom = new GetObjectMetadataRequest(b, k, v)
    try {
        GetObjectMetadataRequest gom = new GetObjectMetadataRequest(AWSS3Factory.S3_BUCKET, key);
        s3.getObjectMetadata(gom);
    }
    catch(com.amazonaws.services.s3.model.AmazonS3Exception e) {
        System.out.println("What happened: " + e.getMessage());
    }

    // read the specified object from the demo bucket
    S3Object object = s3.getObject(AWSS3Factory.S3_BUCKET, key);

    // get the metadata for the object
    ObjectMetadata metadata = object.getObjectMetadata();

    // print out the object key/value and metadata for validation
    System.out.println( String.format("Metadata for [%s/%s]",
            AWSS3Factory.S3_BUCKET, key));

    Map<String,String> metadataList = metadata.getUserMetadata();
    //String metaVal = metadataList.get("metakey1");
    //System.out.println(String.format("    %s = %s", "metakey1", metaVal));

    for (Map.Entry<String, String> entry : metadataList.entrySet())
    {
        System.out.println(String.format("    %s = %s", entry.getKey(), entry.getValue()));
    }

}
项目:digdag    文件:S3WaitOperatorFactoryTest.java   
@Test
public void testSSECWithAlgorithmAndMd5()
        throws Exception
{
    Config config = newConfig();
    config.set("_command", BUCKET + "/" + KEY);
    when(taskRequest.getConfig()).thenReturn(config);

    when(s3Secrets.getSecretOptional("sse_c_key")).thenReturn(Optional.of(SSE_C_KEY));
    when(s3Secrets.getSecretOptional("sse_c_key_algorithm")).thenReturn(Optional.of(SSE_C_KEY_ALGORITM));
    when(s3Secrets.getSecretOptional("sse_c_key_md5")).thenReturn(Optional.of(SSE_C_KEY_MD5));

    when(s3Client.getObjectMetadata(objectMetadataRequestCaptor.capture())).thenThrow(NOT_FOUND_EXCEPTION);

    Operator operator = factory.newOperator(newContext(projectPath, taskRequest));

    try {
        operator.run();
        fail();
    }
    catch (TaskExecutionException ignore) {
    }

    GetObjectMetadataRequest objectMetadataRequest = objectMetadataRequestCaptor.getValue();
    assertThat(objectMetadataRequest.getSSECustomerKey().getKey(), is(SSE_C_KEY));
    assertThat(objectMetadataRequest.getSSECustomerKey().getAlgorithm(), is(SSE_C_KEY_ALGORITM));
    assertThat(objectMetadataRequest.getSSECustomerKey().getMd5(), is(SSE_C_KEY_MD5));
}
项目:amediamanager    文件:VideoServiceImpl.java   
@Override
public Video save(String bucket, String videoKey) throws ParseException {

    // From bucket and key, get metadata from video that was just uploaded
    GetObjectMetadataRequest metadataReq = new GetObjectMetadataRequest(
            bucket, videoKey);
    ObjectMetadata metadata = s3Client.getObjectMetadata(metadataReq);
    Map<String, String> userMetadata = metadata.getUserMetadata();

    Video video = new Video();

    video.setDescription(userMetadata.get("description"));
    video.setOwner(userMetadata.get("owner"));
    video.setId(userMetadata.get("uuid"));
    video.setTitle(userMetadata.get("title"));
    video.setPrivacy(Privacy.fromName(userMetadata.get("privacy")));
    video.setCreatedDate(new SimpleDateFormat("MM/dd/yyyy")
            .parse(userMetadata.get("createddate")));
    video.setOriginalKey(videoKey);
    video.setBucket(userMetadata.get("bucket"));
    video.setUploadedDate(new Date());

    Set<Tag> tags = new HashSet<Tag>();
    for (String tag : userMetadata.get("tags").split(",")) {
        tags.add(new Tag(tag.trim()));
    }
    video.setTags(tags);

    save(video);

    return video;
}
项目:spring-cloud-aws    文件:SimpleStorageResourceTest.java   
@Test
public void exists_withExistingObjectMetadata_returnsTrue() throws Exception {
    //Arrange
    AmazonS3 amazonS3 = mock(AmazonS3.class);
    when(amazonS3.getObjectMetadata(any(GetObjectMetadataRequest.class))).thenReturn(new ObjectMetadata());

    //Act
    SimpleStorageResource simpleStorageResource = new SimpleStorageResource(amazonS3, "bucket", "object", new SyncTaskExecutor());

    //Assert
    assertTrue(simpleStorageResource.exists());
}
项目:spring-cloud-aws    文件:SimpleStorageResourceTest.java   
@Test
public void exists_withoutExistingObjectMetadata_returnsFalse() throws Exception {
    //Arrange
    AmazonS3 amazonS3 = mock(AmazonS3.class);
    when(amazonS3.getObjectMetadata(any(GetObjectMetadataRequest.class))).thenReturn(null);

    //Act
    SimpleStorageResource simpleStorageResource = new SimpleStorageResource(amazonS3, "bucket", "object", new SyncTaskExecutor());

    //Act
    assertFalse(simpleStorageResource.exists());
}
项目:spring-cloud-aws    文件:SimpleStorageResourceTest.java   
@Test
public void contentLength_withExistingResource_returnsContentLengthOfObjectMetaData() throws Exception {
    //Arrange
    AmazonS3 amazonS3 = mock(AmazonS3.class);
    ObjectMetadata objectMetadata = new ObjectMetadata();
    objectMetadata.setContentLength(1234L);
    when(amazonS3.getObjectMetadata(any(GetObjectMetadataRequest.class))).thenReturn(objectMetadata);

    //Act
    SimpleStorageResource simpleStorageResource = new SimpleStorageResource(amazonS3, "bucket", "object", new SyncTaskExecutor());

    //Assert
    assertEquals(1234L, simpleStorageResource.contentLength());
}
项目:spring-cloud-aws    文件:SimpleStorageResourceTest.java   
@Test
public void lastModified_withExistingResource_returnsLastModifiedDateOfResource() throws Exception {
    //Arrange
    AmazonS3 amazonS3 = mock(AmazonS3.class);
    ObjectMetadata objectMetadata = new ObjectMetadata();
    Date lastModified = new Date();
    objectMetadata.setLastModified(lastModified);
    when(amazonS3.getObjectMetadata(any(GetObjectMetadataRequest.class))).thenReturn(objectMetadata);

    //Act
    SimpleStorageResource simpleStorageResource = new SimpleStorageResource(amazonS3, "bucket", "object", new SyncTaskExecutor());

    //Assert
    assertEquals(lastModified.getTime(), simpleStorageResource.lastModified());
}
项目:spring-cloud-aws    文件:SimpleStorageResourceTest.java   
@Test
public void contentLength_fileDoesNotExists_reportsError() throws Exception {
    //Arrange
    this.expectedException.expect(FileNotFoundException.class);
    this.expectedException.expectMessage("not found");

    AmazonS3 amazonS3 = mock(AmazonS3.class);
    when(amazonS3.getObjectMetadata(any(GetObjectMetadataRequest.class))).thenReturn(null);
    SimpleStorageResource simpleStorageResource = new SimpleStorageResource(amazonS3, "bucket", "object", new SyncTaskExecutor());

    //Act
    simpleStorageResource.contentLength();

    //Assert
}
项目:spring-cloud-aws    文件:SimpleStorageResourceTest.java   
@Test
public void lastModified_fileDoestNotExist_reportsError() throws Exception {
    //Arrange
    this.expectedException.expect(FileNotFoundException.class);
    this.expectedException.expectMessage("not found");

    AmazonS3 amazonS3 = mock(AmazonS3.class);
    when(amazonS3.getObjectMetadata(any(GetObjectMetadataRequest.class))).thenReturn(null);
    SimpleStorageResource simpleStorageResource = new SimpleStorageResource(amazonS3, "bucket", "object", new SyncTaskExecutor());

    //Act
    simpleStorageResource.lastModified();

    //Assert
}
项目:spring-cloud-aws    文件:SimpleStorageResourceTest.java   
@Test
public void getFileName_existingObject_returnsFileNameWithoutBucketNameFromParameterWithoutActuallyFetchingTheFile() throws Exception {
    //Arrange
    AmazonS3 amazonS3 = mock(AmazonS3.class);
    when(amazonS3.getObjectMetadata(any(GetObjectMetadataRequest.class))).thenReturn(null);

    //Act
    SimpleStorageResource simpleStorageResource = new SimpleStorageResource(amazonS3, "bucket", "object", new SyncTaskExecutor());

    //Assert
    assertEquals("object", simpleStorageResource.getFilename());
}
项目:spring-cloud-aws    文件:SimpleStorageResourceTest.java   
@Test
public void createRelative_existingObject_returnsRelativeCreatedFile() throws IOException {

    //Arrange
    AmazonS3 amazonS3 = mock(AmazonS3.class);
    when(amazonS3.getObjectMetadata(any(GetObjectMetadataRequest.class))).thenReturn(new ObjectMetadata());
    SimpleStorageResource simpleStorageResource = new SimpleStorageResource(amazonS3, "bucket", "object", new SyncTaskExecutor());

    //Act
    SimpleStorageResource subObject = simpleStorageResource.createRelative("subObject");

    //Assert
    assertEquals("object/subObject", subObject.getFilename());
}
项目:spring-cloud-aws    文件:PathMatchingSimpleStorageResourcePatternResolverTest.java   
private AmazonS3 prepareMockForTestTruncatedListings() {
    AmazonS3 amazonS3 = mock(AmazonS3.class);

    // Without prefix calls
    ObjectListing objectListingWithoutPrefixPart1 = createObjectListingMock(Arrays.asList(createS3ObjectSummaryWithKey("fooOne/barOne/test.txt"),
            createS3ObjectSummaryWithKey("fooOne/bazOne/test.txt"), createS3ObjectSummaryWithKey("fooTwo/barTwo/test.txt")), Collections.emptyList(), true);
    when(amazonS3.listObjects(argThat(new ListObjectsRequestMatcher("myBucket", null, null)))).thenReturn(objectListingWithoutPrefixPart1);

    ObjectListing objectListingWithoutPrefixPart2 = createObjectListingMock(Arrays.asList(createS3ObjectSummaryWithKey("fooThree/baz/test.txt"),
            createS3ObjectSummaryWithKey("foFour/barFour/test.txt")), Collections.emptyList(), false);
    when(amazonS3.listNextBatchOfObjects(objectListingWithoutPrefixPart1)).thenReturn(objectListingWithoutPrefixPart2);

    // With prefix calls
    ObjectListing objectListingWithPrefixPart1 = createObjectListingMock(Collections.emptyList(), Arrays.asList("dooOne/", "dooTwo/"), true);
    when(amazonS3.listObjects(argThat(new ListObjectsRequestMatcher("myBucket", null, "/")))).thenReturn(objectListingWithPrefixPart1);

    ObjectListing objectListingWithPrefixPart2 = createObjectListingMock(Collections.emptyList(), Collections.singletonList("fooOne/"), false);
    when(amazonS3.listNextBatchOfObjects(objectListingWithPrefixPart1)).thenReturn(objectListingWithPrefixPart2);

    ObjectListing objectListingWithPrefixFooOne = createObjectListingMock(Collections.emptyList(), Collections.singletonList("fooOne/barOne/"), false);
    when(amazonS3.listObjects(argThat(new ListObjectsRequestMatcher("myBucket", "fooOne/", "/")))).thenReturn(objectListingWithPrefixFooOne);

    ObjectListing objectListingWithPrefixFooOneBarOne = createObjectListingMock(Collections.singletonList(createS3ObjectSummaryWithKey("fooOne/barOne/test.txt")), Collections.emptyList(), false);
    when(amazonS3.listObjects(argThat(new ListObjectsRequestMatcher("myBucket", "fooOne/barOne/", "/")))).thenReturn(objectListingWithPrefixFooOneBarOne);

    when(amazonS3.getObjectMetadata(any(GetObjectMetadataRequest.class))).thenReturn(new ObjectMetadata());

    return amazonS3;
}
项目:spring-cloud-aws    文件:SimpleStorageResourceLoaderTest.java   
@Test
public void testGetResourceWithExistingResource() throws Exception {

    AmazonS3 amazonS3 = mock(AmazonS3.class);

    SimpleStorageResourceLoader resourceLoader = new SimpleStorageResourceLoader(amazonS3);

    ObjectMetadata metadata = new ObjectMetadata();
    when(amazonS3.getObjectMetadata(any(GetObjectMetadataRequest.class))).thenReturn(metadata);

    String resourceName = "s3://bucket/object/";
    Resource resource = resourceLoader.getResource(resourceName);
    assertNotNull(resource);
}
项目:spring-cloud-aws    文件:SimpleStorageResourceLoaderTest.java   
@Test
public void testGetResourceWithVersionId() throws Exception {
    AmazonS3 amazonS3 = mock(AmazonS3.class);

    SimpleStorageResourceLoader resourceLoader = new SimpleStorageResourceLoader(amazonS3);

    ObjectMetadata metadata = new ObjectMetadata();

    when(amazonS3.getObjectMetadata(any(GetObjectMetadataRequest.class))).thenReturn(metadata);

    String resourceName = "s3://bucket/object^versionIdValue";
    Resource resource = resourceLoader.getResource(resourceName);
    assertNotNull(resource);
}
项目:jcabi-s3    文件:AwsOcketTest.java   
/**
 * AwsOcket can throw if object not found.
 * @throws Exception If fails
 */
@Test(expected = OcketNotFoundException.class)
public void throwsWhenObjectNotFound() throws Exception {
    final AmazonS3 aws = Mockito.mock(AmazonS3.class);
    Mockito.doThrow(new AmazonS3Exception("")).when(aws).getObjectMetadata(
        Mockito.any(GetObjectMetadataRequest.class)
    );
    final Region region = Mockito.mock(Region.class);
    Mockito.doReturn(aws).when(region).aws();
    final Bucket bucket = Mockito.mock(Bucket.class);
    Mockito.doReturn(region).when(bucket).region();
    final Ocket ocket = new AwsOcket(bucket, "test-99.txt");
    ocket.meta();
}
项目:elasticsearch_my    文件:AmazonS3Wrapper.java   
@Override
public ObjectMetadata getObjectMetadata(GetObjectMetadataRequest getObjectMetadataRequest) throws AmazonClientException, AmazonServiceException {
    return delegate.getObjectMetadata(getObjectMetadataRequest);
}
项目:syndesis    文件:AmazonS3ClientMock.java   
@Override
public ObjectMetadata getObjectMetadata(GetObjectMetadataRequest getObjectMetadataRequest) throws AmazonClientException, AmazonServiceException {
    throw new UnsupportedOperationException();
}
项目:syndesis    文件:AmazonS3ClientMock.java   
@Override
public ObjectMetadata getObjectMetadata(GetObjectMetadataRequest getObjectMetadataRequest) throws AmazonClientException, AmazonServiceException {
    throw new UnsupportedOperationException();
}
项目:syndesis    文件:AmazonS3ClientMock.java   
@Override
public ObjectMetadata getObjectMetadata(GetObjectMetadataRequest getObjectMetadataRequest) throws AmazonClientException, AmazonServiceException {
    throw new UnsupportedOperationException();
}
项目:connectors    文件:AmazonS3ClientMock.java   
@Override
public ObjectMetadata getObjectMetadata(GetObjectMetadataRequest getObjectMetadataRequest) throws AmazonClientException, AmazonServiceException {
    throw new UnsupportedOperationException();
}
项目:connectors    文件:AmazonS3ClientMock.java   
@Override
public ObjectMetadata getObjectMetadata(GetObjectMetadataRequest getObjectMetadataRequest) throws AmazonClientException, AmazonServiceException {
    throw new UnsupportedOperationException();
}
项目:connectors    文件:AmazonS3ClientMock.java   
@Override
public ObjectMetadata getObjectMetadata(GetObjectMetadataRequest getObjectMetadataRequest) throws AmazonClientException, AmazonServiceException {
    throw new UnsupportedOperationException();
}
项目:ibm-cos-sdk-java    文件:AmazonS3Client.java   
@Override
public ObjectMetadata getObjectMetadata(String bucketName, String key)
        throws SdkClientException, AmazonServiceException {
    return getObjectMetadata(new GetObjectMetadataRequest(bucketName, key));
}
项目:S3Decorators    文件:S3Decorator.java   
@Override
public ObjectMetadata getObjectMetadata(GetObjectMetadataRequest getObjectMetadataRequest) throws SdkClientException, AmazonServiceException {
  return call(() -> getDelegate().getObjectMetadata(getObjectMetadataRequest));
}
项目:backuprotator    文件:AWSHandler.java   
private ObjectMetadata getMetaData(Bucket srcBucket, String fileName) {
    GetObjectMetadataRequest metadataRequest = 
            new GetObjectMetadataRequest(srcBucket.getName(), srcBucket.getPath() + SEPARATOR + fileName);
    ObjectMetadata metadataResult = s3Client.getObjectMetadata(metadataRequest);
    return metadataResult;
}
项目:Camel    文件:AmazonS3ClientMock.java   
@Override
public ObjectMetadata getObjectMetadata(GetObjectMetadataRequest getObjectMetadataRequest) throws AmazonClientException, AmazonServiceException {
    throw new UnsupportedOperationException();
}
项目:presto    文件:MockAmazonS3.java   
@Override
public ObjectMetadata getObjectMetadata(GetObjectMetadataRequest getObjectMetadataRequest)
        throws AmazonClientException
{
    return null;
}
项目:digdag    文件:S3WaitOperatorFactoryTest.java   
@Test
public void testDefaults()
        throws Exception
{
    Config config = newConfig();

    config.set("_command", BUCKET + "/" + KEY);

    when(taskRequest.getConfig()).thenReturn(config);

    ObjectMetadata objectMetadata = new ObjectMetadata();
    objectMetadata.setContentType(CONTENT_TYPE);
    objectMetadata.setContentLength(CONTENT_LENGTH);
    objectMetadata.setUserMetadata(USER_METADATA);

    Operator operator = factory.newOperator(newContext(projectPath, taskRequest));

    when(s3Client.getObjectMetadata(objectMetadataRequestCaptor.capture())).thenReturn(objectMetadata);

    TaskResult taskResult = operator.run();

    verify(s3ClientFactory).create(credentialsCaptor.capture(), clientConfigurationCaptor.capture());

    ClientConfiguration clientConfiguration = clientConfigurationCaptor.getValue();
    assertThat(clientConfiguration.getProxyHost(), is(nullValue()));
    assertThat(clientConfiguration.getProxyPort(), is(-1));
    assertThat(clientConfiguration.getProxyUsername(), is(nullValue()));
    assertThat(clientConfiguration.getProxyPassword(), is(nullValue()));

    verify(s3Client).setS3ClientOptions(s3ClientOptionsCaptor.capture());
    S3ClientOptions s3ClientOptions = s3ClientOptionsCaptor.getValue();
    assertThat(s3ClientOptions.isPathStyleAccess(), is(false));

    AWSCredentials credentials = credentialsCaptor.getValue();
    assertThat(credentials.getAWSAccessKeyId(), is(ACCESS_KEY_ID));
    assertThat(credentials.getAWSSecretKey(), is(SECRET_ACCESS_KEY));

    GetObjectMetadataRequest objectMetadataRequest = objectMetadataRequestCaptor.getValue();
    assertThat(objectMetadataRequest.getKey(), is(KEY));
    assertThat(objectMetadataRequest.getBucketName(), is(BUCKET));
    assertThat(objectMetadataRequest.getSSECustomerKey(), is(nullValue()));

    Config expectedStoreParams = newConfig();
    expectedStoreParams
            .getNestedOrSetEmpty("s3")
            .getNestedOrSetEmpty("last_object")
            .set("metadata", objectMetadata.getRawMetadata())
            .set("user_metadata", objectMetadata.getUserMetadata());

    assertThat(taskResult.getStoreParams(), is(expectedStoreParams));
}
项目:digdag    文件:S3WaitOperatorFactoryTest.java   
@Test
public void testExponentialBackoff()
        throws Exception
{
    Config config = newConfig();
    config.set("_command", BUCKET + "/" + KEY);

    when(taskRequest.getConfig()).thenReturn(config);

    ObjectMetadata objectMetadata = new ObjectMetadata();
    objectMetadata.setContentType(CONTENT_TYPE);
    objectMetadata.setContentLength(CONTENT_LENGTH);
    objectMetadata.setUserMetadata(USER_METADATA);

    when(s3Client.getObjectMetadata(any(GetObjectMetadataRequest.class))).thenThrow(NOT_FOUND_EXCEPTION);

    Operator operator = factory.newOperator(newContext(projectPath, taskRequest));

    List<Integer> retryIntervals = new ArrayList<>();

    for (int i = 0; i < 10; i++) {
        try {
            operator.run();
            fail();
        }
        catch (TaskExecutionException e) {
            assertThat(e.isError(), is(false));
            assertThat(e.getRetryInterval().isPresent(), is(true));
            retryIntervals.add(e.getRetryInterval().get());
            Config lastStateParams = e.getStateParams(configFactory).get();
            when(taskRequest.getLastStateParams()).thenReturn(lastStateParams);
        }
    }

    for (int i = 1; i < retryIntervals.size(); i++) {
        int prevInterval = retryIntervals.get(i - 1);
        int interval = retryIntervals.get(i);
        assertThat(interval, is(Math.min(MAX_POLL_INTERVAL, prevInterval * 2)));
    }

    assertThat(retryIntervals.get(retryIntervals.size() - 1), is(MAX_POLL_INTERVAL));
}