com.xpn.xwiki.api
Class StatsService

java.lang.Object
  extended by com.xpn.xwiki.api.Api
      extended by com.xpn.xwiki.api.StatsService

public class StatsService
extends Api

Statistics api. The Statistics module needs to be activated (xwiki.stats=1 in xwiki.cfg).


Field Summary
 
Fields inherited from class com.xpn.xwiki.api.Api
context
 
Constructor Summary
StatsService(XWikiContext context)
          Create new StatsService instance.
 
Method Summary
 Map<?,?> getActionStatistics(String action, Scope scope, Period period, Duration step)
          Shows how the statistics for the specified action have evolved over the specified period of time.
 List<?> getBackLinkStatistics(String domain, Scope scope, Period period, Range range)
          Retrieves back-link statistics.
 List<?> getDocumentStatistics(String action, Scope scope, Period period, Range range)
          Retrieves document statistics.
 Collection<?> getRecentActions(String action, int size)
          Returns the recently visited pages for a specific action.
 List<?> getRefererStatistics(String domain, Scope scope, Period period, Range range)
          Retrieves referrer statistics.
 List<?> getVisitStatistics(String action, Period period, Range range)
          Retrieves visit statistics.
 boolean isEnabled()
          Deprecated. use isEnabledForCurrentWiki()
 boolean isEnabledForCurrentWiki()
          Indicate if statistics service is enabled for the current wiki.
 boolean isEnabledGlobally()
          Indicate if statistics service is globally enabled.
 
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
 

Constructor Detail

StatsService

public StatsService(XWikiContext context)
Create new StatsService instance.

Parameters:
context - the XWiki context.
Method Detail

isEnabledGlobally

public boolean isEnabledGlobally()
Indicate if statistics service is globally enabled. Note that it is possible for statistics to be enabled at the global level, yet disabled in most or even all wikis. When statistics are globally enabled, session statistics are available. To check if document statistics are enabled for the current wiki, use isEnabledForCurrentWiki().

To be true the xwiki.stats setting in xwiki.cfg has to be 1.

Returns:
true if the statistics module is enabled

isEnabledForCurrentWiki

public boolean isEnabledForCurrentWiki()
Indicate if statistics service is enabled for the current wiki.

To be true the xwiki.stats in xwiki.cfg has to be 1 and xwiki.stats.default too.

xwiki.stats.default can be overwritten by statistics in XWikiPreferences.

Returns:
true if statistics are enabled for the context's wiki.

isEnabled

@Deprecated
public boolean isEnabled()
Deprecated. use isEnabledForCurrentWiki()

Indicate if statistics service is enabled for the current wiki.

To be true the xwiki.stats in xwiki.cfg has to be 1 and xwiki.stats.default too.

xwiki.stats.default can be overwritten by statistics in XWikiPreferences.

Returns:
true if statistics are enabled for the context's wiki.

getDocumentStatistics

public List<?> getDocumentStatistics(String action,
                                     Scope scope,
                                     Period period,
                                     Range range)
Retrieves document statistics.

Parameters:
action - The action the results should be ordered by. It can be one of: "view", "save" or "download". If the action is "view" then the documents are ordered by the number of times they have been viewed so far.
scope - The set of documents for which to retrieve statistics
period - The period of time
range - The sub-range to return from the entire result set. Use this parameter for pagination
Returns:
A list of DocumentStats objects

getVisitStatistics

public List<?> getVisitStatistics(String action,
                                  Period period,
                                  Range range)
Retrieves visit statistics.

Parameters:
action - The action the results should be ordered by. It can be one of: "view", "save" or "download". If the action is "view" then the visitors are ordered by the number of pages they have viewed so far.
period - The period of time
range - The sub-range to return from the entire result set. Use this parameter for pagination
Returns:
A list of VisitStats objects

getRefererStatistics

public List<?> getRefererStatistics(String domain,
                                    Scope scope,
                                    Period period,
                                    Range range)
Retrieves referrer statistics.

Parameters:
domain - The domain for which to retrieve statistics. To retrieve statistics for all domains use the empty string.
scope - The scope of referred documents to use for filtering the results.
period - The period of time
range - The sub-range to return from the entire result set. Use this parameter for pagination
Returns:
A list of RefererStats objects

getBackLinkStatistics

public List<?> getBackLinkStatistics(String domain,
                                     Scope scope,
                                     Period period,
                                     Range range)
Retrieves back-link statistics.

Parameters:
domain - the domain used for filtering the results
scope - the scope of referred documents for which to retrieve statistics.
period - the period of time
range - the sub-range to return from the entire result set. Use this parameter for pagination
Returns:
a list of DocumentStats objects

getActionStatistics

public Map<?,?> getActionStatistics(String action,
                                    Scope scope,
                                    Period period,
                                    Duration step)
Shows how the statistics for the specified action have evolved over the specified period of time.

Parameters:
action - the action for which to retrieve statistics.
scope - the set of documents to consider.
period - the period of time.
step - the step used for sampling the period.
Returns:
a map of (date, actionCount) pairs.

getRecentActions

public Collection<?> getRecentActions(String action,
                                      int size)
Returns the recently visited pages for a specific action.

Parameters:
action - ("view" or "edit").
size - how many recent actions to retrieve.
Returns:
a ArrayList of document names.