[portal-commits] JBoss Portal SVN: r5827 - in trunk: . search search/src search/src/etc search/src/main search/src/main/org search/src/main/org/jboss search/src/main/org/jboss/portal search/src/main/org/jboss/portal/search search/src/main/org/jboss/portal/search/federation search/src/main/org/jboss/portal/search/federation/impl search/src/main/org/jboss/portal/search/query search/src/main/org/jboss/portal/search/query/impl search/src/main/org/jboss/portal/search/test

portal-commits at lists.jboss.org portal-commits at lists.jboss.org
Wed Dec 13 09:39:04 EST 2006


Author: thomas.heute at jboss.com
Date: 2006-12-13 09:38:58 -0500 (Wed, 13 Dec 2006)
New Revision: 5827

Added:
   trunk/search/
   trunk/search/.classpath
   trunk/search/.project
   trunk/search/build.bat
   trunk/search/build.sh
   trunk/search/build.xml
   trunk/search/src/
   trunk/search/src/etc/
   trunk/search/src/etc/portal-search-lib-jar.mf
   trunk/search/src/main/
   trunk/search/src/main/org/
   trunk/search/src/main/org/jboss/
   trunk/search/src/main/org/jboss/portal/
   trunk/search/src/main/org/jboss/portal/search/
   trunk/search/src/main/org/jboss/portal/search/IndexingException.java
   trunk/search/src/main/org/jboss/portal/search/Result.java
   trunk/search/src/main/org/jboss/portal/search/Results.java
   trunk/search/src/main/org/jboss/portal/search/federation/
   trunk/search/src/main/org/jboss/portal/search/federation/Info.java
   trunk/search/src/main/org/jboss/portal/search/federation/SearchFederated.java
   trunk/search/src/main/org/jboss/portal/search/federation/SearchFederation.java
   trunk/search/src/main/org/jboss/portal/search/federation/impl/
   trunk/search/src/main/org/jboss/portal/search/federation/impl/SearchFederationService.java
   trunk/search/src/main/org/jboss/portal/search/query/
   trunk/search/src/main/org/jboss/portal/search/query/Query.java
   trunk/search/src/main/org/jboss/portal/search/query/QueryTerm.java
   trunk/search/src/main/org/jboss/portal/search/query/impl/
   trunk/search/src/main/org/jboss/portal/search/query/impl/FieldQueryTerm.java
   trunk/search/src/main/org/jboss/portal/search/query/impl/KeywordQueryTerm.java
   trunk/search/src/main/org/jboss/portal/search/test/
   trunk/search/src/main/org/jboss/portal/search/test/LuceneQueryTest.java
   trunk/search/src/main/org/jboss/portal/search/test/LuceneUtil.java
   trunk/search/src/main/org/jboss/portal/search/test/SearchFederatedLucene.java
Log:
First import

Added: trunk/search/.classpath
===================================================================
--- trunk/search/.classpath	2006-12-13 14:29:48 UTC (rev 5826)
+++ trunk/search/.classpath	2006-12-13 14:38:58 UTC (rev 5827)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src/main"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3.8.1"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/jems"/>
+	<classpathentry kind="lib" path="/thirdparty/jbossas/core-libs/lib/jboss-system.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jbossas/core-libs/lib/jboss-jmx.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jbossas/core-libs/lib/jboss-common.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/apache-lucene/lib/lucene.jar"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

Added: trunk/search/.project
===================================================================
--- trunk/search/.project	2006-12-13 14:29:48 UTC (rev 5826)
+++ trunk/search/.project	2006-12-13 14:38:58 UTC (rev 5827)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>search</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

Added: trunk/search/build.bat
===================================================================
--- trunk/search/build.bat	2006-12-13 14:29:48 UTC (rev 5826)
+++ trunk/search/build.bat	2006-12-13 14:38:58 UTC (rev 5827)
@@ -0,0 +1,54 @@
+ at echo off
+rem
+rem  Invokes a script of the same name in the 'tools' module.
+rem  
+rem  The 'tools' module is expected to be a peer directory of the directory
+rem  in which this script lives.
+rem
+rem  @author Jason Dillon <jason at planet57.com>
+rem
+
+rem $Id: build.bat 2 2005-01-14 23:01:32 +0000 (Fri, 14 Jan 2005) vietj $
+
+setlocal
+
+set PROGNAME=%~nx0
+set DIRNAME=%~dp0
+
+rem Legacy shell support
+if x%PROGNAME%==x set PROGNAME=build.bat
+if x%DIRNAME%==x set DIRNAME=.\
+
+set MODULE_ROOT=%DIRNAME%
+if x%TOOLS_ROOT%==x set TOOLS_ROOT=%DIRNAME%..\tools
+set TARGET=%TOOLS_ROOT%\bin\build.bat
+set ARGS=%*
+
+rem Start'er up yo
+goto main
+
+:debug
+if not x%DEBUG%==x echo %PROGNAME%: %*
+goto :EOF
+
+:main
+call :debug PROGNAME=%PROGNAME%
+call :debug DIRNAME=%DIRNAME%
+call :debug TOOLS_ROOT=%TOOLS_ROOT%
+call :debug TARGET=%TARGET%
+
+if exist %TARGET% call :call-script & goto :EOF
+rem else fail, we can not go on
+
+echo %PROGNAME%: *ERROR* The target executable does not exist:
+echo %PROGNAME%:
+echo %PROGNAME%:    %TARGET%
+echo %PROGNAME%:
+echo %PROGNAME%: Please make sure you have checked out the 'tools' module
+echo %PROGNAME%: and make sure it is up to date.
+goto :EOF
+
+:call-script
+call :debug Executing %TARGET% %ARGS%
+call %TARGET% %ARGS%
+goto :EOF


Property changes on: trunk/search/build.bat
___________________________________________________________________
Name: svn:executable
   + 

Added: trunk/search/build.sh
===================================================================
--- trunk/search/build.sh	2006-12-13 14:29:48 UTC (rev 5826)
+++ trunk/search/build.sh	2006-12-13 14:38:58 UTC (rev 5827)
@@ -0,0 +1,49 @@
+#!/bin/sh
+##
+##  Invokes a script of the same name in the 'tools' module.
+##  
+##  The 'tools' module is expected to be a peer directory of the directory
+##  in which this script lives.
+##
+##  @author Jason Dillon <jason at planet57.com>
+##
+
+# $Id: build.sh 2 2005-01-14 23:01:32 +0000 (Fri, 14 Jan 2005) vietj $
+
+PROGNAME=`basename $0`
+DIRNAME=`dirname $0`
+
+# Buss it yo
+main() {
+    if [ "x$TOOLS_ROOT" = "x" ]; then
+	TOOLS_ROOT=`cd $DIRNAME/../tools && pwd`
+    fi
+
+    MODULE_ROOT=`cd $DIRNAME; pwd`
+    export TOOLS_ROOT MODULE_ROOT DEBUG TRACE
+
+    # Where is the target script?
+    target="$TOOLS_ROOT/bin/$PROGNAME"
+    if [ ! -f "$target" ]; then
+	echo "${PROGNAME}: *ERROR* The target executable does not exist:"
+        echo "${PROGNAME}:"
+        echo "${PROGNAME}:    $target"
+        echo "${PROGNAME}:"
+	echo "${PROGNAME}: Please make sure you have checked out the 'tools' module"
+	echo "${PROGNAME}: and make sure it is up to date."
+        exit 2
+    fi
+
+    # Get busy yo!
+    if [ "x$DEBUG" != "x" ]; then
+	echo "${PROGNAME}: Executing: /bin/sh $target $@"
+    fi
+    if [ "x$TRACE" = "x" ]; then
+	exec /bin/sh $target "$@"
+    else
+	exec /bin/sh -x $target "$@"
+    fi
+}
+
+# Lets get ready to rumble!
+main "$@"


Property changes on: trunk/search/build.sh
___________________________________________________________________
Name: svn:executable
   + 

Added: trunk/search/build.xml
===================================================================
--- trunk/search/build.xml	2006-12-13 14:29:48 UTC (rev 5826)
+++ trunk/search/build.xml	2006-12-13 14:38:58 UTC (rev 5827)
@@ -0,0 +1,185 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE project [
+   <!ENTITY buildmagic SYSTEM "../tools/etc/buildfragments/buildmagic.ent">
+   <!ENTITY tools      SYSTEM "../tools/etc/buildfragments/tools.ent">
+   <!ENTITY libraries  SYSTEM "../thirdparty/libraries.ent">
+   <!ENTITY modules    SYSTEM "../tools/etc/buildfragments/modules.ent">
+   <!ENTITY defaults   SYSTEM "../tools/etc/buildfragments/defaults.ent">
+   <!ENTITY targets    SYSTEM "../tools/etc/buildfragments/targets.ent">
+   ]>
+
+<!-- $Id: build.xml 5658 2006-11-15 15:02:57Z julien at jboss.com $ -->
+
+<!--+======================================================================+-->
+<!--| JBoss Portal (The OpenSource Portal) Build File                      |-->
+<!--|                                                                      |-->
+<!--| Distributable under LGPL license.                                    |-->
+<!--| See terms of license at http://www.gnu.org.                          |-->
+<!--|                                                                      |-->
+<!--| This file has been designed to work with the 'tools' module and      |-->
+<!--| Buildmagic extentions.                                               |-->
+<!--+======================================================================+-->
+
+<project default="main" name="JBoss Portal">
+
+   <!--+====================================================================+-->
+   <!--| Setup                                                              |-->
+   <!--|                                                                    |-->
+   <!--| Include the common build elements.                                 |-->
+   <!--|                                                                    |-->
+   <!--| This defines several different targets, properties and paths.      |-->
+   <!--| It also sets up the basic extention tasks amoung other things.     |-->
+   <!--+====================================================================+-->
+
+   &buildmagic;   
+   &modules;
+   &defaults;
+   &tools;
+   &targets;
+
+   <!-- ================================================================== -->
+   <!-- Initialization                                                     -->
+   <!-- ================================================================== -->
+
+   <!--
+      | Initialize the build system.  Must depend on '_buildmagic:init'.
+      | Other targets should depend on 'init' or things will mysteriously fail.
+    -->
+
+   <target name="init" unless="init.disable" depends="_buildmagic:init">
+   </target>
+
+   <!--+====================================================================+-->
+   <!--| Configuration                                                      |-->
+   <!--|                                                                    |-->
+   <!--| This target is invoked by the Buildmagic initialization logic      |-->
+   <!--| and should contain module specific configuration elements.         |-->
+   <!--+====================================================================+-->
+
+   <target name="configure" unless="configure.disable">
+
+      <!-- Configure some properties -->
+      <property name="jboss-junit-configuration" value=""/>
+      <property name="junit.formatter.usefile" value="true"/>
+
+      <!-- Configure thirdparty libraries -->
+      &libraries;
+      <path id="library.classpath">
+         <path refid="jbossas/core.libs.classpath"/>
+         <path refid="apache.lucene.classpath"/>
+         <path refid="junit.junit.classpath"/>
+      </path>
+
+      <!-- Configure modules -->
+      <call target="configure-modules"/>
+      <path id="dependentmodule.classpath">
+        <path refid="jboss.portal-jems.classpath"/>
+      </path>
+
+      <!--+=======================================+-->
+      <!--| Override any default properties here. |-->
+      <!--+=======================================+-->
+
+      <!-- Configure defaults & build tools -->
+      <call target="configure-defaults"/>
+      <call target="configure-tools"/>
+
+      <!--+=======================================+-->
+      <!--| Define module specific elements here. |-->
+      <!--+=======================================+-->
+      <property name="javadoc.private" value="true"/>
+      <property name="javadoc.protected" value="false"/>
+
+   </target>
+   
+
+   <!--+====================================================================+-->
+   <!--| Compile                                                            |-->
+   <!--|                                                                    |-->
+   <!--| This target should depend on other compile-* targets for each      |-->
+   <!--| different type of compile that needs to be performed, short of     |-->
+   <!--| documentation compiles.                                            |-->
+   <!--+====================================================================+-->
+
+   <target name="compile"
+           description="Compile all source files."
+           depends="generate-parsers,
+               _default:compile-classes,
+               _default:compile-etc,
+               _default:compile-resources">
+      <!-- Add module specific elements here. -->
+   </target>
+
+   <target name="generate-parsers" depends="init">
+   </target>
+
+   <!--+====================================================================+-->
+   <!--| Generate Output                                                    |-->
+   <!--|                                                                    |-->
+   <!--| Generates the target output for this module. Target output is      |-->
+   <!--| the output which is ment to be released or used by external        |-->
+   <!--| modules.                                                           |-->
+   <!--+====================================================================+-->
+
+	<target name="output"
+	           description="Generate all target output."
+	           depends="compile">
+
+	      <mkdir dir="${build.lib}"/>
+
+	      <jar jarfile="${build.lib}/portal-search-lib.jar" manifest="${build.etc}/portal-search-lib-jar.mf">
+            <fileset dir="${build.classes}">
+               <exclude name="org/jboss/portal/search/test/**/*"/>
+            </fileset>
+	      </jar>
+	   </target>
+	   
+
+   <!-- ================================================================== -->
+   <!-- Cleaning                                                           -->
+   <!-- ================================================================== -->
+
+   <!-- Clean up all build output -->
+   <target name="clean" depends="_default:clean">
+      <!-- Add module specific elements here. -->
+   </target>
+
+   <!--+====================================================================+-->
+   <!--| Documents                                                          |-->
+   <!--|                                                                    |-->
+   <!--| Generate all documentation for this module.                        |-->
+   <!--+====================================================================+-->
+
+   <target name="docs" depends="_default:docs">
+      <!-- Add module specific elements here. -->
+   </target>
+
+   <!-- ================================================================== -->
+   <!-- Misc.                                                              -->
+   <!-- ================================================================== -->
+
+   <target name="main" depends="most"/>
+   <target name="all" depends="_default:all"/>
+   <target name="most" depends="_default:most"/>
+   <target name="help" depends="_default:help"/>
+
+   <target name="tests" depends="init">
+
+
+      <execute-tests>
+
+
+         <x-test>
+            <test todir="${test.reports}" name="org.jboss.portal.search.test.LuceneQueryTest"/>
+         </x-test>
+         <x-classpath>
+            <pathelement location="${build.classes}"/>
+            <pathelement location="${build.resources}"/>
+            <path refid="dom4j.dom4j.classpath"/>
+            <path refid="library.classpath"/>
+            <path refid="dependentmodule.classpath"/>
+         </x-classpath>
+      </execute-tests>
+   </target>
+
+</project>


Property changes on: trunk/search/build.xml
___________________________________________________________________
Name: svn:executable
   + 

Added: trunk/search/src/etc/portal-search-lib-jar.mf
===================================================================
--- trunk/search/src/etc/portal-search-lib-jar.mf	2006-12-13 14:29:48 UTC (rev 5826)
+++ trunk/search/src/etc/portal-search-lib-jar.mf	2006-12-13 14:38:58 UTC (rev 5827)
@@ -0,0 +1,10 @@
+Manifest-Version: 1.0
+Created-By: @java.vm.version@ (@java.vm.vendor@)
+Specification-Title: @specification.title@
+Specification-Version: @specification.version@
+Specification-Vendor: @specification.vendor@
+Implementation-Title: @implementation.title@
+Implementation-URL: @implementation.url@
+Implementation-Version: @implementation.version@
+Implementation-Vendor: @implementation.vendor@
+Implementation-Vendor-Id: @implementation.vendor.id@


Property changes on: trunk/search/src/etc/portal-search-lib-jar.mf
___________________________________________________________________
Name: svn:executable
   + 

Added: trunk/search/src/main/org/jboss/portal/search/IndexingException.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/IndexingException.java	2006-12-13 14:29:48 UTC (rev 5826)
+++ trunk/search/src/main/org/jboss/portal/search/IndexingException.java	2006-12-13 14:38:58 UTC (rev 5827)
@@ -0,0 +1,45 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat                                               *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
+ * contributors as indicated by the @authors tag. See the                     *
+ * copyright.txt in the distribution for a full listing of                    *
+ * individual contributors.                                                   *
+ *                                                                            *
+ * This is free software; you can redistribute it and/or modify it            *
+ * under the terms of the GNU Lesser General Public License as                *
+ * published by the Free Software Foundation; either version 2.1 of           *
+ * the License, or (at your option) any later version.                        *
+ *                                                                            *
+ * This software is distributed in the hope that it will be useful,           *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
+ * Lesser General Public License for more details.                            *
+ *                                                                            *
+ * You should have received a copy of the GNU Lesser General Public           *
+ * License along with this software; if not, write to the Free                *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
+ ******************************************************************************/
+package org.jboss.portal.search;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class IndexingException extends Exception
+{
+   /**
+    * 
+    */
+   private static final long serialVersionUID = -4153594211827182795L;
+
+   public IndexingException(Throwable e)
+   {
+      super(e);
+   }
+
+   public IndexingException(String msg, Throwable e)
+   {
+      super(msg, e);
+   }
+}

Added: trunk/search/src/main/org/jboss/portal/search/Result.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/Result.java	2006-12-13 14:29:48 UTC (rev 5826)
+++ trunk/search/src/main/org/jboss/portal/search/Result.java	2006-12-13 14:38:58 UTC (rev 5827)
@@ -0,0 +1,56 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat                                               *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
+ * contributors as indicated by the @authors tag. See the                     *
+ * copyright.txt in the distribution for a full listing of                    *
+ * individual contributors.                                                   *
+ *                                                                            *
+ * This is free software; you can redistribute it and/or modify it            *
+ * under the terms of the GNU Lesser General Public License as                *
+ * published by the Free Software Foundation; either version 2.1 of           *
+ * the License, or (at your option) any later version.                        *
+ *                                                                            *
+ * This software is distributed in the hope that it will be useful,           *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
+ * Lesser General Public License for more details.                            *
+ *                                                                            *
+ * You should have received a copy of the GNU Lesser General Public           *
+ * License along with this software; if not, write to the Free                *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
+ ******************************************************************************/
+package org.jboss.portal.search;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class Result
+{
+   private String federatedId;
+
+   private Object value;
+   
+   public Result(String federatedId, Object value)
+   {
+      this.federatedId = federatedId;
+      this.value = value;
+   }
+   
+   public Object getValue()
+   {
+      return value;
+   }
+   
+   public void setValue(Object value)
+   {
+      this.value = value;
+   }
+
+   public String getFederatedId()
+   {
+      return federatedId;
+   }
+
+}

Added: trunk/search/src/main/org/jboss/portal/search/Results.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/Results.java	2006-12-13 14:29:48 UTC (rev 5826)
+++ trunk/search/src/main/org/jboss/portal/search/Results.java	2006-12-13 14:38:58 UTC (rev 5827)
@@ -0,0 +1,36 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat                                               *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
+ * contributors as indicated by the @authors tag. See the                     *
+ * copyright.txt in the distribution for a full listing of                    *
+ * individual contributors.                                                   *
+ *                                                                            *
+ * This is free software; you can redistribute it and/or modify it            *
+ * under the terms of the GNU Lesser General Public License as                *
+ * published by the Free Software Foundation; either version 2.1 of           *
+ * the License, or (at your option) any later version.                        *
+ *                                                                            *
+ * This software is distributed in the hope that it will be useful,           *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
+ * Lesser General Public License for more details.                            *
+ *                                                                            *
+ * You should have received a copy of the GNU Lesser General Public           *
+ * License along with this software; if not, write to the Free                *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
+ ******************************************************************************/
+package org.jboss.portal.search;
+
+import java.util.ArrayList;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class Results  extends ArrayList
+{
+
+   private static final long serialVersionUID = -334471675564695554L;
+
+}

Added: trunk/search/src/main/org/jboss/portal/search/federation/Info.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/federation/Info.java	2006-12-13 14:29:48 UTC (rev 5826)
+++ trunk/search/src/main/org/jboss/portal/search/federation/Info.java	2006-12-13 14:38:58 UTC (rev 5827)
@@ -0,0 +1,64 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat                                               *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
+ * contributors as indicated by the @authors tag. See the                     *
+ * copyright.txt in the distribution for a full listing of                    *
+ * individual contributors.                                                   *
+ *                                                                            *
+ * This is free software; you can redistribute it and/or modify it            *
+ * under the terms of the GNU Lesser General Public License as                *
+ * published by the Free Software Foundation; either version 2.1 of           *
+ * the License, or (at your option) any later version.                        *
+ *                                                                            *
+ * This software is distributed in the hope that it will be useful,           *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
+ * Lesser General Public License for more details.                            *
+ *                                                                            *
+ * You should have received a copy of the GNU Lesser General Public           *
+ * License along with this software; if not, write to the Free                *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
+ ******************************************************************************/
+package org.jboss.portal.search.federation;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class Info
+{
+   
+   private int status = Status.STOPPED;
+   private long lastIndexedDate;
+   
+   public int getStatus()
+   {
+      return status;
+   }
+   
+   public void setStatus(int status)
+   {
+      this.status = status;
+   }
+
+   public long getLastIndexedDate()
+   {
+      return lastIndexedDate;
+   }
+   
+   public void setLastIndexedDate(int lastIndexedDate)
+   {
+      this.lastIndexedDate = lastIndexedDate;
+   }
+   
+   public interface Status
+   {
+      public static final int STARTED = 0;
+      public static final int INDEXING = 1;
+      public static final int CORRUPTED = 2;
+      public static final int UNAVAILABLE = 3;
+      public static final int STOPPED = 4;
+   }
+   
+}

Added: trunk/search/src/main/org/jboss/portal/search/federation/SearchFederated.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/federation/SearchFederated.java	2006-12-13 14:29:48 UTC (rev 5826)
+++ trunk/search/src/main/org/jboss/portal/search/federation/SearchFederated.java	2006-12-13 14:38:58 UTC (rev 5827)
@@ -0,0 +1,53 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat                                               *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
+ * contributors as indicated by the @authors tag. See the                     *
+ * copyright.txt in the distribution for a full listing of                    *
+ * individual contributors.                                                   *
+ *                                                                            *
+ * This is free software; you can redistribute it and/or modify it            *
+ * under the terms of the GNU Lesser General Public License as                *
+ * published by the Free Software Foundation; either version 2.1 of           *
+ * the License, or (at your option) any later version.                        *
+ *                                                                            *
+ * This software is distributed in the hope that it will be useful,           *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
+ * Lesser General Public License for more details.                            *
+ *                                                                            *
+ * You should have received a copy of the GNU Lesser General Public           *
+ * License along with this software; if not, write to the Free                *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
+ ******************************************************************************/
+package org.jboss.portal.search.federation;
+
+import org.jboss.portal.search.IndexingException;
+import org.jboss.portal.search.Results;
+import org.jboss.portal.search.query.Query;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public interface SearchFederated
+{
+
+   public String getId();
+
+   public void destroy() throws IndexingException;
+   
+   public void create() throws IndexingException;
+   
+   public Info getInfo();
+   
+   public Results search(Query query);
+   
+   public String getMarkup(Results results, int markupLevel);
+   
+   public interface MarkupLevel
+   {
+      public static final int FULL = 0;
+      public static final int REDUCED = 1;
+   }
+}

Added: trunk/search/src/main/org/jboss/portal/search/federation/SearchFederation.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/federation/SearchFederation.java	2006-12-13 14:29:48 UTC (rev 5826)
+++ trunk/search/src/main/org/jboss/portal/search/federation/SearchFederation.java	2006-12-13 14:38:58 UTC (rev 5827)
@@ -0,0 +1,43 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat                                               *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
+ * contributors as indicated by the @authors tag. See the                     *
+ * copyright.txt in the distribution for a full listing of                    *
+ * individual contributors.                                                   *
+ *                                                                            *
+ * This is free software; you can redistribute it and/or modify it            *
+ * under the terms of the GNU Lesser General Public License as                *
+ * published by the Free Software Foundation; either version 2.1 of           *
+ * the License, or (at your option) any later version.                        *
+ *                                                                            *
+ * This software is distributed in the hope that it will be useful,           *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
+ * Lesser General Public License for more details.                            *
+ *                                                                            *
+ * You should have received a copy of the GNU Lesser General Public           *
+ * License along with this software; if not, write to the Free                *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
+ ******************************************************************************/
+package org.jboss.portal.search.federation;
+
+import java.util.List;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public interface SearchFederation
+{
+   public void register(SearchFederated searchFederated);
+   
+   public void unregister(String id);
+   
+   public void reindexAll();
+   
+   public List getSearchFederated();
+
+   public SearchFederated getSearchFederated(String id);
+
+}

Added: trunk/search/src/main/org/jboss/portal/search/federation/impl/SearchFederationService.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/federation/impl/SearchFederationService.java	2006-12-13 14:29:48 UTC (rev 5826)
+++ trunk/search/src/main/org/jboss/portal/search/federation/impl/SearchFederationService.java	2006-12-13 14:38:58 UTC (rev 5827)
@@ -0,0 +1,131 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat                                               *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
+ * contributors as indicated by the @authors tag. See the                     *
+ * copyright.txt in the distribution for a full listing of                    *
+ * individual contributors.                                                   *
+ *                                                                            *
+ * This is free software; you can redistribute it and/or modify it            *
+ * under the terms of the GNU Lesser General Public License as                *
+ * published by the Free Software Foundation; either version 2.1 of           *
+ * the License, or (at your option) any later version.                        *
+ *                                                                            *
+ * This software is distributed in the hope that it will be useful,           *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
+ * Lesser General Public License for more details.                            *
+ *                                                                            *
+ * You should have received a copy of the GNU Lesser General Public           *
+ * License along with this software; if not, write to the Free                *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
+ ******************************************************************************/
+package org.jboss.portal.search.federation.impl;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+import org.jboss.portal.search.IndexingException;
+import org.jboss.portal.search.federation.Info;
+import org.jboss.portal.search.federation.SearchFederated;
+import org.jboss.portal.search.federation.SearchFederation;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class SearchFederationService extends AbstractJBossService implements SearchFederation
+{
+
+   private Map registry;
+   
+   public synchronized void register(SearchFederated searchFederated)
+   {
+      if (searchFederated == null)
+      {
+         throw new IllegalArgumentException("No null invoker");
+      }
+      String id = searchFederated.getId();
+      if (registry.containsKey(id))
+      {
+         throw new IllegalArgumentException("Attempting dual registration of " + id);
+      }
+      Map copy = new HashMap(registry);
+      copy.put(id, searchFederated);
+      registry = copy;
+   }
+
+   public synchronized void unregister(String id)
+   {
+      if (id == null)
+      {
+         throw new IllegalArgumentException("No null id accepted");
+      }
+      if (!registry.containsKey(id))
+      {
+         throw new IllegalArgumentException("Attempting to unregister unknown federated search service " + id);
+      }
+      Map copy = new HashMap(registry);
+      copy.remove(id);
+      registry = copy;
+   }
+
+   public void reindexAll()
+   {
+      if (registry != null)
+      {
+         Iterator it = registry.values().iterator();
+         while (it.hasNext())
+         {
+            SearchFederated federated = (SearchFederated) it.next();
+            if (federated.getInfo().getStatus() != Info.Status.INDEXING)
+            {
+               Thread thread = new ReindexFederatedThread(federated);
+               thread.run();
+            }
+         }
+      }
+   }
+   
+   private class ReindexFederatedThread extends Thread
+   {
+      private SearchFederated federated;
+      
+      public ReindexFederatedThread(SearchFederated federated)
+      {
+         this.federated = federated;
+      }
+      
+      public void run()
+      {
+         federated.getInfo().setStatus(Info.Status.INDEXING);
+         try
+         {
+            federated.destroy();
+            federated.create();
+            federated.getInfo().setStatus(Info.Status.STARTED);
+         }
+         catch (IndexingException e)
+         {
+            federated.getInfo().setStatus(Info.Status.CORRUPTED);
+            e.printStackTrace();
+         }
+      }
+   }
+
+   public List getSearchFederated()
+   {
+      return Collections.unmodifiableList(new ArrayList(registry.values()));
+   }
+
+   public SearchFederated getSearchFederated(String id)
+   {
+      return (SearchFederated)registry.get(id);
+   }
+   
+}

Added: trunk/search/src/main/org/jboss/portal/search/query/Query.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/query/Query.java	2006-12-13 14:29:48 UTC (rev 5826)
+++ trunk/search/src/main/org/jboss/portal/search/query/Query.java	2006-12-13 14:38:58 UTC (rev 5827)
@@ -0,0 +1,127 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat                                               *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
+ * contributors as indicated by the @authors tag. See the                     *
+ * copyright.txt in the distribution for a full listing of                    *
+ * individual contributors.                                                   *
+ *                                                                            *
+ * This is free software; you can redistribute it and/or modify it            *
+ * under the terms of the GNU Lesser General Public License as                *
+ * published by the Free Software Foundation; either version 2.1 of           *
+ * the License, or (at your option) any later version.                        *
+ *                                                                            *
+ * This software is distributed in the hope that it will be useful,           *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
+ * Lesser General Public License for more details.                            *
+ *                                                                            *
+ * You should have received a copy of the GNU Lesser General Public           *
+ * License along with this software; if not, write to the Free                *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
+ ******************************************************************************/
+package org.jboss.portal.search.query;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class Query
+{
+   
+   private List mandatoryTerms;
+   private List optionalTerms;
+   private List notTerms;
+   
+   private List mandatoryQueries;
+   private List optionalQueries;
+   private List notQueries;
+   
+   public void addMandatoryTerm(QueryTerm term)
+   {
+      if (mandatoryTerms == null)
+      {
+         mandatoryTerms = new ArrayList();
+      }
+      mandatoryTerms.add(term);
+   }
+
+   public void addOptionalTerm(QueryTerm term)
+   {
+      if (optionalTerms == null)
+      {
+         optionalTerms = new ArrayList();
+      }
+      optionalTerms.add(term);
+   }
+
+   public void addNotTerm(QueryTerm term)
+   {
+      if (notTerms == null)
+      {
+         notTerms = new ArrayList();
+      }
+      notTerms.add(term);
+   }
+
+   public void addMandatoryQuery(Query query)
+   {
+      if (mandatoryQueries == null)
+      {
+          mandatoryQueries = new ArrayList();
+      }
+      mandatoryQueries.add(query);
+   }
+
+   public void addOptionalQuery(Query query)
+   {
+      if (optionalQueries == null)
+      {
+          optionalQueries = new ArrayList();
+      }
+      optionalQueries.add(query);
+   }
+
+   public void addNotQuery(Query query)
+   {
+      if (notQueries == null)
+      {
+          notQueries = new ArrayList();
+      }
+      notQueries.add(query);
+   }
+
+   public List getMandatoryQueries()
+   {
+      return mandatoryQueries;
+   }
+
+   public List getMandatoryTerms()
+   {
+      return mandatoryTerms;
+   }
+
+   public List getNotQueries()
+   {
+      return notQueries;
+   }
+
+   public List getNotTerms()
+   {
+      return notTerms;
+   }
+
+   public List getOptionalQueries()
+   {
+      return optionalQueries;
+   }
+
+   public List getOptionalTerms()
+   {
+      return optionalTerms;
+   }
+}

Added: trunk/search/src/main/org/jboss/portal/search/query/QueryTerm.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/query/QueryTerm.java	2006-12-13 14:29:48 UTC (rev 5826)
+++ trunk/search/src/main/org/jboss/portal/search/query/QueryTerm.java	2006-12-13 14:38:58 UTC (rev 5827)
@@ -0,0 +1,32 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat                                               *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
+ * contributors as indicated by the @authors tag. See the                     *
+ * copyright.txt in the distribution for a full listing of                    *
+ * individual contributors.                                                   *
+ *                                                                            *
+ * This is free software; you can redistribute it and/or modify it            *
+ * under the terms of the GNU Lesser General Public License as                *
+ * published by the Free Software Foundation; either version 2.1 of           *
+ * the License, or (at your option) any later version.                        *
+ *                                                                            *
+ * This software is distributed in the hope that it will be useful,           *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
+ * Lesser General Public License for more details.                            *
+ *                                                                            *
+ * You should have received a copy of the GNU Lesser General Public           *
+ * License along with this software; if not, write to the Free                *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
+ ******************************************************************************/
+package org.jboss.portal.search.query;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public interface QueryTerm
+{
+   
+}

Added: trunk/search/src/main/org/jboss/portal/search/query/impl/FieldQueryTerm.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/query/impl/FieldQueryTerm.java	2006-12-13 14:29:48 UTC (rev 5826)
+++ trunk/search/src/main/org/jboss/portal/search/query/impl/FieldQueryTerm.java	2006-12-13 14:38:58 UTC (rev 5827)
@@ -0,0 +1,54 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat                                               *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
+ * contributors as indicated by the @authors tag. See the                     *
+ * copyright.txt in the distribution for a full listing of                    *
+ * individual contributors.                                                   *
+ *                                                                            *
+ * This is free software; you can redistribute it and/or modify it            *
+ * under the terms of the GNU Lesser General Public License as                *
+ * published by the Free Software Foundation; either version 2.1 of           *
+ * the License, or (at your option) any later version.                        *
+ *                                                                            *
+ * This software is distributed in the hope that it will be useful,           *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
+ * Lesser General Public License for more details.                            *
+ *                                                                            *
+ * You should have received a copy of the GNU Lesser General Public           *
+ * License along with this software; if not, write to the Free                *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
+ ******************************************************************************/
+package org.jboss.portal.search.query.impl;
+
+import org.jboss.portal.search.query.QueryTerm;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class FieldQueryTerm implements QueryTerm
+{
+
+   private String name;
+   
+   private String value;
+   
+   public FieldQueryTerm(String name, String value)
+   {
+      this.name = name;
+      this.value = value;
+   }
+
+   public String getName()
+   {
+      return name;
+   }
+   
+   public String getValue()
+   {
+      return value;
+   }
+
+}

Added: trunk/search/src/main/org/jboss/portal/search/query/impl/KeywordQueryTerm.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/query/impl/KeywordQueryTerm.java	2006-12-13 14:29:48 UTC (rev 5826)
+++ trunk/search/src/main/org/jboss/portal/search/query/impl/KeywordQueryTerm.java	2006-12-13 14:38:58 UTC (rev 5827)
@@ -0,0 +1,45 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat                                               *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
+ * contributors as indicated by the @authors tag. See the                     *
+ * copyright.txt in the distribution for a full listing of                    *
+ * individual contributors.                                                   *
+ *                                                                            *
+ * This is free software; you can redistribute it and/or modify it            *
+ * under the terms of the GNU Lesser General Public License as                *
+ * published by the Free Software Foundation; either version 2.1 of           *
+ * the License, or (at your option) any later version.                        *
+ *                                                                            *
+ * This software is distributed in the hope that it will be useful,           *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
+ * Lesser General Public License for more details.                            *
+ *                                                                            *
+ * You should have received a copy of the GNU Lesser General Public           *
+ * License along with this software; if not, write to the Free                *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
+ ******************************************************************************/
+package org.jboss.portal.search.query.impl;
+
+import org.jboss.portal.search.query.QueryTerm;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class KeywordQueryTerm implements QueryTerm
+{
+
+   private String keyword;
+   
+   public KeywordQueryTerm(String keyword)
+   {
+      this.keyword = keyword;
+   }
+   
+   public String getKeyWord()
+   {
+      return keyword;
+   }
+}

Added: trunk/search/src/main/org/jboss/portal/search/test/LuceneQueryTest.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/test/LuceneQueryTest.java	2006-12-13 14:29:48 UTC (rev 5826)
+++ trunk/search/src/main/org/jboss/portal/search/test/LuceneQueryTest.java	2006-12-13 14:38:58 UTC (rev 5827)
@@ -0,0 +1,57 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat                                               *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
+ * contributors as indicated by the @authors tag. See the                     *
+ * copyright.txt in the distribution for a full listing of                    *
+ * individual contributors.                                                   *
+ *                                                                            *
+ * This is free software; you can redistribute it and/or modify it            *
+ * under the terms of the GNU Lesser General Public License as                *
+ * published by the Free Software Foundation; either version 2.1 of           *
+ * the License, or (at your option) any later version.                        *
+ *                                                                            *
+ * This software is distributed in the hope that it will be useful,           *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
+ * Lesser General Public License for more details.                            *
+ *                                                                            *
+ * You should have received a copy of the GNU Lesser General Public           *
+ * License along with this software; if not, write to the Free                *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
+ ******************************************************************************/
+package org.jboss.portal.search.test;
+
+import org.jboss.portal.search.IndexingException;
+import org.jboss.portal.search.Results;
+import org.jboss.portal.search.query.Query;
+import org.jboss.portal.search.query.impl.FieldQueryTerm;
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class LuceneQueryTest extends TestCase
+{
+
+   public void test01()
+   {
+      Query query = new Query();
+      query.addMandatoryTerm(new FieldQueryTerm("Title", "My Title"));
+      query.addMandatoryTerm(new FieldQueryTerm("id", "1"));
+      assertEquals(" +Title:\"My Title\" +id:\"1\"", LuceneUtil.convert(query));
+   }
+   
+   public void test02() throws IndexingException
+   {
+      Query query = new Query();
+      query.addMandatoryTerm(new FieldQueryTerm("id", "1"));
+      SearchFederatedLucene fed = new SearchFederatedLucene();
+      fed.create();
+      Results results = fed.search(query);
+      assertEquals("Id:1 Id:1 test ", fed.getMarkup(results, 0));
+   }
+   
+}

Added: trunk/search/src/main/org/jboss/portal/search/test/LuceneUtil.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/test/LuceneUtil.java	2006-12-13 14:29:48 UTC (rev 5826)
+++ trunk/search/src/main/org/jboss/portal/search/test/LuceneUtil.java	2006-12-13 14:38:58 UTC (rev 5827)
@@ -0,0 +1,56 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat                                               *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
+ * contributors as indicated by the @authors tag. See the                     *
+ * copyright.txt in the distribution for a full listing of                    *
+ * individual contributors.                                                   *
+ *                                                                            *
+ * This is free software; you can redistribute it and/or modify it            *
+ * under the terms of the GNU Lesser General Public License as                *
+ * published by the Free Software Foundation; either version 2.1 of           *
+ * the License, or (at your option) any later version.                        *
+ *                                                                            *
+ * This software is distributed in the hope that it will be useful,           *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
+ * Lesser General Public License for more details.                            *
+ *                                                                            *
+ * You should have received a copy of the GNU Lesser General Public           *
+ * License along with this software; if not, write to the Free                *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
+ ******************************************************************************/
+package org.jboss.portal.search.test;
+
+import java.util.Iterator;
+
+import org.jboss.portal.search.query.Query;
+import org.jboss.portal.search.query.QueryTerm;
+import org.jboss.portal.search.query.impl.FieldQueryTerm;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class LuceneUtil
+{
+
+   // TODO: actually do it...
+   public static String convert(Query query)
+   {
+      StringBuffer result = new StringBuffer();
+      Iterator it = query.getMandatoryTerms().iterator();
+      while (it.hasNext())
+      {
+         QueryTerm term = (QueryTerm) it.next();
+         if (term instanceof FieldQueryTerm)
+         {
+            FieldQueryTerm convertedTerm = (FieldQueryTerm) term;
+            result.append(" +" + convertedTerm.getName() + ":\"" + convertedTerm.getValue()+"\"");
+         }
+      }
+      
+      return result.toString();
+   }
+
+}

Added: trunk/search/src/main/org/jboss/portal/search/test/SearchFederatedLucene.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/test/SearchFederatedLucene.java	2006-12-13 14:29:48 UTC (rev 5826)
+++ trunk/search/src/main/org/jboss/portal/search/test/SearchFederatedLucene.java	2006-12-13 14:38:58 UTC (rev 5827)
@@ -0,0 +1,144 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat                                               *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
+ * contributors as indicated by the @authors tag. See the                     *
+ * copyright.txt in the distribution for a full listing of                    *
+ * individual contributors.                                                   *
+ *                                                                            *
+ * This is free software; you can redistribute it and/or modify it            *
+ * under the terms of the GNU Lesser General Public License as                *
+ * published by the Free Software Foundation; either version 2.1 of           *
+ * the License, or (at your option) any later version.                        *
+ *                                                                            *
+ * This software is distributed in the hope that it will be useful,           *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
+ * Lesser General Public License for more details.                            *
+ *                                                                            *
+ * You should have received a copy of the GNU Lesser General Public           *
+ * License along with this software; if not, write to the Free                *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
+ ******************************************************************************/
+package org.jboss.portal.search.test;
+
+import java.io.IOException;
+import java.util.Iterator;
+
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.search.Hits;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.Searcher;
+import org.jboss.portal.search.IndexingException;
+import org.jboss.portal.search.Result;
+import org.jboss.portal.search.Results;
+import org.jboss.portal.search.federation.Info;
+import org.jboss.portal.search.federation.SearchFederated;
+import org.jboss.portal.search.query.Query;
+
+/**
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class SearchFederatedLucene implements SearchFederated
+{
+
+   private IndexWriter index;
+
+   private String id;
+   
+   private Info info;
+   
+   public SearchFederatedLucene()
+   {
+      this.id = "Lucene Federated";
+      info = new Info();
+      try
+      {
+         index = new IndexWriter("Test", new StandardAnalyzer(), true);
+      }
+      catch (IOException e)
+      {
+         e.printStackTrace();
+      }
+      info.setStatus(Info.Status.STARTED);
+   }
+   
+   public void create() throws IndexingException
+   {
+      info.setStatus(Info.Status.INDEXING);
+      try
+      {
+         Document doc1 = new Document();
+         doc1.add(Field.Keyword("id", "1"));
+         index.addDocument(doc1);
+         Document doc2 = new Document();
+         doc2.add(Field.Text("id", "1 test"));
+         index.addDocument(doc2);
+         index.close();
+      }
+      catch (IOException e)
+      {
+         throw new IndexingException("Cannot index document", e);
+      }
+      info.setStatus(Info.Status.STARTED);
+   }
+
+   public void destroy()
+   {
+      info.setStatus(Info.Status.STOPPED);
+   }
+
+   public String getId()
+   {
+      return id;
+   }
+
+   public Info getInfo()
+   {
+      return info;
+   }
+
+   public Results search(Query query)
+   {
+      Results result = new Results();
+      String luceneQueryString = LuceneUtil.convert(query);
+      QueryParser parser = new QueryParser("all", new StandardAnalyzer());
+      try
+      {
+         org.apache.lucene.search.Query luceneQuery = parser.parse(luceneQueryString);
+         Searcher searcher = new IndexSearcher("Test");
+         Hits hits = searcher.search(luceneQuery);
+         for (int i=0; i<hits.length(); i++)
+         {
+            result.add(new Result(id, hits.doc(i)));
+         }
+      }
+      catch (Exception e)
+      {
+         // TODO Auto-generated catch block
+         e.printStackTrace();
+      }
+
+      return result;
+   }
+
+   public String getMarkup(Results results, int markupLevel)
+   {
+      StringBuffer buffer = new StringBuffer();
+      Iterator it = results.iterator();
+      while (it.hasNext())
+      {
+         Result result = (Result) it.next();
+         Document document = (Document)result.getValue();
+         buffer.append("Id:" + document.getField("id").stringValue());
+         buffer.append(" ");
+      }
+      return buffer.toString();
+   }
+
+}




More information about the portal-commits mailing list