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

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

parent 260e8fb1
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 #21427 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