You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ad...@apache.org on 2014/11/17 22:37:58 UTC
[2/3] jclouds-labs-google git commit: Be consistent in naming,
as opposed to GCS here and GoogleCloudStorage there.
Be consistent in naming, as opposed to GCS here and GoogleCloudStorage there.
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/4d3449f1
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/tree/4d3449f1
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/diff/4d3449f1
Branch: refs/heads/master
Commit: 4d3449f1cc41c1607ca09b604e878a8c3920e627
Parents: 737495c
Author: Adrian Cole <ad...@gmail.com>
Authored: Sun Nov 16 19:51:02 2014 -0800
Committer: Adrian Cole <ac...@twitter.com>
Committed: Mon Nov 17 13:34:52 2014 -0800
----------------------------------------------------------------------
.../GoogleCloudStorageApi.java | 2 -
.../blobstore/GCSBlobStore.java | 254 ------------------
.../blobstore/GoogleCloudStorageBlobStore.java | 254 ++++++++++++++++++
...oogleCloudStorageBlobStoreContextModule.java | 4 +-
.../functions/ObjectListToStorageMetadata.java | 6 +-
.../functions/ObjectToBlobMetadata.java | 6 +-
.../SequentialMultipartUploadStrategy.java | 6 +-
.../googlecloudstorage/domain/GCSObject.java | 79 ------
.../domain/GoogleCloudStorageObject.java | 79 ++++++
.../domain/templates/ComposeObjectTemplate.java | 6 +-
.../googlecloudstorage/features/ObjectApi.java | 56 ++--
.../features/ResumableUploadApi.java | 2 +-
.../integration/GCSBlobIntegrationLiveTest.java | 260 -------------------
.../blobstore/integration/GCSBlobLiveTest.java | 114 --------
.../GCSContainerIntegrationLiveTest.java | 102 --------
.../integration/GCSContainerLiveTest.java | 35 ---
...ogleCloudStorageBlobIntegrationLiveTest.java | 260 +++++++++++++++++++
.../GoogleCloudStorageBlobLiveTest.java | 114 ++++++++
...loudStorageContainerIntegrationLiveTest.java | 102 ++++++++
.../GoogleCloudStorageContainerLiveTest.java | 35 +++
.../features/ObjectApiLiveTest.java | 42 +--
21 files changed, 908 insertions(+), 910 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/4d3449f1/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/GoogleCloudStorageApi.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/GoogleCloudStorageApi.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/GoogleCloudStorageApi.java
index eb930df..eec5294 100644
--- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/GoogleCloudStorageApi.java
+++ b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/GoogleCloudStorageApi.java
@@ -67,13 +67,11 @@ public interface GoogleCloudStorageApi extends Closeable {
* Provides access to Google Cloud Storage Object features
*/
@Delegate
- @Path("")
ObjectApi getObjectApi();
/**
* Provides access to Google Cloud Storage ResumableUpload features
*/
@Delegate
- @Path("")
ResumableUploadApi getResumableUploadApi();
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/4d3449f1/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/GCSBlobStore.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/GCSBlobStore.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/GCSBlobStore.java
deleted file mode 100644
index 186fc9b..0000000
--- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/GCSBlobStore.java
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.googlecloudstorage.blobstore;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.io.BaseEncoding.base64;
-import static org.jclouds.googlecloudstorage.domain.DomainResourceReferences.ObjectRole.READER;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-import java.util.Set;
-
-import javax.inject.Inject;
-
-import org.jclouds.blobstore.BlobStoreContext;
-import org.jclouds.blobstore.domain.Blob;
-import org.jclouds.blobstore.domain.BlobMetadata;
-import org.jclouds.blobstore.domain.MutableBlobMetadata;
-import org.jclouds.blobstore.domain.PageSet;
-import org.jclouds.blobstore.domain.StorageMetadata;
-import org.jclouds.blobstore.domain.internal.BlobImpl;
-import org.jclouds.blobstore.domain.internal.PageSetImpl;
-import org.jclouds.blobstore.internal.BaseBlobStore;
-import org.jclouds.blobstore.options.CreateContainerOptions;
-import org.jclouds.blobstore.options.GetOptions;
-import org.jclouds.blobstore.options.ListContainerOptions;
-import org.jclouds.blobstore.options.PutOptions;
-import org.jclouds.blobstore.strategy.internal.FetchBlobMetadata;
-import org.jclouds.blobstore.util.BlobUtils;
-import org.jclouds.collect.Memoized;
-import org.jclouds.domain.Location;
-import org.jclouds.googlecloud.config.CurrentProject;
-import org.jclouds.googlecloud.domain.ListPage;
-import org.jclouds.googlecloudstorage.GoogleCloudStorageApi;
-import org.jclouds.googlecloudstorage.blobstore.functions.BlobMetadataToObjectTemplate;
-import org.jclouds.googlecloudstorage.blobstore.functions.BlobStoreListContainerOptionsToListObjectOptions;
-import org.jclouds.googlecloudstorage.blobstore.functions.BucketToStorageMetadata;
-import org.jclouds.googlecloudstorage.blobstore.functions.ObjectListToStorageMetadata;
-import org.jclouds.googlecloudstorage.blobstore.functions.ObjectToBlobMetadata;
-import org.jclouds.googlecloudstorage.blobstore.strategy.internal.MultipartUploadStrategy;
-import org.jclouds.googlecloudstorage.domain.Bucket;
-import org.jclouds.googlecloudstorage.domain.DomainResourceReferences;
-import org.jclouds.googlecloudstorage.domain.GCSObject;
-import org.jclouds.googlecloudstorage.domain.ListPageWithPrefixes;
-import org.jclouds.googlecloudstorage.domain.templates.BucketTemplate;
-import org.jclouds.googlecloudstorage.domain.templates.ObjectAccessControlsTemplate;
-import org.jclouds.googlecloudstorage.domain.templates.ObjectTemplate;
-import org.jclouds.googlecloudstorage.options.ListObjectOptions;
-import org.jclouds.http.HttpResponseException;
-import org.jclouds.io.Payload;
-
-import com.google.common.base.Charsets;
-import com.google.common.base.Function;
-import com.google.common.base.Supplier;
-import com.google.common.base.Throwables;
-import com.google.common.collect.Iterables;
-import com.google.common.hash.HashCode;
-import com.google.inject.Provider;
-
-public final class GCSBlobStore extends BaseBlobStore {
-
- private final GoogleCloudStorageApi api;
- private final BucketToStorageMetadata bucketToStorageMetadata;
- private final ObjectToBlobMetadata objectToBlobMetadata;
- private final ObjectListToStorageMetadata objectListToStorageMetadata;
- private final Provider<FetchBlobMetadata> fetchBlobMetadataProvider;
- private final BlobMetadataToObjectTemplate blobMetadataToObjectTemplate;
- private final BlobStoreListContainerOptionsToListObjectOptions listContainerOptionsToListObjectOptions;
- private final MultipartUploadStrategy multipartUploadStrategy;
- private final Supplier<String> projectId;
-
- @Inject GCSBlobStore(BlobStoreContext context, BlobUtils blobUtils, Supplier<Location> defaultLocation,
- @Memoized Supplier<Set<? extends Location>> locations, GoogleCloudStorageApi api,
- BucketToStorageMetadata bucketToStorageMetadata, ObjectToBlobMetadata objectToBlobMetadata,
- ObjectListToStorageMetadata objectListToStorageMetadata,
- Provider<FetchBlobMetadata> fetchBlobMetadataProvider,
- BlobMetadataToObjectTemplate blobMetadataToObjectTemplate,
- BlobStoreListContainerOptionsToListObjectOptions listContainerOptionsToListObjectOptions,
- MultipartUploadStrategy multipartUploadStrategy, @CurrentProject Supplier<String> projectId) {
- super(context, blobUtils, defaultLocation, locations);
- this.api = api;
- this.bucketToStorageMetadata = bucketToStorageMetadata;
- this.objectToBlobMetadata = objectToBlobMetadata;
- this.objectListToStorageMetadata = objectListToStorageMetadata;
- this.fetchBlobMetadataProvider = checkNotNull(fetchBlobMetadataProvider, "fetchBlobMetadataProvider");
- this.blobMetadataToObjectTemplate = blobMetadataToObjectTemplate;
- this.listContainerOptionsToListObjectOptions = listContainerOptionsToListObjectOptions;
- this.projectId = projectId;
- this.multipartUploadStrategy = multipartUploadStrategy;
- }
-
- @Override
- public PageSet<? extends StorageMetadata> list() {
- return new Function<ListPage<Bucket>, PageSet<? extends StorageMetadata>>() {
- public PageSet<? extends StorageMetadata> apply(ListPage<Bucket> from) {
- return new PageSetImpl<StorageMetadata>(Iterables.transform(from, bucketToStorageMetadata),
- from.nextPageToken());
- }
- }.apply(api.getBucketApi().listBucket(projectId.get()));
- }
-
- @Override
- public boolean containerExists(String container) {
- return api.getBucketApi().bucketExist(container);
- }
-
- @Override
- public boolean createContainerInLocation(Location location, String container) {
- BucketTemplate template = new BucketTemplate().name(container);
- if (location != null) {
- DomainResourceReferences.Location gcsLocation = DomainResourceReferences.Location.fromValue(location.getId());
- template = template.location(gcsLocation);
- }
- return api.getBucketApi().createBucket(projectId.get(), template) != null;
- }
-
- @Override
- public boolean createContainerInLocation(Location location, String container, CreateContainerOptions options) {
- BucketTemplate template = new BucketTemplate().name(container);
- if (location != null) {
- DomainResourceReferences.Location gcsLocation = DomainResourceReferences.Location.fromValue(location.getId());
- template = template.location(gcsLocation);
- }
- Bucket bucket = api.getBucketApi().createBucket(projectId.get(), template);
- if (options.isPublicRead()) {
- try {
- ObjectAccessControlsTemplate doAclTemplate = ObjectAccessControlsTemplate.create("allUsers", READER);
- api.getDefaultObjectAccessControlsApi().createDefaultObjectAccessControls(container, doAclTemplate);
- } catch (HttpResponseException e) {
- // If DefaultObjectAccessControls operation fail, Reverse create operation the operation.
- api.getBucketApi().deleteBucket(container);
- return false;
- }
- }
-
- return bucket != null;
- }
-
- /** Returns list of of all the objects */
- @Override
- public PageSet<? extends StorageMetadata> list(String container) {
- ListPageWithPrefixes<GCSObject> gcsList = api.getObjectApi().listObjects(container);
- PageSet<? extends StorageMetadata> list = objectListToStorageMetadata.apply(gcsList);
- return list;
- }
-
- @Override
- public PageSet<? extends StorageMetadata> list(String container, ListContainerOptions options) {
- if (options != null && options != ListContainerOptions.NONE) {
- ListObjectOptions listOptions = listContainerOptionsToListObjectOptions.apply(options);
- ListPageWithPrefixes<GCSObject> 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);
- }
- }
-
- /**
- * Checks whether an accessible object is available. Google cloud storage does not support directly support
- * BucketExist or ObjectExist operations
- */
- @Override
- public boolean blobExists(String container, String name) {
- try {
- String urlName = name.contains("/") ? URLEncoder.encode(name, Charsets.UTF_8.toString()) : name;
- return api.getObjectApi().objectExists(container, urlName);
- } catch (UnsupportedEncodingException e) {
- throw Throwables.propagate(e);
- }
- }
-
- /**
- * This supports multipart/related upload which has exactly 2 parts, media-part and metadata-part
- */
- @Override
- public String putBlob(String container, Blob blob) {
- checkNotNull(blob.getPayload().getContentMetadata().getContentLength());
- HashCode md5 = blob.getMetadata().getContentMetadata().getContentMD5AsHashCode();
-
- ObjectTemplate template = blobMetadataToObjectTemplate.apply(blob.getMetadata());
-
- if (md5 != null) {
- template.md5Hash(base64().encode(md5.asBytes()));
- }
- return api.getObjectApi().multipartUpload(container, template, blob.getPayload()).etag();
- }
-
- @Override
- public String putBlob(String container, Blob blob, PutOptions options) {
- if (options.multipart().isMultipart()) {
- return multipartUploadStrategy.execute(container, blob);
- } else {
- return putBlob(container, blob);
- }
- }
-
- @Override
- public BlobMetadata blobMetadata(String container, String name) {
- return objectToBlobMetadata.apply(api.getObjectApi().getObject(container, name));
- }
-
- @Override
- public Blob getBlob(String container, String name, GetOptions options) {
- GCSObject gcsObject = api.getObjectApi().getObject(container, name);
- if (gcsObject == null) {
- return null;
- }
- MutableBlobMetadata metadata = objectToBlobMetadata.apply(gcsObject);
- Blob blob = new BlobImpl(metadata);
- // TODO: Does getObject not get the payload?!
- Payload payload = api.getObjectApi().download(container, name).getPayload();
- payload.setContentMetadata(metadata.getContentMetadata()); // Doing this first retains it on setPayload.
- blob.setPayload(payload);
- return blob;
- }
-
- @Override
- public void removeBlob(String container, String name) {
- String urlName;
- try {
- urlName = name.contains("/") ? URLEncoder.encode(name, Charsets.UTF_8.toString()) : name;
- } catch (UnsupportedEncodingException uee) {
- throw Throwables.propagate(uee);
- }
- api.getObjectApi().deleteObject(container, urlName);
- }
-
- @Override
- protected boolean deleteAndVerifyContainerGone(String container) {
- ListPageWithPrefixes<GCSObject> list = api.getObjectApi().listObjects(container);
- if (list == null) {
- return api.getBucketApi().deleteBucket(container);
- }
- if (!list.iterator().hasNext() && list.prefixes().isEmpty())
- return api.getBucketApi().deleteBucket(container);
-
- return false;
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/4d3449f1/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
new file mode 100644
index 0000000..c3f2fd8
--- /dev/null
+++ b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/GoogleCloudStorageBlobStore.java
@@ -0,0 +1,254 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecloudstorage.blobstore;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.io.BaseEncoding.base64;
+import static org.jclouds.googlecloudstorage.domain.DomainResourceReferences.ObjectRole.READER;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.util.Set;
+
+import javax.inject.Inject;
+
+import org.jclouds.blobstore.BlobStoreContext;
+import org.jclouds.blobstore.domain.Blob;
+import org.jclouds.blobstore.domain.BlobMetadata;
+import org.jclouds.blobstore.domain.MutableBlobMetadata;
+import org.jclouds.blobstore.domain.PageSet;
+import org.jclouds.blobstore.domain.StorageMetadata;
+import org.jclouds.blobstore.domain.internal.BlobImpl;
+import org.jclouds.blobstore.domain.internal.PageSetImpl;
+import org.jclouds.blobstore.internal.BaseBlobStore;
+import org.jclouds.blobstore.options.CreateContainerOptions;
+import org.jclouds.blobstore.options.GetOptions;
+import org.jclouds.blobstore.options.ListContainerOptions;
+import org.jclouds.blobstore.options.PutOptions;
+import org.jclouds.blobstore.strategy.internal.FetchBlobMetadata;
+import org.jclouds.blobstore.util.BlobUtils;
+import org.jclouds.collect.Memoized;
+import org.jclouds.domain.Location;
+import org.jclouds.googlecloud.config.CurrentProject;
+import org.jclouds.googlecloud.domain.ListPage;
+import org.jclouds.googlecloudstorage.GoogleCloudStorageApi;
+import org.jclouds.googlecloudstorage.blobstore.functions.BlobMetadataToObjectTemplate;
+import org.jclouds.googlecloudstorage.blobstore.functions.BlobStoreListContainerOptionsToListObjectOptions;
+import org.jclouds.googlecloudstorage.blobstore.functions.BucketToStorageMetadata;
+import org.jclouds.googlecloudstorage.blobstore.functions.ObjectListToStorageMetadata;
+import org.jclouds.googlecloudstorage.blobstore.functions.ObjectToBlobMetadata;
+import org.jclouds.googlecloudstorage.blobstore.strategy.internal.MultipartUploadStrategy;
+import org.jclouds.googlecloudstorage.domain.Bucket;
+import org.jclouds.googlecloudstorage.domain.DomainResourceReferences;
+import org.jclouds.googlecloudstorage.domain.GoogleCloudStorageObject;
+import org.jclouds.googlecloudstorage.domain.ListPageWithPrefixes;
+import org.jclouds.googlecloudstorage.domain.templates.BucketTemplate;
+import org.jclouds.googlecloudstorage.domain.templates.ObjectAccessControlsTemplate;
+import org.jclouds.googlecloudstorage.domain.templates.ObjectTemplate;
+import org.jclouds.googlecloudstorage.options.ListObjectOptions;
+import org.jclouds.http.HttpResponseException;
+import org.jclouds.io.Payload;
+
+import com.google.common.base.Charsets;
+import com.google.common.base.Function;
+import com.google.common.base.Supplier;
+import com.google.common.base.Throwables;
+import com.google.common.collect.Iterables;
+import com.google.common.hash.HashCode;
+import com.google.inject.Provider;
+
+public final class GoogleCloudStorageBlobStore extends BaseBlobStore {
+
+ private final GoogleCloudStorageApi api;
+ private final BucketToStorageMetadata bucketToStorageMetadata;
+ private final ObjectToBlobMetadata objectToBlobMetadata;
+ private final ObjectListToStorageMetadata objectListToStorageMetadata;
+ private final Provider<FetchBlobMetadata> fetchBlobMetadataProvider;
+ private final BlobMetadataToObjectTemplate blobMetadataToObjectTemplate;
+ private final BlobStoreListContainerOptionsToListObjectOptions listContainerOptionsToListObjectOptions;
+ private final MultipartUploadStrategy multipartUploadStrategy;
+ private final Supplier<String> projectId;
+
+ @Inject GoogleCloudStorageBlobStore(BlobStoreContext context, BlobUtils blobUtils, Supplier<Location> defaultLocation,
+ @Memoized Supplier<Set<? extends Location>> locations, GoogleCloudStorageApi api,
+ BucketToStorageMetadata bucketToStorageMetadata, ObjectToBlobMetadata objectToBlobMetadata,
+ ObjectListToStorageMetadata objectListToStorageMetadata,
+ Provider<FetchBlobMetadata> fetchBlobMetadataProvider,
+ BlobMetadataToObjectTemplate blobMetadataToObjectTemplate,
+ BlobStoreListContainerOptionsToListObjectOptions listContainerOptionsToListObjectOptions,
+ MultipartUploadStrategy multipartUploadStrategy, @CurrentProject Supplier<String> projectId) {
+ super(context, blobUtils, defaultLocation, locations);
+ this.api = api;
+ this.bucketToStorageMetadata = bucketToStorageMetadata;
+ this.objectToBlobMetadata = objectToBlobMetadata;
+ this.objectListToStorageMetadata = objectListToStorageMetadata;
+ this.fetchBlobMetadataProvider = checkNotNull(fetchBlobMetadataProvider, "fetchBlobMetadataProvider");
+ this.blobMetadataToObjectTemplate = blobMetadataToObjectTemplate;
+ this.listContainerOptionsToListObjectOptions = listContainerOptionsToListObjectOptions;
+ this.projectId = projectId;
+ this.multipartUploadStrategy = multipartUploadStrategy;
+ }
+
+ @Override
+ public PageSet<? extends StorageMetadata> list() {
+ return new Function<ListPage<Bucket>, PageSet<? extends StorageMetadata>>() {
+ public PageSet<? extends StorageMetadata> apply(ListPage<Bucket> from) {
+ return new PageSetImpl<StorageMetadata>(Iterables.transform(from, bucketToStorageMetadata),
+ from.nextPageToken());
+ }
+ }.apply(api.getBucketApi().listBucket(projectId.get()));
+ }
+
+ @Override
+ public boolean containerExists(String container) {
+ return api.getBucketApi().bucketExist(container);
+ }
+
+ @Override
+ public boolean createContainerInLocation(Location location, String container) {
+ BucketTemplate template = new BucketTemplate().name(container);
+ if (location != null) {
+ DomainResourceReferences.Location gcsLocation = DomainResourceReferences.Location.fromValue(location.getId());
+ template = template.location(gcsLocation);
+ }
+ return api.getBucketApi().createBucket(projectId.get(), template) != null;
+ }
+
+ @Override
+ public boolean createContainerInLocation(Location location, String container, CreateContainerOptions options) {
+ BucketTemplate template = new BucketTemplate().name(container);
+ if (location != null) {
+ DomainResourceReferences.Location gcsLocation = DomainResourceReferences.Location.fromValue(location.getId());
+ template = template.location(gcsLocation);
+ }
+ Bucket bucket = api.getBucketApi().createBucket(projectId.get(), template);
+ if (options.isPublicRead()) {
+ try {
+ ObjectAccessControlsTemplate doAclTemplate = ObjectAccessControlsTemplate.create("allUsers", READER);
+ api.getDefaultObjectAccessControlsApi().createDefaultObjectAccessControls(container, doAclTemplate);
+ } catch (HttpResponseException e) {
+ // If DefaultObjectAccessControls operation fail, Reverse create operation the operation.
+ api.getBucketApi().deleteBucket(container);
+ return false;
+ }
+ }
+
+ return bucket != null;
+ }
+
+ /** 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;
+ }
+
+ @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);
+ }
+ }
+
+ /**
+ * Checks whether an accessible object is available. Google cloud storage does not support directly support
+ * BucketExist or ObjectExist operations
+ */
+ @Override
+ public boolean blobExists(String container, String name) {
+ try {
+ String urlName = name.contains("/") ? URLEncoder.encode(name, Charsets.UTF_8.toString()) : name;
+ return api.getObjectApi().objectExists(container, urlName);
+ } catch (UnsupportedEncodingException e) {
+ throw Throwables.propagate(e);
+ }
+ }
+
+ /**
+ * This supports multipart/related upload which has exactly 2 parts, media-part and metadata-part
+ */
+ @Override
+ public String putBlob(String container, Blob blob) {
+ checkNotNull(blob.getPayload().getContentMetadata().getContentLength());
+ HashCode md5 = blob.getMetadata().getContentMetadata().getContentMD5AsHashCode();
+
+ ObjectTemplate template = blobMetadataToObjectTemplate.apply(blob.getMetadata());
+
+ if (md5 != null) {
+ template.md5Hash(base64().encode(md5.asBytes()));
+ }
+ return api.getObjectApi().multipartUpload(container, template, blob.getPayload()).etag();
+ }
+
+ @Override
+ public String putBlob(String container, Blob blob, PutOptions options) {
+ if (options.multipart().isMultipart()) {
+ return multipartUploadStrategy.execute(container, blob);
+ } else {
+ return putBlob(container, blob);
+ }
+ }
+
+ @Override
+ public BlobMetadata blobMetadata(String container, String name) {
+ return objectToBlobMetadata.apply(api.getObjectApi().getObject(container, name));
+ }
+
+ @Override
+ public Blob getBlob(String container, String name, GetOptions options) {
+ GoogleCloudStorageObject gcsObject = api.getObjectApi().getObject(container, name);
+ if (gcsObject == null) {
+ return null;
+ }
+ MutableBlobMetadata metadata = objectToBlobMetadata.apply(gcsObject);
+ Blob blob = new BlobImpl(metadata);
+ // TODO: Does getObject not get the payload?!
+ Payload payload = api.getObjectApi().download(container, name).getPayload();
+ payload.setContentMetadata(metadata.getContentMetadata()); // Doing this first retains it on setPayload.
+ blob.setPayload(payload);
+ return blob;
+ }
+
+ @Override
+ public void removeBlob(String container, String name) {
+ String urlName;
+ try {
+ urlName = name.contains("/") ? URLEncoder.encode(name, Charsets.UTF_8.toString()) : name;
+ } catch (UnsupportedEncodingException uee) {
+ throw Throwables.propagate(uee);
+ }
+ api.getObjectApi().deleteObject(container, urlName);
+ }
+
+ @Override
+ protected boolean deleteAndVerifyContainerGone(String container) {
+ ListPageWithPrefixes<GoogleCloudStorageObject> list = api.getObjectApi().listObjects(container);
+ if (list == null) {
+ return api.getBucketApi().deleteBucket(container);
+ }
+ if (!list.iterator().hasNext() && list.prefixes().isEmpty())
+ return api.getBucketApi().deleteBucket(container);
+
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/4d3449f1/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/config/GoogleCloudStorageBlobStoreContextModule.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/config/GoogleCloudStorageBlobStoreContextModule.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/config/GoogleCloudStorageBlobStoreContextModule.java
index 85560e3..3d2bcd7 100644
--- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/config/GoogleCloudStorageBlobStoreContextModule.java
+++ b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/config/GoogleCloudStorageBlobStoreContextModule.java
@@ -18,7 +18,7 @@ package org.jclouds.googlecloudstorage.blobstore.config;
import org.jclouds.blobstore.BlobStore;
import org.jclouds.blobstore.attr.ConsistencyModel;
-import org.jclouds.googlecloudstorage.blobstore.GCSBlobStore;
+import org.jclouds.googlecloudstorage.blobstore.GoogleCloudStorageBlobStore;
import com.google.inject.AbstractModule;
import com.google.inject.Scopes;
@@ -28,6 +28,6 @@ public class GoogleCloudStorageBlobStoreContextModule extends AbstractModule {
@Override
protected void configure() {
bind(ConsistencyModel.class).toInstance(ConsistencyModel.EVENTUAL);
- bind(BlobStore.class).to(GCSBlobStore.class).in(Scopes.SINGLETON);
+ bind(BlobStore.class).to(GoogleCloudStorageBlobStore.class).in(Scopes.SINGLETON);
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/4d3449f1/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 edc931d..008cb46 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
@@ -26,7 +26,7 @@ import org.jclouds.blobstore.domain.StorageMetadata;
import org.jclouds.blobstore.domain.StorageType;
import org.jclouds.blobstore.domain.internal.PageSetImpl;
import org.jclouds.blobstore.domain.internal.StorageMetadataImpl;
-import org.jclouds.googlecloudstorage.domain.GCSObject;
+import org.jclouds.googlecloudstorage.domain.GoogleCloudStorageObject;
import org.jclouds.googlecloudstorage.domain.ListPageWithPrefixes;
import com.google.common.base.Function;
@@ -34,14 +34,14 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
public class ObjectListToStorageMetadata
- implements Function<ListPageWithPrefixes<GCSObject>, PageSet<? extends StorageMetadata>> {
+ implements Function<ListPageWithPrefixes<GoogleCloudStorageObject>, PageSet<? extends StorageMetadata>> {
private final ObjectToBlobMetadata object2blobMd;
@Inject public ObjectListToStorageMetadata(ObjectToBlobMetadata object2blobMd) {
this.object2blobMd = object2blobMd;
}
- public PageSet<? extends StorageMetadata> apply(ListPageWithPrefixes<GCSObject> from) {
+ public PageSet<? extends StorageMetadata> apply(ListPageWithPrefixes<GoogleCloudStorageObject> from) {
if (from == null) {
from = ListPageWithPrefixes.create(null, null, null);
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/4d3449f1/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 8515b3f..636e332 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
@@ -22,21 +22,21 @@ 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.GCSObject;
+import org.jclouds.googlecloudstorage.domain.GoogleCloudStorageObject;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Function;
import com.google.common.hash.HashCode;
import com.google.common.io.BaseEncoding;
-public class ObjectToBlobMetadata implements Function<GCSObject, MutableBlobMetadata> {
+public class ObjectToBlobMetadata implements Function<GoogleCloudStorageObject, MutableBlobMetadata> {
private final IfDirectoryReturnNameStrategy ifDirectoryReturnName;
@Inject public ObjectToBlobMetadata(IfDirectoryReturnNameStrategy ifDirectoryReturnName) {
this.ifDirectoryReturnName = ifDirectoryReturnName;
}
- public MutableBlobMetadata apply(GCSObject from) {
+ public MutableBlobMetadata apply(GoogleCloudStorageObject from) {
if (from == null) {
return null;
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/4d3449f1/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/strategy/internal/SequentialMultipartUploadStrategy.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/strategy/internal/SequentialMultipartUploadStrategy.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/strategy/internal/SequentialMultipartUploadStrategy.java
index 3ee612d..137372d 100644
--- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/strategy/internal/SequentialMultipartUploadStrategy.java
+++ b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/strategy/internal/SequentialMultipartUploadStrategy.java
@@ -26,7 +26,7 @@ import org.jclouds.blobstore.domain.Blob;
import org.jclouds.blobstore.domain.BlobBuilder;
import org.jclouds.googlecloudstorage.GoogleCloudStorageApi;
import org.jclouds.googlecloudstorage.blobstore.functions.BlobMetadataToObjectTemplate;
-import org.jclouds.googlecloudstorage.domain.GCSObject;
+import org.jclouds.googlecloudstorage.domain.GoogleCloudStorageObject;
import org.jclouds.googlecloudstorage.domain.templates.ComposeObjectTemplate;
import org.jclouds.googlecloudstorage.domain.templates.ObjectTemplate;
import org.jclouds.io.Payload;
@@ -60,7 +60,7 @@ public final class SequentialMultipartUploadStrategy extends MultipartUploadStra
ObjectTemplate destination = blob2ObjectTemplate.apply(blob.getMetadata());
- List<GCSObject> sourceList = Lists.newArrayList();
+ List<GoogleCloudStorageObject> sourceList = Lists.newArrayList();
String key = blob.getMetadata().getName();
Payload payload = blob.getPayload();
@@ -81,7 +81,7 @@ public final class SequentialMultipartUploadStrategy extends MultipartUploadStra
Blob blobPart = blobBuilders.get().name(partName).payload(part).contentDisposition(partName)
.contentLength(partSize).contentType(blob.getMetadata().getContentMetadata().getContentType())
.build();
- GCSObject object = api.getObjectApi().multipartUpload(container,
+ GoogleCloudStorageObject object = api.getObjectApi().multipartUpload(container,
blob2ObjectTemplate.apply(blobPart.getMetadata()), blobPart.getPayload());
sourceList.add(object);
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/4d3449f1/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/GCSObject.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/GCSObject.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/GCSObject.java
deleted file mode 100644
index 9a38781..0000000
--- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/GCSObject.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jclouds.googlecloudstorage.domain;
-
-import static org.jclouds.googlecloud.internal.NullSafeCopies.copyOf;
-
-import java.net.URI;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-
-import org.jclouds.googlecloudstorage.domain.DomainResourceReferences.StorageClass;
-import org.jclouds.javax.annotation.Nullable;
-import org.jclouds.json.SerializedNames;
-
-import com.google.auto.value.AutoValue;
-
-/**
- * This class represent an object in a Google Cloud Storage Bucket.
- *
- * @see <a href = "https://developers.google.com/storage/docs/json_api/v1/Objects"/>
- */
-@AutoValue
-// TODO: nullable sweep
-public abstract class GCSObject {
-
- public abstract String id();
- public abstract URI selfLink();
- public abstract String etag();
- public abstract String name();
- public abstract String bucket();
- public abstract long generation();
- public abstract long metageneration();
- public abstract String contentType();
- public abstract Date updated();
- @Nullable public abstract Date timeDeleted();
- public abstract StorageClass storageClass();
- public abstract long size();
- @Nullable public abstract String md5Hash();
- public abstract URI mediaLink();
- public abstract Map<String, String> metadata();
- @Nullable public abstract String contentEncoding();
- @Nullable public abstract String contentDisposition();
- @Nullable public abstract String contentLanguage();
- @Nullable public abstract String cacheControl();
- public abstract List<ObjectAccessControls> acl();
- public abstract Owner owner();
- @Nullable public abstract String crc32c();
- @Nullable public abstract Integer componentCount();
-
- @SerializedNames(
- { "id", "selfLink", "etag", "name", "bucket", "generation", "metageneration", "contentType", "updated",
- "timeDeleted", "storageClass", "size", "md5Hash", "mediaLink", "metadata", "contentEncoding",
- "contentDisposition", "contentLanguage", "cacheControl", "acl", "owner", "crc32c", "componentCount" })
- public static GCSObject create(String id, URI selfLink, String etag, String name, String bucket, long generation,
- long metageneration, String contentType, Date updated, Date timeDeleted, StorageClass storageClass, long size,
- String md5Hash, URI mediaLink, Map<String, String> metadata, String contentEncoding, String contentDisposition,
- String contentLanguage, String cacheControl, List<ObjectAccessControls> acl, Owner owner, String crc32c,
- Integer componentCount) {
- return new AutoValue_GCSObject(id, selfLink, etag, name, bucket, generation, metageneration, contentType, updated,
- timeDeleted, storageClass, size, md5Hash, mediaLink, copyOf(metadata), contentEncoding, contentDisposition,
- contentLanguage, cacheControl, copyOf(acl), owner, crc32c, componentCount);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/4d3449f1/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/GoogleCloudStorageObject.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/GoogleCloudStorageObject.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/GoogleCloudStorageObject.java
new file mode 100644
index 0000000..f8bd84b
--- /dev/null
+++ b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/GoogleCloudStorageObject.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jclouds.googlecloudstorage.domain;
+
+import static org.jclouds.googlecloud.internal.NullSafeCopies.copyOf;
+
+import java.net.URI;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import org.jclouds.googlecloudstorage.domain.DomainResourceReferences.StorageClass;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.json.SerializedNames;
+
+import com.google.auto.value.AutoValue;
+
+/**
+ * This class represent an object in a Google Cloud Storage Bucket.
+ *
+ * @see <a href = "https://developers.google.com/storage/docs/json_api/v1/Objects"/>
+ */
+@AutoValue
+// TODO: nullable sweep
+public abstract class GoogleCloudStorageObject {
+
+ public abstract String id();
+ public abstract URI selfLink();
+ public abstract String etag();
+ public abstract String name();
+ public abstract String bucket();
+ public abstract long generation();
+ public abstract long metageneration();
+ public abstract String contentType();
+ public abstract Date updated();
+ @Nullable public abstract Date timeDeleted();
+ public abstract StorageClass storageClass();
+ public abstract long size();
+ @Nullable public abstract String md5Hash();
+ public abstract URI mediaLink();
+ public abstract Map<String, String> metadata();
+ @Nullable public abstract String contentEncoding();
+ @Nullable public abstract String contentDisposition();
+ @Nullable public abstract String contentLanguage();
+ @Nullable public abstract String cacheControl();
+ public abstract List<ObjectAccessControls> acl();
+ public abstract Owner owner();
+ @Nullable public abstract String crc32c();
+ @Nullable public abstract Integer componentCount();
+
+ @SerializedNames(
+ { "id", "selfLink", "etag", "name", "bucket", "generation", "metageneration", "contentType", "updated",
+ "timeDeleted", "storageClass", "size", "md5Hash", "mediaLink", "metadata", "contentEncoding",
+ "contentDisposition", "contentLanguage", "cacheControl", "acl", "owner", "crc32c", "componentCount" })
+ public static GoogleCloudStorageObject create(String id, URI selfLink, String etag, String name, String bucket, long generation,
+ long metageneration, String contentType, Date updated, Date timeDeleted, StorageClass storageClass, long size,
+ String md5Hash, URI mediaLink, Map<String, String> metadata, String contentEncoding, String contentDisposition,
+ String contentLanguage, String cacheControl, List<ObjectAccessControls> acl, Owner owner, String crc32c,
+ Integer componentCount) {
+ return new AutoValue_GoogleCloudStorageObject(id, selfLink, etag, name, bucket, generation, metageneration, contentType, updated,
+ timeDeleted, storageClass, size, md5Hash, mediaLink, copyOf(metadata), contentEncoding, contentDisposition,
+ contentLanguage, cacheControl, copyOf(acl), owner, crc32c, componentCount);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/4d3449f1/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/templates/ComposeObjectTemplate.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/templates/ComposeObjectTemplate.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/templates/ComposeObjectTemplate.java
index 0af32ea..669a8f1 100644
--- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/templates/ComposeObjectTemplate.java
+++ b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/templates/ComposeObjectTemplate.java
@@ -19,7 +19,7 @@ package org.jclouds.googlecloudstorage.domain.templates;
import java.util.List;
-import org.jclouds.googlecloudstorage.domain.GCSObject;
+import org.jclouds.googlecloudstorage.domain.GoogleCloudStorageObject;
import com.google.auto.value.AutoValue;
@@ -28,11 +28,11 @@ public abstract class ComposeObjectTemplate {
private final String kind = "storage/composeRequest";
- public abstract List<GCSObject> sourceObjects();
+ public abstract List<GoogleCloudStorageObject> sourceObjects();
public abstract ObjectTemplate destination();
- public static ComposeObjectTemplate create(List<GCSObject> sourceObjects, ObjectTemplate destination) {
+ public static ComposeObjectTemplate create(List<GoogleCloudStorageObject> sourceObjects, ObjectTemplate destination) {
return new AutoValue_ComposeObjectTemplate(sourceObjects, destination);
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/4d3449f1/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/features/ObjectApi.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/features/ObjectApi.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/features/ObjectApi.java
index 3d6127e..3db8f98 100644
--- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/features/ObjectApi.java
+++ b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/features/ObjectApi.java
@@ -34,7 +34,7 @@ import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.Fallbacks.TrueOnNotFoundOr404;
import org.jclouds.googlecloudstorage.binders.MultipartUploadBinder;
import org.jclouds.googlecloudstorage.binders.UploadBinder;
-import org.jclouds.googlecloudstorage.domain.GCSObject;
+import org.jclouds.googlecloudstorage.domain.GoogleCloudStorageObject;
import org.jclouds.googlecloudstorage.domain.ListPageWithPrefixes;
import org.jclouds.googlecloudstorage.domain.templates.ComposeObjectTemplate;
import org.jclouds.googlecloudstorage.domain.templates.ObjectTemplate;
@@ -103,7 +103,7 @@ public interface ObjectApi {
@Consumes(APPLICATION_JSON)
@Fallback(NullOnNotFoundOr404.class)
@Nullable
- GCSObject getObject(@PathParam("bucket") String bucketName, @PathParam("object") String objectName);
+ GoogleCloudStorageObject getObject(@PathParam("bucket") String bucketName, @PathParam("object") String objectName);
/**
* Retrieves objects metadata
@@ -115,7 +115,7 @@ public interface ObjectApi {
* @param options
* Supply {@link GetObjectOptions} with optional query parameters
*
- * @return a {@link GCSObject}
+ * @return a {@link GoogleCloudStorageObject}
*/
@Named("Object:get")
@GET
@@ -123,7 +123,7 @@ public interface ObjectApi {
@Consumes(APPLICATION_JSON)
@Fallback(NullOnNotFoundOr404.class)
@Nullable
- GCSObject getObject(@PathParam("bucket") String bucketName, @PathParam("object") String objectName,
+ GoogleCloudStorageObject getObject(@PathParam("bucket") String bucketName, @PathParam("object") String objectName,
GetObjectOptions options);
/**
@@ -155,7 +155,7 @@ public interface ObjectApi {
* @param options
* Supply {@link GetObjectOptions} with optional query parameters
*
- * @return a {@link GCSObject}
+ * @return a {@link GoogleCloudStorageObject}
*/
@Named("Object:get")
@GET
@@ -176,7 +176,7 @@ public interface ObjectApi {
* @param options
* Supply an {@link InsertObjectOptions}. 'name' should not null.
*
- * @return a {@link GCSObject}
+ * @return a {@link GoogleCloudStorageObject}
*/
@Named("Object:simpleUpload")
@POST
@@ -184,7 +184,7 @@ public interface ObjectApi {
@Consumes(APPLICATION_JSON)
@Path("/upload/storage/v1/b/{bucket}/o")
@MapBinder(UploadBinder.class)
- GCSObject simpleUpload(@PathParam("bucket") String bucketName, @HeaderParam("Content-Type") String contentType,
+ GoogleCloudStorageObject simpleUpload(@PathParam("bucket") String bucketName, @HeaderParam("Content-Type") String contentType,
@HeaderParam("Content-Length") Long contentLength, @PayloadParam("payload") Payload payload,
InsertObjectOptions Options);
@@ -230,7 +230,7 @@ public interface ObjectApi {
@GET
@Consumes(APPLICATION_JSON)
@Path("storage/v1/b/{bucket}/o")
- ListPageWithPrefixes<GCSObject> listObjects(@PathParam("bucket") String bucketName);
+ ListPageWithPrefixes<GoogleCloudStorageObject> listObjects(@PathParam("bucket") String bucketName);
/**
* Retrieves a list of objects matching the criteria.
@@ -239,13 +239,13 @@ public interface ObjectApi {
* Name of the bucket in which to look for objects.
* @param options
* Supply {@link ListObjectOptions}
- * @return a {@link ListPage<GCSObject>}
+ * @return a {@link ListPage<GoogleCloudStorageObject>}
*/
@Named("Object:list")
@GET
@Consumes(APPLICATION_JSON)
@Path("storage/v1/b/{bucket}/o")
- ListPageWithPrefixes<GCSObject> listObjects(@PathParam("bucket") String bucketName, ListObjectOptions options);
+ ListPageWithPrefixes<GoogleCloudStorageObject> listObjects(@PathParam("bucket") String bucketName, ListObjectOptions options);
/**
* Updates an object metadata
@@ -257,7 +257,7 @@ public interface ObjectApi {
* @param objectTemplate
* Supply an {@link ObjectTemplate}
*
- * @return a {@link GCSObject}
+ * @return a {@link GoogleCloudStorageObject}
*/
@Named("Object:update")
@PUT
@@ -265,7 +265,7 @@ public interface ObjectApi {
@Produces(APPLICATION_JSON)
@Path("storage/v1/b/{bucket}/o/{object}")
@Fallback(NullOnNotFoundOr404.class)
- GCSObject updateObject(@PathParam("bucket") String bucketName, @PathParam("object") String objectName,
+ GoogleCloudStorageObject updateObject(@PathParam("bucket") String bucketName, @PathParam("object") String objectName,
@BinderParam(BindToJsonPayload.class) ObjectTemplate objectTemplate);
/**
@@ -280,7 +280,7 @@ public interface ObjectApi {
* @param options
* Supply {@link UpdateObjectOptions} with optional query parameters
*
- * @return a {@link GCSObject} .
+ * @return a {@link GoogleCloudStorageObject} .
*/
@Named("Object:update")
@PUT
@@ -288,7 +288,7 @@ public interface ObjectApi {
@Produces(APPLICATION_JSON)
@Path("storage/v1/b/{bucket}/o/{object}")
@Fallback(NullOnNotFoundOr404.class)
- GCSObject updateObject(@PathParam("bucket") String bucketName, @PathParam("object") String objectName,
+ GoogleCloudStorageObject updateObject(@PathParam("bucket") String bucketName, @PathParam("object") String objectName,
@BinderParam(BindToJsonPayload.class) ObjectTemplate objectTemplate, UpdateObjectOptions options);
/**
@@ -301,7 +301,7 @@ public interface ObjectApi {
* @param objectTemplate
* Supply {@link ObjectTemplate} with optional query parameters
*
- * @return a {@link GCSObject}
+ * @return a {@link GoogleCloudStorageObject}
*/
@Named("Object:patch")
@PATCH
@@ -309,7 +309,7 @@ public interface ObjectApi {
@Produces(APPLICATION_JSON)
@Path("storage/v1/b/{bucket}/o/{object}")
@Fallback(NullOnNotFoundOr404.class)
- GCSObject patchObject(@PathParam("bucket") String bucketName, @PathParam("object") String objectName,
+ GoogleCloudStorageObject patchObject(@PathParam("bucket") String bucketName, @PathParam("object") String objectName,
@BinderParam(BindToJsonPayload.class) ObjectTemplate objectTemplate);
/**
@@ -324,7 +324,7 @@ public interface ObjectApi {
* @param options
* Supply {@link UpdateObjectOptions} with optional query parameters
*
- * @return a {@link GCSObject}
+ * @return a {@link GoogleCloudStorageObject}
*/
@Named("Object:patch")
@PUT
@@ -332,7 +332,7 @@ public interface ObjectApi {
@Produces(APPLICATION_JSON)
@Path("storage/v1/b/{bucket}/o/{object}")
@Fallback(NullOnNotFoundOr404.class)
- GCSObject patchObject(@PathParam("bucket") String bucketName, @PathParam("object") String objectName,
+ GoogleCloudStorageObject patchObject(@PathParam("bucket") String bucketName, @PathParam("object") String objectName,
@BinderParam(BindToJsonPayload.class) ObjectTemplate objectTemplate, UpdateObjectOptions options);
/**
@@ -345,13 +345,13 @@ public interface ObjectApi {
* @param composeObjectTemplate
* Supply a {@link ComposeObjectTemplate}
*
- * @return a {@link GCSObject}
+ * @return a {@link GoogleCloudStorageObject}
*/
@Named("Object:compose")
@POST
@Consumes(APPLICATION_JSON)
@Path("storage/v1/b/{destinationBucket}/o/{destinationObject}/compose")
- GCSObject composeObjects(@PathParam("destinationBucket") String destinationBucket,
+ GoogleCloudStorageObject composeObjects(@PathParam("destinationBucket") String destinationBucket,
@PathParam("destinationObject") String destinationObject,
@BinderParam(BindToJsonPayload.class) ComposeObjectTemplate composeObjectTemplate);
@@ -367,13 +367,13 @@ public interface ObjectApi {
* @param options
* Supply an {@link ComposeObjectOptions}
*
- * @return a {@link GCSObject}
+ * @return a {@link GoogleCloudStorageObject}
*/
@Named("Object:compose")
@POST
@Consumes(APPLICATION_JSON)
@Path("storage/v1/b/{destinationBucket}/o/{destinationObject}/compose")
- GCSObject composeObjects(@PathParam("destinationBucket") String destinationBucket,
+ GoogleCloudStorageObject composeObjects(@PathParam("destinationBucket") String destinationBucket,
@PathParam("destinationObject") String destinationObject,
@BinderParam(BindToJsonPayload.class) ComposeObjectTemplate composeObjectTemplate,
ComposeObjectOptions options);
@@ -390,13 +390,13 @@ public interface ObjectApi {
* @param sourceObject
* Name of the source object
*
- * @return a {@link GCSObject}
+ * @return a {@link GoogleCloudStorageObject}
*/
@Named("Object:copy")
@POST
@Consumes(APPLICATION_JSON)
@Path("/storage/v1/b/{sourceBucket}/o/{sourceObject}/copyTo/b/{destinationBucket}/o/{destinationObject}")
- GCSObject copyObject(@PathParam("destinationBucket") String destinationBucket,
+ GoogleCloudStorageObject copyObject(@PathParam("destinationBucket") String destinationBucket,
@PathParam("destinationObject") String destinationObject, @PathParam("sourceBucket") String sourceBucket,
@PathParam("sourceObject") String sourceObject);
@@ -414,13 +414,13 @@ public interface ObjectApi {
* @param options
* Supply a {@link CopyObjectOptions}
*
- * @return a {@link GCSObject}
+ * @return a {@link GoogleCloudStorageObject}
*/
@Named("Object:copy")
@POST
@Consumes(APPLICATION_JSON)
@Path("/storage/v1/b/{sourceBucket}/o/{sourceObject}/copyTo/b/{destinationBucket}/o/{destinationObject}")
- GCSObject copyObject(@PathParam("destinationBucket") String destinationBucket,
+ GoogleCloudStorageObject copyObject(@PathParam("destinationBucket") String destinationBucket,
@PathParam("destinationObject") String destinationObject, @PathParam("sourceBucket") String sourceBucket,
@PathParam("sourceObject") String sourceObject, CopyObjectOptions options);
@@ -434,7 +434,7 @@ public interface ObjectApi {
* @param objectTemplate
* Supply an {@link ObjectTemplate}.
*
- * @return a {@link GCSObject}
+ * @return a {@link GoogleCloudStorageObject}
*/
@Named("Object:multipartUpload")
@POST
@@ -442,7 +442,7 @@ public interface ObjectApi {
@Consumes(APPLICATION_JSON)
@Path("/upload/storage/v1/b/{bucket}/o")
@MapBinder(MultipartUploadBinder.class)
- GCSObject multipartUpload(@PathParam("bucket") String bucketName,
+ GoogleCloudStorageObject multipartUpload(@PathParam("bucket") String bucketName,
@PayloadParam("template") ObjectTemplate objectTemplate,
@PayloadParam("payload") Payload payload);
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/4d3449f1/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/features/ResumableUploadApi.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/features/ResumableUploadApi.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/features/ResumableUploadApi.java
index eae3de6..ab8d172 100644
--- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/features/ResumableUploadApi.java
+++ b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/features/ResumableUploadApi.java
@@ -116,7 +116,7 @@ public interface ResumableUploadApi {
* @param options
* Supply {@link InsertObjectOptions} with optional query parameters. 'name' is mandatory.
*
- * @return If successful, this method returns a {@link GCSObject} resource.
+ * @return If successful, this method returns a {@link GoogleCloudStorageObject} resource.
*/
@Named("Object:resumableUpload")
@PUT
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/4d3449f1/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/blobstore/integration/GCSBlobIntegrationLiveTest.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/blobstore/integration/GCSBlobIntegrationLiveTest.java b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/blobstore/integration/GCSBlobIntegrationLiveTest.java
deleted file mode 100644
index cef46f8..0000000
--- a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/blobstore/integration/GCSBlobIntegrationLiveTest.java
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.googlecloudstorage.blobstore.integration;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertTrue;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Properties;
-
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.blobstore.BlobStore;
-import org.jclouds.blobstore.domain.Blob;
-import org.jclouds.blobstore.domain.BlobBuilder.PayloadBlobBuilder;
-import org.jclouds.blobstore.domain.BlobMetadata;
-import org.jclouds.blobstore.domain.PageSet;
-import org.jclouds.blobstore.domain.StorageMetadata;
-import org.jclouds.blobstore.integration.internal.BaseBlobIntegrationTest;
-import org.jclouds.blobstore.options.PutOptions;
-import org.jclouds.googlecloud.internal.TestProperties;
-import org.jclouds.googlecloudstorage.blobstore.strategy.internal.MultipartUpload;
-import org.jclouds.io.Payloads;
-import org.jclouds.io.payloads.ByteSourcePayload;
-import org.jclouds.utils.TestUtils;
-import org.testng.SkipException;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Charsets;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.hash.HashCode;
-import com.google.common.hash.HashFunction;
-import com.google.common.hash.Hashing;
-import com.google.common.io.ByteSource;
-import com.google.common.io.Files;
-
-@Test(groups = { "live", "blobstorelive" })
-public class GCSBlobIntegrationLiveTest extends BaseBlobIntegrationTest {
-
- private long PART_SIZE = MultipartUpload.MIN_PART_SIZE;
-
- public GCSBlobIntegrationLiveTest() throws IOException {
- provider = "google-cloud-storage";
- }
-
- @Override protected Properties setupProperties() {
- Properties properties = super.setupProperties();
- properties.put("jclouds.mpu.parts.size", 2 * 1024 * 1024);
- return TestProperties.apply(provider, properties);
- }
-
- @Override
- @Test(enabled = false)
- public void testGetTwoRanges() throws SkipException {
- // not supported in GCS
- }
-
- @Override
- @Test(enabled = false)
- public void testGetRange() throws SkipException {
- // not supported in GCS
- }
-
- @Override
- @Test(enabled = false)
- public void testCreateBlobWithExpiry() throws SkipException {
- // not supported in object level.
- }
-
- @Override
- @Test(enabled = false)
- public void testFileGetParallel() throws SkipException {
- // Implement Parallel uploads
- }
-
- @Override
- @Test(enabled = false)
- public void testPutFileParallel() throws SkipException {
- // Implement Parallel uploads
- }
-
- @Override
- @Test(groups = { "integration", "live" }, dataProvider = "gcsPutTest")
- public void testPutObject(String name, String type, Object content, Object realObject) throws InterruptedException,
- IOException {
- PayloadBlobBuilder blobBuilder = view.getBlobStore().blobBuilder(name).payload(Payloads.newPayload(content))
- .contentType(type);
- addContentMetadata(blobBuilder);
- Blob blob = blobBuilder.build();
- blob.getPayload().setContentMetadata(blob.getMetadata().getContentMetadata());
- String container = getContainerName();
-
- try {
- assertNotNull(view.getBlobStore().putBlob(container, blob));
- blob = view.getBlobStore().getBlob(container, blob.getMetadata().getName());
- validateMetadata(blob.getMetadata(), container, name);
- checkContentMetadata(blob);
-
- String returnedString = getContentAsStringOrNullAndClose(blob);
- assertEquals(returnedString, realObject);
- PageSet<? extends StorageMetadata> set = view.getBlobStore().list(container);
- assertThat(set).isNotEmpty();
- } finally {
- returnContainer(container);
- }
- }
-
- private void addContentMetadata(PayloadBlobBuilder blobBuilder) {
- blobBuilder.contentType("text/csv");
- blobBuilder.contentDisposition("attachment; filename=photo.jpg");
- blobBuilder.contentLanguage("en");
- }
-
- protected void checkContentMetadata(Blob blob) {
- checkContentType(blob, "text/csv");
- checkContentDisposition(blob, "attachment; filename=photo.jpg");
- checkContentLanguage(blob, "en");
- }
-
- @DataProvider(name = "gcsPutTest")
- public Object[][] createData1() throws IOException {
- File file = new File("pom.xml");
- String realObject = Files.toString(file, Charsets.UTF_8);
-
- return new Object[][] { { "file.xml", "text/xml", file, realObject },
- { "string.xml", "text/xml", realObject, realObject },
- { "bytes.xml", "application/octet-stream", realObject.getBytes(), realObject } };
- }
-
- // Content-Length should not be null
- @Override
- public void testPutObjectStream() throws InterruptedException, IOException, java.util.concurrent.ExecutionException {
-
- ByteSource byteSource = ByteSource.wrap("foo".getBytes());
- ByteSourcePayload payload = new ByteSourcePayload(byteSource);
- PayloadBlobBuilder blobBuilder = view.getBlobStore().blobBuilder("streaming").payload(payload)
- .contentLength(byteSource.read().length);
- addContentMetadata(blobBuilder);
-
- Blob blob = blobBuilder.build();
- String container = getContainerName();
-
- try {
- assertNotNull(view.getBlobStore().putBlob(container, blob));
-
- blob = view.getBlobStore().getBlob(container, blob.getMetadata().getName());
- String returnedString = getContentAsStringOrNullAndClose(blob);
- assertEquals(returnedString, "foo");
- validateMetadata(blob.getMetadata(), container, blob.getMetadata().getName());
- checkContentMetadata(blob);
- PageSet<? extends StorageMetadata> set = view.getBlobStore().list(container);
- assertThat(set).isNotEmpty();
- } finally {
- returnContainer(container);
- }
- };
-
- @Override
- public void testMetadata() throws InterruptedException, IOException {
- String name = "hello";
-
- HashFunction hf = Hashing.md5();
- HashCode md5 = hf.newHasher().putString(TEST_STRING, Charsets.UTF_8).hash();
- Blob blob = view.getBlobStore().blobBuilder(name).userMetadata(ImmutableMap.of("adrian", "powderpuff"))
- .payload(TEST_STRING).contentType(MediaType.TEXT_PLAIN).contentMD5(md5).build();
- String container = getContainerName();
- try {
- assertNull(view.getBlobStore().blobMetadata(container, "powderpuff"));
-
- addBlobToContainer(container, blob);
- Blob newObject = validateContent(container, name);
-
- BlobMetadata metadata = newObject.getMetadata();
-
- validateMetadata(metadata);
- validateMetadata(metadata, container, name);
- validateMetadata(view.getBlobStore().blobMetadata(container, name));
-
- blob.getMetadata().getUserMetadata().put("adrian", "wonderpuff");
- blob.getMetadata().getUserMetadata().put("adrian", "powderpuff");
-
- addBlobToContainer(container, blob);
- validateMetadata(view.getBlobStore().blobMetadata(container, name));
-
- } finally {
- returnContainer(container);
- }
- }
-
- @Override
- protected void checkMD5(BlobMetadata metadata) throws IOException {
- HashCode md5 = Hashing.md5().hashString(TEST_STRING, Charsets.UTF_8);
- assertEquals(metadata.getContentMetadata().getContentMD5AsHashCode(), md5);
- }
-
- @Test(groups = { "integration", "live" })
- public void testMultipartChunkedFileStream() throws IOException, InterruptedException {
- String containerName = getContainerName();
- try {
- BlobStore blobStore = view.getBlobStore();
- long countBefore = blobStore.countBlobs(containerName);
-
- addMultipartBlobToContainer(containerName, "const.txt");
-
- long countAfter = blobStore.countBlobs(containerName);
- assertNotEquals(countBefore, countAfter, "No blob was created");
- assertTrue(countAfter - countBefore > 1, "A multipart blob wasn't actually created - "
- + "there was only 1 extra blob but there should be one manifest blob and multiple chunk blobs");
- } finally {
- returnContainer(containerName);
- }
- }
-
- protected void addMultipartBlobToContainer(String containerName, String key) throws IOException {
- ByteSource sourceToUpload = TestUtils.randomByteSource().slice(0, (long) (PART_SIZE * 1.1));
-
- BlobStore blobStore = view.getBlobStore();
- blobStore.createContainerInLocation(null, containerName);
- Blob blob = blobStore.blobBuilder(key).payload(sourceToUpload).contentLength(sourceToUpload.size())
- .contentType(MediaType.TEXT_PLAIN).build();
- blobStore.putBlob(containerName, blob, PutOptions.Builder.multipart());
- }
-
- @DataProvider(name = "delete")
- public Object[][] createData() {
- if (System.getProperty("os.name").toLowerCase().contains("windows")) {
- return new Object[][] { { "normal" }, { "sp ace" } };
- } else {
- return new Object[][] { { "normal" }, { "sp ace" }, { "qu?stion" }, { "path/foo" }, { "colon:" },
- { "asteri*k" }, { "quote\"" }, { "{great<r}" }, { "lesst>en" }, { "p|pe" } };
- }
- }
-
- // Remove "unic₪de" from DataProvider
- @Override
- @Test(groups = { "integration", "live" }, dataProvider = "delete")
- public void deleteObject(String name) throws InterruptedException {
- super.deleteObject(name);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/4d3449f1/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/blobstore/integration/GCSBlobLiveTest.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/blobstore/integration/GCSBlobLiveTest.java b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/blobstore/integration/GCSBlobLiveTest.java
deleted file mode 100644
index 3db2158..0000000
--- a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/blobstore/integration/GCSBlobLiveTest.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.googlecloudstorage.blobstore.integration;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-
-import java.io.IOException;
-import java.util.Properties;
-
-import org.jclouds.blobstore.BlobStore;
-import org.jclouds.blobstore.domain.Blob;
-import org.jclouds.blobstore.integration.internal.BaseBlobLiveTest;
-import org.jclouds.googlecloud.internal.TestProperties;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.http.internal.PayloadEnclosingImpl;
-import org.jclouds.io.ByteStreams2;
-import org.jclouds.io.Payloads;
-import org.jclouds.io.payloads.ByteSourcePayload;
-import org.jclouds.utils.TestUtils;
-import org.testng.annotations.Parameters;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.common.hash.HashCode;
-import com.google.common.hash.Hashing;
-import com.google.common.io.BaseEncoding;
-import com.google.common.io.ByteSource;
-
-@Test(groups = { "live" })
-public class GCSBlobLiveTest extends BaseBlobLiveTest {
- private static final String sysHttpStreamUrl = System.getProperty("jclouds.blobstore.httpstream.url");
- private static final String sysHttpStreamMD5 = System.getProperty("jclouds.blobstore.httpstream.md5");
-
- public GCSBlobLiveTest() {
- provider = "google-cloud-storage";
- }
-
- @Override protected Properties setupProperties() {
- return TestProperties.apply(provider, super.setupProperties());
- }
-
- @Override
- @Parameters({ "jclouds.blobstore.httpstream.url", "jclouds.blobstore.httpstream.md5" })
- public void testCopyUrl(String httpStreamUrl, String httpStreamMD5) throws Exception {
- httpStreamUrl = checkNotNull(httpStreamUrl != null ? httpStreamUrl : sysHttpStreamUrl, "httpStreamUrl");
- httpStreamMD5 = checkNotNull(httpStreamMD5 != null ? httpStreamMD5 : sysHttpStreamMD5, "httpStreamMd5");
-
- HttpResponse response = view.utils().http()
- .invoke(HttpRequest.builder().method("GET").endpoint(httpStreamUrl).build());
- long length = response.getPayload().getContentMetadata().getContentLength();
-
- checkNotNull(response.getPayload().getContentMetadata().getContentType());
- assertEquals(response.getPayload().getContentMetadata().getContentType(), "application/x-gzip");
-
- String name = "hello";
- HashCode md5 = HashCode.fromBytes(BaseEncoding.base16().lowerCase().decode(httpStreamMD5));
- byte[] payload = ByteStreams2.toByteArrayAndClose(response.getPayload().getInput());
-
- Blob blob = view.getBlobStore().blobBuilder(name).payload(payload).contentLength(length)
- .contentType(response.getPayload().getContentMetadata().getContentType())
- .contentMD5(md5).build();
- String container = getContainerName();
- try {
- assertNotNull(view.getBlobStore().putBlob(container, blob));
- checkMD5(container, name, md5.asBytes());
- } finally {
- returnContainer(container);
- }
- }
-
- @Test(groups = "live")
- public void testPutBlobWithMd5() throws IOException, InterruptedException {
- String containerName = getContainerName();
- String blobName = "md5test";
- try {
- long contentLength = 32 * 1024L;
- ByteSource byteSource = TestUtils.randomByteSource().slice(0, contentLength);
- ByteSourcePayload payload = Payloads.newByteSourcePayload(byteSource);
- PayloadEnclosingImpl payloadImpl = new PayloadEnclosingImpl(payload);
-
- BlobStore blobStore = view.getBlobStore();
-
- // This would trigger server side validation of md5
- HashCode hcMd5 = byteSource.hash(Hashing.md5());
-
- Blob blob = blobStore.blobBuilder(blobName).payload(payloadImpl.getPayload()).contentType("image/jpeg")
- .contentLength(contentLength).contentLanguage("en").contentDisposition("attachment")
- .contentMD5(hcMd5).userMetadata(ImmutableMap.of("Adrian", "powderpuff")).build();
-
- blobStore.putBlob(containerName, blob);
- checkMD5(containerName, blobName, hcMd5.asBytes());
-
- } finally {
- returnContainer(containerName);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/4d3449f1/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/blobstore/integration/GCSContainerIntegrationLiveTest.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/blobstore/integration/GCSContainerIntegrationLiveTest.java b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/blobstore/integration/GCSContainerIntegrationLiveTest.java
deleted file mode 100644
index d3686de..0000000
--- a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/blobstore/integration/GCSContainerIntegrationLiveTest.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.googlecloudstorage.blobstore.integration;
-
-import static com.google.common.collect.Iterables.get;
-import static org.jclouds.blobstore.options.ListContainerOptions.Builder.maxResults;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNull;
-
-import java.io.IOException;
-import java.util.Properties;
-
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.blobstore.domain.BlobMetadata;
-import org.jclouds.blobstore.domain.PageSet;
-import org.jclouds.blobstore.domain.StorageMetadata;
-import org.jclouds.blobstore.integration.internal.BaseContainerIntegrationTest;
-import org.jclouds.blobstore.options.ListContainerOptions;
-import org.jclouds.googlecloud.internal.TestProperties;
-import org.testng.SkipException;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Charsets;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.hash.Hashing;
-
-public class GCSContainerIntegrationLiveTest extends BaseContainerIntegrationTest {
-
- public GCSContainerIntegrationLiveTest() {
- provider = "google-cloud-storage";
- }
-
- @Override protected Properties setupProperties() {
- return TestProperties.apply(provider, super.setupProperties());
- }
-
- @Override
- @Test(groups = { "integration", "live" })
- public void testWithDetails() throws InterruptedException, IOException {
- String key = "hello";
- String containerName = getContainerName();
- try {
- addBlobToContainer(
- containerName,
- view.getBlobStore().blobBuilder(key).userMetadata(ImmutableMap.of("adrian", "powderpuff"))
- .payload(TEST_STRING).contentType(MediaType.TEXT_PLAIN)
- .contentMD5(Hashing.md5().newHasher().putString(TEST_STRING, Charsets.UTF_8).hash()).build());
- validateContent(containerName, key);
-
- PageSet<? extends StorageMetadata> container = view.getBlobStore().list(containerName,
- maxResults(1).withDetails());
-
- BlobMetadata metadata = BlobMetadata.class.cast(get(container, 0));
-
- assert metadata.getContentMetadata().getContentType().startsWith("text/plain") : metadata.getContentMetadata()
- .getContentType();
- assertEquals(metadata.getContentMetadata().getContentLength(), Long.valueOf(TEST_STRING.length()));
- assertEquals(metadata.getUserMetadata().get("adrian"), "powderpuff");
- checkMD5(metadata);
- } finally {
- returnContainer(containerName);
- }
- }
-
- /** Google Cloud Storage lists prefixes and objects in two different lists */
- @Override
- public void testListRootUsesDelimiter() throws InterruptedException {
- String containerName = getContainerName();
- try {
- String prefix = "rootdelimiter";
- addTenObjectsUnderPrefix(containerName, prefix);
- add15UnderRoot(containerName);
- PageSet<? extends StorageMetadata> container = view.getBlobStore().list(containerName,
- new ListContainerOptions());
- assertNull(container.getNextMarker());
- assertEquals(container.size(), 15);
- } finally {
- returnContainer(containerName);
- }
- }
-
- @Override
- public void testDirectory() throws InterruptedException {
- // GCS does not support directories, rather it supports prefixes which look like directories.
- throw new SkipException("directories are not supported in GCS");
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/4d3449f1/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/blobstore/integration/GCSContainerLiveTest.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/blobstore/integration/GCSContainerLiveTest.java b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/blobstore/integration/GCSContainerLiveTest.java
deleted file mode 100644
index 305db36..0000000
--- a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/blobstore/integration/GCSContainerLiveTest.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.googlecloudstorage.blobstore.integration;
-
-import java.util.Properties;
-
-import org.jclouds.blobstore.integration.internal.BaseContainerLiveTest;
-import org.jclouds.googlecloud.internal.TestProperties;
-import org.testng.annotations.Test;
-
-@Test(groups = { "live" })
-public class GCSContainerLiveTest extends BaseContainerLiveTest {
-
- public GCSContainerLiveTest() {
- provider = "google-cloud-storage";
- }
-
- @Override protected Properties setupProperties() {
- return TestProperties.apply(provider, super.setupProperties());
- }
-}