Package org.opencms.jsp
Class CmsJspTagUserTracking
java.lang.Object
javax.servlet.jsp.tagext.TagSupport
org.opencms.jsp.CmsJspTagUserTracking
- All Implemented Interfaces:
Serializable
,javax.servlet.jsp.tagext.IterationTag
,javax.servlet.jsp.tagext.JspTag
,javax.servlet.jsp.tagext.Tag
Implementation of the
<cms:usertracking/>
tag.This tag can be used to mark OpenCms files as visited or subscribe/unsubscribe them to/from users or groups.
It is also possible to check if single resources are visited/subscribed by the current user.
See also the CmsSubscriptionManager
for more information about subscription or visitation.
- Since:
- 8.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Prefix for the visited session attributes.static final String
Prefix for the visited session attributes.Fields inherited from class javax.servlet.jsp.tagext.TagSupport
id, pageContext
Fields inherited from interface javax.servlet.jsp.tagext.IterationTag
EVAL_BODY_AGAIN
Fields inherited from interface javax.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
protected static String
generateSessionKey
(String prefix, String fileName, boolean subFolder, CmsUser user, List<CmsGroup> groups) Returns a unique session key depending on the values of the given parameters.Returns the action that should be performed, i.e.Returns the current user flag.getFile()
Returns the file name to track.getGroup()
Returns the group name that is used for the tracking.Returns the include groups flag.Returns the online flag.Returns the subfolder flag.getUser()
Returns the user name that is used for the tracking.protected static boolean
isResourceSubscribed
(CmsObject cms, String fileName, boolean subFolder, CmsUser user, List<CmsGroup> groups, javax.servlet.http.HttpServletRequest req) Returns if the given resource is subscribed to the user or groups.protected static boolean
isResourceVisited
(CmsObject cms, String fileName, boolean subFolder, CmsUser user, javax.servlet.http.HttpServletRequest req) Returns if the given resource was visited by the user.void
release()
protected static void
removeSessionAttributes
(String[] prefixes, javax.servlet.http.HttpServletRequest req) Removes all session attributes starting with the given prefixes.void
Sets the action that should be performed, i.e.void
setCurrentuser
(String currentUser) Sets the current user flag.void
Sets the file name to track.void
Sets the group name that is used for the tracking.void
setIncludegroups
(String includeGroups) Sets the include groups flag.void
Sets the online flag.void
setSubfolder
(String subfolder) Sets the subfolder flag.void
Sets the user name that is used for the tracking.static String
userTrackingTagAction
(String action, String fileName, boolean subFolder, boolean currentUser, String userName, boolean includeGroups, String groupName, javax.servlet.http.HttpServletRequest req) Tracks an OpenCms file according to the parameters.Methods inherited from class javax.servlet.jsp.tagext.TagSupport
doAfterBody, doEndTag, findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, setPageContext, setParent, setValue
-
Field Details
-
SESSION_PREFIX_SUBSCRIBED
Prefix for the visited session attributes.- See Also:
-
SESSION_PREFIX_VISITED
Prefix for the visited session attributes.- See Also:
-
-
Constructor Details
-
CmsJspTagUserTracking
public CmsJspTagUserTracking()
-
-
Method Details
-
userTrackingTagAction
public static String userTrackingTagAction(String action, String fileName, boolean subFolder, boolean currentUser, String userName, boolean includeGroups, String groupName, javax.servlet.http.HttpServletRequest req) throws javax.servlet.jsp.JspException Tracks an OpenCms file according to the parameters.- Parameters:
action
- the action that should be performedfileName
- the file name to tracksubFolder
- flag indicating if sub folders should be includedcurrentUser
- flag indicating if the current user should be used for the tracking actionuserName
- the user name that should be used for the actionincludeGroups
- flag indicating if the given users groups should be includedgroupName
- the group name that should be used for the actionreq
- the current request- Returns:
- the result of the action, usually empty except for the check actions
- Throws:
javax.servlet.jsp.JspException
- in case something goes wrong
-
generateSessionKey
protected static String generateSessionKey(String prefix, String fileName, boolean subFolder, CmsUser user, List<CmsGroup> groups) Returns a unique session key depending on the values of the given parameters.- Parameters:
prefix
- the key prefix to usefileName
- the file name to tracksubFolder
- flag indicating if sub folders should be includeduser
- the user that should be usedgroups
- the groups that should be used- Returns:
- a unique session key
-
isResourceSubscribed
protected static boolean isResourceSubscribed(CmsObject cms, String fileName, boolean subFolder, CmsUser user, List<CmsGroup> groups, javax.servlet.http.HttpServletRequest req) throws CmsException Returns if the given resource is subscribed to the user or groups.- Parameters:
cms
- the current users contextfileName
- the file name to tracksubFolder
- flag indicating if sub folders should be includeduser
- the user that should be used for the checkgroups
- the groups that should be used for the checkreq
- the current request- Returns:
true
if the given resource is subscribed to the user or groups, otherwisefalse
- Throws:
CmsException
- if something goes wrong
-
isResourceVisited
protected static boolean isResourceVisited(CmsObject cms, String fileName, boolean subFolder, CmsUser user, javax.servlet.http.HttpServletRequest req) throws CmsException Returns if the given resource was visited by the user.- Parameters:
cms
- the current users contextfileName
- the file name to tracksubFolder
- flag indicating if sub folders should be includeduser
- the user that should be used for the checkreq
- the current request- Returns:
true
if the given resource was visited by the user, otherwisefalse
- Throws:
CmsException
- if something goes wrong
-
removeSessionAttributes
protected static void removeSessionAttributes(String[] prefixes, javax.servlet.http.HttpServletRequest req) Removes all session attributes starting with the given prefixes.- Parameters:
prefixes
- the prefixes of the session attributes to removereq
- the current request
-
doStartTag
- Specified by:
doStartTag
in interfacejavax.servlet.jsp.tagext.Tag
- Overrides:
doStartTag
in classjavax.servlet.jsp.tagext.TagSupport
- Throws:
javax.servlet.jsp.JspException
- See Also:
-
Tag.doStartTag()
-
getAction
Returns the action that should be performed, i.e. mark as visited or subscribe/unsubscribe.- Returns:
- the action that should be performed
-
getCurrentuser
Returns the current user flag.- Returns:
- the current user flag
-
getFile
Returns the file name to track.- Returns:
- the file name to track
-
getGroup
Returns the group name that is used for the tracking.- Returns:
- the group name that is used for the tracking
-
getIncludegroups
Returns the include groups flag.- Returns:
- the include groups flag
-
getOnline
Returns the online flag.- Returns:
- the online flag
-
getSubfolder
Returns the subfolder flag.- Returns:
- the subfolder flag
-
getUser
Returns the user name that is used for the tracking.- Returns:
- the user name that is used for the tracking
-
release
- Specified by:
release
in interfacejavax.servlet.jsp.tagext.Tag
- Overrides:
release
in classjavax.servlet.jsp.tagext.TagSupport
- See Also:
-
Tag.release()
-
setAction
Sets the action that should be performed, i.e. mark as visited or subscribe/unsubscribe.- Parameters:
action
- the action that should be performed
-
setCurrentuser
Sets the current user flag.Current user is
false
by default.- Parameters:
currentUser
- the flag to set
-
setFile
Sets the file name to track.- Parameters:
file
- the file name to track
-
setGroup
Sets the group name that is used for the tracking.- Parameters:
group
- the group name that is used for the tracking
-
setIncludegroups
Sets the include groups flag.Include groups is
false
by default.- Parameters:
includeGroups
- the flag to set
-
setOnline
Sets the online flag.Online is
false
by default.- Parameters:
online
- the flag to set
-
setSubfolder
Sets the subfolder flag.Online is
false
by default.- Parameters:
subfolder
- the flag to set
-
setUser
Sets the user name that is used for the tracking.- Parameters:
user
- the user name that is used for the tracking
-