Class AnalyticsManager

    • Method Detail

      • isDisable

        public boolean isDisable()
      • propertiesChange

        public void propertiesChange​(JProperties properties)
        Description copied from interface: JPropertiesListener
        Invoked after properties have been modified in JCMS and save on disk.

        You cannot alter the value received in parameters.

        Note that properties parameter may be null, a limited set of site properties, or all site properties.

        To check that a property has been modified, reload the "current" property instead using channel.getProperties or channel.getProperty.

        Specified by:
        propertiesChange in interface JPropertiesListener
        Parameters:
        properties - the properties which have been submitted to change
      • checkRequirements

        public boolean checkRequirements()
      • serializeEvent

        public java.lang.String serializeEvent​(EventData data)
                                        throws java.io.IOException
        Serialize an EventData in a string
        Parameters:
        data - the EventData
        Returns:
        the JSON value
        Throws:
        java.io.IOException - Exception thrown when eventData is save as JSON data
      • getObjectMapper

        public org.codehaus.jackson.map.ObjectMapper getObjectMapper()
        get the ObjectMapper (cached in the class)
        Returns:
        the ObjectMapper
      • getRequestCustomContextMap

        public java.util.Map<java.lang.String,​java.lang.String> getRequestCustomContextMap​(javax.servlet.http.HttpServletRequest request)
        Get the context Map which will be merge with existing context if it exists before writing EventData
        Parameters:
        request - the current HttpServletRequest (if null, context map will be get from a ThreadLocal object)
        Returns:
        the context Map
      • getThreadLocalCustomContextMap

        public java.util.Map<java.lang.String,​java.lang.String> getThreadLocalCustomContextMap()
        Get the context Map which will be merge with existing context if it exists before writing EventData context map will be get from a ThreadLocal object
        Returns:
        the context Map
      • appendPageEvent

        public static void appendPageEvent​(javax.servlet.http.HttpServletRequest request,
                                           long startPageRequest)
                                    throws java.io.IOException
        Append a page event (like previous page stat mechanism)
        Parameters:
        request - the current HttpServletRequest
        startPageRequest - the start time of the page request
        Throws:
        java.io.IOException - thrown when saving EventData
      • appendPageEvent

        protected static void appendPageEvent​(javax.servlet.http.HttpServletRequest request,
                                              long startPageRequest,
                                              long endPageRequest,
                                              long eventDate)
                                       throws java.io.IOException
        Append a page event (like previous page stat mechanism)
        Parameters:
        request - the current HttpServletRequestr
        startPageRequest - the start time of the page request
        endPageRequest - the end time of the page request
        eventDate - the Date of the event
        Throws:
        java.io.IOException - thrown when saving EventData
      • generateAccessContextMap

        public static java.util.Map<java.lang.String,​java.lang.String> generateAccessContextMap​(javax.servlet.http.HttpServletRequest request,
                                                                                                      EventData eventData)
      • getBrowsers

        public static java.util.SortedSet<java.lang.String> getBrowsers​(java.lang.String userAgent)
      • getBots

        public static java.util.SortedSet<java.lang.String> getBots​(java.lang.String userAgent)
      • processQueries

        public static void processQueries​(java.util.Map<java.lang.String,​java.lang.String> ctxMap)
      • isSearchRequest

        public static boolean isSearchRequest​(java.lang.String uri,
                                              java.lang.String queryString)
      • runDayAgent

        public void runDayAgent​(java.util.Date startDate,
                                java.util.Date endDate,
                                Workspace workspace,
                                java.lang.String urid,
                                boolean scheduled,
                                boolean globalAnalyze)
        Run day agent in a specific period
        Parameters:
        startDate - the start day of the period
        endDate - the end day of the period
        workspace - Workspace to limit analyze (null for all workspaces)
        urid - the urid used in analysis
        scheduled - is the run a manual run or from a schedule (alarm)
        globalAnalyze - do global analyze (workspace == null in agent and report)
      • runDayAgent

        public void runDayAgent​(java.util.Date startDate,
                                java.util.Date endDate,
                                Workspace workspace,
                                java.lang.String urid,
                                boolean scheduled,
                                boolean globalAnalyze,
                                java.util.Date ignoreBeforeDate)
        Run day agent in a specific period
        Parameters:
        startDate - the start day of the period
        endDate - the end day of the period
        workspace - Workspace to limit analyze (null for all workspaces)
        urid - the urid used in analysis
        scheduled - is the run a manual run or from a schedule (alarm)
        globalAnalyze - do global analyze (workspace == null in agent and report)
        ignoreBeforeDate - the date used to lower limit of files used for analyze (may be null for no lower limit)
      • runDayAgent

        public void runDayAgent​(java.util.Date startDate,
                                java.util.Date endDate,
                                java.util.Set<Workspace> workspaceSet,
                                java.lang.String urid,
                                java.util.Set<AbstractStatisticAgent> dayAgentList,
                                boolean scheduled,
                                boolean globalAnalyze)
        Run day agent in the specified period
        Parameters:
        startDate - the start day of the period
        endDate - the end day of the period
        urid - the urid used in analysis
        workspaceSet - Workspace Set to limit analyze (null for all workspaces)
        dayAgentList - Set of agent to run
        scheduled - is the run a manual run or from alarm
        globalAnalyze - do global analyze (workspace == null in agent and report)
      • runDayAgent

        public void runDayAgent​(java.util.Date startDate,
                                java.util.Date endDate,
                                java.util.Set<Workspace> workspaceSet,
                                java.lang.String urid,
                                java.util.Set<AbstractStatisticAgent> dayAgentList,
                                boolean scheduled,
                                boolean globalAnalyze,
                                java.util.Date ignoreBeforeDate)
        Run day agent in the specified period
        Parameters:
        startDate - the start day of the period
        endDate - the end day of the period
        urid - the urid used in analysis
        workspaceSet - Workspace Set to limit analyze (null for all workspaces)
        dayAgentList - Set of agent to run
        scheduled - is the run a manual run or from alarm
        globalAnalyze - do global analyze (workspace == null in agent and report)
        ignoreBeforeDate - the date used to lower limit of files used for analyze (may be null for no lower limit)
      • runPeriodAgent2

        public void runPeriodAgent2​(java.util.Date startDate,
                                    java.util.Date endDate,
                                    AbstractPeriod period,
                                    java.util.Set<Workspace> workspaceSet,
                                    java.lang.String urid,
                                    java.util.Set<AbstractStatisticAgent> agentList,
                                    boolean scheduled,
                                    boolean globalAnalyze)
        Run agent with a custom period in a specified interval
        Parameters:
        startDate - the start day of the interval (also start date of the analyzed period)
        endDate - the end day of the interval (if analyzed period is greater than endDate, the real end date will be the end of the period or today)
        period - the AbstractPeriod of the analysis
        urid - the urid used in analysis
        workspaceSet - Workspace Set to limit analyze (null for all workspaces)
        agentList - Set of agent to run
        scheduled - is the run a manual run or from alarm
        globalAnalyze - do global analyze (workspace == null in agent and report)
      • runPeriodAgent

        public void runPeriodAgent​(java.util.Date startDate,
                                   java.util.Date endDate,
                                   AbstractPeriod period,
                                   java.util.Set<Workspace> workspaceSet,
                                   java.lang.String urid,
                                   java.util.Set<AbstractStatisticAgent> agentList,
                                   boolean scheduled,
                                   boolean globalAnalyze,
                                   java.util.Date ignoreBeforeDate)
        Run agent with a custom period in a specified interval
        Parameters:
        startDate - the start day of the interval (also start date of the analyzed period)
        endDate - the end day of the interval (if analyzed period is greater than endDate, the real end date will be the end of the period or today)
        period - the AbstractPeriod of the analysis
        urid - the urid used in analysis
        workspaceSet - Workspace Set to limit analyze (null for all workspaces)
        agentList - Set of agent to run
        scheduled - is the run a manual run or from alarm
        globalAnalyze - do global analyze (workspace == null in agent and report)
        ignoreBeforeDate - the date used to lower limit of files used for analyze (may be null for no lower limit)
      • getCurrentAnalyzeListener

        public java.util.List<AnalyzeListener> getCurrentAnalyzeListener()
        Retrieve the current analyze listener
        Returns:
        the List of AnalyzeListener
      • initAlarms

        public void initAlarms()
        init analytics alarm use to compute day aggregation
      • reinitAlarms

        public void reinitAlarms()
        ReinitAlarms (remove all analytics alarms from analytics alarm manager and init alarms)
      • runDayAgentFromAlarm

        public void runDayAgentFromAlarm()
        run day agent with management of missing aggregation (from an alarm).
      • runDayAgent

        public void runDayAgent()
        run day agent with management of missing aggregation (manual run)
      • getIgnoreBeforeDate

        public java.util.Date getIgnoreBeforeDate()
      • getUtcTime

        public static java.util.Calendar getUtcTime​(java.util.Date reportDate,
                                                    java.util.Locale userLocale)
        Retrieve a UTC time from a date
        Parameters:
        reportDate - the date
        userLocale - the locale
        Returns:
        the UTC time
      • completeMetricObjectSet

        public static void completeMetricObjectSet​(java.util.Set<AbstractReportMetric> originalSet,
                                                   java.util.Date startDate,
                                                   java.util.Date endDate,
                                                   java.util.Locale locale,
                                                   java.lang.Class<? extends AbstractReportMetric> clazz)
                                            throws java.lang.ReflectiveOperationException
        Update the provided set with some empty report metric instance if any are missing in specified interval
        Parameters:
        originalSet - the original Set of AbstractReportMetric
        startDate - the start date of the interval
        endDate - the end date of the interval
        locale - the current locale (used to compute Calendar object)
        clazz - AbstractReportMetric subclass to instantiate
        Throws:
        java.lang.ReflectiveOperationException - Exception thrown during the execution
      • aggregateAllUrid

        public static java.util.Set<AbstractReportMetric> aggregateAllUrid​(java.util.Set<AbstractReportMetric> originalSet,
                                                                           java.lang.Class<? extends AbstractReportMetric> clazz)
                                                                    throws java.lang.ReflectiveOperationException
        Aggregate all urid report in global report (day by day)
        Parameters:
        originalSet - the original Set of AbstractReportMetric
        clazz - AbstractReportMetric subclass to instantiate
        Returns:
        the new Set with report aggregated
        Throws:
        java.lang.ReflectiveOperationException - Exception thrown during the execution
      • aggregateKeyIntegerMap

        public static void aggregateKeyIntegerMap​(java.util.Map<java.lang.String,​java.lang.Integer> origMap,
                                                  java.util.Map<java.lang.String,​java.lang.Integer> mapToAdd)
      • aggregateKeyLongMap

        public static void aggregateKeyLongMap​(java.util.Map<java.lang.String,​java.lang.Long> origMap,
                                               java.util.Map<java.lang.String,​java.lang.Long> mapToAdd)
      • aggregateDateKeyDoubleMap

        public static void aggregateDateKeyDoubleMap​(java.util.Map<java.util.Date,​java.lang.Double> origMap,
                                                     java.util.Map<java.util.Date,​java.lang.Double> mapToAdd)
      • getSortedTopMap

        public java.util.SortedMap<java.lang.String,​java.lang.Integer> getSortedTopMap​(java.util.Map<java.lang.String,​java.lang.Integer> topMap,
                                                                                             int nbMaxElt)
      • getSortedTopDoubleMap

        public java.util.SortedMap<java.lang.String,​java.lang.Double> getSortedTopDoubleMap​(java.util.Map<java.lang.String,​java.lang.Double> topMap,
                                                                                                  int nbMaxElt)
      • getDeserializedContentTopMap

        public static java.util.Map<java.lang.String,​ContentTopValue> getDeserializedContentTopMap​(java.util.Map<java.lang.String,​java.lang.String> contentTopMap)
        Convert a Map of String to map of ContentTopValue
        Parameters:
        contentTopMap - the Map
        Returns:
        the converted Map
      • getSerializedContentTopMap

        public static java.util.Map<java.lang.String,​java.lang.String> getSerializedContentTopMap​(java.util.Map<java.lang.String,​ContentTopValue> contentTopMap)
        Convert a Map of ContentTopValue to map of String
        Parameters:
        contentTopMap - the Map
        Returns:
        the converted Map
      • aggregateKeyContentTopMap

        public static void aggregateKeyContentTopMap​(java.util.Map<java.lang.String,​ContentTopValue> origContentTopMap,
                                                     java.util.Map<java.lang.String,​ContentTopValue> mapToAdd)
      • getSortedContentTopMap

        public static java.util.SortedMap<java.lang.String,​ContentTopValue> getSortedContentTopMap​(java.util.Map<java.lang.String,​ContentTopValue> origContentTopMap,
                                                                                                         int nbMaxElt)
      • getActionFromOp

        public static java.lang.String getActionFromOp​(int opAction)
      • isValidOperationAction

        public static boolean isValidOperationAction​(java.lang.String opAction)
      • getUrlSubString

        public static java.lang.String getUrlSubString​(java.lang.String value,
                                                       int maxLength)
      • toJSON

        public static java.lang.String toJSON​(java.lang.Object obj)
      • removeToDayMetric

        public static void removeToDayMetric​(java.util.Set<AbstractReportMetric> originalSet)
        Remove today metric, because this metric is not done.
        Parameters:
        originalSet - the AbstractReportMetric Set
      • isBot

        public static boolean isBot​(EventData data)
      • getCompatibleWorkspaceSet

        public static java.util.Set<Workspace> getCompatibleWorkspaceSet()
        Get compatible workspaces for analyze (workspace model are ignored) (without any right check)
        Returns:
        the Set of compatible Workspace
      • getCompatibleWorkspaceSet

        public static java.util.Set<Workspace> getCompatibleWorkspaceSet​(Member loggedMember)
        Get compatible workspaces for analyze (workspace model are ignored)
        Parameters:
        loggedMember - Member to check rights
        Returns:
        the Set of compatible Workspace
      • normalizeMap

        public static java.util.Map<java.lang.String,​java.util.Map<java.util.Date,​java.lang.Double>> normalizeMap​(java.util.Map<java.lang.String,​java.util.Map<java.util.Date,​java.lang.Double>> dataMap)
        Normalize a Map<String, Map<Date, Double>> Map to have value in percentage day by day
        Parameters:
        dataMap - the map to normalize
        Returns:
        the new normalized Map
      • keptBest

        public static java.util.Map<java.lang.String,​java.util.Map<java.util.Date,​java.lang.Double>> keptBest​(java.util.Map<java.lang.String,​java.util.Map<java.util.Date,​java.lang.Double>> dataMap,
                                                                                                                          int nbElement,
                                                                                                                          java.lang.String othersKey)
        Compute a new map by top x data and grouping other data.
        Parameters:
        dataMap - the data map
        nbElement - the number of non grouped element
        othersKey - the key of grouped element
        Returns:
        the new map with grouped data
      • getAjaxDisplayMinimumPeriod

        public long getAjaxDisplayMinimumPeriod()
        indicate when ajax display must be used in report display
        Returns:
        the mininum period between the begin and end date of report display to use ajax asynchronous rendering.
      • createRatioSeries

        public static RatioSeries createRatioSeries​(java.util.Map<java.lang.String,​java.lang.Integer> map,
                                                    java.lang.String prefix,
                                                    java.lang.String userLang)
        Util method use in analytics display (to avoid lambda in JSP)
        Parameters:
        map - the input Map
        prefix - the prefix to use for label
        userLang - the userLang used to get serie's label
        Returns:
        the RatioSeries