com.xpn.xwiki.plugin.globalsearch
Class GlobalSearchPluginApi

java.lang.Object
  extended by com.xpn.xwiki.api.Api
      extended by com.xpn.xwiki.plugin.PluginApi<GlobalSearchPlugin>
          extended by com.xpn.xwiki.plugin.globalsearch.GlobalSearchPluginApi

public class GlobalSearchPluginApi
extends PluginApi<GlobalSearchPlugin>

API tool to be able to make and merge multi wikis search queries.

Version:
$Id: ffab1a34edfe56e171623e1a0f85b482f62ff856 $

Field Summary
static String CONTEXT_LASTERRORCODE
          Field name of the last error code inserted in context.
static String CONTEXT_LASTEXCEPTION
          Field name of the last API exception inserted in context.
protected static org.slf4j.Logger LOGGER
          Logging tool.
 
Fields inherited from class com.xpn.xwiki.api.Api
context
 
Constructor Summary
GlobalSearchPluginApi(GlobalSearchPlugin plugin, XWikiContext context)
          Create an instance of GlobalSearchPluginApi.
 
Method Summary
 void logError(String errorMessage, XWikiException e)
          Log error and store details in the context.
 GlobalSearchQuery newQuery()
          Create a new instance of GlobalSearchQuery and return it.
 Collection<GlobalSearchResult> search(GlobalSearchQuery query)
          Execute query in all provided wikis and return list containing all results.
 Collection<Document> searchDocuments(GlobalSearchQuery query, boolean distinctbylanguage)
          Search wiki pages in all provided wikis and return list containing found Document.
 Collection<String> searchDocumentsNames(GlobalSearchQuery query, boolean distinctbylanguage, boolean checkRight)
          Search wiki pages in all provided wikis and return list containing found Document.
 
Methods inherited from class com.xpn.xwiki.plugin.PluginApi
getInternalPlugin, getProtectedPlugin, setPlugin
 
Methods inherited from class com.xpn.xwiki.api.Api
convert, convert, getXWikiContext, hasAccessLevel, hasAdminRights, hasProgrammingRights, hasWikiAdminRights
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONTEXT_LASTERRORCODE

public static final String CONTEXT_LASTERRORCODE
Field name of the last error code inserted in context.

See Also:
Constant Field Values

CONTEXT_LASTEXCEPTION

public static final String CONTEXT_LASTEXCEPTION
Field name of the last API exception inserted in context.

See Also:
Constant Field Values

LOGGER

protected static final org.slf4j.Logger LOGGER
Logging tool.

Constructor Detail

GlobalSearchPluginApi

public GlobalSearchPluginApi(GlobalSearchPlugin plugin,
                             XWikiContext context)
Create an instance of GlobalSearchPluginApi.

Parameters:
plugin - the entry point of the Global Search plugin.
context - the XWiki context.
Method Detail

logError

public void logError(String errorMessage,
                     XWikiException e)
Log error and store details in the context.

Parameters:
errorMessage - error message.
e - the catched exception.

newQuery

public GlobalSearchQuery newQuery()
Create a new instance of GlobalSearchQuery and return it.

Returns:
a new instance of GlobalSearchQuery and return it.

search

public Collection<GlobalSearchResult> search(GlobalSearchQuery query)
                                      throws XWikiException
Execute query in all provided wikis and return list containing all results. Compared to XWiki Platform search, searchDocuments and searchDocumentsName it's potentially "time-consuming" since it issues one request per provided wiki.

Parameters:
query - the query parameters. The hql has some constraints:
  • "*" is not supported in SELECT clause.
  • All ORDER BY fields has to be listed in SELECT clause.
Returns:
the search result as list of GlobalSearchResult containing all selected fields values.
Throws:
XWikiException - error when executing query.

searchDocuments

public Collection<Document> searchDocuments(GlobalSearchQuery query,
                                            boolean distinctbylanguage)
                                     throws XWikiException
Search wiki pages in all provided wikis and return list containing found Document. Compared to XWiki Platform search, searchDocuments and searchDocumentsName it's potentially "time-consuming" since it issues one request per provided wiki.

Parameters:
query - the query parameters. The hql has some constraints:
  • "*" is not supported in SELECT clause.
  • All ORDER BY fields has to be listed in SELECT clause.
distinctbylanguage - when a document has multiple version for each language it is returned as one document a language.
Returns:
the found Document.
Throws:
XWikiException - error when executing query.

searchDocumentsNames

public Collection<String> searchDocumentsNames(GlobalSearchQuery query,
                                               boolean distinctbylanguage,
                                               boolean checkRight)
                                        throws XWikiException
Search wiki pages in all provided wikis and return list containing found Document. Compared to XWiki Platform search, searchDocuments and searchDocumentsName it's potentially "time-consuming" since it issues one request per provided wiki.

Parameters:
query - the query parameters. The hql has some constraints:
  • "*" is not supported in SELECT clause.
  • All ORDER BY fields has to be listed in SELECT clause.
distinctbylanguage - when a document has multiple version for each language it is returned as one document a language.
checkRight - if true check for each found document if context's user has "view" rights for it.
Returns:
the found Document.
Throws:
XWikiException - error when executing query.


Copyright © 2004-2013 XWiki. All Rights Reserved.