jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dpfis...@apache.org
Subject svn commit: r695880 - /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java
Date Tue, 16 Sep 2008 13:41:29 GMT
Author: dpfister
Date: Tue Sep 16 06:41:28 2008
New Revision: 695880

URL: http://svn.apache.org/viewvc?rev=695880&view=rev
Log:
JCR-1734 - Generated cluster node id should be persisted
- use commons-io

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java?rev=695880&r1=695879&r2=695880&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ClusterNode.java
Tue Sep 16 06:41:28 2008
@@ -18,6 +18,7 @@
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.apache.commons.io.FileUtils;
 import org.apache.jackrabbit.core.config.ClusterConfig;
 import org.apache.jackrabbit.core.config.ConfigurationException;
 import org.apache.jackrabbit.core.config.JournalConfig;
@@ -378,50 +379,15 @@
         File f = new File(filename);
 
         if (f.exists() && f.canRead()) {
-            BufferedReader reader = null;
-
-            try {
-                reader = new BufferedReader(new FileReader(f));
-                return reader.readLine();
-            } finally {
-                if (reader != null) {
-                    reader.close();
-                }
-            }
+            return FileUtils.readFileToString(f);
         }
 
-        FileWriter writer = null;
         String id = UUID.randomUUID().toString();
-
-        try {
-            writer = new FileWriter(f);
-            writer.write(id);
-        } finally {
-            if (writer != null) {
-                writer.close();
-            }
-        }
+        FileUtils.writeStringToFile(f, id);
         return id;
 
     }
 
-    /**
-     * Return a zero-padded short string representation.
-     *
-     * @param n short
-     * @return string representation
-     */
-    private static String toHexString(short n) {
-        String s = Integer.toHexString(n);
-        int padlen = SHORT_PADDING.length() - s.length();
-        if (padlen < 0) {
-            s = s.substring(-padlen);
-        } else if (padlen > 0) {
-            s = SHORT_PADDING.substring(0, padlen) + s;
-        }
-        return s;
-    }
-
     //-----------------------------------------------< NamespaceEventListener >
 
     /**



Mime
View raw message