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 2011/06/12 13:38:17 UTC
svn commit: r1134915 - in /activemq/activemq-apollo/trunk:
apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/
apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/
apollo-web/src/main/webapp/WEB-INF/ apollo-web/src/main/webap...
Author: chirino
Date: Sun Jun 12 11:38:17 2011
New Revision: 1134915
URL: http://svn.apache.org/viewvc?rev=1134915&view=rev
Log:
Fixes https://issues.apache.org/jira/browse/APLO-40 : Web interface should support editing all the apollo configuration files.
Added:
activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/web/resources/ListConfigs.jade
- copied, changed from r1134769, activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/dto/BrokerDTO.jade
Removed:
activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/dto/BrokerDTO.jade
Modified:
activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Queue.scala
activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/ConfigurationResource.scala
activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/dto/BrokerStatusDTO.jade
activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/web/resources/EditConfig.jade
activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/web.xml
Modified: activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Queue.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Queue.scala?rev=1134915&r1=1134914&r2=1134915&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Queue.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Queue.scala Sun Jun 12 11:38:17 2011
@@ -145,9 +145,6 @@ class Queue(val router: LocalRouter, val
auto_delete_after = 0
}
}
-
- println("auto_delete_after: "+this+": "+auto_delete_after)
-
}
dispatch_queue {
configure(config)
@@ -225,7 +222,6 @@ class Queue(val router: LocalRouter, val
}
def check_idle {
- println("check_idle auto_delete_after: "+this+": "+auto_delete_after)
if (producers.isEmpty && all_subscriptions.isEmpty && queue_items==0 ) {
if (idled_at==0) {
val now = System.currentTimeMillis()
@@ -272,8 +268,6 @@ class Queue(val router: LocalRouter, val
}
protected def _start(on_completed: Runnable) = {
- println("_start auto_delete_after: "+this+": "+auto_delete_after)
-
swapped_in_size_max += tune_queue_buffer;
restore_from_store {
Modified: activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/ConfigurationResource.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/ConfigurationResource.scala?rev=1134915&r1=1134914&r2=1134915&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/ConfigurationResource.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/ConfigurationResource.scala Sun Jun 12 11:38:17 2011
@@ -16,49 +16,29 @@
*/
package org.apache.activemq.apollo.web.resources
-import javax.ws.rs._
-import core.Response
-import Response.Status._
-import org.apache.activemq.apollo.broker.ConfigStore
-import org.apache.activemq.apollo.dto.{XmlCodec, BrokerDTO, ValueDTO}
+import org.apache.activemq.apollo.dto.{XmlCodec, BrokerDTO}
import org.fusesource.hawtbuf._
+import java.io.File
+import org.apache.activemq.apollo.util.FileSupport._
+import javax.ws.rs._
+import javax.ws.rs.core.Response.Status._
import com.sun.jersey.api.view.ImplicitProduces
-case class EditConfig(config:String)
+case class EditConfig(file:String, config:String, can_write:Boolean)
+case class ListConfigs(files:Array[String])
/**
* A broker resource is used to represent the configuration of a broker.
*/
case class ConfigurationResource(parent:BrokerResource, dto:BrokerDTO) extends Resource(parent) {
- lazy val store = {
- val rc = ConfigStore()
- if( rc !=null && rc.can_write ) {
- rc
- } else {
- None
- }.getOrElse(result(NOT_FOUND))
- }
-
- @GET
- @Produces(Array("text/plain"))
- def get() = store.read
-
- @PUT
- def put( config:String):Unit = {
- store.write(config)
- }
-
- @POST
- def edit_post(@FormParam("config") config:String) = {
- put(config)
- result(uri_info.getAbsolutePathBuilder().build())
- }
-
- @GET
- @Produces(Array("text/html"))
- def edit_html() = {
- EditConfig(store.read)
+ lazy val etc_directory = {
+ val apollo_base = Option(System.getProperty("apollo.base")).getOrElse(result(NOT_FOUND))
+ val rc = new File(apollo_base) / "etc"
+ if ( !rc.exists() || !rc.isDirectory ) {
+ result(NOT_FOUND)
+ }
+ rc
}
@GET
@@ -81,5 +61,67 @@ case class ConfigurationResource(parent:
copy
}
+ @GET
+ @Produces(Array("application/json"))
+ @Path("files")
+ def list() = {
+ etc_directory.listFiles().flatMap { file =>
+ if( file.canRead ) {
+ Some(file.getName)
+ } else {
+ None
+ }
+ }
+ }
+
+ @GET
+ @Produces(Array("text/html"))
+ @Path("files")
+ def list_html() = {
+ ListConfigs(list())
+ }
+
+ @GET
+ @Produces(Array("text/plain"))
+ @Path("files/{name}")
+ def get(@PathParam("name") name:String) = {
+ val file = etc_directory / name
+ if( !file.exists() || !file.canRead || file.getParentFile != etc_directory ) {
+ result(NOT_FOUND)
+ }
+ file.read_bytes
+ }
+
+ @GET
+ @Produces(Array("text/html"))
+ @Path("files/{name}")
+ def edit_html(@PathParam("name") name:String) = {
+ val file = etc_directory / name
+ if( !file.exists() || !file.canRead || file.getParentFile != etc_directory ) {
+ result(NOT_FOUND)
+ }
+ EditConfig(name, file.read_text(), file.canWrite)
+ }
+
+ @PUT
+ @Path("files/{name}")
+ def put(@PathParam("name") name:String, config:Array[Byte]):Unit = {
+ val file = etc_directory / name
+ if( !file.exists() || !file.canWrite || file.getParentFile != etc_directory ) {
+ result(NOT_FOUND)
+ }
+ file.write_bytes(config)
+ }
+
+ @POST
+ @Path("files/{name}")
+ @Produces(Array("application/json", "application/xml","text/xml", "text/html"))
+ def edit_post(@PathParam("name") name:String, @FormParam("config") config:String):Unit = {
+ put(name, config.getBytes("UTF-8"))
+ result(strip_resolve("."))
+ }
+
+
+
}
Modified: activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/dto/BrokerStatusDTO.jade
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/dto/BrokerStatusDTO.jade?rev=1134915&r1=1134914&r2=1134915&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/dto/BrokerStatusDTO.jade (original)
+++ activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/dto/BrokerStatusDTO.jade Sun Jun 12 11:38:17 2011
@@ -21,11 +21,12 @@ h1 Apache ActiveMQ Apollo #{version}
p state: #{state} #{ uptime(state_since) } ago
-
- if( state == "STARTED" )
form(method="post" action={path("action/shutdown")})
input(type="submit" value="shutdown")
+a(href={path("config/files")}) Edit Configuration
+
h2 Virtual Hosts
ul
- for( x <- virtual_hosts )
Modified: activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/web/resources/EditConfig.jade
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/web/resources/EditConfig.jade?rev=1134915&r1=1134914&r2=1134915&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/web/resources/EditConfig.jade (original)
+++ activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/web/resources/EditConfig.jade Sun Jun 12 11:38:17 2011
@@ -18,13 +18,15 @@
- import helper._
.breadcumbs
- a(href={strip_resolve("../..")}) Back
+ a(href={strip_resolve(".")}) Back
-form(method="post" action="config")
- div
- input(type="submit" value="Update")
+form(method="post" action={file+".html"})
+ - if( can_write )
+ div
+ input(type="submit" value="Update")
div
textarea(rows="40" cols="80" name="config")<
~~ config
- div
- input(type="submit" value="Update")
\ No newline at end of file
+ - if( can_write )
+ div
+ input(type="submit" value="Update")
\ No newline at end of file
Copied: activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/web/resources/ListConfigs.jade (from r1134769, activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/dto/BrokerDTO.jade)
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/web/resources/ListConfigs.jade?p2=activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/web/resources/ListConfigs.jade&p1=activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/dto/BrokerDTO.jade&r1=1134769&r2=1134915&rev=1134915&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/dto/BrokerDTO.jade (original)
+++ activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/web/resources/ListConfigs.jade Sun Jun 12 11:38:17 2011
@@ -4,9 +4,9 @@
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
--#
+-#
-# http://www.apache.org/licenses/LICENSE-2.0
--#
+-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,4 +20,7 @@
.breadcumbs
a(href={strip_resolve("..")}) Back
-a(href="config/edit") Edit
+ul
+ - for( file <- files )
+ li
+ a(href={"files/"+file+".html"}) = file
\ No newline at end of file
Modified: activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/web.xml?rev=1134915&r1=1134914&r2=1134915&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/web.xml (original)
+++ activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/web.xml Sun Jun 12 11:38:17 2011
@@ -88,25 +88,5 @@
<error-code>500</error-code>
<location>/WEB-INF/scalate/errors/500.scaml</location>
</error-page>
-
- <!-- In case you want to use container based security..
- <security-constraint>
- <web-resource-collection>
- <web-resource-name>everything</web-resource-name>
- <url-pattern>/*</url-pattern>
- </web-resource-collection>
- <auth-constraint>
- <role-name>admin</role-name>
- </auth-constraint>
- </security-constraint>
- <login-config>
- <auth-method>BASIC</auth-method>
- <realm-name>Apollo</realm-name>
- </login-config>
- <security-role>
- <description>Who can login</description>
- <role-name>admin</role-name>
- </security-role>
- -->
</web-app>