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 2017/05/08 20:52:16 UTC
[7/7] jclouds-labs-google git commit: JCLOUDS-944: Promote Google
Cloud Storage to core
JCLOUDS-944: Promote Google Cloud Storage to core
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/a4acb11f
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/tree/a4acb11f
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/diff/a4acb11f
Branch: refs/heads/master
Commit: a4acb11f72d17a0618072c22c1db699f5d4f7550
Parents: 2759926
Author: Andrew Gaul <ga...@apache.org>
Authored: Mon May 8 11:10:54 2017 -0700
Committer: Andrew Gaul <ga...@apache.org>
Committed: Mon May 8 11:13:07 2017 -0700
----------------------------------------------------------------------
CONTRIBUTING.md | 9 -
README.md | 214 +-------
google-cloud-storage/README.md | 51 --
google-cloud-storage/pom.xml | 172 ------
.../GoogleCloudStorageApi.java | 77 ---
.../GoogleCloudStorageApiMetadata.java | 96 ----
.../GoogleCloudStorageFallbacks.java | 34 --
.../GoogleCloudStorageProviderMetadata.java | 72 ---
.../binders/MultipartUploadBinder.java | 69 ---
.../binders/UploadBinder.java | 38 --
.../GoogleCloudStorageBlobRequestSigner.java | 153 ------
.../blobstore/GoogleCloudStorageBlobStore.java | 468 ----------------
...oogleCloudStorageBlobStoreContextModule.java | 44 --
.../functions/BlobMetadataToObjectTemplate.java | 56 --
...ListContainerOptionsToListObjectOptions.java | 58 --
.../functions/BucketToStorageMetadata.java | 45 --
.../functions/ObjectListToStorageMetadata.java | 58 --
.../functions/ObjectToBlobMetadata.java | 59 --
.../config/GoogleCloudStorageHttpApiModule.java | 63 ---
.../config/GoogleCloudStorageOAuthScopes.java | 56 --
.../config/GoogleCloudStorageParserModule.java | 90 ----
.../googlecloudstorage/domain/Bucket.java | 181 -------
.../domain/BucketAccessControls.java | 122 -----
.../domain/DomainResourceReferences.java | 105 ----
.../domain/GoogleCloudStorageObject.java | 79 ---
.../domain/ListPageWithPrefixes.java | 58 --
.../domain/ObjectAccessControls.java | 133 -----
.../googlecloudstorage/domain/Owner.java | 34 --
.../googlecloudstorage/domain/ProjectTeam.java | 55 --
.../domain/ResumableUpload.java | 43 --
.../domain/RewriteResponse.java | 41 --
.../templates/BucketAccessControlsTemplate.java | 33 --
.../domain/templates/BucketTemplate.java | 172 ------
.../domain/templates/ComposeObjectTemplate.java | 123 -----
.../templates/ObjectAccessControlsTemplate.java | 33 --
.../domain/templates/ObjectTemplate.java | 178 -------
.../features/BucketAccessControlsApi.java | 172 ------
.../googlecloudstorage/features/BucketApi.java | 281 ----------
.../DefaultObjectAccessControlsApi.java | 180 -------
.../features/ObjectAccessControlsApi.java | 317 -----------
.../googlecloudstorage/features/ObjectApi.java | 532 -------------------
.../features/ResumableUploadApi.java | 185 -------
.../GoogleCloudStorageErrorHandler.java | 75 ---
.../GoogleCloudStorageRedirectRetryHandler.java | 48 --
.../options/ComposeObjectOptions.java | 63 ---
.../options/CopyObjectOptions.java | 153 ------
.../options/DeleteBucketOptions.java | 51 --
.../options/DeleteObjectOptions.java | 88 ---
.../options/GetBucketOptions.java | 61 ---
.../options/GetObjectOptions.java | 88 ---
.../options/InsertBucketOptions.java | 53 --
.../options/InsertObjectOptions.java | 115 ----
.../options/ListObjectOptions.java | 82 ---
.../googlecloudstorage/options/ListOptions.java | 53 --
.../options/RewriteObjectOptions.java | 155 ------
.../options/UpdateBucketOptions.java | 71 ---
.../options/UpdateObjectOptions.java | 100 ----
.../parser/ParseToPayloadEnclosing.java | 33 --
.../parser/ParseToResumableUpload.java | 72 ---
.../reference/GoogleCloudStorageConstants.java | 37 --
.../GoogleCloudStorageProviderMetadataTest.java | 34 --
...ogleCloudStorageBlobIntegrationLiveTest.java | 324 -----------
.../GoogleCloudStorageBlobLiveTest.java | 115 ----
.../GoogleCloudStorageBlobSignerLiveTest.java | 36 --
...loudStorageContainerIntegrationLiveTest.java | 106 ----
.../GoogleCloudStorageContainerLiveTest.java | 36 --
.../BucketAccessControlsApiExpectTest.java | 188 -------
.../BucketAccessControlsApiLiveTest.java | 107 ----
.../features/BucketApiExpectTest.java | 258 ---------
.../features/BucketApiLiveTest.java | 301 -----------
...efaultObjectAccessControlsApiExpectTest.java | 219 --------
.../DefaultObjectAccessControlsApiLiveTest.java | 110 ----
.../ObjectAccessControlsApiExpectTest.java | 276 ----------
.../features/ObjectApiLiveTest.java | 478 -----------------
.../features/ObjectApiMockTest.java | 303 -----------
.../features/ResumableUploadApiLiveTest.java | 177 ------
.../GoogleCloudStorageErrorHandlerTest.java | 107 ----
.../BaseGoogleCloudStorageApiExpectTest.java | 30 --
.../BaseGoogleCloudStorageApiLiveTest.java | 54 --
.../BaseGoogleCloudStorageApiMockTest.java | 138 -----
.../BaseGoogleCloudStorageExpectTest.java | 178 -------
.../BaseGoogleCloudStorageParseTest.java | 38 --
.../parse/BucketAclGetTest.java | 39 --
.../parse/BucketAclInsertTest.java | 42 --
.../parse/BucketAclListTest.java | 55 --
.../parse/BucketAclUpdateTest.java | 39 --
.../parse/BucketUpdateTest.java | 57 --
.../parse/DefaultObjectAclGetTest.java | 42 --
.../parse/DefaultObjectAclInsertTest.java | 38 --
.../parse/DefaultObjectAclListTest.java | 50 --
.../parse/FullBucketGetTest.java | 80 ---
.../parse/NoAclBucketListTest.java | 61 ---
.../parse/NoAclBucketTest.java | 57 --
.../parse/ObjectAclGetTest.java | 49 --
.../parse/ObjectAclInsertTest.java | 44 --
.../parse/ObjectAclListTest.java | 51 --
.../parse/ObjectAclUpdateTest.java | 40 --
.../parse/ParseGoogleCloudStorageObject.java | 66 ---
.../ParseGoogleCloudStorageObjectListTest.java | 99 ----
.../parse/ParseObjectRewriteResponse.java | 72 ---
.../src/test/resources/bucket_acl_get.json | 9 -
.../resources/bucket_acl_insert_initial.json | 4 -
.../resources/bucket_acl_insert_response.json | 9 -
.../src/test/resources/bucket_acl_list.json | 27 -
.../resources/bucket_acl_update_initial.json | 4 -
.../resources/bucket_acl_update_response.json | 9 -
.../bucket_insert_request_payload.json | 3 -
.../bucket_update_request_payload.json | 12 -
.../test/resources/bucket_update_response.json | 15 -
.../test/resources/default_object_acl_get.json | 10 -
...fault_object_acl_insert_request_payload.json | 4 -
.../default_object_acl_insert_response.json | 6 -
.../test/resources/default_object_acl_list.json | 15 -
.../default_object_acl_update_initial.json | 6 -
...fault_object_acl_update_request_payload.json | 5 -
.../src/test/resources/full_bucket_get.json | 54 --
.../resources/list_bucket_with_options.json | 21 -
.../src/test/resources/logback.xml | 83 ---
.../src/test/resources/no_acl_bucket.json | 15 -
.../src/test/resources/no_acl_bucket_list.json | 21 -
.../src/test/resources/object_acl_get.json | 15 -
.../object_acl_insert_request_payload.json | 4 -
.../resources/object_acl_insert_response.json | 10 -
.../src/test/resources/object_acl_list.json | 17 -
.../resources/object_acl_request_payload.json | 4 -
.../resources/object_acl_update_initial.json | 9 -
.../resources/object_acl_update_response.json | 9 -
.../test/resources/object_compose_request.json | 23 -
.../src/test/resources/object_encoded_get.json | 21 -
.../src/test/resources/object_get.json | 21 -
.../src/test/resources/object_list.json | 47 --
.../src/test/resources/object_rewrite.json | 28 -
pom.xml | 81 ---
133 files changed, 2 insertions(+), 11650 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/CONTRIBUTING.md
----------------------------------------------------------------------
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
deleted file mode 100644
index 4da3fc3..0000000
--- a/CONTRIBUTING.md
+++ /dev/null
@@ -1,9 +0,0 @@
-If you are looking for the google-compute-engine provider, go to the main jclouds reposityy
-
-Please review the [How to Contribute](https://cwiki.apache.org/confluence/display/JCLOUDS/Contribute) page for information on how to submit your patch and how the review process works.
-
-Also make sure all the changes are aligned with the [Coding Standards](https://cwiki.apache.org/confluence/display/JCLOUDS/Writing+jclouds+Code) of the project.
-
-Thanks!
-
-The Apache jclouds team
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index 79c2e80..cebad0a 100644
--- a/README.md
+++ b/README.md
@@ -1,216 +1,6 @@
jclouds Labs Google
======================
-Repository for developing experimental [Google Cloud Platform](https://cloud.google.com/) providers and [APIs](https://cloud.google.com/storage/docs/json_api/v1/)
+Legacy repository for developing experimental [Google Cloud Platform](https://cloud.google.com/) providers and [APIs](https://cloud.google.com/storage/docs/json_api/v1/)
-The Google Compute Engine provider has already been graduated to the main jclouds repo.
-
-License
--------
-Copyright (C) 2009-2014 The Apache Software Foundation
-
-Licensed under the Apache License, Version 2.0
-
-```
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright 2014 The Apache Software Foundation
-
- Licensed 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.
-```
+The Google Cloud Storage and Google Compute Engine providers have graduated to the main jclouds repo.
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/google-cloud-storage/README.md
----------------------------------------------------------------------
diff --git a/google-cloud-storage/README.md b/google-cloud-storage/README.md
deleted file mode 100644
index 59adad9..0000000
--- a/google-cloud-storage/README.md
+++ /dev/null
@@ -1,51 +0,0 @@
-jclouds Google Cloud Storage Provider
-======
-Make sure both Google Cloud Storage and Google Cloud Storage JSON API are enabled for the project
-(check from Developers Console -> Api&auth -> APIs)
-
-FAQ:
---------
-
-* Q. What is the identity for Google Cloud Storage?
-
-A. the identity is the developer email which can be obtained from the admin GUI. Its usually something in the form: [PROJECT_ID](https://cloud.google.com/compute/docs/overview#projectids)@developer.gserviceaccount.com
-
-* Q. What is the credential for Google Cloud Storage
-
-A. the credential is a private key, in pem format. It can be extracted from the p12 keystore that is obtained when creating a "Service Account" (in the GUI: Google apis console > Api Access > Create another client ID > "Service Account"
-
-* Q. How to convert a p12 keystore into a pem format jclouds Google Cloud Storage can handle:
-
-A.
-
-1. Convert the p12 file into pem format (it will ask for the keystore password, which is usually "notasecret"):
- openssl pkcs12 -in <my_keystore>.p12 -out <my_keystore>.pem -nodes
-
-2. Extract only the pk and remove passphrase
- openssl rsa -in <my_keystore>.pem -out <my_key>.pem
-
-The last file (<my_key>.pem) should contain the pk that needs to be passed to `ContextBuilder.credential()` for the provider `google-cloud-storage`.
-
-
-Running the live tests:
---------
-
-1. Place the following in your ~/.m2/settings.xml in a profile enabled when live:
-```
- <test.google-cloud-storage.identity>PROJECT_ID@developer.gserviceaccount.com</test.google-cloud-storage.identity>
- <test.google-cloud-storage.credential>-----BEGIN RSA PRIVATE KEY-----
-MIICXgIBAAKBgQRRbRqVDtJLN1MO/xJoKqZuphDeBh5jIKueW3aNIiWs1XFcct+h
--- this text is literally from your <my_key>.pem
-aH7xmpHSTbbXmQkuuv+z8EKijigprd/FoJpTX1f5/R+4wQ==
------END RSA PRIVATE KEY-----</test.google-cloud-storage.credential>
- </properties>
-```
-Or, if using an existing OAuth Bearer Token for authentication.
-```
- <test.google-cloud-storage.identity>PROJECT_ID@developer.gserviceaccount.com</test.google-cloud-storage.identity>
- <test.google-cloud-storage.credential>EXISTING_BEARER_TOKEN</test.google-cloud-storage.credential>
- <test.jclouds.oauth.credential-type>bearerTokenCredentials</test.jclouds.oauth.credential-type>
- </properties>
-```
-
-2. mvn clean install -Plive
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/google-cloud-storage/pom.xml
----------------------------------------------------------------------
diff --git a/google-cloud-storage/pom.xml b/google-cloud-storage/pom.xml
deleted file mode 100644
index 6332b9e..0000000
--- a/google-cloud-storage/pom.xml
+++ /dev/null
@@ -1,172 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.jclouds.labs</groupId>
- <artifactId>jclouds-labs-google</artifactId>
- <version>2.1.0-SNAPSHOT</version>
- </parent>
-
- <!-- TODO: when out of labs, switch to org.jclouds.provider -->
- <groupId>org.apache.jclouds.labs</groupId>
- <artifactId>google-cloud-storage</artifactId>
- <name>jclouds Google Cloud Storage provider</name>
- <description>jclouds components to access Google Cloud Storage</description>
- <packaging>bundle</packaging>
-
- <properties>
- <test.google-cloud-storage.identity>client_email which usually looks like project_id@developer.gserviceaccount.com</test.google-cloud-storage.identity>
- <test.google-cloud-storage.credential>Private key (PEM encoded PKCS12 file or literal) associated with the client_email</test.google-cloud-storage.credential>
- <!-- Add this property to use a different project, or avoid looking up the project for each test. -->
- <test.jclouds.googlecloud.project-name></test.jclouds.googlecloud.project-name>
- <test.jclouds.oauth.credential-type>p12PrivateKeyCredentials</test.jclouds.oauth.credential-type>
- <test.google-cloud-storage.api-version>v1</test.google-cloud-storage.api-version>
- <test.google-cloud-storage.build-version/>
- <jclouds.osgi.export>org.jclouds.googlecloudstorage*;version="${project.version}"</jclouds.osgi.export>
- <jclouds.osgi.import>org.jclouds*;version="${project.version}",*</jclouds.osgi.import>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.jclouds</groupId>
- <artifactId>jclouds-core</artifactId>
- <version>${jclouds.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.jclouds.common</groupId>
- <artifactId>googlecloud</artifactId>
- <version>${project.version}</version>
- <type>jar</type>
- </dependency>
- <dependency>
- <groupId>org.apache.jclouds.common</groupId>
- <artifactId>googlecloud</artifactId>
- <version>${project.version}</version>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.jclouds.api</groupId>
- <artifactId>oauth</artifactId>
- <version>${project.version}</version>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.jclouds</groupId>
- <artifactId>jclouds-blobstore</artifactId>
- <version>${jclouds.version}</version>
- </dependency>
- <dependency>
- <groupId>com.google.auto.service</groupId>
- <artifactId>auto-service</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>com.google.auto.value</groupId>
- <artifactId>auto-value</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.jclouds</groupId>
- <artifactId>jclouds-blobstore</artifactId>
- <version>${jclouds.version}</version>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.jclouds</groupId>
- <artifactId>jclouds-core</artifactId>
- <version>${jclouds.version}</version>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.jclouds.driver</groupId>
- <artifactId>jclouds-slf4j</artifactId>
- <version>${jclouds.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.jclouds.driver</groupId>
- <artifactId>jclouds-okhttp</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>com.squareup.okhttp</groupId>
- <artifactId>mockwebserver</artifactId>
- <scope>test</scope>
- <exclusions>
- <!-- Already provided by jclouds-sshj -->
- <exclusion>
- <groupId>org.bouncycastle</groupId>
- <artifactId>bcprov-jdk15on</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- </dependencies>
- <profiles>
- <profile>
- <id>live</id>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <executions>
- <execution>
- <id>default-test</id>
- <configuration>
- <skipTests>true</skipTests>
- </configuration>
- </execution>
- <execution>
- <id>integration</id>
- <phase>integration-test</phase>
- <goals>
- <goal>test</goal>
- </goals>
- <configuration>
- <threadCount>1</threadCount>
- <systemPropertyVariables>
- <test.google-cloud-storage.identity>${test.google-cloud-storage.identity}</test.google-cloud-storage.identity>
- <test.google-cloud-storage.credential>${test.google-cloud-storage.credential}</test.google-cloud-storage.credential>
- <test.jclouds.googlecloud.project-name>${test.jclouds.googlecloud.project-name}</test.jclouds.googlecloud.project-name>
- <test.jclouds.oauth.credential-type>${test.jclouds.oauth.credential-type}</test.jclouds.oauth.credential-type>
- <test.google-cloud-storage.api-version>${test.google-cloud-storage.api-version}</test.google-cloud-storage.api-version>
- <test.google-cloud-storage.build-version>${test.google-cloud-storage.build-version}</test.google-cloud-storage.build-version>
- </systemPropertyVariables>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-</project>
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/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
deleted file mode 100644
index eec5294..0000000
--- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/GoogleCloudStorageApi.java
+++ /dev/null
@@ -1,77 +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;
-
-import java.io.Closeable;
-
-import javax.ws.rs.Path;
-
-import org.jclouds.googlecloudstorage.features.BucketAccessControlsApi;
-import org.jclouds.googlecloudstorage.features.BucketApi;
-import org.jclouds.googlecloudstorage.features.DefaultObjectAccessControlsApi;
-import org.jclouds.googlecloudstorage.features.ObjectAccessControlsApi;
-import org.jclouds.googlecloudstorage.features.ObjectApi;
-import org.jclouds.googlecloudstorage.features.ResumableUploadApi;
-import org.jclouds.rest.annotations.Delegate;
-
-/**
- * Provide access to GoogleCloudStorage
- *
- * @see <a href="https://developers.google.com/storage/docs/json_api/v1/">api doc /a>
- */
-public interface GoogleCloudStorageApi extends Closeable {
-
- /**
- * Provides access to Default Object Access Control features on bucket
- */
- @Delegate
- @Path("/storage/v1")
- DefaultObjectAccessControlsApi getDefaultObjectAccessControlsApi();
-
- /**
- * Provides access to Bucket Access Control features
- */
- @Delegate
- @Path("/storage/v1")
- BucketAccessControlsApi getBucketAccessControlsApi();
-
- /**
- * Provides access to Bucket features
- */
- @Delegate
- @Path("/storage/v1")
- BucketApi getBucketApi();
-
- /**
- * Provides access to Object Access Control features
- */
- @Delegate
- @Path("/storage/v1")
- ObjectAccessControlsApi getObjectAccessControlsApi();
-
- /**
- * Provides access to Google Cloud Storage Object features
- */
- @Delegate
- ObjectApi getObjectApi();
-
- /**
- * Provides access to Google Cloud Storage ResumableUpload features
- */
- @Delegate
- ResumableUploadApi getResumableUploadApi();
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/GoogleCloudStorageApiMetadata.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/GoogleCloudStorageApiMetadata.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/GoogleCloudStorageApiMetadata.java
deleted file mode 100644
index 884edd2..0000000
--- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/GoogleCloudStorageApiMetadata.java
+++ /dev/null
@@ -1,96 +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;
-
-import static org.jclouds.Constants.PROPERTY_IDEMPOTENT_METHODS;
-import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
-import static org.jclouds.googlecloudstorage.reference.GoogleCloudStorageConstants.OPERATION_COMPLETE_INTERVAL;
-import static org.jclouds.googlecloudstorage.reference.GoogleCloudStorageConstants.OPERATION_COMPLETE_TIMEOUT;
-import static org.jclouds.oauth.v2.config.OAuthProperties.AUDIENCE;
-import static org.jclouds.oauth.v2.config.OAuthProperties.JWS_ALG;
-import static org.jclouds.reflect.Reflection2.typeToken;
-
-import java.net.URI;
-import java.util.Properties;
-
-import org.jclouds.blobstore.BlobStoreContext;
-import org.jclouds.googlecloud.config.CurrentProject;
-import org.jclouds.googlecloudstorage.blobstore.config.GoogleCloudStorageBlobStoreContextModule;
-import org.jclouds.googlecloudstorage.config.GoogleCloudStorageHttpApiModule;
-import org.jclouds.googlecloudstorage.config.GoogleCloudStorageParserModule;
-import org.jclouds.oauth.v2.config.OAuthModule;
-import org.jclouds.rest.internal.BaseHttpApiMetadata;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.inject.Module;
-
-public class GoogleCloudStorageApiMetadata extends BaseHttpApiMetadata<GoogleCloudStorageApi> {
-
- @Override
- public Builder toBuilder() {
- return new Builder().fromApiMetadata(this);
- }
-
- public GoogleCloudStorageApiMetadata() {
- this(new Builder());
- }
-
- protected GoogleCloudStorageApiMetadata(Builder builder) {
- super(builder);
- }
-
- public static Properties defaultProperties() {
- Properties properties = BaseHttpApiMetadata.defaultProperties();
- properties.put("oauth.endpoint", "https://accounts.google.com/o/oauth2/token");
- properties.put(AUDIENCE, "https://accounts.google.com/o/oauth2/token");
- properties.put(JWS_ALG, "RS256");
- properties.put(PROPERTY_SESSION_INTERVAL, 3600);
- properties.put(OPERATION_COMPLETE_INTERVAL, 2000);
- properties.put(OPERATION_COMPLETE_TIMEOUT, 600000);
- properties.setProperty(PROPERTY_IDEMPOTENT_METHODS, "DELETE,GET,HEAD,OPTIONS,POST,PUT");
- return properties;
- }
-
- public static class Builder extends BaseHttpApiMetadata.Builder<GoogleCloudStorageApi, Builder> {
- protected Builder() {
- id("google-cloud-storage")
- .name("Google Cloud Storage Api")
- .identityName(CurrentProject.ClientEmail.DESCRIPTION)
- .credentialName("PEM encoded P12 private key associated with client_email")
- .documentation(URI.create("https://developers.google.com/storage/docs/json_api"))
- .version("v1")
- .defaultEndpoint("https://www.googleapis.com")
- .defaultProperties(GoogleCloudStorageApiMetadata.defaultProperties())
- .view(typeToken(BlobStoreContext.class))
- .defaultModules(ImmutableSet.<Class<? extends Module>> builder()
- .add(GoogleCloudStorageParserModule.class)
- .add(OAuthModule.class)
- .add(GoogleCloudStorageHttpApiModule.class)
- .add(GoogleCloudStorageBlobStoreContextModule.class).build());
- }
-
- @Override
- public GoogleCloudStorageApiMetadata build() {
- return new GoogleCloudStorageApiMetadata(this);
- }
-
- @Override
- protected Builder self() {
- return this;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/GoogleCloudStorageFallbacks.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/GoogleCloudStorageFallbacks.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/GoogleCloudStorageFallbacks.java
deleted file mode 100644
index d19175a..0000000
--- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/GoogleCloudStorageFallbacks.java
+++ /dev/null
@@ -1,34 +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;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Throwables.propagate;
-
-import org.jclouds.Fallback;
-
-public final class GoogleCloudStorageFallbacks {
-
- public static final class NullOnBucketAlreadyExists implements Fallback<Object> {
- public Object createOrPropagate(Throwable t) throws Exception {
- if (checkNotNull(t, "throwable") instanceof IllegalStateException) {
- return null;
- }
- throw propagate(t);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/GoogleCloudStorageProviderMetadata.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/GoogleCloudStorageProviderMetadata.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/GoogleCloudStorageProviderMetadata.java
deleted file mode 100644
index 1431a5c..0000000
--- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/GoogleCloudStorageProviderMetadata.java
+++ /dev/null
@@ -1,72 +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;
-
-import java.net.URI;
-import java.util.Properties;
-
-import org.jclouds.providers.ProviderMetadata;
-import org.jclouds.providers.internal.BaseProviderMetadata;
-
-import com.google.auto.service.AutoService;
-
-/** Note: This does not set iso3166Codes as Google intentionally does not document them. */
-@AutoService(ProviderMetadata.class)
-public final class GoogleCloudStorageProviderMetadata extends BaseProviderMetadata {
-
- public static Builder builder() {
- return new Builder();
- }
-
- @Override
- public Builder toBuilder() {
- return builder().fromProviderMetadata(this);
- }
-
- public GoogleCloudStorageProviderMetadata() {
- super(builder());
- }
-
- public GoogleCloudStorageProviderMetadata(Builder builder) {
- super(builder);
- }
-
- public static Properties defaultProperties() {
- return new Properties(); // currently all are set in the api metadata class.
- }
-
- public static final class Builder extends BaseProviderMetadata.Builder {
-
- private Builder() {
- id("google-cloud-storage") //
- .name("Google Cloud Storage") //
- .apiMetadata(new GoogleCloudStorageApiMetadata()) //
- .homepage(URI.create("https://cloud.google.com/storage")) //
- .console(URI.create("https://console.developers.google.com/project")) //
- .defaultProperties(GoogleCloudStorageProviderMetadata.defaultProperties());
- }
-
- @Override public GoogleCloudStorageProviderMetadata build() {
- return new GoogleCloudStorageProviderMetadata(this);
- }
-
- @Override public Builder fromProviderMetadata(ProviderMetadata in) {
- super.fromProviderMetadata(in);
- return this;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/binders/MultipartUploadBinder.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/binders/MultipartUploadBinder.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/binders/MultipartUploadBinder.java
deleted file mode 100644
index ca6422b..0000000
--- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/binders/MultipartUploadBinder.java
+++ /dev/null
@@ -1,69 +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.binders;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static javax.ws.rs.core.HttpHeaders.CONTENT_TYPE;
-import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
-
-import java.util.Map;
-
-import org.jclouds.googlecloudstorage.domain.templates.ObjectTemplate;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.io.Payload;
-import org.jclouds.io.Payloads;
-import org.jclouds.io.payloads.MultipartForm;
-import org.jclouds.io.payloads.Part;
-import org.jclouds.io.payloads.StringPayload;
-import org.jclouds.json.Json;
-import org.jclouds.rest.MapBinder;
-
-import com.google.inject.Inject;
-
-public final class MultipartUploadBinder implements MapBinder {
- private static final String BOUNDARY_HEADER = "multipart_boundary";
-
- private final Json json;
-
- @Inject MultipartUploadBinder(Json json){
- this.json = json;
- }
-
- @Override public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
- ObjectTemplate template = (ObjectTemplate) postParams.get("template");
- Payload payload = (Payload) postParams.get("payload");
-
- String contentType = checkNotNull(template.contentType(), "contentType");
- Long length = checkNotNull(template.size(), "contentLength");
-
- StringPayload jsonPayload = Payloads.newStringPayload(json.toJson(template));
-
- payload.getContentMetadata().setContentLength(length);
-
- Part jsonPart = Part.create("Metadata", jsonPayload, new Part.PartOptions().contentType(APPLICATION_JSON));
- Part mediaPart = Part.create(template.name(), payload, new Part.PartOptions().contentType(contentType));
-
- request.setPayload(new MultipartForm(BOUNDARY_HEADER, jsonPart, mediaPart));
- // HeaderPart
- request.toBuilder().replaceHeader(CONTENT_TYPE, "Multipart/related; boundary= " + BOUNDARY_HEADER).build();
- return request;
- }
-
- @Override public <R extends HttpRequest> R bindToRequest(R request, Object input) {
- return request;
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/binders/UploadBinder.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/binders/UploadBinder.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/binders/UploadBinder.java
deleted file mode 100644
index 9b6fa4b..0000000
--- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/binders/UploadBinder.java
+++ /dev/null
@@ -1,38 +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.binders;
-
-import java.util.Map;
-
-import org.jclouds.http.HttpRequest;
-import org.jclouds.io.Payload;
-import org.jclouds.rest.MapBinder;
-
-public class UploadBinder implements MapBinder {
-
- @Override public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
- Payload payload = (Payload) postParams.get("payload");
-
- request.getPayload().getContentMetadata().setContentType(payload.getContentMetadata().getContentType());
- request.setPayload(payload);
- return bindToRequest(request, payload);
- }
-
- @Override public <R extends HttpRequest> R bindToRequest(R request, Object input) {
- return request;
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/GoogleCloudStorageBlobRequestSigner.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/GoogleCloudStorageBlobRequestSigner.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/GoogleCloudStorageBlobRequestSigner.java
deleted file mode 100644
index 390ada1..0000000
--- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/GoogleCloudStorageBlobRequestSigner.java
+++ /dev/null
@@ -1,153 +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 java.net.URI;
-import java.security.InvalidKeyException;
-import java.security.NoSuchAlgorithmException;
-import java.security.PrivateKey;
-import java.security.Signature;
-import java.security.SignatureException;
-
-import javax.annotation.Resource;
-import javax.inject.Provider;
-
-import org.jclouds.Constants;
-import org.jclouds.blobstore.BlobRequestSigner;
-import org.jclouds.blobstore.domain.Blob;
-import org.jclouds.blobstore.functions.BlobToHttpGetOptions;
-import org.jclouds.date.TimeStamp;
-import org.jclouds.domain.Credentials;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpUtils;
-import org.jclouds.http.Uris;
-import org.jclouds.http.options.GetOptions;
-import org.jclouds.logging.Logger;
-import org.jclouds.oauth.v2.config.Authorization;
-
-import com.google.common.base.Charsets;
-import com.google.common.base.Strings;
-import com.google.common.base.Supplier;
-import com.google.common.io.BaseEncoding;
-import com.google.common.net.HttpHeaders;
-import com.google.inject.Inject;
-import com.google.inject.name.Named;
-
-public final class GoogleCloudStorageBlobRequestSigner implements BlobRequestSigner {
- private static final int DEFAULT_EXPIRY_SECONDS = 15 * 60;
- private static final URI STORAGE_URL = URI.create("http://storage.googleapis.com/");
-
- private final Supplier<Credentials> creds;
- private final Supplier<PrivateKey> privateKey;
- private final Provider<Long> timestamp;
- private final HttpUtils utils;
-
- private final BlobToHttpGetOptions toGetOptions = new BlobToHttpGetOptions();
-
- @Resource
- @Named(Constants.LOGGER_SIGNATURE)
- protected Logger signatureLog = Logger.NULL;
-
- @Inject
- protected GoogleCloudStorageBlobRequestSigner(@org.jclouds.location.Provider Supplier<Credentials> creds,
- @Authorization Supplier<PrivateKey> privateKey, @TimeStamp Provider<Long> timestamp, HttpUtils utils) {
- this.creds = creds;
- this.privateKey = privateKey;
- this.timestamp = timestamp;
- this.utils = utils;
- }
-
- @Override
- public HttpRequest signGetBlob(String container, String name) {
- return signGetBlob(container, name, DEFAULT_EXPIRY_SECONDS);
- }
-
- @Override
- public HttpRequest signGetBlob(String container, String name, long timeInSeconds) {
- return sign("GET", container, name, GetOptions.NONE, timestamp.get() + timeInSeconds, null);
- }
-
- @Override
- public HttpRequest signGetBlob(String container, String name, org.jclouds.blobstore.options.GetOptions options) {
- return sign("GET", container, name, toGetOptions.apply(options), timestamp.get() + DEFAULT_EXPIRY_SECONDS, null);
- }
-
- @Override
- public HttpRequest signPutBlob(String container, Blob blob) {
- return signPutBlob(container, blob, DEFAULT_EXPIRY_SECONDS);
- }
-
- @Override
- public HttpRequest signPutBlob(String container, Blob blob, long timeInSeconds) {
- return sign("PUT", container, blob.getMetadata().getName(), GetOptions.NONE, timestamp.get() + timeInSeconds, null);
- }
-
- @Deprecated
- @Override
- public HttpRequest signRemoveBlob(String container, String name) {
- throw new UnsupportedOperationException();
- }
-
- private HttpRequest sign(String method, String container, String name, GetOptions options, long expires, String contentType) {
- checkNotNull(container, "container");
- checkNotNull(name, "name");
-
- HttpRequest.Builder request = HttpRequest.builder()
- .method(method)
- .endpoint(Uris.uriBuilder(STORAGE_URL).appendPath(container).appendPath(name).build());
- if (contentType != null) {
- request.replaceHeader(HttpHeaders.CONTENT_TYPE, contentType);
- }
-
- String stringToSign = createStringToSign(request.build(), expires);
- byte[] rawSignature;
- try {
- Signature signer = Signature.getInstance("SHA256withRSA");
- signer.initSign(privateKey.get());
- signer.update(stringToSign.getBytes(Charsets.UTF_8));
- rawSignature = signer.sign();
- } catch (InvalidKeyException ike) {
- throw new RuntimeException(ike);
- } catch (NoSuchAlgorithmException nsae) {
- throw new RuntimeException(nsae);
- } catch (SignatureException se) {
- throw new RuntimeException(se);
- }
- String signature = BaseEncoding.base64().encode(rawSignature);
-
- return (HttpRequest) request
- .addQueryParam("Expires", String.valueOf(expires))
- .addQueryParam("GoogleAccessId", creds.get().identity)
- .addQueryParam("Signature", signature)
- .headers(options.buildRequestHeaders())
- .build();
- }
-
- private String createStringToSign(HttpRequest request, long expires) {
- utils.logRequest(signatureLog, request, ">>");
- StringBuilder buffer = new StringBuilder();
- buffer.append(request.getMethod()).append("\n");
- buffer.append(Strings.nullToEmpty(request.getFirstHeaderOrNull(HttpHeaders.CONTENT_MD5))).append("\n");
- buffer.append(Strings.nullToEmpty(request.getFirstHeaderOrNull(HttpHeaders.CONTENT_TYPE))).append("\n");
- buffer.append(String.valueOf(expires)).append("\n");
- // TODO: extension headers
- buffer.append(request.getEndpoint().getPath());
- return buffer.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/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
deleted file mode 100644
index c86dcc8..0000000
--- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/GoogleCloudStorageBlobStore.java
+++ /dev/null
@@ -1,468 +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.util.List;
-import java.util.Set;
-import java.util.UUID;
-
-import javax.inject.Inject;
-
-import org.jclouds.blobstore.BlobStoreContext;
-import org.jclouds.blobstore.domain.Blob;
-import org.jclouds.blobstore.domain.BlobAccess;
-import org.jclouds.blobstore.domain.BlobMetadata;
-import org.jclouds.blobstore.domain.ContainerAccess;
-import org.jclouds.blobstore.domain.MultipartPart;
-import org.jclouds.blobstore.domain.MultipartUpload;
-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.functions.BlobToHttpGetOptions;
-import org.jclouds.blobstore.internal.BaseBlobStore;
-import org.jclouds.blobstore.options.CopyOptions;
-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.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.ObjectAccessControls;
-import org.jclouds.googlecloudstorage.domain.templates.BucketTemplate;
-import org.jclouds.googlecloudstorage.domain.templates.ComposeObjectTemplate;
-import org.jclouds.googlecloudstorage.domain.templates.ObjectAccessControlsTemplate;
-import org.jclouds.googlecloudstorage.domain.templates.ObjectTemplate;
-import org.jclouds.googlecloudstorage.options.InsertObjectOptions;
-import org.jclouds.googlecloudstorage.options.ListObjectOptions;
-import org.jclouds.http.HttpResponseException;
-import org.jclouds.io.ContentMetadata;
-import org.jclouds.io.Payload;
-import org.jclouds.io.PayloadSlicer;
-import org.jclouds.util.Strings2;
-
-import com.google.common.base.Function;
-import com.google.common.base.Supplier;
-import com.google.common.collect.ImmutableList;
-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 Supplier<String> projectId;
- private final BlobToHttpGetOptions blob2ObjectGetOptions;
-
- @Inject GoogleCloudStorageBlobStore(BlobStoreContext context, BlobUtils blobUtils, Supplier<Location> defaultLocation,
- @Memoized Supplier<Set<? extends Location>> locations, PayloadSlicer slicer, GoogleCloudStorageApi api,
- BucketToStorageMetadata bucketToStorageMetadata, ObjectToBlobMetadata objectToBlobMetadata,
- ObjectListToStorageMetadata objectListToStorageMetadata,
- Provider<FetchBlobMetadata> fetchBlobMetadataProvider,
- BlobMetadataToObjectTemplate blobMetadataToObjectTemplate,
- BlobStoreListContainerOptionsToListObjectOptions listContainerOptionsToListObjectOptions,
- @CurrentProject Supplier<String> projectId,
- BlobToHttpGetOptions blob2ObjectGetOptions) {
- super(context, blobUtils, defaultLocation, locations, slicer);
- 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.blob2ObjectGetOptions = checkNotNull(blob2ObjectGetOptions, "blob2ObjectGetOptions");
- }
-
- @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;
- }
-
- @Override
- public ContainerAccess getContainerAccess(String container) {
- ObjectAccessControls controls = api.getDefaultObjectAccessControlsApi().getDefaultObjectAccessControls(container, "allUsers");
- if (controls == null || controls.role() == DomainResourceReferences.ObjectRole.OWNER) {
- return ContainerAccess.PRIVATE;
- } else {
- return ContainerAccess.PUBLIC_READ;
- }
- }
-
- @Override
- public void setContainerAccess(String container, ContainerAccess access) {
- ObjectAccessControlsTemplate doAclTemplate;
- if (access == ContainerAccess.PUBLIC_READ) {
- doAclTemplate = ObjectAccessControlsTemplate.create("allUsers", READER);
- api.getDefaultObjectAccessControlsApi().createDefaultObjectAccessControls(container, doAclTemplate);
- } else {
- api.getDefaultObjectAccessControlsApi().deleteDefaultObjectAccessControls(container, "allUsers");
- }
- }
-
- /** Returns list of of all the objects */
- @Override
- public PageSet<? extends StorageMetadata> list(String container) {
- return list(container, ListContainerOptions.NONE);
- }
-
- @Override
- public PageSet<? extends StorageMetadata> list(String container, ListContainerOptions options) {
- 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;
- }
-
- /**
- * 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) {
- return api.getObjectApi().objectExists(container, Strings2.urlEncode(name));
- }
-
- /**
- * This supports multipart/related upload which has exactly 2 parts, media-part and metadata-part
- */
- @Override
- public String putBlob(String container, Blob blob) {
- return putBlob(container, blob, PutOptions.NONE);
- }
-
- @Override
- public String putBlob(String container, Blob blob, PutOptions options) {
- if (options.isMultipart() || !blob.getPayload().isRepeatable()) {
- // JCLOUDS-912 prevents using single-part uploads with InputStream payloads.
- // Work around this with multi-part upload which buffers parts in-memory.
- return putMultipartBlob(container, blob, options);
- } else {
- checkNotNull(blob.getPayload().getContentMetadata().getContentLength());
-
- ObjectTemplate template = blobMetadataToObjectTemplate.apply(blob.getMetadata());
-
- HashCode md5 = blob.getMetadata().getContentMetadata().getContentMD5AsHashCode();
- if (md5 != null) {
- template.md5Hash(base64().encode(md5.asBytes()));
- }
-
- if (options.getBlobAccess() == BlobAccess.PUBLIC_READ) {
- ObjectAccessControls controls = ObjectAccessControls.builder()
- .entity("allUsers")
- .bucket(container)
- .role(READER)
- .build();
- template.addAcl(controls);
- }
-
- return api.getObjectApi().multipartUpload(container, template, blob.getPayload()).etag();
- }
- }
-
- @Override
- public BlobMetadata blobMetadata(String container, String name) {
- return objectToBlobMetadata.apply(api.getObjectApi().getObject(container, Strings2.urlEncode(name)));
- }
-
- @Override
- public Blob getBlob(String container, String name, GetOptions options) {
- GoogleCloudStorageObject gcsObject = api.getObjectApi().getObject(container, Strings2.urlEncode(name));
- if (gcsObject == null) {
- return null;
- }
- org.jclouds.http.options.GetOptions httpOptions = blob2ObjectGetOptions.apply(options);
- MutableBlobMetadata metadata = objectToBlobMetadata.apply(gcsObject);
- Blob blob = new BlobImpl(metadata);
- // TODO: Does getObject not get the payload?!
- Payload payload = api.getObjectApi().download(container, Strings2.urlEncode(name), httpOptions).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) {
- api.getObjectApi().deleteObject(container, Strings2.urlEncode(name));
- }
-
- @Override
- public BlobAccess getBlobAccess(String container, String name) {
- ObjectAccessControls controls = api.getObjectAccessControlsApi().getObjectAccessControls(container,
- Strings2.urlEncode(name), "allUsers");
- if (controls != null && controls.role() == DomainResourceReferences.ObjectRole.READER) {
- return BlobAccess.PUBLIC_READ;
- } else {
- return BlobAccess.PRIVATE;
- }
- }
-
- @Override
- public void setBlobAccess(String container, String name, BlobAccess access) {
- if (access == BlobAccess.PUBLIC_READ) {
- ObjectAccessControls controls = ObjectAccessControls.builder()
- .entity("allUsers")
- .bucket(container)
- .role(READER)
- .build();
- api.getObjectApi().patchObject(container, Strings2.urlEncode(name), new ObjectTemplate().addAcl(controls));
- } else {
- api.getObjectAccessControlsApi().deleteObjectAccessControls(container, Strings2.urlEncode(name), "allUsers");
- }
- }
-
- @Override
- protected boolean deleteAndVerifyContainerGone(String container) {
- ListPageWithPrefixes<GoogleCloudStorageObject> list = api.getObjectApi().listObjects(container);
-
- if (list == null || (!list.iterator().hasNext() && list.prefixes().isEmpty())) {
- if (!api.getBucketApi().deleteBucket(container)) {
- return true;
- } else {
- return !api.getBucketApi().bucketExist(container);
- }
- }
-
- return false;
- }
-
- @Override
- public String copyBlob(String fromContainer, String fromName, String toContainer, String toName,
- CopyOptions options) {
- if (options.ifMatch() != null) {
- throw new UnsupportedOperationException("GCS does not support ifMatch");
- }
- if (options.ifNoneMatch() != null) {
- throw new UnsupportedOperationException("GCS does not support ifNoneMatch");
- }
- if (options.ifModifiedSince() != null) {
- throw new UnsupportedOperationException("GCS does not support ifModifiedSince");
- }
- if (options.ifUnmodifiedSince() != null) {
- throw new UnsupportedOperationException("GCS does not support ifUnmodifiedSince");
- }
-
- if (options.contentMetadata() == null && options.userMetadata() == null) {
- return api.getObjectApi().copyObject(toContainer, Strings2.urlEncode(toName), fromContainer,
- Strings2.urlEncode(fromName)).etag();
- }
-
- ObjectTemplate template = new ObjectTemplate();
-
- if (options.contentMetadata() != null) {
- ContentMetadata contentMetadata = options.contentMetadata();
-
- String contentDisposition = contentMetadata.getContentDisposition();
- if (contentDisposition != null) {
- template.contentDisposition(contentDisposition);
- }
-
- // TODO: causes failures with subsequent GET operations:
- // HTTP/1.1 failed with response: HTTP/1.1 503 Service Unavailable; content: [Service Unavailable]
-/*
- String contentEncoding = contentMetadata.getContentEncoding();
- if (contentEncoding != null) {
- template.contentEncoding(contentEncoding);
- }
-*/
-
- String contentLanguage = contentMetadata.getContentLanguage();
- if (contentLanguage != null) {
- template.contentLanguage(contentLanguage);
- }
-
- String contentType = contentMetadata.getContentType();
- if (contentType != null) {
- template.contentType(contentType);
- }
- }
-
- if (options.userMetadata() != null) {
- template.customMetadata(options.userMetadata());
- }
-
- return api.getObjectApi().copyObject(toContainer, Strings2.urlEncode(toName), fromContainer,
- Strings2.urlEncode(fromName), template).etag();
- }
-
- @Override
- public MultipartUpload initiateMultipartUpload(String container, BlobMetadata blobMetadata, PutOptions options) {
- String uploadId = UUID.randomUUID().toString();
- return MultipartUpload.create(container, blobMetadata.getName(), uploadId, blobMetadata, options);
- }
-
- @Override
- public void abortMultipartUpload(MultipartUpload mpu) {
- ImmutableList.Builder<String> builder = ImmutableList.builder();
- List<MultipartPart> parts = listMultipartUpload(mpu);
- for (MultipartPart part : parts) {
- builder.add(getMPUPartName(mpu, part.partNumber()));
- }
- removeBlobs(mpu.containerName(), builder.build());
- }
-
- @Override
- public String completeMultipartUpload(MultipartUpload mpu, List<MultipartPart> parts) {
- ImmutableList.Builder<GoogleCloudStorageObject> objects = ImmutableList.builder();
- for (MultipartPart part : parts) {
- objects.add(api.getObjectApi().getObject(mpu.containerName(),
- Strings2.urlEncode(getMPUPartName(mpu, part.partNumber()))));
- }
-
- ObjectTemplate destination = blobMetadataToObjectTemplate.apply(mpu.blobMetadata());
- if (mpu.putOptions().getBlobAccess() == BlobAccess.PUBLIC_READ) {
- ObjectAccessControls controls = ObjectAccessControls.builder()
- .entity("allUsers")
- .bucket(mpu.containerName())
- .role(READER)
- .build();
- destination.addAcl(controls);
- }
-
- ComposeObjectTemplate template = ComposeObjectTemplate.builder()
- .fromGoogleCloudStorageObject(objects.build())
- .destination(destination).build();
- String eTag = api.getObjectApi().composeObjects(mpu.containerName(), Strings2.urlEncode(mpu.blobName()), template)
- .etag();
-
- // remove parts, composite object keeps a reference to them
- ImmutableList.Builder<String> builder = ImmutableList.builder();
- for (MultipartPart part : parts) {
- builder.add(getMPUPartName(mpu, part.partNumber()));
- }
- removeBlobs(mpu.containerName(), builder.build());
-
- return eTag;
- }
-
- @Override
- public MultipartPart uploadMultipartPart(MultipartUpload mpu, int partNumber, Payload payload) {
- String partName = getMPUPartName(mpu, partNumber);
- long partSize = payload.getContentMetadata().getContentLength();
- InsertObjectOptions insertOptions = new InsertObjectOptions().name(partName);
- GoogleCloudStorageObject object = api.getObjectApi().simpleUpload(mpu.containerName(),
- mpu.blobMetadata().getContentMetadata().getContentType(), partSize, payload, insertOptions);
- return MultipartPart.create(partNumber, partSize, object.etag(), object.updated());
- }
-
- @Override
- public List<MultipartPart> listMultipartUpload(MultipartUpload mpu) {
- ImmutableList.Builder<MultipartPart> parts = ImmutableList.builder();
- PageSet<? extends StorageMetadata> pageSet = list(mpu.containerName(),
- new ListContainerOptions().prefix(mpu.id() + "_"));
- // TODO: pagination
- for (StorageMetadata sm : pageSet) {
- int lastUnderscore = sm.getName().lastIndexOf('_');
- int partNumber = Integer.parseInt(sm.getName().substring(lastUnderscore + 1));
- parts.add(MultipartPart.create(partNumber, sm.getSize(), sm.getETag(), sm.getLastModified()));
- }
- return parts.build();
- }
-
- @Override
- public List<MultipartUpload> listMultipartUploads(String container) {
- throw new UnsupportedOperationException("not supported");
- }
-
- @Override
- public long getMinimumMultipartPartSize() {
- return 5L * 1024L * 1024L;
- }
-
- @Override
- public long getMaximumMultipartPartSize() {
- return 5L * 1024L * 1024L * 1024L;
- }
-
- @Override
- public int getMaximumNumberOfParts() {
- // can raise limit via composite objects of composites
- return 32;
- }
-
- private static String getMPUPartName(MultipartUpload mpu, int partNumber) {
- return String.format("%s_%08d", mpu.id(), partNumber);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/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
deleted file mode 100644
index 1392d3f..0000000
--- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/config/GoogleCloudStorageBlobStoreContextModule.java
+++ /dev/null
@@ -1,44 +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.config;
-
-import org.jclouds.blobstore.BlobRequestSigner;
-import org.jclouds.blobstore.BlobStore;
-import org.jclouds.blobstore.attr.ConsistencyModel;
-import org.jclouds.date.TimeStamp;
-import org.jclouds.googlecloudstorage.blobstore.GoogleCloudStorageBlobRequestSigner;
-import org.jclouds.googlecloudstorage.blobstore.GoogleCloudStorageBlobStore;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Provides;
-import com.google.inject.Scopes;
-
-public class GoogleCloudStorageBlobStoreContextModule extends AbstractModule {
-
- @Override
- protected void configure() {
- bind(ConsistencyModel.class).toInstance(ConsistencyModel.EVENTUAL);
- bind(BlobStore.class).to(GoogleCloudStorageBlobStore.class).in(Scopes.SINGLETON);
- bind(BlobRequestSigner.class).to(GoogleCloudStorageBlobRequestSigner.class);
- }
-
- @Provides
- @TimeStamp
- protected final Long unixEpochTimestamp() {
- return System.currentTimeMillis() / 1000;
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a4acb11f/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/functions/BlobMetadataToObjectTemplate.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/functions/BlobMetadataToObjectTemplate.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/functions/BlobMetadataToObjectTemplate.java
deleted file mode 100644
index e40ce49..0000000
--- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/functions/BlobMetadataToObjectTemplate.java
+++ /dev/null
@@ -1,56 +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.functions;
-
-import static com.google.common.io.BaseEncoding.base64;
-
-import java.util.Map;
-
-import org.jclouds.blobstore.domain.BlobMetadata;
-import org.jclouds.googlecloudstorage.domain.templates.ObjectTemplate;
-import org.jclouds.io.ContentMetadata;
-
-import com.google.common.base.Function;
-import com.google.common.hash.HashCode;
-
-public class BlobMetadataToObjectTemplate implements Function<BlobMetadata, ObjectTemplate> {
-
- public ObjectTemplate apply(BlobMetadata from) {
- if (from == null)
- return null;
-
- String name = from.getName();
- Map<String, String> userMeta = from.getUserMetadata();
-
- ContentMetadata metadata = from.getContentMetadata();
- String contentDisposition = metadata.getContentDisposition();
- String contentEncoding = metadata.getContentEncoding();
- String contentLanguage = metadata.getContentLanguage();
- String contentType = metadata.getContentType();
- Long contentLength = metadata.getContentLength();
-
- HashCode md5 = metadata.getContentMD5AsHashCode();
-
- ObjectTemplate template = new ObjectTemplate().contentType(contentType).size(contentLength)
- .contentEncoding(contentEncoding).contentLanguage(contentLanguage)
- .contentDisposition(contentDisposition).name(name).customMetadata(userMeta);
- if (md5 != null) {
- template.md5Hash(base64().encode(md5.asBytes()));
- }
- return template;
- }
-}