Update of /var/cvs/contributions/lucene/src/org/mmbase/module/lucene
In directory james.mmbase.org:/tmp/cvs-serv8459/src/org/mmbase/module/lucene

Modified Files:
        Lucene.java 
Log Message:
made directory of indices explicit in lucene.xml. Therefore easier to configure


See also: 
http://cvs.mmbase.org/viewcvs/contributions/lucene/src/org/mmbase/module/lucene


Index: Lucene.java
===================================================================
RCS file: 
/var/cvs/contributions/lucene/src/org/mmbase/module/lucene/Lucene.java,v
retrieving revision 1.114
retrieving revision 1.115
diff -u -b -r1.114 -r1.115
--- Lucene.java 28 Jul 2008 13:28:21 -0000      1.114
+++ Lucene.java 28 Jul 2008 13:43:44 -0000      1.115
@@ -48,7 +48,7 @@
  *
  * @author Pierre van Rooden
  * @author Michiel Meeuwissen
- * @version $Id: Lucene.java,v 1.114 2008/07/28 13:28:21 michiel Exp $
+ * @version $Id: Lucene.java,v 1.115 2008/07/28 13:43:44 michiel Exp $
  **/
 public class Lucene extends ReloadableModule implements NodeEventListener, 
RelationEventListener, IdEventListener, AssignmentEvents.Listener {
 
@@ -650,6 +650,40 @@
                     // Force init of MMBase
                     MMBase mmbase = MMBase.getMMBase();
 
+                    String databaseName = "";
+                    String binaryFileBasePath = "";
+                    //try to get the index path from the strorage configuration
+                   try {
+                        DatabaseStorageManagerFactory dsmf = 
(DatabaseStorageManagerFactory)mmbase.getStorageManagerFactory();
+                        String binaries = 
dsmf.getBinaryFileBasePath().toString();
+                        if (binaries != null) {  // this test is needed for 
compatibility betwen 1.8 and 1.9
+                            if (! binaries.endsWith(File.separator)) {
+                                binaries += File.separator;
+                            }
+                            binaryFileBasePath = binaries;
+                            databaseName = dsmf.getDatabaseName();
+                        }
+                    } catch(Exception e){}
+
+                    String path = getInitParameter("indexpath");
+                    if (path != null) {
+                        indexPath = path;
+                        indexPath.replace("$BINARYFILEBASEPATH", 
binaryFileBasePath);
+                        indexPath.replace("$DATABASE", databaseName);
+                        indexPath.replace("/", File.separator);
+                        log.service("found module parameter for lucene index 
path : " + indexPath);
+                    } else {
+                        indexPath = binaryFileBasePath + databaseName + 
File.separator + "lucene";
+                    }
+
+                    if(indexPath != null) {
+                        log.service("found storage configuration for lucene 
index path : " + indexPath);
+                    } else {
+                        // expand the default path (which is relative to the 
web-application)
+                        indexPath = 
MMBaseContext.getServletContext().getRealPath(indexPath);
+                        log.service("fall back to default for lucene index 
path : " + indexPath);
+                    }
+
 
                     if (initialWait) {
                        // initial wait time?
@@ -676,32 +710,6 @@
                     factory = ContentExtractor.getInstance();
 
 
-                    String path = getInitParameter("indexpath");
-                    if (path != null) {
-                        indexPath = path;
-                        log.service("found module parameter for lucene index 
path : " + indexPath);
-                    } else {
-                        //try to get the index path from the strorage 
configuration
-                        try {
-                            DatabaseStorageManagerFactory dsmf = 
(DatabaseStorageManagerFactory)mmbase.getStorageManagerFactory();
-                            indexPath = 
dsmf.getBinaryFileBasePath().toString();
-                            if (indexPath != null) {  // this test is needed 
for compatibility betwen 1.8 and 1.9
-                                if (! indexPath.endsWith(File.separator)) {
-                                    indexPath += File.separator;
-                                }
-                                indexPath = indexPath + dsmf.getDatabaseName() 
+ File.separator + "lucene";
-                            }
-                        } catch(Exception e){}
-                    }
-
-                    if(indexPath != null) {
-                        log.service("found storage configuration for lucene 
index path : " + indexPath);
-                    } else {
-                        // expand the default path (which is relative to the 
web-application)
-                        indexPath = 
MMBaseContext.getServletContext().getRealPath(indexPath);
-                        log.service("fall back to default for lucene index 
path : " + indexPath);
-                    }
-
 
                     String readOnlySetting = getInitParameter("readonly");
                     while (readOnlySetting != null && 
readOnlySetting.startsWith("system:")) {
_______________________________________________
Cvs mailing list
Cvs@lists.mmbase.org
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to