From 941579707530acb8d9f7657e21feaa8879cb0c0a Mon Sep 17 00:00:00 2001 From: andreisavu Date: Fri, 2 Dec 2011 18:06:47 +0200 Subject: [PATCH] Made updates to the parser as Adrian suggested --- .../cloudstack/features/AsyncJobAsyncClient.java | 1 - .../functions/ParseAsyncJobsFromHttpResponse.java | 14 +++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/AsyncJobAsyncClient.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/AsyncJobAsyncClient.java index 00d2f59935..eef86dd0c7 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/AsyncJobAsyncClient.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/AsyncJobAsyncClient.java @@ -57,7 +57,6 @@ public interface AsyncJobAsyncClient { */ @GET @QueryParams(keys = "command", values = "listAsyncJobs") - @SelectJson("asyncjobs") @ResponseParser(ParseAsyncJobsFromHttpResponse.class) @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) ListenableFuture>> listAsyncJobs(ListAsyncJobsOptions... options); diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/functions/ParseAsyncJobsFromHttpResponse.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/functions/ParseAsyncJobsFromHttpResponse.java index 78d1494177..f182804121 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/functions/ParseAsyncJobsFromHttpResponse.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/functions/ParseAsyncJobsFromHttpResponse.java @@ -25,30 +25,34 @@ import java.util.Set; import javax.inject.Singleton; +import com.google.inject.TypeLiteral; import org.jclouds.cloudstack.domain.AsyncJob; import org.jclouds.domain.JsonBall; import org.jclouds.http.HttpResponse; +import org.jclouds.http.functions.ParseFirstJsonValueNamed; import org.jclouds.http.functions.UnwrapOnlyNestedJsonValue; import com.google.common.base.Function; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.inject.Inject; +import org.jclouds.json.internal.GsonWrapper; /** - * * @author Adrian Cole */ @Singleton public class ParseAsyncJobsFromHttpResponse implements Function>> { - private final UnwrapOnlyNestedJsonValue>>> parser; + private final ParseFirstJsonValueNamed>>> parser; private final ParseTypedAsyncJob parseTyped; @Inject - public ParseAsyncJobsFromHttpResponse(ParseTypedAsyncJob parseTyped, - UnwrapOnlyNestedJsonValue>>> parser) { + public ParseAsyncJobsFromHttpResponse(ParseTypedAsyncJob parseTyped, GsonWrapper gsonWrapper) { this.parseTyped = checkNotNull(parseTyped, "parseTyped"); - this.parser = checkNotNull(parser, "parser"); + this.parser = new ParseFirstJsonValueNamed>>>( + checkNotNull(gsonWrapper, "gsonWrapper"), + new TypeLiteral>>>() { }, + "asyncjobs"); } public Set> apply(HttpResponse response) {