1 2 3 package org.apache.lenya.cms.task; 4 5 import org.apache.log4j.Category; 6 7 import java.io.File ; 8 9 import org.apache.lenya.lucene.index.Index; 10 import org.apache.lenya.lucene.index.Indexer; 11 12 public class LuceneTask extends AbstractTask { 13 Category log = Category.getInstance(LuceneTask.class); 14 15 18 public void execute(String servletContextPath) throws ExecutionException { 19 try { 20 22 log.debug("Servlet context path: " + servletContextPath); 23 24 String publicationId = getParameters().getParameter("publication-id"); 25 log.debug("Publication ID: " + publicationId); 26 27 String files = getParameters().getParameter("properties.files2index"); 28 log.debug("Files 2 index: " + files); 29 30 String luceneConfig = getParameters().getParameter("config"); 31 log.debug("Lucene configuration: " + luceneConfig); 32 33 String luceneConfigAbsolutePath = servletContextPath + File.separator + "lenya" + File.separator + "pubs" + File.separator + publicationId + File.separator + luceneConfig; 34 log.debug("Lucene configuration: " + luceneConfigAbsolutePath); 35 36 Indexer indexer = Index.getIndexer(luceneConfigAbsolutePath); 37 indexer.indexDocument(new File (files)); 38 } catch (Exception e) { 39 log.error("" + e); 40 } 41 } 42 43 46 public void outputParameters() throws Exception { 47 String [] names = getParameters().getNames(); 48 for (int i = 0; i < names.length; i++) { 49 log.error("Name: " + names[i]); 50 log.error("Value: " + getParameters().getParameter(names[i])); 51 } 52 } 53 } 54 | Popular Tags |