jspwiki-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ajaqu...@apache.org
Subject svn commit: r762300 - in /incubator/jspwiki/trunk/src/java/org/apache/wiki: search/BasicSearchProvider.java search/LuceneSearchProvider.java search/SearchManager.java ui/stripes/WikiPageTypeConverter.java url/StripesURLConstructor.java
Date Mon, 06 Apr 2009 12:02:47 GMT
Author: ajaquith
Date: Mon Apr  6 12:02:47 2009
New Revision: 762300

URL: http://svn.apache.org/viewvc?rev=762300&view=rev
Log:
Fixed bug in HandlerInfo that was preventing evaluation of permissions when <null> pages
were set.

Modified:
    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/SearchManager.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/WikiPageTypeConverter.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/url/StripesURLConstructor.java

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=762300&r1=762299&r2=762300&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 Mon Apr
 6 12:02:47 2009
@@ -150,15 +150,15 @@
         return "";
     }
 
-    private Collection findPages( QueryItem[] query )
+    private Collection<SearchResult> findPages( QueryItem[] query )
     {
         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();
+            allPages = m_engine.getContentManager().getAllPages( null );
         }
         catch( ProviderException pe )
         {
@@ -166,17 +166,14 @@
             return null;
         }
 
-        Iterator it = allPages.iterator();
-        while( it.hasNext() )
+        for ( WikiPage page : allPages )
         {
             try
             {
-                WikiPage page = (WikiPage) it.next();
                 if (page != null)
                 {
                     String pageName = page.getName();
-                    String pageContent = m_engine.getPageManager().getPageText(pageName,
WikiPageProvider.LATEST_VERSION) +
-                                         attachmentNames(page, " ");
+                    String pageContent = page.getContentAsString() + attachmentNames(page,
" ");
                     SearchResult comparison = matcher.matchPageContent( pageName, pageContent
);
 
                     if( comparison != null )
@@ -185,10 +182,6 @@
                     }
                 }
             }
-            catch( PageNotFoundException e )
-            {
-                log.error( "Unable to page content", e );
-            }
             catch( ProviderException pe )
             {
                 log.error( "Unable to retrieve page from cache", pe );
@@ -205,7 +198,7 @@
     /**
      *  {@inheritDoc}
      */
-    public Collection findPages(String query)
+    public Collection<SearchResult> findPages(String query)
     {
         return 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=762300&r1=762299&r2=762300&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 Mon
Apr  6 12:02:47 2009
@@ -306,7 +306,7 @@
      * @param att Attachment to get content for. Filename extension is used to determine
the type of the attachment.
      * @return String representing the content of the file.
      * FIXME This is a very simple implementation of some text-based attachment, mainly used
for testing.
-     * This should be replaced /moved to Attachment search providers or some other 'plugable'
wat to search attachments
+     * This should be replaced /moved to Attachment search providers or some other 'pluggable'
way to search attachments
      */
     protected String getAttachmentContent( Attachment att )
     {

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/search/SearchManager.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/search/SearchManager.java?rev=762300&r1=762299&r2=762300&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/search/SearchManager.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/search/SearchManager.java Mon Apr  6
12:02:47 2009
@@ -87,7 +87,7 @@
     {
         initialize( engine, properties );
 
-        WikiEventUtils.addWikiEventListener(m_engine.getPageManager(),
+        WikiEventUtils.addWikiEventListener(m_engine.getContentManager(),
                                             WikiPageEvent.PAGE_DELETE_REQUEST, this);
 
         JSONRPCManager.registerGlobalObject( JSON_SEARCH, new JSONSearch() );
@@ -129,7 +129,7 @@
 
                 String oldStyleName = MarkupParser.wikifyLink(wikiName).toLowerCase() + filename;
 
-                Set allPages;
+                Set<String> allPages;
                 try
                 {
                     allPages = m_engine.getReferenceManager().findCreated();
@@ -137,13 +137,13 @@
                 catch( ProviderException e )
                 {
                     // FIXME: THis is probably not very smart.
-                    allPages = new TreeSet();
+                    allPages = new TreeSet<String>();
                 }
 
                 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( cleanWikiName) || pp.startsWith( oldStyleName ) )
                     {

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/WikiPageTypeConverter.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/WikiPageTypeConverter.java?rev=762300&r1=762299&r2=762300&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/WikiPageTypeConverter.java
(original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/WikiPageTypeConverter.java
Mon Apr  6 12:02:47 2009
@@ -26,6 +26,7 @@
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.api.WikiPage;
 import org.apache.wiki.content.PageNotFoundException;
+import org.apache.wiki.content.WikiName;
 import org.apache.wiki.providers.ProviderException;
 
 import net.sourceforge.stripes.controller.StripesFilter;
@@ -74,7 +75,30 @@
         }
         catch( PageNotFoundException e )
         {
-            errors.add( new LocalizableError( "common.nopage", pageName ) );
+            try
+            {
+                WikiName finalName = engine.getFinalPageName( WikiName.valueOf( pageName
) );
+                if ( finalName == null )
+                {
+                    errors.add( new LocalizableError( "common.nopage", pageName ) );
+                }
+                else
+                {
+                    try
+                    {
+                        return engine.getPage( finalName );
+                    }
+                    catch( PageNotFoundException pnf )
+                    {
+                        // This should never happen, because getFinalPageName always verifies
the page exists!
+                        pnf.printStackTrace();
+                    }
+                }
+            }
+            catch( ProviderException e2 )
+            {
+                errors.add( new SimpleError( e2.getMessage() ) );
+            }
         }
         catch( ProviderException e )
         {

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/url/StripesURLConstructor.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/url/StripesURLConstructor.java?rev=762300&r1=762299&r2=762300&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/url/StripesURLConstructor.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/url/StripesURLConstructor.java Mon Apr
 6 12:02:47 2009
@@ -186,6 +186,11 @@
                 throw new RuntimeException( "Stripes ActionResolver was not AnnotatedClassActionResolver!
Fatal error." );
             }
         }
+        else
+        {
+            Thread.dumpStack();
+            throw new RuntimeException( "Could not retrieve the Stripes configuration. Something
is wrong..." );
+        }
 
         // Load the URL patterns from the config file
         File file = new File( "WEB-INF/urlpattern.properties" );



Mime
View raw message