eagle-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h..@apache.org
Subject incubator-eagle git commit: [EAGLE-399] Implement consistent RESTResponse Wrapper for GET request
Date Fri, 29 Jul 2016 08:45:51 GMT
Repository: incubator-eagle
Updated Branches:
  refs/heads/develop 994a1e584 -> b75367832


[EAGLE-399] Implement consistent RESTResponse Wrapper for GET request

https://issues.apache.org/jira/browse/EAGLE-399

Author: Hao Chen <hao@apache.org>

Closes #285 from haoch/EAGLE-399-2.


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

Branch: refs/heads/develop
Commit: b7536783206d3e131040eb43b613093b83a35325
Parents: 994a1e5
Author: Hao Chen <hao@apache.org>
Authored: Fri Jul 29 16:45:33 2016 +0800
Committer: Hao Chen <hao@apache.org>
Committed: Fri Jul 29 16:45:33 2016 +0800

----------------------------------------------------------------------
 .../eagle/app/resource/ApplicationResource.java | 26 +++++++++++---------
 .../eagle/app/TestApplicationTestSuite.java     |  2 +-
 .../eagle/metadata/resource/SiteResource.java   |  8 +++---
 .../app/example/ExampleApplicationTest.java     |  2 +-
 4 files changed, 20 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/b7536783/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/resource/ApplicationResource.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/resource/ApplicationResource.java
b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/resource/ApplicationResource.java
index 7878587..185a1d5 100644
--- a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/resource/ApplicationResource.java
+++ b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/resource/ApplicationResource.java
@@ -49,15 +49,15 @@ public class ApplicationResource {
     @GET
     @Path("/providers")
     @Produces(MediaType.APPLICATION_JSON)
-    public Collection<ApplicationDesc> getApplicationDescs(){
-        return providerService.getApplicationDescs();
+    public RESTResponse<Collection<ApplicationDesc>> getApplicationDescs(){
+        return RESTResponse.async(providerService::getApplicationDescs).get();
     }
 
     @GET
     @Path("/providers/{type}")
     @Produces(MediaType.APPLICATION_JSON)
-    public ApplicationDesc getApplicationDescs(@PathParam("type") String type){
-        return providerService.getApplicationDescByType(type);
+    public RESTResponse<ApplicationDesc> getApplicationDescByType(@PathParam("type")
String type){
+        return RESTResponse.async(()->providerService.getApplicationDescByType(type)).get();
     }
 
     @PUT
@@ -74,19 +74,21 @@ public class ApplicationResource {
     @GET
     @Path("/")
     @Produces(MediaType.APPLICATION_JSON)
-    public Collection<ApplicationEntity> getApplicationEntities(@QueryParam("siteId")
String siteId){
-        if(siteId == null) {
-            return entityService.findAll();
-        } else {
-            return entityService.findBySiteId(siteId);
-        }
+    public RESTResponse<Collection<ApplicationEntity>> getApplicationEntities(@QueryParam("siteId")
String siteId){
+        return RESTResponse.async(()-> {
+            if (siteId == null) {
+                return entityService.findAll();
+            } else {
+                return entityService.findBySiteId(siteId);
+            }
+        }).get();
     }
 
     @GET
     @Path("/{appUuid}")
     @Produces(MediaType.APPLICATION_JSON)
-    public ApplicationEntity getApplicationEntityByUUID(@PathParam("appUuid") String appUuid){
-        return entityService.getByUUID(appUuid);
+    public RESTResponse<ApplicationEntity> getApplicationEntityByUUID(@PathParam("appUuid")
String appUuid){
+        return RESTResponse.async(()->entityService.getByUUID(appUuid)).get();
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/b7536783/eagle-core/eagle-app/eagle-app-base/src/test/java/org/apache/eagle/app/TestApplicationTestSuite.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-app/eagle-app-base/src/test/java/org/apache/eagle/app/TestApplicationTestSuite.java
b/eagle-core/eagle-app/eagle-app-base/src/test/java/org/apache/eagle/app/TestApplicationTestSuite.java
index 9688951..de3338e 100644
--- a/eagle-core/eagle-app/eagle-app-base/src/test/java/org/apache/eagle/app/TestApplicationTestSuite.java
+++ b/eagle-core/eagle-app/eagle-app-base/src/test/java/org/apache/eagle/app/TestApplicationTestSuite.java
@@ -40,7 +40,7 @@ public class TestApplicationTestSuite {
 
     @Test
     public void testApplicationProviderLoading(){
-        Collection<ApplicationDesc> applicationDescs = applicationResource.getApplicationDescs();
+        Collection<ApplicationDesc> applicationDescs = applicationResource.getApplicationDescs().getData();
         Assert.assertNotNull(applicationDescs);
         Assert.assertEquals(1,applicationDescs.size());
     }

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/b7536783/eagle-core/eagle-metadata/eagle-metadata-base/src/main/java/org/apache/eagle/metadata/resource/SiteResource.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-metadata/eagle-metadata-base/src/main/java/org/apache/eagle/metadata/resource/SiteResource.java
b/eagle-core/eagle-metadata/eagle-metadata-base/src/main/java/org/apache/eagle/metadata/resource/SiteResource.java
index bf642c2..ec683b7 100644
--- a/eagle-core/eagle-metadata/eagle-metadata-base/src/main/java/org/apache/eagle/metadata/resource/SiteResource.java
+++ b/eagle-core/eagle-metadata/eagle-metadata-base/src/main/java/org/apache/eagle/metadata/resource/SiteResource.java
@@ -40,8 +40,8 @@ public class SiteResource {
     @GET
     @Path("/")
     @Produces(MediaType.APPLICATION_JSON)
-    public Collection<SiteEntity> getAllSites(){
-        return siteEntityService.findAll();
+    public RESTResponse<Collection<SiteEntity>> getAllSites(){
+        return RESTResponse.async(siteEntityService::findAll).get();
     }
 
     @POST
@@ -59,7 +59,7 @@ public class SiteResource {
     @GET
     @Path("/{siteIdOrUUID}")
     @Produces(MediaType.APPLICATION_JSON)
-    public SiteEntity getSiteByNameOrUUID(@PathParam("siteIdOrUUID") String siteIdOrUUID){
-        return siteEntityService.getBySiteIdOrUUID(siteIdOrUUID);
+    public RESTResponse<SiteEntity> getSiteByNameOrUUID(@PathParam("siteIdOrUUID")
String siteIdOrUUID){
+        return RESTResponse.async(()->siteEntityService.getBySiteIdOrUUID(siteIdOrUUID)).get();
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/b7536783/eagle-examples/eagle-app-example/src/test/java/org/apache/eagle/app/example/ExampleApplicationTest.java
----------------------------------------------------------------------
diff --git a/eagle-examples/eagle-app-example/src/test/java/org/apache/eagle/app/example/ExampleApplicationTest.java
b/eagle-examples/eagle-app-example/src/test/java/org/apache/eagle/app/example/ExampleApplicationTest.java
index d4cc082..4383907 100644
--- a/eagle-examples/eagle-app-example/src/test/java/org/apache/eagle/app/example/ExampleApplicationTest.java
+++ b/eagle-examples/eagle-app-example/src/test/java/org/apache/eagle/app/example/ExampleApplicationTest.java
@@ -39,7 +39,7 @@ public class ExampleApplicationTest {
 
     @Test
     public void testApplicationProviderLoading(){
-        Collection<ApplicationDesc> applicationDescs = applicationResource.getApplicationDescs();
+        Collection<ApplicationDesc> applicationDescs = applicationResource.getApplicationDescs().getData();
         Assert.assertNotNull(applicationDescs);
         Assert.assertEquals(2,applicationDescs.size());
     }


Mime
View raw message