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

public class CmsJspTagUserTracking extends javax.servlet.jsp.tagext.TagSupport
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 Details

  • Constructor Details

  • 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 performed
      fileName - the file name to track
      subFolder - flag indicating if sub folders should be included
      currentUser - flag indicating if the current user should be used for the tracking action
      userName - the user name that should be used for the action
      includeGroups - flag indicating if the given users groups should be included
      groupName - the group name that should be used for the action
      req - 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 use
      fileName - the file name to track
      subFolder - flag indicating if sub folders should be included
      user - the user that should be used
      groups - 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 context
      fileName - the file name to track
      subFolder - flag indicating if sub folders should be included
      user - the user that should be used for the check
      groups - the groups that should be used for the check
      req - the current request
      Returns:
      true if the given resource is subscribed to the user or groups, otherwise false
      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 context
      fileName - the file name to track
      subFolder - flag indicating if sub folders should be included
      user - the user that should be used for the check
      req - the current request
      Returns:
      true if the given resource was visited by the user, otherwise false
      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 remove
      req - the current request
    • doStartTag

      public int doStartTag() throws javax.servlet.jsp.JspException
      Specified by:
      doStartTag in interface javax.servlet.jsp.tagext.Tag
      Overrides:
      doStartTag in class javax.servlet.jsp.tagext.TagSupport
      Throws:
      javax.servlet.jsp.JspException
      See Also:
      • Tag.doStartTag()
    • getAction

      public String 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

      public String getFile()
      Returns the file name to track.

      Returns:
      the file name to track
    • getGroup

      public String 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

      public String getOnline()
      Returns the online flag.

      Returns:
      the online flag
    • getSubfolder

      public String getSubfolder()
      Returns the subfolder flag.

      Returns:
      the subfolder flag
    • getUser

      public String getUser()
      Returns the user name that is used for the tracking.

      Returns:
      the user name that is used for the tracking
    • release

      public void release()
      Specified by:
      release in interface javax.servlet.jsp.tagext.Tag
      Overrides:
      release in class javax.servlet.jsp.tagext.TagSupport
      See Also:
      • Tag.release()
    • setAction

      public void setAction(String action)
      Sets the action that should be performed, i.e. mark as visited or subscribe/unsubscribe.

      Parameters:
      action - the action that should be performed
    • setCurrentuser

      public void setCurrentuser(String currentUser)
      Sets the current user flag.

      Current user is false by default.

      Parameters:
      currentUser - the flag to set
    • setFile

      public void setFile(String file)
      Sets the file name to track.

      Parameters:
      file - the file name to track
    • setGroup

      public void setGroup(String group)
      Sets the group name that is used for the tracking.

      Parameters:
      group - the group name that is used for the tracking
    • setIncludegroups

      public void setIncludegroups(String includeGroups)
      Sets the include groups flag.

      Include groups is false by default.

      Parameters:
      includeGroups - the flag to set
    • setOnline

      public void setOnline(String online)
      Sets the online flag.

      Online is false by default.

      Parameters:
      online - the flag to set
    • setSubfolder

      public void setSubfolder(String subfolder)
      Sets the subfolder flag.

      Online is false by default.

      Parameters:
      subfolder - the flag to set
    • setUser

      public void setUser(String user)
      Sets the user name that is used for the tracking.

      Parameters:
      user - the user name that is used for the tracking