Class Message

  • All Implemented Interfaces:
    java.io.Serializable

    public class Message
    extends java.lang.Object
    implements java.io.Serializable
    A message contains many properties serializable. It is used between the web application and the engine to send complex structure of data.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String ERROR
      The service reply error(s)
      static java.lang.String FATAL
      The service reply fatal(s)
      static java.lang.String INFO
      The service reply info(s)
      static char LEVEL_ERROR
      Error level
      static char LEVEL_FATAL
      Fatal level
      static char LEVEL_INFO
      Information level
      static char LEVEL_TEXT
      Text level
      static char LEVEL_WARN
      Warning level
      static char OK
      The service reply only datas
      static java.lang.String TEXT
      The service reply text message(s)
      static java.lang.String WARN
      The service reply warning(s)
    • Constructor Summary

      Constructors 
      Constructor Description
      Message()  
    • Method Summary

      Modifier and Type Method Description
      static java.util.List<java.lang.String> concat​(java.util.List<java.lang.String> msgs, java.lang.String msg)
      Concat messages taking into account null values
      static java.util.List<java.lang.String> concat​(java.util.List<java.lang.String> msgs1, java.util.List<java.lang.String> msgs2)
      Concat messages taking into account null values
      static java.lang.String formatError​(java.lang.String code, java.lang.String msg, java.lang.String input)
      Formats a error message
      static java.lang.String formatEvent​(java.lang.String code, java.lang.String msg, java.lang.String level, java.lang.String input)
      Formats an event message of specified level
      static java.lang.String formatEventWithParams​(java.lang.String code, java.lang.String msg, java.lang.String level, java.lang.String input, java.util.HashMap<java.lang.String,​java.lang.String> params)
      Formats an event message of specified level
      static java.lang.String formatFatal​(java.lang.String code, java.lang.String msg, java.lang.String input)
      Formats a fatal message
      static java.lang.String formatInfo​(java.lang.String code, java.lang.String msg, java.lang.String input)
      Formats a info message
      static java.lang.String formatSimpleError​(java.lang.String msg)
      Formats a simple error message
      static java.lang.String formatSimpleFatal​(java.lang.String msg)
      Formats a simple fatal message
      static java.lang.String formatSimpleInfo​(java.lang.String msg)
      Formats a simple info message
      static java.lang.String formatSimpleText​(java.lang.String msg)
      Formats a simple text message
      static java.lang.String formatSimpleText​(java.lang.String code, java.lang.String msg)
      Formats a simple text message
      static java.lang.String formatSimpleWarning​(java.lang.String msg)
      Formats a simple warning message
      static java.lang.String formatSuggestion​(java.lang.String code, java.lang.String msg, java.lang.String level, java.lang.String input, java.lang.String suggestion)
      Formats a suggestion message of specified level
      static java.lang.String formatWarning​(java.lang.String code, java.lang.String msg, java.lang.String input)
      Formats a warning message
      java.lang.Object get​(java.lang.String key)
      Get a message data
      static java.lang.String getAdditionalMessage​(ObjectDB obj, java.lang.String msg)
      Deprecated.
      static java.lang.String getAdditionalMessage​(java.lang.String msg)
      Get the additional message if exists
      java.util.List<java.lang.String> getAllMessages()
      Get all message
      static java.lang.String getCode​(java.lang.String msg)
      Get the message code (lov TEXT code)
      static java.lang.String getDisplay​(Grant g, java.lang.String msg)
      Display a simple message in user language
      java.lang.String getError()
      Get the first fatal or error
      java.util.List<java.lang.String> getErrors()
      Get errors
      static java.util.List<java.lang.String> getErrors​(java.util.List<java.lang.String> msg)
      Extract error/fatal messages
      java.lang.String getFatal()
      Get the first fatal
      java.util.List<java.lang.String> getFatals()
      Get fatals
      static ObjectField getField​(ObjectDB obj, java.lang.String msg)
      Get the message associated field if exists
      java.lang.String getFullErrors()
      Get the errors concatenation separated by ;
      java.lang.String getInfo()
      Get the first info
      java.util.List<java.lang.String> getInfos()
      Get infos
      static ObjectField getInput​(ObjectDB obj, java.lang.String msg)
      Deprecated. 
      static java.lang.String getLabel​(Grant g, java.lang.String msg)
      Display a simple message in user language (alias to getDisplay)
      static java.lang.String getLevel​(char level)
      Get the level TEXT code
      static char getLevel​(java.lang.String msg)
      Get the message level, default is LEVEL_ERROR
      static java.util.HashMap<java.lang.String,​java.lang.String> getParams​(java.lang.String msg)  
      java.lang.String getResultData()
      Get data result (key Integration.RESULT_DATA) if present in the message
      java.lang.String getResultFile()
      Get file result (key Integration.RESULT_FILE) if present in the message
      java.lang.String getResultLog()
      Get log (key Integration.RESULT_LOG) if present in the message, otherwise the full messages
      FlowXML getResultXML()
      Get XML result (key Integration.RESULT_XML) if present in the message
      java.io.File getResultZIP()
      Get ZIP result (key Integration.RESULT_ZIP) if present in the message
      char getStatus()  
      java.lang.String getSupervisionId()
      Get supervision ID
      java.lang.String getWarning()
      Get the first warning
      java.util.List<java.lang.String> getWarnings()
      Get warnings
      static boolean isError​(java.lang.String msg)
      Check if message is an error/fatal message (using Message.getLevel)
      boolean isOk()
      Is the message OK ? use getStatus to manage exactly the returned level.
      static boolean isWarning​(java.lang.String msg)
      Check if message is a warning message (using Message.getLevel)
      void put​(java.lang.String key, java.lang.Object o)
      Put a message data
      void raiseError​(java.lang.Exception e)
      Raise one error
      void raiseError​(java.lang.String msg)
      Raise one error
      void raiseErrors​(java.util.List<java.lang.String> msgs)
      Raise many errors
      void raiseFatal​(java.lang.Exception e)
      Raise one fatal
      void raiseFatal​(java.lang.String msg)
      Raise one fatal
      void raiseFatals​(java.util.List<java.lang.String> msgs)
      Raise many fatals
      void raiseInfo​(java.lang.String msg)
      Raise one info
      void raiseInfos​(java.util.List<java.lang.String> msgs)
      Raise many infos
      boolean raiseMessage​(java.lang.String msg)
      Raise one message
      void raiseWarning​(java.lang.Exception e)
      Raise one warning
      void raiseWarning​(java.lang.String msg)
      Raise one warning
      void raiseWarnings​(java.util.List<java.lang.String> msgs)
      Raise many warnings
      void setResultData​(java.lang.String data)
      Set data result (key Integration.RESULT_DATA)
      void setResultFile​(java.lang.String path)
      Set file result (key Integration.RESULT_FILE)
      void setResultLog​(java.lang.String log)
      Set log (key Integration.RESULT_LOG)
      void setResultXML​(FlowXML xml)
      Set XML result (key Integration.RESULT_XML)
      void setResultZIP​(java.io.File zip)
      Set ZIP result (key Integration.RESULT_ZIP)
      java.lang.String toJSON​(Grant g, java.lang.String msg, ObjectDB obj)
      Convert to JSON { code, level, text, label }
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Message

        public Message()
    • Method Detail

      • get

        public java.lang.Object get​(java.lang.String key)
        Get a message data
      • put

        public void put​(java.lang.String key,
                        java.lang.Object o)
        Put a message data
      • raiseMessage

        public boolean raiseMessage​(java.lang.String msg)
        Raise one message
        Returns:
        true if raised message is an error or fatal error
      • raiseInfo

        public void raiseInfo​(java.lang.String msg)
        Raise one info
        Parameters:
        msg - Message
      • raiseWarning

        public void raiseWarning​(java.lang.String msg)
        Raise one warning
        Parameters:
        msg - Message
      • raiseWarning

        public void raiseWarning​(java.lang.Exception e)
        Raise one warning
        Parameters:
        e - Exception
      • raiseError

        public void raiseError​(java.lang.String msg)
        Raise one error
        Parameters:
        msg - Message
      • raiseError

        public void raiseError​(java.lang.Exception e)
        Raise one error
        Parameters:
        e - Exception
      • raiseFatal

        public void raiseFatal​(java.lang.String msg)
        Raise one fatal
        Parameters:
        msg - Message
      • raiseFatal

        public void raiseFatal​(java.lang.Exception e)
        Raise one fatal
        Parameters:
        e - Exception
      • raiseInfos

        public void raiseInfos​(java.util.List<java.lang.String> msgs)
        Raise many infos
        Parameters:
        msgs - Messages
      • raiseWarnings

        public void raiseWarnings​(java.util.List<java.lang.String> msgs)
        Raise many warnings
        Parameters:
        msgs - Messages
      • raiseErrors

        public void raiseErrors​(java.util.List<java.lang.String> msgs)
        Raise many errors
        Parameters:
        msgs - Messages
      • raiseFatals

        public void raiseFatals​(java.util.List<java.lang.String> msgs)
        Raise many fatals
        Parameters:
        msgs - Messages
      • isOk

        public boolean isOk()
        Is the message OK ? use getStatus to manage exactly the returned level.
        Returns:
        True when the message contains no errors and fatals
      • getStatus

        public char getStatus()
        Returns:
        the message status Message.OK INFO WARN ERROR or FATAL
      • getInfos

        public java.util.List<java.lang.String> getInfos()
        Get infos
      • getWarnings

        public java.util.List<java.lang.String> getWarnings()
        Get warnings
      • getErrors

        public java.util.List<java.lang.String> getErrors()
        Get errors
      • getFatals

        public java.util.List<java.lang.String> getFatals()
        Get fatals
      • getInfo

        public java.lang.String getInfo()
        Get the first info
      • getWarning

        public java.lang.String getWarning()
        Get the first warning
      • getError

        public java.lang.String getError()
        Get the first fatal or error
      • getFatal

        public java.lang.String getFatal()
        Get the first fatal
      • getAllMessages

        public java.util.List<java.lang.String> getAllMessages()
        Get all message
      • getFullErrors

        public java.lang.String getFullErrors()
        Get the errors concatenation separated by ;
      • formatSimpleText

        public static java.lang.String formatSimpleText​(java.lang.String msg)

        Formats a simple text message

        Parameters:
        msg - Message (or code)
        Returns:
        formatted event : message#TEXT
      • formatSimpleText

        public static java.lang.String formatSimpleText​(java.lang.String code,
                                                        java.lang.String msg)

        Formats a simple text message

        Parameters:
        code - code (from list of values TEXT)
        msg - Message
        Returns:
        formatted event : message#TEXT
      • formatSimpleInfo

        public static java.lang.String formatSimpleInfo​(java.lang.String msg)

        Formats a simple info message

        Parameters:
        msg - Message
        Returns:
        formatted event : message#INFO
      • formatInfo

        public static java.lang.String formatInfo​(java.lang.String code,
                                                  java.lang.String msg,
                                                  java.lang.String input)

        Formats a info message

        Parameters:
        code - code (from list of values TEXT)
        msg - Optional Additional message
        input - Optional associated input field
        Returns:
        formatted event : code[:message]#INFO[#input]
      • formatSimpleWarning

        public static java.lang.String formatSimpleWarning​(java.lang.String msg)

        Formats a simple warning message

        Parameters:
        msg - Message
        Returns:
        formatted event : message#WARNING
      • formatWarning

        public static java.lang.String formatWarning​(java.lang.String code,
                                                     java.lang.String msg,
                                                     java.lang.String input)

        Formats a warning message

        Parameters:
        code - code (from list of values TEXT)
        msg - Optional Additional message
        input - Optional associated input field
        Returns:
        formatted event : code[:message]#WARNING[#input]
      • formatSimpleError

        public static java.lang.String formatSimpleError​(java.lang.String msg)

        Formats a simple error message

        Parameters:
        msg - Message
        Returns:
        formatted event : message#ERROR
      • formatError

        public static java.lang.String formatError​(java.lang.String code,
                                                   java.lang.String msg,
                                                   java.lang.String input)

        Formats a error message

        Parameters:
        code - code (from list of values TEXT)
        msg - Optional Additional message
        input - Optional associated input field
        Returns:
        formatted event : code[:message]#ERROR[#input]
      • formatSimpleFatal

        public static java.lang.String formatSimpleFatal​(java.lang.String msg)

        Formats a simple fatal message

        Parameters:
        msg - Message
        Returns:
        formatted event : message#FATAL
      • formatFatal

        public static java.lang.String formatFatal​(java.lang.String code,
                                                   java.lang.String msg,
                                                   java.lang.String input)

        Formats a fatal message

        Parameters:
        code - code (from list of values TEXT)
        msg - Optional Additional message
        input - Optional associated input field
        Returns:
        formatted event : code[:message]#FATAL[#input]
      • formatEvent

        public static java.lang.String formatEvent​(java.lang.String code,
                                                   java.lang.String msg,
                                                   java.lang.String level,
                                                   java.lang.String input)

        Formats an event message of specified level

        Parameters:
        code - code (from list of values TEXT)
        msg - Optional Additional message
        level - Optional level INFO WARNING ERROR FATAL
        input - Optional associated input field
        Returns:
        formatted event : code[:message][#level][#input]
      • formatSuggestion

        public static java.lang.String formatSuggestion​(java.lang.String code,
                                                        java.lang.String msg,
                                                        java.lang.String level,
                                                        java.lang.String input,
                                                        java.lang.String suggestion)

        Formats a suggestion message of specified level

        Parameters:
        code - code (from list of values TEXT)
        msg - Optional Additional message
        level - Optional level INFO WARNING ERROR FATAL
        input - Optional associated input field
        suggestion - Suggestion
        Returns:
        formatted event : code[:message][#level][#input][#suggest:value]
      • formatEventWithParams

        public static java.lang.String formatEventWithParams​(java.lang.String code,
                                                             java.lang.String msg,
                                                             java.lang.String level,
                                                             java.lang.String input,
                                                             java.util.HashMap<java.lang.String,​java.lang.String> params)

        Formats an event message of specified level

        Parameters:
        code - code (from list of values TEXT)
        msg - Optional Additional message
        level - Optional level INFO WARNING ERROR FATAL
        input - Optional associated input field
        params - Optional parameters
        Returns:
        formatted event : code[:message][#level][#input][#param1:value1][#param2:value2]
      • getParams

        public static java.util.HashMap<java.lang.String,​java.lang.String> getParams​(java.lang.String msg)
      • getCode

        public static java.lang.String getCode​(java.lang.String msg)
        Get the message code (lov TEXT code)
      • getAdditionalMessage

        @Deprecated
        public static java.lang.String getAdditionalMessage​(ObjectDB obj,
                                                            java.lang.String msg)
        Deprecated.
      • getAdditionalMessage

        public static java.lang.String getAdditionalMessage​(java.lang.String msg)
        Get the additional message if exists
      • getLevel

        public static char getLevel​(java.lang.String msg)
        Get the message level, default is LEVEL_ERROR
      • isError

        public static boolean isError​(java.lang.String msg)
        Check if message is an error/fatal message (using Message.getLevel)
      • isWarning

        public static boolean isWarning​(java.lang.String msg)
        Check if message is a warning message (using Message.getLevel)
      • getErrors

        public static java.util.List<java.lang.String> getErrors​(java.util.List<java.lang.String> msg)
        Extract error/fatal messages
        Returns:
        null when messages contain no error (only empty, info, warning)
      • getLevel

        public static java.lang.String getLevel​(char level)
        Get the level TEXT code
      • getInput

        @Deprecated
        public static final ObjectField getInput​(ObjectDB obj,
                                                 java.lang.String msg)
        Deprecated.

        Use getField

      • getField

        public static ObjectField getField​(ObjectDB obj,
                                           java.lang.String msg)
        Get the message associated field if exists
      • setResultLog

        public void setResultLog​(java.lang.String log)
        Set log (key Integration.RESULT_LOG)
      • getResultLog

        public java.lang.String getResultLog()
        Get log (key Integration.RESULT_LOG) if present in the message, otherwise the full messages
      • setResultXML

        public void setResultXML​(FlowXML xml)
        Set XML result (key Integration.RESULT_XML)
      • getResultXML

        public FlowXML getResultXML()
        Get XML result (key Integration.RESULT_XML) if present in the message
      • setResultZIP

        public void setResultZIP​(java.io.File zip)
        Set ZIP result (key Integration.RESULT_ZIP)
      • getResultZIP

        public java.io.File getResultZIP()
        Get ZIP result (key Integration.RESULT_ZIP) if present in the message
      • setResultFile

        public void setResultFile​(java.lang.String path)
        Set file result (key Integration.RESULT_FILE)
      • getResultFile

        public java.lang.String getResultFile()
        Get file result (key Integration.RESULT_FILE) if present in the message
      • setResultData

        public void setResultData​(java.lang.String data)
        Set data result (key Integration.RESULT_DATA)
      • getResultData

        public java.lang.String getResultData()
        Get data result (key Integration.RESULT_DATA) if present in the message
      • concat

        public static java.util.List<java.lang.String> concat​(java.util.List<java.lang.String> msgs,
                                                              java.lang.String msg)
        Concat messages taking into account null values
      • concat

        public static java.util.List<java.lang.String> concat​(java.util.List<java.lang.String> msgs1,
                                                              java.util.List<java.lang.String> msgs2)
        Concat messages taking into account null values
      • getDisplay

        public static java.lang.String getDisplay​(Grant g,
                                                  java.lang.String msg)
        Display a simple message in user language
      • getLabel

        public static java.lang.String getLabel​(Grant g,
                                                java.lang.String msg)
        Display a simple message in user language (alias to getDisplay)
      • getSupervisionId

        public java.lang.String getSupervisionId()
        Get supervision ID
      • toJSON

        public java.lang.String toJSON​(Grant g,
                                       java.lang.String msg,
                                       ObjectDB obj)
        Convert to JSON { code, level, text, label }
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object