Skip to content

Commit

Permalink
Move gcloud->cloud (issue googleapis#877) and update version number
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-philippe-martin authored and mziccard committed Jun 29, 2016
1 parent 5834df4 commit e510dae
Show file tree
Hide file tree
Showing 14 changed files with 120 additions and 147 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
8 changes: 4 additions & 4 deletions gcloud-java-contrib/gcloud-java-nio/pom.xml
Original file line number Diff line number Diff line change
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 @@ -16,10 +16,6 @@

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

import static com.google.cloud.storage.contrib.nio.CloudStorageUtil.checkBucket;
import static com.google.cloud.storage.contrib.nio.CloudStorageUtil.checkNotNullArray;
import static com.google.cloud.storage.contrib.nio.CloudStorageUtil.checkPath;
import static com.google.cloud.storage.contrib.nio.CloudStorageUtil.stripPathFromUri;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Strings.isNullOrEmpty;
Expand Down Expand Up @@ -71,6 +67,7 @@
import java.util.Map;
import java.util.Objects;
import java.util.Set;

import javax.annotation.Nullable;
import javax.annotation.concurrent.ThreadSafe;

Expand Down Expand Up @@ -173,20 +170,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 @@ -222,7 +219,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 @@ -232,7 +229,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 @@ -306,7 +303,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 @@ -318,7 +315,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 @@ -327,7 +324,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 @@ -356,7 +353,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 @@ -397,7 +394,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 @@ -465,15 +462,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 @@ -489,7 +486,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 @@ -503,11 +500,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 @@ -538,11 +535,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 @@ -553,13 +550,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 @@ -16,8 +16,6 @@

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

import static com.google.cloud.storage.contrib.nio.CloudStorageUtil.checkNotNullArray;
import static com.google.cloud.storage.contrib.nio.CloudStorageUtil.checkPath;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;

Expand Down Expand Up @@ -125,7 +123,7 @@ public CloudStoragePath toAbsolutePath() {
*/
@Override
public CloudStoragePath toRealPath(LinkOption... options) {
checkNotNullArray(options);
CloudStorageUtil.checkNotNullArray(options);
return newPath(toRealPathInternal(true));
}

Expand Down Expand Up @@ -155,7 +153,7 @@ public CloudStoragePath normalize() {

@Override
public CloudStoragePath resolve(Path object) {
return newPath(path.resolve(checkPath(object).path));
return newPath(path.resolve(CloudStorageUtil.checkPath(object).path));
}

@Override
Expand All @@ -165,7 +163,7 @@ public CloudStoragePath resolve(String other) {

@Override
public CloudStoragePath resolveSibling(Path other) {
return newPath(path.resolveSibling(checkPath(other).path));
return newPath(path.resolveSibling(CloudStorageUtil.checkPath(other).path));
}

@Override
Expand All @@ -175,7 +173,7 @@ public CloudStoragePath resolveSibling(String other) {

@Override
public CloudStoragePath relativize(Path object) {
return newPath(path.relativize(checkPath(object).path));
return newPath(path.relativize(CloudStorageUtil.checkPath(object).path));
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

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

import static com.google.cloud.storage.contrib.nio.CloudStorageFileSystem.FILE_TIME_UNKNOWN;

import com.google.cloud.storage.Acl;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableMap;
Expand Down Expand Up @@ -68,17 +66,17 @@ public long size() {

@Override
public FileTime lastModifiedTime() {
return FILE_TIME_UNKNOWN;
return CloudStorageFileSystem.FILE_TIME_UNKNOWN;
}

@Override
public FileTime creationTime() {
return FILE_TIME_UNKNOWN;
return CloudStorageFileSystem.FILE_TIME_UNKNOWN;
}

@Override
public FileTime lastAccessTime() {
return FILE_TIME_UNKNOWN;
return CloudStorageFileSystem.FILE_TIME_UNKNOWN;
}

@Override
Expand Down
Loading

0 comments on commit e510dae

Please sign in to comment.