Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.apache.jena.shared.PrefixMapping;
import org.apache.jena.sparql.graph.PrefixMappingMem;
import org.apache.jena.sparql.graph.PrefixMappingZero;
import org.eclipse.microprofile.config.ConfigProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -54,6 +55,7 @@
import eu.knowledge.engine.smartconnector.api.ReactKnowledgeInteraction;
import eu.knowledge.engine.smartconnector.api.RecipientSelector;
import eu.knowledge.engine.smartconnector.api.SmartConnector;
import eu.knowledge.engine.smartconnector.api.SmartConnectorConfig;
import eu.knowledge.engine.smartconnector.impl.SmartConnectorBuilder;
import eu.knowledge.engine.smartconnector.impl.SmartConnectorImpl;
import jakarta.ws.rs.container.AsyncResponse;
Expand Down Expand Up @@ -340,11 +342,13 @@ public void finishHandleRequest(String knowledgeInteractionId,
hr = this.beingProcessedHandleRequests.get(handleRequestId);
bs = this.listToBindingSet(responseBody.getBindingSet());

// Moved the validation to the {@link
// eu.knowledge.engine.smartconnector.impl.InteractionProcessorImpl} so that
// also the Java API benefits this, but unfortunately we also have to validate
// here to be able to return an error to the Knowledge Base using the REST API.
hr.validateBindings(bs);
if (this.shouldValidateInputOutputBindings()) {
// Moved the validation to the {@link
// eu.knowledge.engine.smartconnector.impl.InteractionProcessorImpl} so that
// also the Java API benefits this, but unfortunately we also have to validate
// here to be able to return an error to the Knowledge Base using the REST API.
hr.validateBindings(bs);
}

// Now that the validation is done, from the reactive side we are done, so
// we can remove the HandleRequest from our list.
Expand Down Expand Up @@ -863,4 +867,13 @@ public void setDomainKnowledge(String someDomainKnowledge) {

this.sc.setDomainKnowledge(theRules);
}

/**
* Checks the configuration option to determine whether validation is turned on
* or off.
*/
private boolean shouldValidateInputOutputBindings() {
return ConfigProvider.getConfig().getValue(
SmartConnectorConfig.CONF_KEY_VALIDATE_OUTGOING_BINDINGS_WRT_INCOMING_BINDINGS, Boolean.class);
}
}