[gatewiki-commits] SF.net SVN: gatewiki:[1808] trunk/cow

View: New views
1 Messages — Rating Filter:   Alert me  

[gatewiki-commits] SF.net SVN: gatewiki:[1808] trunk/cow

by ian_roberts :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Revision: 1808
          http://gatewiki.svn.sourceforge.net/gatewiki/?rev=1808&view=rev
Author:   ian_roberts
Date:     2009-11-12 13:38:21 +0000 (Thu, 12 Nov 2009)

Log Message:
-----------
Include the environment in the name of the serialized dependency files
(Dependencies-development_1.ser, Dependencies-production_2.ser, etc.).

Modified Paths:
--------------
    trunk/cow/grails-app/conf/BootStrap.groovy
    trunk/cow/grails-app/services/DependenciesService.groovy
    trunk/cow/src/java/gate/yam/depend/Dependencies.java

Modified: trunk/cow/grails-app/conf/BootStrap.groovy
===================================================================
--- trunk/cow/grails-app/conf/BootStrap.groovy 2009-11-11 15:30:49 UTC (rev 1807)
+++ trunk/cow/grails-app/conf/BootStrap.groovy 2009-11-12 13:38:21 UTC (rev 1808)
@@ -14,6 +14,7 @@
 import gate.cow.CowUtils
 import gate.versioning.svnkit.SandboxManager
 import gate.versioning.svnkit.Sandbox
+import grails.util.Environment
 import org.jsecurity.cache.ehcache.EhCacheManager
 import org.tmatesoft.svn.core.SVNException
 import org.tmatesoft.svn.core.wc.SVNRevision
@@ -79,6 +80,9 @@
     dependenciesService.setSerializationDirectory(
       new File(conf.gate.cow.dbs)
     )
+    dependenciesService.setSerializationFilePrefix(
+      'Dependencies-' + Environment.current.name + '_'
+    )
 
     // create default auth data if it doesn't exist
     if(!AuthenticationData.list()) {

Modified: trunk/cow/grails-app/services/DependenciesService.groovy
===================================================================
--- trunk/cow/grails-app/services/DependenciesService.groovy 2009-11-11 15:30:49 UTC (rev 1807)
+++ trunk/cow/grails-app/services/DependenciesService.groovy 2009-11-12 13:38:21 UTC (rev 1808)
@@ -27,6 +27,11 @@
     Dependencies.setSerializationDirectory(f)
   }
 
+  /** Set the prefix to use for the serialized dependencies files */
+  void setSerializationFilePrefix(String prefix) {
+    Dependencies.setSerializationFilePrefix(prefix)
+  }
+
   /** Serialize the given wiki */
   void serialize(Wiki wiki) {
     Dependencies.serialize(wiki.id.toString())

Modified: trunk/cow/src/java/gate/yam/depend/Dependencies.java
===================================================================
--- trunk/cow/src/java/gate/yam/depend/Dependencies.java 2009-11-11 15:30:49 UTC (rev 1807)
+++ trunk/cow/src/java/gate/yam/depend/Dependencies.java 2009-11-12 13:38:21 UTC (rev 1808)
@@ -58,10 +58,17 @@
     wikiDependencies.clear();
   }
 
-  private static final String SERIALIZATION_FILE_PREFIX = "Dependencies_";
-  private static final String SERIALIZATION_FILE_SUFFIX = ".ser";
+  /**
+   * The prefix used for serialized dependency files.
+   */
+  private static String serializationFilePrefix = "Dependencies_";
 
   /**
+   * The suffix used for serialized dependency files.
+   */
+  private static String serializationFileSuffix = ".ser";
+
+  /**
    * The directory to which Dependencies are serialized
    */
   private static File serializationDirectory;
@@ -80,6 +87,34 @@
   }
 
   /**
+   * Set the prefix for serialized dependency file names. This is not
+   * synchonised. It is expected that it will be set once by the wiki on start
+   * up, and that neither users nor administrators will change it while the
+   * wiki is running.
+   *
+   * @param prefix The prefix for serialized dependency files. The dependency
+   * file name is made up of this prefix, the wiki ID, and the configured
+   * suffix.
+   */
+  public static void setSerializationFilePrefix(String prefix) {
+    serializationFilePrefix = prefix;
+  }
+
+  /**
+   * Set the suffix for serialized dependency file names. This is not
+   * synchonised. It is expected that it will be set once by the wiki on start
+   * up, and that neither users nor administrators will change it while the
+   * wiki is running.
+   *
+   * @param suffix The suffix for serialized dependency files. The dependency
+   * file name is made up of the configured prefix, the wiki ID, and this
+   * suffix.
+   */
+  public static void setSerializationFileSuffix(String suffix) {
+    serializationFileSuffix = suffix;
+  }
+
+  /**
    * Get the Dependencies instance for a wiki area. Lazily loads if
    * serialized. Creates a new Dependencies if none exists for a wiki area.
    *
@@ -104,7 +139,7 @@
 
     // Maybe we have serialized the Dependencies?
     String serializationFileName =
-      SERIALIZATION_FILE_PREFIX + wikiID + SERIALIZATION_FILE_SUFFIX;
+      serializationFilePrefix + wikiID + serializationFileSuffix;
     File serializationFile =
       new File(serializationDirectory, serializationFileName);
 
@@ -160,7 +195,7 @@
     } else {
       // Does it exist in serialized form?
       String serializationFileName =
-        SERIALIZATION_FILE_PREFIX + wikiID + SERIALIZATION_FILE_SUFFIX;
+        serializationFilePrefix + wikiID + serializationFileSuffix;
       File serializationFile =
         new File(serializationDirectory, serializationFileName);
 
@@ -185,7 +220,7 @@
 
     // Now remove any serialization
     String serializationFileName =
-      SERIALIZATION_FILE_PREFIX + wikiID + SERIALIZATION_FILE_SUFFIX;
+      serializationFilePrefix + wikiID + serializationFileSuffix;
     File serializationFile =
       new File(serializationDirectory, serializationFileName);
     if (serializationFile.exists()) {
@@ -232,7 +267,7 @@
       Dependencies dep = get(wikiID);
 
       String serializationFileName =
-              SERIALIZATION_FILE_PREFIX + wikiID + SERIALIZATION_FILE_SUFFIX;
+              serializationFilePrefix + wikiID + serializationFileSuffix;
       File serializationFile =
               new File(serializationDirectory, serializationFileName);
       FileOutputStream fos = new FileOutputStream(serializationFile);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
gatewiki-commits mailing list
gatewiki-commits@...
https://lists.sourceforge.net/lists/listinfo/gatewiki-commits