Package fr.gouv.vitam.common.error
Class VitamCodeHelper
java.lang.Object
fr.gouv.vitam.common.error.VitamCodeHelper
Helper to get error message or VitamCode from Service, Domain and item or from error code
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
Get the vitam codestatic VitamCode
getFrom
(ServiceName service, DomainName domain, String item) Get VitamCode from Service, Domain and item valuesstatic VitamCode
Get VitamCode from codegetFromDomain
(DomainName domain) Get list of VitamCode from a DomaingetFromService
(ServiceName service) Get list of VitamCode from a Servicestatic String
getLogMessage
(VitamCode vitamCode, Object... params) Get formatted message for Loggerstatic String
getMessage
(ServiceName service, DomainName domain, String item) Get the message from the Service, Domain and item valuesstatic String
getMessage
(String vitamCode) Get the message from codestatic String
getMessageFromVitamCode
(VitamCode vitamCode) Get the message from vitam codestatic String
getParametrizedMessage
(ServiceName service, DomainName domain, String item, Object... params) Get parameterized message from Service, Domain and item valuesstatic String
getParametrizedMessageFromCode
(String vitamCode, Object... params) Get parameterized message from codestatic String
getParametrizedMessageFromVitamCode
(VitamCode vitamCode, Object... params) Get parameterized message from codestatic boolean
isAlphanumericCode
(String code) Check if the code is alphanumeric [A-Z0-9]static VitamError<com.fasterxml.jackson.databind.JsonNode>
toVitamError
(VitamCode vitamCode, String description) Transform a vitamCode to a VitamError with the given descriptionstatic <T> VitamError<T>
toVitamError
(VitamCode vitamCode, String description, Class<T> clasz) Transform a vitamCode to a VitamError with the given description
-
Method Details
-
isAlphanumericCode
Check if the code is alphanumeric [A-Z0-9]- Parameters:
code
- the code to check- Returns:
- true if code is aplhanumeric, false otherwise
-
getFrom
Get VitamCode from code- Parameters:
code
- the code to get VitamCode- Returns:
- VitamCode if exists
- Throws:
IllegalArgumentException
- thrown if the code is wrong format or if VitamCode associated to code does not exists
-
getFrom
Get VitamCode from Service, Domain and item values- Parameters:
service
- the servicedomain
- the domainitem
- the item- Returns:
- VitamCode if exists
- Throws:
IllegalArgumentException
- thrown if one argument at least is null or if VitamCode associated to the wanted Service, Domain and item does not exist
-
getMessage
Get the message from the Service, Domain and item values- Parameters:
service
- the servicedomain
- the domainitem
- the item- Returns:
- the String message if exists
- Throws:
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
Get the message from vitam code- Parameters:
vitamCode
- the code- Returns:
- the String message if exists
- Throws:
IllegalArgumentException
- thrown if vitamCode is null or if VitamCode (and the message) associated to the wanted code does not exist
-
getMessage
Get the message from code- Parameters:
vitamCode
- the code- Returns:
- the String message if exists
- Throws:
IllegalArgumentException
- thrown if vitamCode is null or if VitamCode (and the message) associated to the wanted code does not exist
-
getParametrizedMessageFromVitamCode
Get parameterized message from code- Parameters:
vitamCode
- the codeparams
- parameters to add to message- Returns:
- parameterized message
- Throws:
IllegalArgumentException
- thrown if vitamCode or params is null if VitamCode (and the message) associated to the wanted code does not exist
-
getParametrizedMessageFromCode
Get parameterized message from code- Parameters:
vitamCode
- the codeparams
- parameters to add to message- Returns:
- parameterized message
- Throws:
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 String getParametrizedMessage(ServiceName service, DomainName domain, String item, Object... params) Get parameterized message from Service, Domain and item values- Parameters:
service
- the servicedomain
- the domainitem
- the itemparams
- the parameters- Returns:
- parameterized message
- Throws:
IllegalArgumentException
- thrown if one argument at least is null or if VitamCode (and the message) associated to the wanted code does not exist
-
getFromDomain
Get list of VitamCode from a Domain- Parameters:
domain
- the domain- Returns:
- list of VitamCode or empty list
- Throws:
IllegalArgumentException
- thrown if domain is null
-
getFromService
Get list of VitamCode from a Service- Parameters:
service
- the service- Returns:
- list of VitamCode or empty list
- Throws:
IllegalArgumentException
- thrown if service is null
-
getCode
Get the vitam code- Parameters:
vitamCode
- to get- Returns:
- the vitam code in String
-
getLogMessage
Get formatted message for Logger- Parameters:
vitamCode
- the Vitam codeparams
- parameters for the message- Returns:
- formatted parameterized message
- Throws:
IllegalArgumentException
- thrown if vitamCode
-
toVitamError
public static VitamError<com.fasterxml.jackson.databind.JsonNode> toVitamError(VitamCode vitamCode, String description) Transform a vitamCode to a VitamError with the given description- Parameters:
vitamCode
- the vitamCodedescription
- the description- Returns:
- the vitamError
-
toVitamError
public static <T> VitamError<T> toVitamError(VitamCode vitamCode, String description, Class<T> clasz) Transform a vitamCode to a VitamError with the given description- Parameters:
vitamCode
- the vitamCodedescription
- the descriptionclasz
- the class type- Returns:
- the vitamError
-