Skip to content

Commit

Permalink
Move gcloud->cloud (issue #877) and update version number
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-philippe-martin committed Apr 18, 2016
1 parent 5644d92 commit c138bf0
Show file tree
Hide file tree
Showing 44 changed files with 222 additions and 259 deletions.
4 changes: 2 additions & 2 deletions gcloud-java-contrib/gcloud-java-nio-examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ To run this example:
4. Run the sample with:

```
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
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
```

Notice that it lists gcs, which it wouldn't if you ran it without the nio jar:
```
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
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
```

The sample doesn't have anything about GCS in it. It gets that ability from the nio jar that
Expand Down
4 changes: 2 additions & 2 deletions gcloud-java-contrib/gcloud-java-nio-examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
Demonstrates how to use the gcloud-java-nio jar to add GCS functionality to legacy code.
</description>
<parent>
<groupId>com.google.gcloud</groupId>
<groupId>com.google.cloud</groupId>
<artifactId>gcloud-java-contrib</artifactId>
<version>0.1.6-SNAPSHOT</version>
<version>0.2.1-SNAPSHOT</version>
</parent>
<properties>
<site.installationModule>nio</site.installationModule>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.google.gcloud.nio.examples;
package com.google.cloud.nio.examples;

import java.io.IOException;
import java.net.URI;
Expand Down
12 changes: 6 additions & 6 deletions gcloud-java-contrib/gcloud-java-nio/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
FileSystemProvider for Java NIO to access GCS transparently.
</description>
<parent>
<groupId>com.google.gcloud</groupId>
<groupId>com.google.cloud</groupId>
<artifactId>gcloud-java-contrib</artifactId>
<version>0.1.6-SNAPSHOT</version>
<version>0.2.1-SNAPSHOT</version>
</parent>
<properties>
<site.installationModule>nio</site.installationModule>
Expand Down Expand Up @@ -102,18 +102,18 @@
<relocations>
<relocation>
<pattern>com</pattern>
<shadedPattern>shaded.gcloud-nio.com</shadedPattern>
<shadedPattern>shaded.cloud-nio.com</shadedPattern>
<excludes>
<exclude>com.google.gcloud.**</exclude>
<exclude>com.google.cloud.**</exclude>
</excludes>
</relocation>
<relocation>
<pattern>org</pattern>
<shadedPattern>shaded.gcloud-nio.org</shadedPattern>
<shadedPattern>shaded.cloud-nio.org</shadedPattern>
</relocation>
<relocation>
<pattern>google</pattern>
<shadedPattern>shaded.gcloud-nio.google</shadedPattern>
<shadedPattern>shaded.cloud-nio.google</shadedPattern>
</relocation>
</relocations>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.google.gcloud.storage.contrib.nio;
package com.google.cloud.storage.contrib.nio;

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
* limitations under the License.
*/

package com.google.gcloud.storage.contrib.nio;
package com.google.cloud.storage.contrib.nio;

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

import com.google.common.base.MoreObjects;
import com.google.gcloud.storage.BlobInfo;
import com.google.gcloud.storage.Storage;
import com.google.cloud.storage.BlobInfo;
import com.google.cloud.storage.Storage;

import java.io.IOException;
import java.nio.file.NoSuchFileException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
* limitations under the License.
*/

package com.google.gcloud.storage.contrib.nio;
package com.google.cloud.storage.contrib.nio;

import com.google.common.base.Optional;
import com.google.common.collect.ImmutableMap;
import com.google.gcloud.storage.Acl;
import com.google.cloud.storage.Acl;

import java.nio.file.attribute.BasicFileAttributes;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
* limitations under the License.
*/

package com.google.gcloud.storage.contrib.nio;
package com.google.cloud.storage.contrib.nio;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;

import com.google.common.collect.ImmutableSet;
import com.google.gcloud.storage.StorageOptions;
import com.google.cloud.storage.StorageOptions;

import java.io.IOException;
import java.net.URI;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,26 @@
* limitations under the License.
*/

package com.google.gcloud.storage.contrib.nio;
package com.google.cloud.storage.contrib.nio;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Strings.isNullOrEmpty;
import static com.google.gcloud.storage.contrib.nio.CloudStorageFileSystem.URI_SCHEME;
import static com.google.gcloud.storage.contrib.nio.CloudStorageUtil.checkBucket;
import static com.google.gcloud.storage.contrib.nio.CloudStorageUtil.checkNotNullArray;
import static com.google.gcloud.storage.contrib.nio.CloudStorageUtil.checkPath;
import static com.google.gcloud.storage.contrib.nio.CloudStorageUtil.stripPathFromUri;

import com.google.auto.service.AutoService;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.MoreObjects;
import com.google.common.base.Throwables;
import com.google.common.collect.AbstractIterator;
import com.google.common.primitives.Ints;
import com.google.gcloud.storage.Acl;
import com.google.gcloud.storage.Blob;
import com.google.gcloud.storage.BlobId;
import com.google.gcloud.storage.BlobInfo;
import com.google.gcloud.storage.CopyWriter;
import com.google.gcloud.storage.Storage;
import com.google.gcloud.storage.StorageException;
import com.google.gcloud.storage.StorageOptions;
import com.google.cloud.storage.Acl;
import com.google.cloud.storage.Blob;
import com.google.cloud.storage.BlobId;
import com.google.cloud.storage.BlobInfo;
import com.google.cloud.storage.CopyWriter;
import com.google.cloud.storage.Storage;
import com.google.cloud.storage.StorageException;
import com.google.cloud.storage.StorageOptions;

import java.io.BufferedInputStream;
import java.io.IOException;
Expand Down Expand Up @@ -147,7 +142,7 @@ public CloudStorageFileSystemProvider() {

@Override
public String getScheme() {
return URI_SCHEME;
return CloudStorageFileSystem.URI_SCHEME;
}

/**
Expand All @@ -164,12 +159,12 @@ public CloudStorageFileSystem getFileSystem(URI uri) {
@Override
public CloudStorageFileSystem newFileSystem(URI uri, Map<String, ?> env) {
checkArgument(
uri.getScheme().equalsIgnoreCase(URI_SCHEME),
uri.getScheme().equalsIgnoreCase(CloudStorageFileSystem.URI_SCHEME),
"Cloud Storage URIs must have '%s' scheme: %s",
URI_SCHEME,
CloudStorageFileSystem.URI_SCHEME,
uri);
checkArgument(
!isNullOrEmpty(uri.getHost()), "%s:// URIs must have a host: %s", URI_SCHEME, uri);
!isNullOrEmpty(uri.getHost()), "%s:// URIs must have a host: %s", CloudStorageFileSystem.URI_SCHEME, uri);
checkArgument(
uri.getPort() == -1
&& isNullOrEmpty(uri.getPath())
Expand All @@ -178,20 +173,20 @@ && isNullOrEmpty(uri.getFragment())
&& isNullOrEmpty(uri.getUserInfo()),
"GCS FileSystem URIs mustn't have: port, userinfo, path, query, or fragment: %s",
uri);
checkBucket(uri.getHost());
CloudStorageUtil.checkBucket(uri.getHost());
return new CloudStorageFileSystem(this, uri.getHost(), CloudStorageConfiguration.fromMap(env));
}

@Override
public CloudStoragePath getPath(URI uri) {
return CloudStoragePath.getPath(getFileSystem(stripPathFromUri(uri)), uri.getPath());
return CloudStoragePath.getPath(getFileSystem(CloudStorageUtil.stripPathFromUri(uri)), uri.getPath());
}

@Override
public SeekableByteChannel newByteChannel(
Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException {
checkNotNull(path);
checkNotNullArray(attrs);
CloudStorageUtil.checkNotNullArray(attrs);
if (options.contains(StandardOpenOption.WRITE)) {
// TODO: Make our OpenOptions implement FileAttribute. Also remove buffer option.
return newWriteChannel(path, options);
Expand Down Expand Up @@ -227,7 +222,7 @@ private SeekableByteChannel newReadChannel(Path path, Set<? extends OpenOption>
throw new UnsupportedOperationException(option.toString());
}
}
CloudStoragePath cloudPath = checkPath(path);
CloudStoragePath cloudPath = CloudStorageUtil.checkPath(path);
if (cloudPath.seemsLikeADirectoryAndUsePseudoDirectories()) {
throw new CloudStoragePseudoDirectoryException(cloudPath);
}
Expand All @@ -237,7 +232,7 @@ private SeekableByteChannel newReadChannel(Path path, Set<? extends OpenOption>
private SeekableByteChannel newWriteChannel(Path path, Set<? extends OpenOption> options)
throws IOException {

CloudStoragePath cloudPath = checkPath(path);
CloudStoragePath cloudPath = CloudStorageUtil.checkPath(path);
if (cloudPath.seemsLikeADirectoryAndUsePseudoDirectories()) {
throw new CloudStoragePseudoDirectoryException(cloudPath);
}
Expand Down Expand Up @@ -311,7 +306,7 @@ private SeekableByteChannel newWriteChannel(Path path, Set<? extends OpenOption>
@Override
public InputStream newInputStream(Path path, OpenOption... options) throws IOException {
InputStream result = super.newInputStream(path, options);
CloudStoragePath cloudPath = checkPath(path);
CloudStoragePath cloudPath = CloudStorageUtil.checkPath(path);
int blockSize = cloudPath.getFileSystem().config().blockSize();
for (OpenOption option : options) {
if (option instanceof OptionBlockSize) {
Expand All @@ -323,7 +318,7 @@ public InputStream newInputStream(Path path, OpenOption... options) throws IOExc

@Override
public boolean deleteIfExists(Path path) throws IOException {
CloudStoragePath cloudPath = checkPath(path);
CloudStoragePath cloudPath = CloudStorageUtil.checkPath(path);
if (cloudPath.seemsLikeADirectoryAndUsePseudoDirectories()) {
throw new CloudStoragePseudoDirectoryException(cloudPath);
}
Expand All @@ -332,7 +327,7 @@ public boolean deleteIfExists(Path path) throws IOException {

@Override
public void delete(Path path) throws IOException {
CloudStoragePath cloudPath = checkPath(path);
CloudStoragePath cloudPath = CloudStorageUtil.checkPath(path);
if (!deleteIfExists(cloudPath)) {
throw new NoSuchFileException(cloudPath.toString());
}
Expand Down Expand Up @@ -361,7 +356,7 @@ public void copy(Path source, Path target, CopyOption... options) throws IOExcep
boolean setContentEncoding = false;
boolean setContentDisposition = false;

CloudStoragePath toPath = checkPath(target);
CloudStoragePath toPath = CloudStorageUtil.checkPath(target);
BlobInfo.Builder tgtInfoBuilder = BlobInfo.builder(toPath.getBlobId()).contentType("");

int blockSize = -1;
Expand Down Expand Up @@ -402,7 +397,7 @@ public void copy(Path source, Path target, CopyOption... options) throws IOExcep
}
}

CloudStoragePath fromPath = checkPath(source);
CloudStoragePath fromPath = CloudStorageUtil.checkPath(source);

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

@Override
public boolean isSameFile(Path path, Path path2) {
return checkPath(path).equals(checkPath(path2));
return CloudStorageUtil.checkPath(path).equals(CloudStorageUtil.checkPath(path2));
}

/**
* Always returns {@code false}, because GCS doesn't support hidden files.
*/
@Override
public boolean isHidden(Path path) {
checkPath(path);
CloudStorageUtil.checkPath(path);
return false;
}

Expand All @@ -494,7 +489,7 @@ public void checkAccess(Path path, AccessMode... modes) throws IOException {
throw new UnsupportedOperationException(mode.toString());
}
}
CloudStoragePath cloudPath = checkPath(path);
CloudStoragePath cloudPath = CloudStorageUtil.checkPath(path);
if (cloudPath.seemsLikeADirectoryAndUsePseudoDirectories()) {
return;
}
Expand All @@ -508,11 +503,11 @@ public void checkAccess(Path path, AccessMode... modes) throws IOException {
public <A extends BasicFileAttributes> A readAttributes(
Path path, Class<A> type, LinkOption... options) throws IOException {
checkNotNull(type);
checkNotNullArray(options);
CloudStorageUtil.checkNotNullArray(options);
if (type != CloudStorageFileAttributes.class && type != BasicFileAttributes.class) {
throw new UnsupportedOperationException(type.getSimpleName());
}
CloudStoragePath cloudPath = checkPath(path);
CloudStoragePath cloudPath = CloudStorageUtil.checkPath(path);
if (cloudPath.seemsLikeADirectoryAndUsePseudoDirectories()) {
@SuppressWarnings("unchecked")
A result = (A) new CloudStoragePseudoDirectoryAttributes(cloudPath);
Expand Down Expand Up @@ -543,11 +538,11 @@ public Map<String, Object> readAttributes(Path path, String attributes, LinkOpti
public <V extends FileAttributeView> V getFileAttributeView(
Path path, Class<V> type, LinkOption... options) {
checkNotNull(type);
checkNotNullArray(options);
CloudStorageUtil.checkNotNullArray(options);
if (type != CloudStorageFileAttributeView.class && type != BasicFileAttributeView.class) {
throw new UnsupportedOperationException(type.getSimpleName());
}
CloudStoragePath cloudPath = checkPath(path);
CloudStoragePath cloudPath = CloudStorageUtil.checkPath(path);
@SuppressWarnings("unchecked")
V result = (V) new CloudStorageFileAttributeView(storage, cloudPath);
return result;
Expand All @@ -558,13 +553,13 @@ public <V extends FileAttributeView> V getFileAttributeView(
*/
@Override
public void createDirectory(Path dir, FileAttribute<?>... attrs) {
checkPath(dir);
checkNotNullArray(attrs);
CloudStorageUtil.checkPath(dir);
CloudStorageUtil.checkNotNullArray(attrs);
}

@Override
public DirectoryStream<Path> newDirectoryStream(Path dir, final Filter<? super Path> filter) {
final CloudStoragePath cloudPath = checkPath(dir);
final CloudStoragePath cloudPath = CloudStorageUtil.checkPath(dir);
checkNotNull(filter);
String prefix = cloudPath.toString();
final Iterator<Blob> blobIterator = storage.list(cloudPath.bucket(), Storage.BlobListOption.prefix(prefix), Storage.BlobListOption.fields()).iterateAll();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
* limitations under the License.
*/

package com.google.gcloud.storage.contrib.nio;
package com.google.cloud.storage.contrib.nio;

import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.gcloud.storage.contrib.nio.CloudStorageFileSystem.FILE_TIME_UNKNOWN;
import static com.google.cloud.storage.contrib.nio.CloudStorageFileSystem.FILE_TIME_UNKNOWN;

import com.google.common.base.MoreObjects;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableMap;
import com.google.gcloud.storage.Acl;
import com.google.gcloud.storage.BlobInfo;
import com.google.cloud.storage.Acl;
import com.google.cloud.storage.BlobInfo;

import java.nio.file.attribute.FileTime;
import java.util.List;
Expand Down Expand Up @@ -127,7 +127,7 @@ public FileTime lastAccessTime() {

@Override
public Object fileKey() {
return info.id();
return info.blobId().bucket() + info.blobId().name() + info.blobId().generation();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.google.gcloud.storage.contrib.nio;
package com.google.cloud.storage.contrib.nio;

/**
* Exception reminding user that Cloud Storage objects can't be mutated.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.google.gcloud.storage.contrib.nio;
package com.google.cloud.storage.contrib.nio;

import java.nio.file.CopyOption;
import java.nio.file.OpenOption;
Expand Down
Loading

0 comments on commit c138bf0

Please sign in to comment.