Throw on profile violation, closes
@@ -64,7 +64,9 @@ public class ValidateProfileCommand implements Command {
IOHelper ioHelper = CommandLineHelper.getIOHelper(line);
state = CommandLineHelper.updateInputOntology(ioHelper, state, line);
OWLOntology ontology = state.getOntology();
- String profile = CommandLineHelper.getOptionalValue(line, "profile").toUpperCase();
+ String profile = CommandLineHelper.getRequiredValue(
+ line, "profile", "A --profile is required");
+ profile = profile.toUpperCase();
final OWLProfile owlProfile;
switch(profile) {
case "DL": owlProfile = Profiles.OWL2_DL; break;
@@ -72,7 +74,7 @@ public class ValidateProfileCommand implements Command {
case "RL": owlProfile = Profiles.OWL2_RL; break;
case "QL": owlProfile = Profiles.OWL2_QL; break;
case "FULL": owlProfile = new OWL2Profile(); break; // #162
- default: owlProfile = null;
+ default: throw new Exception("Invalid profile: " + profile);
}
OWLProfileReport report = owlProfile.checkOntology(ontology);
File outputFile = CommandLineHelper.getOutputFile(line);
@@ -83,6 +85,9 @@ public class ValidateProfileCommand implements Command {
} else {
System.out.println(report.toString());
}
+ if (!report.isInProfile()) {
+ throw new Exception("Ontology is not in profile " + profile);
+ }
return state;
}
