You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by mo...@apache.org on 2003/06/13 00:11:36 UTC
cvs commit: jakarta-jetspeed/webapp/WEB-INF/templates/vm/portlets/html search.vm lucene-search.vm
morciuch 2003/06/12 15:11:36
Modified: build build.xml
test/conf jetspeed-test.properties
webapp/WEB-INF/conf JetspeedResources.properties
demo-portlets.xreg
Added: src/java/org/apache/jetspeed/modules/actions/portlets
SearchAction.java
src/java/org/apache/jetspeed/services/search
BaseParsedObject.java HandlerFactory.java
ObjectHandler.java ParsedObject.java
PopulateSampleIndices.java Search.java
SearchResult.java SearchResults.java
SearchService.java TestSearch.java
URLToDocHandler.java
src/java/org/apache/jetspeed/services/search/lucene
LuceneSearchService.java
test search-sample-urls.txt
webapp/WEB-INF/templates/vm/portlets/html search.vm
Removed: src/java/org/apache/jetspeed/modules/actions/portlets
LuceneSearchAction.java
src/java/org/apache/jetspeed/services/lucene
LuceneSearch.java LuceneSearchService.java
PopulateSampleIndices.java SearchResult.java
SearchResults.java TestLuceneSearch.java
test lucene-sample-urls.txt
webapp/WEB-INF/templates/vm/portlets/html lucene-search.vm
Log:
Initial refactoring of the Search Service (see Bugzilla bug# 20720). Original functionality was preserved but it's still work in progress.
Revision Changes Path
1.197 +15 -15 jakarta-jetspeed/build/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/build/build.xml,v
retrieving revision 1.196
retrieving revision 1.197
diff -u -r1.196 -r1.197
--- build.xml 5 Jun 2003 18:25:26 -0000 1.196
+++ build.xml 12 Jun 2003 22:11:32 -0000 1.197
@@ -106,7 +106,7 @@
<!-- Test settings -->
<property name="test.dir" value="test"/>
- <property name="test.lucene.dir" value="${test.dir}/LuceneIndex"/>
+ <property name="test.search.dir" value="${test.dir}/SearchIndex"/>
<!-- =================================================================== -->
<!-- Builds Classpath -->
@@ -1005,7 +1005,7 @@
<!-- =================================================================== -->
<!-- Run the client JUnit test cases (non-cactus) on the Caching system -->
<!-- =================================================================== -->
- <target name="unittest-all" depends="unittest, unittest-cache, unittest-security, unittest-search-lucene"
+ <target name="unittest-all" depends="unittest, unittest-cache, unittest-security, unittest-search"
description="Run all unit test"/>
@@ -1063,7 +1063,7 @@
<formatter type="plain" usefile="false"/>
- <test name="org.apache.jetspeed.services.lucene.TestLuceneSearch"/>
+ <test name="org.apache.jetspeed.services.search.TestSearch"/>
</junit>
</target>
<!-- =================================================================== -->
@@ -1085,10 +1085,10 @@
</target>
<!-- =================================================================== -->
- <!-- Run the client JUnit test cases (non-cactus) on the Lucene Search -->
+ <!-- Run the client JUnit test cases (non-cactus) on the Search -->
<!-- =================================================================== -->
- <target name="unittest-search-lucene" depends="compile, remove-test-lucene"
- description="Test the Lucene Search service">
+ <target name="unittest-search" depends="compile, remove-test-search"
+ description="Test the Search service">
<junit printsummary="yes" haltonfailure="yes" haltonerror="yes" fork="yes">
@@ -1101,27 +1101,27 @@
<formatter type="plain" usefile="false"/>
<!-- First always remove the Index directory before testing -->
- <test name="org.apache.jetspeed.services.lucene.TestLuceneSearch"/>
+ <test name="org.apache.jetspeed.services.search.TestSearch"/>
</junit>
</target>
- <target name="remove-test-lucene">
- <delete dir="${test.lucene.dir}"/>
+ <target name="remove-test-search">
+ <delete dir="${test.search.dir}"/>
</target>
<!-- =================================================================== -->
- <!-- Create the deployment indices for Lucene -->
+ <!-- Create the deployment indices for Search -->
<!-- The indices are already populated by default for the sample portlet -->
<!-- Run this target to recreate them to change the default sample data -->
<!-- =================================================================== -->
- <property name="sample.lucene.dir" value="${webapp.dir}/WEB-INF/LuceneIndex"/>
+ <property name="sample.search.dir" value="${webapp.dir}/WEB-INF/SearchIndex"/>
- <target name="lucene-create-indices" depends="compile"
- description="Creates sample data for Sample Lucene Portlet">
+ <target name="search-create-indices" depends="compile"
+ description="Creates sample data for Sample Search Portlet">
- <delete dir="${sample.lucene.dir}"/>
- <java fork="true" classname="org.apache.jetspeed.services.lucene.PopulateSampleIndices" >
+ <delete dir="${sample.search.dir}"/>
+ <java fork="true" classname="org.apache.jetspeed.services.search.PopulateSampleIndices" >
<classpath>
<pathelement location="${build.dest.dir}"/>
<path refid="classpath"/>
1.1 jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/portlets/SearchAction.java
Index: SearchAction.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Jetspeed" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache" or
* "Apache Jetspeed", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.jetspeed.modules.actions.portlets;
import java.util.List;
import org.apache.turbine.util.RunData;
import org.apache.velocity.context.Context;
import org.apache.jetspeed.portal.Portlet;
import org.apache.jetspeed.util.PortletSessionState;
import org.apache.jetspeed.services.search.Search;
import org.apache.jetspeed.services.search.SearchResult;
import org.apache.jetspeed.services.search.SearchResults;
/**
* Search Actions built here
*
* @author <a href="mailto:taylor@apache.org">David Sean taylor</a>
* @version $Id: SearchAction.java,v 1.1 2003/06/12 22:11:32 morciuch Exp $
*/
public class SearchAction extends GenericMVCAction
{
public final static String SEARCH_STRING = "search";
public final static String SEARCH_RESULTS = "search_results";
public final static String SEARCH_RESULTSIZE = "search_resultsize";
/**
* Subclasses must override this method to provide default behavior
* for the portlet action
*/
public void buildNormalContext(Portlet portlet,
Context context,
RunData rundata)
throws Exception
{
List results = (List)rundata.getRequest().getAttribute(SEARCH_RESULTS);
if (null == results)
{
results = (List)PortletSessionState.getAttribute(rundata, SEARCH_RESULTS);
System.out.println("session results = " + results);
}
else
{
System.out.println("qp results = " + results);
PortletSessionState.setAttribute(rundata, SEARCH_RESULTS, results);
}
if (null != results)
{
context.put(SEARCH_RESULTS, results);
}
String searchString = (String)rundata.getParameters().getString(SEARCH_STRING);
if (searchString == null || searchString.trim().length() == 0)
{
searchString = (String)PortletSessionState.getAttribute(rundata, SEARCH_STRING);
}
else
{
PortletSessionState.setAttribute(rundata, SEARCH_STRING, searchString);
}
context.put(SEARCH_STRING, searchString);
if (results != null)
{
System.out.println("size = " + results.size());
context.put(SEARCH_RESULTSIZE, new Integer(results.size()));
}
}
public void doSearch(RunData rundata, Context context)
{
// get posted new target
String searchString = (String)rundata.getParameters().getString(SEARCH_STRING);
if (searchString == null || searchString.trim().length() == 0)
{
System.out.println("No " + SEARCH_STRING + " specified");
return;
}
//
// execute the query
//
SearchResult result = null;
SearchResults results = Search.search(searchString);
System.out.println("Query hits = " + results.size());
rundata.getRequest().setAttribute(SEARCH_RESULTS, results.getResults());
}
}
1.1 jakarta-jetspeed/src/java/org/apache/jetspeed/services/search/BaseParsedObject.java
Index: BaseParsedObject.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Jetspeed" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache" or
* "Apache Jetspeed", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.jetspeed.services.search;
import java.util.Map;
import java.net.URL;
/**
* Base parsed object.
*
* @author <a href="mailto:morciuch@apache.org">Mark Orciuch</a>
* @version $Id: BaseParsedObject.java,v 1.1 2003/06/12 22:11:33 morciuch Exp $
*/
public class BaseParsedObject implements ParsedObject
{
private String title;
private String description;
private String content;
private String language;
private URL url;
private String[] keywords;
private Map fields;
/**
* Returns parsed object content
*
* @return
*/
public String getContent()
{
return this.content;
}
/**
* Sets parsed object content
*
* @param content
*/
public void setContent(String content)
{
this.content = content;
}
/**
* Returns parsed object description
*
* @return
*/
public String getDescription()
{
return this.description;
}
/**
* Sets parsed object description
*
* @param description
*/
public void setDescription(String description)
{
this.description = description;
}
/**
* Returns parsed object keywords
*
* @return
*/
public String[] getKeywords()
{
return this.keywords;
}
/**
* Sets parsed object keywords
*
* @param keywords
*/
public void setKeywords(String[] keywords)
{
this.keywords = keywords;
}
/**
* Returns parsed object title
*
* @return
*/
public String getTitle()
{
return this.title;
}
/**
* Sets parsed object title
*
* @param title
*/
public void setTitle(String title)
{
this.title = title;
}
/**
* Returns parsed object language
*
* @return
*/
public String getLanguage()
{
return this.language;
}
/**
* Sets parsed object language
*
* @param language
*/
public void setLanguage(String language)
{
this.language = language;
}
/**
* Returns parsed object searchable fields
*
* @return
*/
public Map getFields()
{
return this.fields;
}
/**
* Sets parsed object searchable fields
*
* @param fields
*/
public void setFields(Map fields)
{
this.fields = fields;
}
/**
* Returns parsed object URL
*
* @return
*/
public URL getURL()
{
return this.url;
}
/**
* Sets parsed object URL
*
* @param fields
*/
public void setURL(URL url)
{
this.url = url;
}
}
1.1 jakarta-jetspeed/src/java/org/apache/jetspeed/services/search/HandlerFactory.java
Index: HandlerFactory.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Jetspeed" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache" or
* "Apache Jetspeed", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.jetspeed.services.search;
// Turbine APIs
import org.apache.turbine.services.resources.ResourceService;
import org.apache.turbine.services.TurbineServices;
/**
* Search object handler factory
*
* @author <a href="morciuch@apache.org">Mark Orciuch</a>
*
* @version $Id: HandlerFactory.java,v 1.1 2003/06/12 22:11:33 morciuch Exp $
*/
public class HandlerFactory
{
/**
* Returns parsed object handler for specific object
*
* @param obj
* @return
*/
public static ObjectHandler getHandler(Object obj) throws Exception
{
ObjectHandler handler = null;
ResourceService serviceConf = ((TurbineServices) TurbineServices.getInstance())
.getResources(SearchService.SERVICE_NAME);
String handlerClass = serviceConf.getString("document." + obj.getClass().getName());
if (handlerClass == null)
{
throw new Exception("No handler was found for document type: " + obj.getClass().getName());
}
handler = (ObjectHandler) Class.forName(handlerClass).newInstance();
System.out.println("HandlerFactory: returning handler " + handler + " for " + obj);
return handler;
}
}
1.1 jakarta-jetspeed/src/java/org/apache/jetspeed/services/search/ObjectHandler.java
Index: ObjectHandler.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Jetspeed" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache" or
* "Apache Jetspeed", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.jetspeed.services.search;
/**
* Contract for implementing a specific object handler. Implementation
* should convert the object into a document suitable for placement into
* search index.
*
* @author <a href="mailto:morciuch@apache.org">Mark Orciuch</a>
* @version $Id: ObjectHandler.java,v 1.1 2003/06/12 22:11:33 morciuch Exp $
*/
public interface ObjectHandler
{
/**
* Parses a specific object into a document suitable for index placement
*
* @param o
* @return
*/
public ParsedObject parseObject(Object o);
}
1.1 jakarta-jetspeed/src/java/org/apache/jetspeed/services/search/ParsedObject.java
Index: ParsedObject.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Jetspeed" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache" or
* "Apache Jetspeed", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.jetspeed.services.search;
import java.util.Map;
import java.net.URL;
/**
* Contract for implementing a specific parsed object.
*
* @author <a href="mailto:morciuch@apache.org">Mark Orciuch</a>
* @version $Id: ParsedObject.java,v 1.1 2003/06/12 22:11:33 morciuch Exp $
*/
public interface ParsedObject
{
public static final String FIELDNAME_CONTENT = "fieldname.content";
public static final String FIELDNAME_CONTENT_DEFAULT = "Content";
public static final String FIELDNAME_DESCRIPTION = "fieldname.description";
public static final String FIELDNAME_DESCRIPTION_DEFAULT = "Description";
public static final String FIELDNAME_TITLE = "fieldname.title";
public static final String FIELDNAME_TITLE_DEFAULT = "Title";
public static final String FIELDNAME_LANGUAGE = "fieldname.language";
public static final String FIELDNAME_LANGUAGE_DEFAULT = "Language";
public static final String FIELDNAME_FIELDS = "fieldname.fields";
public static final String FIELDNAME_FIELDS_DEFAULT = "Fields";
public static final String FIELDNAME_KEYWORDS = "fieldname.keywords";
public static final String FIELDNAME_KEYWORDS_DEFAULT = "Keywords";
public static final String FIELDNAME_URL = "fieldname.url";
public static final String FIELDNAME_URL_DEFAULT = "URL";
/**
* Returns parsed object content (cannot be null)
*
* @return
*/
public String getContent();
/**
* Sets parsed object content (cannot be null)
*
* @param content
*/
public void setContent(String content);
/**
* Returns parsed object description (cannot be null)
*
* @return
*/
public String getDescription();
/**
* Sets parsed object description (cannot be null)
*
* @param description
*/
public void setDescription(String description);
/**
* Returns parsed object keywords
*
* @return
*/
public String[] getKeywords();
/**
* Sets parsed object keywords
*
* @param keywords
*/
public void setKeywords(String[] keywords);
/**
* Returns parsed object title (cannot be null)
*
* @return
*/
public String getTitle();
/**
* Sets parsed object title (cannot be null)
*
* @param title
*/
public void setTitle(String title);
/**
* Returns parsed object language (cannot be null)
*
* @return
*/
public String getLanguage();
/**
* Sets parsed object language (cannot be null)
*
* @param language
*/
public void setLanguage(String language);
/**
* Returns parsed object searchable fields
*
* @return
*/
public Map getFields();
/**
* Sets parsed object searchable fields
*
* @param fields
*/
public void setFields(Map fields);
/**
* Returns parsed object URL
*
* @return
*/
public URL getURL();
/**
* Sets parsed object URL
*
* @param url
*/
public void setURL(URL url);
}
1.1 jakarta-jetspeed/src/java/org/apache/jetspeed/services/search/PopulateSampleIndices.java
Index: PopulateSampleIndices.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Jetspeed" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache" or
* "Apache Jetspeed", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.jetspeed.services.search;
import java.io.BufferedReader;
import java.io.FileReader;
import java.net.URL;
import org.apache.turbine.util.TurbineConfig;
/**
* Populate sample data for Search Portlet
*
* @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
* @version $Id: PopulateSampleIndices.java,v 1.1 2003/06/12 22:11:33 morciuch Exp $
*/
public class PopulateSampleIndices
{
static public final String SAMPLE_URLS = "./test/search-sample-urls.txt";
public static void main(String args[])
{
try
{
TurbineConfig config = null;
config = new TurbineConfig( "./webapp", "/WEB-INF/conf/TurbineResources.properties");
config.init();
FileReader reader = new FileReader(SAMPLE_URLS);
BufferedReader breader = new BufferedReader(reader);
String line = null;
System.out.println("================= Populate Sample Indices =================");
System.out.println("... creates Search sample portlet test data from URLs provided in file: " + SAMPLE_URLS);
System.out.println("...");
while (null != (line = breader.readLine()))
{
System.out.println("Creating index for: " + line);
URL url = new URL(line);
Search.add(url);
}
System.out.println("===========================================================");
reader.close();
}
catch (Exception e)
{
System.out.println("Exception reading URLS" + e);
}
}
}
1.1 jakarta-jetspeed/src/java/org/apache/jetspeed/services/search/Search.java
Index: Search.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Jetspeed" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache" or
* "Apache Jetspeed", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.jetspeed.services.search;
// Java Imports
import java.io.File;
import java.net.URL;
// Turbine imports
import org.apache.turbine.services.TurbineServices;
/**
* Static accessor for the SearchService
*
* @author <a href="mailto:paulsp@apache.org">Paul Spencer</a>
* @version $Id: Search.java,v 1.1 2003/06/12 22:11:33 morciuch Exp $
*/
public abstract class Search
{
/**
* Utility method for accessing the service
* implementation
*
* @return a SearchServiceimplementation instance
*/
protected static SearchService getService()
{
return (SearchService) TurbineServices
.getInstance().getService(SearchService.SERVICE_NAME);
}
/**
* Search the default index
*
* @param searchString to use
* @return Hits
*/
public static SearchResults search(String searchString)
{
return getService().search(searchString);
}
public static boolean add(URL pageToAdd)
{
return getService().add(pageToAdd);
}
public static boolean add(Object objectToAdd)
{
return getService().add(objectToAdd);
}
public boolean addDirectory(String path, String extension)
{
File directory = new File(path);
File[] files = directory.listFiles();
for (int ix=0; ix < files.length; ix++)
{
if (files[ix].isDirectory())
{
continue;
}
// TODO: subdirectories
}
return true;
}
}
1.1 jakarta-jetspeed/src/java/org/apache/jetspeed/services/search/SearchResult.java
Index: SearchResult.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Jetspeed" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache" or
* "Apache Jetspeed", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.jetspeed.services.search;
/**
*
* @author paul
*/
public class SearchResult
{
/** Holds value of property documentURL. */
private String documentURL;
/** Holds value of property title. */
private String title;
/** Holds value of property description. */
private String description;
/** Holds value of property score. */
private float score;
/** Getter for property targetURL.
* @return Value of property targetURL.
*
*/
public String getDocumentURL()
{
return this.documentURL;
}
/** Setter for property targetURL.
* @param targetURL New value of property targetURL.
*
*/
public void setDocumentURL(String documentURL)
{
this.documentURL = documentURL;
}
/** Getter for property title.
* @return Value of property title.
*
*/
public String getTitle()
{
return this.title;
}
/** Setter for property title.
* @param title New value of property title.
*
*/
public void setTitle(String title)
{
this.title = title;
}
/** Getter for property description.
* @return Value of property description.
*
*/
public String getDescription()
{
return this.description;
}
/** Setter for property description.
* @param description New value of property description.
*
*/
public void setDescription(String description)
{
this.description = description;
}
/** Getter for property score.
* @return Value of property score.
*
*/
public float getScore()
{
return this.score;
}
/** Setter for property score.
* @param score New value of property score.
*
*/
public void setScore(float score)
{
this.score = score;
}
}
1.1 jakarta-jetspeed/src/java/org/apache/jetspeed/services/search/SearchResults.java
Index: SearchResults.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Jetspeed" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache" or
* "Apache Jetspeed", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.jetspeed.services.search;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author paul
*/
public class SearchResults
{
private List results = null;
public SearchResults()
{
init(0);
}
public SearchResults(int initialCapacity)
{
init(initialCapacity);
}
private void init(int initialCapacity)
{
results = new ArrayList(initialCapacity);
}
public boolean add(SearchResult searchResult)
{
return results.add(searchResult);
}
public void add(int index, SearchResult searchResult)
{
results.add(index, searchResult);
return;
}
public SearchResult get(int index)
{
return (SearchResult) results.get(index);
}
public int size()
{
return results.size();
}
public List getResults()
{
return this.results;
}
}
1.1 jakarta-jetspeed/src/java/org/apache/jetspeed/services/search/SearchService.java
Index: SearchService.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Jetspeed" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache" or
* "Apache Jetspeed", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.jetspeed.services.search;
/**
* Contract for implementing a search service.
*
* @author <a href="mailto:taylor@apache.org">David Sean taylor</a>
* @version $Id: SearchService.java,v 1.1 2003/06/12 22:11:33 morciuch Exp $
*/
public interface SearchService
{
/**
* Service name
*/
public static final String SERVICE_NAME = "Search";
/**
* Add index entry
*
* @param o
* @return
*/
public boolean add(Object o);
/**
* Remove index entry
*
* @param o
* @return
*/
public boolean remove(Object o);
/**
* Update indxe entry
*
* @param o
* @return
*/
public boolean update(Object o);
/**
* Search the index
*
* @param search
* @return
*/
public SearchResults search(String search);
}
1.1 jakarta-jetspeed/src/java/org/apache/jetspeed/services/search/TestSearch.java
Index: TestSearch.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Jetspeed" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache" or
* "Apache Jetspeed", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.jetspeed.services.search;
import java.net.URL;
import junit.awtui.TestRunner;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.jetspeed.services.resources.JetspeedResources;
import org.apache.jetspeed.test.HeadlessBaseTest;
/**
* Test Search Service
*
* @author <a href="paulsp@apache.org">Paul Spencer</a>
* @author <a href="taylor@apache.org">David Sean Taylor</a>
*
* @version $Id: TestSearch.java,v 1.1 2003/06/12 22:11:33 morciuch Exp $
*/
public class TestSearch extends HeadlessBaseTest
{
/**
* Defines the testcase name for JUnit.
*
* @param name the testcase's name.
*/
public TestSearch(String name)
{
super(name);
}
/**
* Start the tests.
*
* @param args the arguments. Not used
*/
public static void main(String args[])
{
TestRunner.main(new String[] { TestSearch.class.getName() });
}
/**
* Creates the test suite.
*
* @return a test suite (<code>TestSuite</code>) that includes all methods
* starting with "test"
*/
public static Test suite()
{
// All methods starting with "test" will be executed in the test suite.
return new TestSuite(TestSearch.class);
}
public void testPutWebPage() throws Exception
{
System.out.println("search home = " + JetspeedResources.getString("services.SearchService.directory"));
URL jetspeedHomePage = new URL("http://jakarta.apache.org/jetspeed");
assertNotNull("Created URL to Jetspeed Home Page", jetspeedHomePage);
assertTrue("Adding to index", Search.add(jetspeedHomePage));
assertTrue("Adding to index", Search.add(new URL("http://www.google.com")));
assertTrue("Adding to index", Search.add(new URL("http://jakarta.apache.org")));
}
/**
*
* @throws Exception
*/
public void testVerifyJetspeedSearch() throws Exception
{
SearchResult result = null;
SearchResults results = Search.search("rss");
System.out.println("Query 'rss' hits = " + results.size());
assertTrue(" Hit count > 0", results.size() > 0);
for (int i = 0; i < results.size(); i++)
{
result = results.get(i);
System.out.println("Score = " + result.getScore());
System.out.println("title = " + result.getTitle());
System.out.println("summary = " + result.getDescription());
System.out.println("url = " + result.getDocumentURL());
}
}
public void testVerifyJetspeedSearch1() throws Exception
{
SearchResult result = null;
SearchResults results = Search.search("Jetspeed");
System.out.println("Query 'Jetspeed' hits = " + results.size());
assertTrue(" Hit count > 0", results.size() > 0);
for (int i = 0; i < results.size(); i++)
{
result = results.get(i);
System.out.println("Score = " + result.getScore());
System.out.println("title = " + result.getTitle());
System.out.println("summary = " + result.getDescription());
System.out.println("url = " + result.getDocumentURL());
}
}
public void testVerifyJetspeedSearch2() throws Exception
{
SearchResult result = null;
SearchResults results = Search.search("google");
System.out.println("Query 'goggle' hits = " + results.size());
assertTrue(" Hit count > 0", results.size() > 0);
for (int i = 0; i < results.size(); i++)
{
result = results.get(i);
System.out.println("Score = " + result.getScore());
System.out.println("title = " + result.getTitle());
System.out.println("summary = " + result.getDescription());
System.out.println("url = " + result.getDocumentURL());
}
}
}
1.1 jakarta-jetspeed/src/java/org/apache/jetspeed/services/search/URLToDocHandler.java
Index: URLToDocHandler.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Jetspeed" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache" or
* "Apache Jetspeed", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.jetspeed.services.search;
// Java imports
import java.io.IOException;
import java.net.URL;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.methods.GetMethod;
// Turbine APIs
import org.apache.turbine.util.Log;
/**
* This object handler deals with URLs.
*
* @author <a href="mailto:morciuch@apache.org">Mark Orciuch</a>
* @version $Id: URLToDocHandler.java,v 1.1 2003/06/12 22:11:33 morciuch Exp $
*/
public class URLToDocHandler implements ObjectHandler
{
/**
* Parses a specific object into a document suitable for index placement
*
* @param o
* @return
*/
public ParsedObject parseObject(Object o)
{
ParsedObject result = new BaseParsedObject();
if ((o instanceof URL) == false)
{
Log.error("URLToDocHandler: invalid object type: " + o);
return null;
}
URL pageToAdd = (URL) o;
HttpClient client = new HttpClient();
client.startSession(pageToAdd);
GetMethod method = new GetMethod(pageToAdd.getPath());
method.setFollowRedirects(true);
int statusCode = -1;
int attempt = 0;
// We will retry up to 3 times.
while (statusCode == -1 && attempt < 3)
{
try
{
// execute the method.
client.executeMethod(method);
statusCode = method.getStatusCode();
Log.debug("URL = " + pageToAdd.toString() + "Status code = " + statusCode);
}
catch (HttpException e)
{
// We will retry
}
catch (IOException e)
{
return null;
}
}
// Check that we didn't run out of retries.
if (statusCode != -1)
{
String content = null;
try
{
content = method.getDataAsString();
}
catch (IOException ioe)
{
Log.error("Getting content for " + pageToAdd.toString(), ioe);
}
if (content != null)
{
try
{
// TODO: We should extract the <title> tag here.
result.setTitle(pageToAdd.toString());
result.setContent(content);
result.setDescription("");
result.setLanguage("");
result.setURL(pageToAdd);
Log.info("Parsed '" + pageToAdd.toString() + "'");
}
catch (Exception e)
{
e.printStackTrace();
Log.error("Adding document to index", e);
}
}
}
try
{
client.endSession();
}
catch (IOException ioe)
{
ioe.printStackTrace();
Log.error("Ending session to " + pageToAdd.toString(), ioe);
}
return result;
}
}
1.1 jakarta-jetspeed/src/java/org/apache/jetspeed/services/search/lucene/LuceneSearchService.java
Index: LuceneSearchService.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Jetspeed" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache" or
* "Apache Jetspeed", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.jetspeed.services.search.lucene;
// Java imports
import java.io.File;
import java.io.IOException;
import java.net.URL;
import javax.servlet.ServletConfig;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.methods.GetMethod;
// Jetspeed imports
import org.apache.jetspeed.services.search.HandlerFactory;
import org.apache.jetspeed.services.search.ObjectHandler;
import org.apache.jetspeed.services.search.ParsedObject;
// Turbine imports
import org.apache.turbine.services.InitializationException;
import org.apache.turbine.services.resources.ResourceService;
import org.apache.turbine.services.servlet.TurbineServlet;
import org.apache.turbine.services.TurbineBaseService;
import org.apache.turbine.services.TurbineServices;
import org.apache.turbine.util.Log;
// Lucene imports
import org.apache.jetspeed.services.search.SearchResult;
import org.apache.jetspeed.services.search.SearchResults;
import org.apache.jetspeed.services.search.SearchService;
import org.apache.lucene.analysis.Analyzer;
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.IndexSearcher;
import org.apache.lucene.search.Hits;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.Searcher;
/**
* Lucene implementation of search service.
*
* @author <a href="mailto:taylor@apache.org">David Sean taylor</a>
* @author <a href="mailto:caius1440@hotmail.com">Jeremy Ford</a>
* @author <a href="mailto:morciuch@apache.org">Mark Orciuch</a>
* @version $Id: LuceneSearchService.java,v 1.1 2003/06/12 22:11:33 morciuch Exp $
*/
public class LuceneSearchService extends TurbineBaseService implements SearchService
{
private static final String CONFIG_DIRECTORY = "directory";
private static final String CONFIG_CONTENT_FIELDNAME = "fieldname.content";
private static final String CONFIG_CONTENT_FIELDNAME_DEFAULT = "Content";
private static final String CONFIG_DESCRIPTION_FIELDNAME = "fieldname.description";
private static final String CONFIG_DESCRIPTION_FIELDNAME_DEFAULT = "Description";
private static final String CONFIG_TITLE_FIELDNAME = "fieldname.title";
private static final String CONFIG_TITLE_FIELDNAME_DEFAULT = "Title";
private static final String CONFIG_URL_FIELDNAME = "fieldname.url";
private static final String CONFIG_URL_FIELDNAME_DEFAULT = "URL";
private String contentFieldName = null;
private String descriptionFieldName = null;
private File rootDir = null;
private String indexRoot = null;
// private Searcher searcher = null;
private String titleFieldName = null;
private String urlFieldName = null;
/**
* This is the early initialization method called by the
* Turbine <code>Service</code> framework
* @param conf The <code>ServletConfig</code>
* @exception throws a <code>InitializationException</code> if the service
* fails to initialize
*/
public synchronized void init(ServletConfig conf) throws InitializationException
{
// already initialized
if (getInit())
{
return;
}
initConfiguration(conf);
// initialization done
setInit(true);
}
/**
* This is the lateinitialization method called by the
* Turbine <code>Service</code> framework
*
* @exception throws a <code>InitializationException</code> if the service
* fails to initialize
*/
public void init() throws InitializationException
{
Log.info("Late init for " + SearchService.SERVICE_NAME + " called");
while (!getInit())
{
//Not yet...
try
{
Thread.sleep(100);
Log.info("Waiting for init of " + SearchService.SERVICE_NAME + "...");
}
catch (InterruptedException ie)
{
Log.error(ie);
}
}
}
/**
* This is the shutdown method called by the
* Turbine <code>Service</code> framework
*/
public void shutdown()
{
}
/**
* Loads the configuration parameters for this service from the
* JetspeedResources.properties file.
*
* @exception throws a <code>InitializationException</code> if the service
* fails to initialize
*/
private void initConfiguration(ServletConfig conf) throws InitializationException
{
if (getInit())
{
return;
}
// get configuration parameters from Jetspeed Resources
ResourceService serviceConf = ((TurbineServices) TurbineServices.getInstance())
.getResources(SearchService.SERVICE_NAME);
// Get config properties
contentFieldName = serviceConf.getString(CONFIG_CONTENT_FIELDNAME, CONFIG_CONTENT_FIELDNAME_DEFAULT);
descriptionFieldName = serviceConf.getString(CONFIG_DESCRIPTION_FIELDNAME, CONFIG_DESCRIPTION_FIELDNAME_DEFAULT);
titleFieldName = serviceConf.getString(CONFIG_TITLE_FIELDNAME, CONFIG_TITLE_FIELDNAME_DEFAULT);
urlFieldName = serviceConf.getString(CONFIG_URL_FIELDNAME, CONFIG_URL_FIELDNAME_DEFAULT);
indexRoot = serviceConf.getString(CONFIG_DIRECTORY);
//
// The following section opens or creates the search index
//
//
rootDir = new File(indexRoot);
//If the rootDir does not exist, treat it as context relative
if (!rootDir.exists())
{
if (indexRoot != null)
{
String rootDirPath = TurbineServlet.getRealPath("") + indexRoot;
rootDir = new File(rootDirPath);
if (!rootDir.exists())
{
rootDir.mkdir();
Log.info("Created index directory '" + rootDir.getPath() + "'");
}
}
}
try
{
Searcher searcher = null;
searcher = new IndexSearcher(rootDir.getPath());
searcher.close();
}
catch (Exception e)
{
try
{
IndexWriter indexWriter = new IndexWriter(rootDir, new StandardAnalyzer(), true);
indexWriter.close();
indexWriter = null;
Log.info("Created Lucene Index in " + rootDir.getPath());
}
catch (Exception e1)
{
Log.error(this.getClass().getName() + ".initConfiguration - Getting or creating IndexSearcher");
Log.error(e);
throw new InitializationException("Getting or creating Index Searcher");
}
}
//Mark that we are done
setInit(true);
}
/**
* Search
*
* @param searchString is the what is being searched for
* @return Hits, if no hits then null.
*
* @task Parse content into title and description fields
*/
public SearchResults search(String searchString)
{
Searcher searcher = null;
Hits hits = null;
try
{
searcher = new IndexSearcher(rootDir.getPath());
Analyzer analyzer = new StandardAnalyzer();
Query query = QueryParser.parse(searchString, ParsedObject.FIELDNAME_CONTENT, analyzer);
hits = searcher.search(query);
}
catch (Exception e)
{
e.printStackTrace();
Log.error(e);
}
// Copy hits to the result list
int hitCount = hits.length();
Document doc = null;
SearchResults results = new SearchResults(hitCount);
for (int counter = 0; counter < hitCount; counter++)
{
SearchResult result = new SearchResult();
try
{
doc = hits.doc(counter);
result.setScore(hits.score(counter));
result.setDescription(doc.getField(ParsedObject.FIELDNAME_DESCRIPTION).toString());
result.setTitle(doc.getField(ParsedObject.FIELDNAME_TITLE).toString());
result.setDocumentURL(doc.getField(ParsedObject.FIELDNAME_URL).stringValue());
results.add(counter, result);
}
catch (IOException ioe)
{
Log.error(ioe);
}
result = null;
}
if (searcher != null)
{
try
{
searcher.close();
}
catch (IOException ioe)
{
Log.error("Closing Searcher", ioe);
}
}
return results;
}
public String[] getSearchSets()
{
return null;
}
/* (non-Javadoc)
* @see org.apache.jetspeed.services.search.SearchService#add(java.lang.Object)
*/
public boolean add(Object o)
{
boolean result = false;
try
{
// Look up appropriate handler
ObjectHandler handler = HandlerFactory.getHandler(o);
// Parse the object
ParsedObject parsedObject = handler.parseObject(o);
// Create document
Document doc = new Document();
// Populate document from the parsed object
doc.add(Field.Text(ParsedObject.FIELDNAME_TITLE, parsedObject.getTitle()));
doc.add(Field.Text(ParsedObject.FIELDNAME_DESCRIPTION, parsedObject.getDescription()));
doc.add(Field.Text(ParsedObject.FIELDNAME_CONTENT, parsedObject.getContent()));
doc.add(Field.Text(ParsedObject.FIELDNAME_LANGUAGE, parsedObject.getLanguage()));
doc.add(Field.Text(ParsedObject.FIELDNAME_URL, parsedObject.getURL().toString()));
// TODO: How to handle keywords and fields
/*String[] keywords = parsedObject.getKeywords();
if (keywords != null)
{
for (int i = 0; i < keywords.length; i++)
{
doc.add(Field.Keyword();
}
} */
// Add the document to search index
IndexWriter indexWriter = new IndexWriter(rootDir, new StandardAnalyzer(), false);
indexWriter.addDocument(doc);
Log.debug("Index Document Count = " + indexWriter.docCount());
indexWriter.optimize();
indexWriter.close();
Log.info("Added '" + parsedObject.getTitle() + "' to index");
result = true;
}
catch (Exception e)
{
Log.error(e);
}
return result;
}
/* (non-Javadoc)
* @see org.apache.jetspeed.services.search.SearchService#remove(java.lang.Object)
*/
public boolean remove(Object o)
{
// TODO Auto-generated method stub
return false;
}
/* (non-Javadoc)
* @see org.apache.jetspeed.services.search.SearchService#update(java.lang.Object)
*/
public boolean update(Object o)
{
// TODO Auto-generated method stub
return false;
}
}
1.1 jakarta-jetspeed/test/search-sample-urls.txt
Index: search-sample-urls.txt
===================================================================
http://jakarta.apache.org/jetspeed/site/index.html
http://jakarta.apache.org/jetspeed/site/features.html
http://jakarta.apache.org/jetspeed/site/license.html
http://jakarta.apache.org/jetspeed/site/install.html
http://jakarta.apache.org/jetspeed/site/faq.html
http://jakarta.apache.org/jetspeed/site/usejetspeed.html
http://jakarta.apache.org/jetspeed/site/resources.html
http://jakarta.apache.org/jetspeed/site/todo.html
http://jakarta.apache.org/jetspeed/site/changes.html
http://jakarta.apache.org/site/binindex.html
http://jakarta.apache.org/site/sourceindex.html
http://jakarta.apache.org/jetspeed/site/supporting-projects.html
http://jakarta.apache.org/jetspeed/site/config_guide.html
http://jakarta.apache.org/jetspeed/site/application-development.html
http://jakarta.apache.org/jetspeed/site/portlet_config_HTML.html
http://jakarta.apache.org/jetspeed/site/portlet_config_JSP.html
http://jakarta.apache.org/jetspeed/site/portlet_config_RSS.html
http://jakarta.apache.org/jetspeed/site/portlet_config_Velocity.html
http://jakarta.apache.org/jetspeed/site/portlet_config_WebPagePortlet.html
http://jakarta.apache.org/jetspeed/site/portlet_config_XSL.html
http://jakarta.apache.org/jetspeed/site/portlet_config_DBBrowser.html
http://jakarta.apache.org/jetspeed/site/portlet_config_common.html
http://jakarta.apache.org/jetspeed/site/registry.html
http://jakarta.apache.org/jetspeed/site/registry_xml.html
http://jakarta.apache.org/jetspeed/site/administration.html
http://jakarta.apache.org/jetspeed/site/security.html
http://jakarta.apache.org/jetspeed/site/content-syndication.html
http://jakarta.apache.org/jetspeed/site/wap.html
http://jakarta.apache.org/jetspeed/site/customizer.html
http://jakarta.apache.org/jetspeed/site/diskcache.html
http://jakarta.apache.org/jetspeed/site/psml.html
http://jakarta.apache.org/jetspeed/site/psml_db.html
http://jakarta.apache.org/jetspeed/site/forwards.html
http://jakarta.apache.org/jetspeed/site/contributors.html
http://jakarta.apache.org/site/cvsindex.html
http://jakarta.apache.org/jetspeed/site/code-standards.html
http://www.bluesunrise.com/jetspeed-docs/JetspeedTutorial.htm
1.2 +2 -2 jakarta-jetspeed/test/conf/jetspeed-test.properties
Index: jetspeed-test.properties
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/test/conf/jetspeed-test.properties,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- jetspeed-test.properties 19 May 2003 23:18:58 -0000 1.1
+++ jetspeed-test.properties 12 Jun 2003 22:11:35 -0000 1.2
@@ -1,5 +1,5 @@
-# override the Lucene Index for unit testing
-services.LuceneSearch.directory=../../test/LuceneIndex/
+# override the Search Index for unit testing
+services.Search.directory=../../test/SearchIndex/
include = ../../webapp/WEB-INF/conf/TurbineResources.properties
include = ../../webapp/WEB-INF/conf/JetspeedResources.properties
include = ../../webapp/WEB-INF/conf/JetspeedSecurity.properties
1.101 +8 -5 jakarta-jetspeed/webapp/WEB-INF/conf/JetspeedResources.properties
Index: JetspeedResources.properties
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/webapp/WEB-INF/conf/JetspeedResources.properties,v
retrieving revision 1.100
retrieving revision 1.101
diff -u -r1.100 -r1.101
--- JetspeedResources.properties 4 Jun 2003 15:59:14 -0000 1.100
+++ JetspeedResources.properties 12 Jun 2003 22:11:35 -0000 1.101
@@ -263,7 +263,7 @@
autocreate.portlets=false
#########################################
-# IdGenerator Service #
+# IdGenerator Service #
#########################################
# Classname of the ID Generation implemented as a Turbine service.
services.IdGenerator.classname=org.apache.jetspeed.services.idgenerator.JetspeedIdGeneratorService
@@ -280,11 +280,14 @@
services.IdGenerator.peid.suffix=
#########################################
-# LuceneSearch #
+# Search #
#########################################
# Classname of the ID Generation implemented as a Turbine service.
-services.LuceneSearch.classname=org.apache.jetspeed.services.lucene.LuceneSearchService
-services.LuceneSearch.directory=/WEB-INF/LuceneIndex
+services.Search.classname=org.apache.jetspeed.services.search.lucene.LuceneSearchService
+services.Search.directory=/WEB-INF/SearchIndex
+
+services.Search.document.java.net.URL = org.apache.jetspeed.services.search.URLToDocHandler
+services.Search.document.org.apache.jetspeed.om.registry.PortletEntry = org.apache.jetspeed.services.search.PortletToDocHandler
#########################################
# ThreadPool Service #
1.37 +4 -5 jakarta-jetspeed/webapp/WEB-INF/conf/demo-portlets.xreg
Index: demo-portlets.xreg
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/webapp/WEB-INF/conf/demo-portlets.xreg,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- demo-portlets.xreg 10 Jun 2003 17:36:56 -0000 1.36
+++ demo-portlets.xreg 12 Jun 2003 22:11:35 -0000 1.37
@@ -585,17 +585,16 @@
<category>demo</category>
<category>forward</category>
</portlet-entry>
- <portlet-entry name="LuceneSearch" hidden="false" type="ref" application="false" parent="GenericMVCPortlet">
+ <portlet-entry name="Search" hidden="false" type="ref" application="false" parent="GenericMVCPortlet">
<meta-info>
- <title>Lucene Search Portlet</title>
+ <title>Search Portlet</title>
<description>Sample Search Portlet to index and search web sites</description>
</meta-info>
- <parameter name="template" value="lucene-search" hidden="true"/>
+ <parameter name="template" value="search" hidden="true"/>
<parameter name="viewtype" value="Velocity" hidden="true"/>
- <parameter name="action" value="portlets.LuceneSearchAction" hidden="true"/>
+ <parameter name="action" value="portlets.SearchAction" hidden="true"/>
<media-type ref="html"/>
<category>search</category>
- <category>lucene</category>
</portlet-entry>
</registry>
1.1 jakarta-jetspeed/webapp/WEB-INF/templates/vm/portlets/html/search.vm
Index: search.vm
===================================================================
<form action="$jslink.setAction('portlets.SearchAction')" method="POST">
<INPUT TYPE='hidden' VALUE='' NAME='listIndex'>
<table border="0" cellpadding="0" cellspacing="0" width="75%">
<tr>
<td><font size="-2"> </font></td>
<td class="blackline">
<table border="0" cellpadding="0" cellspacing="1" width="100%">
<tr>
<td>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td class="$!{skin.ContentStyleClass}" colspan="4" align="right"> </td></tr>
<tr>
<td width="5%" class="$!{skin.ContentStyleClass}" align="left"> </td>
<td class="$!{skin.ContentStyleClass}" align="left">Search Content:</td>
<td class="$!{skin.ContentStyleClass}" align="left">
<input tabindex='1' id="search" type="text" name="search" size="50" value="$!search"/>
<input type="submit"
border="0" alt="Search" value="Search" name="eventSubmit_doSearch"/>
</td>
<td width="5%" class="$!{skin.ContentStyleClass}" align="left"> </td>
</tr>
<tr><td class="$!{skin.ContentStyleClass}" colspan="4" align="right"> </td></tr>
<tr><td colspan="4" class="blackline"/></tr>
<tr>
<td colspan="4">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="80%" class="$!{skin.HighlightTitleStyleClass}" align="left"> URL</td>
</tr>
#set ($listIndex = 1)
#foreach ($result in $search_results)
<tr><td colspan="5" class="blackline"/></tr>
<tr>
<td class="$!{skin.ContentStyleClass}" align="left">
<a id="preview_$listIndex"
href="$result.DocumentURL" target="_blank">
<span class="$!{skin.ContentStyleClass}">$result.DocumentURL</span>
</a>
</td>
</tr>
#set ($listIndex = $listIndex + 1)
#end
#if ($!search_resultsize == 0)
<tr>
<td class="$!{skin.ContentStyleClass}" align="left">No matching hits found for given search criteria</td>
</tr>
#end
<tr><td colspan="5" class="blackline"/></tr>
<tr><td class="$!{skin.ContentStyleClass}" colspan="5" align="right"> </td></tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
<br/>
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org