@Test public void getObjectStorageMetadata() { when(s3Client.getBucketLocation(BUCKET_NAME)).thenReturn(REGION_NAME); ObjectStorageMetadataRequest request = ObjectStorageMetadataRequest.builder().withObjectStoragePath(BUCKET_NAME).build(); ObjectStorageMetadataResponse result = underTest.getObjectStorageMetadata(request); verify(s3Client).getBucketLocation(BUCKET_NAME); assertEquals(REGION_NAME, result.getRegion()); assertEquals(ResponseStatus.OK, result.getStatus()); }
@Override public ObjectStorageMetadataResponse getObjectStorageMetadata(ObjectStorageMetadataRequest request) { AwsCredentialView awsCredentialView = new AwsCredentialView(request.getCredential()); try { AmazonS3 s3Client = awsClient.createS3Client(awsCredentialView); String bucketLocation = fixBucketLocation(s3Client.getBucketLocation(request.getObjectStoragePath())); return ObjectStorageMetadataResponse.builder() .withRegion(bucketLocation) .withStatus(ResponseStatus.OK) .build(); } catch (AmazonS3Exception e) { if (e.getStatusCode() != ACCESS_DENIED_ERROR_CODE) { throw new CloudConnectorException(String.format("Cannot get object storage location for %s. " + "Provider error message: %s", request.getObjectStoragePath(), e.getErrorMessage()), e); } return ObjectStorageMetadataResponse.builder() .withStatus(ResponseStatus.ACCESS_DENIED) .build(); } }
AwsObjectStorageConnector implements ObjectStorageConnector { @Override public ObjectStorageMetadataResponse getObjectStorageMetadata(ObjectStorageMetadataRequest request) { AwsCredentialView awsCredentialView = new AwsCredentialView(request.getCredential()); try { AmazonS3 s3Client = awsClient.createS3Client(awsCredentialView); String bucketLocation = fixBucketLocation(s3Client.getBucketLocation(request.getObjectStoragePath())); return ObjectStorageMetadataResponse.builder() .withRegion(bucketLocation) .withStatus(ResponseStatus.OK) .build(); } catch (AmazonS3Exception e) { if (e.getStatusCode() != ACCESS_DENIED_ERROR_CODE) { throw new CloudConnectorException(String.format("Cannot get object storage location for %s. " + "Provider error message: %s", request.getObjectStoragePath(), e.getErrorMessage()), e); } return ObjectStorageMetadataResponse.builder() .withStatus(ResponseStatus.ACCESS_DENIED) .build(); } } }
AwsObjectStorageConnector implements ObjectStorageConnector { @Override public ObjectStorageMetadataResponse getObjectStorageMetadata(ObjectStorageMetadataRequest request) { AwsCredentialView awsCredentialView = new AwsCredentialView(request.getCredential()); try { AmazonS3 s3Client = awsClient.createS3Client(awsCredentialView); String bucketLocation = fixBucketLocation(s3Client.getBucketLocation(request.getObjectStoragePath())); return ObjectStorageMetadataResponse.builder() .withRegion(bucketLocation) .withStatus(ResponseStatus.OK) .build(); } catch (AmazonS3Exception e) { if (e.getStatusCode() != ACCESS_DENIED_ERROR_CODE) { throw new CloudConnectorException(String.format("Cannot get object storage location for %s. " + "Provider error message: %s", request.getObjectStoragePath(), e.getErrorMessage()), e); } return ObjectStorageMetadataResponse.builder() .withStatus(ResponseStatus.ACCESS_DENIED) .build(); } }  }
AwsObjectStorageConnector implements ObjectStorageConnector { @Override public ObjectStorageMetadataResponse getObjectStorageMetadata(ObjectStorageMetadataRequest request) { AwsCredentialView awsCredentialView = new AwsCredentialView(request.getCredential()); try { AmazonS3 s3Client = awsClient.createS3Client(awsCredentialView); String bucketLocation = fixBucketLocation(s3Client.getBucketLocation(request.getObjectStoragePath())); return ObjectStorageMetadataResponse.builder() .withRegion(bucketLocation) .withStatus(ResponseStatus.OK) .build(); } catch (AmazonS3Exception e) { if (e.getStatusCode() != ACCESS_DENIED_ERROR_CODE) { throw new CloudConnectorException(String.format("Cannot get object storage location for %s. " + "Provider error message: %s", request.getObjectStoragePath(), e.getErrorMessage()), e); } return ObjectStorageMetadataResponse.builder() .withStatus(ResponseStatus.ACCESS_DENIED) .build(); } }  @Override ObjectStorageMetadataResponse getObjectStorageMetadata(ObjectStorageMetadataRequest request); @Override ObjectStorageValidateResponse validateObjectStorage(ObjectStorageValidateRequest request); @Override Platform platform(); @Override Variant variant(); }
AwsObjectStorageConnector implements ObjectStorageConnector { @Override public ObjectStorageMetadataResponse getObjectStorageMetadata(ObjectStorageMetadataRequest request) { AwsCredentialView awsCredentialView = new AwsCredentialView(request.getCredential()); try { AmazonS3 s3Client = awsClient.createS3Client(awsCredentialView); String bucketLocation = fixBucketLocation(s3Client.getBucketLocation(request.getObjectStoragePath())); return ObjectStorageMetadataResponse.builder() .withRegion(bucketLocation) .withStatus(ResponseStatus.OK) .build(); } catch (AmazonS3Exception e) { if (e.getStatusCode() != ACCESS_DENIED_ERROR_CODE) { throw new CloudConnectorException(String.format("Cannot get object storage location for %s. " + "Provider error message: %s", request.getObjectStoragePath(), e.getErrorMessage()), e); } return ObjectStorageMetadataResponse.builder() .withStatus(ResponseStatus.ACCESS_DENIED) .build(); } }  @Override ObjectStorageMetadataResponse getObjectStorageMetadata(ObjectStorageMetadataRequest request); @Override ObjectStorageValidateResponse validateObjectStorage(ObjectStorageValidateRequest request); @Override Platform platform(); @Override Variant variant();  }