Skip to content

Commit

Permalink
Move gcloud -> cloud (issue #877)
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 75a22c9
Show file tree
Hide file tree
Showing 40 changed files with 162 additions and 191 deletions.
2 changes: 1 addition & 1 deletion gcloud-java-contrib/gcloud-java-nio-examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
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>
</parent>
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
2 changes: 1 addition & 1 deletion gcloud-java-contrib/gcloud-java-nio/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
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>
</parent>
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,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.checkNotNull;

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 com.google.common.base.Optional;
import com.google.common.collect.ImmutableMap;
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;
import static com.google.common.base.Preconditions.checkNotNull;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,11 @@
* 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;
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,10 +14,10 @@
* 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;
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
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 com.google.gcloud.storage.Acl;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,10 @@
* 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.gcloud.storage.contrib.nio.CloudStorageFileSystem.URI_SCHEME;
import static com.google.gcloud.storage.contrib.nio.CloudStorageUtil.checkNotNullArray;
import static com.google.gcloud.storage.contrib.nio.CloudStorageUtil.checkPath;

import com.google.common.collect.UnmodifiableIterator;
import com.google.gcloud.storage.BlobId;
Expand Down Expand Up @@ -126,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 @@ -156,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 @@ -166,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 @@ -176,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 Expand Up @@ -311,7 +308,7 @@ public String toString() {
@Override
public URI toUri() {
try {
return new URI(URI_SCHEME, bucket(), path.toAbsolutePath().toString(), null);
return new URI(CloudStorageFileSystem.URI_SCHEME, bucket(), path.toAbsolutePath().toString(), null);
} catch (URISyntaxException e) {
throw new AssertionError(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
* limitations under the License.
*/

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

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

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 75a22c9

Please sign in to comment.