Package eu.europa.ec.taxud.cesop.utils
Class ValidationErrorUtils
- java.lang.Object
-
- eu.europa.ec.taxud.cesop.utils.ValidationErrorUtils
-
public final class ValidationErrorUtils extends Object
Util class handling error records.
-
-
Field Summary
Fields Modifier and Type Field Description static DateTimeFormatter
XML_DATE_TIME_FORMATTER
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
checkCmBr0010(List<ValidationError> validationErrors, String messageRefId, Set<String> docRefIds, String docRefId)
Checks if the DocRefId is not unique in the message (20010).static void
checkCmBr0050(List<ValidationError> validationErrors, String messageRefId, DocTypeEnum docTypeEnum, String corrDocRefId, String docRefId)
Checks if the CorrDocRefId is not specified for new data (20050).static void
checkCmBr0060(List<ValidationError> validationErrors, String messageRefId, DocTypeEnum docTypeEnum, String corrDocRefId, String docRefId)
Checks if the corrDocRefId is provided in case of correction (20060).static void
checkCmBr0100(List<ValidationError> validationErrors, String messageRefId, XmlTypeAndValue pspId)
Checks Psp BIC conforms ISO-9362.static void
checkCmBr0110(List<ValidationError> validationErrors, String messageRefId, MessageTypeIndicEnum messageTypeIndic)
Given there's no payees in the message, check if it is allowed for the specified type of message.static void
checkCmTr0020(List<ValidationError> validationErrors, String messageRefId)
Failed Decryption (50020).static void
checkCmTr0030(List<ValidationError> validationErrors, String messageRefId)
Failed Decompression (50030).static void
checkCmTr0040(List<ValidationError> validationErrors, String messageRefId)
Failed Signature Check (50040).static void
checkCmTr0050(List<ValidationError> validationErrors, String messageRefId)
Failed Threat Scan (50050).static void
checkCmTr0060(List<ValidationError> validationErrors, String messageRefId)
Failed Virus Scan (50060).static void
checkCmTr0070(List<ValidationError> validationErrors, String messageRefId, long size, long maxSize)
Message size exceeded (50070).static void
checkDuplicateReportedPayees(List<ValidationError> validationErrors, String messageRefId, HashMap<Set<XmlTypeAndValue>,String> reportedPayees, List<XmlTypeAndValue> names, XmlCountryTypeAndValue account, String docRefId)
Checks if the current reported payee is not a duplicate of a previously reported payee.static void
checkMhBr0020(List<ValidationError> validationErrors, String messageRefId, String timestamp)
Checks if the 'Timestamp' element does not refer to a wrong (future) value (10020).static void
checkMhBr0030(List<ValidationError> validationErrors, String messageRefId, Integer period, Integer minPeriod)
Checks if the period is not before 01/01/2024 (10030).static void
checkMhBr0070AndMhBr0080(List<ValidationError> validationErrors, String messageRefId, MessageTypeIndicEnum messageTypeIndic, DocTypeEnum docType, String docRefId)
Checks if an initial Payment data message only contains new data and if a correction message only contains corrections/deletions (10070 and 10080).static void
checkMhBr0090(List<ValidationError> validationErrors, String messageRefId, MessageTypeEnum messageType, boolean hasPaymentDataBody)
A payment data message (MessageType = 'PMT') must contain the 'PaymentDataBody' element.static void
checkMhBr0100(List<ValidationError> validationErrors, String messageRefId, MessageTypeIndicEnum messageTypeIndic, Integer period, Integer correlatedPeriod)
In a correction message, the reporting period must be identical to the reporting period of the correlated message.static void
checkMhBr0110(List<ValidationError> validationErrors, String messageRefId, String corrMessageRefId, MessageTypeIndicEnum messageTypeIndic)
CorrMessageRefId in the 'MessageSpec' element must only be provided in correction messages (when 'MessageTypeIndic' = CESOP101).static void
checkMhBr0120(List<ValidationError> validationErrors, String messageRefId, String transmittingCountry, String requiredCountry)
TransmittingCountry in the 'MessageSpec' element must be the same as required country if that is passed.static void
checkRpBr0010(List<ValidationError> validationErrors, String messageRefId, String payeeCountry, String payerMsCountry, String transactionIdentifier)
Checks if the country code of the 'Country' element within the 'ReportedPayee' element is not the same as the country code of the 'PayerMS' element (40010).static void
checkRpBr0020(List<ValidationError> validationErrors, String messageRefId, String accountIdentifierType, String iban, String docRefId)
Checks the IBAN format (40020).static void
checkRpBr0030(List<ValidationError> validationErrors, String messageRefId, String accountIdentifierType, String countryCode, String iban, String docRefId)
Validates the IBAN (40030) based on the countryCode IBAN length and the MOD97 algorithm.static void
checkRpBr0040(List<ValidationError> validationErrors, String messageRefId, boolean hasPaymentData, MessageTypeIndicEnum messageTypeIndic)
Checks if no Reported payee is listed in no payment data for the requested period handler (40040).static void
checkRpBr0050(List<ValidationError> validationErrors, String messageRefId, DocTypeEnum docType, boolean emptyTransactions)
Checks if the 'ReportedTransaction' element is present, except in case of deletion of the related Reported Payee.static void
checkRpBr0060(List<ValidationError> validationErrors, XmlCountryTypeAndValue account, String messageRefId)
Checks if there is no discrepancy in the 'AccountIdentifier' attributes.static void
checkRpBr0070(List<ValidationError> validationErrors, String messageRefId, XmlTypeAndValue representativeId, String docRefId)
Checks if the representative's BIC conforms ISO-9362.static void
checkRpBr0080(List<ValidationError> validationErrors, String messageRefId, XmlCountryTypeAndValue accountIdentifier, XmlPsp representative, String docRefId)
static void
checkRtBr0010(List<ValidationError> validationErrors, String messageRefId, boolean isRefund, XmlTypeAndValue amount, String transactionIdentifier)
Checks the amount value.static void
checkRtBr0030(List<ValidationError> validationErrors, String messageRefId, Integer period, EnumMap<TransactionDateEnum,String> dates, String transactionIdentifier)
Checks if at least one 'DateTime' element in the 'ReportedTransaction' element refers to a date within the period and year declared in the 'ReportingPeriod' element (45030).static void
checkRtBr0040(List<ValidationError> validationErrors, String messageRefId, Set<String> transactionIdentifiers, String transactionIdentifier)
Checks if the transaction identifier is unique in message handler (45040).static void
checkRtBr0060(List<ValidationError> validationErrors, String messageRefId, String amount, String transactionIdentifier)
Checks if the value of the 'Amount' element is not equal to zero (45060).static void
checkRtBr0080(List<ValidationError> validationErrors, String messageRefId, boolean isInErrorRtBr0080, String transactionIdentifier)
Checks if the same type of transaction date has not been provided more than once (45080).static String
convertGreece(String code)
static ValidationError
createCustomError(String messageRefId, String description)
Custom error (99999).static ValidationError
createValidationError(ValidationErrorTypeEnum errorType, String messageRefId)
Create aValidationError
from anValidationErrorTypeEnum
.static ValidationError
createValidationError(ValidationErrorTypeEnum errorType, String messageRefId, String docRefId, String transactionIdentifier)
Create aValidationError
from anValidationErrorTypeEnum
.
-
-
-
Field Detail
-
XML_DATE_TIME_FORMATTER
public static final DateTimeFormatter XML_DATE_TIME_FORMATTER
-
-
Method Detail
-
checkMhBr0070AndMhBr0080
public static void checkMhBr0070AndMhBr0080(List<ValidationError> validationErrors, String messageRefId, MessageTypeIndicEnum messageTypeIndic, DocTypeEnum docType, String docRefId)
Checks if an initial Payment data message only contains new data and if a correction message only contains corrections/deletions (10070 and 10080).- Parameters:
validationErrors
- the list of validation errorsmessageRefId
- the reference of the messagemessageTypeIndic
- the message type indicdocType
- the doc typedocRefId
- the doc ref id
-
checkCmBr0010
public static void checkCmBr0010(List<ValidationError> validationErrors, String messageRefId, Set<String> docRefIds, String docRefId)
Checks if the DocRefId is not unique in the message (20010).- Parameters:
validationErrors
- the list of validation errorsmessageRefId
- the reference of the messagedocRefIds
- the docref ids already checkeddocRefId
- the docref id
-
checkCmBr0050
public static void checkCmBr0050(List<ValidationError> validationErrors, String messageRefId, DocTypeEnum docTypeEnum, String corrDocRefId, String docRefId)
Checks if the CorrDocRefId is not specified for new data (20050).- Parameters:
validationErrors
- the list of validation errorsmessageRefId
- the reference of the messagedocTypeEnum
- the doc type enumcorrDocRefId
- the corr doc ref iddocRefId
- the doc ref id
-
checkCmBr0060
public static void checkCmBr0060(List<ValidationError> validationErrors, String messageRefId, DocTypeEnum docTypeEnum, String corrDocRefId, String docRefId)
Checks if the corrDocRefId is provided in case of correction (20060).- Parameters:
validationErrors
- the list of validation errorsmessageRefId
- the reference of the messagedocTypeEnum
- the doc type enumcorrDocRefId
- the corrDocRefIddocRefId
- the doc ref id
-
checkRpBr0010
public static void checkRpBr0010(List<ValidationError> validationErrors, String messageRefId, String payeeCountry, String payerMsCountry, String transactionIdentifier)
Checks if the country code of the 'Country' element within the 'ReportedPayee' element is not the same as the country code of the 'PayerMS' element (40010).- Parameters:
validationErrors
- the list of validation errorsmessageRefId
- the reference of the messagepayeeCountry
- the payee countrypayerMsCountry
- the payer MS countrytransactionIdentifier
- the transaction identifier id
-
checkRpBr0020
public static void checkRpBr0020(List<ValidationError> validationErrors, String messageRefId, String accountIdentifierType, String iban, String docRefId)
Checks the IBAN format (40020).- Parameters:
validationErrors
- the list of validation errorsmessageRefId
- the reference of the messageaccountIdentifierType
- the account identifier type enumiban
- the ibandocRefId
- the doc ref id
-
checkRpBr0030
public static void checkRpBr0030(List<ValidationError> validationErrors, String messageRefId, String accountIdentifierType, String countryCode, String iban, String docRefId)
Validates the IBAN (40030) based on the countryCode IBAN length and the MOD97 algorithm.- Parameters:
validationErrors
- the list of validation errorsmessageRefId
- the reference of the messageaccountIdentifierType
- the account identifier type enumcountryCode
- the country codeiban
- the ibandocRefId
- the doc ref id
-
checkRpBr0040
public static void checkRpBr0040(List<ValidationError> validationErrors, String messageRefId, boolean hasPaymentData, MessageTypeIndicEnum messageTypeIndic)
Checks if no Reported payee is listed in no payment data for the requested period handler (40040).- Parameters:
validationErrors
- the list of validation errorsmessageRefId
- the reference of the messagehasPaymentData
- if the transaction has payment datamessageTypeIndic
- the message type indic
-
checkRpBr0050
public static void checkRpBr0050(List<ValidationError> validationErrors, String messageRefId, DocTypeEnum docType, boolean emptyTransactions)
Checks if the 'ReportedTransaction' element is present, except in case of deletion of the related Reported Payee. (40050).- Parameters:
validationErrors
- the list of validation errorsmessageRefId
- the reference of the messagedocType
- the doc type of the reported payeeemptyTransactions
- true if no reported transactions for this reported payee
-
checkRpBr0060
public static void checkRpBr0060(List<ValidationError> validationErrors, XmlCountryTypeAndValue account, String messageRefId)
Checks if there is no discrepancy in the 'AccountIdentifier' attributes. (40060)- Parameters:
validationErrors
- the validation errorsaccount
- the accountmessageRefId
- the message ref id
-
checkMhBr0020
public static void checkMhBr0020(List<ValidationError> validationErrors, String messageRefId, String timestamp)
Checks if the 'Timestamp' element does not refer to a wrong (future) value (10020).- Parameters:
validationErrors
- the list of validation errorsmessageRefId
- the reference of the messagetimestamp
- the timestamp of the transaction
-
checkMhBr0030
public static void checkMhBr0030(List<ValidationError> validationErrors, String messageRefId, Integer period, Integer minPeriod)
Checks if the period is not before 01/01/2024 (10030).- Parameters:
validationErrors
- the list of validation errorsmessageRefId
- the reference of the messageperiod
- the periodminPeriod
- the minimum period allowed
-
checkMhBr0090
public static void checkMhBr0090(List<ValidationError> validationErrors, String messageRefId, MessageTypeEnum messageType, boolean hasPaymentDataBody)
A payment data message (MessageType = 'PMT') must contain the 'PaymentDataBody' element.- Parameters:
validationErrors
- the list of validation errorsmessageRefId
- the reference of the messagemessageType
- the message typehasPaymentDataBody
- true if the message contains a 'PaymentDataBody' element, false otherwise
-
checkMhBr0100
public static void checkMhBr0100(List<ValidationError> validationErrors, String messageRefId, MessageTypeIndicEnum messageTypeIndic, Integer period, Integer correlatedPeriod)
In a correction message, the reporting period must be identical to the reporting period of the correlated message.- Parameters:
validationErrors
- the list of validation errorsmessageRefId
- the message ref idmessageTypeIndic
- the message type indicperiod
- the message periodcorrelatedPeriod
- the period of the correlated message
-
checkMhBr0110
public static void checkMhBr0110(List<ValidationError> validationErrors, String messageRefId, String corrMessageRefId, MessageTypeIndicEnum messageTypeIndic)
CorrMessageRefId in the 'MessageSpec' element must only be provided in correction messages (when 'MessageTypeIndic' = CESOP101). Otherwise, the element must not be provided.- Parameters:
validationErrors
- the list of validation errorsmessageRefId
- the message ref idcorrMessageRefId
- the CorrMessageRefId valuemessageTypeIndic
- the message type indic
-
checkMhBr0120
public static void checkMhBr0120(List<ValidationError> validationErrors, String messageRefId, String transmittingCountry, String requiredCountry)
TransmittingCountry in the 'MessageSpec' element must be the same as required country if that is passed. EU is a wildcard and should allow the upload for any MS.- Parameters:
validationErrors
- the validation errorsmessageRefId
- the message ref idtransmittingCountry
- the transmitting countryrequiredCountry
- the required country
-
checkRtBr0010
public static void checkRtBr0010(List<ValidationError> validationErrors, String messageRefId, boolean isRefund, XmlTypeAndValue amount, String transactionIdentifier)
Checks the amount value. The refund attribute refers to a wrong value declared in the AmountCurrency element. When the refund attribute is set to 'false', the value of the amount in AmountCurrency element must be positive. When the refund attribute is set to 'true', the value of the amount in the AmountCurrency element must be negative.- Parameters:
validationErrors
- the validation errorsmessageRefId
- the message ref idisRefund
- the is refundamount
- the amounttransactionIdentifier
- the transaction identifier
-
checkRtBr0030
public static void checkRtBr0030(List<ValidationError> validationErrors, String messageRefId, Integer period, EnumMap<TransactionDateEnum,String> dates, String transactionIdentifier)
Checks if at least one 'DateTime' element in the 'ReportedTransaction' element refers to a date within the period and year declared in the 'ReportingPeriod' element (45030).- Parameters:
validationErrors
- the list of validation errorsmessageRefId
- the reference of the messageperiod
- the perioddates
- the transaction datestransactionIdentifier
- the transaction identifier id
-
checkRtBr0040
public static void checkRtBr0040(List<ValidationError> validationErrors, String messageRefId, Set<String> transactionIdentifiers, String transactionIdentifier)
Checks if the transaction identifier is unique in message handler (45040).- Parameters:
validationErrors
- the list of validation errorsmessageRefId
- the reference of the messagetransactionIdentifiers
- the transaction identifiers ids already checkedtransactionIdentifier
- the transaction identifier id
-
checkRtBr0060
public static void checkRtBr0060(List<ValidationError> validationErrors, String messageRefId, String amount, String transactionIdentifier)
Checks if the value of the 'Amount' element is not equal to zero (45060).- Parameters:
validationErrors
- the list of validation errorsmessageRefId
- the reference of the messageamount
- the amounttransactionIdentifier
- the transaction identifier id
-
checkRtBr0080
public static void checkRtBr0080(List<ValidationError> validationErrors, String messageRefId, boolean isInErrorRtBr0080, String transactionIdentifier)
Checks if the same type of transaction date has not been provided more than once (45080). This rule is checked during the reported transactions parsing.- Parameters:
validationErrors
- the list of validation errorsmessageRefId
- the reference of the messageisInErrorRtBr0080
- true if the rule is not respectedtransactionIdentifier
- the transaction identifier id
-
checkCmTr0020
public static void checkCmTr0020(List<ValidationError> validationErrors, String messageRefId)
Failed Decryption (50020).- Parameters:
validationErrors
- the list of validation errorsmessageRefId
- the reference of the message
-
checkCmTr0030
public static void checkCmTr0030(List<ValidationError> validationErrors, String messageRefId)
Failed Decompression (50030).- Parameters:
validationErrors
- the list of validation errorsmessageRefId
- the reference of the message
-
checkCmTr0040
public static void checkCmTr0040(List<ValidationError> validationErrors, String messageRefId)
Failed Signature Check (50040).- Parameters:
validationErrors
- the list of validation errorsmessageRefId
- the reference of the message
-
checkCmTr0050
public static void checkCmTr0050(List<ValidationError> validationErrors, String messageRefId)
Failed Threat Scan (50050).- Parameters:
validationErrors
- the list of validation errorsmessageRefId
- the reference of the message
-
checkCmTr0060
public static void checkCmTr0060(List<ValidationError> validationErrors, String messageRefId)
Failed Virus Scan (50060).- Parameters:
validationErrors
- the list of validation errorsmessageRefId
- the reference of the message
-
checkCmTr0070
public static void checkCmTr0070(List<ValidationError> validationErrors, String messageRefId, long size, long maxSize)
Message size exceeded (50070).- Parameters:
validationErrors
- the list of validation errorsmessageRefId
- the reference of the messagesize
- the size of messagemaxSize
- the max size authorized
-
checkCmBr0110
public static void checkCmBr0110(List<ValidationError> validationErrors, String messageRefId, MessageTypeIndicEnum messageTypeIndic)
Given there's no payees in the message, check if it is allowed for the specified type of message.- Parameters:
validationErrors
- the list of validation errorsmessageRefId
- the reference of the messagemessageTypeIndic
- the type of message indic being validated
-
checkRpBr0070
public static void checkRpBr0070(List<ValidationError> validationErrors, String messageRefId, XmlTypeAndValue representativeId, String docRefId)
Checks if the representative's BIC conforms ISO-9362.- Parameters:
validationErrors
- the list of validation errorsmessageRefId
- the reference of the messagerepresentativeId
- the representative iddocRefId
- the doc ref id
-
checkCmBr0100
public static void checkCmBr0100(List<ValidationError> validationErrors, String messageRefId, XmlTypeAndValue pspId)
Checks Psp BIC conforms ISO-9362.- Parameters:
validationErrors
- the list of validation errorsmessageRefId
- the reference of the messagepspId
- the psp id
-
checkRpBr0080
public static void checkRpBr0080(List<ValidationError> validationErrors, String messageRefId, XmlCountryTypeAndValue accountIdentifier, XmlPsp representative, String docRefId)
-
checkDuplicateReportedPayees
public static void checkDuplicateReportedPayees(List<ValidationError> validationErrors, String messageRefId, HashMap<Set<XmlTypeAndValue>,String> reportedPayees, List<XmlTypeAndValue> names, XmlCountryTypeAndValue account, String docRefId)
Checks if the current reported payee is not a duplicate of a previously reported payee. The check is done by comparing the set of names and account identifiers of the current reported payee with the previously seen reported payees.- Parameters:
validationErrors
- the list of validation errorsmessageRefId
- the message ref idreportedPayees
- the map of seen reported payees, maps the set of names and account identifiers to the doc ref idnames
- the names of the payeeaccount
- the account identifier of the payeedocRefId
- the doc ref id
-
createCustomError
public static ValidationError createCustomError(String messageRefId, String description)
Custom error (99999).- Parameters:
messageRefId
- the reference of the messagedescription
- the description of the error- Returns:
- the validation error
-
createValidationError
public static ValidationError createValidationError(ValidationErrorTypeEnum errorType, String messageRefId)
Create aValidationError
from anValidationErrorTypeEnum
.- Parameters:
errorType
- the validation error typemessageRefId
- the reference of the message- Returns:
- the validation error
-
createValidationError
public static ValidationError createValidationError(ValidationErrorTypeEnum errorType, String messageRefId, String docRefId, String transactionIdentifier)
Create aValidationError
from anValidationErrorTypeEnum
.- Parameters:
errorType
- the validation error typemessageRefId
- the reference of the messagedocRefId
- the doc ref idtransactionIdentifier
- the transaction identifier- Returns:
- the validation error
-
-