jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r527813 - /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/xml/XMLPersistenceManager.java
Date Thu, 12 Apr 2007 07:25:38 GMT
Author: jukka
Date: Thu Apr 12 00:25:37 2007
New Revision: 527813

URL: http://svn.apache.org/viewvc?view=rev&rev=527813
Log:
JCR-692: Added an option to customize the path names used by the XML persistence manager.

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/xml/XMLPersistenceManager.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/xml/XMLPersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/xml/XMLPersistenceManager.java?view=diff&rev=527813&r1=527812&r2=527813
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/xml/XMLPersistenceManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/xml/XMLPersistenceManager.java
Thu Apr 12 00:25:37 2007
@@ -122,26 +122,58 @@
     private BLOBStore blobStore;
 
     /**
+     * Template for the subdirectory path for the files associated with
+     * a single node. The template is processed by replacing each
+     * "<code>x</code>" with the next hex digit in the UUID string.
+     * All other characters in the template are used as-is.
+     */
+    private String nodePathTemplate = "xxxx/xxxx/xxxxxxxxxxxxxxxxxxxxxxxx";
+
+    /**
      * Creates a new <code>XMLPersistenceManager</code> instance.
      */
     public XMLPersistenceManager() {
         initialized = false;
     }
 
+    /**
+     * Returns the node path template.
+     *
+     * @return node path template
+     */
+    public String getNodePathTemplate() {
+        return nodePathTemplate;
+    }
+
+    /**
+     * Sets the node path template.
+     *
+     * @param template node path template
+     */
+    public void setNodePathTemplate(String template) {
+        nodePathTemplate = template;
+    }
+
+    /**
+     * Builds the path of the node folder for the given node identifier
+     * based on the configured node path template.
+     *
+     * @param id node identifier
+     * @return node folder path
+     */
     private String buildNodeFolderPath(NodeId id) {
         StringBuffer sb = new StringBuffer();
         char[] chars = id.getUUID().toString().toCharArray();
         int cnt = 0;
-        for (int i = 0; i < chars.length; i++) {
-            if (chars[i] == '-') {
-                continue;
-            }
-            //if (cnt > 0 && cnt % 4 == 0) {
-            if (cnt == 4 || cnt == 8) {
-                sb.append('/');
+        for (int i = 0; i < nodePathTemplate.length(); i++) {
+            char ch = nodePathTemplate.charAt(i);
+            if (ch == 'x' && cnt < chars.length) {
+                ch = chars[cnt++];
+                if (ch == '-') {
+                    ch = chars[cnt++];
+                }
             }
-            sb.append(chars[i]);
-            cnt++;
+            sb.append(ch);
         }
         return sb.toString();
     }



Mime
View raw message