Index: src/com/ecyrd/jspwiki/SearchMatcher.java
===================================================================
--- src/com/ecyrd/jspwiki/SearchMatcher.java (revision 735653)
+++ src/com/ecyrd/jspwiki/SearchMatcher.java (working copy)
@@ -145,6 +145,7 @@
{
int m_score;
WikiPage m_page;
+ private String[] m_contexts;
/**
* Create a new SearchResult with a given name and a score.
@@ -188,6 +189,17 @@
// Unimplemented
return new String[0];
}
+
+ /**
+ * Sets the m_contexts, although BasicSearchProvider does not support
+ * context matching.
+ *
+ * @return an empty array
+ */
+ public void notAuthorized()
+ {
+ m_contexts = new String[]{"You are not authorized to view this content."};
+ }
}
}
Index: src/com/ecyrd/jspwiki/SearchResult.java
===================================================================
--- src/com/ecyrd/jspwiki/SearchResult.java (revision 735653)
+++ src/com/ecyrd/jspwiki/SearchResult.java (working copy)
@@ -50,4 +50,10 @@
* @since 2.4
*/
public String[] getContexts();
+
+ /* Prevent People from seeing relevant Information.
+ * @see com.ecyrd.jspwiki.SearchResult#notAuthorized()
+ */
+ public void notAuthorized();
+
}
Index: src/com/ecyrd/jspwiki/WikiEngine.java
===================================================================
--- src/com/ecyrd/jspwiki/WikiEngine.java (revision 735653)
+++ src/com/ecyrd/jspwiki/WikiEngine.java (working copy)
@@ -1837,12 +1837,37 @@
public Collection findPages( String query )
throws ProviderException, IOException
{
- Collection results = m_searchManager.findPages( query );
-
- return results;
+ return findPages(query, -1, -1);
}
/**
+ * Parses an incoming search request, then
+ * does a search.
+ *
+ * The query is dependent on the actual chosen search provider - each one of them has
+ * a language of its own.
+ *
+ * @param query The query string
+ * @return A Collection of SearchResult objects.
+ * @throws ProviderException If the searching failed
+ * @throws IOException If the searching failed
+ */
+
+ //
+ // FIXME: Should also have attributes attached.
+ //
+ public Collection findPages( String query , int startSearchFrom ,int SearchItemAmount )
+ throws ProviderException, IOException
+ {
+ StopWatch sw = new StopWatch();
+ sw.start();
+ Collection results = m_searchManager.findPages( query , startSearchFrom , SearchItemAmount);
+ sw.stop();
+ log.info("The search for \"" + query + "\" lasted : " + sw.getTime());
+ return results;
+ }
+
+ /**
* Finds the corresponding WikiPage object based on the page name. It always finds
* the latest version of a page.
*
Index: src/com/ecyrd/jspwiki/search/BasicSearchProvider.java
===================================================================
--- src/com/ecyrd/jspwiki/search/BasicSearchProvider.java (revision 735653)
+++ src/com/ecyrd/jspwiki/search/BasicSearchProvider.java (working copy)
@@ -168,6 +168,7 @@
return null;
}
+
Iterator it = allPages.iterator();
while( it.hasNext() )
{
@@ -203,11 +204,13 @@
/**
* {@inheritDoc}
*/
- public Collection findPages(String query)
- {
- return findPages(parseQuery(query));
- }
+ public Collection findPages(String query) throws ProviderException,
+ IOException
+ {
+ return findPages(parseQuery(query));
+ }
+
/**
* {@inheritDoc}
*/
@@ -216,4 +219,13 @@
return "BasicSearchProvider";
}
+
+ public Collection findPages(String query, int startShowFrom, int showAmount)
+ throws ProviderException, IOException
+ {
+ //There is no need to sort the results because he needs to go over every page anymway
+ return findPages(parseQuery(query));
+ }
+
+
}
Index: src/com/ecyrd/jspwiki/search/LuceneSearchProvider.java
===================================================================
--- src/com/ecyrd/jspwiki/search/LuceneSearchProvider.java (revision 735653)
+++ src/com/ecyrd/jspwiki/search/LuceneSearchProvider.java (working copy)
@@ -1,27 +1,37 @@
/*
- JSPWiki - a JSP-based WikiWiki clone.
+JSPWiki - a JSP-based WikiWiki clone.
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
+Copyright (C) 2005 Janne Jalkanen (Janne.Jalkanen@iki.fi)
- http://www.apache.org/licenses/LICENSE-2.0
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation; either version 2.1 of the License, or
+(at your option) any later version.
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
- */
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
package com.ecyrd.jspwiki.search;
-import java.io.*;
-import java.util.*;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.Vector;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
@@ -46,7 +56,17 @@
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;
-import com.ecyrd.jspwiki.*;
+import pl.com.pbpolsoft.wiki.util.attachment.ReadableAttachmentProvider;
+import pl.com.pbpolsoft.wiki.util.attachment.ReadableAttachmentProviderFactory;
+
+import com.ecyrd.jspwiki.FileUtil;
+import com.ecyrd.jspwiki.InternalWikiException;
+import com.ecyrd.jspwiki.NoRequiredPropertyException;
+import com.ecyrd.jspwiki.SearchResult;
+import com.ecyrd.jspwiki.TextUtil;
+import com.ecyrd.jspwiki.WikiEngine;
+import com.ecyrd.jspwiki.WikiPage;
+import com.ecyrd.jspwiki.WikiProvider;
import com.ecyrd.jspwiki.attachment.Attachment;
import com.ecyrd.jspwiki.attachment.AttachmentManager;
import com.ecyrd.jspwiki.parser.MarkupParser;
@@ -59,10 +79,10 @@
/**
* Interface for the search providers that handle searching the Wiki
*
- * @author Arent-Jan Banck
+ * @author Arent-Jan Banck for Informatica
* @since 2.2.21.
*/
-public class LuceneSearchProvider implements SearchProvider
+public class LuceneSearchProvider implements SearchProvider
{
protected static final Logger log = Logger.getLogger(LuceneSearchProvider.class);
@@ -75,7 +95,7 @@
private static final String PROP_LUCENE_INDEXDELAY = "jspwiki.lucene.indexdelay";
private static final String PROP_LUCENE_INITIALDELAY = "jspwiki.lucene.initialdelay";
-
+
private String m_analyzerClass = "org.apache.lucene.analysis.standard.StandardAnalyzer";
private static final String LUCENE_DIR = "lucene";
@@ -92,10 +112,11 @@
private String m_luceneDirectory = null;
private int m_updateCount = 0;
- protected Vector