home *** CD-ROM | disk | FTP | other *** search
- <?xml version="1.0"?>
- <!--
- Copyright 1999-2004 The Apache Software Foundation
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-
- <xsp:page language="java"
- xmlns:xsp="http://apache.org/xsp"
- xmlns:xsp-request="http://apache.org/xsp/request/2.0">
-
- <xsp:structure>
- <xsp:include>org.apache.avalon.framework.context.ContextException</xsp:include>
- <xsp:include>org.apache.avalon.framework.component.ComponentException</xsp:include>
- <xsp:include>org.apache.cocoon.ProcessingException</xsp:include>
- <xsp:include>java.net.URL</xsp:include>
- <xsp:include>java.net.MalformedURLException</xsp:include>
- <xsp:include>org.apache.cocoon.components.language.markup.xsp.XSPUtil</xsp:include>
- <xsp:include>org.apache.avalon.framework.context.ContextException</xsp:include>
- <xsp:include>org.apache.cocoon.components.search.*</xsp:include>
- <xsp:include>org.apache.lucene.store.Directory</xsp:include>
- <xsp:include>org.apache.lucene.analysis.Analyzer</xsp:include>
- </xsp:structure>
-
- <xsp:logic>
- 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) throws ProcessingException {
- try {
-
- lcii = (LuceneCocoonIndexer)this.manager.lookup( LuceneCocoonIndexer.ROLE );
- Directory directory = LuceneCocoonHelper.getDirectory( new File( workDir, "index" ), create );
- lcii.setAnalyzer( analyzer );
- 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;
- }
- }
-
- </xsp:logic>
-
- <page>
- <xsp:logic>
- boolean create;
- String createParam = <xsp-request:get-parameter name="create" />;
- if (createParam == null) {
- create = false;
- } else {
- create = true;
- }
-
- String baseURL = <xsp-request:get-parameter name="baseURL" />;
- if (baseURL != null && baseURL.length() > 0) {
- createIndex(baseURL, create );
- }
- if (baseURL == null || baseURL.length() < 1) {
- baseURL =
- "http://" +
- <xsp-request:get-server-name/> +
- ":" + <xsp-request:get-server-port/> +
- <xsp-request:get-context-path/> + "/" + "docs/index.html";
- }
- </xsp:logic>
- <content>
- <h1>Create a Lucene search index</h1>
- <para>
- <font size="-1">
- <a href="welcome">Welcome</a>
- </font>
- </para>
- <para>
- This process might take some time (follow the tail of your logfiles
- to see the indexer in progress).
- <ul>
- <li>LuceneCocoonIndexer.ROLE <xsp:expr>LuceneCocoonIndexer.ROLE</xsp:expr>
- </li>
- <li>context-path <xsp-request:get-context-path/>
- </li>
- <li>baseURL <xsp:expr>baseURL</xsp:expr>
- </li>
- <li>create <xsp:expr>String.valueOf(createParam)</xsp:expr>,
- <xsp:expr>String.valueOf( create )</xsp:expr>
- </li>
- <li>get-uri <xsp-request:get-uri/>
- </li>
- <li>get-sitemap-uri <xsp-request:get-sitemap-uri/>
- </li>
- </ul>
-
- <form action="create">
- <table>
- <tr>
- <td>BaseURL</td>
- <td>
- <input type="text" name="baseURL" size="60">
- <xsp:attribute name="value"><xsp:expr>baseURL</xsp:expr></xsp:attribute>
- </input>
- </td>
- </tr>
- <tr>
- <td colspan="2">
- <input type="radio" name="create" value="true" checked="checked"/>
- Create/Overwrite the Index, or
- <input type="radio" name="create" value="false"/>
- Update the existing Index
- </td>
- </tr>
- <tr>
- <td colspan="2">
- <input type="submit" name="find" value="Create"/>
- </td>
- </tr>
- </table>
- </form>
-
- </para>
- </content>
- </page>
-
- </xsp:page>
-
-