cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r155049 - in cocoon/branches/BRANCH_2_1_X: ./ src/blocks/lucene/java/org/apache/cocoon/samples/ src/blocks/lucene/samples/
Date Wed, 23 Feb 2005 19:02:36 GMT
Author: cziegeler
Date: Wed Feb 23 11:02:34 2005
New Revision: 155049

URL: http://svn.apache.org/viewcvs?view=rev&rev=155049
Log:
Rewrite lucene xsp samples

Added:
    cocoon/branches/BRANCH_2_1_X/src/blocks/lucene/java/org/apache/cocoon/samples/
    cocoon/branches/BRANCH_2_1_X/src/blocks/lucene/java/org/apache/cocoon/samples/LuceneUtil.java
  (with props)
    cocoon/branches/BRANCH_2_1_X/src/blocks/lucene/samples/create-index.jx   (with props)
    cocoon/branches/BRANCH_2_1_X/src/blocks/lucene/samples/flow.js   (with props)
    cocoon/branches/BRANCH_2_1_X/src/blocks/lucene/samples/welcome-index.xml   (with props)
Removed:
    cocoon/branches/BRANCH_2_1_X/src/blocks/lucene/samples/create-index.xsp
    cocoon/branches/BRANCH_2_1_X/src/blocks/lucene/samples/document-files.xsp
    cocoon/branches/BRANCH_2_1_X/src/blocks/lucene/samples/search-index.xsp
    cocoon/branches/BRANCH_2_1_X/src/blocks/lucene/samples/statistic-index.xsp
    cocoon/branches/BRANCH_2_1_X/src/blocks/lucene/samples/welcome-index.xsp
Modified:
    cocoon/branches/BRANCH_2_1_X/blocks.properties
    cocoon/branches/BRANCH_2_1_X/gump.xml
    cocoon/branches/BRANCH_2_1_X/src/blocks/lucene/samples/sitemap.xmap

Modified: cocoon/branches/BRANCH_2_1_X/blocks.properties
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/blocks.properties?view=diff&r1=155048&r2=155049
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/blocks.properties (original)
+++ cocoon/branches/BRANCH_2_1_X/blocks.properties Wed Feb 23 11:02:34 2005
@@ -66,7 +66,6 @@
 #include.block.jsp=false
 #-----[dependency]: "linkrewriter" depends on "xsp".
 #include.block.linkrewriter=false
-#-----[dependency]: "lucene" depends on "forms" (for samples), "xsp" (for samples).
 #include.block.lucene=false
 #include.block.naming=false
 #include.block.paranoid=false
@@ -85,7 +84,7 @@
 #include.block.web3=false
 #-----[dependency]: "xmldb" depends on "databases".
 #include.block.xmldb=false
-#-----[dependency]: "xsp" is needed by "databases", "forms", "linkrewriter", "lucene", "python",
"scratchpad", "session-fw", "woody".
+#-----[dependency]: "xsp" is needed by "databases", "forms", "linkrewriter", "python", "scratchpad",
"session-fw", "woody".
 #include.block.xsp=false
 
 # Unstable blocks --------------------------------------------------------------
@@ -113,7 +112,7 @@
 #-----[dependency]: "faces" depends on "portal", "taglib".
 #include.block.faces=false
 #-----[dependency]: "forms" depends on "xsp" (for samples).
-#-----[dependency]: "forms" is needed by "apples", "javaflow", "lucene", "ojb", "petstore",
"portal", "tour".
+#-----[dependency]: "forms" is needed by "apples", "javaflow", "ojb", "petstore", "portal",
"tour".
 #include.block.forms=false
 #-----[dependency]: "javaflow" depends on "forms", "ojb".
 #include.block.javaflow=false

Modified: cocoon/branches/BRANCH_2_1_X/gump.xml
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/gump.xml?view=diff&r1=155048&r2=155049
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/gump.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/gump.xml Wed Feb 23 11:02:34 2005
@@ -502,8 +502,6 @@
 
     <depend project="cocoon" inherit="all"/>
     <depend project="jakarta-lucene"/>
-    <depend project="cocoon-block-xsp" type="samples"/>
-    <depend project="cocoon-block-forms" type="samples"/>
 
     <library name="lucene"/>
 

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/lucene/java/org/apache/cocoon/samples/LuceneUtil.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/lucene/java/org/apache/cocoon/samples/LuceneUtil.java?view=auto&rev=155049
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/lucene/java/org/apache/cocoon/samples/LuceneUtil.java
(added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/lucene/java/org/apache/cocoon/samples/LuceneUtil.java
Wed Feb 23 11:02:34 2005
@@ -0,0 +1,86 @@
+/*
+ * Copyright 1999-2005 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.
+ */
+package org.apache.cocoon.samples;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.framework.context.Contextualizable;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.cocoon.Constants;
+import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.components.search.LuceneCocoonHelper;
+import org.apache.cocoon.components.search.LuceneCocoonIndexer;
+import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.store.Directory;
+
+/**
+ * This is a sample helper class that can be used from flow to 
+ * create an index.
+ * @version $Id$
+ */
+public class LuceneUtil 
+    implements Contextualizable, Serviceable {
+
+    private File workDir;
+    private ServiceManager manager;
+
+    /* (non-Javadoc)
+     * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
+     */
+    public void contextualize(Context context) throws ContextException {
+        this.workDir = (File) context.get(Constants.CONTEXT_WORK_DIR);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
+     */
+    public void service(ServiceManager manager) throws ServiceException {
+        this.manager = manager;
+    }
+
+    public void createIndex(String baseURL, boolean create)
+    throws ProcessingException {
+        LuceneCocoonIndexer lcii = null;
+        Analyzer analyzer = LuceneCocoonHelper.getAnalyzer( "org.apache.lucene.analysis.standard.StandardAnalyzer"
);
+        
+        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 (ServiceException ce) {
+            // ignore ??
+            throw new ProcessingException( "ServiceException in createIndex()!", ce );
+        } finally {
+            this.manager.release( lcii );
+        }
+    }
+    
+}

Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/lucene/java/org/apache/cocoon/samples/LuceneUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/lucene/java/org/apache/cocoon/samples/LuceneUtil.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/lucene/samples/create-index.jx
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/lucene/samples/create-index.jx?view=auto&rev=155049
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/lucene/samples/create-index.jx (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/lucene/samples/create-index.jx Wed Feb 23 11:02:34
2005
@@ -0,0 +1,70 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2005 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.
+-->
+<!-- @version $Id$ -->
+<page>
+    <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 org.apache.cocoon.components.search.LuceneCocoonIndexer
+          </li>
+          <li>context-path ${cocoon.request.getContextPath()}
+          </li>
+          <li>baseURL ${url}
+          </li>
+          <li>create ${cocoon.request.getParameter("create")}, ${create}
+          </li>
+          <li>get-uri ${cocoon.request.getRequestURI()}
+          </li>
+          <li>get-sitemap-uri ${cocoon.request.getSitemapURI()}
+          </li>
+        </ul>
+
+        <form action="create">
+        <table>
+          <tr>
+            <td>BaseURL</td>
+            <td>
+              <input type="text" name="baseURL" size="60" value="${url}"/>
+            </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>

Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/lucene/samples/create-index.jx
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/lucene/samples/create-index.jx
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/lucene/samples/flow.js
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/lucene/samples/flow.js?view=auto&rev=155049
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/lucene/samples/flow.js (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/lucene/samples/flow.js Wed Feb 23 11:02:34 2005
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+//
+// @version $Id$
+//
+function create() {
+    var create;
+    var createParam = cocoon.request.getParameter("create");
+    if (createParam == null) {
+        create = false;
+    } else {
+        create = true;
+    }
+      
+    var baseURL = cocoon.request.getParameter("baseURL");
+    if (baseURL != null && baseURL.length() > 0) {
+        var util = cocoon.createObject("org.apache.cocoon.samples.LuceneUtil");
+        util.createIndex(baseURL, create );
+    }
+    if (baseURL == null || baseURL.length() < 1) {
+        baseURL = "http://" + cocoon.request.getServerName()
+                            + ":" + cocoon.request.getServerPort()
+                            + cocoon.request.getContextPath()
+                            + "/docs/index.html";
+    }
+    cocoon.sendPage("create-index.jx", {"url" : baseURL, "create" : create});
+}

Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/lucene/samples/flow.js
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/lucene/samples/flow.js
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/lucene/samples/sitemap.xmap
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/lucene/samples/sitemap.xmap?view=diff&r1=155048&r2=155049
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/lucene/samples/sitemap.xmap (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/lucene/samples/sitemap.xmap Wed Feb 23 11:02:34
2005
@@ -55,16 +55,21 @@
 </map:views>
 
 
+  <map:flow language="javascript">
+    <map:script src="flow.js"/>
+  </map:flow>
+
 <!-- =========================== Pipelines ================================= -->
 
 <map:pipelines>
   
   <map:pipeline>
   	
-		<!-- mount query bean pipelines -->
-		<map:match pattern="query/**">
-			<map:mount check-reload="yes" src="query/sitemap.xmap" uri-prefix="query"/>
-		</map:match>
+    <!-- mount query bean pipelines
+      <map:match pattern="query/**">
+        <map:mount check-reload="yes" src="query/sitemap.xmap" uri-prefix="query"/>
+      </map:match> 
+    -->
 
     <map:match pattern="images/*.gif">
       <map:read src="images/{1}.gif" mime-type="image/gif">
@@ -88,37 +93,20 @@
       <map:serialize/>
     </map:match>
 
-    <map:match pattern="document-files.xsp">
-      <map:generate type="serverpages" src="document-files.xsp">
-      </map:generate>
-
-      <map:transform src="stylesheets/all-files2content.xsl"/>
-      <map:transform type="cinclude"/>
-      <map:transform src="stylesheets/content2lucene.xsl"/>
-      <map:transform type="index"/>
-
-      <map:transform src="stylesheets/lucene-index2html.xsl"/>
-
+    <map:match pattern="welcome">
+      <map:generate src="welcome-index.xml"/>
+      <map:transform src="context://samples/stylesheets/dynamic-page2html.xsl">
+        <map:parameter name="contextPath" value="{request:contextPath}"/>
+      </map:transform>
       <map:serialize/>
     </map:match>
 
-    <map:match pattern="*.xsp">
-      <map:generate type="serverpages" src="{1}.xsp">
-        <map:parameter name="p1" value="context://docs/xdocs"/>
-      </map:generate>
-
-      <map:serialize type="xml"/>
+    <map:match pattern="create">
+      <map:call function="create"/>
     </map:match>
     
-    <map:match pattern="*">
-      <map:generate type="serverpages" src="{1}-index.xsp"/>
-      <!--
-        Run-time configuration is done through these
-        <map:parameter/> elements. Again, let's have a look at the
-        javadocs:
-        "[...] All <map:parameter> declarations will be made
-        available in the XSLT stylesheet as xsl:variables. [...]" 
-      -->
+    <map:match pattern="create-index.jx">
+      <map:generate type="jx" src="create-index.jx"/>
       <map:transform src="context://samples/stylesheets/dynamic-page2html.xsl">
           <map:parameter name="contextPath" value="{request:contextPath}"/>
       </map:transform>

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/lucene/samples/welcome-index.xml
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/lucene/samples/welcome-index.xml?view=auto&rev=155049
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/lucene/samples/welcome-index.xml (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/lucene/samples/welcome-index.xml Wed Feb 23 11:02:34
2005
@@ -0,0 +1,131 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2005 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.
+-->
+<!-- @version $Id:$ -->
+<page>
+    <title>Welcome to Cocoon XML Search using Lucene</title>
+    <content>
+      <a href="http://jakarta.apache.org/lucene/"><img border="0" alt="Lucene Logo"
src="images/lucene_green_300.gif"/></a>
+      
+      <h1>XML Search</h1>
+      
+      <p>
+        Welcome to Cocoon XML Search. This page introduces Cocoon searching
+        and offers the following samples:
+      </p>
+      <ul>
+        <li>Creating a Lucene index to enable searching
+        </li>
+        <li>Searching through a once created Lucene index using various means:
+        </li>
+        <li>Searching a Lucene index using <em>SearchGenerator</em>
+        </li>
+      </ul>
+      
+      <h2>Creating an Index</h2>
+      <p>
+        You must create a Lucene index first, before you can do the searching.
+        You can create a Lucene index either by crawling, or by using
+        LuceneIndexTransformer.
+      </p>
+
+      <h3>Creating Index By Crawling</h3>
+      <p>
+        Create an index by specifying a base url from which to start
+        crawling (the indexer will follow the links to build its content).
+        The base url should be 
+        <a href="../../../docs/userdocs/concepts/views.html">cocoon-view</a>
+        aware of content-labels
+        <strong>links</strong>, and <strong>content</strong>.
+        For example you might use the base URL 
+        <code>http://localhost:8888/docs/index.html</code>
+      </p>
+      <p>
+        This following page allows you to <a href="create">create</a> an
+        index, named index.
+      </p>
+
+      <h2>Searching</h2>
+      <p>
+        If you have created a Lucene index, you can search the created index.
+      </p>
+      <h3>Searching Index</h3>
+      <p>
+        Enter a query and search the Lucene index that you have created
+        - using <a href="findIt?queryString=lucene">Cocoon Generators</a>.
+      </p>
+
+      <h3>Searching Index2</h3>
+      <p>
+        Enter a query and search the Lucene index2 that you have created
+        - using <a href="findIt2?queryString=cocoon">Cocoon Generators</a>.
+      </p>
+      <!--<p>
+        Construct a query and search the Lucene index2 that you have created
+        - using <a href="query/advanced.html">Cocoon Forms</a>.<br/>
+        Or enter a word or two in here : 
+        	<form action="query/simple.html">
+        		<input type="text" name="query" size="20" value="cocoon"/>
+        		<input type="submit" value="Search" />
+        	</form>
+      </p>-->
+      
+      <h2>Internals</h2>
+      <p>
+        Cocoon XML search uses the
+        <a href="http://jakarta.apache.org/lucene/">Jakarta Lucene</a>
+        indexing and search engine.
+        The Cocoon documentation
+        <a href="../../../docs/userdocs/concepts/xmlsearching.html">explains</a>
how it is implemented within Cocoon. Look behind the scenes of this
+        example to find out more.
+      </p>
+
+      <!--center>
+        <form name="search" action="search" method="get">
+          <table>
+            <tr><td></td>
+              <td>
+                <input name="queryString" size="44"/>&#160;<input type="submit"
value="Search"/>
+              </td>
+            </tr>
+            <tr>
+              <td>Index</td>
+              <td>
+                <select name="index">
+                  <option value="index">index</option>
+                  <option value="index-1">index-1</option>
+                  <option value="index-2">index-2</option>
+                  <option value="index-3">index-3</option>
+                </select>
+              </td>
+            </tr>
+            <tr>
+              <td>Analyzer Class</td>
+              <td>
+                <select name="analyzerClassName">
+                  <option value="org.apache.lucene.analysis.StopAnalyzer">StopAnalyzer</option>
+                  <option value="org.apache.lucene.analysis.standard.StandardAnalyzer">StandardAnalyzer</option>
+                  <option value="org.apache.lucene.analysis.de.GermanAnalyzer">GermanAnalyzer</option>
+                  <option value="org.apache.lucene.analysis.SimpleAnalyzer">SimpleAnalyzer</option>
+                </select>
+              </td>
+            </tr>
+          </table>
+        </form>
+      </center-->
+    </content>
+</page>
+

Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/lucene/samples/welcome-index.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/lucene/samples/welcome-index.xml
------------------------------------------------------------------------------
    svn:keywords = Id



Mime
View raw message