Commits

David Chui committed 3114472

[CONTRB-40] Made compatible with very recent changes of the v2 search API. Fixed a bug where NPEs would be thrown if the pages processed by this plugin has not been indexed by the its extractors before.

Comments (0)

Files changed (2)

contrb-40/src/main/java/com/atlassian/confluence/contributors/util/PageDetailsHelper.java

                                     final Document document = indexSearcher.doc(i);
                                     String line;
 
-                                    reader = new BufferedReader(new StringReader(document.get(AuthorContributionExtractor.AUTHOR_CONTRIBUTIONS)));
+                                    reader = new BufferedReader(new StringReader(StringUtils.defaultString(document.get(AuthorContributionExtractor.AUTHOR_CONTRIBUTIONS))));
                                     while (null != (line = reader.readLine()))
                                     {
                                         final String[] authorContributionTokens = StringUtils.splitByWholeSeparator(line, AbstractContributionExtractor.CONTRIBUTION_TOKEN_SEPARATOR);
                                     final Document document = indexSearcher.doc(i);
                                     String line;
 
-                                    reader = new BufferedReader(new StringReader(document.get(LabelContributionExtractor.LABEL_CONTRIBUTIONS)));
+                                    reader = new BufferedReader(new StringReader(StringUtils.defaultString(document.get(LabelContributionExtractor.LABEL_CONTRIBUTIONS))));
                                     while (null != (line = reader.readLine()))
                                     {
                                         final String[] labelContributionTokens = StringUtils.splitByWholeSeparator(line, AbstractContributionExtractor.CONTRIBUTION_TOKEN_SEPARATOR);
                                     final Document document = indexSearcher.doc(i);
                                     String line;
 
-                                    reader = new BufferedReader(new StringReader(document.get(NotificationContributionExtractor.WATCHERS)));
+                                    reader = new BufferedReader(new StringReader(StringUtils.defaultString(document.get(NotificationContributionExtractor.WATCHERS))));
                                     while (null != (line = reader.readLine()))
                                     {
                                         if (StringUtils.isNotBlank(line))

contrb-40/src/main/java/com/atlassian/confluence/contributors/util/PageSearchHelper.java

 import com.atlassian.confluence.search.v2.SearchQuery;
 import com.atlassian.confluence.search.v2.SearchResult;
 import com.atlassian.confluence.search.v2.SearchResults;
+import com.atlassian.confluence.search.v2.searchfilter.ContentPermissionsSearchFilter;
 import com.atlassian.confluence.search.v2.query.BooleanQuery;
 import com.atlassian.confluence.search.v2.query.ContentTypeQuery;
 import com.atlassian.confluence.search.v2.query.InSpaceQuery;
         try
         {
             return getSearchManager().search(
-                        new Search(searchQuery, null, new PublishedDateAndTitleResultFilter(contentTitle, publishedDate, Calendar.DAY_OF_MONTH)));
+                        new Search(searchQuery, null, ContentPermissionsSearchFilter.getInstance(), new PublishedDateAndTitleResultFilter(contentTitle, publishedDate, Calendar.DAY_OF_MONTH)));
         }
         finally
         {