jspwiki-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dvit...@apache.org
Subject svn commit: r1655991 - in /jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/search: BasicSearchProvider.java LuceneSearchProvider.java SearchManager.java
Date Fri, 30 Jan 2015 12:31:31 GMT
Author: dvittor
Date: Fri Jan 30 12:31:30 2015
New Revision: 1655991

URL: http://svn.apache.org/r1655991
Log:
JSPWIKI-502: and JSPWIKI-760 Fixed these issues using WikiEngine.createContext.

Modified:
    jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/search/BasicSearchProvider.java
    jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/search/LuceneSearchProvider.java
    jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/search/SearchManager.java

Modified: jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/search/BasicSearchProvider.java
URL: http://svn.apache.org/viewvc/jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/search/BasicSearchProvider.java?rev=1655991&r1=1655990&r2=1655991&view=diff
==============================================================================
--- jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/search/BasicSearchProvider.java
(original)
+++ jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/search/BasicSearchProvider.java
Fri Jan 30 12:31:30 2015
@@ -153,12 +153,9 @@ public class BasicSearchProvider impleme
         SearchMatcher matcher = new SearchMatcher( m_engine, query );
 
         Collection allPages = null;
-        try
-        {
+        try {
             allPages = m_engine.getPageManager().getAllPages();
-        }
-        catch( ProviderException pe )
-        {
+        } catch( ProviderException pe ) {
             log.error( "Unable to retrieve page list", pe );
             return null;
         }
@@ -166,34 +163,26 @@ public class BasicSearchProvider impleme
         AuthorizationManager mgr = m_engine.getAuthorizationManager();
 
         Iterator it = allPages.iterator();
-        while( it.hasNext() )
-        {
-            try
-            {
+        while( it.hasNext() ) {
+            try {
                 WikiPage page = (WikiPage) it.next();
-                if (page != null)
-                {
+                if (page != null) {
+                	
                     PagePermission pp = new PagePermission( page, PagePermission.VIEW_ACTION
);
-                    // TODO: WikiContext should never be null
                     if( wikiContext==null || mgr.checkPermission( wikiContext.getWikiSession(),
pp ) ) {
-                    String pageName = page.getName();
-                    String pageContent = m_engine.getPageManager().getPageText(pageName,
WikiPageProvider.LATEST_VERSION) +
-                                         attachmentNames(page, " ");
-                    SearchResult comparison = matcher.matchPageContent( pageName, pageContent
);
-
-                    if( comparison != null )
-                    {
-                        res.add( comparison );
-                    }
-                }
-            }
-            }
-            catch( ProviderException pe )
-            {
+	                    String pageName = page.getName();
+	                    String pageContent = m_engine.getPageManager().getPageText(pageName,
WikiPageProvider.LATEST_VERSION) +
+	                                         attachmentNames(page, " ");
+	                    SearchResult comparison = matcher.matchPageContent( pageName, pageContent
);
+	
+	                    if( comparison != null ) {
+	                        res.add( comparison );
+	                    }
+	                }
+	            }
+            } catch( ProviderException pe ) {
                 log.error( "Unable to retrieve page from cache", pe );
-            }
-            catch( IOException ioe )
-            {
+            } catch( IOException ioe ) {
                 log.error( "Failed to search page", ioe );
             }
         }
@@ -204,16 +193,14 @@ public class BasicSearchProvider impleme
     /**
      *  {@inheritDoc}
      */
-    public Collection findPages(String query, WikiContext wikiContext)
-    {
+    public Collection findPages(String query, WikiContext wikiContext) {
         return findPages(parseQuery(query), wikiContext);
     }
 
     /**
      *  {@inheritDoc}
      */
-    public String getProviderInfo()
-    {
+    public String getProviderInfo() {
         return "BasicSearchProvider";
     }
 

Modified: jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/search/LuceneSearchProvider.java
URL: http://svn.apache.org/viewvc/jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/search/LuceneSearchProvider.java?rev=1655991&r1=1655990&r2=1655991&view=diff
==============================================================================
--- jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/search/LuceneSearchProvider.java
(original)
+++ jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/search/LuceneSearchProvider.java
Fri Jan 30 12:31:30 2015
@@ -669,8 +669,7 @@ public class LuceneSearchProvider implem
                     }
 
                     PagePermission pp = new PagePermission( page, PagePermission.VIEW_ACTION
);
-                    // TODO: WikiContext should never be null
-	                if( wikiContext==null || mgr.checkPermission( wikiContext.getWikiSession(),
pp ) ) {
+	                if( mgr.checkPermission( wikiContext.getWikiSession(), pp ) ) {
 	
 	                    int score = (int)(hits[curr].score * 100);
 	

Modified: jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/search/SearchManager.java
URL: http://svn.apache.org/viewvc/jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/search/SearchManager.java?rev=1655991&r1=1655990&r2=1655991&view=diff
==============================================================================
--- jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/search/SearchManager.java (original)
+++ jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/search/SearchManager.java Fri
Jan 30 12:31:30 2015
@@ -142,8 +142,10 @@ public class SearchManager extends Basic
     			} else if (actionName.equals(AJAX_ACTION_PAGES)) {
     				List<Map<String,Object>> callResults = new ArrayList<Map<String,Object>>();
     				log.debug("Calling findPages() START");
-    				// FIXME: JSPWIKI-502 In an AJAX call we do not have access to WikiContext and so
the below is null.
-    				WikiContext wikiContext = (WikiContext)req.getAttribute( WikiTagBase.ATTR_CONTEXT
);
+    				WikiContext wikiContext = m_engine.createContext(req, WikiContext.VIEW);
+    				if (wikiContext == null) {
+    					throw new ServletException("Could not create a WikiContext from the request "+req);
+    				}
     				callResults = findPages(itemId, maxResults, wikiContext);
     				log.debug("Calling findPages() DONE. "+callResults.size());
     				result = AjaxUtil.toJson(callResults);



Mime
View raw message