Class MonitorUtilInternal


  • public class MonitorUtilInternal
    extends java.lang.Object
    Monitor internal utilities.
    Since:
    9.0.0
    Version:
    $Revision: 25736 $ $Date: 2023-06-13 10:53:58 -0300 (Tue, 13 Jun 2023) $
    • Field Detail

      • INVALID_COLLECT_EVENT_ID

        public static final java.lang.String INVALID_COLLECT_EVENT_ID
        See Also:
        Constant Field Values
      • MONITOR_FIELD

        public static final java.lang.String MONITOR_FIELD
        Big data monitor field identifier.
        Since:
        9.0.0
        See Also:
        Constant Field Values
    • Constructor Detail

      • MonitorUtilInternal

        public MonitorUtilInternal()
    • Method Detail

      • getDocumentTypeFieldId

        public static java.lang.String getDocumentTypeFieldId​(java.lang.String fieldId)
        Returns the normalized full field identifier.
        Parameters:
        fieldId - the raw field identifier.
        Returns:
        the normalized full field identifier.
        Since:
        9.0.0
      • getDocumentTypeId

        public static java.lang.String getDocumentTypeId​(IMonitorEvent event)
        Returns the big data document type identifier for the given event.
        Parameters:
        event - the event.
        Returns:
        the big data document type identifier for the given event.
        Since:
        11.1.0
      • getAllEventDocumentTypeIds

        public static java.lang.String[] getAllEventDocumentTypeIds()
        Returns the identifiers of document types of all monitor events.
        Returns:
        the identifiers.
        Since:
        12.5.0
      • getDocument

        public static Document getDocument​(IMonitorEvent event,
                                           java.util.Deque<IMonitorValuesProvider> monitoringValues)
                                    throws java.lang.Exception
        Returns the document for the given event with the given values or null if some required field is missing.
        Parameters:
        event - the event.
        monitoringValues - the values.
        Returns:
        the document for the given event with the given values or null if some required field is missing.
        Throws:
        java.lang.Exception
        Since:
        9.0.0
      • updateDocumentType

        public static void updateDocumentType​(MonitorEvent event)
        Updates the document type of the given event. Does not create one if it doesn't exist yet.
        Parameters:
        event - the event.
        Since:
        10.2.0
      • getSecondsAfterMidnight

        public static long getSecondsAfterMidnight​(java.util.Date date)
        Returns the amount of seconds after midnight for a date.
        Parameters:
        date - the date for getting seconds after midnight.
        Returns:
        the amount of seconds after midnight for the given date.
        Since:
        10.2.0
      • getDayOfWeek

        public static int getDayOfWeek​(java.util.Date date)
        Returns the day of week for a date.
        Parameters:
        date - the date for getting day of week.
        Returns:
        the day of week for the given date.
        Since:
        10.2.0
      • getDayOfMonth

        public static int getDayOfMonth​(java.util.Date date)
        Returns the day of month for a date.
        Parameters:
        date - the date for getting day of month.
        Returns:
        the day of month for the given date.
        Since:
        12.2.0
      • getMonth

        public static int getMonth​(java.util.Date date)
        Returns the month for a date.
        Parameters:
        date - the date for getting month from.
        Returns:
        the month for the given date.
        Since:
        12.2.0
      • getQuarter

        public static int getQuarter​(java.util.Date date)
        Returns the quarter for a date.
        Parameters:
        date - the date for getting quarter from.
        Returns:
        the quarter for the given date.
        Since:
        12.2.0
      • getYear

        public static int getYear​(java.util.Date date)
        Returns the year for a date.
        Parameters:
        date - the date for getting year from.
        Returns:
        the year for the given date.
        Since:
        12.2.0
      • refreshMonitorIndices

        public static void refreshMonitorIndices()
                                          throws PortalException
        Refreshes all monitor indices.
        Throws:
        PortalException
        Since:
        12.2.0
      • setUserInfoIfPresent

        public static void setUserInfoIfPresent​(boolean isTrusted,
                                                boolean affectTrusted,
                                                MonitorUser monitorUser,
                                                org.json.simple.JSONObject sourceFields)
                                         throws PortalException
        Update monitor user fields if key field presents in JSON.
        Parameters:
        isTrusted - whether the info is trusted or not.
        affectTrusted - case info is untrusted, should erase trusted.
        monitorUser - the monitor user that will be updated.
        sourceFields - a JSON with source key and values.
        Throws:
        PortalException
        Since:
        12.3.0
      • setUserInfoIfPresent

        public static void setUserInfoIfPresent​(boolean isTrusted,
                                                boolean affectTrusted,
                                                MonitorUser monitorUser,
                                                org.json.simple.JSONObject sourceFields,
                                                org.json.simple.JSONObject customAttributes)
                                         throws PortalException
        Update monitor user fields if key field presents in JSON.
        Parameters:
        isTrusted - whether the info is trusted or not.
        affectTrusted - case info is untrusted, should erase trusted.
        monitorUser - the monitor user that will be updated.
        sourceFields - a JSON with source key and values.
        customAttributes - the custom attributes.
        Throws:
        PortalException
        Since:
        12.3.0
      • setUserDefaultAttributesIfPresents

        public static void setUserDefaultAttributesIfPresents​(boolean isTrusted,
                                                              boolean affectTrusted,
                                                              MonitorUser monitorUser,
                                                              org.json.simple.JSONObject sourceFields)
        Update monitor user default fields if key field presents in JSON.
        Parameters:
        isTrusted - whether the info is trusted or not.
        affectTrusted - case info is untrusted, should erase trusted.
        monitorUser - the monitor user that will be updated.
        sourceFields - a JSON with source key and values.
        Since:
        14.0.0
      • getPrivacyFilter

        public static ISearchQueryFilter getPrivacyFilter​(ServiceInstanceConfig analyticsServiceInstance,
                                                          DocumentTypeField acceptedPurposetsTypeField)
                                                   throws PortalException
        Returns the privacy term part filter.
        Parameters:
        analyticsServiceInstance - the service instance of analytics.
        acceptedPurposetsTypeField - big data privacy term field .
        Returns:
        the privacy term part filter.
        Throws:
        PortalException
        Since:
        12.3.0
      • getProjectIdFilter

        public static ISearchQueryFilter getProjectIdFilter​(ServiceInstanceConfig serviceInstance,
                                                            boolean forMonitorUser)
                                                     throws PortalException
        Returns a search query filter to filter the data with the appropriated area tags.
        Parameters:
        serviceInstance - the service instance
        forMonitorUser - indicates whether the filter will be used in monitor user index
        Returns:
        a search query filter to filter the data with the appropriated area tags.
        Throws:
        PortalException
        Since:
        12.4.0
      • getValuesToFilterProjectIdFor

        public static java.util.Set<java.lang.String> getValuesToFilterProjectIdFor​(ServiceInstanceConfig serviceInstance,
                                                                                    boolean forMonitorUser)
                                                                             throws PortalException
        Returns the filter values to be applied in project id field.
        Parameters:
        serviceInstance - the service instance
        forMonitorUser - indicates whether the filter will be used in monitor user index
        Returns:
        the filter values to be applied in project id field.
        Throws:
        PortalException
        Since:
        12.4.0
      • checkModeViewPermission

        public static ServiceInstanceConfig checkModeViewPermission​(CustomerExperienceApp app,
                                                                    java.lang.String serviceInstanceId)
                                                             throws PortalException
        Checks user has the required view permissions.
        Parameters:
        app - the customer app to which the permission should be checked.
        serviceInstanceId - the service instance identifier.
        Throws:
        java.lang.IllegalArgumentException - if the given service instance identifier is null or an empty string.
        java.lang.IllegalArgumentException - if the given service instance identifier refers to a service other than customer experience.
        PortalObjectNotFoundException - if no service instance was found with the given identifier.
        PortalException - if some error occur during the service instance reading.
        AccessDeniedException - if the user doesn't have the requested permission.
        Since:
        12.5.0
      • checkModeManagePermission

        public static ServiceInstanceConfig checkModeManagePermission​(CustomerExperienceApp app,
                                                                      java.lang.String serviceInstanceId)
                                                               throws PortalException
        Checks user has the required manage permissions.
        Parameters:
        app - the customer app to which the permission should be checked.
        serviceInstanceId - the service instance identifier.
        Throws:
        java.lang.IllegalArgumentException - if the given service instance identifier is null or an empty string.
        java.lang.IllegalArgumentException - if the given service instance identifier refers to a service other than customer experience.
        PortalObjectNotFoundException - if no service instance was found with the given identifier.
        PortalException - if some error occur during the service instance reading.
        AccessDeniedException - if the user doesn't have the requested permission.
        Since:
        12.5.0
      • checkViewServiceInstancePermission

        public static ServiceInstanceConfig checkViewServiceInstancePermission​(java.lang.String serviceInstanceId)
                                                                        throws PortalException
        Checks user has the required view service instance permission.
        Parameters:
        serviceInstanceId - the service instance identifier.
        Throws:
        java.lang.IllegalArgumentException - if the given service instance identifier is null or an empty string.
        java.lang.IllegalArgumentException - if the given service instance identifier refers to a service other than customer experience.
        PortalObjectNotFoundException - if no service instance was found with the given identifier.
        PortalException - if some error occur during the service instance reading.
        AccessDeniedException - if the user doesn't have the requested permission.
        Since:
        12.5.0
      • injectCurrentEventValues

        public static void injectCurrentEventValues​(java.util.Deque<IMonitorValuesProvider> monitoringValues,
                                                    MonitorHelper monitorHelper,
                                                    boolean isForErrorEvent)
        Injects the current monitoring values in monitoring context.
        Parameters:
        monitoringValues - the current monitoring values
        monitorHelper - the monitor helper to inject the values into
        isForErrorEvent - indicates whether the injection is being performed for an error event.
        Since:
        14.2.0
      • setUserCustomAttributesByPkIfPresents

        public static void setUserCustomAttributesByPkIfPresents​(boolean isTrusted,
                                                                 boolean affectTrusted,
                                                                 MonitorUser monitorUser,
                                                                 org.json.simple.JSONObject sourceFields)
                                                          throws PortalException
        Update monitor user custom fields if key field presents in JSON.
        Parameters:
        isTrusted - whether the info is trusted or not.
        affectTrusted - case info is untrusted, should erase trusted.
        monitorUser - the monitor user that will be updated.
        sourceFields - a JSON with source key and values.
        Throws:
        PortalException
        Since:
        14.0.0