1414 * limitations under the License.
1515 */
1616
17- package com .google .gcloud .storage .contrib .nio ;
17+ package com .google .cloud .storage .contrib .nio ;
1818
1919import static com .google .common .base .Preconditions .checkArgument ;
2020import static com .google .common .base .Preconditions .checkNotNull ;
2121import 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
2823import com .google .auto .service .AutoService ;
2924import com .google .common .annotations .VisibleForTesting ;
3025import com .google .common .base .MoreObjects ;
3126import com .google .common .base .Throwables ;
3227import com .google .common .collect .AbstractIterator ;
3328import 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
4338import java .io .BufferedInputStream ;
4439import 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 ();
0 commit comments