From fff7ad0f11a6c6291faf56cbdfde6750b807aeed Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Sat, 25 Oct 2014 08:36:54 -0700 Subject: [PATCH] Remove redundant binder implementations in GCE. --- .../binders/BucketAccessControlsBinder.java | 43 ------------------ .../binders/BucketBinder.java | 43 ------------------ .../binders/ComposeObjectBinder.java | 43 ------------------ .../DefaultObjectAccessControlsBinder.java | 43 ------------------ .../binders/MultipartUploadBinder.java | 27 +++++------- .../binders/ObjectAccessControlsBinder.java | 43 ------------------ .../binders/ResumableUploadBinder.java | 44 ------------------- .../binders/UploadBinder.java | 7 +-- .../features/BucketAccessControlsApi.java | 6 +-- .../features/BucketApi.java | 9 +--- .../DefaultObjectAccessControlsApi.java | 10 ++--- .../features/ObjectAccessControlsApi.java | 11 ++--- .../features/ObjectApi.java | 14 +++--- .../features/ResumableUploadApi.java | 6 +-- 14 files changed, 31 insertions(+), 318 deletions(-) delete mode 100644 providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/binders/BucketAccessControlsBinder.java delete mode 100644 providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/binders/BucketBinder.java delete mode 100644 providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/binders/ComposeObjectBinder.java delete mode 100644 providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/binders/DefaultObjectAccessControlsBinder.java delete mode 100644 providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/binders/ObjectAccessControlsBinder.java delete mode 100644 providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/binders/ResumableUploadBinder.java diff --git a/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/binders/BucketAccessControlsBinder.java b/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/binders/BucketAccessControlsBinder.java deleted file mode 100644 index 94cd73f1cf..0000000000 --- a/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/binders/BucketAccessControlsBinder.java +++ /dev/null @@ -1,43 +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 javax.inject.Inject; - -import org.jclouds.googlecloudstorage.domain.templates.BucketAccessControlsTemplate; -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.MapBinder; -import org.jclouds.rest.binders.BindToJsonPayload; - -public class BucketAccessControlsBinder implements MapBinder { - - @Inject - private BindToJsonPayload jsonBinder; - - @Override - public R bindToRequest(R request, Map postParams) { - BucketAccessControlsTemplate postBucket = (BucketAccessControlsTemplate) postParams.get("template"); - return bindToRequest(request, postBucket); - } - - @Override - public R bindToRequest(R request, Object input) { - return jsonBinder.bindToRequest(request, input); - } -} diff --git a/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/binders/BucketBinder.java b/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/binders/BucketBinder.java deleted file mode 100644 index 1aa8dd90eb..0000000000 --- a/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/binders/BucketBinder.java +++ /dev/null @@ -1,43 +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 javax.inject.Inject; - -import org.jclouds.googlecloudstorage.domain.templates.BucketTemplate; -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.MapBinder; -import org.jclouds.rest.binders.BindToJsonPayload; - -public class BucketBinder implements MapBinder { - - @Inject - private BindToJsonPayload jsonBinder; - - @Override - public R bindToRequest(R request, Map postParams) throws IllegalArgumentException { - BucketTemplate postBucket = (BucketTemplate) postParams.get("template"); - return bindToRequest(request, postBucket); - } - - @Override - public R bindToRequest(R request, Object input) { - return jsonBinder.bindToRequest(request, input); - } -} diff --git a/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/binders/ComposeObjectBinder.java b/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/binders/ComposeObjectBinder.java deleted file mode 100644 index 9401ad6d3a..0000000000 --- a/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/binders/ComposeObjectBinder.java +++ /dev/null @@ -1,43 +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 javax.inject.Inject; - -import org.jclouds.googlecloudstorage.domain.templates.ComposeObjectTemplate; -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.MapBinder; -import org.jclouds.rest.binders.BindToJsonPayload; - -public class ComposeObjectBinder implements MapBinder { - - @Inject - private BindToJsonPayload jsonBinder; - - @Override - public R bindToRequest(R request, Map postParams) throws IllegalArgumentException{ - ComposeObjectTemplate postCompose = (ComposeObjectTemplate) postParams.get("template"); - return bindToRequest(request, postCompose); - } - - @Override - public R bindToRequest(R request, Object input) { - return jsonBinder.bindToRequest(request, input); - } -} diff --git a/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/binders/DefaultObjectAccessControlsBinder.java b/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/binders/DefaultObjectAccessControlsBinder.java deleted file mode 100644 index 0588eec6d7..0000000000 --- a/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/binders/DefaultObjectAccessControlsBinder.java +++ /dev/null @@ -1,43 +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 javax.inject.Inject; - -import org.jclouds.googlecloudstorage.domain.templates.DefaultObjectAccessControlsTemplate; -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.MapBinder; -import org.jclouds.rest.binders.BindToJsonPayload; - -public class DefaultObjectAccessControlsBinder implements MapBinder { - - @Inject - private BindToJsonPayload jsonBinder; - - @Override - public R bindToRequest(R request, Map postParams) { - DefaultObjectAccessControlsTemplate template = (DefaultObjectAccessControlsTemplate) postParams.get("template"); - return bindToRequest(request, template); - } - - @Override - public R bindToRequest(R request, Object input) { - return jsonBinder.bindToRequest(request, input); - } -} diff --git a/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/binders/MultipartUploadBinder.java b/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/binders/MultipartUploadBinder.java index b286d2843a..f8f145121a 100644 --- a/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/binders/MultipartUploadBinder.java +++ b/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/binders/MultipartUploadBinder.java @@ -16,10 +16,11 @@ */ package org.jclouds.googlecloudstorage.binders; -import java.util.Map; +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 javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.MediaType; +import java.util.Map; import org.jclouds.googlecloudstorage.domain.templates.ObjectTemplate; import org.jclouds.http.HttpRequest; @@ -32,40 +33,32 @@ import org.jclouds.rest.MapBinder; import com.google.gson.Gson; -import static com.google.common.base.Preconditions.checkNotNull; - public class MultipartUploadBinder implements MapBinder { - private final String BOUNDARY_HEADER = "multipart_boundary"; - - @Override - public R bindToRequest(R request, Map postParams) - throws IllegalArgumentException { + private static final String BOUNDARY_HEADER = "multipart_boundary"; + @Override public R bindToRequest(R request, Map postParams) { ObjectTemplate template = (ObjectTemplate) postParams.get("template"); Payload payload = (Payload) postParams.get("payload"); String contentType = checkNotNull(template.getContentType(), "contentType"); - Long length = checkNotNull(template.getSize(), "contetLength"); + Long length = checkNotNull(template.getSize(), "contentLength"); StringPayload jsonPayload = Payloads.newStringPayload(new Gson().toJson(template)); payload.getContentMetadata().setContentLength(length); - Part jsonPart = Part.create("Metadata", jsonPayload, - new Part.PartOptions().contentType(MediaType.APPLICATION_JSON)); + Part jsonPart = Part.create("Metadata", jsonPayload, new Part.PartOptions().contentType(APPLICATION_JSON)); Part mediaPart = Part.create(template.getName(), payload, new Part.PartOptions().contentType(contentType)); MultipartForm compPayload = new MultipartForm(BOUNDARY_HEADER, jsonPart, mediaPart); request.setPayload(compPayload); // HeaderPart - request.toBuilder().replaceHeader(HttpHeaders.CONTENT_TYPE, "Multipart/related; boundary= " + BOUNDARY_HEADER) - .build(); + request.toBuilder().replaceHeader(CONTENT_TYPE, "Multipart/related; boundary= " + BOUNDARY_HEADER).build(); return request; } - @Override - public R bindToRequest(R request, Object input) { + @Override public R bindToRequest(R request, Object input) { return request; } } diff --git a/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/binders/ObjectAccessControlsBinder.java b/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/binders/ObjectAccessControlsBinder.java deleted file mode 100644 index 77218db239..0000000000 --- a/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/binders/ObjectAccessControlsBinder.java +++ /dev/null @@ -1,43 +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 javax.inject.Inject; - -import org.jclouds.googlecloudstorage.domain.templates.ObjectAccessControlsTemplate; -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.MapBinder; -import org.jclouds.rest.binders.BindToJsonPayload; - -public class ObjectAccessControlsBinder implements MapBinder { - - @Inject - private BindToJsonPayload jsonBinder; - - @Override - public R bindToRequest(R request, Map postParams) throws IllegalArgumentException{ - ObjectAccessControlsTemplate postBucket = (ObjectAccessControlsTemplate) postParams.get("template"); - return bindToRequest(request, postBucket); - } - - @Override - public R bindToRequest(R request, Object input) { - return jsonBinder.bindToRequest(request, input); - } -} diff --git a/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/binders/ResumableUploadBinder.java b/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/binders/ResumableUploadBinder.java deleted file mode 100644 index bfa29c9b88..0000000000 --- a/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/binders/ResumableUploadBinder.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.binders; - -import java.util.Map; - -import javax.inject.Inject; - -import org.jclouds.googlecloudstorage.domain.templates.ObjectTemplate; -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.MapBinder; -import org.jclouds.rest.binders.BindToJsonPayload; - -public class ResumableUploadBinder implements MapBinder { - - @Inject - private BindToJsonPayload jsonBinder; - - @Override - public R bindToRequest(R request, Map postParams) - throws IllegalArgumentException { - ObjectTemplate template = (ObjectTemplate) postParams.get("template"); - return bindToRequest(request, template); - } - - @Override - public R bindToRequest(R request, Object input) { - return jsonBinder.bindToRequest(request, input); - } -} diff --git a/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/binders/UploadBinder.java b/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/binders/UploadBinder.java index a218ec07fc..9b6fa4b4c9 100644 --- a/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/binders/UploadBinder.java +++ b/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/binders/UploadBinder.java @@ -24,9 +24,7 @@ import org.jclouds.rest.MapBinder; public class UploadBinder implements MapBinder { - @Override - public R bindToRequest(R request, Map postParams) - throws IllegalArgumentException { + @Override public R bindToRequest(R request, Map postParams) { Payload payload = (Payload) postParams.get("payload"); request.getPayload().getContentMetadata().setContentType(payload.getContentMetadata().getContentType()); @@ -34,8 +32,7 @@ public class UploadBinder implements MapBinder { return bindToRequest(request, payload); } - @Override - public R bindToRequest(R request, Object input) { + @Override public R bindToRequest(R request, Object input) { return request; } } diff --git a/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/features/BucketAccessControlsApi.java b/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/features/BucketAccessControlsApi.java index 34d090c8f6..338b3ba23e 100644 --- a/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/features/BucketAccessControlsApi.java +++ b/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/features/BucketAccessControlsApi.java @@ -30,7 +30,6 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.googlecloudstorage.binders.BucketAccessControlsBinder; import org.jclouds.googlecloudstorage.domain.BucketAccessControls; import org.jclouds.googlecloudstorage.domain.ListBucketAccessControls; import org.jclouds.googlecloudstorage.domain.templates.BucketAccessControlsTemplate; @@ -40,9 +39,7 @@ import org.jclouds.oauth.v2.config.OAuthScopes; import org.jclouds.oauth.v2.filters.OAuthAuthenticationFilter; import org.jclouds.rest.annotations.BinderParam; import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.MapBinder; import org.jclouds.rest.annotations.PATCH; -import org.jclouds.rest.annotations.PayloadParam; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.SkipEncoding; import org.jclouds.rest.binders.BindToJsonPayload; @@ -96,9 +93,8 @@ public interface BucketAccessControlsApi { @Consumes(MediaType.APPLICATION_JSON) @Path("/b/{bucket}/acl") @OAuthScopes(STORAGE_FULLCONTROL_SCOPE) - @MapBinder(BucketAccessControlsBinder.class) BucketAccessControls createBucketAccessControls(@PathParam("bucket") String bucketName, - @PayloadParam("template") BucketAccessControlsTemplate template); + @BinderParam(BindToJsonPayload.class) BucketAccessControlsTemplate template); /** * Permanently deletes the ACL entry for the specified entity on the specified bucket. diff --git a/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/features/BucketApi.java b/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/features/BucketApi.java index 71f6d95d08..ebb120d483 100644 --- a/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/features/BucketApi.java +++ b/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/features/BucketApi.java @@ -35,7 +35,6 @@ import org.jclouds.Fallbacks.FalseOnNotFoundOr404; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.Fallbacks.TrueOnNotFoundOr404; import org.jclouds.blobstore.BlobStoreFallbacks.NullOnKeyAlreadyExists; -import org.jclouds.googlecloudstorage.binders.BucketBinder; import org.jclouds.googlecloudstorage.domain.Bucket; import org.jclouds.googlecloudstorage.domain.ListPage; import org.jclouds.googlecloudstorage.domain.templates.BucketTemplate; @@ -50,9 +49,7 @@ import org.jclouds.oauth.v2.config.OAuthScopes; import org.jclouds.oauth.v2.filters.OAuthAuthenticationFilter; import org.jclouds.rest.annotations.BinderParam; import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.MapBinder; import org.jclouds.rest.annotations.PATCH; -import org.jclouds.rest.annotations.PayloadParam; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.SkipEncoding; import org.jclouds.rest.binders.BindToJsonPayload; @@ -136,9 +133,8 @@ public interface BucketApi { @Consumes(MediaType.APPLICATION_JSON) @Path("/b") @OAuthScopes(STORAGE_FULLCONTROL_SCOPE) - @MapBinder(BucketBinder.class) @Fallback(NullOnBucketAlreadyExists.class) - Bucket createBucket(@QueryParam("project") String projectId, @PayloadParam("template") BucketTemplate bucketTemplate); + Bucket createBucket(@QueryParam("project") String projectId, @BinderParam(BindToJsonPayload.class) BucketTemplate bucketTemplate); /** * Creates a new Bucket @@ -158,10 +154,9 @@ public interface BucketApi { @Consumes(MediaType.APPLICATION_JSON) @Path("/b") @OAuthScopes(STORAGE_FULLCONTROL_SCOPE) - @MapBinder(BucketBinder.class) @Fallback(NullOnKeyAlreadyExists.class) Bucket createBucket(@QueryParam("project") String projectId, - @PayloadParam("template") BucketTemplate bucketTemplate, InsertBucketOptions options); + @BinderParam(BindToJsonPayload.class) BucketTemplate bucketTemplate, InsertBucketOptions options); /** * Permanently deletes an empty Bucket.If bucket is not empty 409 error to indicate the conflict. diff --git a/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/features/DefaultObjectAccessControlsApi.java b/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/features/DefaultObjectAccessControlsApi.java index a1cb2a2f60..54dca83338 100644 --- a/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/features/DefaultObjectAccessControlsApi.java +++ b/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/features/DefaultObjectAccessControlsApi.java @@ -31,20 +31,17 @@ import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.googlecloudstorage.binders.DefaultObjectAccessControlsBinder; import org.jclouds.googlecloudstorage.domain.DefaultObjectAccessControls; -import org.jclouds.googlecloudstorage.domain.ListDefaultObjectAccessControls; import org.jclouds.googlecloudstorage.domain.DomainResourceReferences.ObjectRole; -import org.jclouds.http.HttpResponse; +import org.jclouds.googlecloudstorage.domain.ListDefaultObjectAccessControls; import org.jclouds.googlecloudstorage.domain.templates.DefaultObjectAccessControlsTemplate; +import org.jclouds.http.HttpResponse; import org.jclouds.javax.annotation.Nullable; import org.jclouds.oauth.v2.config.OAuthScopes; import org.jclouds.oauth.v2.filters.OAuthAuthenticationFilter; import org.jclouds.rest.annotations.BinderParam; import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.MapBinder; import org.jclouds.rest.annotations.PATCH; -import org.jclouds.rest.annotations.PayloadParam; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.SkipEncoding; import org.jclouds.rest.binders.BindToJsonPayload; @@ -97,9 +94,8 @@ public interface DefaultObjectAccessControlsApi { @Produces(MediaType.APPLICATION_JSON) @Path("/b/{bucket}/defaultObjectAcl") @OAuthScopes(STORAGE_FULLCONTROL_SCOPE) - @MapBinder(DefaultObjectAccessControlsBinder.class) DefaultObjectAccessControls createDefaultObjectAccessControls(@PathParam("bucket") String bucketName, - @PayloadParam("template") DefaultObjectAccessControlsTemplate template); + @BinderParam(BindToJsonPayload.class) DefaultObjectAccessControlsTemplate template); /** * Permanently deletes the DefaultObjectAcessControl entry for the specified entity on the specified bucket. diff --git a/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/features/ObjectAccessControlsApi.java b/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/features/ObjectAccessControlsApi.java index 2836c8f5ed..5645757ce9 100644 --- a/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/features/ObjectAccessControlsApi.java +++ b/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/features/ObjectAccessControlsApi.java @@ -31,7 +31,6 @@ import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.googlecloudstorage.binders.ObjectAccessControlsBinder; import org.jclouds.googlecloudstorage.domain.ListObjectAccessControls; import org.jclouds.googlecloudstorage.domain.ObjectAccessControls; import org.jclouds.googlecloudstorage.domain.templates.ObjectAccessControlsTemplate; @@ -40,9 +39,7 @@ import org.jclouds.oauth.v2.config.OAuthScopes; import org.jclouds.oauth.v2.filters.OAuthAuthenticator; import org.jclouds.rest.annotations.BinderParam; import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.MapBinder; import org.jclouds.rest.annotations.PATCH; -import org.jclouds.rest.annotations.PayloadParam; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.SkipEncoding; import org.jclouds.rest.binders.BindToJsonPayload; @@ -126,9 +123,9 @@ public interface ObjectAccessControlsApi { @Produces(MediaType.APPLICATION_JSON) @Path("/b/{bucket}/o/{object}/acl") @OAuthScopes(STORAGE_FULLCONTROL_SCOPE) - @MapBinder(ObjectAccessControlsBinder.class) ObjectAccessControls createObjectAccessControls(@PathParam("bucket") String bucketName, - @PathParam("object") String objectName, @PayloadParam("template") ObjectAccessControlsTemplate template); + @PathParam("object") String objectName, + @BinderParam(BindToJsonPayload.class) ObjectAccessControlsTemplate template); /** * Creates a new acl entry for specified object @@ -150,9 +147,9 @@ public interface ObjectAccessControlsApi { @Produces(MediaType.APPLICATION_JSON) @Path("/b/{bucket}/o/{object}/acl") @OAuthScopes(STORAGE_FULLCONTROL_SCOPE) - @MapBinder(ObjectAccessControlsBinder.class) ObjectAccessControls createObjectAccessControls(@PathParam("bucket") String bucketName, - @PathParam("object") String objectName, @PayloadParam("template") ObjectAccessControlsTemplate template, + @PathParam("object") String objectName, + @BinderParam(BindToJsonPayload.class) ObjectAccessControlsTemplate template, @QueryParam("generation") Long generation); /** diff --git a/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/features/ObjectApi.java b/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/features/ObjectApi.java index 93f67ad549..77d6cf090b 100644 --- a/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/features/ObjectApi.java +++ b/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/features/ObjectApi.java @@ -34,7 +34,6 @@ import javax.ws.rs.core.MediaType; import org.jclouds.Fallbacks.FalseOnNotFoundOr404; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.Fallbacks.TrueOnNotFoundOr404; -import org.jclouds.googlecloudstorage.binders.ComposeObjectBinder; import org.jclouds.googlecloudstorage.binders.MultipartUploadBinder; import org.jclouds.googlecloudstorage.binders.UploadBinder; import org.jclouds.googlecloudstorage.domain.GCSObject; @@ -59,10 +58,10 @@ import org.jclouds.rest.annotations.Fallback; import org.jclouds.rest.annotations.MapBinder; import org.jclouds.rest.annotations.PATCH; import org.jclouds.rest.annotations.PayloadParam; +import org.jclouds.rest.annotations.QueryParams; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.ResponseParser; import org.jclouds.rest.annotations.SkipEncoding; -import org.jclouds.rest.annotations.QueryParams; import org.jclouds.rest.binders.BindToJsonPayload; /** @@ -387,10 +386,9 @@ public interface ObjectApi { @Consumes(MediaType.APPLICATION_JSON) @Path("storage/v1/b/{destinationBucket}/o/{destinationObject}/compose") @OAuthScopes(STORAGE_FULLCONTROL_SCOPE) - @MapBinder(ComposeObjectBinder.class) GCSObject composeObjects(@PathParam("destinationBucket") String destinationBucket, @PathParam("destinationObject") String destinationObject, - @PayloadParam("template") ComposeObjectTemplate composeObjectTemplate); + @BinderParam(BindToJsonPayload.class) ComposeObjectTemplate composeObjectTemplate); /** * Concatenates a list of existing objects into a new object in the same bucket. @@ -411,10 +409,10 @@ public interface ObjectApi { @Consumes(MediaType.APPLICATION_JSON) @Path("storage/v1/b/{destinationBucket}/o/{destinationObject}/compose") @OAuthScopes(STORAGE_FULLCONTROL_SCOPE) - @MapBinder(ComposeObjectBinder.class) GCSObject composeObjects(@PathParam("destinationBucket") String destinationBucket, @PathParam("destinationObject") String destinationObject, - @PayloadParam("template") ComposeObjectTemplate composeObjectTemplate, ComposeObjectOptions options); + @BinderParam(BindToJsonPayload.class) ComposeObjectTemplate composeObjectTemplate, + ComposeObjectOptions options); /** * Copies an object to a specified location. Optionally overrides metadata. @@ -485,6 +483,6 @@ public interface ObjectApi { @OAuthScopes(STORAGE_FULLCONTROL_SCOPE) @MapBinder(MultipartUploadBinder.class) GCSObject multipartUpload(@PathParam("bucket") String bucketName, - @PayloadParam("template") ObjectTemplate objectTemplate, @PayloadParam("payload") Payload payload); - + @BinderParam(BindToJsonPayload.class) ObjectTemplate objectTemplate, + @PayloadParam("payload") Payload payload); } diff --git a/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/features/ResumableUploadApi.java b/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/features/ResumableUploadApi.java index 91d822cdcd..3f68e304ef 100644 --- a/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/features/ResumableUploadApi.java +++ b/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/features/ResumableUploadApi.java @@ -29,7 +29,6 @@ import javax.ws.rs.PathParam; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; -import org.jclouds.googlecloudstorage.binders.ResumableUploadBinder; import org.jclouds.googlecloudstorage.binders.UploadBinder; import org.jclouds.googlecloudstorage.domain.ResumableUpload; import org.jclouds.googlecloudstorage.domain.templates.ObjectTemplate; @@ -38,12 +37,14 @@ import org.jclouds.googlecloudstorage.parser.ParseToResumableUpload; import org.jclouds.io.Payload; import org.jclouds.oauth.v2.config.OAuthScopes; import org.jclouds.oauth.v2.filters.OAuthAuthenticator; +import org.jclouds.rest.annotations.BinderParam; import org.jclouds.rest.annotations.MapBinder; import org.jclouds.rest.annotations.PayloadParam; import org.jclouds.rest.annotations.QueryParams; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.ResponseParser; import org.jclouds.rest.annotations.SkipEncoding; +import org.jclouds.rest.binders.BindToJsonPayload; /** * Provides Resumable Upload support via Rest API @@ -105,12 +106,11 @@ public interface ResumableUploadApi { @Consumes(MediaType.APPLICATION_JSON) @Path("/upload/storage/v1/b/{bucket}/o") @OAuthScopes(STORAGE_FULLCONTROL_SCOPE) - @MapBinder(ResumableUploadBinder.class) @ResponseParser(ParseToResumableUpload.class) ResumableUpload initResumableUpload(@PathParam("bucket") String bucketName, @HeaderParam("X-Upload-Content-Type") String contentType, @HeaderParam("X-Upload-Content-Length") Long contentLength, - @PayloadParam("template") ObjectTemplate metadata); + @BinderParam(BindToJsonPayload.class) ObjectTemplate metadata); /** * Stores a new object