Author: ajaquith
Date: Sat Feb 23 11:16:10 2008
New Revision: 630510
URL: http://svn.apache.org/viewvc?rev=630510&view=rev
Log:
Initial Stripes component commit.
Modified:
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/providers/CachingProvider.java
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/providers/WikiAttachmentProvider.java
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/rpc/atom/AtomAPIServlet.java
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/rpc/json/JSONRPCManager.java
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/rss/AtomFeed.java
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/rss/RSS10Feed.java
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/rss/RSS20Feed.java
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/rss/RSSGenerator.java
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/search/BasicSearchProvider.java
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/search/LuceneSearchProvider.java
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/search/SearchManager.java
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/search/SearchProvider.java
Modified:
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/providers/CachingProvider.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/providers/CachingProvider.java?rev=630510&r1=630509&r2=630510&view=diff
==============================================================================
---
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/providers/CachingProvider.java
(original)
+++
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/providers/CachingProvider.java
Sat Feb 23 11:16:10 2008
@@ -658,7 +658,7 @@
{
String data = m_provider.getPageText(page.getName(),
page.getVersion());
- WikiContext ctx = new WikiContext( m_engine, page );
+ WikiContext ctx =
m_engine.getWikiActionBeanFactory().newViewActionBean( page );
MarkupParser parser = mgr.getParser( ctx, data );
parser.parse();
Modified:
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/providers/WikiAttachmentProvider.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/providers/WikiAttachmentProvider.java?rev=630510&r1=630509&r2=630510&view=diff
==============================================================================
---
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/providers/WikiAttachmentProvider.java
(original)
+++
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/providers/WikiAttachmentProvider.java
Sat Feb 23 11:16:10 2008
@@ -80,7 +80,7 @@
* @throws ProviderException If something goes wrong when listing the
attachments.
*/
- public Collection listAttachments( WikiPage page )
+ public Collection<Attachment> listAttachments( WikiPage page )
throws ProviderException;
/**
@@ -106,7 +106,7 @@
* @return A List of Attachment objects, in most-recently-changed first
order.
* @throws ProviderException If something goes wrong.
*/
- public List listAllChanged( Date timestamp )
+ public List<Attachment> listAllChanged( Date timestamp )
throws ProviderException;
/**
Modified:
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/rpc/atom/AtomAPIServlet.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/rpc/atom/AtomAPIServlet.java?rev=630510&r1=630509&r2=630510&view=diff
==============================================================================
---
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/rpc/atom/AtomAPIServlet.java
(original)
+++
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/rpc/atom/AtomAPIServlet.java
Sat Feb 23 11:16:10 2008
@@ -137,7 +137,7 @@
WikiPage entryPage = new WikiPage( m_engine, pageName );
entryPage.setAuthor( username );
- WikiContext context = new WikiContext( m_engine, request,
entryPage );
+ WikiContext context =
m_engine.getWikiActionBeanFactory().newViewActionBean( request, response,
entryPage );
StringBuffer text = new StringBuffer();
text.append( "!"+title.getBody() );
@@ -273,7 +273,7 @@
String encodedName = TextUtil.urlEncodeUTF8( p.getName() );
- WikiContext context = new WikiContext( m_engine, p );
+ WikiContext context =
m_engine.getWikiActionBeanFactory().newViewActionBean( p );
String title =
TextUtil.replaceEntities(BlogUtil.getSiteName(context));
Modified:
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/rpc/json/JSONRPCManager.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/rpc/json/JSONRPCManager.java?rev=630510&r1=630509&r2=630510&view=diff
==============================================================================
---
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/rpc/json/JSONRPCManager.java
(original)
+++
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/rpc/json/JSONRPCManager.java
Sat Feb 23 11:16:10 2008
@@ -32,6 +32,7 @@
import com.ecyrd.jspwiki.WikiContext;
import com.ecyrd.jspwiki.WikiEngine;
import com.ecyrd.jspwiki.WikiSession;
+import com.ecyrd.jspwiki.action.NoneActionBean;
import com.ecyrd.jspwiki.auth.WikiSecurityException;
import com.ecyrd.jspwiki.auth.permissions.PagePermission;
import com.ecyrd.jspwiki.rpc.RPCCallable;
@@ -150,9 +151,9 @@
{
TemplateManager.addResourceRequest(context,
TemplateManager.RESOURCE_SCRIPT,
-
context.getURL(WikiContext.NONE,"scripts/json-rpc/jsonrpc.js"));
+
context.getContext().getURL(NoneActionBean.class,"scripts/json-rpc/jsonrpc.js"));
- String jsonurl = context.getURL( WikiContext.NONE, "JSON-RPC" );
+ String jsonurl = context.getContext().getURL( NoneActionBean.class,
"JSON-RPC" );
TemplateManager.addResourceRequest(context,
TemplateManager.RESOURCE_JSFUNCTION,
"jsonrpc = new
JSONRpcClient(\""+jsonurl+"\");");
Modified:
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/rss/AtomFeed.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/rss/AtomFeed.java?rev=630510&r1=630509&r2=630510&view=diff
==============================================================================
---
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/rss/AtomFeed.java
(original)
+++
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/rss/AtomFeed.java
Sat Feb 23 11:16:10 2008
@@ -21,10 +21,7 @@
import java.io.IOException;
import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.Iterator;
+import java.util.*;
import javax.servlet.ServletContext;
@@ -38,6 +35,8 @@
import com.ecyrd.jspwiki.WikiContext;
import com.ecyrd.jspwiki.WikiEngine;
import com.ecyrd.jspwiki.WikiPage;
+import com.ecyrd.jspwiki.action.AttachActionBean;
+import com.ecyrd.jspwiki.action.RSSActionBean;
import com.ecyrd.jspwiki.attachment.Attachment;
import com.ecyrd.jspwiki.providers.ProviderException;
@@ -124,7 +123,7 @@
Element attEl = getElement("link");
attEl.setAttribute( "rel","enclosure" );
- attEl.setAttribute( "href",
engine.getURL(WikiContext.ATTACH, att.getName(), null, true ) );
+ attEl.setAttribute( "href",
m_wikiContext.getContext().getURL(AttachActionBean.class, att.getName(), null,
true ) );
attEl.setAttribute( "length",
Long.toString(att.getSize()) );
attEl.setAttribute( "type", getMimeType(
servletContext, att.getFileName() ) );
@@ -174,10 +173,12 @@
root.addContent(
getElement("link").setAttribute("href",engine.getBaseURL()));
root.addContent( getElement("generator").setText("JSPWiki
"+Release.VERSTR));
- String rssFeedURL = engine.getURL(WikiContext.NONE, "rss.jsp",
-
"page="+engine.encodeName(m_wikiContext.getPage().getName())+
- "&mode="+m_mode+
- "&type=atom",
+ Map<String,String> rssParams = new HashMap<String,String>();
+ rssParams.put("mode", m_mode);
+ rssParams.put("type", "atom");
+ String rssFeedURL =
m_wikiContext.getContext().getURL(RSSActionBean.class,
+
"page="+engine.encodeName(m_wikiContext.getPage().getName()),
+ rssParams,
true );
Element self = getElement("link").setAttribute("rel","self");
self.setAttribute("href",rssFeedURL);
Modified:
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/rss/RSS10Feed.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/rss/RSS10Feed.java?rev=630510&r1=630509&r2=630510&view=diff
==============================================================================
---
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/rss/RSS10Feed.java
(original)
+++
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/rss/RSS10Feed.java
Sat Feb 23 11:16:10 2008
@@ -21,13 +21,17 @@
import java.text.SimpleDateFormat;
import java.util.Calendar;
+import java.util.HashMap;
import java.util.Iterator;
+import java.util.Map;
import org.apache.ecs.xml.XML;
import com.ecyrd.jspwiki.WikiContext;
import com.ecyrd.jspwiki.WikiEngine;
import com.ecyrd.jspwiki.WikiPage;
+import com.ecyrd.jspwiki.action.DiffActionBean;
+import com.ecyrd.jspwiki.action.PageInfoActionBean;
/**
* @author jalkanen
@@ -96,9 +100,11 @@
if( p.getVersion() > 1 )
{
- item.addElement( new XML("wiki:diff").addElement(
engine.getURL( WikiContext.DIFF,
+ Map<String,String> rssParams = new HashMap<String,String>();
+ rssParams.put("r1", "-1");
+ item.addElement( new XML("wiki:diff").addElement(
m_wikiContext.getContext().getURL( DiffActionBean.class,
p.getName(),
-
"r1=-1",
+
rssParams,
true) ) );
}
@@ -144,7 +150,7 @@
// PageHistory
- item.addElement( new XML("wiki:history").addElement(
engine.getURL( WikiContext.INFO,
+ item.addElement( new XML("wiki:history").addElement(
m_wikiContext.getContext().getURL( PageInfoActionBean.class,
p.getName(),
null,
true ) ) );
Modified:
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/rss/RSS20Feed.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/rss/RSS20Feed.java?rev=630510&r1=630509&r2=630510&view=diff
==============================================================================
---
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/rss/RSS20Feed.java
(original)
+++
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/rss/RSS20Feed.java
Sat Feb 23 11:16:10 2008
@@ -34,6 +34,7 @@
import com.ecyrd.jspwiki.WikiContext;
import com.ecyrd.jspwiki.WikiEngine;
import com.ecyrd.jspwiki.WikiPage;
+import com.ecyrd.jspwiki.action.AttachActionBean;
import com.ecyrd.jspwiki.attachment.Attachment;
import com.ecyrd.jspwiki.providers.ProviderException;
@@ -93,7 +94,7 @@
Attachment att = (Attachment) a.next();
Element attEl = new Element("enclosure");
- attEl.setAttribute( "url",
engine.getURL(WikiContext.ATTACH, att.getName(), null, true ) );
+ attEl.setAttribute( "url",
m_wikiContext.getContext().getURL(AttachActionBean.class, att.getName(), null,
true ) );
attEl.setAttribute( "length",
Long.toString(att.getSize()) );
attEl.setAttribute( "type", getMimeType(
servletContext, att.getFileName() ) );
Modified:
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/rss/RSSGenerator.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/rss/RSSGenerator.java?rev=630510&r1=630509&r2=630510&view=diff
==============================================================================
---
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/rss/RSSGenerator.java
(original)
+++
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/rss/RSSGenerator.java
Sat Feb 23 11:16:10 2008
@@ -24,6 +24,10 @@
import org.apache.log4j.Logger;
import com.ecyrd.jspwiki.*;
+import com.ecyrd.jspwiki.action.AttachActionBean;
+import com.ecyrd.jspwiki.action.PageInfoActionBean;
+import com.ecyrd.jspwiki.action.RSSActionBean;
+import com.ecyrd.jspwiki.action.ViewActionBean;
import com.ecyrd.jspwiki.attachment.Attachment;
import com.ecyrd.jspwiki.auth.permissions.PagePermission;
import com.ecyrd.jspwiki.providers.ProviderException;
@@ -140,7 +144,7 @@
return author;
}
- private String getAttachmentDescription( Attachment att )
+ private String getAttachmentDescription( WikiContext wikiContext,
Attachment att )
{
String author = getAuthor(att);
StringBuffer sb = new StringBuffer();
@@ -156,10 +160,10 @@
sb.append("<br /><hr /><br />");
sb.append( "Parent page: <a href=\""+
- m_engine.getURL( WikiContext.VIEW, att.getParentName(),
null, true ) +
+ wikiContext.getContext().getURL( ViewActionBean.class,
att.getParentName(), null, true ) +
"\">"+att.getParentName()+"</a><br />" );
sb.append( "Info page: <a href=\""+
- m_engine.getURL( WikiContext.INFO, att.getName(), null,
true ) +
+ wikiContext.getContext().getURL( PageInfoActionBean.class,
att.getName(), null, true ) +
"\">"+att.getName()+"</a>" );
return sb.toString();
@@ -170,7 +174,7 @@
StringBuffer buf = new StringBuffer();
String author = getAuthor(page);
- WikiContext ctx = new WikiContext( m_engine, page );
+ WikiContext ctx =
m_engine.getWikiActionBeanFactory().newViewActionBean( page );
if( page.getVersion() > 1 )
{
String diff = m_engine.getDiff( ctx,
@@ -189,13 +193,13 @@
return buf.toString();
}
- private String getEntryDescription( WikiPage page )
+ private String getEntryDescription( WikiContext context, WikiPage page )
{
String res;
if( page instanceof Attachment )
{
- res = getAttachmentDescription( (Attachment)page );
+ res = getAttachmentDescription( context, (Attachment)page );
}
else
{
@@ -215,10 +219,11 @@
* Generates the RSS resource. You probably want to output this
* result into a file or something, or serve as output from a servlet.
*/
- public String generate()
+ public String generate() throws WikiException
{
- WikiContext context = new WikiContext( m_engine,new WikiPage(
m_engine, "__DUMMY" ) );
- context.setRequestContext( WikiContext.RSS );
+ // FIXME: This will absolutely, positively not work. We need to do
something else
+ WikiContext context =
(WikiContext)m_engine.getWikiActionBeanFactory().newActionBean(null,null,RSSActionBean.class);
+ context.setPage( new WikiPage( m_engine, "__DUMMY" ) );
Feed feed = new RSS10Feed( context );
String result = generateFullWikiRSS( context, feed );
@@ -359,14 +364,14 @@
if( page instanceof Attachment )
{
- url = m_engine.getURL( WikiContext.ATTACH,
+ url = wikiContext.getContext().getURL( AttachActionBean.class,
page.getName(),
null,
true );
}
else
{
- url = m_engine.getURL( WikiContext.VIEW,
+ url = wikiContext.getContext().getURL( ViewActionBean.class,
page.getName(),
null,
true );
@@ -374,7 +379,7 @@
e.setURL( url );
e.setTitle( page.getName() );
- e.setContent( getEntryDescription(page) );
+ e.setContent( getEntryDescription(wikiContext, page) );
e.setAuthor( getAuthor(page) );
feed.addEntry( e );
@@ -422,18 +427,20 @@
String url;
+ Map<String,String> rssParams = new HashMap<String,String>();
+ rssParams.put("version", String.valueOf(page.getVersion()));
if( page instanceof Attachment )
{
- url = m_engine.getURL( WikiContext.ATTACH,
+ url = wikiContext.getContext().getURL( AttachActionBean.class,
page.getName(),
- "version="+page.getVersion(),
+ rssParams,
true );
}
else
{
- url = m_engine.getURL( WikiContext.VIEW,
+ url = wikiContext.getContext().getURL( ViewActionBean.class,
page.getName(),
- "version="+page.getVersion(),
+ rssParams,
true );
}
@@ -444,7 +451,7 @@
e.setURL( url );
e.setTitle( getEntryTitle(page) );
- e.setContent( getEntryDescription(page) );
+ e.setContent( getEntryDescription(wikiContext, page) );
e.setAuthor( getAuthor(page) );
feed.addEntry( e );
@@ -507,14 +514,14 @@
if( page instanceof Attachment )
{
- url = m_engine.getURL( WikiContext.ATTACH,
+ url = wikiContext.getContext().getURL( AttachActionBean.class,
page.getName(),
null,
true );
}
else
{
- url = m_engine.getURL( WikiContext.VIEW,
+ url = wikiContext.getContext().getURL( ViewActionBean.class,
page.getName(),
null,
true );
Modified:
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/search/BasicSearchProvider.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/search/BasicSearchProvider.java?rev=630510&r1=630509&r2=630510&view=diff
==============================================================================
---
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/search/BasicSearchProvider.java
(original)
+++
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/search/BasicSearchProvider.java
Sat Feb 23 11:16:10 2008
@@ -111,7 +111,7 @@
{
if(m_engine.getAttachmentManager().hasAttachments(page))
{
- Collection attachments;
+ Collection<Attachment> attachments;
try
{
attachments =
m_engine.getAttachmentManager().listAttachments(page);
@@ -123,9 +123,9 @@
}
StringBuffer attachmentNames = new StringBuffer();
- for( Iterator it = attachments.iterator(); it.hasNext(); )
+ for( Iterator<Attachment> it = attachments.iterator();
it.hasNext(); )
{
- Attachment att = (Attachment) it.next();
+ Attachment att = it.next();
attachmentNames.append(att.getName());
if(it.hasNext())
attachmentNames.append(separator);
@@ -136,12 +136,12 @@
return "";
}
- private Collection findPages( QueryItem[] query )
+ private Collection<SearchResult> findPages( QueryItem[] query )
{
- TreeSet res = new TreeSet( new SearchResultComparator() );
+ TreeSet<SearchResult> res = new TreeSet<SearchResult>( new
SearchResultComparator() );
SearchMatcher matcher = new SearchMatcher( m_engine, query );
- Collection allPages = null;
+ Collection<WikiPage> allPages = null;
try
{
allPages = m_engine.getPageManager().getAllPages();
@@ -152,12 +152,12 @@
return null;
}
- Iterator it = allPages.iterator();
+ Iterator<WikiPage> it = allPages.iterator();
while( it.hasNext() )
{
try
{
- WikiPage page = (WikiPage) it.next();
+ WikiPage page = it.next();
if (page != null)
{
String pageName = page.getName();
@@ -184,7 +184,7 @@
return res;
}
- public Collection findPages(String query)
+ public Collection<SearchResult> findPages(String query)
{
return findPages(parseQuery(query));
}
Modified:
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/search/LuceneSearchProvider.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/search/LuceneSearchProvider.java?rev=630510&r1=630509&r2=630510&view=diff
==============================================================================
---
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/search/LuceneSearchProvider.java
(original)
+++
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/search/LuceneSearchProvider.java
Sat Feb 23 11:16:10 2008
@@ -91,7 +91,7 @@
private String m_luceneDirectory = null;
private int m_updateCount = 0;
- protected Vector m_updates = new Vector(); // Vector because
multi-threaded.
+ protected Vector<Object[]> m_updates = new Vector<Object[]>(); // Vector
because multi-threaded.
/** Maximum number of fragments from search matches. */
private static final int MAX_FRAGMENTS = 3;
@@ -206,20 +206,18 @@
writer = new IndexWriter( m_luceneDirectory,
getLuceneAnalyzer(),
true );
- Collection allPages =
m_engine.getPageManager().getAllPages();
+ Collection<WikiPage> allPages =
m_engine.getPageManager().getAllPages();
- for( Iterator iterator = allPages.iterator();
iterator.hasNext(); )
+ for( WikiPage page : allPages )
{
- WikiPage page = (WikiPage) iterator.next();
String text = m_engine.getPageManager().getPageText(
page.getName(),
WikiProvider.LATEST_VERSION );
luceneIndexPage( page, text, writer );
}
- Collection allAttachments =
m_engine.getAttachmentManager().getAllAttachments();
- for( Iterator iterator = allAttachments.iterator();
iterator.hasNext(); )
+ Collection<Attachment> allAttachments =
m_engine.getAttachmentManager().getAllAttachments();
+ for( Attachment att : allAttachments )
{
- Attachment att = (Attachment) iterator.next();
String text = getAttachmentContent( att.getName(),
WikiProvider.LATEST_VERSION );
luceneIndexPage( att, text, writer );
@@ -446,12 +444,11 @@
// Now add the names of the attachments of this page
try
{
- Collection attachments =
m_engine.getAttachmentManager().listAttachments(page);
+ Collection<Attachment> attachments =
m_engine.getAttachmentManager().listAttachments(page);
String attachmentNames = "";
- for( Iterator it = attachments.iterator(); it.hasNext(); )
+ for( Attachment att : attachments )
{
- Attachment att = (Attachment) it.next();
attachmentNames += att.getName() + ";";
}
field = new Field(LUCENE_ATTACHMENTS, attachmentNames,
@@ -525,7 +522,7 @@
/**
* [EMAIL PROTECTED]
*/
- public Collection findPages( String query )
+ public Collection<SearchResult> findPages( String query )
throws ProviderException
{
return findPages( query, FLAG_CONTEXTS );
@@ -549,7 +546,7 @@
throws ProviderException
{
Searcher searcher = null;
- ArrayList list = null;
+ ArrayList<SearchResult> list = null;
Highlighter highlighter = null;
try
@@ -579,7 +576,7 @@
Hits hits = searcher.search(luceneQuery);
- list = new ArrayList(hits.length());
+ list = new ArrayList<SearchResult>(hits.length());
for ( int curr = 0; curr < hits.length(); curr++ )
{
Document doc = hits.doc(curr);
@@ -714,7 +711,7 @@
{
while( m_provider.m_updates.size() > 0 )
{
- Object[] pair = ( Object[] )
m_provider.m_updates.remove(0);
+ Object[] pair = m_provider.m_updates.remove(0);
WikiPage page = ( WikiPage ) pair[0];
String text = ( String ) pair[1];
m_provider.updateLuceneIndex(page, text);
Modified:
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/search/SearchManager.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/search/SearchManager.java?rev=630510&r1=630509&r2=630510&view=diff
==============================================================================
---
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/search/SearchManager.java
(original)
+++
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/search/SearchManager.java
Sat Feb 23 11:16:10 2008
@@ -90,7 +90,7 @@
{
StopWatch sw = new StopWatch();
sw.start();
- List list = new ArrayList(maxLength);
+ List<String> list = new ArrayList<String>(maxLength);
if( wikiName.length() > 0 )
{
@@ -99,12 +99,12 @@
String oldStyleName =
MarkupParser.wikifyLink(wikiName).toLowerCase();
- Set allPages = m_engine.getReferenceManager().findCreated();
+ Set<String> allPages =
m_engine.getReferenceManager().findCreated();
int counter = 0;
- for( Iterator i = allPages.iterator(); i.hasNext() && counter
< maxLength; )
+ for( Iterator<String> i = allPages.iterator(); i.hasNext() &&
counter < maxLength; )
{
- String p = (String) i.next();
+ String p = i.next();
String pp = p.toLowerCase();
if( pp.startsWith( wikiName ) || pp.startsWith(
oldStyleName ) )
{
@@ -126,18 +126,18 @@
* @param maxLength How many hits to return
* @return the pages found
*/
- public List findPages( String searchString, int maxLength )
+ public List<HashMap<String,Object>> findPages( String searchString,
int maxLength )
{
StopWatch sw = new StopWatch();
sw.start();
- List list = new ArrayList(maxLength);
+ List<HashMap<String,Object>> list = new
ArrayList<HashMap<String,Object>>(maxLength);
if( searchString.length() > 0 )
{
try
{
- Collection c;
+ Collection<SearchResult> c;
if( m_searchProvider instanceof LuceneSearchProvider )
c =
((LuceneSearchProvider)m_searchProvider).findPages( searchString, 0 );
@@ -145,10 +145,10 @@
c = m_searchProvider.findPages( searchString );
int count = 0;
- for( Iterator i = c.iterator(); i.hasNext() && count <
maxLength; count++ )
+ for( Iterator<SearchResult> i = c.iterator(); i.hasNext()
&& count < maxLength; count++ )
{
- SearchResult sr = (SearchResult)i.next();
- HashMap hm = new HashMap();
+ SearchResult sr = i.next();
+ HashMap<String,Object> hm = new
HashMap<String,Object>();
hm.put( "page", sr.getPage().getName() );
hm.put( "score", new Integer(sr.getScore()) );
list.add( hm );
Modified:
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/search/SearchProvider.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/search/SearchProvider.java?rev=630510&r1=630509&r2=630510&view=diff
==============================================================================
---
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/search/SearchProvider.java
(original)
+++
incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/search/SearchProvider.java
Sat Feb 23 11:16:10 2008
@@ -22,6 +22,7 @@
import java.io.IOException;
import java.util.Collection;
+import com.ecyrd.jspwiki.SearchResult;
import com.ecyrd.jspwiki.WikiPage;
import com.ecyrd.jspwiki.WikiProvider;
import com.ecyrd.jspwiki.providers.ProviderException;
@@ -56,5 +57,5 @@
* @throws ProviderException if the search provider failed.
* @throws IOException if for some reason the query could not be executed.
*/
- public Collection findPages(String query) throws ProviderException,
IOException;
+ public Collection<SearchResult> findPages(String query) throws
ProviderException, IOException;
}