brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rich...@apache.org
Subject [1/2] git commit: API methods returning `Iterable` breaks RESTclient
Date Sun, 01 Jun 2014 18:55:10 GMT
Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master 82ff6e8e5 -> 1e9d2a914


API methods returning `Iterable` breaks RESTclient

It is impossible to use the official rest-client module on API methods
that return `Iterable`, as Jackson does not know which concrete type to
implement. The Jackson configuration is hidden behind RESTeasy, so
reconfiguring Jackson is non trivial.

This PR changes some API calls from `Iterable` to `List`, which
RESTeasy/Jackson is able to deserialize. Further PRs will need to follow
for other `Iterable`-returning API methods.

Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/6183ff6a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/6183ff6a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/6183ff6a

Branch: refs/heads/master
Commit: 6183ff6a8fab06ba4cb4f084651d05e73503da51
Parents: 48df48a
Author: Richard Downer <richard.downer@cloudsoftcorp.com>
Authored: Sat May 31 14:46:33 2014 +0100
Committer: Richard Downer <richard.downer@cloudsoftcorp.com>
Committed: Sat May 31 14:55:27 2014 +0100

----------------------------------------------------------------------
 .../src/main/java/brooklyn/rest/api/ApplicationApi.java  |  5 +++--
 .../brooklyn/rest/resources/ApplicationResource.java     | 11 +++++++----
 2 files changed, 10 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6183ff6a/usage/rest-api/src/main/java/brooklyn/rest/api/ApplicationApi.java
----------------------------------------------------------------------
diff --git a/usage/rest-api/src/main/java/brooklyn/rest/api/ApplicationApi.java b/usage/rest-api/src/main/java/brooklyn/rest/api/ApplicationApi.java
index abe75af..ba59250 100644
--- a/usage/rest-api/src/main/java/brooklyn/rest/api/ApplicationApi.java
+++ b/usage/rest-api/src/main/java/brooklyn/rest/api/ApplicationApi.java
@@ -1,5 +1,6 @@
 package brooklyn.rest.api;
 
+import java.util.List;
 import java.util.Map;
 
 import javax.validation.Valid;
@@ -57,7 +58,7 @@ public interface ApplicationApi {
       value = "Fetch list of applications, as ApplicationSummary objects",
       responseClass = "brooklyn.rest.domain.ApplicationSummary"
   )
-  public Iterable<ApplicationSummary> list() ;
+  public List<ApplicationSummary> list() ;
 
   @GET
   @Path("/{application}")
@@ -170,7 +171,7 @@ public interface ApplicationApi {
   @ApiErrors(value = {
       @ApiError(code = 404, reason = "Application or entity missing")
   })
-  public Iterable<EntitySummary> getDescendants(
+  public List<EntitySummary> getDescendants(
       @ApiParam(value = "Application ID or name", required = true)
       @PathParam("application") String application,
       @ApiParam(value="Regular expression for an entity type which must be matched", required=false)

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6183ff6a/usage/rest-server/src/main/java/brooklyn/rest/resources/ApplicationResource.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/main/java/brooklyn/rest/resources/ApplicationResource.java
b/usage/rest-server/src/main/java/brooklyn/rest/resources/ApplicationResource.java
index b270773..9a72d24 100644
--- a/usage/rest-server/src/main/java/brooklyn/rest/resources/ApplicationResource.java
+++ b/usage/rest-server/src/main/java/brooklyn/rest/resources/ApplicationResource.java
@@ -59,7 +59,7 @@ import brooklyn.util.collections.MutableMap;
 import brooklyn.util.exceptions.Exceptions;
 
 import com.google.common.base.Throwables;
-import com.google.common.collect.Collections2;
+import com.google.common.collect.FluentIterable;
 import com.google.common.collect.Iterables;
 
 
@@ -182,8 +182,11 @@ public class ApplicationResource extends AbstractBrooklynRestResource
implements
   }
   
   @Override
-  public Iterable<ApplicationSummary> list() {
-    return Collections2.transform(mgmt().getApplications(), ApplicationTransformer.FROM_APPLICATION);
+  public List<ApplicationSummary> list() {
+      return FluentIterable
+              .from(mgmt().getApplications())
+              .transform(ApplicationTransformer.FROM_APPLICATION)
+              .toList();
   }
 
   @Override
@@ -353,7 +356,7 @@ public class ApplicationResource extends AbstractBrooklynRestResource
implements
   }
 
   @Override
-  public Iterable<EntitySummary> getDescendants(String application, String typeRegex)
{
+  public List<EntitySummary> getDescendants(String application, String typeRegex) {
       return EntityTransformer.entitySummaries(brooklyn().descendantsOfType(application,
application, typeRegex));
   }
 


Mime
View raw message