You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ch...@apache.org on 2010/07/07 06:19:54 UTC

svn commit: r961208 - in /activemq/sandbox/activemq-apollo-actor/activemq-web/src/main: scala/org/apache/activemq/apollo/web/resources/ webapp/WEB-INF/org/apache/activemq/apollo/dto/

Author: chirino
Date: Wed Jul  7 04:19:54 2010
New Revision: 961208

URL: http://svn.apache.org/viewvc?rev=961208&view=rev
Log:
added an html form for updating the broker config.

Added:
    activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/dto/BrokerDTO.scaml
Modified:
    activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/apache/activemq/apollo/web/resources/ConfigurationResource.scala
    activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/apache/activemq/apollo/web/resources/RuntimeResource.scala

Modified: activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/apache/activemq/apollo/web/resources/ConfigurationResource.scala
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/apache/activemq/apollo/web/resources/ConfigurationResource.scala?rev=961208&r1=961207&r2=961208&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/apache/activemq/apollo/web/resources/ConfigurationResource.scala (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/apache/activemq/apollo/web/resources/ConfigurationResource.scala Wed Jul  7 04:19:54 2010
@@ -21,15 +21,16 @@ import core.{UriInfo, Response, Context}
 import org.fusesource.hawtdispatch.Future
 import Response.Status._
 import Response._
-import org.apache.activemq.apollo.dto.{BrokerDTO}
 import org.apache.activemq.apollo.web.ConfigStore
 import java.net.URI
+import java.io.ByteArrayInputStream
+import org.apache.activemq.apollo.dto.{XmlEncoderDecoder, BrokerDTO}
 
 /**
  * A broker resource is used to represent the configuration of a broker.
  */
 @Produces(Array("application/json", "application/xml","text/xml", "text/html;qs=5"))
-case class ConfigurationResource(parent:BrokerResource) extends Resource {
+case class ConfigurationResource(parent:BrokerResource) extends Resource(parent) {
 
 
   def store = ConfigStore()
@@ -44,7 +45,7 @@ case class ConfigurationResource(parent:
   @GET
   def get(@Context uriInfo:UriInfo) = {
     val ub = uriInfo.getAbsolutePathBuilder()
-    seeOther(ub.path(config.rev.toString).build()).build
+    seeOther(path(config.rev)).build
   }
 
   @GET @Path("{rev}")
@@ -54,6 +55,13 @@ case class ConfigurationResource(parent:
     config
   }
 
+  @POST @Path("{rev}")
+  def post(@PathParam("rev") rev:Int, @FormParam("config") config:String) = {
+    val dto = XmlEncoderDecoder.unmarshalBrokerDTO(new ByteArrayInputStream(config.getBytes("UTF-8")))
+    put(rev, dto)
+    seeOther(path("../"+dto.rev)).build
+  }
+
   @PUT @Path("{rev}")
   def put(@PathParam("rev") rev:Int, config:BrokerDTO) = {
     config.id = parent.id;

Modified: activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/apache/activemq/apollo/web/resources/RuntimeResource.scala
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/apache/activemq/apollo/web/resources/RuntimeResource.scala?rev=961208&r1=961207&r2=961208&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/apache/activemq/apollo/web/resources/RuntimeResource.scala (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/apache/activemq/apollo/web/resources/RuntimeResource.scala Wed Jul  7 04:19:54 2010
@@ -37,7 +37,7 @@ import collection.mutable.ListBuffer
  * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
  */
 @Produces(Array("application/json", "application/xml","text/xml", "text/html;qs=5"))
-case class RuntimeResource(parent:BrokerResource) extends Resource {
+case class RuntimeResource(parent:BrokerResource) extends Resource(parent) {
 
   private def with_broker[T](func: (org.apache.activemq.apollo.broker.Broker, Option[T]=>Unit)=>Unit):T = {
     val broker:org.apache.activemq.apollo.broker.Broker = BrokerRegistry.get(parent.id)

Added: activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/dto/BrokerDTO.scaml
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/dto/BrokerDTO.scaml?rev=961208&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/dto/BrokerDTO.scaml (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/dto/BrokerDTO.scaml Wed Jul  7 04:19:54 2010
@@ -0,0 +1,15 @@
+- val helper = new org.apache.activemq.apollo.web.resources.ViewHelper
+- import helper._
+- import org.fusesource.hawtbuf._
+- import org.apache.activemq.apollo.dto.XmlEncoderDecoder._
+
+%form(method="post" action={it.rev+1})
+  %div
+    %input(type="submit" value="Update")
+  %div
+    %textarea(rows="40" cols="80" name="config")<
+      - val baos = new ByteArrayOutputStream
+      - marshalBrokerDTO(it, baos, true)
+      ~~ new String(baos.toByteArray, "UTF-8")
+  %div
+    %input(type="submit" value="Update")
\ No newline at end of file