Skip to content

Commit 258fad6

Browse files
committed
---
yaml --- r: 1763 b: refs/heads/master c: de9b0d6 h: refs/heads/master i: 1761: da25b58 1759: 041a30e
1 parent bf59744 commit 258fad6

5 files changed

Lines changed: 30 additions & 29 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: d930b4bbc2833d82ce84c13e3c6704695aebd91c
2+
refs/heads/master: de9b0d60eee8079223feb6f1f30b069e91e67431
33
refs/heads/travis: e21ee7b88a5edc3f3d8c71f90c3fc32abf7e8dd6
44
refs/heads/gh-pages: d1b373c30c176edc08692348167bec3a244bb823
55
refs/heads/bigquery: 762fa5830e6c398c0396177e3e7fd243bd62cfc3

trunk/gcloud-java-storage/src/main/java/com/google/gcloud/spi/DefaultStorageRpc.java

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
package com.google.gcloud.spi;
1616

17+
import static com.google.common.base.MoreObjects.firstNonNull;
1718
import static com.google.gcloud.spi.StorageRpc.Option.DELIMITER;
1819
import static com.google.gcloud.spi.StorageRpc.Option.FIELDS;
1920
import static com.google.gcloud.spi.StorageRpc.Option.IF_GENERATION_MATCH;
@@ -58,7 +59,6 @@
5859
import com.google.api.services.storage.model.Objects;
5960
import com.google.api.services.storage.model.StorageObject;
6061
import com.google.common.base.Function;
61-
import com.google.common.base.MoreObjects;
6262
import com.google.common.collect.ImmutableList;
6363
import com.google.common.collect.Iterables;
6464
import com.google.common.collect.Lists;
@@ -167,24 +167,29 @@ public Tuple<String, Iterable<StorageObject>> list(final String bucket, Map<Opti
167167
.setFields(FIELDS.getString(options))
168168
.execute();
169169
Iterable<StorageObject> storageObjects = Iterables.concat(
170-
objects.getItems() != null ? objects.getItems() : ImmutableList.<StorageObject>of(),
170+
firstNonNull(objects.getItems(), ImmutableList.<StorageObject>of()),
171171
objects.getPrefixes() != null
172-
? Lists.transform(objects.getPrefixes(), new Function<String, StorageObject>() {
173-
@Override
174-
public StorageObject apply(String prefix) {
175-
return new StorageObject()
176-
.set("isDirectory", true)
177-
.setBucket(bucket)
178-
.setName(prefix)
179-
.setSize(BigInteger.ZERO);
180-
}
181-
}) : ImmutableList.<StorageObject>of());
172+
? Lists.transform(objects.getPrefixes(), objectFromPrefix(bucket))
173+
: ImmutableList.<StorageObject>of());
182174
return Tuple.of(objects.getNextPageToken(), storageObjects);
183175
} catch (IOException ex) {
184176
throw translate(ex);
185177
}
186178
}
187179

180+
private static Function<String, StorageObject> objectFromPrefix(final String bucket) {
181+
return new Function<String, StorageObject>() {
182+
@Override
183+
public StorageObject apply(String prefix) {
184+
return new StorageObject()
185+
.set("isDirectory", true)
186+
.setBucket(bucket)
187+
.setName(prefix)
188+
.setSize(BigInteger.ZERO);
189+
}
190+
};
191+
}
192+
188193
@Override
189194
public Bucket get(Bucket bucket, Map<Option, ?> options) {
190195
try {
@@ -549,7 +554,7 @@ public String open(StorageObject object, Map<Option, ?> options) {
549554
HttpRequest httpRequest =
550555
requestFactory.buildPostRequest(url, new JsonHttpContent(jsonFactory, object));
551556
httpRequest.getHeaders().set("X-Upload-Content-Type",
552-
MoreObjects.firstNonNull(object.getContentType(), "application/octet-stream"));
557+
firstNonNull(object.getContentType(), "application/octet-stream"));
553558
HttpResponse response = httpRequest.execute();
554559
if (response.getStatusCode() != 200) {
555560
GoogleJsonError error = new GoogleJsonError();

trunk/gcloud-java-storage/src/main/java/com/google/gcloud/storage/BlobInfo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ public Long updateTime() {
603603
/**
604604
* Returns {@code true} if the current blob represents a directory. This can only happen if the
605605
* blob is returned by {@link Storage#list(String, Storage.BlobListOption...)} when the
606-
* {@link Storage.BlobListOption#currentDirectory()} option is used. If {@code true} only
606+
* {@link Storage.BlobListOption#currentDirectory()} option is used. When this is the case only
607607
* {@link #blobId()} and {@link #size()} are set for the current blob: {@link BlobId#name()} ends
608608
* with the '/' character, {@link BlobId#generation()} returns {@code null} and {@link #size()} is
609609
* {@code 0}.
@@ -785,7 +785,7 @@ public Acl apply(ObjectAccessControl objectAccessControl) {
785785
}
786786
}));
787787
}
788-
if (storageObject.get("isDirectory") != null) {
788+
if (storageObject.containsKey("isDirectory")) {
789789
builder.isDirectory(Boolean.TRUE);
790790
}
791791
return builder.build();

trunk/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -694,14 +694,14 @@ public static BlobListOption prefix(String prefix) {
694694
}
695695

696696
/**
697-
* If specified, results are returned in a directory-like mode. Blobs whose names, aside from
698-
* a possible {@link #prefix(String)}, do not contain the '/' delimiter are returned as is.
699-
* Blobs whose names, aside from a possible {@link #prefix(String)}, contain the '/' delimiter,
700-
* will have their name truncated after the delimiter and will be returned as {@link Blob}
701-
* objects where only {@link Blob#blobId()}, {@link Blob#size()} and {@link Blob#isDirectory()}
702-
* are set. For such directory blobs, ({@link BlobId#generation()} returns {@code null}),
703-
* {@link Blob#size()} returns {@code 0} while {@link Blob#isDirectory()} returns {@code true}.
704-
* Duplicate directory blobs are omitted.
697+
* If specified, results are returned in a directory-like mode. Blobs whose names, after a
698+
* possible {@link #prefix(String)}, do not contain the '/' delimiter are returned as is. Blobs
699+
* whose names, after a possible {@link #prefix(String)}, contain the '/' delimiter, will have
700+
* their name truncated after the delimiter and will be returned as {@link Blob} objects where
701+
* only {@link Blob#blobId()}, {@link Blob#size()} and {@link Blob#isDirectory()} are set. For
702+
* such directory blobs, ({@link BlobId#generation()} returns {@code null}), {@link Blob#size()}
703+
* returns {@code 0} while {@link Blob#isDirectory()} returns {@code true}. Duplicate directory
704+
* blobs are omitted.
705705
*/
706706
public static BlobListOption currentDirectory() {
707707
return new BlobListOption(StorageRpc.Option.DELIMITER, true);

trunk/gcloud-java-storage/src/main/java/com/google/gcloud/storage/StorageOptions.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,7 @@ public int hashCode() {
106106

107107
@Override
108108
public boolean equals(Object obj) {
109-
if (!(obj instanceof StorageOptions)) {
110-
return false;
111-
}
112-
StorageOptions other = (StorageOptions) obj;
113-
return baseEquals(other);
109+
return obj instanceof StorageOptions && baseEquals((StorageOptions) obj);
114110
}
115111

116112
public static Builder builder() {

0 commit comments

Comments
 (0)