Package com.xpn.xwiki.api
Class StatsService
- java.lang.Object
-
- com.xpn.xwiki.api.Api
-
- 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).- Version:
- $Id: a4ab447cf37d0e66a0b35eaa0f2c3626ebda4afc $
-
-
Constructor Summary
Constructors Constructor Description StatsService(XWikiContext context)
Create new StatsService instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description 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.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, convert, convertAttachments, getAuthorizationManager, getContextualAuthorizationManager, getXWikiContext, hasAccess, hasAccessLevel, hasAdminRights, hasProgrammingRights, hasWikiAdminRights
-
-
-
-
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, useisEnabledForCurrentWiki()
.To be true the
xwiki.stats
setting in xwiki.cfg has to be1
.- 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 be1
andxwiki.stats.default
too.xwiki.stats.default
can be overwritten bystatistics
inXWikiPreferences
.- Returns:
- true if statistics are enabled for the context's wiki.
-
isEnabled
@Deprecated public boolean isEnabled()
Deprecated.Indicate if statistics service is enabled for the current wiki.To be true the
xwiki.stats
in xwiki.cfg has to be1
andxwiki.stats.default
too.xwiki.stats.default
can be overwritten bystatistics
inXWikiPreferences
.- 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 statisticsperiod
- The period of timerange
- 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 timerange
- 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 timerange
- 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 resultsscope
- the scope of referred documents for which to retrieve statistics.period
- the period of timerange
- 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.
-
-