org.apache.avalon.framework.context.ContextException org.apache.avalon.framework.component.ComponentException org.apache.cocoon.ProcessingException java.net.URL java.net.MalformedURLException org.apache.cocoon.components.language.markup.xsp.XSPUtil org.apache.avalon.framework.context.ContextException org.apache.cocoon.components.search.* org.apache.lucene.store.Directory org.apache.lucene.analysis.Analyzer File workDir = null; /** Contextualize this class */ public void contextualize(Context context) throws ContextException { super.contextualize( context ); workDir = (File) context.get(Constants.CONTEXT_WORK_DIR); } LuceneCocoonIndexer lcii; Analyzer analyzer = LuceneCocoonHelper.getAnalyzer( "org.apache.lucene.analysis.standard.StandardAnalyzer" ); void createIndex(String baseURL, boolean create,String publication_id) throws ProcessingException { try { lcii = (LuceneCocoonIndexer)this.manager.lookup( LuceneCocoonIndexer.ROLE ); //Directory directory = LuceneCocoonHelper.getDirectory( new File( workDir, "index" ), create ); Directory directory = LuceneCocoonHelper.getDirectory( new File( workDir, "lucene-search-index-"+publication_id ), create ); lcii.setAnalyzer( analyzer ); // "http://localhost:8080/cocoon/documents/index.html" URL base_url = new URL( baseURL ); lcii.index( directory, create, base_url ); } catch (MalformedURLException mue) { throw new ProcessingException( "MalformedURLException in createIndex()!", mue ); } catch (IOException ioe) { // ignore ?? throw new ProcessingException( "IOException in createIndex()!", ioe ); } catch (ComponentException ce) { // ignore ?? throw new ProcessingException( "ComponentException in createIndex()!", ce ); } finally { if (lcii != null) { this.manager.release( lcii ); } lcii = null; } } boolean indexHasBeenCreated=false; boolean create; String createParam = ; if (createParam == null) { create = false; } else { create = true; } String baseURL = ; String publication_id = ; if (baseURL != null && baseURL.length() > 0 && publication_id != null && publication_id.length() > 0) { createIndex(baseURL, create, publication_id); indexHasBeenCreated=true; } if (baseURL == null || baseURL.length() < 1) { baseURL = "http://" + + ":" + + + "/" + "oscom/index.html"; } if(indexHasBeenCreated){

Index has been created for Publication publication_id

}

Create a Lucene search index

This process might take some time (follow the tail of your logfiles to see the indexer in progress).
  • LuceneCocoonIndexer.ROLE LuceneCocoonIndexer.ROLE
  • context-path
  • baseURL baseURL
  • create String.valueOf(createParam), String.valueOf( create )
  • get-uri
  • get-sitemap-uri
Publication ID OSCOM Lenya News unipublic
BaseURL baseURL
Create/Overwrite the Index, or Update the existing Index