Class VitamCodeHelper


  • public class VitamCodeHelper
    extends java.lang.Object
    Helper to get error message or VitamCode from Service, Domain and item or from error code
    • Method Detail

      • isAlphanumericCode

        public static boolean isAlphanumericCode​(java.lang.String code)
        Check if the code is alphanumeric [A-Z0-9]
        Parameters:
        code - the code to check
        Returns:
        true if code is aplhanumeric, false otherwise
      • getFrom

        public static VitamCode getFrom​(java.lang.String code)
        Get VitamCode from code
        Parameters:
        code - the code to get VitamCode
        Returns:
        VitamCode if exists
        Throws:
        java.lang.IllegalArgumentException - thrown if the code is wrong format or if VitamCode associated to code does not exists
      • getFrom

        public static VitamCode getFrom​(ServiceName service,
                                        DomainName domain,
                                        java.lang.String item)
        Get VitamCode from Service, Domain and item values
        Parameters:
        service - the service
        domain - the domain
        item - the item
        Returns:
        VitamCode if exists
        Throws:
        java.lang.IllegalArgumentException - thrown if one argument at least is null or if VitamCode associated to the wanted Service, Domain and item does not exist
      • getMessage

        public static java.lang.String getMessage​(ServiceName service,
                                                  DomainName domain,
                                                  java.lang.String item)
        Get the message from the Service, Domain and item values
        Parameters:
        service - the service
        domain - the domain
        item - the item
        Returns:
        the String message if exists
        Throws:
        java.lang.IllegalArgumentException - thrown if one argument at least is null or if VitamCode (and the message) associated to the wanted Service, Domain and item does not exist
      • getMessageFromVitamCode

        public static java.lang.String getMessageFromVitamCode​(VitamCode vitamCode)
        Get the message from vitam code
        Parameters:
        vitamCode - the code
        Returns:
        the String message if exists
        Throws:
        java.lang.IllegalArgumentException - thrown if vitamCode is null or if VitamCode (and the message) associated to the wanted code does not exist
      • getMessage

        public static java.lang.String getMessage​(java.lang.String vitamCode)
        Get the message from code
        Parameters:
        vitamCode - the code
        Returns:
        the String message if exists
        Throws:
        java.lang.IllegalArgumentException - thrown if vitamCode is null or if VitamCode (and the message) associated to the wanted code does not exist
      • getParametrizedMessageFromVitamCode

        public static java.lang.String getParametrizedMessageFromVitamCode​(VitamCode vitamCode,
                                                                           java.lang.Object... params)
        Get parameterized message from code
        Parameters:
        vitamCode - the code
        params - parameters to add to message
        Returns:
        parameterized message
        Throws:
        java.lang.IllegalArgumentException - thrown if vitamCode or params is null if VitamCode (and the message) associated to the wanted code does not exist
      • getParametrizedMessageFromCode

        public static java.lang.String getParametrizedMessageFromCode​(java.lang.String vitamCode,
                                                                      java.lang.Object... params)
        Get parameterized message from code
        Parameters:
        vitamCode - the code
        params - parameters to add to message
        Returns:
        parameterized message
        Throws:
        java.lang.IllegalArgumentException - thrown if vitamCode or params is null or if VitamCode (and the message) associated to the wanted code does not exist
      • getParametrizedMessage

        public static java.lang.String getParametrizedMessage​(ServiceName service,
                                                              DomainName domain,
                                                              java.lang.String item,
                                                              java.lang.Object... params)
        Get parameterized message from Service, Domain and item values
        Parameters:
        service - the service
        domain - the domain
        item - the item
        params - the parameters
        Returns:
        parameterized message
        Throws:
        java.lang.IllegalArgumentException - thrown if one argument at least is null or if VitamCode (and the message) associated to the wanted code does not exist
      • getFromDomain

        public static java.util.List<VitamCode> getFromDomain​(DomainName domain)
        Get list of VitamCode from a Domain
        Parameters:
        domain - the domain
        Returns:
        list of VitamCode or empty list
        Throws:
        java.lang.IllegalArgumentException - thrown if domain is null
      • getFromService

        public static java.util.List<VitamCode> getFromService​(ServiceName service)
        Get list of VitamCode from a Service
        Parameters:
        service - the service
        Returns:
        list of VitamCode or empty list
        Throws:
        java.lang.IllegalArgumentException - thrown if service is null
      • getCode

        public static java.lang.String getCode​(VitamCode vitamCode)
        Get the vitam code
        Parameters:
        vitamCode - to get
        Returns:
        the vitam code in String
      • getLogMessage

        public static java.lang.String getLogMessage​(VitamCode vitamCode,
                                                     java.lang.Object... params)
        Get formatted message for Logger
        Parameters:
        vitamCode - the Vitam code
        params - parameters for the message
        Returns:
        formatted parameterized message
        Throws:
        java.lang.IllegalArgumentException - thrown if vitamCode
      • toVitamError

        public static VitamError toVitamError​(VitamCode vitamCode,
                                              java.lang.String description)
        Transform a vitamCode to a VitamError with the given description
        Parameters:
        vitamCode - the vitamCode
        description - the description
        Returns:
        the vitamError