You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jspwiki.apache.org by ja...@apache.org on 2009/04/30 21:19:52 UTC
svn commit: r770403 - in /incubator/jspwiki/trunk: ./
src/java/org/apache/wiki/ src/java/org/apache/wiki/attachment/
src/java/org/apache/wiki/search/
Author: jalkanen
Date: Thu Apr 30 19:19:51 2009
New Revision: 770403
URL: http://svn.apache.org/viewvc?rev=770403&view=rev
Log:
JSPWIKI-528: Three patches from Greg Kable to rationalize the use
of Collections in the APIs.
Modified:
incubator/jspwiki/trunk/ChangeLog
incubator/jspwiki/trunk/src/java/org/apache/wiki/LinkCollector.java
incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
incubator/jspwiki/trunk/src/java/org/apache/wiki/attachment/AttachmentManager.java
incubator/jspwiki/trunk/src/java/org/apache/wiki/search/BasicSearchProvider.java
incubator/jspwiki/trunk/src/java/org/apache/wiki/search/LuceneSearchProvider.java
incubator/jspwiki/trunk/src/java/org/apache/wiki/search/SearchProvider.java
Modified: incubator/jspwiki/trunk/ChangeLog
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/ChangeLog?rev=770403&r1=770402&r2=770403&view=diff
==============================================================================
--- incubator/jspwiki/trunk/ChangeLog (original)
+++ incubator/jspwiki/trunk/ChangeLog Thu Apr 30 19:19:51 2009
@@ -1,3 +1,10 @@
+2009-04-30 Janne Jalkanen <ja...@apache.org>
+
+ * 3.0.0-svn-107
+
+ * JSPWIKI-528: Three patches from Greg Kable to rationalize the use
+ of Collections in the APIs.
+
2009-04-26 Harry Metske <me...@apache.org>
* 3.0.0-svn-106
Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/LinkCollector.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/LinkCollector.java?rev=770403&r1=770402&r2=770403&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/LinkCollector.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/LinkCollector.java Thu Apr 30 19:19:51 2009
@@ -21,7 +21,7 @@
package org.apache.wiki;
import java.util.ArrayList;
-import java.util.Collection;
+import java.util.List;
import org.apache.wiki.util.StringTransmutator;
@@ -38,7 +38,7 @@
* Returns a List of Strings representing links.
* @return the link collection
*/
- public Collection<String> getLinks()
+ public List<String> getLinks()
{
return m_items;
}
Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java?rev=770403&r1=770402&r2=770403&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java Thu Apr 30 19:19:51 2009
@@ -77,7 +77,7 @@
* <p>
* If the build identifier is empty, it is not added.
*/
- public static final String BUILD = "106";
+ public static final String BUILD = "107";
/**
* This is the generic version string you should use
Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/attachment/AttachmentManager.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/attachment/AttachmentManager.java?rev=770403&r1=770402&r2=770403&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/attachment/AttachmentManager.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/attachment/AttachmentManager.java Thu Apr 30 19:19:51 2009
@@ -24,10 +24,7 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Properties;
+import java.util.*;
import org.apache.commons.lang.StringUtils;
import org.apache.wiki.JCRWikiPage;
@@ -220,33 +217,66 @@
}
/**
- * Returns the list of attachments associated with a given wiki page.
- * If there are no attachments, returns an empty Collection.
+ * Returns the list of attachments associated with a given wiki page.
+ * If there are no attachments, returns an empty List. The order of
+ * the list is not defined.
+ *
+ * @param wikipage
+ * the wiki page from which you are seeking attachments for
+ * @return an unordered List of attachments
+ * @throws ProviderException
+ * if there was something wrong in the backend
+ */
+ public List<WikiPage> listAttachments( WikiPage wikipage )
+ throws ProviderException
+ {
+ return (List<WikiPage>) listAttachmentsImpl( new ArrayList<WikiPage>(), wikipage );
+ }
+
+ /**
+ * Returns the sorted set of attachments associated with a given wiki page.
+ * If there are no attachments, returns an empty Set. The set is in page
+ * name order.
+ *
+ * @param wikipage
+ * the wiki page from which you are seeking attachments for
+ * @return a SortedSet of attachments
+ * @throws ProviderException
+ * if there was something wrong in the backend
+ */
+ public SortedSet<WikiPage> listAttachmentsSorted( WikiPage wikipage )
+ throws ProviderException
+ {
+ return (SortedSet<WikiPage>) listAttachmentsImpl( new TreeSet<WikiPage>(), wikipage );
+ }
+
+ /**
+ * Internal routine to find the attachments associated with a given wiki page.
+ * Depends on the passed Collection for ordering and such.
*
+ * @param result Collection used to hold the resulting attachments
* @param wikipage the wiki page from which you are seeking attachments for
- * @return a valid collection of attachments
+ * @return the passed in Collection, filled with the attachments
* @throws ProviderException if there was something wrong in the backend
*/
- // FIXME: This API should be changed to return a List.
- public Collection<WikiPage> listAttachments( WikiPage wikipage )
+ private Collection<WikiPage> listAttachmentsImpl( Collection<WikiPage> result, WikiPage wikipage )
throws ProviderException
{
List<WikiPage> children = wikipage.getChildren();
- ArrayList<WikiPage> atts = new ArrayList<WikiPage>();
for( WikiPage p : children )
{
JCRWikiPage jwp = (JCRWikiPage)p;
if( jwp.isAttachment() )
- atts.add( jwp );
+ result.add( jwp );
}
- return atts;
+ return result;
}
/**
* Returns true, if the page has any attachments at all. This is
- * a convinience method.
+ * a convenience method.
*
*
* @param wikipage The wiki page from which you are seeking attachments for.
@@ -256,9 +286,18 @@
{
try
{
- return listAttachments( wikipage ).size() > 0;
+ List<WikiPage> children = wikipage.getChildren();
+ for( WikiPage p : children )
+ {
+ JCRWikiPage jwp = (JCRWikiPage)p;
+ if( jwp.isAttachment() )
+ return true;
+ }
+ }
+ catch( ProviderException e )
+ {
+ // Do nothing because there's nothing we can do
}
- catch( Exception e ) {}
return false;
}
Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/search/BasicSearchProvider.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/search/BasicSearchProvider.java?rev=770403&r1=770402&r2=770403&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/search/BasicSearchProvider.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/search/BasicSearchProvider.java Thu Apr 30 19:19:51 2009
@@ -144,7 +144,7 @@
return "";
}
- private Collection<SearchResult> findPages( QueryItem[] query )
+ private SortedSet<SearchResult> findPages( QueryItem[] query )
{
TreeSet<SearchResult> res = new TreeSet<SearchResult>( new SearchResultComparator() );
SearchMatcher matcher = new SearchMatcher( m_engine, query );
@@ -192,9 +192,9 @@
/**
* {@inheritDoc}
*/
- public Collection<SearchResult> findPages(String query)
+ public List<SearchResult> findPages(String query)
{
- return findPages(parseQuery(query));
+ return new ArrayList<SearchResult>( findPages( parseQuery( query ) ) );
}
/**
Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/search/LuceneSearchProvider.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/search/LuceneSearchProvider.java?rev=770403&r1=770402&r2=770403&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/search/LuceneSearchProvider.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/search/LuceneSearchProvider.java Thu Apr 30 19:19:51 2009
@@ -528,7 +528,7 @@
/**
* {@inheritDoc}
*/
- public Collection<SearchResult> findPages( String query )
+ public List<SearchResult> findPages( String query )
throws ProviderException
{
return findPages( query, FLAG_CONTEXTS );
@@ -545,10 +545,10 @@
*
* @param query The query to perform in Lucene query language
* @param flags A set of flags
- * @return A Collection of SearchResult instances
+ * @return the ordered list of SearchResult instances in descending quality order (i.e. best match first)
* @throws ProviderException if there is a problem with the backend
*/
- public Collection<SearchResult> findPages( String query, int flags )
+ public List<SearchResult> findPages( String query, int flags )
throws ProviderException
{
Searcher searcher = null;
Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/search/SearchProvider.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/search/SearchProvider.java?rev=770403&r1=770402&r2=770403&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/search/SearchProvider.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/search/SearchProvider.java Thu Apr 30 19:19:51 2009
@@ -21,7 +21,7 @@
package org.apache.wiki.search;
import java.io.IOException;
-import java.util.Collection;
+import java.util.List;
import org.apache.wiki.WikiProvider;
import org.apache.wiki.api.WikiPage;
@@ -53,11 +53,12 @@
public void reindexPage(WikiPage page) throws ProviderException;
/**
- * Search for pages matching a search query
+ * Search for pages matching a search query returning an ordered list of results.
+ *
* @param query query to search for
- * @return collection of pages that match query
+ * @return the ordered list of SearchResults that match query, in descending quality order (i.e. best match first)
* @throws ProviderException if the search provider failed.
* @throws IOException if for some reason the query could not be executed.
*/
- public Collection<SearchResult> findPages(String query) throws ProviderException, IOException;
+ public List<SearchResult> findPages(String query) throws ProviderException, IOException;
}