JCLOUDS-1272: Promote B2 to core
Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs/repo Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs/commit/85b30385 Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs/tree/85b30385 Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs/diff/85b30385 Branch: refs/heads/master Commit: 85b30385e7e538f5de4295fbaaf8802909fe92c7 Parents: dbadb27 Author: Andrew Gaul <[email protected]> Authored: Mon May 8 14:52:41 2017 -0700 Committer: Andrew Gaul <[email protected]> Committed: Mon May 8 14:52:58 2017 -0700 ---------------------------------------------------------------------- b2/pom.xml | 132 ----- b2/src/main/java/org/jclouds/b2/B2Api.java | 40 -- .../main/java/org/jclouds/b2/B2ApiMetadata.java | 91 ---- .../java/org/jclouds/b2/B2ProviderMetadata.java | 66 --- .../org/jclouds/b2/B2ResponseException.java | 38 -- .../jclouds/b2/binders/UploadFileBinder.java | 56 --- .../jclouds/b2/binders/UploadPartBinder.java | 47 -- .../org/jclouds/b2/blobstore/B2BlobStore.java | 493 ------------------- .../config/B2BlobStoreContextModule.java | 32 -- .../org/jclouds/b2/config/B2HttpApiModule.java | 88 ---- .../main/java/org/jclouds/b2/domain/Action.java | 33 -- .../org/jclouds/b2/domain/Authorization.java | 38 -- .../java/org/jclouds/b2/domain/B2Error.java | 33 -- .../java/org/jclouds/b2/domain/B2Object.java | 52 -- .../org/jclouds/b2/domain/B2ObjectList.java | 52 -- .../main/java/org/jclouds/b2/domain/Bucket.java | 34 -- .../java/org/jclouds/b2/domain/BucketList.java | 34 -- .../java/org/jclouds/b2/domain/BucketType.java | 34 -- .../jclouds/b2/domain/DeleteFileResponse.java | 32 -- .../b2/domain/GetUploadPartResponse.java | 35 -- .../org/jclouds/b2/domain/HideFileResponse.java | 37 -- .../jclouds/b2/domain/ListPartsResponse.java | 51 -- .../ListUnfinishedLargeFilesResponse.java | 55 --- .../b2/domain/MultipartUploadResponse.java | 41 -- .../jclouds/b2/domain/UploadFileResponse.java | 41 -- .../jclouds/b2/domain/UploadPartResponse.java | 34 -- .../jclouds/b2/domain/UploadUrlResponse.java | 35 -- .../jclouds/b2/features/AuthorizationApi.java | 37 -- .../java/org/jclouds/b2/features/BucketApi.java | 75 --- .../org/jclouds/b2/features/MultipartApi.java | 104 ---- .../java/org/jclouds/b2/features/ObjectApi.java | 149 ------ .../org/jclouds/b2/filters/B2RetryHandler.java | 90 ---- .../b2/filters/RequestAuthorization.java | 59 --- .../filters/RequestAuthorizationDownload.java | 59 --- .../b2/functions/ParseB2ObjectFromResponse.java | 66 --- .../handlers/ParseB2ErrorFromJsonContent.java | 61 --- .../org/jclouds/b2/reference/B2Headers.java | 36 -- .../org/jclouds/b2/B2ProviderMetadataTest.java | 27 - .../integration/B2BlobIntegrationLiveTest.java | 244 --------- .../blobstore/integration/B2BlobLiveTest.java | 42 -- .../integration/B2BlobSignerLiveTest.java | 112 ----- .../B2ContainerIntegrationLiveTest.java | 84 ---- .../integration/B2ContainerLiveTest.java | 27 - .../org/jclouds/b2/features/B2TestUtils.java | 139 ------ .../jclouds/b2/features/BucketApiLiveTest.java | 106 ---- .../jclouds/b2/features/BucketApiMockTest.java | 141 ------ .../b2/features/MultipartApiLiveTest.java | 194 -------- .../b2/features/MultipartApiMockTest.java | 246 --------- .../jclouds/b2/features/ObjectApiLiveTest.java | 284 ----------- .../jclouds/b2/features/ObjectApiMockTest.java | 436 ---------------- .../jclouds/b2/internal/BaseB2ApiLiveTest.java | 33 -- .../resources/authorize_account_response.json | 7 - b2/src/test/resources/bucket.json | 6 - .../resources/cancel_large_file_request.json | 3 - .../resources/cancel_large_file_response.json | 6 - .../test/resources/create_bucket_request.json | 5 - .../delete_bucket_already_deleted_response.json | 5 - .../test/resources/delete_bucket_request.json | 4 - ...e_file_version_already_deleted_response.json | 5 - .../test/resources/delete_object_request.json | 4 - .../test/resources/delete_object_response.json | 4 - .../resources/finish_large_file_request.json | 7 - .../resources/finish_large_file_response.json | 14 - .../get_file_info_deleted_file_response.json | 5 - .../test/resources/get_file_info_request.json | 3 - .../test/resources/get_file_info_response.json | 12 - .../resources/get_upload_part_url_request.json | 3 - .../resources/get_upload_part_url_response.json | 5 - .../get_upload_url_deleted_bucket_response.json | 5 - .../test/resources/get_upload_url_request.json | 3 - .../test/resources/get_upload_url_response.json | 5 - b2/src/test/resources/hide_file_request.json | 4 - b2/src/test/resources/hide_file_response.json | 6 - b2/src/test/resources/list_buckets_request.json | 3 - .../test/resources/list_buckets_response.json | 21 - .../test/resources/list_file_names_request.json | 3 - .../resources/list_file_names_response.json | 19 - .../resources/list_file_versions_request.json | 3 - .../resources/list_file_versions_response.json | 27 - b2/src/test/resources/list_parts_request.json | 5 - b2/src/test/resources/list_parts_response.json | 26 - .../list_unfinished_large_files_request.json | 5 - .../list_unfinished_large_files_response.json | 16 - b2/src/test/resources/log4j.xml | 106 ---- .../resources/start_large_file_request.json | 8 - .../resources/start_large_file_response.json | 11 - .../test/resources/update_bucket_request.json | 5 - b2/src/test/resources/upload_file_response.json | 13 - b2/src/test/resources/upload_part_response.json | 6 - pom.xml | 1 - 90 files changed, 5004 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/85b30385/b2/pom.xml ---------------------------------------------------------------------- diff --git a/b2/pom.xml b/b2/pom.xml deleted file mode 100644 index ded3513..0000000 --- a/b2/pom.xml +++ /dev/null @@ -1,132 +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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" - 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</artifactId> - <version>2.1.0-SNAPSHOT</version> - </parent> - - <!-- TODO: when out of labs, switch to org.jclouds.api --> - <groupId>org.apache.jclouds.labs</groupId> - <artifactId>b2</artifactId> - <name>Apache jclouds B2 API</name> - <description>BlobStore binding to the Backblaze B2 API</description> - <packaging>bundle</packaging> - - <properties> - <test.b2.identity>FIXME_IDENTITY</test.b2.identity> - <test.b2.credential>FIXME_CREDENTIAL</test.b2.credential> - <test.b2.build-version /> - <jclouds.osgi.export>org.jclouds.b2*;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-blobstore</artifactId> - <version>${project.parent.version}</version> - <type>jar</type> - </dependency> - <dependency> - <groupId>org.apache.jclouds</groupId> - <artifactId>jclouds-core</artifactId> - <version>${project.parent.version}</version> - <type>test-jar</type> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.jclouds</groupId> - <artifactId>jclouds-blobstore</artifactId> - <version>${project.parent.version}</version> - <type>test-jar</type> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.jclouds.driver</groupId> - <artifactId>jclouds-log4j</artifactId> - <version>${project.parent.version}</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>com.google.auto.value</groupId> - <artifactId>auto-value</artifactId> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>com.squareup.okhttp</groupId> - <artifactId>mockwebserver</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.assertj</groupId> - <artifactId>assertj-core</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>com.google.auto.service</groupId> - <artifactId>auto-service</artifactId> - <optional>true</optional> - </dependency> - </dependencies> - - <profiles> - <profile> - <id>live</id> - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-surefire-plugin</artifactId> - <executions> - <execution> - <id>integration</id> - <phase>integration-test</phase> - <goals> - <goal>test</goal> - </goals> - <configuration> - <groups>live</groups> - <systemPropertyVariables> - <jclouds.blobstore.httpstream.url>${jclouds.blobstore.httpstream.url}</jclouds.blobstore.httpstream.url> - <jclouds.blobstore.httpstream.md5>${jclouds.blobstore.httpstream.md5}</jclouds.blobstore.httpstream.md5> - <test.b2.endpoint>${test.b2.endpoint}</test.b2.endpoint> - <test.b2.api-version>${test.b2.api-version}</test.b2.api-version> - <test.b2.build-version>${test.b2.build-version}</test.b2.build-version> - <test.b2.identity>${test.b2.identity}</test.b2.identity> - <test.b2.credential>${test.b2.credential}</test.b2.credential> - </systemPropertyVariables> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - </build> - </profile> - </profiles> -</project> http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/85b30385/b2/src/main/java/org/jclouds/b2/B2Api.java ---------------------------------------------------------------------- diff --git a/b2/src/main/java/org/jclouds/b2/B2Api.java b/b2/src/main/java/org/jclouds/b2/B2Api.java deleted file mode 100644 index bd4ca28..0000000 --- a/b2/src/main/java/org/jclouds/b2/B2Api.java +++ /dev/null @@ -1,40 +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.b2; - -import java.io.Closeable; - -import org.jclouds.b2.features.AuthorizationApi; -import org.jclouds.b2.features.BucketApi; -import org.jclouds.b2.features.MultipartApi; -import org.jclouds.b2.features.ObjectApi; -import org.jclouds.rest.annotations.Delegate; - -/** Provides access to Backblaze B2 resources via their REST API. */ -public interface B2Api extends Closeable { - @Delegate - AuthorizationApi getAuthorizationApi(); - - @Delegate - BucketApi getBucketApi(); - - @Delegate - ObjectApi getObjectApi(); - - @Delegate - MultipartApi getMultipartApi(); -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/85b30385/b2/src/main/java/org/jclouds/b2/B2ApiMetadata.java ---------------------------------------------------------------------- diff --git a/b2/src/main/java/org/jclouds/b2/B2ApiMetadata.java b/b2/src/main/java/org/jclouds/b2/B2ApiMetadata.java deleted file mode 100644 index 96b3b09..0000000 --- a/b2/src/main/java/org/jclouds/b2/B2ApiMetadata.java +++ /dev/null @@ -1,91 +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.b2; - -import static org.jclouds.reflect.Reflection2.typeToken; - -import java.net.URI; -import java.util.Properties; -import java.util.concurrent.TimeUnit; - -import org.jclouds.Constants; -import org.jclouds.apis.ApiMetadata; -import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.reference.BlobStoreConstants; -import org.jclouds.b2.blobstore.config.B2BlobStoreContextModule; -import org.jclouds.b2.config.B2HttpApiModule; -import org.jclouds.rest.internal.BaseHttpApiMetadata; - -import com.google.common.collect.ImmutableSet; -import com.google.inject.Module; - -public final class B2ApiMetadata extends BaseHttpApiMetadata { - @Override - public Builder toBuilder() { - return new Builder().fromApiMetadata(this); - } - - public B2ApiMetadata() { - this(new Builder()); - } - - protected B2ApiMetadata(Builder builder) { - super(builder); - } - - public static Properties defaultProperties() { - Properties properties = BaseHttpApiMetadata.defaultProperties(); - properties.setProperty(BlobStoreConstants.PROPERTY_USER_METADATA_PREFIX, "X-Bz-Info-"); - properties.setProperty(Constants.PROPERTY_SESSION_INTERVAL, String.valueOf(TimeUnit.HOURS.toSeconds(1))); - properties.setProperty(Constants.PROPERTY_IDEMPOTENT_METHODS, "DELETE,GET,HEAD,OPTIONS,POST,PUT"); - properties.setProperty(Constants.PROPERTY_RETRY_DELAY_START, String.valueOf(TimeUnit.SECONDS.toMillis(1))); - return properties; - } - - public static class Builder extends BaseHttpApiMetadata.Builder<B2Api, Builder> { - - protected Builder() { - super(B2Api.class); - id("b2") - .name("Backblaze B2 API") - .identityName("Account Id") - .credentialName("Application Key") - .documentation(URI.create("https://www.backblaze.com/b2/docs/")) - .defaultEndpoint("https://api.backblazeb2.com/") - .defaultProperties(B2ApiMetadata.defaultProperties()) - .view(typeToken(BlobStoreContext.class)) - .defaultModules(ImmutableSet.<Class<? extends Module>>of( - B2HttpApiModule.class, - B2BlobStoreContextModule.class)); - } - - @Override - public B2ApiMetadata build() { - return new B2ApiMetadata(this); - } - - @Override - protected Builder self() { - return this; - } - - @Override - public Builder fromApiMetadata(ApiMetadata in) { - return this; - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/85b30385/b2/src/main/java/org/jclouds/b2/B2ProviderMetadata.java ---------------------------------------------------------------------- diff --git a/b2/src/main/java/org/jclouds/b2/B2ProviderMetadata.java b/b2/src/main/java/org/jclouds/b2/B2ProviderMetadata.java deleted file mode 100644 index fda7063..0000000 --- a/b2/src/main/java/org/jclouds/b2/B2ProviderMetadata.java +++ /dev/null @@ -1,66 +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.b2; - -import java.util.Properties; - -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.providers.internal.BaseProviderMetadata; - -import com.google.auto.service.AutoService; - -@AutoService(ProviderMetadata.class) -public final class B2ProviderMetadata extends BaseProviderMetadata { - @Override - public Builder toBuilder() { - return new Builder().fromProviderMetadata(this); - } - - public B2ProviderMetadata() { - this(new Builder()); - } - - protected B2ProviderMetadata(Builder builder) { - super(builder); - } - - public static Properties defaultProperties() { - Properties properties = B2ApiMetadata.defaultProperties(); - return properties; - } - - public static class Builder extends BaseProviderMetadata.Builder { - - protected Builder() { - id("b2") - .name("Backblaze B2") - .apiMetadata(new B2ApiMetadata()) - .endpoint("https://api.backblazeb2.com/") - .defaultProperties(B2ProviderMetadata.defaultProperties()); - } - - @Override - public B2ProviderMetadata build() { - return new B2ProviderMetadata(this); - } - - @Override - public Builder fromProviderMetadata(ProviderMetadata in) { - return this; - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/85b30385/b2/src/main/java/org/jclouds/b2/B2ResponseException.java ---------------------------------------------------------------------- diff --git a/b2/src/main/java/org/jclouds/b2/B2ResponseException.java b/b2/src/main/java/org/jclouds/b2/B2ResponseException.java deleted file mode 100644 index 3e89359..0000000 --- a/b2/src/main/java/org/jclouds/b2/B2ResponseException.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.b2; - -import org.jclouds.b2.domain.B2Error; -import org.jclouds.http.HttpCommand; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.HttpResponseException; - -import com.google.common.base.Preconditions; - -public final class B2ResponseException extends HttpResponseException { - private final B2Error error; - - public B2ResponseException(HttpCommand command, HttpResponse response, B2Error error) { - super("request " + command.getCurrentRequest().getRequestLine() + " failed with code " + response.getStatusCode() - + ", error: " + Preconditions.checkNotNull(error, "error").toString(), command, response); - this.error = error; - } - - public B2Error getError() { - return error; - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/85b30385/b2/src/main/java/org/jclouds/b2/binders/UploadFileBinder.java ---------------------------------------------------------------------- diff --git a/b2/src/main/java/org/jclouds/b2/binders/UploadFileBinder.java b/b2/src/main/java/org/jclouds/b2/binders/UploadFileBinder.java deleted file mode 100644 index aa4ebc9..0000000 --- a/b2/src/main/java/org/jclouds/b2/binders/UploadFileBinder.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.b2.binders; - -import java.util.Map; - -import org.jclouds.http.HttpRequest; -import org.jclouds.b2.domain.UploadUrlResponse; -import org.jclouds.b2.reference.B2Headers; -import org.jclouds.rest.MapBinder; - -import com.google.common.net.HttpHeaders; -import com.google.common.net.PercentEscaper; - -public final class UploadFileBinder implements MapBinder { - private static final PercentEscaper escaper = new PercentEscaper("._-/~!$'()*;=:@", false); - - @Override - public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) { - UploadUrlResponse uploadUrl = (UploadUrlResponse) postParams.get("uploadUrl"); - String fileName = (String) postParams.get("fileName"); - String contentSha1 = (String) postParams.get("contentSha1"); - if (contentSha1 == null) { - contentSha1 = "do_not_verify"; - } - Map<String, String> fileInfo = (Map<String, String>) postParams.get("fileInfo"); - HttpRequest.Builder builder = request.toBuilder() - .endpoint(uploadUrl.uploadUrl()) - .replaceHeader(HttpHeaders.AUTHORIZATION, uploadUrl.authorizationToken()) - .replaceHeader(B2Headers.CONTENT_SHA1, contentSha1) - .replaceHeader(B2Headers.FILE_NAME, escaper.escape(fileName)); - for (Map.Entry<String, String> entry : fileInfo.entrySet()) { - builder.replaceHeader(B2Headers.FILE_INFO_PREFIX + entry.getKey(), escaper.escape(entry.getValue())); - } - return (R) builder.build(); - } - - @Override - public <R extends HttpRequest> R bindToRequest(R request, Object input) { - throw new UnsupportedOperationException(); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/85b30385/b2/src/main/java/org/jclouds/b2/binders/UploadPartBinder.java ---------------------------------------------------------------------- diff --git a/b2/src/main/java/org/jclouds/b2/binders/UploadPartBinder.java b/b2/src/main/java/org/jclouds/b2/binders/UploadPartBinder.java deleted file mode 100644 index e89e2df..0000000 --- a/b2/src/main/java/org/jclouds/b2/binders/UploadPartBinder.java +++ /dev/null @@ -1,47 +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.b2.binders; - -import java.util.Map; - -import org.jclouds.http.HttpRequest; -import org.jclouds.b2.domain.GetUploadPartResponse; -import org.jclouds.b2.reference.B2Headers; -import org.jclouds.rest.MapBinder; - -import com.google.common.net.HttpHeaders; - -public final class UploadPartBinder implements MapBinder { - @Override - public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) { - GetUploadPartResponse uploadUrl = (GetUploadPartResponse) postParams.get("response"); - String contentSha1 = (String) postParams.get("contentSha1"); - if (contentSha1 == null) { - contentSha1 = "do_not_verify"; - } - return (R) request.toBuilder() - .endpoint(uploadUrl.uploadUrl()) - .replaceHeader(HttpHeaders.AUTHORIZATION, uploadUrl.authorizationToken()) - .replaceHeader(B2Headers.CONTENT_SHA1, contentSha1) - .build(); - } - - @Override - public <R extends HttpRequest> R bindToRequest(R request, Object input) { - throw new UnsupportedOperationException(); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/85b30385/b2/src/main/java/org/jclouds/b2/blobstore/B2BlobStore.java ---------------------------------------------------------------------- diff --git a/b2/src/main/java/org/jclouds/b2/blobstore/B2BlobStore.java b/b2/src/main/java/org/jclouds/b2/blobstore/B2BlobStore.java deleted file mode 100644 index b8d046c..0000000 --- a/b2/src/main/java/org/jclouds/b2/blobstore/B2BlobStore.java +++ /dev/null @@ -1,493 +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.b2.blobstore; - -import java.io.UnsupportedEncodingException; -import java.net.URI; -import java.net.URLEncoder; -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.TimeUnit; - -import javax.inject.Inject; - -import org.jclouds.b2.B2Api; -import org.jclouds.b2.B2ResponseException; -import org.jclouds.b2.domain.Authorization; -import org.jclouds.b2.domain.B2Object; -import org.jclouds.b2.domain.B2ObjectList; -import org.jclouds.b2.domain.Bucket; -import org.jclouds.b2.domain.BucketList; -import org.jclouds.b2.domain.BucketType; -import org.jclouds.b2.domain.GetUploadPartResponse; -import org.jclouds.b2.domain.ListPartsResponse; -import org.jclouds.b2.domain.ListUnfinishedLargeFilesResponse; -import org.jclouds.b2.domain.MultipartUploadResponse; -import org.jclouds.b2.domain.UploadFileResponse; -import org.jclouds.b2.domain.UploadUrlResponse; -import org.jclouds.b2.domain.UploadPartResponse; -import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.ContainerNotFoundException; -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.StorageType; -import org.jclouds.blobstore.domain.internal.BlobImpl; -import org.jclouds.blobstore.domain.internal.BlobMetadataImpl; -import org.jclouds.blobstore.domain.internal.MutableBlobMetadataImpl; -import org.jclouds.blobstore.domain.internal.PageSetImpl; -import org.jclouds.blobstore.domain.internal.StorageMetadataImpl; -import org.jclouds.blobstore.functions.BlobToHttpGetOptions; -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.util.BlobUtils; -import org.jclouds.collect.Memoized; -import org.jclouds.domain.Location; -import org.jclouds.io.ContentMetadata; -import org.jclouds.io.ContentMetadataBuilder; -import org.jclouds.io.MutableContentMetadata; -import org.jclouds.io.Payload; -import org.jclouds.io.PayloadSlicer; -import org.jclouds.io.payloads.BaseMutableContentMetadata; - -import com.google.common.base.Preconditions; -import com.google.common.base.Strings; -import com.google.common.base.Supplier; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Sets; -import com.google.common.net.HttpHeaders; -import com.google.common.util.concurrent.UncheckedExecutionException; - -public final class B2BlobStore extends BaseBlobStore { - private final B2Api api; - private final BlobToHttpGetOptions blob2ObjectGetOptions; - private final LoadingCache<String, Bucket> bucketNameToBucket; - private final Supplier<Authorization> auth; - - @Inject - B2BlobStore(BlobStoreContext context, BlobUtils blobUtils, Supplier<Location> defaultLocation, - @Memoized Supplier<Set<? extends Location>> locations, PayloadSlicer slicer, final B2Api api, - BlobToHttpGetOptions blob2ObjectGetOptions, @Memoized Supplier<Authorization> auth) { - super(context, blobUtils, defaultLocation, locations, slicer); - this.api = api; - this.blob2ObjectGetOptions = blob2ObjectGetOptions; - this.auth = auth; - this.bucketNameToBucket = CacheBuilder.newBuilder() - .expireAfterWrite(5, TimeUnit.MINUTES) - .build(new CacheLoader<String, Bucket>() { - @Override - public Bucket load(String bucketName) { - BucketList list = api.getBucketApi().listBuckets(); - for (Bucket bucket : list.buckets()) { - if (bucket.bucketName().equals(bucketName)) { - return bucket; - } - } - throw new ContainerNotFoundException(bucketName, null); - } - }); - } - - @Override - public PageSet<? extends StorageMetadata> list() { - ImmutableList.Builder<StorageMetadata> builder = ImmutableList.builder(); - BucketList list = api.getBucketApi().listBuckets(); - for (Bucket bucket : list.buckets()) { - builder.add(new StorageMetadataImpl(StorageType.CONTAINER, null, bucket.bucketName(), defaultLocation.get(), null, null, null, null, ImmutableMap.<String, String>of(), null)); - } - return new PageSetImpl<StorageMetadata>(builder.build(), null); - } - - @Override - public boolean containerExists(String container) { - BucketList list = api.getBucketApi().listBuckets(); - for (Bucket bucket : list.buckets()) { - if (bucket.bucketName().equals(container)) { - return true; - } - } - return false; - } - - @Override - public boolean createContainerInLocation(Location location, String container) { - return createContainerInLocation(location, container, CreateContainerOptions.NONE); - } - - @Override - public boolean createContainerInLocation(Location location, String container, CreateContainerOptions options) { - BucketType bucketType = options.isPublicRead() ? BucketType.ALL_PUBLIC : BucketType.ALL_PRIVATE; - try { - Bucket bucket = api.getBucketApi().createBucket(container, bucketType); - bucketNameToBucket.put(container, bucket); - } catch (B2ResponseException bre) { - if (bre.getError().code().equals("duplicate_bucket_name")) { - return false; - } - throw bre; - } - return true; - } - - @Override - public ContainerAccess getContainerAccess(String container) { - Bucket bucket = getBucket(container); - return bucket.bucketType() == BucketType.ALL_PUBLIC ? ContainerAccess.PUBLIC_READ : ContainerAccess.PRIVATE; - } - - @Override - public void setContainerAccess(String container, ContainerAccess access) { - Bucket bucket = getBucket(container); - - BucketType bucketType = access == ContainerAccess.PUBLIC_READ ? BucketType.ALL_PUBLIC : BucketType.ALL_PRIVATE; - bucket = api.getBucketApi().updateBucket(bucket.bucketId(), bucketType); - bucketNameToBucket.put(container, bucket); - } - - @Override - public PageSet<? extends StorageMetadata> list(String container) { - return list(container, ListContainerOptions.NONE); - } - - @Override - public PageSet<? extends StorageMetadata> list(String container, ListContainerOptions options) { - Preconditions.checkArgument(options.getDir() == null, "B2 does not support directories"); - String delimiter = null; - if (!options.isRecursive()) { - delimiter = "/"; - } - if (options.getDelimiter() != null) { - delimiter = options.getDelimiter(); - } - - Bucket bucket = getBucket(container); - - int size = 0; - ImmutableList.Builder<StorageMetadata> builder = ImmutableList.builder(); - Set<String> commonPrefixes = Sets.newHashSet(); - String marker = options.getMarker(); - while (true) { - B2ObjectList list = api.getObjectApi().listFileNames(bucket.bucketId(), marker, options.getMaxResults()); - for (B2ObjectList.Entry entry : list.files()) { - // B2 does not support server-side filtering via prefix and delimiter so we emulate it on the client. - if (options.getPrefix() != null && !entry.fileName().startsWith(options.getPrefix())) { - continue; - } - - if (delimiter != null) { - String fileName = entry.fileName(); - int index = entry.fileName().indexOf(delimiter, Strings.nullToEmpty(options.getPrefix()).length()); - if (index != -1) { - String prefix = entry.fileName().substring(0, index + 1); - if (!commonPrefixes.contains(prefix)) { - commonPrefixes.add(prefix); - ++size; - builder.add(new StorageMetadataImpl(StorageType.RELATIVE_PATH, null, prefix, null, null, null, null, null, ImmutableMap.<String, String>of(), null)); - } - continue; - } - } - - if (options.isDetailed()) { - BlobMetadata metadata = blobMetadata(container, entry.fileName()); - if (metadata != null) { - ++size; - builder.add(metadata); - } - } else { - Map<String, String> userMetadata = ImmutableMap.of(); - ContentMetadata metadata = ContentMetadataBuilder.create() - .contentLength(entry.size()) - .build(); - ++size; - builder.add(new BlobMetadataImpl(null, entry.fileName(), null, null, null, null, entry.uploadTimestamp(), userMetadata, null, container, metadata, entry.size())); - } - } - marker = list.nextFileName(); - if (marker == null || options.getMaxResults() == null || size == options.getMaxResults()) { - break; - } - } - return new PageSetImpl<StorageMetadata>(builder.build(), marker); - } - - @Override - public boolean blobExists(String container, String name) { - return blobMetadata(container, name) != null; - } - - @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.getBlobAccess() != BlobAccess.PRIVATE) { - throw new UnsupportedOperationException("B2 only supports private access blobs"); - } - - if (options.isMultipart()) { - return putMultipartBlob(container, blob, options); - } else { - String name = blob.getMetadata().getName(); - - // B2 versions all files so we store the original fileId to delete it after the upload succeeds - String oldFileId = getFileId(container, name); - - Bucket bucket = getBucket(container); - UploadUrlResponse uploadUrl = api.getObjectApi().getUploadUrl(bucket.bucketId()); - UploadFileResponse uploadFile = api.getObjectApi().uploadFile(uploadUrl, name, null, blob.getMetadata().getUserMetadata(), blob.getPayload()); - - if (oldFileId != null) { - api.getObjectApi().deleteFileVersion(name, oldFileId); - } - - return uploadFile.contentSha1(); // B2 does not support ETag, fake it with SHA-1 - } - } - - @Override - public BlobMetadata blobMetadata(String container, String name) { - String fileId = getFileId(container, name); - if (fileId == null) { - return null; - } - - B2Object b2Object = api.getObjectApi().getFileInfo(fileId); - if (b2Object == null) { - return null; - } - - return toBlobMetadata(container, b2Object); - } - - @Override - public Blob getBlob(String container, String name, GetOptions options) { - if (options.getIfMatch() != null || - options.getIfNoneMatch() != null || - options.getIfModifiedSince() != null || - options.getIfUnmodifiedSince() != null) { - throw new UnsupportedOperationException("B2 does not support conditional get"); - } - - B2Object b2Object = api.getObjectApi().downloadFileByName(container, name, blob2ObjectGetOptions.apply(options)); - if (b2Object == null) { - return null; - } - - MutableBlobMetadata metadata = toBlobMetadata(container, b2Object); - Blob blob = new BlobImpl(metadata); - blob.setPayload(b2Object.payload()); - if (b2Object.contentRange() != null) { - blob.getAllHeaders().put(HttpHeaders.CONTENT_RANGE, b2Object.contentRange()); - } - return blob; - } - - @Override - public void removeBlob(String container, String name) { - String fileId = getFileId(container, name); - if (fileId == null) { - return; - } - - api.getObjectApi().deleteFileVersion(name, fileId); - } - - @Override - public BlobAccess getBlobAccess(String container, String name) { - return BlobAccess.PRIVATE; - } - - @Override - public void setBlobAccess(String container, String name, BlobAccess access) { - throw new UnsupportedOperationException("B2 does not support object access control"); - } - - @Override - public void deleteContainer(String container) { - // Explicitly abort multi-part uploads which B2 requires to delete a bucket but other providers do not. - try { - for (MultipartUpload upload : listMultipartUploads(container)) { - abortMultipartUpload(upload); - } - } catch (ContainerNotFoundException cnfe) { - // ignore - } - - super.deleteContainer(container); - } - - @Override - protected boolean deleteAndVerifyContainerGone(String container) { - Bucket bucket = getBucket(container); - try { - api.getBucketApi().deleteBucket(bucket.bucketId()); - } catch (B2ResponseException bre) { - if (bre.getError().code().equals("cannot_delete_non_empty_bucket")) { - return false; - } - throw bre; - } - return true; - } - - @Override - public MultipartUpload initiateMultipartUpload(String container, BlobMetadata blobMetadata, PutOptions options) { - Bucket bucket = getBucket(container); - MultipartUploadResponse response = api.getMultipartApi().startLargeFile(bucket.bucketId(), blobMetadata.getName(), blobMetadata.getContentMetadata().getContentType(), blobMetadata.getUserMetadata()); - return MultipartUpload.create(container, blobMetadata.getName(), response.fileId(), blobMetadata, options); - } - - @Override - public void abortMultipartUpload(MultipartUpload mpu) { - api.getMultipartApi().cancelLargeFile(mpu.id()); - } - - @Override - public String completeMultipartUpload(MultipartUpload mpu, List<MultipartPart> parts) { - ImmutableList.Builder<String> sha1 = ImmutableList.builder(); - for (MultipartPart part : parts) { - sha1.add(part.partETag()); - } - B2Object b2Object = api.getMultipartApi().finishLargeFile(mpu.id(), sha1.build()); - return b2Object.contentSha1(); // this is always "none" - } - - @Override - public MultipartPart uploadMultipartPart(MultipartUpload mpu, int partNumber, Payload payload) { - GetUploadPartResponse getUploadPart = api.getMultipartApi().getUploadPartUrl(mpu.id()); - UploadPartResponse uploadPart = api.getMultipartApi().uploadPart(getUploadPart, partNumber, null, payload); - - Date lastModified = null; // B2 does not return Last-Modified - String contentSha1 = uploadPart.contentSha1(); - if (contentSha1.startsWith("unverified:")) { - contentSha1 = contentSha1.substring("unverified:".length()); - } - return MultipartPart.create(uploadPart.partNumber(), uploadPart.contentLength(), contentSha1, lastModified); - } - - @Override - public List<MultipartPart> listMultipartUpload(MultipartUpload mpu) { - ListPartsResponse response = api.getMultipartApi().listParts(mpu.id(), null, null); - ImmutableList.Builder<MultipartPart> parts = ImmutableList.builder(); - for (ListPartsResponse.Entry entry : response.parts()) { - parts.add(MultipartPart.create(entry.partNumber(), entry.contentLength(), entry.contentSha1(), entry.uploadTimestamp())); - } - return parts.build(); - } - - @Override - public List<MultipartUpload> listMultipartUploads(String container) { - ImmutableList.Builder<MultipartUpload> builder = ImmutableList.builder(); - Bucket bucket = getBucket(container); - - String marker = null; - while (true) { - ListUnfinishedLargeFilesResponse response = api.getMultipartApi().listUnfinishedLargeFiles(bucket.bucketId(), marker, null); - for (ListUnfinishedLargeFilesResponse.Entry entry : response.files()) { - builder.add(MultipartUpload.create(container, entry.fileName(), entry.fileId(), null, null)); - } - - if (response.nextFileId() == null || response.files().isEmpty()) { - break; - } - } - - return builder.build(); - } - - @Override - public long getMinimumMultipartPartSize() { - return auth.get().absoluteMinimumPartSize(); - } - - @Override - public long getMaximumMultipartPartSize() { - return 5L * 1024L * 1024L * 1024L; - } - - @Override - public int getMaximumNumberOfParts() { - return 10 * 1000; - } - - private Bucket getBucket(String container) { - Bucket bucket; - try { - bucket = bucketNameToBucket.getUnchecked(container); - } catch (UncheckedExecutionException uee) { - if (uee.getCause() instanceof ContainerNotFoundException) { - throw (ContainerNotFoundException) uee.getCause(); - } - throw uee; - } - return bucket; - } - - private String getFileId(String container, String name) { - Bucket bucket = getBucket(container); - B2ObjectList list = api.getObjectApi().listFileNames(bucket.bucketId(), name, 1); - if (list.files().isEmpty()) { - return null; - } - - B2ObjectList.Entry entry = list.files().get(0); - if (!entry.fileName().equals(name)) { - return null; - } - - return entry.fileId(); - } - - private MutableBlobMetadata toBlobMetadata(String container, B2Object b2Object) { - MutableBlobMetadata metadata = new MutableBlobMetadataImpl(); - metadata.setContainer(container); - metadata.setETag(b2Object.contentSha1()); // B2 does not support ETag, fake it with SHA-1 - metadata.setLastModified(b2Object.uploadTimestamp()); - metadata.setName(b2Object.fileName()); - metadata.setSize(b2Object.contentLength()); - MutableContentMetadata contentMetadata = new BaseMutableContentMetadata(); - contentMetadata.setContentLength(b2Object.contentLength()); - contentMetadata.setContentType(b2Object.contentType()); - metadata.setContentMetadata(contentMetadata); - metadata.setUserMetadata(b2Object.fileInfo()); - try { - metadata.setPublicUri(URI.create(auth.get().downloadUrl() + "/file/" + container + "/" + - URLEncoder.encode(b2Object.fileName(), "UTF-8"))); - } catch (UnsupportedEncodingException uee) { - throw new RuntimeException(uee); - } - return metadata; - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/85b30385/b2/src/main/java/org/jclouds/b2/blobstore/config/B2BlobStoreContextModule.java ---------------------------------------------------------------------- diff --git a/b2/src/main/java/org/jclouds/b2/blobstore/config/B2BlobStoreContextModule.java b/b2/src/main/java/org/jclouds/b2/blobstore/config/B2BlobStoreContextModule.java deleted file mode 100644 index 151390b..0000000 --- a/b2/src/main/java/org/jclouds/b2/blobstore/config/B2BlobStoreContextModule.java +++ /dev/null @@ -1,32 +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.b2.blobstore.config; - -import org.jclouds.blobstore.BlobStore; -import org.jclouds.blobstore.attr.ConsistencyModel; -import org.jclouds.b2.blobstore.B2BlobStore; - -import com.google.inject.AbstractModule; -import com.google.inject.Scopes; - -public final class B2BlobStoreContextModule extends AbstractModule { - @Override - protected void configure() { - bind(ConsistencyModel.class).toInstance(ConsistencyModel.EVENTUAL); - bind(BlobStore.class).to(B2BlobStore.class).in(Scopes.SINGLETON); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/85b30385/b2/src/main/java/org/jclouds/b2/config/B2HttpApiModule.java ---------------------------------------------------------------------- diff --git a/b2/src/main/java/org/jclouds/b2/config/B2HttpApiModule.java b/b2/src/main/java/org/jclouds/b2/config/B2HttpApiModule.java deleted file mode 100644 index a30f9a4..0000000 --- a/b2/src/main/java/org/jclouds/b2/config/B2HttpApiModule.java +++ /dev/null @@ -1,88 +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.b2.config; - -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicReference; - -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.Constants; -import org.jclouds.collect.Memoized; -import org.jclouds.b2.B2Api; -import org.jclouds.b2.domain.Authorization; -import org.jclouds.b2.filters.B2RetryHandler; -import org.jclouds.b2.filters.RequestAuthorization; -import org.jclouds.b2.handlers.ParseB2ErrorFromJsonContent; -import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.HttpRetryHandler; -import org.jclouds.http.annotation.ClientError; -import org.jclouds.http.annotation.Redirection; -import org.jclouds.http.annotation.ServerError; -import org.jclouds.rest.AuthorizationException; -import org.jclouds.rest.ConfiguresHttpApi; -import org.jclouds.rest.config.HttpApiModule; -import org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier; - -import com.google.common.base.Supplier; -import com.google.inject.Provides; -import com.google.inject.Scopes; - -/** Configures the mappings. Installs the Object and Parser modules. */ -@ConfiguresHttpApi -public final class B2HttpApiModule extends HttpApiModule<B2Api> { - @Override - protected void configure() { - super.configure(); - bind(RequestAuthorization.class).in(Scopes.SINGLETON); - } - - @Override - protected void bindErrorHandlers() { - bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(ParseB2ErrorFromJsonContent.class); - bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(ParseB2ErrorFromJsonContent.class); - bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(ParseB2ErrorFromJsonContent.class); - } - - @Override - protected void bindRetryHandlers() { - bind(HttpRetryHandler.class).annotatedWith(ServerError.class).to(B2RetryHandler.class); - } - - @Provides - @Singleton - static Supplier<Authorization> provideAuthorizationSupplier(final B2Api b2Api) { - return new Supplier<Authorization>() { - @Override - public Authorization get() { - return b2Api.getAuthorizationApi().authorizeAccount(); - } - }; - } - - @Provides - @Singleton - @Memoized - static Supplier<Authorization> provideAuthorizationCache( - AtomicReference<AuthorizationException> authException, - @Named(Constants.PROPERTY_SESSION_INTERVAL) long seconds, - Supplier<Authorization> uncached) { - return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create( - authException, uncached, seconds, TimeUnit.SECONDS); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/85b30385/b2/src/main/java/org/jclouds/b2/domain/Action.java ---------------------------------------------------------------------- diff --git a/b2/src/main/java/org/jclouds/b2/domain/Action.java b/b2/src/main/java/org/jclouds/b2/domain/Action.java deleted file mode 100644 index bd6c852..0000000 --- a/b2/src/main/java/org/jclouds/b2/domain/Action.java +++ /dev/null @@ -1,33 +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.b2.domain; - -import com.google.common.base.CaseFormat; - -public enum Action { - UPLOAD, - HIDE; - - public static Action fromValue(String symbol) { - return Action.valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, symbol)); - } - - @Override - public String toString() { - return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name()); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/85b30385/b2/src/main/java/org/jclouds/b2/domain/Authorization.java ---------------------------------------------------------------------- diff --git a/b2/src/main/java/org/jclouds/b2/domain/Authorization.java b/b2/src/main/java/org/jclouds/b2/domain/Authorization.java deleted file mode 100644 index 9f5b6fc..0000000 --- a/b2/src/main/java/org/jclouds/b2/domain/Authorization.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.b2.domain; - -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; - -@AutoValue -public abstract class Authorization { - public abstract String accountId(); - public abstract String apiUrl(); - public abstract String authorizationToken(); - public abstract String downloadUrl(); - @Deprecated - public abstract long minimumPartSize(); - public abstract long absoluteMinimumPartSize(); - public abstract long recommendedPartSize(); - - @SerializedNames({"accountId", "apiUrl", "authorizationToken", "downloadUrl", "minimumPartSize", "absoluteMinimumPartSize", "recommendedPartSize"}) - public static Authorization create(String accountId, String apiUrl, String authorizationToken, String downloadUrl, long minimumPartSize, long absoluteMinimumPartSize, long recommendedPartSize) { - return new AutoValue_Authorization(accountId, apiUrl, authorizationToken, downloadUrl, minimumPartSize, absoluteMinimumPartSize, recommendedPartSize); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/85b30385/b2/src/main/java/org/jclouds/b2/domain/B2Error.java ---------------------------------------------------------------------- diff --git a/b2/src/main/java/org/jclouds/b2/domain/B2Error.java b/b2/src/main/java/org/jclouds/b2/domain/B2Error.java deleted file mode 100644 index c4d16a9..0000000 --- a/b2/src/main/java/org/jclouds/b2/domain/B2Error.java +++ /dev/null @@ -1,33 +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.b2.domain; - -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; - -@AutoValue -public abstract class B2Error { - public abstract String code(); - public abstract String message(); - public abstract int status(); - - @SerializedNames({ "code", "message", "status" }) - public static B2Error create(String code, String message, int status) { - return new AutoValue_B2Error(code, message, status); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/85b30385/b2/src/main/java/org/jclouds/b2/domain/B2Object.java ---------------------------------------------------------------------- diff --git a/b2/src/main/java/org/jclouds/b2/domain/B2Object.java b/b2/src/main/java/org/jclouds/b2/domain/B2Object.java deleted file mode 100644 index b5ac4e3..0000000 --- a/b2/src/main/java/org/jclouds/b2/domain/B2Object.java +++ /dev/null @@ -1,52 +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.b2.domain; - -import java.util.Date; -import java.util.Map; - -import org.jclouds.io.Payload; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; -import com.google.common.collect.ImmutableMap; - -@AutoValue -public abstract class B2Object { - public abstract String fileId(); - public abstract String fileName(); - @Nullable public abstract String contentSha1(); - @Nullable public abstract Map<String, String> fileInfo(); - @Nullable public abstract Payload payload(); - @Nullable public abstract Date uploadTimestamp(); - @Nullable public abstract Action action(); - @Nullable public abstract String accountId(); - @Nullable public abstract String bucketId(); - @Nullable public abstract Long contentLength(); - @Nullable public abstract String contentType(); - @Nullable public abstract String contentRange(); - - @SerializedNames({"fileId", "fileName", "accountId", "bucketId", "contentLength", "contentSha1", "contentType", "fileInfo", "action", "uploadTimestamp", "contentRange", "payload"}) - public static B2Object create(String fileId, String fileName, @Nullable String accountId, @Nullable String bucketId, @Nullable Long contentLength, @Nullable String contentSha1, @Nullable String contentType, @Nullable Map<String, String> fileInfo, @Nullable Action action, @Nullable Long uploadTimestamp, @Nullable String contentRange, @Nullable Payload payload) { - if (fileInfo != null) { - fileInfo = ImmutableMap.copyOf(fileInfo); - } - Date date = uploadTimestamp == null ? null : new Date(uploadTimestamp); - return new AutoValue_B2Object(fileId, fileName, contentSha1, fileInfo, payload, date, action, accountId, bucketId, contentLength, contentType, contentRange); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/85b30385/b2/src/main/java/org/jclouds/b2/domain/B2ObjectList.java ---------------------------------------------------------------------- diff --git a/b2/src/main/java/org/jclouds/b2/domain/B2ObjectList.java b/b2/src/main/java/org/jclouds/b2/domain/B2ObjectList.java deleted file mode 100644 index 780ab75..0000000 --- a/b2/src/main/java/org/jclouds/b2/domain/B2ObjectList.java +++ /dev/null @@ -1,52 +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.b2.domain; - -import java.util.Date; -import java.util.List; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; -import com.google.common.collect.ImmutableList; - -@AutoValue -public abstract class B2ObjectList { - public abstract List<Entry> files(); - @Nullable public abstract String nextFileId(); - @Nullable public abstract String nextFileName(); - - @SerializedNames({"files", "nextFileId", "nextFileName"}) - public static B2ObjectList create(List<Entry> files, @Nullable String nextFileId, @Nullable String nextFileName) { - return new AutoValue_B2ObjectList(ImmutableList.copyOf(files), nextFileId, nextFileName); - } - - @AutoValue - public abstract static class Entry { - public abstract Action action(); - public abstract String fileId(); - public abstract String fileName(); - public abstract long size(); - public abstract Date uploadTimestamp(); - - @SerializedNames({"action", "fileId", "fileName", "size", "uploadTimestamp"}) - public static Entry create(Action action, String fileId, String fileName, long size, long uploadTimestamp) { - return new AutoValue_B2ObjectList_Entry(action, fileId, fileName, size, new Date(uploadTimestamp)); - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/85b30385/b2/src/main/java/org/jclouds/b2/domain/Bucket.java ---------------------------------------------------------------------- diff --git a/b2/src/main/java/org/jclouds/b2/domain/Bucket.java b/b2/src/main/java/org/jclouds/b2/domain/Bucket.java deleted file mode 100644 index e9556ef..0000000 --- a/b2/src/main/java/org/jclouds/b2/domain/Bucket.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.b2.domain; - -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; - -@AutoValue -public abstract class Bucket { - public abstract String bucketId(); - public abstract String accountId(); - public abstract String bucketName(); - public abstract BucketType bucketType(); - - @SerializedNames({"bucketId", "accountId", "bucketName", "bucketType"}) - public static Bucket create(String bucketId, String accountId, String bucketName, BucketType bucketType) { - return new AutoValue_Bucket(bucketId, accountId, bucketName, bucketType); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/85b30385/b2/src/main/java/org/jclouds/b2/domain/BucketList.java ---------------------------------------------------------------------- diff --git a/b2/src/main/java/org/jclouds/b2/domain/BucketList.java b/b2/src/main/java/org/jclouds/b2/domain/BucketList.java deleted file mode 100644 index 827cdb8..0000000 --- a/b2/src/main/java/org/jclouds/b2/domain/BucketList.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.b2.domain; - -import java.util.List; - -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; -import com.google.common.collect.ImmutableList; - -@AutoValue -public abstract class BucketList { - public abstract List<Bucket> buckets(); - - @SerializedNames({"buckets"}) - public static BucketList create(List<Bucket> buckets) { - return new AutoValue_BucketList(ImmutableList.copyOf(buckets)); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/85b30385/b2/src/main/java/org/jclouds/b2/domain/BucketType.java ---------------------------------------------------------------------- diff --git a/b2/src/main/java/org/jclouds/b2/domain/BucketType.java b/b2/src/main/java/org/jclouds/b2/domain/BucketType.java deleted file mode 100644 index abcee1f..0000000 --- a/b2/src/main/java/org/jclouds/b2/domain/BucketType.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.b2.domain; - -import com.google.common.base.CaseFormat; - -public enum BucketType { - ALL_PUBLIC, - ALL_PRIVATE, - SNAPSHOT; - - public static BucketType fromValue(String symbol) { - return BucketType.valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, symbol)); - } - - @Override - public String toString() { - return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name()); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/85b30385/b2/src/main/java/org/jclouds/b2/domain/DeleteFileResponse.java ---------------------------------------------------------------------- diff --git a/b2/src/main/java/org/jclouds/b2/domain/DeleteFileResponse.java b/b2/src/main/java/org/jclouds/b2/domain/DeleteFileResponse.java deleted file mode 100644 index 21e5470..0000000 --- a/b2/src/main/java/org/jclouds/b2/domain/DeleteFileResponse.java +++ /dev/null @@ -1,32 +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.b2.domain; - -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; - -@AutoValue -public abstract class DeleteFileResponse { - public abstract String fileName(); - public abstract String fileId(); - - @SerializedNames({"fileName", "fileId"}) - public static DeleteFileResponse create(String fileName, String fileId) { - return new AutoValue_DeleteFileResponse(fileName, fileId); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/85b30385/b2/src/main/java/org/jclouds/b2/domain/GetUploadPartResponse.java ---------------------------------------------------------------------- diff --git a/b2/src/main/java/org/jclouds/b2/domain/GetUploadPartResponse.java b/b2/src/main/java/org/jclouds/b2/domain/GetUploadPartResponse.java deleted file mode 100644 index d6222cc..0000000 --- a/b2/src/main/java/org/jclouds/b2/domain/GetUploadPartResponse.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.b2.domain; - -import java.net.URI; - -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; - -@AutoValue -public abstract class GetUploadPartResponse { - public abstract String fileId(); - public abstract URI uploadUrl(); - public abstract String authorizationToken(); - - @SerializedNames({"fileId", "uploadUrl", "authorizationToken"}) - public static GetUploadPartResponse create(String fileId, URI uploadUrl, String authorizationToken) { - return new AutoValue_GetUploadPartResponse(fileId, uploadUrl, authorizationToken); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/85b30385/b2/src/main/java/org/jclouds/b2/domain/HideFileResponse.java ---------------------------------------------------------------------- diff --git a/b2/src/main/java/org/jclouds/b2/domain/HideFileResponse.java b/b2/src/main/java/org/jclouds/b2/domain/HideFileResponse.java deleted file mode 100644 index d7e5e11..0000000 --- a/b2/src/main/java/org/jclouds/b2/domain/HideFileResponse.java +++ /dev/null @@ -1,37 +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.b2.domain; - -import java.util.Date; - -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; - -@AutoValue -public abstract class HideFileResponse { - /** Always "hide". */ - public abstract Action action(); - public abstract String fileId(); - public abstract String fileName(); - public abstract Date uploadTimestamp(); - - @SerializedNames({"action", "fileId", "fileName", "uploadTimestamp"}) - public static HideFileResponse create(Action action, String fileId, String fileName, long uploadTimestamp) { - return new AutoValue_HideFileResponse(action, fileId, fileName, new Date(uploadTimestamp)); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/85b30385/b2/src/main/java/org/jclouds/b2/domain/ListPartsResponse.java ---------------------------------------------------------------------- diff --git a/b2/src/main/java/org/jclouds/b2/domain/ListPartsResponse.java b/b2/src/main/java/org/jclouds/b2/domain/ListPartsResponse.java deleted file mode 100644 index 1ed9b41..0000000 --- a/b2/src/main/java/org/jclouds/b2/domain/ListPartsResponse.java +++ /dev/null @@ -1,51 +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.b2.domain; - -import java.util.Date; -import java.util.List; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; -import com.google.common.collect.ImmutableList; - -@AutoValue -public abstract class ListPartsResponse { - @Nullable public abstract Integer nextPartNumber(); - public abstract List<Entry> parts(); - - @SerializedNames({"nextPartNumber", "parts"}) - public static ListPartsResponse create(@Nullable Integer nextPartNumber, List<Entry> parts) { - return new AutoValue_ListPartsResponse(nextPartNumber, ImmutableList.copyOf(parts)); - } - - @AutoValue - public abstract static class Entry { - public abstract long contentLength(); - public abstract String contentSha1(); - public abstract String fileId(); - public abstract int partNumber(); - public abstract Date uploadTimestamp(); - - @SerializedNames({"contentLength", "contentSha1", "fileId", "partNumber", "uploadTimestamp"}) - public static Entry create(long contentLength, String contentSha1, String fileId, int partNumber, long uploadTimestamp) { - return new AutoValue_ListPartsResponse_Entry(contentLength, contentSha1, fileId, partNumber, new Date(uploadTimestamp)); - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/85b30385/b2/src/main/java/org/jclouds/b2/domain/ListUnfinishedLargeFilesResponse.java ---------------------------------------------------------------------- diff --git a/b2/src/main/java/org/jclouds/b2/domain/ListUnfinishedLargeFilesResponse.java b/b2/src/main/java/org/jclouds/b2/domain/ListUnfinishedLargeFilesResponse.java deleted file mode 100644 index 986fd63..0000000 --- a/b2/src/main/java/org/jclouds/b2/domain/ListUnfinishedLargeFilesResponse.java +++ /dev/null @@ -1,55 +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.b2.domain; - -import java.util.Date; -import java.util.List; -import java.util.Map; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; - -@AutoValue -public abstract class ListUnfinishedLargeFilesResponse { - @Nullable public abstract String nextFileId(); - public abstract List<Entry> files(); - - @SerializedNames({"nextFileId", "files"}) - public static ListUnfinishedLargeFilesResponse create(@Nullable String nextFileId, List<Entry> files) { - return new AutoValue_ListUnfinishedLargeFilesResponse(nextFileId, ImmutableList.copyOf(files)); - } - - @AutoValue - public abstract static class Entry { - public abstract String accountId(); - public abstract String bucketId(); - public abstract String contentType(); - public abstract String fileId(); - public abstract Map<String, String> fileInfo(); - public abstract String fileName(); - public abstract Date uploadTimestamp(); - - @SerializedNames({"accountId", "bucketId", "contentType", "fileId", "fileInfo", "fileName", "uploadTimestamp"}) - public static Entry create(String accountId, String bucketId, String contentType, String fileId, Map<String, String> fileInfo, String fileName, long uploadTimestamp) { - return new AutoValue_ListUnfinishedLargeFilesResponse_Entry(accountId, bucketId, contentType, fileId, ImmutableMap.copyOf(fileInfo), fileName, new Date(uploadTimestamp)); - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/85b30385/b2/src/main/java/org/jclouds/b2/domain/MultipartUploadResponse.java ---------------------------------------------------------------------- diff --git a/b2/src/main/java/org/jclouds/b2/domain/MultipartUploadResponse.java b/b2/src/main/java/org/jclouds/b2/domain/MultipartUploadResponse.java deleted file mode 100644 index bfd1dfe..0000000 --- a/b2/src/main/java/org/jclouds/b2/domain/MultipartUploadResponse.java +++ /dev/null @@ -1,41 +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.b2.domain; - -import java.util.Date; -import java.util.Map; - -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; -import com.google.common.collect.ImmutableMap; - -@AutoValue -public abstract class MultipartUploadResponse { - public abstract String accountId(); - public abstract String bucketId(); - public abstract String contentType(); - public abstract String fileId(); - public abstract Map<String, String> fileInfo(); - public abstract String fileName(); - public abstract Date uploadTimestamp(); - - @SerializedNames({"accountId", "bucketId", "contentType", "fileId", "fileInfo", "fileName", "uploadTimestamp"}) - public static MultipartUploadResponse create(String accountId, String bucketId, String contentType, String fileId, Map<String, String> fileInfo, String fileName, long uploadTimestamp) { - return new AutoValue_MultipartUploadResponse(accountId, bucketId, contentType, fileId, ImmutableMap.copyOf(fileInfo), fileName, new Date(uploadTimestamp)); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/85b30385/b2/src/main/java/org/jclouds/b2/domain/UploadFileResponse.java ---------------------------------------------------------------------- diff --git a/b2/src/main/java/org/jclouds/b2/domain/UploadFileResponse.java b/b2/src/main/java/org/jclouds/b2/domain/UploadFileResponse.java deleted file mode 100644 index dc235db..0000000 --- a/b2/src/main/java/org/jclouds/b2/domain/UploadFileResponse.java +++ /dev/null @@ -1,41 +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.b2.domain; - -import java.util.Map; - -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; -import com.google.common.collect.ImmutableMap; - -@AutoValue -public abstract class UploadFileResponse { - public abstract String fileId(); - public abstract String fileName(); - public abstract String accountId(); - public abstract String bucketId(); - public abstract long contentLength(); - public abstract String contentSha1(); - public abstract String contentType(); - public abstract Map<String, String> fileInfo(); - - @SerializedNames({"fileId", "fileName", "accountId", "bucketId", "contentLength", "contentSha1", "contentType", "fileInfo"}) - public static UploadFileResponse create(String fileId, String fileName, String accountId, String bucketId, long contentLength, String contentSha1, String contentType, Map<String, String> fileInfo) { - return new AutoValue_UploadFileResponse(fileId, fileName, accountId, bucketId, contentLength, contentSha1, contentType, ImmutableMap.copyOf(fileInfo)); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/85b30385/b2/src/main/java/org/jclouds/b2/domain/UploadPartResponse.java ---------------------------------------------------------------------- diff --git a/b2/src/main/java/org/jclouds/b2/domain/UploadPartResponse.java b/b2/src/main/java/org/jclouds/b2/domain/UploadPartResponse.java deleted file mode 100644 index 1a8b3ad..0000000 --- a/b2/src/main/java/org/jclouds/b2/domain/UploadPartResponse.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.b2.domain; - -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; - -@AutoValue -public abstract class UploadPartResponse { - public abstract long contentLength(); - public abstract String contentSha1(); - public abstract String fileId(); - public abstract int partNumber(); - - @SerializedNames({"contentLength", "contentSha1", "fileId", "partNumber"}) - public static UploadPartResponse create(long contentLength, String contentSha1, String fileId, int partNumber) { - return new AutoValue_UploadPartResponse(contentLength, contentSha1, fileId, partNumber); - } -}
