Skip to content

Commit c138bf0

Browse files
Move gcloud->cloud (issue #877) and update version number
1 parent 5644d92 commit c138bf0

File tree

44 files changed

+222
-259
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+222
-259
lines changed

gcloud-java-contrib/gcloud-java-nio-examples/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ To run this example:
2222
4. Run the sample with:
2323
2424
```
25-
java -cp gcloud-java-contrib/gcloud-java-nio/target/gcloud-java-nio-0.1.6-SNAPSHOT-shaded.jar:gcloud-java-contrib/gcloud-java-nio-examples/target/gcloud-java-nio-examples-0.1.6-SNAPSHOT.jar com.google.gcloud.nio.examples.ListFilesystems
25+
java -cp gcloud-java-contrib/gcloud-java-nio/target/gcloud-java-nio-0.2.1-SNAPSHOT-shaded.jar:gcloud-java-contrib/gcloud-java-nio-examples/target/gcloud-java-nio-examples-0.2.1-SNAPSHOT.jar com.google.cloud.nio.examples.ListFilesystems
2626
```
2727
2828
Notice that it lists gcs, which it wouldn't if you ran it without the nio jar:
2929
```
30-
java -cp gcloud-java-contrib/gcloud-java-nio-examples/target/gcloud-java-nio-examples-0.1.6-SNAPSHOT.jar com.google.gcloud.nio.examples.ListFilesystems
30+
java -cp gcloud-java-contrib/gcloud-java-nio-examples/target/gcloud-java-nio-examples-0.2.1-SNAPSHOT.jar com.google.cloud.nio.examples.ListFilesystems
3131
```
3232
3333
The sample doesn't have anything about GCS in it. It gets that ability from the nio jar that

gcloud-java-contrib/gcloud-java-nio-examples/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
Demonstrates how to use the gcloud-java-nio jar to add GCS functionality to legacy code.
1010
</description>
1111
<parent>
12-
<groupId>com.google.gcloud</groupId>
12+
<groupId>com.google.cloud</groupId>
1313
<artifactId>gcloud-java-contrib</artifactId>
14-
<version>0.1.6-SNAPSHOT</version>
14+
<version>0.2.1-SNAPSHOT</version>
1515
</parent>
1616
<properties>
1717
<site.installationModule>nio</site.installationModule>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.google.gcloud.nio.examples;
17+
package com.google.cloud.nio.examples;
1818

1919
import java.io.IOException;
2020
import java.net.URI;

gcloud-java-contrib/gcloud-java-nio/pom.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
FileSystemProvider for Java NIO to access GCS transparently.
1010
</description>
1111
<parent>
12-
<groupId>com.google.gcloud</groupId>
12+
<groupId>com.google.cloud</groupId>
1313
<artifactId>gcloud-java-contrib</artifactId>
14-
<version>0.1.6-SNAPSHOT</version>
14+
<version>0.2.1-SNAPSHOT</version>
1515
</parent>
1616
<properties>
1717
<site.installationModule>nio</site.installationModule>
@@ -102,18 +102,18 @@
102102
<relocations>
103103
<relocation>
104104
<pattern>com</pattern>
105-
<shadedPattern>shaded.gcloud-nio.com</shadedPattern>
105+
<shadedPattern>shaded.cloud-nio.com</shadedPattern>
106106
<excludes>
107-
<exclude>com.google.gcloud.**</exclude>
107+
<exclude>com.google.cloud.**</exclude>
108108
</excludes>
109109
</relocation>
110110
<relocation>
111111
<pattern>org</pattern>
112-
<shadedPattern>shaded.gcloud-nio.org</shadedPattern>
112+
<shadedPattern>shaded.cloud-nio.org</shadedPattern>
113113
</relocation>
114114
<relocation>
115115
<pattern>google</pattern>
116-
<shadedPattern>shaded.gcloud-nio.google</shadedPattern>
116+
<shadedPattern>shaded.cloud-nio.google</shadedPattern>
117117
</relocation>
118118
</relocations>
119119
</configuration>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.google.gcloud.storage.contrib.nio;
17+
package com.google.cloud.storage.contrib.nio;
1818

1919
import static com.google.common.base.Preconditions.checkArgument;
2020

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.google.gcloud.storage.contrib.nio;
17+
package com.google.cloud.storage.contrib.nio;
1818

1919
import static com.google.common.base.Preconditions.checkNotNull;
2020

2121
import com.google.common.base.MoreObjects;
22-
import com.google.gcloud.storage.BlobInfo;
23-
import com.google.gcloud.storage.Storage;
22+
import com.google.cloud.storage.BlobInfo;
23+
import com.google.cloud.storage.Storage;
2424

2525
import java.io.IOException;
2626
import java.nio.file.NoSuchFileException;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.google.gcloud.storage.contrib.nio;
17+
package com.google.cloud.storage.contrib.nio;
1818

1919
import com.google.common.base.Optional;
2020
import com.google.common.collect.ImmutableMap;
21-
import com.google.gcloud.storage.Acl;
21+
import com.google.cloud.storage.Acl;
2222

2323
import java.nio.file.attribute.BasicFileAttributes;
2424
import java.util.List;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.google.gcloud.storage.contrib.nio;
17+
package com.google.cloud.storage.contrib.nio;
1818

1919
import static com.google.common.base.Preconditions.checkArgument;
2020
import static com.google.common.base.Preconditions.checkNotNull;
2121

2222
import com.google.common.collect.ImmutableSet;
23-
import com.google.gcloud.storage.StorageOptions;
23+
import com.google.cloud.storage.StorageOptions;
2424

2525
import java.io.IOException;
2626
import java.net.URI;
Lines changed: 33 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,26 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.google.gcloud.storage.contrib.nio;
17+
package com.google.cloud.storage.contrib.nio;
1818

1919
import static com.google.common.base.Preconditions.checkArgument;
2020
import static com.google.common.base.Preconditions.checkNotNull;
2121
import static com.google.common.base.Strings.isNullOrEmpty;
22-
import static com.google.gcloud.storage.contrib.nio.CloudStorageFileSystem.URI_SCHEME;
23-
import static com.google.gcloud.storage.contrib.nio.CloudStorageUtil.checkBucket;
24-
import static com.google.gcloud.storage.contrib.nio.CloudStorageUtil.checkNotNullArray;
25-
import static com.google.gcloud.storage.contrib.nio.CloudStorageUtil.checkPath;
26-
import static com.google.gcloud.storage.contrib.nio.CloudStorageUtil.stripPathFromUri;
2722

2823
import com.google.auto.service.AutoService;
2924
import com.google.common.annotations.VisibleForTesting;
3025
import com.google.common.base.MoreObjects;
3126
import com.google.common.base.Throwables;
3227
import com.google.common.collect.AbstractIterator;
3328
import com.google.common.primitives.Ints;
34-
import com.google.gcloud.storage.Acl;
35-
import com.google.gcloud.storage.Blob;
36-
import com.google.gcloud.storage.BlobId;
37-
import com.google.gcloud.storage.BlobInfo;
38-
import com.google.gcloud.storage.CopyWriter;
39-
import com.google.gcloud.storage.Storage;
40-
import com.google.gcloud.storage.StorageException;
41-
import com.google.gcloud.storage.StorageOptions;
29+
import com.google.cloud.storage.Acl;
30+
import com.google.cloud.storage.Blob;
31+
import com.google.cloud.storage.BlobId;
32+
import com.google.cloud.storage.BlobInfo;
33+
import com.google.cloud.storage.CopyWriter;
34+
import com.google.cloud.storage.Storage;
35+
import com.google.cloud.storage.StorageException;
36+
import com.google.cloud.storage.StorageOptions;
4237

4338
import java.io.BufferedInputStream;
4439
import java.io.IOException;
@@ -147,7 +142,7 @@ public CloudStorageFileSystemProvider() {
147142

148143
@Override
149144
public String getScheme() {
150-
return URI_SCHEME;
145+
return CloudStorageFileSystem.URI_SCHEME;
151146
}
152147

153148
/**
@@ -164,12 +159,12 @@ public CloudStorageFileSystem getFileSystem(URI uri) {
164159
@Override
165160
public CloudStorageFileSystem newFileSystem(URI uri, Map<String, ?> env) {
166161
checkArgument(
167-
uri.getScheme().equalsIgnoreCase(URI_SCHEME),
162+
uri.getScheme().equalsIgnoreCase(CloudStorageFileSystem.URI_SCHEME),
168163
"Cloud Storage URIs must have '%s' scheme: %s",
169-
URI_SCHEME,
164+
CloudStorageFileSystem.URI_SCHEME,
170165
uri);
171166
checkArgument(
172-
!isNullOrEmpty(uri.getHost()), "%s:// URIs must have a host: %s", URI_SCHEME, uri);
167+
!isNullOrEmpty(uri.getHost()), "%s:// URIs must have a host: %s", CloudStorageFileSystem.URI_SCHEME, uri);
173168
checkArgument(
174169
uri.getPort() == -1
175170
&& isNullOrEmpty(uri.getPath())
@@ -178,20 +173,20 @@ && isNullOrEmpty(uri.getFragment())
178173
&& isNullOrEmpty(uri.getUserInfo()),
179174
"GCS FileSystem URIs mustn't have: port, userinfo, path, query, or fragment: %s",
180175
uri);
181-
checkBucket(uri.getHost());
176+
CloudStorageUtil.checkBucket(uri.getHost());
182177
return new CloudStorageFileSystem(this, uri.getHost(), CloudStorageConfiguration.fromMap(env));
183178
}
184179

185180
@Override
186181
public CloudStoragePath getPath(URI uri) {
187-
return CloudStoragePath.getPath(getFileSystem(stripPathFromUri(uri)), uri.getPath());
182+
return CloudStoragePath.getPath(getFileSystem(CloudStorageUtil.stripPathFromUri(uri)), uri.getPath());
188183
}
189184

190185
@Override
191186
public SeekableByteChannel newByteChannel(
192187
Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException {
193188
checkNotNull(path);
194-
checkNotNullArray(attrs);
189+
CloudStorageUtil.checkNotNullArray(attrs);
195190
if (options.contains(StandardOpenOption.WRITE)) {
196191
// TODO: Make our OpenOptions implement FileAttribute. Also remove buffer option.
197192
return newWriteChannel(path, options);
@@ -227,7 +222,7 @@ private SeekableByteChannel newReadChannel(Path path, Set<? extends OpenOption>
227222
throw new UnsupportedOperationException(option.toString());
228223
}
229224
}
230-
CloudStoragePath cloudPath = checkPath(path);
225+
CloudStoragePath cloudPath = CloudStorageUtil.checkPath(path);
231226
if (cloudPath.seemsLikeADirectoryAndUsePseudoDirectories()) {
232227
throw new CloudStoragePseudoDirectoryException(cloudPath);
233228
}
@@ -237,7 +232,7 @@ private SeekableByteChannel newReadChannel(Path path, Set<? extends OpenOption>
237232
private SeekableByteChannel newWriteChannel(Path path, Set<? extends OpenOption> options)
238233
throws IOException {
239234

240-
CloudStoragePath cloudPath = checkPath(path);
235+
CloudStoragePath cloudPath = CloudStorageUtil.checkPath(path);
241236
if (cloudPath.seemsLikeADirectoryAndUsePseudoDirectories()) {
242237
throw new CloudStoragePseudoDirectoryException(cloudPath);
243238
}
@@ -311,7 +306,7 @@ private SeekableByteChannel newWriteChannel(Path path, Set<? extends OpenOption>
311306
@Override
312307
public InputStream newInputStream(Path path, OpenOption... options) throws IOException {
313308
InputStream result = super.newInputStream(path, options);
314-
CloudStoragePath cloudPath = checkPath(path);
309+
CloudStoragePath cloudPath = CloudStorageUtil.checkPath(path);
315310
int blockSize = cloudPath.getFileSystem().config().blockSize();
316311
for (OpenOption option : options) {
317312
if (option instanceof OptionBlockSize) {
@@ -323,7 +318,7 @@ public InputStream newInputStream(Path path, OpenOption... options) throws IOExc
323318

324319
@Override
325320
public boolean deleteIfExists(Path path) throws IOException {
326-
CloudStoragePath cloudPath = checkPath(path);
321+
CloudStoragePath cloudPath = CloudStorageUtil.checkPath(path);
327322
if (cloudPath.seemsLikeADirectoryAndUsePseudoDirectories()) {
328323
throw new CloudStoragePseudoDirectoryException(cloudPath);
329324
}
@@ -332,7 +327,7 @@ public boolean deleteIfExists(Path path) throws IOException {
332327

333328
@Override
334329
public void delete(Path path) throws IOException {
335-
CloudStoragePath cloudPath = checkPath(path);
330+
CloudStoragePath cloudPath = CloudStorageUtil.checkPath(path);
336331
if (!deleteIfExists(cloudPath)) {
337332
throw new NoSuchFileException(cloudPath.toString());
338333
}
@@ -361,7 +356,7 @@ public void copy(Path source, Path target, CopyOption... options) throws IOExcep
361356
boolean setContentEncoding = false;
362357
boolean setContentDisposition = false;
363358

364-
CloudStoragePath toPath = checkPath(target);
359+
CloudStoragePath toPath = CloudStorageUtil.checkPath(target);
365360
BlobInfo.Builder tgtInfoBuilder = BlobInfo.builder(toPath.getBlobId()).contentType("");
366361

367362
int blockSize = -1;
@@ -402,7 +397,7 @@ public void copy(Path source, Path target, CopyOption... options) throws IOExcep
402397
}
403398
}
404399

405-
CloudStoragePath fromPath = checkPath(source);
400+
CloudStoragePath fromPath = CloudStorageUtil.checkPath(source);
406401

407402
blockSize =
408403
blockSize != -1
@@ -470,15 +465,15 @@ public void copy(Path source, Path target, CopyOption... options) throws IOExcep
470465

471466
@Override
472467
public boolean isSameFile(Path path, Path path2) {
473-
return checkPath(path).equals(checkPath(path2));
468+
return CloudStorageUtil.checkPath(path).equals(CloudStorageUtil.checkPath(path2));
474469
}
475470

476471
/**
477472
* Always returns {@code false}, because GCS doesn't support hidden files.
478473
*/
479474
@Override
480475
public boolean isHidden(Path path) {
481-
checkPath(path);
476+
CloudStorageUtil.checkPath(path);
482477
return false;
483478
}
484479

@@ -494,7 +489,7 @@ public void checkAccess(Path path, AccessMode... modes) throws IOException {
494489
throw new UnsupportedOperationException(mode.toString());
495490
}
496491
}
497-
CloudStoragePath cloudPath = checkPath(path);
492+
CloudStoragePath cloudPath = CloudStorageUtil.checkPath(path);
498493
if (cloudPath.seemsLikeADirectoryAndUsePseudoDirectories()) {
499494
return;
500495
}
@@ -508,11 +503,11 @@ public void checkAccess(Path path, AccessMode... modes) throws IOException {
508503
public <A extends BasicFileAttributes> A readAttributes(
509504
Path path, Class<A> type, LinkOption... options) throws IOException {
510505
checkNotNull(type);
511-
checkNotNullArray(options);
506+
CloudStorageUtil.checkNotNullArray(options);
512507
if (type != CloudStorageFileAttributes.class && type != BasicFileAttributes.class) {
513508
throw new UnsupportedOperationException(type.getSimpleName());
514509
}
515-
CloudStoragePath cloudPath = checkPath(path);
510+
CloudStoragePath cloudPath = CloudStorageUtil.checkPath(path);
516511
if (cloudPath.seemsLikeADirectoryAndUsePseudoDirectories()) {
517512
@SuppressWarnings("unchecked")
518513
A result = (A) new CloudStoragePseudoDirectoryAttributes(cloudPath);
@@ -543,11 +538,11 @@ public Map<String, Object> readAttributes(Path path, String attributes, LinkOpti
543538
public <V extends FileAttributeView> V getFileAttributeView(
544539
Path path, Class<V> type, LinkOption... options) {
545540
checkNotNull(type);
546-
checkNotNullArray(options);
541+
CloudStorageUtil.checkNotNullArray(options);
547542
if (type != CloudStorageFileAttributeView.class && type != BasicFileAttributeView.class) {
548543
throw new UnsupportedOperationException(type.getSimpleName());
549544
}
550-
CloudStoragePath cloudPath = checkPath(path);
545+
CloudStoragePath cloudPath = CloudStorageUtil.checkPath(path);
551546
@SuppressWarnings("unchecked")
552547
V result = (V) new CloudStorageFileAttributeView(storage, cloudPath);
553548
return result;
@@ -558,13 +553,13 @@ public <V extends FileAttributeView> V getFileAttributeView(
558553
*/
559554
@Override
560555
public void createDirectory(Path dir, FileAttribute<?>... attrs) {
561-
checkPath(dir);
562-
checkNotNullArray(attrs);
556+
CloudStorageUtil.checkPath(dir);
557+
CloudStorageUtil.checkNotNullArray(attrs);
563558
}
564559

565560
@Override
566561
public DirectoryStream<Path> newDirectoryStream(Path dir, final Filter<? super Path> filter) {
567-
final CloudStoragePath cloudPath = checkPath(dir);
562+
final CloudStoragePath cloudPath = CloudStorageUtil.checkPath(dir);
568563
checkNotNull(filter);
569564
String prefix = cloudPath.toString();
570565
final Iterator<Blob> blobIterator = storage.list(cloudPath.bucket(), Storage.BlobListOption.prefix(prefix), Storage.BlobListOption.fields()).iterateAll();
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.google.gcloud.storage.contrib.nio;
17+
package com.google.cloud.storage.contrib.nio;
1818

1919
import static com.google.common.base.Preconditions.checkNotNull;
20-
import static com.google.gcloud.storage.contrib.nio.CloudStorageFileSystem.FILE_TIME_UNKNOWN;
20+
import static com.google.cloud.storage.contrib.nio.CloudStorageFileSystem.FILE_TIME_UNKNOWN;
2121

2222
import com.google.common.base.MoreObjects;
2323
import com.google.common.base.Optional;
2424
import com.google.common.collect.ImmutableMap;
25-
import com.google.gcloud.storage.Acl;
26-
import com.google.gcloud.storage.BlobInfo;
25+
import com.google.cloud.storage.Acl;
26+
import com.google.cloud.storage.BlobInfo;
2727

2828
import java.nio.file.attribute.FileTime;
2929
import java.util.List;
@@ -127,7 +127,7 @@ public FileTime lastAccessTime() {
127127

128128
@Override
129129
public Object fileKey() {
130-
return info.id();
130+
return info.blobId().bucket() + info.blobId().name() + info.blobId().generation();
131131
}
132132

133133
@Override
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.google.gcloud.storage.contrib.nio;
17+
package com.google.cloud.storage.contrib.nio;
1818

1919
/**
2020
* Exception reminding user that Cloud Storage objects can't be mutated.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.google.gcloud.storage.contrib.nio;
17+
package com.google.cloud.storage.contrib.nio;
1818

1919
import java.nio.file.CopyOption;
2020
import java.nio.file.OpenOption;

0 commit comments

Comments
 (0)