@@ -138,8 +138,8 @@ CloudBlobClient getSelectedClient(String account, LocationMode mode) {
138138 public boolean doesContainerExist (String account , LocationMode mode , String container ) {
139139 try {
140140 CloudBlobClient client = this .getSelectedClient (account , mode );
141- CloudBlobContainer blob_container = client .getContainerReference (container );
142- return blob_container .exists ();
141+ CloudBlobContainer blobContainer = client .getContainerReference (container );
142+ return blobContainer .exists ();
143143 } catch (Exception e ) {
144144 logger .error ("can not access container [{}]" , container );
145145 }
@@ -149,25 +149,25 @@ public boolean doesContainerExist(String account, LocationMode mode, String cont
149149 @ Override
150150 public void removeContainer (String account , LocationMode mode , String container ) throws URISyntaxException , StorageException {
151151 CloudBlobClient client = this .getSelectedClient (account , mode );
152- CloudBlobContainer blob_container = client .getContainerReference (container );
152+ CloudBlobContainer blobContainer = client .getContainerReference (container );
153153 // TODO Should we set some timeout and retry options?
154154 /*
155155 BlobRequestOptions options = new BlobRequestOptions();
156156 options.setTimeoutIntervalInMs(1000);
157157 options.setRetryPolicyFactory(new RetryNoRetry());
158- blob_container .deleteIfExists(options, null);
158+ blobContainer .deleteIfExists(options, null);
159159 */
160160 logger .trace ("removing container [{}]" , container );
161- blob_container .deleteIfExists ();
161+ blobContainer .deleteIfExists ();
162162 }
163163
164164 @ Override
165165 public void createContainer (String account , LocationMode mode , String container ) throws URISyntaxException , StorageException {
166166 try {
167167 CloudBlobClient client = this .getSelectedClient (account , mode );
168- CloudBlobContainer blob_container = client .getContainerReference (container );
168+ CloudBlobContainer blobContainer = client .getContainerReference (container );
169169 logger .trace ("creating container [{}]" , container );
170- blob_container .createIfNotExists ();
170+ blobContainer .createIfNotExists ();
171171 } catch (IllegalArgumentException e ) {
172172 logger .trace ("fails creating container [{}]" , e , container );
173173 throw new RepositoryException (container , e .getMessage ());
@@ -180,10 +180,10 @@ public void deleteFiles(String account, LocationMode mode, String container, Str
180180
181181 // Container name must be lower case.
182182 CloudBlobClient client = this .getSelectedClient (account , mode );
183- CloudBlobContainer blob_container = client .getContainerReference (container );
184- if (blob_container .exists ()) {
183+ CloudBlobContainer blobContainer = client .getContainerReference (container );
184+ if (blobContainer .exists ()) {
185185 // We list the blobs using a flat blob listing mode
186- for (ListBlobItem blobItem : blob_container .listBlobs (path , true )) {
186+ for (ListBlobItem blobItem : blobContainer .listBlobs (path , true )) {
187187 String blobName = blobNameFromUri (blobItem .getUri ());
188188 logger .trace ("removing blob [{}] full URI was [{}]" , blobName , blobItem .getUri ());
189189 deleteBlob (account , mode , container , blobName );
@@ -201,9 +201,10 @@ public static String blobNameFromUri(URI uri) {
201201 String path = uri .getPath ();
202202
203203 // We remove the container name from the path
204- // The 3 magic number cames from the fact we have // in the first part of the URI (protocol)
205- // Then a / after the server address
206- // And we finally split after the container/
204+ // The 3 magic number cames from the fact if path is /container/path/to/myfile
205+ // First occurrence is empty "/"
206+ // Second occurrence is "container
207+ // Last part contains "path/to/myfile" which is what we want to get
207208 String [] splits = path .split ("/" , 3 );
208209
209210 // We return the remaining end of the string
@@ -214,9 +215,9 @@ public static String blobNameFromUri(URI uri) {
214215 public boolean blobExists (String account , LocationMode mode , String container , String blob ) throws URISyntaxException , StorageException {
215216 // Container name must be lower case.
216217 CloudBlobClient client = this .getSelectedClient (account , mode );
217- CloudBlobContainer blob_container = client .getContainerReference (container );
218- if (blob_container .exists ()) {
219- CloudBlockBlob azureBlob = blob_container .getBlockBlobReference (blob );
218+ CloudBlobContainer blobContainer = client .getContainerReference (container );
219+ if (blobContainer .exists ()) {
220+ CloudBlockBlob azureBlob = blobContainer .getBlockBlobReference (blob );
220221 return azureBlob .exists ();
221222 }
222223
@@ -229,10 +230,10 @@ public void deleteBlob(String account, LocationMode mode, String container, Stri
229230
230231 // Container name must be lower case.
231232 CloudBlobClient client = this .getSelectedClient (account , mode );
232- CloudBlobContainer blob_container = client .getContainerReference (container );
233- if (blob_container .exists ()) {
233+ CloudBlobContainer blobContainer = client .getContainerReference (container );
234+ if (blobContainer .exists ()) {
234235 logger .trace ("container [{}]: blob [{}] found. removing." , container , blob );
235- CloudBlockBlob azureBlob = blob_container .getBlockBlobReference (blob );
236+ CloudBlockBlob azureBlob = blobContainer .getBlockBlobReference (blob );
236237 azureBlob .delete ();
237238 }
238239 }
@@ -292,10 +293,10 @@ public void moveBlob(String account, LocationMode mode, String container, String
292293 logger .debug ("moveBlob container [{}], sourceBlob [{}], targetBlob [{}]" , container , sourceBlob , targetBlob );
293294
294295 CloudBlobClient client = this .getSelectedClient (account , mode );
295- CloudBlobContainer blob_container = client .getContainerReference (container );
296- CloudBlockBlob blobSource = blob_container .getBlockBlobReference (sourceBlob );
296+ CloudBlobContainer blobContainer = client .getContainerReference (container );
297+ CloudBlockBlob blobSource = blobContainer .getBlockBlobReference (sourceBlob );
297298 if (blobSource .exists ()) {
298- CloudBlockBlob blobTarget = blob_container .getBlockBlobReference (targetBlob );
299+ CloudBlockBlob blobTarget = blobContainer .getBlockBlobReference (targetBlob );
299300 blobTarget .startCopy (blobSource );
300301 blobSource .delete ();
301302 logger .debug ("moveBlob container [{}], sourceBlob [{}], targetBlob [{}] -> done" , container , sourceBlob , targetBlob );
0 commit comments