You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by ju...@apache.org on 2010/04/09 12:47:48 UTC
svn commit: r932348 - in /jackrabbit/branches/2.1: ./
jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java
Author: jukka
Date: Fri Apr 9 10:47:48 2010
New Revision: 932348
URL: http://svn.apache.org/viewvc?rev=932348&view=rev
Log:
2.1: Merged revision 932319 (JCR-2504)
Modified:
jackrabbit/branches/2.1/ (props changed)
jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java
Propchange: jackrabbit/branches/2.1/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Apr 9 10:47:48 2010
@@ -2,4 +2,4 @@
/jackrabbit/sandbox/JCR-1456:774917-886178
/jackrabbit/sandbox/JCR-2170:812417-816332
/jackrabbit/sandbox/tripod-JCR-2209:795441-795863
-/jackrabbit/trunk:931479,931483-931484,931838,931919
+/jackrabbit/trunk:931121,931479,931483-931484,931504,931609,931613,931838,931919,932318-932319
Modified: jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java?rev=932348&r1=932347&r2=932348&view=diff
==============================================================================
--- jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java (original)
+++ jackrabbit/branches/2.1/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java Fri Apr 9 10:47:48 2010
@@ -16,6 +16,8 @@
*/
package org.apache.jackrabbit.core.query.lucene;
+import java.io.InputStream;
+
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
@@ -355,7 +357,8 @@ public class SearchIndex extends Abstrac
private Class<?> excerptProviderClass = DefaultHTMLExcerpt.class;
/**
- * The path to the indexing configuration file.
+ * The path to the indexing configuration file (can be an absolute path to a
+ * file or a classpath resource).
*/
private String indexingConfigPath;
@@ -1291,9 +1294,17 @@ public class SearchIndex extends Abstrac
return null;
}
File config = new File(indexingConfigPath);
+ InputStream configStream = null;
+
if (!config.exists()) {
- log.warn("File does not exist: " + indexingConfigPath);
- return null;
+ // check if it's a classpath resource
+ configStream = getClass().getResourceAsStream(indexingConfigPath);
+
+ if (configStream == null) {
+ // only warn if not available also in the classpath
+ log.warn("File does not exist: " + indexingConfigPath);
+ return null;
+ }
} else if (!config.canRead()) {
log.warn("Cannot read file: " + indexingConfigPath);
return null;
@@ -1303,13 +1314,28 @@ public class SearchIndex extends Abstrac
DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
builder.setEntityResolver(new IndexingConfigurationEntityResolver());
- indexingConfiguration = builder.parse(config).getDocumentElement();
+
+ if (configStream != null) {
+ indexingConfiguration = builder
+ .parse(configStream).getDocumentElement();
+ } else {
+ indexingConfiguration = builder
+ .parse(config).getDocumentElement();
+ }
} catch (ParserConfigurationException e) {
log.warn("Unable to create XML parser", e);
} catch (IOException e) {
log.warn("Exception parsing " + indexingConfigPath, e);
} catch (SAXException e) {
log.warn("Exception parsing " + indexingConfigPath, e);
+ } finally {
+ if (configStream != null) {
+ try {
+ configStream.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
}
return indexingConfiguration;
}