Skip to content

Commit 72bb3ee

Browse files
committed
Merge pull request #48 from aozarov/master
change source options and some docs
2 parents 1f6cefe + 92c6df8 commit 72bb3ee

File tree

7 files changed

+212
-101
lines changed

7 files changed

+212
-101
lines changed

src/main/java/com/google/gcloud/examples/StorageExample.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,14 @@ private static class InfoAction extends BlobsAction {
117117
public void run(StorageService storage, Blob... blobs) {
118118
if (blobs.length == 1) {
119119
if (blobs[0].name().isEmpty()) {
120-
System.out.println(storage.get(Bucket.of(blobs[0].bucket())));
120+
System.out.println(storage.get(blobs[0].bucket()));
121121
} else {
122-
System.out.println(storage.get(blobs[0]));
122+
System.out.println(storage.get(blobs[0].bucket(), blobs[0].name()));
123123
}
124124
} else {
125125
BatchRequest.Builder batch = BatchRequest.builder();
126126
for (Blob blob : blobs) {
127-
batch.get(blob);
127+
batch.get(blob.bucket(), blob.name());
128128
}
129129
BatchResponse response = storage.apply(batch.build());
130130
System.out.println(response.gets());
@@ -149,11 +149,11 @@ private static class DeleteAction extends BlobsAction {
149149
@Override
150150
public void run(StorageService storage, Blob... blobs) {
151151
if (blobs.length == 1) {
152-
System.out.println(storage.delete(blobs[0]));
152+
System.out.println(storage.delete(blobs[0].bucket(), blobs[0].name()));
153153
} else {
154154
BatchRequest.Builder batch = BatchRequest.builder();
155155
for (Blob blob : blobs) {
156-
batch.delete(blob);
156+
batch.delete(blob.bucket(), blob.name());
157157
}
158158
BatchResponse response = storage.apply(batch.build());
159159
System.out.println(response.deletes());
@@ -236,7 +236,7 @@ private static class DownloadAction extends StorageAction<Tuple<Blob, Path>> {
236236

237237
@Override
238238
public void run(StorageService storage, Tuple<Blob, Path> tuple) throws IOException {
239-
Blob blob = storage.get(tuple.x());
239+
Blob blob = storage.get(tuple.x().bucket(), tuple.x().name());
240240
if (blob == null) {
241241
System.out.println("No such object");
242242
return;
@@ -246,9 +246,9 @@ public void run(StorageService storage, Tuple<Blob, Path> tuple) throws IOExcept
246246
writeTo = new PrintStream(new FileOutputStream(tuple.y().toFile()));
247247
}
248248
if (blob.size() < 1024) {
249-
writeTo.write(storage.load(blob));
249+
writeTo.write(storage.load(blob.bucket(), blob.name()));
250250
} else {
251-
try (BlobReadChannel reader = storage.reader(blob)) {
251+
try (BlobReadChannel reader = storage.reader(blob.bucket(), blob.name())) {
252252
WritableByteChannel channel = Channels.newChannel(writeTo);
253253
ByteBuffer bytes = ByteBuffer.allocate(64 * 1024);
254254
while (reader.read(bytes) > 0) {
@@ -299,7 +299,7 @@ CopyRequest parse(String... args) {
299299
if (args.length != 4) {
300300
throw new IllegalArgumentException();
301301
}
302-
return CopyRequest.of(Blob.of(args[0], args[1]), Blob.of(args[2], args[3]));
302+
return CopyRequest.of(args[0], args[1], Blob.of(args[2], args[3]));
303303
}
304304

305305
@Override

src/main/java/com/google/gcloud/storage/BatchRequest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ private Builder() {}
4646
/**
4747
* Delete the given blob.
4848
*/
49-
public void delete(Blob blob, BlobSourceOption... options) {
50-
toDelete.put(blob, options);
49+
public void delete(String bucket, String blob, BlobSourceOption... options) {
50+
toDelete.put(Blob.of(bucket, blob), options);
5151
}
5252

5353
/**
@@ -60,8 +60,8 @@ public void update(Blob blob, BlobTargetOption... options) {
6060
/**
6161
* Retrieve metadata for the given blob.
6262
*/
63-
public void get(Blob blob, BlobSourceOption... options) {
64-
toGet.put(blob, options);
63+
public void get(String bucket, String blob, BlobSourceOption... options) {
64+
toGet.put(Blob.of(bucket, blob), options);
6565
}
6666

6767
public BatchRequest build() {

src/main/java/com/google/gcloud/storage/BatchResponse.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@
2727
*/
2828
public class BatchResponse implements Serializable {
2929

30-
private List<Result<Boolean>> deleteResult;
31-
private List<Result<Blob>> updateResult;
32-
private List<Result<Blob>> getResult;
30+
private static final long serialVersionUID = 1057416839397037706L;
31+
32+
private final List<Result<Boolean>> deleteResult;
33+
private final List<Result<Blob>> updateResult;
34+
private final List<Result<Blob>> getResult;
3335

3436
public static class Result<T extends Serializable> implements Serializable {
3537

src/main/java/com/google/gcloud/storage/Option.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Option implements Serializable {
3636

3737
Option(StorageRpc.Option rpcOption, Object value) {
3838
this.rpcOption = checkNotNull(rpcOption);
39-
this.value = checkNotNull(value);
39+
this.value = value;
4040
}
4141

4242
StorageRpc.Option rpcOption() {

0 commit comments

Comments
 (0)