code: public String getBucketName(String spaceId) {
          // Determine if there is an existing bucket that matches this space ID.
          // The bucket name may use any access key ID as the prefix, so there is
          // no way to know the exact bucket name up front.
          List<Bucket> buckets = listAllBuckets();
          for (Bucket bucket : buckets) {
              String bucketName = bucket.getName();
              spaceId = spaceId.replace(".", "[.]");
              if (bucketName.matches("(" + HIDDEN_SPACE_PREFIX + ")?[\\w]{20}[.]" + spaceId)) {
                  return bucketName;
              }
          }
          throw new NotFoundException("No S3 bucket found matching spaceID: " + spaceId);
      }
docs: Gets the name of an existing bucket based on a space ID. If no bucket
  with this spaceId exists, throws a NotFoundException
  
  @param spaceId the space Id to convert into an S3 bucket name
  @return S3 bucket name of a given DuraCloud space
  @throws NotFoundException if no bucket matches this spaceID