public final class StatsUtil extends Object
Modifier and Type | Class and Description |
---|---|
static class |
StatsUtil.PeriodType
The type of the period.
|
Modifier and Type | Method and Description |
---|---|
protected static javax.servlet.http.Cookie |
addCookie(XWikiContext context)
Create a new visit cookie and return it.
|
static boolean |
findCookie(XWikiContext context)
Try to find the cookie of the current request or create it.
|
static VisitStats |
findVisit(XWikiContext context)
Try to find the visiting session of the current request, or create a new one if this request is not part of a
visit.
|
protected static VisitStats |
findVisitByCookie(String cookie,
XWikiContext context)
Search visit statistics object in the database based on cookie name.
|
protected static VisitStats |
findVisitByField(String fieldName,
String fieldValue,
XWikiContext context)
Search visit statistics object in the database based on cookie name.
|
protected static VisitStats |
findVisitByIPUA(String uniqueID,
XWikiContext context)
Search visit statistics object in the database based on visit unique id.
|
static String[] |
getCookieDomains(XWikiContext context) |
static Date |
getCookieExpirationDate() |
static int |
getPeriodAsInt(Date date,
StatsUtil.PeriodType type)
Computes an integer representation of the passed date using the following format:
"yyyMMdd" for
StatsUtil.PeriodType.DAY
"yyyMM" for StatsUtil.PeriodType.MONTH
. |
static Collection<?> |
getRecentActionFromSessions(XWikiContext context,
String action) |
static int |
getRecentVisitSize(XWikiContext context) |
static String |
getReferer(XWikiContext context) |
static Collection<DocumentReference> |
getRequestFilteredUsers(XWikiContext context)
The list of users to filter in view request.
|
static Collection<DocumentReference> |
getStorageFilteredUsers(XWikiContext context)
The list of users to filter when storing statistics.
|
static VisitStats |
getVisitFromSession(javax.servlet.http.HttpSession session) |
static boolean |
isStatsEnabled(XWikiContext context) |
static boolean |
isWikiStatsEnabled(XWikiContext context) |
static void |
setRecentActionsFromSession(XWikiContext context,
String action,
Collection<?> actions)
Store the recent statistics actions in the session.
|
static void |
setVisitInSession(javax.servlet.http.HttpSession session,
VisitStats visitStat)
Store the visit object in the session.
|
public static int getPeriodAsInt(Date date, StatsUtil.PeriodType type)
StatsUtil.PeriodType.DAY
StatsUtil.PeriodType.MONTH
date
- the date for which to return an integer representation.type
- the date type. It can be StatsUtil.PeriodType.DAY
or StatsUtil.PeriodType.MONTH
.SimpleDateFormat
public static String[] getCookieDomains(XWikiContext context)
context
- the XWiki context.public static Date getCookieExpirationDate()
public static Collection<?> getRecentActionFromSessions(XWikiContext context, String action)
context
- the XWiki context from where to get the HTTP session session.action
- the action id.public static void setRecentActionsFromSession(XWikiContext context, String action, Collection<?> actions)
context
- the XWiki context from where to get the HTTP session session.action
- the action id.actions
- the actions.public static int getRecentVisitSize(XWikiContext context)
context
- the XWiki context.public static VisitStats getVisitFromSession(javax.servlet.http.HttpSession session)
session
- the session.public static void setVisitInSession(javax.servlet.http.HttpSession session, VisitStats visitStat)
session
- the session.visitStat
- the visit object.public static boolean isStatsEnabled(XWikiContext context)
context
- the XWiki context.public static boolean isWikiStatsEnabled(XWikiContext context)
context
- the XWiki contextpublic static VisitStats findVisit(XWikiContext context)
context
- The context of this request.protected static VisitStats findVisitByField(String fieldName, String fieldValue, XWikiContext context) throws XWikiException
fieldName
- the field name.fieldValue
- the field value.context
- the XWiki context.XWikiException
- error when searching for visit object.protected static VisitStats findVisitByCookie(String cookie, XWikiContext context) throws XWikiException
cookie
- the cookie name.context
- the XWiki context.XWikiException
- error when searching for visit object.protected static VisitStats findVisitByIPUA(String uniqueID, XWikiContext context) throws XWikiException
uniqueID
- the visit unique id.context
- the XWiki context.XWikiException
- error when searching for visit object.protected static javax.servlet.http.Cookie addCookie(XWikiContext context)
context
- the XWiki context.public static boolean findCookie(XWikiContext context)
context
- The context of this request.public static String getReferer(XWikiContext context)
context
- the XWiki context.public static Collection<DocumentReference> getStorageFilteredUsers(XWikiContext context) throws XWikiException
context
- the XWiki contextXWikiException
- error when trying to resolve userspublic static Collection<DocumentReference> getRequestFilteredUsers(XWikiContext context) throws XWikiException
context
- the XWiki contextXWikiException
- error when trying to resolve usersCopyright © 2004–2021 XWiki. All rights reserved.