You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by jo...@apache.org on 2006/02/07 15:35:23 UTC
svn commit: r375610 - in /lenya/trunk/src:
modules/lucene/java/src/org/apache/cocoon/components/search/components/impl/IndexManagerImpl.java
pubs/default/config/cocoon-xconf/index_manager_index.xconf
Author: josias
Date: Tue Feb 7 06:35:21 2006
New Revision: 375610
URL: http://svn.apache.org/viewcvs?rev=375610&view=rev
Log:
allow relativ paths for the search index to make it possible to move a publication around.
Modified:
lenya/trunk/src/modules/lucene/java/src/org/apache/cocoon/components/search/components/impl/IndexManagerImpl.java
lenya/trunk/src/pubs/default/config/cocoon-xconf/index_manager_index.xconf
Modified: lenya/trunk/src/modules/lucene/java/src/org/apache/cocoon/components/search/components/impl/IndexManagerImpl.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/modules/lucene/java/src/org/apache/cocoon/components/search/components/impl/IndexManagerImpl.java?rev=375610&r1=375609&r2=375610&view=diff
==============================================================================
--- lenya/trunk/src/modules/lucene/java/src/org/apache/cocoon/components/search/components/impl/IndexManagerImpl.java (original)
+++ lenya/trunk/src/modules/lucene/java/src/org/apache/cocoon/components/search/components/impl/IndexManagerImpl.java Tue Feb 7 06:35:21 2006
@@ -15,6 +15,7 @@
*/
package org.apache.cocoon.components.search.components.impl;
+import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.HashMap;
@@ -37,6 +38,8 @@
import org.apache.cocoon.components.search.fieldmodel.FieldDefinition;
import org.apache.cocoon.components.search.utils.SourceHelper;
import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceResolver;
+import org.apache.excalibur.source.SourceUtil;
//import org.apache.excalibur.source.SourceResolver;
@@ -320,6 +323,11 @@
index.setID(id);
index.setIndexer(indexerRole);
+ // if the directory path is relative, prepend context path:
+ if (!directory.startsWith(File.separator)) {
+ directory = getServletContextPath() + File.separator + directory;
+ }
+
if (index.setDirectory(directory)) {
this.getLogger().warn(
"directory " + directory + " was locked ");
@@ -329,14 +337,31 @@
index.setManager(manager);
this.addIndex(index);
- this.getLogger().info("add index " + index.getID());
- } catch (IOException ex) {
+ this.getLogger().info("add index " + index.getID() + " for directory " + directory);
+ } catch (Exception ex) {
throw new ConfigurationException(ex.getMessage(), ex);
}
this.manager.release(analyzerM);
}
}
+ public String getServletContextPath() throws Exception {
+ SourceResolver resolver = null;
+ Source source = null;
+ try {
+ resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
+ source = resolver.resolveURI("context:///");
+ return SourceUtil.getFile(source).getCanonicalPath();
+ } finally {
+ if (resolver != null) {
+ if (source != null) {
+ resolver.release(source);
+ }
+ this.manager.release(resolver);
+ }
+ }
+ }
+
/* (non-Javadoc)
* @see org.apache.cocoon.components.search.components.IndexManager#getIndex()
*/
Modified: lenya/trunk/src/pubs/default/config/cocoon-xconf/index_manager_index.xconf
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/pubs/default/config/cocoon-xconf/index_manager_index.xconf?rev=375610&r1=375609&r2=375610&view=diff
==============================================================================
--- lenya/trunk/src/pubs/default/config/cocoon-xconf/index_manager_index.xconf (original)
+++ lenya/trunk/src/pubs/default/config/cocoon-xconf/index_manager_index.xconf Tue Feb 7 06:35:21 2006
@@ -17,7 +17,7 @@
<xconf xpath="/cocoon/index_manager/indexes" unless="/cocoon/index_manager/indexes/index[@id = 'default-live' or @id = 'default-authoring']">
- <index id="default-live" analyzer="stopword_en" directory="${basedir}/${build.webapp}/lenya/pubs/default/work/lucene/index/live/index" >
+ <index id="default-live" analyzer="stopword_en" directory="lenya/pubs/default/work/lucene/index/live/index" >
<structure>
<field id="url" type="keyword" />
<field id="title" type="text" storetext="true"/>
@@ -27,7 +27,7 @@
</structure>
</index>
- <index id="default-authoring" analyzer="stopword_en" directory="${basedir}/${build.webapp}/lenya/pubs/default/work/lucene/index/authoring/index" >
+ <index id="default-authoring" analyzer="stopword_en" directory="lenya/pubs/default/work/lucene/index/authoring/index" >
<structure>
<field id="url" type="keyword" />
<field id="title" type="text" storetext="true"/>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org