incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vgog...@apache.org
Subject svn commit: r1183096 - in /incubator/ambari/trunk: client/src/main/java/org/apache/ambari/client/ client/src/main/java/org/apache/ambari/common/rest/entities/ controller/src/main/java/org/apache/ambari/controller/ controller/src/main/java/org/apache/am...
Date Thu, 13 Oct 2011 21:06:29 GMT
Author: vgogate
Date: Thu Oct 13 21:06:28 2011
New Revision: 1183096

URL: http://svn.apache.org/viewvc?rev=1183096&view=rev
Log:
AMBARI-68

Modified:
    incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/BlueprintAdd.java
    incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/ClusterCreate.java
    incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/rest/entities/Configuration.java
    incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/rest/entities/ConfigurationCategory.java
    incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Blueprints.java
    incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/resources/BlueprintsResource.java

Modified: incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/BlueprintAdd.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/BlueprintAdd.java?rev=1183096&r1=1183095&r2=1183096&view=diff
==============================================================================
--- incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/BlueprintAdd.java
(original)
+++ incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/BlueprintAdd.java
Thu Oct 13 21:06:28 2011
@@ -80,7 +80,7 @@ public class BlueprintAdd extends Comman
         OptionBuilder.withArgName("location");
         OptionBuilder.isRequired();
         OptionBuilder.hasArg();
-        OptionBuilder.withDescription( "Either URL or local file path where blueprint is
available");
+        OptionBuilder.withDescription( "Either URL or local file path where blueprint in
XML format is available");
         Option location = OptionBuilder.create( "location" );
         
         this.options = new Options();
@@ -141,16 +141,20 @@ public class BlueprintAdd extends Comman
             Blueprint bp = new Blueprint();
             response = service.path("blueprints")
                     .queryParam("url", location)
-                    .accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON).post(ClientResponse.class,
bp);
+                    .accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_XML).post(ClientResponse.class,
bp);
         } else {
             Blueprint bp = this.readBlueprintFromFile(f);
             response = service.path("blueprints")
-                    .accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON).post(ClientResponse.class,
bp);
-        }        
+                    .accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_XML).post(ClientResponse.class,
bp);
+        }     
+        
+        Blueprint bp_return = response.getEntity(Blueprint.class);
         if (response.getStatus() != 200) { 
             System.err.println("Blueprint add command failed. Reason [Code: <"+response.getStatus()+">,
Message: <"+response.getHeaders().getFirst("ErrorMessage")+">]");
             System.exit(-1);
         }
+        System.out.println("Blueprint added.\n");
+        printClusterBlueprint(bp_return, null);
     }
     
     public Blueprint readBlueprintFromFile (File f) throws Exception {      

Modified: incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/ClusterCreate.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/ClusterCreate.java?rev=1183096&r1=1183095&r2=1183096&view=diff
==============================================================================
--- incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/ClusterCreate.java
(original)
+++ incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/ClusterCreate.java
Thu Oct 13 21:06:28 2011
@@ -193,13 +193,6 @@ public class ClusterCreate extends Comma
       }
       return result;
     }
-
-    public void printClusterDefinition(ClusterDefinition def) throws Exception {
-        JAXBContext jc = JAXBContext.newInstance(org.apache.ambari.common.rest.entities.ClusterDefinition.class);
-        Marshaller m = jc.createMarshaller();
-        m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
-        m.marshal(def, System.out);
-    }
     
     public void run() throws Exception {
         /* 

Modified: incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/rest/entities/Configuration.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/rest/entities/Configuration.java?rev=1183096&r1=1183095&r2=1183096&view=diff
==============================================================================
--- incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/rest/entities/Configuration.java
(original)
+++ incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/rest/entities/Configuration.java
Thu Oct 13 21:06:28 2011
@@ -35,10 +35,10 @@ import javax.xml.bind.annotation.XmlType
 @XmlType(name = "Configuration", propOrder = {
     "category"
 })
-@XmlRootElement(name = "Configuration")
+@XmlRootElement
 public class Configuration {
 
-    @XmlElements({@XmlElement(name = "ConfigurationCategory")})
+    @XmlElements({@XmlElement})
     protected List<ConfigurationCategory> category;
 
     /**

Modified: incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/rest/entities/ConfigurationCategory.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/rest/entities/ConfigurationCategory.java?rev=1183096&r1=1183095&r2=1183096&view=diff
==============================================================================
--- incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/rest/entities/ConfigurationCategory.java
(original)
+++ incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/rest/entities/ConfigurationCategory.java
Thu Oct 13 21:06:28 2011
@@ -36,12 +36,12 @@ import javax.xml.bind.annotation.XmlType
 @XmlType(name = "ConfigurationCategory", propOrder = {
     "property"
 })
-@XmlRootElement(name = "ConfigurationCategory")
+@XmlRootElement
 public class ConfigurationCategory {
 
-    @XmlAttribute(name = "Name", required = true)
+    @XmlAttribute(required = true)
     protected String name;
-    @XmlElements({@XmlElement(name = "Property")})
+    @XmlElements({@XmlElement})
     protected List<Property> property;
 
     /**

Modified: incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Blueprints.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Blueprints.java?rev=1183096&r1=1183095&r2=1183096&view=diff
==============================================================================
--- incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Blueprints.java
(original)
+++ incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Blueprints.java
Thu Oct 13 21:06:28 2011
@@ -32,6 +32,8 @@ import java.util.concurrent.ConcurrentHa
 
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.Response;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Unmarshaller;
 
 import org.apache.ambari.common.rest.entities.Blueprint;
 import org.apache.ambari.common.rest.entities.Component;
@@ -190,9 +192,15 @@ public class Blueprints {
         URL blueprintUrl;
         try {
             blueprintUrl = new URL(locationURL);
-            ObjectMapper m = new ObjectMapper();
             InputStream is = blueprintUrl.openStream();
+            
+            /* JSON FORMAT READER
+            ObjectMapper m = new ObjectMapper();
             blueprint = m.readValue(is, Blueprint.class);
+            */
+            JAXBContext jc = JAXBContext.newInstance(org.apache.ambari.common.rest.entities.Blueprint.class);
+            Unmarshaller u = jc.createUnmarshaller();
+            blueprint = (Blueprint)u.unmarshal(is);
             return addBlueprint(blueprint);
         } catch (WebApplicationException we) {
             throw we;

Modified: incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/resources/BlueprintsResource.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/resources/BlueprintsResource.java?rev=1183096&r1=1183095&r2=1183096&view=diff
==============================================================================
--- incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/resources/BlueprintsResource.java
(original)
+++ incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/resources/BlueprintsResource.java
Thu Oct 13 21:06:28 2011
@@ -55,7 +55,7 @@ public class BlueprintsResource {
      * @throws Exception throws Exception
      */
     @POST
-    @Consumes ({"application/json"})
+    @Consumes ({"application/xml"})
     public Blueprint createBlueprint(@DefaultValue("") @QueryParam("url") String locationURL,
Blueprint blueprint) throws Exception {  
         try {
             if (locationURL == null || locationURL.equals("")) {
@@ -77,7 +77,7 @@ public class BlueprintsResource {
      * @throws Exception throws Exception
      */
     @GET
-    @Produces({"application/json"})
+    @Produces({"application/json", "application/xml"})
     public JSONArray listBlueprints() throws Exception {
         JSONArray list;
         try {



Mime
View raw message