activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r1043829 - 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/
Date Thu, 09 Dec 2010 03:13:03 GMT
Author: chirino
Date: Thu Dec  9 03:13:02 2010
New Revision: 1043829

URL: http://svn.apache.org/viewvc?rev=1043829&view=rev
Log:
Support working against read only config files.

Modified:
    activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/ConfigStore.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/scala/org/apache/activemq/apollo/web/resources/RootResource.scala

Modified: activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/ConfigStore.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/ConfigStore.scala?rev=1043829&r1=1043828&r2=1043829&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/ConfigStore.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/ConfigStore.scala
Thu Dec  9 03:13:02 2010
@@ -65,6 +65,8 @@ trait ConfigStore extends Service {
 
   def dispatchQueue:DispatchQueue
 
+  def can_write:Boolean
+
 }
 
 /**
@@ -110,6 +112,8 @@ class FileConfigStore extends ConfigStor
     })
   }
 
+  def can_write:Boolean = file.canWrite
+
   def startup(onCompleted:Runnable) = {
 
     file = file.getCanonicalFile;
@@ -135,7 +139,7 @@ class FileConfigStore extends ConfigStor
         write(r)
       } else {
         val x = read(rev, file)
-        if ( !Arrays.equals(r.data, x.data) ) {
+        if ( can_write && !Arrays.equals(r.data, x.data) ) {
           write(StoredBrokerModel(x.id, x.rev+1, x.data, x.lastModified))
         } else {
           x
@@ -143,7 +147,7 @@ class FileConfigStore extends ConfigStor
       }
     } getOrElse {
       if( file.exists ) {
-        write(read(1, file))
+        read(1, file)
       } else {
         write(StoredBrokerModel(defaultConfig(1)))
       }

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=1043829&r1=1043828&r2=1043829&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
Thu Dec  9 03:13:02 2010
@@ -34,7 +34,11 @@ case class ConfigurationResource(parent:
 
   lazy val config = {
     ConfigStore.sync{ store=>
-      store.getBroker(parent.id, false)
+      if( store.can_write ) {
+        store.getBroker(parent.id, false)
+      } else {
+        None
+      }
     } .getOrElse(result(NOT_FOUND))
   }
 
@@ -64,14 +68,22 @@ case class ConfigurationResource(parent:
     config.id = parent.id;
     config.rev = rev
     ConfigStore.sync { store=>
-      store.putBroker(config)
+      if( store.can_write ) {
+        store.putBroker(config)
+      } else {
+        false
+      }
     } || result(NOT_FOUND)
   }
 
   @DELETE @Path("{rev}")
   def delete(@PathParam("rev") rev:Int) = {
     ConfigStore.sync { store=>
-      store.removeBroker(parent.id, rev)
+      if( store.can_write ) {
+        store.removeBroker(parent.id, rev)
+      } else {
+        false
+      }
     } || result(NOT_FOUND)
   }
 

Modified: activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/RootResource.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/RootResource.scala?rev=1043829&r1=1043828&r2=1043829&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/RootResource.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/RootResource.scala
Thu Dec  9 03:13:02 2010
@@ -197,7 +197,7 @@ case class BrokerResource(parent:Resourc
     rc.id = id
     rc.manageable = BrokerRegistry.get(id)!=null
     rc.configurable = cs.dispatchQueue.sync{
-      cs.getBroker(id,false).isDefined
+      cs.can_write && cs.getBroker(id,false).isDefined
     }
     rc
   }



Mime
View raw message