From c0d72b6f5316a78695fa4effcdc61946f2c83157 Mon Sep 17 00:00:00 2001 From: Andrew Gaul Date: Mon, 21 Dec 2015 16:52:13 -0800 Subject: [PATCH] JCLOUDS-844: Local blobstore putBlob ACLs --- .../blobstore/config/LocalBlobStore.java | 49 ++++++++++--------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/blobstore/src/main/java/org/jclouds/blobstore/config/LocalBlobStore.java b/blobstore/src/main/java/org/jclouds/blobstore/config/LocalBlobStore.java index 214dd5d320c..06b336763bc 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/config/LocalBlobStore.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/config/LocalBlobStore.java @@ -520,28 +520,7 @@ private static HttpResponseException returnResponseException(int code) { @Override public String putBlob(String containerName, Blob blob) { - checkNotNull(containerName, "containerName must be set"); - checkNotNull(blob, "blob must be set"); - String blobKey = blob.getMetadata().getName(); - - logger.debug("Put blob with key [%s] to container [%s]", blobKey, containerName); - if (!storageStrategy.containerExists(containerName)) { - throw cnfe(containerName); - } - - try { - return storageStrategy.putBlob(containerName, blob); - } catch (IOException e) { - String message = e.getMessage(); - if (message != null && message.startsWith("MD5 hash code mismatch")) { - HttpResponseException exception = returnResponseException(400); - exception.initCause(e); - throw exception; - } - logger.error(e, "An error occurred storing the new blob with name [%s] to container [%s].", blobKey, - containerName); - throw propagate(e); - } + return putBlob(containerName, blob, PutOptions.NONE); } @Override @@ -740,8 +719,30 @@ private boolean deleteAndVerifyContainerGone(final String container) { @Override public String putBlob(String containerName, Blob blob, PutOptions options) { - // TODO implement options - return putBlob(containerName, blob); + checkNotNull(containerName, "containerName must be set"); + checkNotNull(blob, "blob must be set"); + String blobKey = blob.getMetadata().getName(); + + logger.debug("Put blob with key [%s] to container [%s]", blobKey, containerName); + if (!storageStrategy.containerExists(containerName)) { + throw cnfe(containerName); + } + + try { + String eTag = storageStrategy.putBlob(containerName, blob); + setBlobAccess(containerName, blobKey, options.getBlobAccess()); + return eTag; + } catch (IOException e) { + String message = e.getMessage(); + if (message != null && message.startsWith("MD5 hash code mismatch")) { + HttpResponseException exception = returnResponseException(400); + exception.initCause(e); + throw exception; + } + logger.error(e, "An error occurred storing the new blob with name [%s] to container [%s].", blobKey, + containerName); + throw propagate(e); + } } @Override