From commits-return-9824-apmail-jackrabbit-commits-archive=jackrabbit.apache.org@jackrabbit.apache.org Fri Apr 09 10:48:16 2010 Return-Path: Delivered-To: apmail-jackrabbit-commits-archive@www.apache.org Received: (qmail 9208 invoked from network); 9 Apr 2010 10:48:16 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 9 Apr 2010 10:48:16 -0000 Received: (qmail 97470 invoked by uid 500); 9 Apr 2010 10:48:16 -0000 Delivered-To: apmail-jackrabbit-commits-archive@jackrabbit.apache.org Received: (qmail 97299 invoked by uid 500); 9 Apr 2010 10:48:13 -0000 Mailing-List: contact commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list commits@jackrabbit.apache.org Received: (qmail 97287 invoked by uid 99); 9 Apr 2010 10:48:12 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 09 Apr 2010 10:48:12 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 09 Apr 2010 10:48:10 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 0F34423888E4; Fri, 9 Apr 2010 10:47:49 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r932348 - in /jackrabbit/branches/2.1: ./ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/SearchIndex.java Date: Fri, 09 Apr 2010 10:47:48 -0000 To: commits@jackrabbit.apache.org From: jukka@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100409104749.0F34423888E4@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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; }