Skip to content
Snippets Groups Projects
Commit 34ea47ef authored by Mingyang Zhu's avatar Mingyang Zhu
Browse files

Merge branch 'fix-error-message' into 'master'

populate the correct error message thrown by the bottom layer when validating the legal tag

See merge request !91
parents 260e8fb1 f9e30bda
No related branches found
No related tags found
1 merge request!91populate the correct error message thrown by the bottom layer when validating the legal tag
Pipeline #21528 passed with warnings
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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment