diff --git a/ccm-core/src/com/arsdigita/search/ui/filters/SimpleCategoryFilterWidget.java b/ccm-core/src/com/arsdigita/search/ui/filters/SimpleCategoryFilterWidget.java index 41d9e26b0..59b9266fa 100755 --- a/ccm-core/src/com/arsdigita/search/ui/filters/SimpleCategoryFilterWidget.java +++ b/ccm-core/src/com/arsdigita/search/ui/filters/SimpleCategoryFilterWidget.java @@ -43,7 +43,7 @@ public class SimpleCategoryFilterWidget extends CategoryFilterWidget { /** * Creates a new category filter */ - protected SimpleCategoryFilterWidget() { + public SimpleCategoryFilterWidget() { m_roots = new Category[0]; } diff --git a/ccm-ldn-search/src/com/arsdigita/london/search/RemoteSearcher.java b/ccm-ldn-search/src/com/arsdigita/london/search/RemoteSearcher.java index 7dd0595bf..b76b479ea 100755 --- a/ccm-ldn-search/src/com/arsdigita/london/search/RemoteSearcher.java +++ b/ccm-ldn-search/src/com/arsdigita/london/search/RemoteSearcher.java @@ -120,6 +120,10 @@ public class RemoteSearcher extends Thread { if (results != null && !results.isEmpty()) { s_log.debug("about to add results to the searchgroup"); job.getGroup().addResults( results ); + } else { + // Need to add empty results to register completion + // of one servers search. + job.getGroup().addResults(Collections.EMPTY_LIST); } } catch( RemoteException ex ) { s_log.error( "Failure making SOAP call to " + url + ": " + diff --git a/ccm-ldn-search/src/com/arsdigita/london/search/SOAPHandler.java b/ccm-ldn-search/src/com/arsdigita/london/search/SOAPHandler.java index 7e5f39685..82fb642e1 100755 --- a/ccm-ldn-search/src/com/arsdigita/london/search/SOAPHandler.java +++ b/ccm-ldn-search/src/com/arsdigita/london/search/SOAPHandler.java @@ -19,6 +19,7 @@ import com.arsdigita.search.QuerySpecification; import com.arsdigita.search.ResultSet; import com.arsdigita.search.Document; import com.arsdigita.search.filters.PermissionFilterSpecification; +import com.arsdigita.search.filters.ContentSectionFilterSpecification; import com.arsdigita.london.util.Transaction; import com.arsdigita.cms.search.VersionFilterSpecification; import com.arsdigita.cms.ContentItem; @@ -59,12 +60,21 @@ public class SOAPHandler { if (com.arsdigita.search.Search.getConfig().isIntermediaEnabled()) { spec.addFilter(new PermissionFilterSpecification()); } + + String[] sections = Search.getConfig().getRemoteSearchContentSections(); + if (sections != null) { + spec.addFilter(new ContentSectionFilterSpecification(sections)); + } + spec.addFilter(new VersionFilterSpecification(ContentItem.LIVE)); ResultSet resultSet = com.arsdigita.search.Search.processInternal( spec, com.arsdigita.search.Search.getConfig().getIndexer()); - Iterator docs = resultSet.getDocuments(0, 50); + + // Get max. number of remote results as specified in config. param. + Iterator docs = resultSet.getDocuments(0, + Search.getConfig().getMaxRemoteResults().longValue()); s_log.debug("About to return results for query: " + terms); diff --git a/ccm-ldn-search/src/com/arsdigita/london/search/SearchConfig.java b/ccm-ldn-search/src/com/arsdigita/london/search/SearchConfig.java index 4832ee38b..cc210b1fb 100755 --- a/ccm-ldn-search/src/com/arsdigita/london/search/SearchConfig.java +++ b/ccm-ldn-search/src/com/arsdigita/london/search/SearchConfig.java @@ -22,6 +22,7 @@ import com.arsdigita.runtime.AbstractConfig; import com.arsdigita.util.parameter.BooleanParameter; import com.arsdigita.util.parameter.Parameter; import com.arsdigita.util.parameter.IntegerParameter; +import com.arsdigita.util.parameter.StringArrayParameter; import com.arsdigita.util.parameter.StringParameter; import java.util.StringTokenizer; @@ -43,6 +44,8 @@ public final class SearchConfig extends AbstractConfig { private final Parameter m_numThreads; private final Parameter m_searchTimeout; private final Parameter m_showSponsoredLinks; + private final Parameter m_maxRemoteResults; + private final Parameter m_remoteSearchContentSections; private final Parameter m_simpleRestrictTo; private String[] simpleRestrictToArray; @@ -57,6 +60,12 @@ public final class SearchConfig extends AbstractConfig { m_showSponsoredLinks = new BooleanParameter ("com.arsdigita.london.search.show_sponsored_links", Parameter.REQUIRED, Boolean.FALSE); + m_maxRemoteResults = new IntegerParameter + ("com.arsdigita.london.search.max_remote_results", + Parameter.REQUIRED, new Integer(50)); + m_remoteSearchContentSections = new StringArrayParameter + ("com.arsdigita.london.search.remote_search_content_sections", + Parameter.OPTIONAL, null); m_simpleRestrictTo = new StringParameter ("com.arsdigita.london.search.simple_restrict_to", Parameter.OPTIONAL, ""); @@ -64,6 +73,8 @@ public final class SearchConfig extends AbstractConfig { register(m_numThreads); register(m_searchTimeout); register(m_showSponsoredLinks); + register(m_maxRemoteResults); + register(m_remoteSearchContentSections); register(m_simpleRestrictTo); loadInfo(); } @@ -82,10 +93,27 @@ public final class SearchConfig extends AbstractConfig { return (Boolean) get(m_showSponsoredLinks); } + public final Integer getMaxRemoteResults() { + return (Integer) get(m_maxRemoteResults); + } + public final String getSimpleRestrictTo() { return (String) get(m_simpleRestrictTo); } + /** + * When this server is the target of a remote search, this + * parameter enables us to filter by content section - so for + * example, we can prevent results from subsites being + * available externally is we specify the main site content + * section. If parameter is unset, then all content sections + * are searched + * @return + */ + public final String[] getRemoteSearchContentSections() { + return (String[])get(m_remoteSearchContentSections); + } + public final String[] getSimpleRestrictToArray() { if (simpleRestrictToArray == null) { loadSimpleRestrictToArray(); diff --git a/ccm-ldn-search/src/com/arsdigita/london/search/SearchConfig_parameter.properties b/ccm-ldn-search/src/com/arsdigita/london/search/SearchConfig_parameter.properties index 8e5ff63e9..fb12c386d 100755 --- a/ccm-ldn-search/src/com/arsdigita/london/search/SearchConfig_parameter.properties +++ b/ccm-ldn-search/src/com/arsdigita/london/search/SearchConfig_parameter.properties @@ -11,3 +11,14 @@ com.arsdigita.london.search.show_sponsored_links.title=Show Sponsored Links com.arsdigita.london.search.show_sponsored_links.purpose=Whether or not to display Sponsored Links in addition to search results com.arsdigita.london.search.show_sponsored_links.example=false com.arsdigita.london.search.show_sponsored_links.format=[boolean] + +com.arsdigita.london.search.max_remote_results.title=Number of Remote Search Results to Return +com.arsdigita.london.search.max_remote_results.purpose=What is the maximum number of remote search results this server should return +com.arsdigita.london.search.max_remote_results.example=50 +com.arsdigita.london.search.max_remote_results.format=[integer] + +com.arsdigita.london.search.remote_search_content_sections.title=Content Sections for Remote Search +com.arsdigita.london.search.remote_search_content_sections.purpose=When this host is a target for remote search, filter results to specified content sections +com.arsdigita.london.search.remote_search_content_sections.example=content,forms +com.arsdigita.london.search.remote_search_content_sections.format=[string,string,string] + diff --git a/ccm-ldn-search/src/com/arsdigita/london/search/ui/AdvancedQueryComponent.java b/ccm-ldn-search/src/com/arsdigita/london/search/ui/AdvancedQueryComponent.java index 93834e18e..381ae297a 100755 --- a/ccm-ldn-search/src/com/arsdigita/london/search/ui/AdvancedQueryComponent.java +++ b/ccm-ldn-search/src/com/arsdigita/london/search/ui/AdvancedQueryComponent.java @@ -62,8 +62,15 @@ public class AdvancedQueryComponent extends BaseQueryComponent { Application app = Web.getContext().getApplication(); Category root = Category.getRootForObject(app); - add(new SimpleCategoryFilterWidget(root)); + // cg - if no default domain mapped to search application, don't + // display widget. Also, allows implementations that use advanced search + // without the advanced search UI to work without default mapping + if (root != null) { + add(new SimpleCategoryFilterWidget(root)); + } else { + add(new SimpleCategoryFilterWidget()); + } add(new ContentTypeFilterWidget()); add(new VersionFilterComponent(context)); }