Fix comment and rename blob_container to blobContainer

This commit is contained in:
David Pilato 2016-05-25 11:02:11 +02:00
parent fd602cc037
commit c4d3bf472b
1 changed files with 23 additions and 22 deletions

View File

@ -138,8 +138,8 @@ public class AzureStorageServiceImpl extends AbstractLifecycleComponent<AzureSto
public boolean doesContainerExist(String account, LocationMode mode, String container) {
try {
CloudBlobClient client = this.getSelectedClient(account, mode);
CloudBlobContainer blob_container = client.getContainerReference(container);
return blob_container.exists();
CloudBlobContainer blobContainer = client.getContainerReference(container);
return blobContainer.exists();
} catch (Exception e) {
logger.error("can not access container [{}]", container);
}
@ -149,25 +149,25 @@ public class AzureStorageServiceImpl extends AbstractLifecycleComponent<AzureSto
@Override
public void removeContainer(String account, LocationMode mode, String container) throws URISyntaxException, StorageException {
CloudBlobClient client = this.getSelectedClient(account, mode);
CloudBlobContainer blob_container = client.getContainerReference(container);
CloudBlobContainer blobContainer = client.getContainerReference(container);
// TODO Should we set some timeout and retry options?
/*
BlobRequestOptions options = new BlobRequestOptions();
options.setTimeoutIntervalInMs(1000);
options.setRetryPolicyFactory(new RetryNoRetry());
blob_container.deleteIfExists(options, null);
blobContainer.deleteIfExists(options, null);
*/
logger.trace("removing container [{}]", container);
blob_container.deleteIfExists();
blobContainer.deleteIfExists();
}
@Override
public void createContainer(String account, LocationMode mode, String container) throws URISyntaxException, StorageException {
try {
CloudBlobClient client = this.getSelectedClient(account, mode);
CloudBlobContainer blob_container = client.getContainerReference(container);
CloudBlobContainer blobContainer = client.getContainerReference(container);
logger.trace("creating container [{}]", container);
blob_container.createIfNotExists();
blobContainer.createIfNotExists();
} catch (IllegalArgumentException e) {
logger.trace("fails creating container [{}]", e, container);
throw new RepositoryException(container, e.getMessage());
@ -180,10 +180,10 @@ public class AzureStorageServiceImpl extends AbstractLifecycleComponent<AzureSto
// Container name must be lower case.
CloudBlobClient client = this.getSelectedClient(account, mode);
CloudBlobContainer blob_container = client.getContainerReference(container);
if (blob_container.exists()) {
CloudBlobContainer blobContainer = client.getContainerReference(container);
if (blobContainer.exists()) {
// We list the blobs using a flat blob listing mode
for (ListBlobItem blobItem : blob_container.listBlobs(path, true)) {
for (ListBlobItem blobItem : blobContainer.listBlobs(path, true)) {
String blobName = blobNameFromUri(blobItem.getUri());
logger.trace("removing blob [{}] full URI was [{}]", blobName, blobItem.getUri());
deleteBlob(account, mode, container, blobName);
@ -201,9 +201,10 @@ public class AzureStorageServiceImpl extends AbstractLifecycleComponent<AzureSto
String path = uri.getPath();
// We remove the container name from the path
// The 3 magic number cames from the fact we have // in the first part of the URI (protocol)
// Then a / after the server address
// And we finally split after the container/
// The 3 magic number cames from the fact if path is /container/path/to/myfile
// First occurrence is empty "/"
// Second occurrence is "container
// Last part contains "path/to/myfile" which is what we want to get
String[] splits = path.split("/", 3);
// We return the remaining end of the string
@ -214,9 +215,9 @@ public class AzureStorageServiceImpl extends AbstractLifecycleComponent<AzureSto
public boolean blobExists(String account, LocationMode mode, String container, String blob) throws URISyntaxException, StorageException {
// Container name must be lower case.
CloudBlobClient client = this.getSelectedClient(account, mode);
CloudBlobContainer blob_container = client.getContainerReference(container);
if (blob_container.exists()) {
CloudBlockBlob azureBlob = blob_container.getBlockBlobReference(blob);
CloudBlobContainer blobContainer = client.getContainerReference(container);
if (blobContainer.exists()) {
CloudBlockBlob azureBlob = blobContainer.getBlockBlobReference(blob);
return azureBlob.exists();
}
@ -229,10 +230,10 @@ public class AzureStorageServiceImpl extends AbstractLifecycleComponent<AzureSto
// Container name must be lower case.
CloudBlobClient client = this.getSelectedClient(account, mode);
CloudBlobContainer blob_container = client.getContainerReference(container);
if (blob_container.exists()) {
CloudBlobContainer blobContainer = client.getContainerReference(container);
if (blobContainer.exists()) {
logger.trace("container [{}]: blob [{}] found. removing.", container, blob);
CloudBlockBlob azureBlob = blob_container.getBlockBlobReference(blob);
CloudBlockBlob azureBlob = blobContainer.getBlockBlobReference(blob);
azureBlob.delete();
}
}
@ -292,10 +293,10 @@ public class AzureStorageServiceImpl extends AbstractLifecycleComponent<AzureSto
logger.debug("moveBlob container [{}], sourceBlob [{}], targetBlob [{}]", container, sourceBlob, targetBlob);
CloudBlobClient client = this.getSelectedClient(account, mode);
CloudBlobContainer blob_container = client.getContainerReference(container);
CloudBlockBlob blobSource = blob_container.getBlockBlobReference(sourceBlob);
CloudBlobContainer blobContainer = client.getContainerReference(container);
CloudBlockBlob blobSource = blobContainer.getBlockBlobReference(sourceBlob);
if (blobSource.exists()) {
CloudBlockBlob blobTarget = blob_container.getBlockBlobReference(targetBlob);
CloudBlockBlob blobTarget = blobContainer.getBlockBlobReference(targetBlob);
blobTarget.startCopy(blobSource);
blobSource.delete();
logger.debug("moveBlob container [{}], sourceBlob [{}], targetBlob [{}] -> done", container, sourceBlob, targetBlob);