[VIVO-1755] - Better error handling when reasoner disabled (#137)

* Better error handling when reasoner disabled

* Change reasoner error log message to debug

* Extend reasoner status error handling

* Improve reasoner error log message and extend to JenaAdminActions

* Bump up log level for admin action to 'warn' and edit admin panel error message
This commit is contained in:
Ben 2020-03-31 10:25:26 -06:00 committed by GitHub
parent 7981d24da7
commit edef9309ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 57 additions and 33 deletions

View file

@ -199,12 +199,17 @@ public class BaseSiteAdminController extends FreemarkerHttpServlet {
String error = null; String error = null;
String explanation = null; String explanation = null;
TBoxReasonerStatus status = ApplicationUtils.instance().getTBoxReasonerModule().getStatus(); try {
if (!status.isConsistent()) { TBoxReasonerStatus status = ApplicationUtils.instance().getTBoxReasonerModule().getStatus();
error = "INCONSISTENT ONTOLOGY: reasoning halted."; if (!status.isConsistent()) {
explanation = status.getExplanation(); error = "INCONSISTENT ONTOLOGY: reasoning halted.";
} else if ( status.isInErrorState() ) { explanation = status.getExplanation();
error = "An error occurred during reasoning. Reasoning has been halted. See error log for details."; } else if ( status.isInErrorState() ) {
error = "An error occurred during reasoning. Reasoning has been halted. See error log for details.";
}
} catch (IllegalStateException e) {
error = "The inferencing engine is disabled. Data entered manually may exhibit unexpected behavior prior to inferencing.";
log.debug("Status of reasoner could not be determined. It is likely disabled.", e);
} }
if (error != null) { if (error != null) {

View file

@ -192,29 +192,33 @@ public class JenaAdminActions extends BaseEditController {
} }
private void printRestrictions() { private void printRestrictions() {
TBoxReasonerModule reasoner = ApplicationUtils.instance().getTBoxReasonerModule(); try {
for (Restriction rest : reasoner.listRestrictions() ) { TBoxReasonerModule reasoner = ApplicationUtils.instance().getTBoxReasonerModule();
if (rest.isAllValuesFromRestriction()) { for (Restriction rest : reasoner.listRestrictions() ) {
log.trace("All values from: "); if (rest.isAllValuesFromRestriction()) {
AllValuesFromRestriction avfr = rest.asAllValuesFromRestriction(); log.trace("All values from: ");
Resource res = avfr.getAllValuesFrom(); AllValuesFromRestriction avfr = rest.asAllValuesFromRestriction();
if (res.canAs(OntClass.class)) { Resource res = avfr.getAllValuesFrom();
OntClass resClass = res.as(OntClass.class); if (res.canAs(OntClass.class)) {
for (Resource inst : resClass.listInstances().toList() ) { OntClass resClass = res.as(OntClass.class);
log.trace(" -"+inst.getURI()); for (Resource inst : resClass.listInstances().toList() ) {
} log.trace(" -"+inst.getURI());
} }
} else if (rest.isSomeValuesFromRestriction()) { }
log.trace("Some values from: "); } else if (rest.isSomeValuesFromRestriction()) {
} else if (rest.isHasValueRestriction()) { log.trace("Some values from: ");
log.trace("Has value: "); } else if (rest.isHasValueRestriction()) {
} log.trace("Has value: ");
log.trace("On property "+rest.getOnProperty().getURI()); }
for (Resource inst : rest.listInstances().toList() ) { log.trace("On property "+rest.getOnProperty().getURI());
log.trace(" "+inst.getURI()); for (Resource inst : rest.listInstances().toList() ) {
} log.trace(" "+inst.getURI());
}
} }
}
catch (IllegalStateException e) {
log.warn("Status of reasoner could not be determined. It is likely disabled", e);
}
} }
private void removeLongLiterals() { private void removeLongLiterals() {

View file

@ -360,8 +360,13 @@ public class DataPropertyDaoJena extends PropertyDaoJena implements
} }
protected boolean reasoningAvailable() { protected boolean reasoningAvailable() {
TBoxReasonerStatus status = ApplicationUtils.instance().getTBoxReasonerModule().getStatus(); try {
return status.isConsistent() && !status.isInErrorState(); TBoxReasonerStatus status = ApplicationUtils.instance().getTBoxReasonerModule().getStatus();
return status.isConsistent() && !status.isInErrorState();
} catch (IllegalStateException e) {
log.debug("Status of reasoner could not be determined. It is likely disabled.", e);
return false;
}
} }
private String getRequiredDatatypeURI(Individual individual, DataProperty dataprop, List<String> vclassURIs) { private String getRequiredDatatypeURI(Individual individual, DataProperty dataprop, List<String> vclassURIs) {

View file

@ -8,6 +8,9 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import edu.cornell.mannlib.vitro.webapp.application.ApplicationUtils; import edu.cornell.mannlib.vitro.webapp.application.ApplicationUtils;
import edu.cornell.mannlib.vitro.webapp.beans.Individual; import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao; import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
@ -17,6 +20,8 @@ import edu.cornell.mannlib.vitro.webapp.modules.tboxreasoner.TBoxReasonerStatus;
public class IndividualsViaVClassOptions implements FieldOptions { public class IndividualsViaVClassOptions implements FieldOptions {
protected static final Log log = LogFactory.getLog(IndividualsViaVClassOptions.class.getName());
public static final String LEFT_BLANK = ""; public static final String LEFT_BLANK = "";
protected List<String> vclassURIs; protected List<String> vclassURIs;
protected String defaultOptionLabel; protected String defaultOptionLabel;
@ -102,8 +107,13 @@ public class IndividualsViaVClassOptions implements FieldOptions {
} }
protected boolean isReasoningAvailable(){ protected boolean isReasoningAvailable(){
TBoxReasonerStatus status = ApplicationUtils.instance().getTBoxReasonerModule().getStatus(); try {
return status.isConsistent() && !status.isInErrorState(); TBoxReasonerStatus status = ApplicationUtils.instance().getTBoxReasonerModule().getStatus();
return status.isConsistent() && !status.isInErrorState();
} catch (IllegalStateException e) {
log.debug("Status of reasoner could not be determined. It is likely disabled.", e);
return false;
}
} }
protected Map<String, Individual> addWhenMissingInference( String classUri , WebappDaoFactory wDaoFact ){ protected Map<String, Individual> addWhenMissingInference( String classUri , WebappDaoFactory wDaoFact ){