incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maha...@apache.org
Subject svn commit: r1396478 - in /incubator/ambari/branches/AMBARI-666: ./ ambari-server/src/main/java/org/apache/ambari/server/api/services/ ambari-server/src/main/java/org/apache/ambari/server/api/services/parsers/ ambari-server/src/test/java/org/apache/amb...
Date Wed, 10 Oct 2012 05:57:45 GMT
Author: mahadev
Date: Wed Oct 10 05:57:44 2012
New Revision: 1396478

URL: http://svn.apache.org/viewvc?rev=1396478&view=rev
Log:
AMBARI-833. Add missing Path annotation to rest services for put/post/delete. (John Speidel
via mahadev)

Modified:
    incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/ClusterService.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/ComponentService.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/RequestImpl.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/ServiceService.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/parsers/JsonPropertyParser.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/api/services/parsers/JsonPropertyParserTest.java

Modified: incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt?rev=1396478&r1=1396477&r2=1396478&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt (original)
+++ incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt Wed Oct 10 05:57:44 2012
@@ -12,6 +12,9 @@ AMBARI-666 branch (unreleased changes)
 
   NEW FEATURES
 
+  AMBARI-833. Add missing Path annotation to rest services for
+  put/post/delete. (John Speidel via mahadev)
+
   AMBARI-838. HACK: Add a thread in server to inject requests for testing.
   (Jitendra via mahadev)
 

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/ClusterService.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/ClusterService.java?rev=1396478&r1=1396477&r2=1396478&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/ClusterService.java
(original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/ClusterService.java
Wed Oct 10 05:57:44 2012
@@ -72,10 +72,11 @@ public class ClusterService extends Base
    * @param clusterName cluster id
    * @return information regarding the created cluster
    */
-  @PUT
-  @Produces("text/plain")
-  public Response createCluster(String body, @Context HttpHeaders headers, @Context UriInfo
ui,
-                                @PathParam("clusterName") String clusterName) {
+   @PUT
+   @Path("{clusterName}")
+   @Produces("text/plain")
+   public Response createCluster(String body, @Context HttpHeaders headers, @Context UriInfo
ui,
+                                 @PathParam("clusterName") String clusterName) {
 
     return handleRequest(headers, body, ui, Request.Type.PUT, createResourceDefinition(clusterName));
   }
@@ -90,6 +91,7 @@ public class ClusterService extends Base
    * @return information regarding the updated cluster
    */
   @POST
+  @Path("{clusterName}")
   @Produces("text/plain")
   public Response updateCluster(String body, @Context HttpHeaders headers, @Context UriInfo
ui,
                                 @PathParam("clusterName") String clusterName) {
@@ -107,6 +109,7 @@ public class ClusterService extends Base
    * @return information regarding the deleted cluster
    */
   @DELETE
+  @Path("{clusterName}")
   @Produces("text/plain")
   public Response deleteCluster(@Context HttpHeaders headers, @Context UriInfo ui,
                                 @PathParam("clusterName") String clusterName) {

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/ComponentService.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/ComponentService.java?rev=1396478&r1=1396477&r2=1396478&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/ComponentService.java
(original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/ComponentService.java
Wed Oct 10 05:57:44 2012
@@ -95,6 +95,7 @@ public class ComponentService extends Ba
    * @return information regarding the created component
    */
   @PUT
+  @Path("{componentName}")
   @Produces("text/plain")
   public Response createComponent(String body, @Context HttpHeaders headers, @Context UriInfo
ui,
                                 @PathParam("componentName") String componentName) {
@@ -115,6 +116,7 @@ public class ComponentService extends Ba
    * @return information regarding the updated component
    */
   @POST
+  @Path("{componentName}")
   @Produces("text/plain")
   public Response updateComponent(String body, @Context HttpHeaders headers, @Context UriInfo
ui,
                                 @PathParam("componentName") String componentName) {
@@ -133,6 +135,7 @@ public class ComponentService extends Ba
    * @return information regarding the deleted cluster
    */
   @DELETE
+  @Path("{componentName}")
   @Produces("text/plain")
   public Response deleteComponent(@Context HttpHeaders headers, @Context UriInfo ui,
                                 @PathParam("componentName") String componentName) {

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/RequestImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/RequestImpl.java?rev=1396478&r1=1396477&r2=1396478&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/RequestImpl.java
(original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/RequestImpl.java
Wed Oct 10 05:57:44 2012
@@ -127,8 +127,7 @@ public class RequestImpl implements Requ
 
   @Override
   public Map<PropertyId, String> getHttpBodyProperties() {
-    return m_body == null ? Collections.<PropertyId, String>emptyMap() :
-        getHttpBodyParser().parse(getHttpBody());
+    return getHttpBodyParser().parse(getHttpBody());
   }
 
   @Override

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/ServiceService.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/ServiceService.java?rev=1396478&r1=1396477&r2=1396478&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/ServiceService.java
(original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/ServiceService.java
Wed Oct 10 05:57:44 2012
@@ -87,6 +87,7 @@ public class ServiceService extends Base
    * @return information regarding the created service
    */
   @PUT
+  @Path("{serviceName}")
   @Produces("text/plain")
   public Response createService(String body, @Context HttpHeaders headers, @Context UriInfo
ui,
                                 @PathParam("serviceName") String serviceName) {
@@ -105,6 +106,7 @@ public class ServiceService extends Base
    * @return information regarding the updated service
    */
   @POST
+  @Path("{serviceName}")
   @Produces("text/plain")
   public Response updateService(String body, @Context HttpHeaders headers, @Context UriInfo
ui,
                                 @PathParam("serviceName") String serviceName) {
@@ -122,6 +124,7 @@ public class ServiceService extends Base
    * @return information regarding the deleted service
    */
   @DELETE
+  @Path("{serviceName}")
   @Produces("text/plain")
   public Response deleteService(@Context HttpHeaders headers, @Context UriInfo ui,
                                 @PathParam("serviceName") String serviceName) {

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/parsers/JsonPropertyParser.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/parsers/JsonPropertyParser.java?rev=1396478&r1=1396477&r2=1396478&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/parsers/JsonPropertyParser.java
(original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/parsers/JsonPropertyParser.java
Wed Oct 10 05:57:44 2012
@@ -39,10 +39,12 @@ public class JsonPropertyParser implemen
   public Map<PropertyId, String> parse(String s) {
     ObjectMapper mapper = new ObjectMapper();
 
-    try {
-      processNode(mapper.readValue(s, JsonNode.class), "");
-    } catch (IOException e) {
-      throw new RuntimeException("Unable to parse json: " + e, e);
+    if (s != null && ! s.isEmpty()) {
+      try {
+        processNode(mapper.readValue(s, JsonNode.class), "");
+      } catch (IOException e) {
+        throw new RuntimeException("Unable to parse json: " + e, e);
+      }
     }
 
     return m_properties;

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/api/services/parsers/JsonPropertyParserTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/api/services/parsers/JsonPropertyParserTest.java?rev=1396478&r1=1396477&r2=1396478&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/api/services/parsers/JsonPropertyParserTest.java
(original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/api/services/parsers/JsonPropertyParserTest.java
Wed Oct 10 05:57:44 2012
@@ -22,6 +22,7 @@ import org.apache.ambari.server.controll
 import org.apache.ambari.server.controller.spi.PropertyId;
 import org.junit.Test;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -61,6 +62,22 @@ public class JsonPropertyParserTest {
 
     assertEquals(mapExpected, mapProps);
   }
+
+  @Test
+  public void testParse_NullBody() {
+    RequestBodyParser parser = new JsonPropertyParser();
+    Map<PropertyId, String> mapProps = parser.parse(null);
+    assertNotNull(mapProps);
+    assertEquals(0, mapProps.size());
+  }
+
+  @Test
+  public void testParse_EmptyBody() {
+    RequestBodyParser parser = new JsonPropertyParser();
+    Map<PropertyId, String> mapProps = parser.parse("");
+    assertNotNull(mapProps);
+    assertEquals(0, mapProps.size());
+  }
 }
 
 



Mime
View raw message