Skip to content

Commit a82ea68

Browse files
committed
---
yaml --- r: 5963 b: refs/heads/tswast-patch-1 c: a24c7bc h: refs/heads/master i: 5961: 5c0f246 5959: 58faa98
1 parent d79393c commit a82ea68

4 files changed

Lines changed: 32 additions & 16 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: ef0936177fc1df181e79e83f18a252894c6b0878
60+
refs/heads/tswast-patch-1: a24c7bc15e30ce37dd47936e409df9a519cbd923
6161
refs/heads/pubsub-streaming-pull: 19262b752ee874eb2ca3b950eb2aef44d5a5267b

branches/tswast-patch-1/src/main/java/com/google/gcloud/examples/StorageExample.java

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@
1818

1919
import com.google.gcloud.spi.StorageRpc.Tuple;
2020
import com.google.gcloud.storage.BatchRequest;
21+
import com.google.gcloud.storage.BatchResponse;
2122
import com.google.gcloud.storage.Blob;
2223
import com.google.gcloud.storage.Bucket;
2324
import com.google.gcloud.storage.StorageService;
24-
import com.google.gcloud.storage.StorageService.CopyRequest;
2525
import com.google.gcloud.storage.StorageService.ComposeRequest;
26+
import com.google.gcloud.storage.StorageService.CopyRequest;
2627
import com.google.gcloud.storage.StorageServiceFactory;
2728
import com.google.gcloud.storage.StorageServiceOptions;
2829

@@ -102,43 +103,51 @@ public String params() {
102103
}
103104
}
104105

105-
private static class InfoAction extends BlobAction {
106+
private static class InfoAction extends BlobsAction {
106107
@Override
107-
public void run(StorageService storage, Blob blob) {
108-
if (blob.name().isEmpty()) {
109-
System.out.println(storage.get(Bucket.of(blob.bucket())));
108+
public void run(StorageService storage, Blob... blobs) {
109+
if (blobs.length == 1) {
110+
if (blobs[0].name().isEmpty()) {
111+
System.out.println(storage.get(Bucket.of(blobs[0].bucket())));
112+
} else {
113+
System.out.println(storage.get(blobs[0]));
114+
}
110115
} else {
111-
System.out.println(storage.get(blob));
116+
BatchRequest.Builder batch = BatchRequest.builder();
117+
for (Blob blob : blobs) {
118+
batch.get(blob);
119+
}
120+
BatchResponse response = storage.apply(batch.build());
121+
System.out.println(response.gets());
112122
}
113123
}
114124

115125
@Override
116-
Blob parse(String... args) {
126+
Blob[] parse(String... args) {
117127
if (args.length < 2) {
118-
return Blob.of(args[0], "");
128+
return new Blob[] {Blob.of(args[0], "")};
119129
}
120130
return super.parse(args);
121131
}
122132

123133
@Override
124134
public String params() {
125-
return "<bucket> [<path>]";
135+
return "<bucket> [<path>+]";
126136
}
127137
}
128138

129139
private static class DeleteAction extends BlobsAction {
130140
@Override
131141
public void run(StorageService storage, Blob... blobs) {
132142
if (blobs.length == 1) {
133-
System.out.println("Calling delete");
134143
System.out.println(storage.delete(blobs[0]));
135144
} else {
136145
BatchRequest.Builder batch = BatchRequest.builder();
137146
for (Blob blob : blobs) {
138147
batch.delete(blob);
139148
}
140-
System.out.println("Calling batch.delete");
141-
storage.apply(batch.build());
149+
BatchResponse response = storage.apply(batch.build());
150+
System.out.println(response.deletes());
142151
}
143152
}
144153
}

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ public class BatchRequest implements Serializable {
3131

3232
private static final long serialVersionUID = -1527992265939800345L;
3333

34-
private Map<Blob, BlobSourceOption[]> toDelete;
35-
private Map<Blob, BlobTargetOption[]> toUpdate;
36-
private Map<Blob, BlobSourceOption[]> toGet;
34+
private final Map<Blob, BlobSourceOption[]> toDelete;
35+
private final Map<Blob, BlobTargetOption[]> toUpdate;
36+
private final Map<Blob, BlobSourceOption[]> toGet;
3737

3838
public static class Builder {
3939

@@ -63,6 +63,7 @@ public BatchRequest build() {
6363
private BatchRequest(Builder builder) {
6464
toDelete = ImmutableMap.copyOf(builder.toDelete);
6565
toUpdate = ImmutableMap.copyOf(builder.toUpdate);
66+
toGet = ImmutableMap.copyOf(builder.toGet);
6667
}
6768

6869
public Map<Blob, BlobSourceOption[]> toDelete() {

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.google.gcloud.storage;
1818

19+
import com.google.common.base.MoreObjects;
1920
import com.google.common.collect.ImmutableList;
2021

2122
import java.io.Serializable;
@@ -70,6 +71,11 @@ public StorageServiceException failure() {
7071
public boolean failed() {
7172
return exception != null;
7273
}
74+
75+
@Override
76+
public String toString() {
77+
return MoreObjects.firstNonNull(value, exception).toString();
78+
}
7379
}
7480

7581
BatchResponse(List<Result<Boolean>> deleteResult, List<Result<Blob>> updateResult,

0 commit comments

Comments
 (0)