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/16 21:05:02 UTC

cvs commit: jakarta-jetspeed/webapp/images is_url.gif

morciuch    2003/06/16 12:05:01

  Modified:    src/java/org/apache/jetspeed/modules/actions/portlets
                        SearchAction.java
               src/java/org/apache/jetspeed/services/search
                        BaseParsedObject.java HandlerFactory.java
                        ParsedObject.java Search.java SearchResults.java
                        SearchService.java TestSearch.java
               src/java/org/apache/jetspeed/services/search/lucene
                        LuceneSearchService.java
               webapp/WEB-INF/conf JetspeedResources.properties admin.xreg
               webapp/WEB-INF/psml/user/admin/html default.psml
               webapp/WEB-INF/templates/vm/portlets/html search.vm
  Added:       src/java/org/apache/jetspeed/services/search/handlers
                        PortletEntryToDocHandler.java
                        PortletToDocHandler.java
                        RegistryEntryToDocHandler.java URLToDocHandler.java
               webapp/WEB-INF/templates/vm/portlets/html index-registry.vm
               webapp/images is_url.gif
  Removed:     src/java/org/apache/jetspeed/services/search
                        SearchResult.java URLToDocHandler.java
  Log:
  Added indexing of portlet registry (se Bugzilla bug# 20720). Remaining issues:
  
  1. Search.remove does not work
  2. Implement indexing of portlet urls
  
  Revision  Changes    Path
  1.2       +7 -8      jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/portlets/SearchAction.java
  
  Index: SearchAction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/portlets/SearchAction.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SearchAction.java	12 Jun 2003 22:11:32 -0000	1.1
  +++ SearchAction.java	16 Jun 2003 19:05:00 -0000	1.2
  @@ -60,7 +60,7 @@
   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.ParsedObject;
   import org.apache.jetspeed.services.search.SearchResults;
   
   /**
  @@ -89,12 +89,12 @@
           if (null == results)
           {
               results = (List)PortletSessionState.getAttribute(rundata, SEARCH_RESULTS);
  -            System.out.println("session results = " + results); 
  +            //System.out.println("session results = " + results); 
               
           }
           else
           {
  -            System.out.println("qp results = " + results);
  +            //System.out.println("qp results = " + results);
               PortletSessionState.setAttribute(rundata, SEARCH_RESULTS, results);
           }
           
  @@ -117,7 +117,7 @@
           
           if (results != null)
           {
  -            System.out.println("size = " + results.size());
  +            //System.out.println("size = " + results.size());
               context.put(SEARCH_RESULTSIZE, new Integer(results.size()));
           }
       }
  @@ -129,16 +129,15 @@
           
           if (searchString == null || searchString.trim().length() == 0)
           {
  -            System.out.println("No " + SEARCH_STRING + " specified");
               return;
           }
           
           //
           // execute the query
           //
  -        SearchResult result = null;
  +        ParsedObject result = null;
           SearchResults results  = Search.search(searchString);
  -        System.out.println("Query hits = " + results.size());
  +        //System.out.println("Query hits = " + results.size());
           rundata.getRequest().setAttribute(SEARCH_RESULTS, results.getResults());                
       }
   
  
  
  
  1.2       +65 -1     jakarta-jetspeed/src/java/org/apache/jetspeed/services/search/BaseParsedObject.java
  
  Index: BaseParsedObject.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/search/BaseParsedObject.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BaseParsedObject.java	12 Jun 2003 22:11:33 -0000	1.1
  +++ BaseParsedObject.java	16 Jun 2003 19:05:00 -0000	1.2
  @@ -65,6 +65,8 @@
   public class BaseParsedObject implements ParsedObject
   {
   
  +    private String key;
  +    private String type;
       private String title;
       private String description;
       private String content;
  @@ -72,6 +74,47 @@
       private URL url;
       private String[] keywords;
       private Map fields;
  +    private float score;
  +
  +    /**
  +     * Returns parsed object key
  +     * 
  +     * @return 
  +     */
  +    public String getKey()
  +    {
  +        return this.key;
  +    }
  +
  +    /**
  +     * Sets parsed object key
  +     * 
  +     * @param content
  +     */
  +    public void setKey(String key)
  +    {
  +        this.key = key;
  +    }
  +
  +    /**
  +     * Returns parsed object type
  +     * 
  +     * @return 
  +     */
  +    public String getType()
  +    {
  +        return this.type;
  +    }
  +
  +    /**
  +     * Sets parsed object type
  +     * 
  +     * @param type
  +     */
  +    public void setType(String type)
  +    {
  +        this.type = type;
  +    }
   
       /**
        * Returns parsed object content
  @@ -212,5 +255,26 @@
       {
           this.url = url;
       }
  +
  +    /**
  +     * 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.2       +2 -2      jakarta-jetspeed/src/java/org/apache/jetspeed/services/search/HandlerFactory.java
  
  Index: HandlerFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/search/HandlerFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- HandlerFactory.java	12 Jun 2003 22:11:33 -0000	1.1
  +++ HandlerFactory.java	16 Jun 2003 19:05:00 -0000	1.2
  @@ -88,7 +88,7 @@
   
           handler = (ObjectHandler) Class.forName(handlerClass).newInstance();
   
  -        System.out.println("HandlerFactory: returning handler " + handler + " for " + obj);
  +        //System.out.println("HandlerFactory: returning handler " + handler + " for " + obj);
   
           return handler;
   
  
  
  
  1.2       +54 -1     jakarta-jetspeed/src/java/org/apache/jetspeed/services/search/ParsedObject.java
  
  Index: ParsedObject.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/search/ParsedObject.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ParsedObject.java	12 Jun 2003 22:11:33 -0000	1.1
  +++ ParsedObject.java	16 Jun 2003 19:05:00 -0000	1.2
  @@ -65,6 +65,10 @@
   public interface ParsedObject
   {
   
  +    public static final String FIELDNAME_KEY = "fieldname.key";
  +    public static final String FIELDNAME_KEY_DEFAULT = "Key";
  +    public static final String FIELDNAME_TYPE = "fieldname.type";
  +    public static final String FIELDNAME_TYPE_DEFAULT = "Type";
       public static final String FIELDNAME_CONTENT = "fieldname.content";
       public static final String FIELDNAME_CONTENT_DEFAULT = "Content";
       public static final String FIELDNAME_DESCRIPTION = "fieldname.description";
  @@ -79,6 +83,41 @@
       public static final String FIELDNAME_KEYWORDS_DEFAULT = "Keywords";
       public static final String FIELDNAME_URL = "fieldname.url";
       public static final String FIELDNAME_URL_DEFAULT = "URL";
  +    public static final String FIELDNAME_SCORE = "fieldname.score";
  +    public static final String FIELDNAME_SCORE_DEFAULT = "Score";
  +
  +    // Known object types
  +    public static final String OBJECT_TYPE_URL = "url";
  +    public static final String OBJECT_TYPE_PORTLET = "portlet";
  +    public static final String OBJECT_TYPE_PDF = "pdf";
  +
  +    /**
  +     * Returns parsed object key (cannot be null)
  +     * 
  +     * @return 
  +     */
  +    public String getKey();
  +
  +    /**
  +     * Sets parsed object key (cannot be null)
  +     * 
  +     * @param type
  +     */
  +    public void setKey(String key);
  +
  +    /**
  +     * Returns parsed object type (cannot be null)
  +     * 
  +     * @return 
  +     */
  +    public String getType();
  +
  +    /**
  +     * Sets parsed object type (cannot be null)
  +     * 
  +     * @param type
  +     */
  +    public void setType(String type);
   
       /**
        * Returns parsed object content (cannot be null)
  @@ -177,6 +216,20 @@
        * @param url
        */
       public void setURL(URL url);
  +
  +    /**
  +     * Getter for property score.
  +     * 
  +     * @return Value of property score.
  +     */
  +    public float getScore();
  +    
  +    /**
  +     * Setter for property score.
  +     * 
  +     * @param score  New value of property score.
  +     */
  +    public void setScore(float score);
   
   }
   
  
  
  
  1.2       +42 -5     jakarta-jetspeed/src/java/org/apache/jetspeed/services/search/Search.java
  
  Index: Search.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/search/Search.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Search.java	12 Jun 2003 22:11:33 -0000	1.1
  +++ Search.java	16 Jun 2003 19:05:00 -0000	1.2
  @@ -57,6 +57,7 @@
   // Java Imports
   import java.io.File;
   import java.net.URL;
  +import java.util.Collection;
   
   // Turbine imports
   import org.apache.turbine.services.TurbineServices;
  @@ -94,16 +95,52 @@
           return getService().search(searchString);
       }
   
  -    public static boolean add(URL pageToAdd)
  +    /**
  +     * 
  +     * @param o
  +     * @return 
  +     */
  +    public static boolean remove(Object o)
  +    {
  +        return getService().remove(o);
  +    }
  +
  +    /**
  +     * 
  +     * @param c
  +     * @return 
  +     */
  +    public static boolean remove(Collection c)
  +    {
  +        return getService().remove(c);
  +    }
  +
  +    /**
  +     * 
  +     * @param o
  +     * @return 
  +     */
  +    public static boolean add(Object o)
       {
  -        return getService().add(pageToAdd);
  +        return getService().add(o);
       }
   
  -    public static boolean add(Object objectToAdd)
  +    /**
  +     * 
  +     * @param c
  +     * @return 
  +     */
  +    public static boolean add(Collection c)
       {
  -        return getService().add(objectToAdd);
  +        return getService().add(c);
       }
   
  +    /**
  +     * 
  +     * @param path
  +     * @param extension
  +     * @return 
  +     */
       public boolean addDirectory(String path, String extension)
       {
           File directory = new File(path); 
  
  
  
  1.2       +52 -16    jakarta-jetspeed/src/java/org/apache/jetspeed/services/search/SearchResults.java
  
  Index: SearchResults.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/search/SearchResults.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SearchResults.java	12 Jun 2003 22:11:33 -0000	1.1
  +++ SearchResults.java	16 Jun 2003 19:05:00 -0000	1.2
  @@ -59,48 +59,84 @@
   
   
   /**
  -*
  - * @author  paul
  + * Container for search result entries
  + *
  + * @author <a href="mailto:taylor@apache.org">David Sean taylor</a>
  + * @version $Id$
    */
   public class SearchResults
   {
       private List results = null;
  -    
  +
  +    /**
  +     */
       public SearchResults()
       {
           init(0);
       }
  +
  +    /**
  +     * 
  +     * @param initialCapacity
  +     */
       public SearchResults(int initialCapacity)
       {
           init(initialCapacity);
       }
  -    
  +
  +    /**
  +     * 
  +     * @param initialCapacity
  +     */
       private void init(int initialCapacity)
       {
           results = new ArrayList(initialCapacity);
       }
  -    
  -    public boolean add(SearchResult searchResult)
  +
  +    /**
  +     * 
  +     * @param searchResult
  +     * @return 
  +     */
  +    public boolean add(ParsedObject searchResult)
       {
           return results.add(searchResult);
       }
  -    
  -    public void add(int index, SearchResult searchResult)
  +
  +    /**
  +     * 
  +     * @param index
  +     * @param searchResult
  +     */
  +    public void add(int index, ParsedObject searchResult)
       {
           results.add(index, searchResult);
           return;
       }
  -    
  -    public SearchResult get(int index)
  -    {
  -      return (SearchResult) results.get(index);
  -    }
  -    
  +
  +    /**
  +     * 
  +     * @param index
  +     * @return 
  +     */
  +    public ParsedObject get(int index)
  +    {
  +        return(ParsedObject) results.get(index);
  +    }
  +
  +    /**
  +     * 
  +     * @return 
  +     */
       public int size()
  -    { 
  +    {
           return results.size();
       }
  -    
  +
  +    /**
  +     * 
  +     * @return 
  +     */
       public List getResults()
       {
           return this.results;
  
  
  
  1.2       +28 -2     jakarta-jetspeed/src/java/org/apache/jetspeed/services/search/SearchService.java
  
  Index: SearchService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/search/SearchService.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SearchService.java	12 Jun 2003 22:11:33 -0000	1.1
  +++ SearchService.java	16 Jun 2003 19:05:00 -0000	1.2
  @@ -53,6 +53,8 @@
    */
   package org.apache.jetspeed.services.search;
   
  +import java.util.Collection;
  +
   /**
    * Contract for implementing a search service.
    *
  @@ -75,6 +77,14 @@
       public boolean add(Object o);
   
       /**
  +     * Add collection of index entries
  +     * 
  +     * @param c
  +     * @return 
  +     */
  +    public boolean add(Collection c);
  +
  +    /**
        * Remove index entry
        * 
        * @param o
  @@ -83,12 +93,28 @@
       public boolean remove(Object o);
   
       /**
  -     * Update indxe entry
  +     * Remove collection of index entries
  +     * 
  +     * @param c
  +     * @return 
  +     */
  +    public boolean remove(Collection c);
  +
  +    /**
  +     * Update index entry
        * 
        * @param o
        * @return 
        */
       public boolean update(Object o);
  +
  +    /**
  +     * Update index entries
  +     * 
  +     * @param c
  +     * @return 
  +     */
  +    public boolean update(Collection c);
   
       /**
        * Search the index
  
  
  
  1.2       +18 -7     jakarta-jetspeed/src/java/org/apache/jetspeed/services/search/TestSearch.java
  
  Index: TestSearch.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/search/TestSearch.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestSearch.java	12 Jun 2003 22:11:33 -0000	1.1
  +++ TestSearch.java	16 Jun 2003 19:05:00 -0000	1.2
  @@ -105,6 +105,16 @@
           // All methods starting with "test" will be executed in the test suite.
           return new TestSuite(TestSearch.class);
       }
  +
  +    /*public void testRemoveWebPage() 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("Removing non-existent index entry", Search.remove(jetspeedHomePage) == false);
  +        assertTrue("Adding to index", Search.add(jetspeedHomePage));
  +        assertTrue("Removing from index", Search.remove(jetspeedHomePage));
  +    } */
       
       public void testPutWebPage() throws Exception
       {
  @@ -122,7 +132,7 @@
        */
       public void testVerifyJetspeedSearch() throws Exception
       {
  -        SearchResult result = null;
  +        ParsedObject result = null;
           SearchResults results  = Search.search("rss");
           System.out.println("Query 'rss' hits = " + results.size());
           assertTrue(" Hit count > 0", results.size() > 0);
  @@ -132,13 +142,13 @@
               System.out.println("Score = " + result.getScore());
               System.out.println("title = " + result.getTitle());
               System.out.println("summary = " + result.getDescription());
  -            System.out.println("url = " + result.getDocumentURL());
  +            System.out.println("url = " + result.getURL());
           }
       }
       
       public void testVerifyJetspeedSearch1() throws Exception
       {
  -        SearchResult result = null;
  +        ParsedObject result = null;
           SearchResults results  = Search.search("Jetspeed");
           System.out.println("Query 'Jetspeed' hits = " + results.size());
           assertTrue(" Hit count > 0", results.size() > 0);
  @@ -148,13 +158,13 @@
               System.out.println("Score = " + result.getScore());
               System.out.println("title = " + result.getTitle());
               System.out.println("summary = " + result.getDescription());
  -            System.out.println("url = " + result.getDocumentURL());
  +            System.out.println("url = " + result.getURL());
           }
       }
       
       public void testVerifyJetspeedSearch2() throws Exception
       {
  -        SearchResult result = null;
  +        ParsedObject result = null;
           SearchResults results  = Search.search("google");
           System.out.println("Query 'goggle' hits = " + results.size());
           assertTrue(" Hit count > 0", results.size() > 0);
  @@ -164,7 +174,8 @@
               System.out.println("Score = " + result.getScore());
               System.out.println("title = " + result.getTitle());
               System.out.println("summary = " + result.getDescription());
  -            System.out.println("url = " + result.getDocumentURL());
  +            System.out.println("url = " + result.getURL());
           }
       }
  +
   }
  
  
  
  1.1                  jakarta-jetspeed/src/java/org/apache/jetspeed/services/search/handlers/PortletEntryToDocHandler.java
  
  Index: PortletEntryToDocHandler.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.handlers;
  
  // Java APIs
  import java.net.MalformedURLException;
  import java.net.URL;
  import java.util.HashMap;
  import java.util.Iterator;
  
  // Jetspeed APIs
  import org.apache.jetspeed.om.registry.PortletEntry;
  import org.apache.jetspeed.services.search.ParsedObject;
  import org.apache.jetspeed.om.registry.Category;
  
  // Turbine APIs
  import org.apache.turbine.util.Log;
  
  /**
   * This object handler deals with portlet registry entries
   * 
   * @author <a href="mailto:caius1440@hotmail.com">Jeremy Ford</a>
   * @version $Id: PortletEntryToDocHandler.java,v 1.1 2003/06/16 19:05:00 morciuch Exp $
   */
  public class PortletEntryToDocHandler extends RegistryEntryToDocHandler
  {
      /**
       * Parses portlet entry object
       * 
       * @param o
       * @return 
       */
      public ParsedObject parseObject(Object o)
      {
          ParsedObject result = super.parseObject(o);
          
          if ((o instanceof PortletEntry) == false)
          {
              Log.error("PortletEntryToDocHandler: invalid object type: " + o);
              return null;
          }
  
          PortletEntry portletEntry = (PortletEntry) o;
          
          HashMap fields = new HashMap();
          fields.put("parent", portletEntry.getParent());
          fields.put("type", portletEntry.getType());
          
          result.setFields(fields);
  
          StringBuffer content = new StringBuffer();
          String title = portletEntry.getTitle();
          content.append(title == null ? portletEntry.getName() : title);
          content.append(" ");
          content.append(portletEntry.getDescription());
          content.append(" ");
          Iterator it = portletEntry.listCategories();
          while (it.hasNext())
          {
              Category cat = (Category) it.next();
              content.append(cat.getName());
              content.append(" ");
          }
  
          result.setContent(content.toString());
  
          result.setType(ParsedObject.OBJECT_TYPE_PORTLET);
  
          // TODO: index the url for portlets defining one. A good candidate would be HTML, Webpage
          // and IFrame portlets.
          
          return result;
      }
  }
  
  
  
  1.1                  jakarta-jetspeed/src/java/org/apache/jetspeed/services/search/handlers/PortletToDocHandler.java
  
  Index: PortletToDocHandler.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.handlers;
  
  import org.apache.jetspeed.portal.Portlet;
  import org.apache.jetspeed.services.rundata.JetspeedRunDataService;
  import org.apache.jetspeed.services.search.BaseParsedObject;
  import org.apache.jetspeed.services.search.ObjectHandler;
  import org.apache.jetspeed.services.search.ParsedObject;
  import org.apache.turbine.services.TurbineServices;
  import org.apache.turbine.services.rundata.RunDataService;
  import org.apache.turbine.util.Log;
  
  /**
   * This object handler deals with portlets
   * 
   * @author <a href="mailto:caius1440@hotmail.com">Jeremy Ford</a>
   * @version $Id: PortletToDocHandler.java,v 1.1 2003/06/16 19:05:00 morciuch Exp $
   */
  public class PortletToDocHandler implements ObjectHandler
  {
  
      /* (non-Javadoc)
       * @see org.apache.jetspeed.services.search.ObjectHandler#parseObject(java.lang.Object)
       */
      public ParsedObject parseObject(Object o)
      {
          ParsedObject result = new BaseParsedObject();
  
          if ((o instanceof Portlet) == false)
          {
              Log.error("PortletToDocHandler: invalid object type: " + o);
              return null;
          }
  
          Portlet portlet = (Portlet) o;
          
          
          JetspeedRunDataService rds = (JetspeedRunDataService) ((TurbineServices) TurbineServices.getInstance())
                                                                                    .getResources(RunDataService.SERVICE_NAME);
          result.setContent(portlet.getContent(rds.getCurrentRunData()).toString());
          result.setDescription(portlet.getDescription());
          result.setType(this.getClass().getName());
          //result.setFields();
          result.setKey(portlet.getName());
          //result.setKeywords();
          //result.setLanguage();
          result.setTitle(portlet.getTitle());
          //result.setURL();
          
          return result;
      }
  
  }
  
  
  
  1.1                  jakarta-jetspeed/src/java/org/apache/jetspeed/services/search/handlers/RegistryEntryToDocHandler.java
  
  Index: RegistryEntryToDocHandler.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.handlers;
  
  import org.apache.jetspeed.om.registry.RegistryEntry;
  import org.apache.jetspeed.services.search.BaseParsedObject;
  import org.apache.jetspeed.services.search.ObjectHandler;
  import org.apache.jetspeed.services.search.ParsedObject;
  import org.apache.turbine.util.Log;
  
  /**
   * This object handler deals with registry entries
   * 
   * @author <a href="mailto:caius1440@hotmail.com">Jeremy Ford</a>
   * @version $Id: RegistryEntryToDocHandler.java,v 1.1 2003/06/16 19:05:00 morciuch Exp $
   */
  public class RegistryEntryToDocHandler implements ObjectHandler
  {
  
      /**
       * @see org.apache.jetspeed.services.search.ObjectHandler#parseObject(java.lang.Object)
       * @param o
       * @return 
       */
      public ParsedObject parseObject(Object o)
      {
          ParsedObject result = new BaseParsedObject();
  
          if ((o instanceof RegistryEntry) == false)
          {
              Log.error("RegistryEntryToDocHandler: invalid object type: " + o);
              return null;
          }
  
          RegistryEntry regEntry = (RegistryEntry) o;
          String desc = regEntry.getDescription();
          result.setDescription(desc == null ? regEntry.getName() : desc);
          result.setKey(regEntry.getName());
          String title = regEntry.getTitle();
          result.setTitle(title == null ? regEntry.getName() : title);
          
          return result;
      }
  
  }
  
  
  
  1.1                  jakarta-jetspeed/src/java/org/apache/jetspeed/services/search/handlers/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.handlers;
  
  // 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;
  
  // Jetspeed imports
  import org.apache.jetspeed.services.search.BaseParsedObject;
  import org.apache.jetspeed.services.search.ObjectHandler;
  import org.apache.jetspeed.services.search.ParsedObject;
  
  // 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/16 19:05:01 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
                  {
                      result.setKey(java.net.URLEncoder.encode(pageToAdd.toString()));
                      result.setType(ParsedObject.OBJECT_TYPE_URL);
                      // 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.2       +226 -62   jakarta-jetspeed/src/java/org/apache/jetspeed/services/search/lucene/LuceneSearchService.java
  
  Index: LuceneSearchService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/search/lucene/LuceneSearchService.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LuceneSearchService.java	12 Jun 2003 22:11:33 -0000	1.1
  +++ LuceneSearchService.java	16 Jun 2003 19:05:01 -0000	1.2
  @@ -59,6 +59,11 @@
   import java.io.IOException;
   import java.net.URL;
   import javax.servlet.ServletConfig;
  +import java.util.Collection;
  +import java.util.ArrayList;
  +import java.util.Iterator;
  +
  +// Commons imports
   import org.apache.commons.httpclient.HttpClient;
   import org.apache.commons.httpclient.HttpException;
   import org.apache.commons.httpclient.methods.GetMethod;
  @@ -67,6 +72,9 @@
   import org.apache.jetspeed.services.search.HandlerFactory;
   import org.apache.jetspeed.services.search.ObjectHandler;
   import org.apache.jetspeed.services.search.ParsedObject;
  +import org.apache.jetspeed.services.search.BaseParsedObject;
  +import org.apache.jetspeed.services.search.SearchResults;
  +import org.apache.jetspeed.services.search.SearchService;
   
   // Turbine imports
   import org.apache.turbine.services.InitializationException;
  @@ -77,14 +85,13 @@
   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.Term;
   import org.apache.lucene.index.IndexWriter;
  +import org.apache.lucene.index.IndexReader;
   import org.apache.lucene.queryParser.QueryParser;
   import org.apache.lucene.search.IndexSearcher;
   import org.apache.lucene.search.Hits;
  @@ -102,21 +109,8 @@
   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
  @@ -193,10 +187,6 @@
                                         .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
  @@ -248,11 +238,11 @@
   
       /**
        * 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
  +     * @param searchString
  +     *               is the what is being searched for
  +     * @return Hits, if no hits then null.
        */
       public SearchResults search(String searchString)
       {
  @@ -276,18 +266,24 @@
           Document doc = null;
           SearchResults results = new SearchResults(hitCount);
           for (int counter = 0; counter < hitCount; counter++)
  -        {
  -            SearchResult result = new SearchResult();
  +        {            
  +            ParsedObject result = new BaseParsedObject();
               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());
  +                result.setType(doc.getField(ParsedObject.FIELDNAME_TYPE).stringValue());
  +                result.setKey(doc.getField(ParsedObject.FIELDNAME_KEY).stringValue());
  +                result.setDescription(doc.getField(ParsedObject.FIELDNAME_DESCRIPTION).stringValue());
  +                result.setTitle(doc.getField(ParsedObject.FIELDNAME_TITLE).stringValue());
  +                Field url = doc.getField(ParsedObject.FIELDNAME_URL);
  +                if (url != null)
  +                {
  +                    result.setURL(new URL(url.stringValue()));
  +                }                
                   results.add(counter, result);
               }
  -            catch (IOException ioe)
  +            catch (Exception ioe)
               {
                   Log.error(ioe);
               }
  @@ -308,78 +304,246 @@
           return results;
       }
   
  +    /**
  +     * 
  +     * @return 
  +     */
       public String[] getSearchSets()
       {
           return null;
       }
   
  -    /* (non-Javadoc)
  +    /**
  +     * 
        * @see org.apache.jetspeed.services.search.SearchService#add(java.lang.Object)
  +     * @param o
  +     * @return 
        */
       public boolean add(Object o)
       {
  +        Collection c = new ArrayList();
  +        c.add(o);
  +
  +        return add(c);
  +    }
  +
  +    /**
  +     * 
  +     * @see org.apache.jetspeed.services.search.SearchService#add(java.lang.Collection)
  +     * @param c
  +     * @return 
  +     */
  +    public boolean add(Collection c)
  +    {
           boolean result = false;
   
           try 
           {
  -            // Look up appropriate handler
  -            ObjectHandler handler = HandlerFactory.getHandler(o);
  +            IndexWriter indexWriter = new IndexWriter(rootDir, new StandardAnalyzer(), false);
   
  -            // Parse the object
  -            ParsedObject parsedObject = handler.parseObject(o);
  +            Iterator it = c.iterator();
  +            while (it.hasNext()) 
  +            {
  +                Object o = it.next();
  +                // Look up appropriate handler
  +                ObjectHandler handler = HandlerFactory.getHandler(o);
   
  -            // Create document
  -            Document doc = new Document();
  +                // Parse the object
  +                ParsedObject parsedObject = handler.parseObject(o);
   
  -            // 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()));
  +                // Create document
  +                Document doc = new Document();
   
  -            // TODO: How to handle keywords and fields
  -            /*String[] keywords = parsedObject.getKeywords();
  -            if (keywords != null)
  -            {
  -                for (int i = 0; i < keywords.length; i++)
  +                // Populate document from the parsed object
  +                if (parsedObject.getKey() != null)
  +                {
  +                    doc.add(Field.Text(ParsedObject.FIELDNAME_KEY, parsedObject.getKey()));
  +                }
  +                if (parsedObject.getType() != null)
  +                {
  +                    doc.add(Field.Text(ParsedObject.FIELDNAME_TYPE, parsedObject.getType()));
  +                }
  +                if (parsedObject.getTitle() != null)
  +                {
  +                    doc.add(Field.Text(ParsedObject.FIELDNAME_TITLE, parsedObject.getTitle()));
  +                }
  +                if (parsedObject.getDescription() != null)
  +                {
  +                    doc.add(Field.Text(ParsedObject.FIELDNAME_DESCRIPTION, parsedObject.getDescription()));
  +                }
  +                if (parsedObject.getContent() != null)
                   {
  -                    doc.add(Field.Keyword();
  +                    doc.add(Field.Text(ParsedObject.FIELDNAME_CONTENT, parsedObject.getContent()));
  +                }
  +                if (parsedObject.getLanguage() != null)
  +                {
  +                    doc.add(Field.Text(ParsedObject.FIELDNAME_LANGUAGE, parsedObject.getLanguage()));   
  +                }
  +                if (parsedObject.getURL() != null)
  +                {
  +                    doc.add(Field.Text(ParsedObject.FIELDNAME_URL, parsedObject.getURL().toString()));
                   }
  -            } */
   
  -            // Add the document to search index
  -            IndexWriter indexWriter = new IndexWriter(rootDir, new StandardAnalyzer(), false);
  -            indexWriter.addDocument(doc);
  -            Log.debug("Index Document Count = " + indexWriter.docCount());
  +                // 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.addDocument(doc);
  +                Log.debug("Index Document Count = " + indexWriter.docCount());
  +                Log.info("Added '" + parsedObject.getTitle() + "' to index");
  +                result = true;
  +            }
  +
               indexWriter.optimize();
               indexWriter.close();
  -            Log.info("Added '" + parsedObject.getTitle() + "' to index");
  -            result = true;
  +
           }
           catch (Exception e)
           {
               Log.error(e);
  +            result = false;
           }
   
           return result;
       }
   
  -    /* (non-Javadoc)
  +    /**
  +     * 
        * @see org.apache.jetspeed.services.search.SearchService#remove(java.lang.Object)
  +     * @param o
  +     * @return 
        */
       public boolean remove(Object o)
       {
  -        // TODO Auto-generated method stub
  -        return false;
  +        Collection c = new ArrayList();
  +        c.add(o);
  +
  +        return remove(c);
  +    }
  +
  +    /**
  +     * 
  +     * @see org.apache.jetspeed.services.search.SearchService#remove(java.lang.Collection)
  +     * @param c
  +     * @return 
  +     */
  +    public boolean remove(Collection c)
  +    {
  +        boolean result = false;
  +
  +        try 
  +        {
  +            IndexReader indexReader = IndexReader.open(this.rootDir);
  +
  +            Iterator it = c.iterator();
  +            while (it.hasNext()) 
  +            {
  +                Object o = it.next();
  +                // Look up appropriate handler
  +                ObjectHandler handler = HandlerFactory.getHandler(o);
  +
  +                // Parse the object
  +                ParsedObject parsedObject = handler.parseObject(o);
  +
  +                // Create term
  +                Term term = null;
  +
  +                if (parsedObject.getKey() != null)
  +                {
  +                    String key = java.net.URLEncoder.encode(parsedObject.getKey());
  +                    
  +                    /*term = new Term(ParsedObject.FIELDNAME_KEY, key);
  +                    // Remove the document from search index
  +                    int rc = indexReader.delete(term);
  +                    Log.info("Attempted to delete '" + term.toString() + "' from index, documents deleted = " + rc);
  +                    System.out.println("Attempted to delete '" + term.toString() + "' from index, documents deleted = " + rc);
  +                    result = rc > 0;*/
  +
  +                    Searcher searcher = new IndexSearcher(rootDir.getPath());
  +                    Analyzer analyzer = new StandardAnalyzer();
  +                    Query query = QueryParser.parse(key, ParsedObject.FIELDNAME_KEY, analyzer);
  +                    Hits hits = searcher.search(query);                    
  +                    System.out.println("Query '" + query.toString() + "'returned " + hits.length() + " hits");
  +
  +                    for (int i = 0; i < hits.length(); i++)
  +                    {
  +                        System.out.println("Deleting '" + key + "' from index, with doc # = " + hits.id(i));
  +                        indexReader.delete(hits.id(i));
  +                    }
  +                    result = true;
  +                }
  +            }
  +
  +            indexReader.close();
  +
  +            IndexWriter indexWriter = new IndexWriter(rootDir, new StandardAnalyzer(), false);
  +            indexWriter.optimize();
  +            indexWriter.close();
  +
  +        }
  +        catch (Exception e)
  +        {
  +            Log.error(e);
  +            result = false;
  +        }
  +
  +        return result;
       }
   
  -    /* (non-Javadoc)
  +    /**
  +     * 
        * @see org.apache.jetspeed.services.search.SearchService#update(java.lang.Object)
  +     * @param o
  +     * @return 
        */
       public boolean update(Object o)
       {
  -        // TODO Auto-generated method stub
  +        Collection c = new ArrayList();
  +        c.add(o);
  +
  +        return update(c);
  +    }
  +    /**
  +     * Updates an index entry. For now, it's a remove and add.
  +     * 
  +     * @param c
  +     * @return 
  +     * @see org.apache.jetspeed.services.search.SearchService#update(java.lang.Collection)
  +     */
  +    public boolean update(Collection c)
  +    {
  +        boolean result = false;
  +
  +        try
  +        {
  +            // Delete entries from index
  +            remove(c);
  +            result = true;
  +        }
  +        catch (Throwable e)
  +        {
  +            Log.error(e);
  +        }
  +
  +        try
  +        {
  +            // Add entries to index
  +            add(c);
  +            result = true;
  +        }
  +        catch (Throwable e)
  +        {
  +            Log.error(e);
  +        }
  +
           return false;
       }
  +
   }
  
  
  
  1.102     +5 -3      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.101
  retrieving revision 1.102
  diff -u -r1.101 -r1.102
  --- JetspeedResources.properties	12 Jun 2003 22:11:35 -0000	1.101
  +++ JetspeedResources.properties	16 Jun 2003 19:05:01 -0000	1.102
  @@ -286,8 +286,10 @@
   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
  +services.Search.document.java.net.URL = org.apache.jetspeed.services.search.handlers.URLToDocHandler
  +services.Search.document.org.apache.jetspeed.portal.Portlet = org.apache.jetspeed.services.search.handlers.PortletToDocHandler
  +services.Search.document.org.apache.jetspeed.om.registry.RegistryEntry = org.apache.jetspeed.services.search.handlers.RegistryEntryToDocHandler
  +services.Search.document.org.apache.jetspeed.om.registry.PortletEntry = org.apache.jetspeed.services.search.handlers.PortletEntryToDocHandler
   
   #########################################
   # ThreadPool Service                    #
  
  
  
  1.40      +14 -1     jakarta-jetspeed/webapp/WEB-INF/conf/admin.xreg
  
  Index: admin.xreg
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/webapp/WEB-INF/conf/admin.xreg,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- admin.xreg	4 Jun 2003 15:59:14 -0000	1.39
  +++ admin.xreg	16 Jun 2003 19:05:01 -0000	1.40
  @@ -611,6 +611,19 @@
   		<media-type ref="html"/>
   		<category group="Jetspeed">Tools</category>
   	</portlet-entry>
  -
  +    
  +	<portlet-entry name="IndexManager" hidden="false" type="ref" parent="GenericMVCPortlet" application="false">
  +		<security-ref parent="admin-only"/>
  +		<meta-info>
  +			<title>Portlet Index Manager</title>
  +			<description>Utility portlet to rebuild the portlet entry index</description>
  +		</meta-info>
  +          <parameter name="viewtype" value="Velocity" hidden="true"/>		
  +		<parameter name="action" value="portlets.IndexPortletRegistry" hidden="true"/>
  +		<parameter name="template" value="index-registry" hidden="true"/>
  +		<media-type ref="html"/>
  +		<category group="Jetspeed">admin</category>
  +	</portlet-entry>
  +    
   </registry>
   
  
  
  
  1.26      +1 -0      jakarta-jetspeed/webapp/WEB-INF/psml/user/admin/html/default.psml
  
  Index: default.psml
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/webapp/WEB-INF/psml/user/admin/html/default.psml,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- default.psml	5 Jun 2003 18:25:27 -0000	1.25
  +++ default.psml	16 Jun 2003 19:05:01 -0000	1.26
  @@ -98,5 +98,6 @@
           <entry id="354" parent="ControlForm">
               <parameter name="_menustate" value="closed"/>
           </entry>
  +        <entry id="355" parent="IndexManager"/>        
       </portlets>
   </portlets>
  
  
  
  1.2       +13 -3     jakarta-jetspeed/webapp/WEB-INF/templates/vm/portlets/html/search.vm
  
  Index: search.vm
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/webapp/WEB-INF/templates/vm/portlets/html/search.vm,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- search.vm	12 Jun 2003 22:11:36 -0000	1.1
  +++ search.vm	16 Jun 2003 19:05:01 -0000	1.2
  @@ -2,7 +2,7 @@
   <form action="$jslink.setAction('portlets.SearchAction')" method="POST">
   <INPUT TYPE='hidden' VALUE='' NAME='listIndex'>
   
  -<table border="0" cellpadding="0" cellspacing="0" width="75%">
  +<table border="0" cellpadding="0" cellspacing="0" width="95%">
     <tr>
       <td><font size="-2">&nbsp;</font></td>
       <td class="blackline">
  @@ -34,10 +34,20 @@
                       <tr><td colspan="5" class="blackline"/></tr>
                       <tr>
                         <td class="$!{skin.ContentStyleClass}" align="left">
  +                      #if ($result.Type == "portlet")                       
                           <a id="preview_$listIndex" 
  -                           href="$result.DocumentURL" target="_blank">
  -                           <span class="$!{skin.ContentStyleClass}">$result.DocumentURL</span>
  +                           href="$jslink.setTemplate("preview").addQueryData("p",$result.Key).addQueryData("c","ClearPortletControl")"
  +                           target="_blank">
  +                           <IMG border="0" SRC="$clink.setURI("images/html/is_portlet.gif")">                           
  +                           <span class="$!{skin.ContentStyleClass}">$result.Title</span>
  +                        </a>                      
  +                      #else
  +                        <a id="preview_$listIndex" 
  +                           href="$result.URL" target="_blank">
  +                           <IMG border="0" SRC="$clink.setURI("images/is_url.gif")">                           
  +                           <span class="$!{skin.ContentStyleClass}">$result.URL</span>
                           </a>
  +                      #end  
                         </td>
                       </tr>
                       #set ($listIndex = $listIndex + 1)
  
  
  
  1.1                  jakarta-jetspeed/webapp/WEB-INF/templates/vm/portlets/html/index-registry.vm
  
  Index: index-registry.vm
  ===================================================================
  <form method="post">
    <br>
    <p>To rebuild portlet registry index, click the "Index" button below. This will index every portlet registry
       entry. The following portlet attributes are indexed:
       <UL>
          <LI>Title</LI>
          <LI>Description</LI>        
          <LI>Categories</LI>        
       </UL>
      <br>
      <input type="submit" name="eventSubmit_doIndex" value="Index">
    </p>
  </form>
  
  
  1.1                  jakarta-jetspeed/webapp/images/is_url.gif
  
  	<<Binary file>>
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org