Skip to content

Commit 55706a1

Browse files
committed
---
yaml --- r: 6279 b: refs/heads/tswast-patch-1 c: f2b6adc h: refs/heads/master i: 6277: 0e9d0bb 6275: 72fdbe0 6271: acae946
1 parent 0f3a436 commit 55706a1

4 files changed

Lines changed: 28 additions & 66 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,5 @@ refs/tags/v0.18.0: 9d193c4c4b9d1c6f21515dd8e50836b9194ec9bb
5757
refs/tags/v0.19.0: e67b56e4d8dad5f9a7b38c9b2107c23c828f2ed5
5858
refs/tags/v0.20.0: 839f7fb7156535146aa1cb2c5aadd8d375d854e8
5959
refs/tags/v0.20.1: 370471f437f1f4f68a11e068df5cd6bf39edb1fa
60-
refs/heads/tswast-patch-1: f1c6b04fe2701dfd9f05ab24dad117db5bf046a0
60+
refs/heads/tswast-patch-1: f2b6adc735e6b96d1ba0422393e0c0c121118764
6161
refs/heads/pubsub-streaming-pull: 19262b752ee874eb2ca3b950eb2aef44d5a5267b

branches/tswast-patch-1/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Blob.java

Lines changed: 24 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -270,26 +270,21 @@ public Storage storage() {
270270
* @param infos the blobs to get
271271
* @return an immutable list of {@code Blob} objects. If a blob does not exist or access to it has
272272
* been denied the corresponding item in the list is {@code null}.
273+
* @throws StorageException upon failure
273274
*/
274275
public static List<Blob> get(final Storage storage, BlobInfo... infos) {
275276
checkNotNull(storage);
276277
checkNotNull(infos);
277-
int length = infos.length;
278-
switch (length) {
279-
case 0:
280-
return Collections.emptyList();
281-
case 1:
282-
return Collections.singletonList(
283-
new Blob(storage, storage.get(infos[0].bucket(), infos[0].name())));
284-
default:
285-
return Collections.unmodifiableList(Lists.transform(storage.get(infos),
286-
new Function<BlobInfo, Blob>() {
287-
@Override
288-
public Blob apply(BlobInfo f) {
289-
return f != null ? new Blob(storage, f) : null;
290-
}
291-
}));
278+
if (infos.length == 0) {
279+
return Collections.emptyList();
292280
}
281+
return Collections.unmodifiableList(Lists.transform(storage.get(infos),
282+
new Function<BlobInfo, Blob>() {
283+
@Override
284+
public Blob apply(BlobInfo f) {
285+
return f != null ? new Blob(storage, f) : null;
286+
}
287+
}));
293288
}
294289

295290
/**
@@ -300,25 +295,21 @@ public Blob apply(BlobInfo f) {
300295
* @param infos the blobs to update
301296
* @return an immutable list of {@code Blob} objects. If a blob does not exist or access to it has
302297
* been denied the corresponding item in the list is {@code null}.
298+
* @throws StorageException upon failure
303299
*/
304300
public static List<Blob> update(final Storage storage, BlobInfo... infos) {
305301
checkNotNull(storage);
306302
checkNotNull(infos);
307-
int length = infos.length;
308-
switch (length) {
309-
case 0:
310-
return Collections.emptyList();
311-
case 1:
312-
return Collections.singletonList(new Blob(storage, storage.update(infos[0])));
313-
default:
314-
return Collections.unmodifiableList(Lists.transform(storage.update(infos),
315-
new Function<BlobInfo, Blob>() {
316-
@Override
317-
public Blob apply(BlobInfo f) {
318-
return f != null ? new Blob(storage, f) : null;
319-
}
320-
}));
303+
if (infos.length == 0) {
304+
return Collections.emptyList();
321305
}
306+
return Collections.unmodifiableList(Lists.transform(storage.update(infos),
307+
new Function<BlobInfo, Blob>() {
308+
@Override
309+
public Blob apply(BlobInfo f) {
310+
return f != null ? new Blob(storage, f) : null;
311+
}
312+
}));
322313
}
323314

324315
/**
@@ -330,18 +321,14 @@ public Blob apply(BlobInfo f) {
330321
* @return an immutable list of booleans. If a blob has been deleted the corresponding item in the
331322
* list is {@code true}. If deletion failed or access to the resource was denied the item is
332323
* {@code false}.
324+
* @throws StorageException upon failure
333325
*/
334326
public static List<Boolean> delete(Storage storage, BlobInfo... infos) {
335327
checkNotNull(storage);
336328
checkNotNull(infos);
337-
int length = infos.length;
338-
switch (length) {
339-
case 0:
340-
return Collections.emptyList();
341-
case 1:
342-
return Collections.singletonList(storage.delete(infos[0].bucket(), infos[0].name()));
343-
default:
344-
return Collections.unmodifiableList(storage.delete(infos));
329+
if (infos.length == 0) {
330+
return Collections.emptyList();
345331
}
332+
return storage.delete(infos);
346333
}
347334
}

branches/tswast-patch-1/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,7 @@ public static Builder builder() {
653653
* @param blobInfos blobs to get
654654
* @return an immutable list of {@code BlobInfo} objects. If a blob does not exist or access to it
655655
* has been denied the corresponding item in the list is {@code null}.
656+
* @throws StorageException upon failure
656657
*/
657658
List<BlobInfo> get(BlobInfo... blobInfos);
658659

@@ -662,6 +663,7 @@ public static Builder builder() {
662663
* @param blobInfos blobs to update
663664
* @return an immutable list of {@code BlobInfo} objects. If a blob does not exist or access to it
664665
* has been denied the corresponding item in the list is {@code null}.
666+
* @throws StorageException upon failure
665667
*/
666668
List<BlobInfo> update(BlobInfo... blobInfos);
667669

@@ -672,6 +674,7 @@ public static Builder builder() {
672674
* @return an immutable list of booleans. If a blob has been deleted the corresponding item in the
673675
* list is {@code true}. If deletion failed or access to the resource was denied the item is
674676
* {@code false}.
677+
* @throws StorageException upon failure
675678
*/
676679
List<Boolean> delete(BlobInfo... blobInfos);
677680
}

branches/tswast-patch-1/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BlobTest.java

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -172,15 +172,6 @@ public void testGetNone() throws Exception {
172172
assertTrue(Blob.get(storage).isEmpty());
173173
}
174174

175-
@Test
176-
public void testGetOne() throws Exception {
177-
expect(storage.get(BLOB_INFO.bucket(), BLOB_INFO.name())).andReturn(BLOB_INFO);
178-
replay(storage);
179-
List<Blob> result = Blob.get(storage, BLOB_INFO);
180-
assertEquals(1, result.size());
181-
assertEquals(BLOB_INFO, result.get(0).info());
182-
}
183-
184175
@Test
185176
public void testGetSome() throws Exception {
186177
List<BlobInfo> blobInfoList = Arrays.asList(BLOB_INFO_ARRAY);
@@ -215,16 +206,6 @@ public void testUpdateNone() throws Exception {
215206
assertTrue(Blob.update(storage).isEmpty());
216207
}
217208

218-
@Test
219-
public void testUpdateOne() throws Exception {
220-
BlobInfo updatedBlob = BLOB_INFO.toBuilder().contentType("content").build();
221-
expect(storage.update(BLOB_INFO)).andReturn(updatedBlob);
222-
replay(storage);
223-
List<Blob> result = Blob.update(storage, BLOB_INFO);
224-
assertEquals(1, result.size());
225-
assertEquals(updatedBlob, result.get(0).info());
226-
}
227-
228209
@Test
229210
public void testUpdateSome() throws Exception {
230211
List<BlobInfo> blobInfoList = Lists.newArrayListWithCapacity(BLOB_INFO_ARRAY.length);
@@ -264,15 +245,6 @@ public void testDeleteNone() throws Exception {
264245
assertTrue(Blob.delete(storage).isEmpty());
265246
}
266247

267-
@Test
268-
public void testDeleteOne() throws Exception {
269-
expect(storage.delete(BLOB_INFO.bucket(), BLOB_INFO.name())).andReturn(true);
270-
replay(storage);
271-
List<Boolean> result = Blob.delete(storage, BLOB_INFO);
272-
assertEquals(1, result.size());
273-
assertTrue(result.get(0));
274-
}
275-
276248
@Test
277249
public void testDeleteSome() throws Exception {
278250
List<Boolean> deleleResultList = Arrays.asList(true, true, true);

0 commit comments

Comments
 (0)