You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ga...@apache.org on 2015/08/21 03:10:34 UTC

[1/4] jclouds-labs-google git commit: JCLOUDS-992: do not use RELATIVE_PATH for BLOBs.

Repository: jclouds-labs-google
Updated Branches:
  refs/heads/master b29a00e69 -> 66ed87398


JCLOUDS-992: do not use RELATIVE_PATH for BLOBs.

Changes the Google storage provider to be inline with the other
providers in not returning RELATIVE_PATH for objects that are BLOBs.


Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/commit/082fc9ad
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/tree/082fc9ad
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/diff/082fc9ad

Branch: refs/heads/master
Commit: 082fc9ad9e4d46d8003b2c3651c91d05cf0fbb6e
Parents: b29a00e
Author: Timur Alperovich <ti...@gmail.com>
Authored: Thu Aug 20 14:29:20 2015 -0700
Committer: Timur Alperovich <ti...@gmail.com>
Committed: Thu Aug 20 14:30:38 2015 -0700

----------------------------------------------------------------------
 .../blobstore/functions/ObjectToBlobMetadata.java   | 16 +---------------
 1 file changed, 1 insertion(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/082fc9ad/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/functions/ObjectToBlobMetadata.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/functions/ObjectToBlobMetadata.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/functions/ObjectToBlobMetadata.java
index 93f9959..4a6cf7d 100644
--- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/functions/ObjectToBlobMetadata.java
+++ b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/functions/ObjectToBlobMetadata.java
@@ -16,12 +16,10 @@
  */
 package org.jclouds.googlecloudstorage.blobstore.functions;
 
-import javax.inject.Inject;
 
 import org.jclouds.blobstore.domain.MutableBlobMetadata;
 import org.jclouds.blobstore.domain.StorageType;
 import org.jclouds.blobstore.domain.internal.MutableBlobMetadataImpl;
-import org.jclouds.blobstore.strategy.IfDirectoryReturnNameStrategy;
 import org.jclouds.googlecloudstorage.domain.GoogleCloudStorageObject;
 import org.jclouds.javax.annotation.Nullable;
 
@@ -30,11 +28,6 @@ import com.google.common.hash.HashCode;
 import com.google.common.io.BaseEncoding;
 
 public class ObjectToBlobMetadata implements Function<GoogleCloudStorageObject, MutableBlobMetadata> {
-   private final IfDirectoryReturnNameStrategy ifDirectoryReturnName;
-
-   @Inject public ObjectToBlobMetadata(IfDirectoryReturnNameStrategy ifDirectoryReturnName) {
-      this.ifDirectoryReturnName = ifDirectoryReturnName;
-   }
 
    public MutableBlobMetadata apply(GoogleCloudStorageObject from) {
       if (from == null) {
@@ -55,14 +48,7 @@ public class ObjectToBlobMetadata implements Function<GoogleCloudStorageObject,
       to.setUri(from.selfLink());
       to.setId(from.id());
       to.setPublicUri(from.mediaLink());
-
-      String directoryName = ifDirectoryReturnName.execute(to);
-      if (directoryName != null) {
-         to.setName(directoryName);
-         to.setType(StorageType.RELATIVE_PATH);
-      } else {
-         to.setType(StorageType.BLOB);
-      }
+      to.setType(StorageType.BLOB);
       to.setSize(from.size());
       return to;
    }


[2/4] jclouds-labs-google git commit: JCLOUDS-929: Plumb delimiter and prefix to GCS.

Posted by ga...@apache.org.
JCLOUDS-929: Plumb delimiter and prefix to GCS.


Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/commit/6e00fb45
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/tree/6e00fb45
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/diff/6e00fb45

Branch: refs/heads/master
Commit: 6e00fb45fa06db534fef780f9e590b9f912f24f4
Parents: 082fc9a
Author: Timur Alperovich <ti...@gmail.com>
Authored: Thu Aug 20 15:29:41 2015 -0700
Committer: Timur Alperovich <ti...@gmail.com>
Committed: Thu Aug 20 17:55:48 2015 -0700

----------------------------------------------------------------------
 ...ListContainerOptionsToListObjectOptions.java | 11 ++++++-
 .../functions/ObjectListToStorageMetadata.java  | 30 ++++++++------------
 ...loudStorageContainerIntegrationLiveTest.java | 10 -------
 3 files changed, 22 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/6e00fb45/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/functions/BlobStoreListContainerOptionsToListObjectOptions.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/functions/BlobStoreListContainerOptionsToListObjectOptions.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/functions/BlobStoreListContainerOptionsToListObjectOptions.java
index 581e9ce..15b5f4f 100644
--- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/functions/BlobStoreListContainerOptionsToListObjectOptions.java
+++ b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/functions/BlobStoreListContainerOptionsToListObjectOptions.java
@@ -26,18 +26,27 @@ import com.google.common.base.Function;
 public class BlobStoreListContainerOptionsToListObjectOptions implements
          Function<ListContainerOptions, ListObjectOptions> {
    public ListObjectOptions apply(ListContainerOptions from) {
+      if (from.getDir() != null && (from.getPrefix() != null || from.getDelimiter() != null)) {
+         throw new IllegalArgumentException("Cannot pass both directory and prefix/delimiter");
+      }
       checkNotNull(from, "set options to instance NONE instead of passing null");
       ListObjectOptions httpOptions = new ListObjectOptions();
 
-      if (!from.isRecursive()) {
+      if (!from.isRecursive() && from.getDelimiter() == null) {
          httpOptions = httpOptions.delimiter("/");
       }
+      if (from.getDelimiter() != null) {
+         httpOptions = httpOptions.delimiter(from.getDelimiter());
+      }
       if (from.getDir() != null) {
          String path = from.getDir();
          if (!path.endsWith("/"))
             path += "/";
          httpOptions = httpOptions.prefix(path);
       }
+      if (from.getPrefix() != null) {
+         httpOptions.prefix(from.getPrefix());
+      }
       if (from.getMarker() != null) {
          httpOptions = httpOptions.pageToken(from.getMarker());
       }

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/6e00fb45/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/functions/ObjectListToStorageMetadata.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/functions/ObjectListToStorageMetadata.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/functions/ObjectListToStorageMetadata.java
index 22f00da..4f7f1d0 100644
--- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/functions/ObjectListToStorageMetadata.java
+++ b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/functions/ObjectListToStorageMetadata.java
@@ -16,22 +16,22 @@
  */
 package org.jclouds.googlecloudstorage.blobstore.functions;
 
-import java.util.Map;
+import java.util.SortedSet;
 
 import javax.inject.Inject;
 
-import org.jclouds.blobstore.domain.BlobMetadata;
+import org.jclouds.blobstore.domain.MutableStorageMetadata;
 import org.jclouds.blobstore.domain.PageSet;
 import org.jclouds.blobstore.domain.StorageMetadata;
 import org.jclouds.blobstore.domain.StorageType;
+import org.jclouds.blobstore.domain.internal.MutableStorageMetadataImpl;
 import org.jclouds.blobstore.domain.internal.PageSetImpl;
-import org.jclouds.blobstore.domain.internal.StorageMetadataImpl;
 import org.jclouds.googlecloudstorage.domain.GoogleCloudStorageObject;
 import org.jclouds.googlecloudstorage.domain.ListPageWithPrefixes;
 
 import com.google.common.base.Function;
-import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Iterables;
+import com.google.common.collect.Sets;
 
 public class ObjectListToStorageMetadata
       implements Function<ListPageWithPrefixes<GoogleCloudStorageObject>, PageSet<? extends StorageMetadata>> {
@@ -46,19 +46,13 @@ public class ObjectListToStorageMetadata
          from = ListPageWithPrefixes.create(null, null, null);
       }
 
-      return new PageSetImpl<StorageMetadata>(Iterables.transform(Iterables.transform(from, object2blobMd),
-               new Function<BlobMetadata, StorageMetadata>() {
-                  public StorageMetadata apply(BlobMetadata input) {
-                     Map<String, String> userMetaData = (input != null && input.getUserMetadata() != null) ? input
-                              .getUserMetadata() : ImmutableMap.<String, String> of();
-                     if (input.getContentMetadata().getContentType().equals("application/directory")) {
-                        return new StorageMetadataImpl(StorageType.RELATIVE_PATH, input.getProviderId(), input
-                                 .getName(), input.getLocation(), input.getUri(), input.getETag(), input
-                                 .getCreationDate(), input.getLastModified(), userMetaData,
-                                 input.getSize());
-                     }
-                     return input;
-                  }
-               }), from.nextPageToken());
+      SortedSet<StorageMetadata> results = Sets.<StorageMetadata> newTreeSet(Iterables.transform(from, object2blobMd));
+      for (String prefix : from.prefixes()) {
+          MutableStorageMetadata metadata = new MutableStorageMetadataImpl();
+          metadata.setType(StorageType.RELATIVE_PATH);
+          metadata.setName(prefix);
+          results.add(metadata);
+      }
+      return new PageSetImpl<StorageMetadata>(results, from.nextPageToken());
    }
 }

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/6e00fb45/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/blobstore/integration/GoogleCloudStorageContainerIntegrationLiveTest.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/blobstore/integration/GoogleCloudStorageContainerIntegrationLiveTest.java b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/blobstore/integration/GoogleCloudStorageContainerIntegrationLiveTest.java
index d4f5fb8..c129ae8 100644
--- a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/blobstore/integration/GoogleCloudStorageContainerIntegrationLiveTest.java
+++ b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/blobstore/integration/GoogleCloudStorageContainerIntegrationLiveTest.java
@@ -105,14 +105,4 @@ public class GoogleCloudStorageContainerIntegrationLiveTest extends BaseContaine
    public void testListMarkerAfterLastKey() throws Exception {
       throw new SkipException("cannot specify arbitrary markers");
    }
-
-   @Override
-   public void testContainerListWithPrefix() {
-      throw new SkipException("Prefix option has not been plumbed down to GCS");
-   }
-
-   @Override
-   public void testDelimiterList() {
-      throw new SkipException("Prefix option has not been plumbed down to GCS");
-   }
 }


[4/4] jclouds-labs-google git commit: Update comment for the failing test.

Posted by ga...@apache.org.
Update comment for the failing test.


Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/commit/66ed8739
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/tree/66ed8739
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/diff/66ed8739

Branch: refs/heads/master
Commit: 66ed8739873e543e39ed21e1220671e23eedbee2
Parents: 72473dc
Author: Timur Alperovich <ti...@gmail.com>
Authored: Thu Aug 20 17:31:28 2015 -0700
Committer: Timur Alperovich <ti...@gmail.com>
Committed: Thu Aug 20 17:55:55 2015 -0700

----------------------------------------------------------------------
 .../GoogleCloudStorageContainerIntegrationLiveTest.java           | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/66ed8739/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/blobstore/integration/GoogleCloudStorageContainerIntegrationLiveTest.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/blobstore/integration/GoogleCloudStorageContainerIntegrationLiveTest.java b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/blobstore/integration/GoogleCloudStorageContainerIntegrationLiveTest.java
index c129ae8..0850cd7 100644
--- a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/blobstore/integration/GoogleCloudStorageContainerIntegrationLiveTest.java
+++ b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/blobstore/integration/GoogleCloudStorageContainerIntegrationLiveTest.java
@@ -97,7 +97,8 @@ public class GoogleCloudStorageContainerIntegrationLiveTest extends BaseContaine
 
    @Override
    public void testDirectory() throws InterruptedException {
-      // GoogleCloudStorage does not support directories, rather it supports prefixes which look like directories.
+      // TODO: testDirectory fails when querying blob with name "directory/directory"; querying "directory%2Fdirectory"
+      // succeeds, however. I believe this is an escaping issue that should be addressed.
       throw new SkipException("directories are not supported in GoogleCloudStorage");
    }
 


[3/4] jclouds-labs-google git commit: Simplify list handling.

Posted by ga...@apache.org.
Simplify list handling.


Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/commit/72473dc0
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/tree/72473dc0
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/diff/72473dc0

Branch: refs/heads/master
Commit: 72473dc038592036e9cb30372fb93c9cd9a17fcc
Parents: 6e00fb4
Author: Timur Alperovich <ti...@gmail.com>
Authored: Thu Aug 20 17:14:00 2015 -0700
Committer: Timur Alperovich <ti...@gmail.com>
Committed: Thu Aug 20 17:55:55 2015 -0700

----------------------------------------------------------------------
 .../blobstore/GoogleCloudStorageBlobStore.java      | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/72473dc0/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/GoogleCloudStorageBlobStore.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/GoogleCloudStorageBlobStore.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/GoogleCloudStorageBlobStore.java
index 7fd3643..924fad3 100644
--- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/GoogleCloudStorageBlobStore.java
+++ b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/GoogleCloudStorageBlobStore.java
@@ -187,21 +187,15 @@ public final class GoogleCloudStorageBlobStore extends BaseBlobStore {
    /** Returns list of of all the objects */
    @Override
    public PageSet<? extends StorageMetadata> list(String container) {
-      ListPageWithPrefixes<GoogleCloudStorageObject> gcsList = api.getObjectApi().listObjects(container);
-      PageSet<? extends StorageMetadata> list = objectListToStorageMetadata.apply(gcsList);
-      return list;
+      return list(container, ListContainerOptions.NONE);
    }
 
    @Override
    public PageSet<? extends StorageMetadata> list(String container, ListContainerOptions options) {
-      if (options != null && options != ListContainerOptions.NONE) {
-         ListObjectOptions listOptions = listContainerOptionsToListObjectOptions.apply(options);
-         ListPageWithPrefixes<GoogleCloudStorageObject> gcsList = api.getObjectApi().listObjects(container, listOptions);
-         PageSet<? extends StorageMetadata> list = objectListToStorageMetadata.apply(gcsList);
-         return options.isDetailed() ? fetchBlobMetadataProvider.get().setContainerName(container).apply(list) : list;
-      } else {
-         return list(container);
-      }
+      ListObjectOptions listOptions = listContainerOptionsToListObjectOptions.apply(options);
+      ListPageWithPrefixes<GoogleCloudStorageObject> gcsList = api.getObjectApi().listObjects(container, listOptions);
+      PageSet<? extends StorageMetadata> list = objectListToStorageMetadata.apply(gcsList);
+      return options.isDetailed() ? fetchBlobMetadataProvider.get().setContainerName(container).apply(list) : list;
    }
 
    /**