svn commit: r591840 - in /lenya/trunk/src/modules/lucene: ./ config/ config/cocoon-xconf/ java/src/org/apache/lenya/cms/lucene/ resources/i18n/ usecases/

[email protected]
Newsgroups gmane.comp.cms.lenya.cvs
Message-ID <[email protected]>
Author: andreas
Date: Sun Nov  4 13:34:58 2007
New Revision: 591840

URL: http://svn.apache.org/viewvc?rev=591840&view=rev
Log:
Added usecases to index a complete area and to create a new search page

Added:
    lenya/trunk/src/modules/lucene/config/cocoon-xconf/usecase-lucene.indexSite.xconf
    lenya/trunk/src/modules/lucene/config/menu.xsp
    lenya/trunk/src/modules/lucene/java/src/org/apache/lenya/cms/lucene/IndexSite.java
    lenya/trunk/src/modules/lucene/menus.xmap
    lenya/trunk/src/modules/lucene/usecases/indexSite.jx
Modified:
    lenya/trunk/src/modules/lucene/java/src/org/apache/lenya/cms/lucene/IndexUpdater.java
    lenya/trunk/src/modules/lucene/resources/i18n/cmsui.xml
    lenya/trunk/src/modules/lucene/resources/i18n/cmsui_de.xml

Added: lenya/trunk/src/modules/lucene/config/cocoon-xconf/usecase-lucene.indexSite.xconf
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/lucene/config/cocoon-xconf/usecase-lucene.indexSite.xconf?rev=591840&view=auto
==============================================================================
--- lenya/trunk/src/modules/lucene/config/cocoon-xconf/usecase-lucene.indexSite.xconf (added)
+++ lenya/trunk/src/modules/lucene/config/cocoon-xconf/usecase-lucene.indexSite.xconf Sun Nov  4 13:34:58 2007
@@ -0,0 +1,27 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You 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.
+-->
+
+<xconf xpath="/cocoon/usecases" unless="/cocoon/usecases/component-instance[@name = 'lucene.indexSite']">
+
+  <component-instance name="lucene.indexSite"
+                      logger="lenya.usecases.lucene-org.apache.lenya.cms.lucene.IndexSite"
+                      class="org.apache.lenya.cms.lucene.IndexSite">
+    <view uri="modules/lucene/usecases/indexSite.jx"/>
+  </component-instance>
+
+</xconf>

Added: lenya/trunk/src/modules/lucene/config/menu.xsp
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/lucene/config/menu.xsp?rev=591840&view=auto
==============================================================================
--- lenya/trunk/src/modules/lucene/config/menu.xsp (added)
+++ lenya/trunk/src/modules/lucene/config/menu.xsp Sun Nov  4 13:34:58 2007
@@ -0,0 +1,40 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You 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.
+-->
+
+<!-- $Id: generic.xsp 155806 2005-03-01 17:55:42Z andreas $ -->
+
+<xsp:page 
+    language="java" 
+    xmlns:xsp="http://apache.org/xsp"
+    xmlns:i18n="http://apache.org/cocoon/i18n/2.1"    
+    xmlns:uc="http://apache.org/cocoon/lenya/usecase/1.0"
+    xmlns="http://apache.org/cocoon/lenya/menubar/1.0"
+>
+
+  <menu>
+    <menus>
+      <menu i18n:attr="name" name="File">
+        <block admin="false">
+          <item uc:usecase="usecasedocument.create" href="?usecase=lucene.search"><i18n:text>New Search Page</i18n:text></item>
+          <item uc:usecase="lucene.indexSite" href=""><i18n:text>Re-Index Site</i18n:text></item>
+        </block>
+      </menu>
+    </menus>
+  </menu>
+  
+</xsp:page>

Added: lenya/trunk/src/modules/lucene/java/src/org/apache/lenya/cms/lucene/IndexSite.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/lucene/java/src/org/apache/lenya/cms/lucene/IndexSite.java?rev=591840&view=auto
==============================================================================
--- lenya/trunk/src/modules/lucene/java/src/org/apache/lenya/cms/lucene/IndexSite.java (added)
+++ lenya/trunk/src/modules/lucene/java/src/org/apache/lenya/cms/lucene/IndexSite.java Sun Nov  4 13:34:58 2007
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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.lenya.cms.lucene;
+
+import org.apache.lenya.cms.publication.Area;
+import org.apache.lenya.cms.publication.Document;
+import org.apache.lenya.cms.publication.DocumentFactory;
+import org.apache.lenya.cms.publication.Publication;
+import org.apache.lenya.cms.publication.URLInformation;
+import org.apache.lenya.cms.usecase.AbstractUsecase;
+
+/**
+ * Index all documents of the current publication in the current area.
+ */
+public class IndexSite extends AbstractUsecase {
+
+    public void doExecute() throws Exception {
+        String url = getSourceURL();
+        URLInformation info = new URLInformation(url);
+        String pubId = info.getPublicationId();
+
+        DocumentFactory factory = getDocumentFactory();
+        Publication pub = factory.getPublication(pubId);
+        Area area = pub.getArea(info.getArea());
+
+        Document[] docs = area.getDocuments();
+
+        IndexUpdater updater = null;
+        try {
+            updater = (IndexUpdater) this.manager.lookup(IndexUpdater.ROLE);
+            for (int i = 0; i < docs.length; i++) {
+                try {
+                    updater.index(getSession(), docs[i].getResourceType(), pubId, area.getName(),
+                            docs[i].getUUID(), docs[i].getLanguage());
+                } catch (Exception e) {
+                    String message = "Error indexing document [" + docs[i].getPath() + ":"
+                            + docs[i].getLanguage() + "], UUID=" + docs[i].getUUID();
+                    addErrorMessage(e + ", see logfiles for more information.");
+                    getLogger().error(message, e);
+                }
+            }
+        } finally {
+            if (updater != null) {
+                this.manager.release(updater);
+            }
+        }
+    }
+}

Modified: lenya/trunk/src/modules/lucene/java/src/org/apache/lenya/cms/lucene/IndexUpdater.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/lucene/java/src/org/apache/lenya/cms/lucene/IndexUpdater.java?rev=591840&r1=591839&r2=591840&view=diff
==============================================================================
--- lenya/trunk/src/modules/lucene/java/src/org/apache/lenya/cms/lucene/IndexUpdater.java (original)
+++ lenya/trunk/src/modules/lucene/java/src/org/apache/lenya/cms/lucene/IndexUpdater.java Sun Nov  4 13:34:58 2007
@@ -26,6 +26,11 @@
  * Index updater which updates the index when a document changes.
  */
 public interface IndexUpdater extends RepositoryListener {
+    
+    /**
+     * The service role.
+     */
+    String ROLE = IndexUpdater.class.getName();
 
     /**
      * Adds a document to the index.

Added: lenya/trunk/src/modules/lucene/menus.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/lucene/menus.xmap?rev=591840&view=auto
==============================================================================
--- lenya/trunk/src/modules/lucene/menus.xmap (added)
+++ lenya/trunk/src/modules/lucene/menus.xmap Sun Nov  4 13:34:58 2007
@@ -0,0 +1,35 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You 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.
+-->
+
+<!-- $Id: menus.xmap 178738 2005-05-27 03:42:09Z gregor $ -->
+
+<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
+
+  <map:pipelines>
+
+    <map:pipeline>
+    	
+      <map:match pattern="**">
+        <map:generate type="serverpages" src="fallback://lenya/modules/lucene/config/menu.xsp"/>
+        <map:serialize type="xml"/>
+      </map:match>
+      
+    </map:pipeline>
+    
+  </map:pipelines>
+</map:sitemap>

Modified: lenya/trunk/src/modules/lucene/resources/i18n/cmsui.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/lucene/resources/i18n/cmsui.xml?rev=591840&r1=591839&r2=591840&view=diff
==============================================================================
--- lenya/trunk/src/modules/lucene/resources/i18n/cmsui.xml (original)
+++ lenya/trunk/src/modules/lucene/resources/i18n/cmsui.xml Sun Nov  4 13:34:58 2007
@@ -28,5 +28,9 @@
   
   <message key="indexing-failed-subject">Indexing failed</message>
   <message key="indexing-failed-body">The document [{0}:{1}:{2}:{3}] could not be indexed: {4}</message>
+  
+  <message key="New Search Page">New Search Page</message>
+  <message key="Re-Index Site">Re-Index Site</message>
+  <message key="re-index site?">Do you want to re-index all documents of this publication in the current area?</message>
   
 </catalogue>

Modified: lenya/trunk/src/modules/lucene/resources/i18n/cmsui_de.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/lucene/resources/i18n/cmsui_de.xml?rev=591840&r1=591839&r2=591840&view=diff
==============================================================================
--- lenya/trunk/src/modules/lucene/resources/i18n/cmsui_de.xml (original)
+++ lenya/trunk/src/modules/lucene/resources/i18n/cmsui_de.xml Sun Nov  4 13:34:58 2007
@@ -29,5 +29,10 @@
   <message key="indexing-failed-subject">Indexierung fehlgeschlagen</message>
   <message key="indexing-failed-body">Das Dokument [{0}:{1}:{2}:{3}] konnte nicht indexiert werden: {4}</message>
   
+  <message key="New Search Page">Neue Suchseite</message>
+  <message key="Re-Index Site">Website neu indexieren</message>
+  <message key="re-index site?">
+    Wollen Sie alle Dokumente dieser Publikation in der aktuellen Area neu indexieren?
+  </message>
 </catalogue>
 

Added: lenya/trunk/src/modules/lucene/usecases/indexSite.jx
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/lucene/usecases/indexSite.jx?rev=591840&view=auto
==============================================================================
--- lenya/trunk/src/modules/lucene/usecases/indexSite.jx (added)
+++ lenya/trunk/src/modules/lucene/usecases/indexSite.jx Sun Nov  4 13:34:58 2007
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You 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.
+-->
+
+<!-- $Id: login.jx 529195 2007-04-16 10:45:27Z andreas $ -->
+
+<page:page xmlns:jx="http://apache.org/cocoon/templates/jx/1.0" 
+           xmlns:page="http://apache.org/cocoon/lenya/cms-page/1.0" 
+           xmlns="http://www.w3.org/1999/xhtml" 
+           xmlns:i18n="http://apache.org/cocoon/i18n/2.1" >
+
+  <jx:set var="pub" value="${usecase.getParameter('publication')}"/>
+
+  <page:title>
+    <i18n:text>Re-Index Site</i18n:text>
+  </page:title>
+  <page:body>
+    <jx:import uri="fallback://lenya/modules/usecase/templates/messages.jx"/>
+    <p>
+      <i18n:text>re-index site?</i18n:text>
+    </p>
+    <form>
+      <input type="hidden" name="lenya.continuation" value="${continuation.id}"/>
+      <input type="hidden" name="lenya.usecase" value="${usecase.getName()}"/>
+      <p>
+        <input i18n:attr="value" name="submit" type="submit" value="Submit"/>
+        <input i18n:attr="value" name="cancel" type="submit" value="Cancel"/>
+      </p>
+    </form>
+  </page:body>
+</page:page>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.