cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jer...@apache.org
Subject cvs commit: cocoon-2.1/src/blocks/lucene/java/org/apache/cocoon/transformation LuceneIndexTransformer.java
Date Sat, 21 Feb 2004 12:25:44 GMT
jeremy      2004/02/21 04:25:44

  Modified:    src/blocks/lucene/java/org/apache/cocoon/transformation
                        LuceneIndexTransformer.java
  Log:
  added the ability to configure the transformer with an absolute filepath in the 'directory'
parameter, to facilitate keeping indexes in locations other than the Servlet Temp folder,
which is problematic in Jetty (as Jetty deletes this on restart)
  
  Revision  Changes    Path
  1.11      +14 -8     cocoon-2.1/src/blocks/lucene/java/org/apache/cocoon/transformation/LuceneIndexTransformer.java
  
  Index: LuceneIndexTransformer.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/lucene/java/org/apache/cocoon/transformation/LuceneIndexTransformer.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- LuceneIndexTransformer.java	6 Feb 2004 22:45:58 -0000	1.10
  +++ LuceneIndexTransformer.java	21 Feb 2004 12:25:44 -0000	1.11
  @@ -425,8 +425,12 @@
           }
       }
   
  -    private void openWriter() throws IOException {
  -        File indexDirectory = new File(workDir, queryConfiguration.indexDirectory);
  +    private void openWriter() throws IOException {		
  +    		File indexDirectory = new File(queryConfiguration.indexDirectory);
  +        if (!indexDirectory.isAbsolute()) {
  +            indexDirectory = new File(workDir, queryConfiguration.indexDirectory);
  +        }
  +
           // If the index directory doesn't exist, then always create it.
           boolean indexExists = IndexReader.indexExists(indexDirectory);
           if (!indexExists) {
  @@ -434,17 +438,19 @@
           }
           
           // Get the index directory, creating it if necessary
  -        Directory directory = LuceneCocoonHelper.getDirectory(indexDirectory,
  -                                                              createIndex);
  +        Directory directory = LuceneCocoonHelper.getDirectory(indexDirectory, createIndex);
           Analyzer analyzer = LuceneCocoonHelper.getAnalyzer(queryConfiguration.analyzerClassname);
           this.writer = new IndexWriter(directory, analyzer, createIndex);
           this.writer.mergeFactor = queryConfiguration.mergeFactor; 
       }    
       
       private IndexReader openReader() throws IOException {
  -        Directory directory = LuceneCocoonHelper.getDirectory(
  -                                            new File(workDir, queryConfiguration.indexDirectory),
  -                                            createIndex);
  +    		File indexDirectory = new File(queryConfiguration.indexDirectory);
  +        if (!indexDirectory.isAbsolute()) {
  +            indexDirectory = new File(workDir, queryConfiguration.indexDirectory);
  +        }
  +    
  +        Directory directory = LuceneCocoonHelper.getDirectory(indexDirectory, createIndex);
           IndexReader reader = IndexReader.open(directory);
           return reader;
       }    
  
  
  

Mime
View raw message