@Test public void testGetBucketStatus() throws ServiceException { ContainerStatus bucketStatus; doReturn(S3Service.BUCKET_STATUS__MY_BUCKET).when(s3Service).checkBucketStatus(eq(BUCKET_NAME)); bucketStatus = template.checkContainerStatus(BUCKET_NAME); assertEquals(ContainerStatus.MINE, bucketStatus); doReturn(S3Service.BUCKET_STATUS__DOES_NOT_EXIST).when(s3Service).checkBucketStatus(eq(BUCKET_NAME)); bucketStatus = template.checkContainerStatus(BUCKET_NAME); assertEquals(ContainerStatus.DOES_NOT_EXIST, bucketStatus); doReturn(S3Service.BUCKET_STATUS__ALREADY_CLAIMED).when(s3Service).checkBucketStatus(eq(BUCKET_NAME)); bucketStatus = template.checkContainerStatus(BUCKET_NAME); assertEquals(ContainerStatus.ALREADY_CLAIMED, bucketStatus); verify(s3Service, times(3)).checkBucketStatus(eq(BUCKET_NAME)); }
public ContainerStatus checkContainerStatus(String containerName) { Assert.notNull(containerName, BUCKET_NAME_CANNOT_BE_NULL); LOG.debug("Get bucket '{}' status", containerName); try { int bucketStatus = this.s3Service.checkBucketStatus(containerName); switch (bucketStatus) { case S3Service.BUCKET_STATUS__MY_BUCKET: return ContainerStatus.MINE; case S3Service.BUCKET_STATUS__DOES_NOT_EXIST: return ContainerStatus.DOES_NOT_EXIST; case S3Service.BUCKET_STATUS__ALREADY_CLAIMED: return ContainerStatus.ALREADY_CLAIMED; default: throw new StorageException("Unrecognised bucket status: " + bucketStatus); } } catch (S3ServiceException s3E) { throw new StorageCommunicationException("Failed to get status of bucket name " + containerName, s3E); } catch (ServiceException e) { throw new StorageCommunicationException(SERVICE_PROBLEM, e); } }
JetS3Template extends S3Template { public ContainerStatus checkContainerStatus(String containerName) { Assert.notNull(containerName, BUCKET_NAME_CANNOT_BE_NULL); LOG.debug("Get bucket '{}' status", containerName); try { int bucketStatus = this.s3Service.checkBucketStatus(containerName); switch (bucketStatus) { case S3Service.BUCKET_STATUS__MY_BUCKET: return ContainerStatus.MINE; case S3Service.BUCKET_STATUS__DOES_NOT_EXIST: return ContainerStatus.DOES_NOT_EXIST; case S3Service.BUCKET_STATUS__ALREADY_CLAIMED: return ContainerStatus.ALREADY_CLAIMED; default: throw new StorageException("Unrecognised bucket status: " + bucketStatus); } } catch (S3ServiceException s3E) { throw new StorageCommunicationException("Failed to get status of bucket name " + containerName, s3E); } catch (ServiceException e) { throw new StorageCommunicationException(SERVICE_PROBLEM, e); } } }
JetS3Template extends S3Template { public ContainerStatus checkContainerStatus(String containerName) { Assert.notNull(containerName, BUCKET_NAME_CANNOT_BE_NULL); LOG.debug("Get bucket '{}' status", containerName); try { int bucketStatus = this.s3Service.checkBucketStatus(containerName); switch (bucketStatus) { case S3Service.BUCKET_STATUS__MY_BUCKET: return ContainerStatus.MINE; case S3Service.BUCKET_STATUS__DOES_NOT_EXIST: return ContainerStatus.DOES_NOT_EXIST; case S3Service.BUCKET_STATUS__ALREADY_CLAIMED: return ContainerStatus.ALREADY_CLAIMED; default: throw new StorageException("Unrecognised bucket status: " + bucketStatus); } } catch (S3ServiceException s3E) { throw new StorageCommunicationException("Failed to get status of bucket name " + containerName, s3E); } catch (ServiceException e) { throw new StorageCommunicationException(SERVICE_PROBLEM, e); } } JetS3Template(final AwsCredentials awsCredentials);  JetS3Template(final AwsCredentials awsCredentials, final String defaultContainerName); }
JetS3Template extends S3Template { public ContainerStatus checkContainerStatus(String containerName) { Assert.notNull(containerName, BUCKET_NAME_CANNOT_BE_NULL); LOG.debug("Get bucket '{}' status", containerName); try { int bucketStatus = this.s3Service.checkBucketStatus(containerName); switch (bucketStatus) { case S3Service.BUCKET_STATUS__MY_BUCKET: return ContainerStatus.MINE; case S3Service.BUCKET_STATUS__DOES_NOT_EXIST: return ContainerStatus.DOES_NOT_EXIST; case S3Service.BUCKET_STATUS__ALREADY_CLAIMED: return ContainerStatus.ALREADY_CLAIMED; default: throw new StorageException("Unrecognised bucket status: " + bucketStatus); } } catch (S3ServiceException s3E) { throw new StorageCommunicationException("Failed to get status of bucket name " + containerName, s3E); } catch (ServiceException e) { throw new StorageCommunicationException(SERVICE_PROBLEM, e); } } JetS3Template(final AwsCredentials awsCredentials);  JetS3Template(final AwsCredentials awsCredentials, final String defaultContainerName); boolean createContainer(String containerName); void createPublicContainer(String containerName); void deleteContainer(String containerName); void deleteObject(String objectName); void deleteObject(String containerName, String objectName); List<String> listContainerNames(); List<BlobDetails> listContainerObjectDetails(); ContainerStatus checkContainerStatus(String containerName); List<BlobDetails> listContainerObjectDetails(String containerName); String send(String objectName, String stringToSend); String send(String containerName, String objectName, String stringToSend); String send(File fileToSend); String send(String containerName, File fileToSend); String send(String containerName, String objectName, File fileToSend); String send(String objectName, InputStream is); String send(String containerName, String objectName, InputStream is); String sendAndReceiveUrl(String objectName, String stringToSend); String sendAndReceiveUrl(String containerName, String objectName, String stringToSend); String sendAndReceiveUrl(String containerName, String objectName, File fileToSend); String sendAndReceiveUrl(File fileToSend); String sendAndReceiveUrl(String objectName, InputStream is); String sendAndReceiveUrl(String containerName, File fileToSend); String sendAndReceiveUrl(String containerName, String objectName, InputStream is); String receiveAsString(String keyName); String receiveAsString(String containerName, String objectName); String receiveAndSaveToFile(String objectName, File toFile); String receiveAndSaveToFile(String containerName, String objectName, File toFile); InputStream receiveAsInputStream(String objectName); InputStream receiveAsInputStream(String containerName, String objectName); String createdSignedUrl(String containerName, String objectName, Date expiryDate); }
JetS3Template extends S3Template { public ContainerStatus checkContainerStatus(String containerName) { Assert.notNull(containerName, BUCKET_NAME_CANNOT_BE_NULL); LOG.debug("Get bucket '{}' status", containerName); try { int bucketStatus = this.s3Service.checkBucketStatus(containerName); switch (bucketStatus) { case S3Service.BUCKET_STATUS__MY_BUCKET: return ContainerStatus.MINE; case S3Service.BUCKET_STATUS__DOES_NOT_EXIST: return ContainerStatus.DOES_NOT_EXIST; case S3Service.BUCKET_STATUS__ALREADY_CLAIMED: return ContainerStatus.ALREADY_CLAIMED; default: throw new StorageException("Unrecognised bucket status: " + bucketStatus); } } catch (S3ServiceException s3E) { throw new StorageCommunicationException("Failed to get status of bucket name " + containerName, s3E); } catch (ServiceException e) { throw new StorageCommunicationException(SERVICE_PROBLEM, e); } } JetS3Template(final AwsCredentials awsCredentials);  JetS3Template(final AwsCredentials awsCredentials, final String defaultContainerName); boolean createContainer(String containerName); void createPublicContainer(String containerName); void deleteContainer(String containerName); void deleteObject(String objectName); void deleteObject(String containerName, String objectName); List<String> listContainerNames(); List<BlobDetails> listContainerObjectDetails(); ContainerStatus checkContainerStatus(String containerName); List<BlobDetails> listContainerObjectDetails(String containerName); String send(String objectName, String stringToSend); String send(String containerName, String objectName, String stringToSend); String send(File fileToSend); String send(String containerName, File fileToSend); String send(String containerName, String objectName, File fileToSend); String send(String objectName, InputStream is); String send(String containerName, String objectName, InputStream is); String sendAndReceiveUrl(String objectName, String stringToSend); String sendAndReceiveUrl(String containerName, String objectName, String stringToSend); String sendAndReceiveUrl(String containerName, String objectName, File fileToSend); String sendAndReceiveUrl(File fileToSend); String sendAndReceiveUrl(String objectName, InputStream is); String sendAndReceiveUrl(String containerName, File fileToSend); String sendAndReceiveUrl(String containerName, String objectName, InputStream is); String receiveAsString(String keyName); String receiveAsString(String containerName, String objectName); String receiveAndSaveToFile(String objectName, File toFile); String receiveAndSaveToFile(String containerName, String objectName, File toFile); InputStream receiveAsInputStream(String objectName); InputStream receiveAsInputStream(String containerName, String objectName); String createdSignedUrl(String containerName, String objectName, Date expiryDate);  }