cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r155047 - in cocoon/trunk: ./ src/blocks/lucene/java/org/apache/cocoon/samples/ src/blocks/lucene/samples/ src/blocks/portal/samples/coplets/basket/
Date Wed, 23 Feb 2005 18:39:37 GMT
Author: cziegeler
Date: Wed Feb 23 10:39:34 2005
New Revision: 155047

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

Added:
    cocoon/trunk/src/blocks/lucene/java/org/apache/cocoon/samples/
    cocoon/trunk/src/blocks/lucene/java/org/apache/cocoon/samples/LuceneUtil.java   (with
props)
    cocoon/trunk/src/blocks/lucene/samples/create-index.jx   (with props)
    cocoon/trunk/src/blocks/lucene/samples/flow.js   (with props)
    cocoon/trunk/src/blocks/lucene/samples/welcome-index.xml
      - copied, changed from r155003, cocoon/trunk/src/blocks/lucene/samples/welcome-index.xsp
Removed:
    cocoon/trunk/src/blocks/lucene/samples/create-index.xsp
    cocoon/trunk/src/blocks/lucene/samples/document-files.xsp
    cocoon/trunk/src/blocks/lucene/samples/search-index.xsp
    cocoon/trunk/src/blocks/lucene/samples/statistic-index.xsp
    cocoon/trunk/src/blocks/lucene/samples/welcome-index.xsp
Modified:
    cocoon/trunk/blocks.properties
    cocoon/trunk/gump.xml
    cocoon/trunk/src/blocks/lucene/samples/sitemap.xmap
    cocoon/trunk/src/blocks/portal/samples/coplets/basket/basket.js

Modified: cocoon/trunk/blocks.properties
URL: http://svn.apache.org/viewcvs/cocoon/trunk/blocks.properties?view=diff&r1=155046&r2=155047
==============================================================================
--- cocoon/trunk/blocks.properties (original)
+++ cocoon/trunk/blocks.properties Wed Feb 23 10:39:34 2005
@@ -64,7 +64,6 @@
 #include.block.jfor=false
 #include.block.jsp=false
 #include.block.linkrewriter=false
-#-----[dependency]: "lucene" depends on "forms" (for samples), "xsp" (for samples).
 #-----[dependency]: "lucene" is needed by "querybean".
 #include.block.lucene=false
 #include.block.naming=false
@@ -84,7 +83,7 @@
 #-----[dependency]: "xmldb" depends on "databases".
 #include.block.xmldb=false
 #-----[dependency]: "xsp" depends on "databases", "session-fw".
-#-----[dependency]: "xsp" is needed by "lucene", "python", "scratchpad".
+#-----[dependency]: "xsp" is needed by "python", "scratchpad".
 #include.block.xsp=false
 
 # Unstable blocks --------------------------------------------------------------
@@ -112,7 +111,7 @@
 #-----[dependency]: "faces" depends on "portal", "taglib".
 #-----[dependency]: "faces" is needed by "scratchpad".
 #include.block.faces=false
-#-----[dependency]: "forms" is needed by "apples", "lucene", "ojb", "petstore", "portal",
"querybean", "tour".
+#-----[dependency]: "forms" is needed by "apples", "ojb", "petstore", "portal", "querybean",
"tour".
 #include.block.forms=false
 #-----[dependency]: "javaflow" is needed by "scratchpad".
 #include.block.javaflow=false

Modified: cocoon/trunk/gump.xml
URL: http://svn.apache.org/viewcvs/cocoon/trunk/gump.xml?view=diff&r1=155046&r2=155047
==============================================================================
--- cocoon/trunk/gump.xml (original)
+++ cocoon/trunk/gump.xml Wed Feb 23 10:39:34 2005
@@ -441,8 +441,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/trunk/src/blocks/lucene/java/org/apache/cocoon/samples/LuceneUtil.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/lucene/java/org/apache/cocoon/samples/LuceneUtil.java?view=auto&rev=155047
==============================================================================
--- cocoon/trunk/src/blocks/lucene/java/org/apache/cocoon/samples/LuceneUtil.java (added)
+++ cocoon/trunk/src/blocks/lucene/java/org/apache/cocoon/samples/LuceneUtil.java Wed Feb
23 10:39: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/trunk/src/blocks/lucene/java/org/apache/cocoon/samples/LuceneUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Added: cocoon/trunk/src/blocks/lucene/samples/create-index.jx
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/lucene/samples/create-index.jx?view=auto&rev=155047
==============================================================================
--- cocoon/trunk/src/blocks/lucene/samples/create-index.jx (added)
+++ cocoon/trunk/src/blocks/lucene/samples/create-index.jx Wed Feb 23 10:39: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/trunk/src/blocks/lucene/samples/create-index.jx
------------------------------------------------------------------------------
    svn:eol-style = native

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

Added: cocoon/trunk/src/blocks/lucene/samples/flow.js
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/lucene/samples/flow.js?view=auto&rev=155047
==============================================================================
--- cocoon/trunk/src/blocks/lucene/samples/flow.js (added)
+++ cocoon/trunk/src/blocks/lucene/samples/flow.js Wed Feb 23 10:39: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/trunk/src/blocks/lucene/samples/flow.js
------------------------------------------------------------------------------
    svn:eol-style = native

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

Modified: cocoon/trunk/src/blocks/lucene/samples/sitemap.xmap
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/lucene/samples/sitemap.xmap?view=diff&r1=155046&r2=155047
==============================================================================
--- cocoon/trunk/src/blocks/lucene/samples/sitemap.xmap (original)
+++ cocoon/trunk/src/blocks/lucene/samples/sitemap.xmap Wed Feb 23 10:39: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,39 +93,22 @@
       <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:parameter name="contextPath" value="{request:contextPath}"/>
       </map:transform>
       <map:serialize/>
     </map:match>

Copied: cocoon/trunk/src/blocks/lucene/samples/welcome-index.xml (from r155003, cocoon/trunk/src/blocks/lucene/samples/welcome-index.xsp)
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/lucene/samples/welcome-index.xml?view=diff&rev=155047&p1=cocoon/trunk/src/blocks/lucene/samples/welcome-index.xsp&r1=155003&p2=cocoon/trunk/src/blocks/lucene/samples/welcome-index.xml&r2=155047
==============================================================================
--- cocoon/trunk/src/blocks/lucene/samples/welcome-index.xsp (original)
+++ cocoon/trunk/src/blocks/lucene/samples/welcome-index.xml Wed Feb 23 10:39:34 2005
@@ -1,6 +1,6 @@
 <?xml version="1.0"?>
 <!--
-  Copyright 1999-2004 The Apache Software Foundation
+  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.
@@ -14,10 +14,8 @@
   See the License for the specific language governing permissions and
   limitations under the License.
 -->
-<!-- CVS $Id: welcome-index.xsp,v 1.9 2004/07/11 15:45:25 antonio Exp $ -->
-<xsp:page language="java" xmlns:xsp="http://apache.org/xsp">
-
-  <page>
+<!-- @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>
@@ -33,8 +31,6 @@
         </li>
         <li>Searching through a once created Lucene index using various means:
         </li>
-        <li>Searching a Lucene index using <em>XSP</em>
-        </li>
         <li>Searching a Lucene index using <em>SearchGenerator</em>
         </li>
       </ul>
@@ -62,18 +58,6 @@
         index, named index.
       </p>
 
-      <h3>Creating Index2 By Transforming</h3>
-      <p>
-        Create an index by using LuceneIndexTransformer. 
-        An XSP Page gathers all files of directory docs/xdocs, includes all
-        the files and pipes it through LuceneIndexTransformer, creating an
-        index, named index2.
-      </p>
-      <p>
-        This following page allows you to <a href="document-files.xsp">create</a>
an
-        index, named index2.
-      </p>
-
       <h2>Searching</h2>
       <p>
         If you have created a Lucene index, you can search the created index.
@@ -81,10 +65,6 @@
       <h3>Searching Index</h3>
       <p>
         Enter a query and search the Lucene index that you have created
-        - using <a href="search?queryString=lucene">XSP</a>.
-      </p>
-      <p>
-        Enter a query and search the Lucene index that you have created
         - using <a href="findIt?queryString=lucene">Cocoon Generators</a>.
       </p>
 
@@ -147,6 +127,5 @@
         </form>
       </center-->
     </content>
-  </page>
-</xsp:page>
+</page>
 

Modified: cocoon/trunk/src/blocks/portal/samples/coplets/basket/basket.js
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/portal/samples/coplets/basket/basket.js?view=diff&r1=155046&r2=155047
==============================================================================
--- cocoon/trunk/src/blocks/portal/samples/coplets/basket/basket.js (original)
+++ cocoon/trunk/src/blocks/portal/samples/coplets/basket/basket.js Wed Feb 23 10:39:34 2005
@@ -1,5 +1,20 @@
+/*
+ * 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.
+ */
 //
-// SVN $Id:$
+// @version $Id$
 //
 cocoon.load("resource://org/apache/cocoon/forms/flow/javascript/Form.js");
 



Mime
View raw message