Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
JCLOUDS-844: Local blobstore putBlob ACLs
  • Loading branch information
gaul committed Dec 22, 2015
1 parent 86491bc commit c0d72b6
Showing 1 changed file with 25 additions and 24 deletions.
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c0d72b6

Please sign in to comment.