diff --git a/legal-core/src/main/java/org/opengroup/osdu/legal/tags/validation/rules/DefaultRule.java b/legal-core/src/main/java/org/opengroup/osdu/legal/tags/validation/rules/DefaultRule.java index 0ad0f8e8ee8b44576cb4fb23108503202d225d69..6b1083dde25226bce387dcf46933f75318ee6ca3 100644 --- a/legal-core/src/main/java/org/opengroup/osdu/legal/tags/validation/rules/DefaultRule.java +++ b/legal-core/src/main/java/org/opengroup/osdu/legal/tags/validation/rules/DefaultRule.java @@ -1,6 +1,7 @@ package org.opengroup.osdu.legal.tags.validation.rules; import com.fasterxml.jackson.annotation.JsonIgnore; +import org.opengroup.osdu.core.common.model.http.AppException; import org.opengroup.osdu.core.common.model.legal.validation.rules.Rule; import org.opengroup.osdu.legal.countries.LegalTagCountriesService; import org.opengroup.osdu.core.common.model.legal.Properties; @@ -25,11 +26,15 @@ public class DefaultRule extends Rule { @Override protected String hasError(Properties properties) { String output = ""; - if(!properties.hasContractId() && !properties.isUnknownOrNonExistantContractId()) { - output = String.format("Invalid Contract Id given. Only '%s' '%s' or the real contract ID are allowed values. The contract ID must be between 3 and 40 characters and only include alphanumeric values and hyphens,", Properties.UNKNOWN_CONTRACT_ID, Properties.NO_CONTRACT_ID); - } - else if(!isAllowedCOO(properties)){ - output = String.format("Invalid country of origin set. It should match one of the ISO alpha 2 codes and be a country with no restriction on data residency. Found: %s.", properties.getCountryOfOrigin()); + try { + if(!properties.hasContractId() && !properties.isUnknownOrNonExistantContractId()) { + output = String.format("Invalid Contract Id given. Only '%s' '%s' or the real contract ID are allowed values. The contract ID must be between 3 and 40 characters and only include alphanumeric values and hyphens,", Properties.UNKNOWN_CONTRACT_ID, Properties.NO_CONTRACT_ID); + } + else if(!isAllowedCOO(properties)){ + output = String.format("Invalid country of origin set. It should match one of the ISO alpha 2 codes and be a country with no restriction on data residency. Found: %s.", properties.getCountryOfOrigin()); + } + } catch (AppException ex) { + output = ex.getError().getMessage(); } return output; }