use of won.bot.framework.eventbot.event.impl.wonmessage.HintFromMatcherEvent in project webofneeds by researchstudio-sat.
the class OpenConnectionAction method doRun.
@Override
public void doRun(final Event event, EventListener executingListener) throws Exception {
if (event instanceof ConnectFromOtherNeedEvent) {
ConnectionSpecificEvent connectEvent = (ConnectionSpecificEvent) event;
logger.debug("auto-replying to connect for connection {}", connectEvent.getConnectionURI());
getEventListenerContext().getWonMessageSender().sendWonMessage(createOpenWonMessage(connectEvent.getConnectionURI()));
return;
} else if (event instanceof OpenFromOtherNeedEvent) {
ConnectionSpecificEvent connectEvent = (ConnectionSpecificEvent) event;
URI connectionState = WonLinkedDataUtils.getConnectionStateforConnectionURI(connectEvent.getConnectionURI(), getEventListenerContext().getLinkedDataSource());
if (ConnectionState.REQUEST_RECEIVED.getURI().equals(connectionState)) {
logger.debug("auto-replying to open(REQUEST_RECEIVED) with open for connection {}", connectEvent.getConnectionURI());
getEventListenerContext().getWonMessageSender().sendWonMessage(createOpenWonMessage(connectEvent.getConnectionURI()));
} else {
// else do not respond - we assume the connection is now established.
}
return;
} else if (event instanceof HintFromMatcherEvent) {
// TODO: the hint with a match object is not really suitable here. Would be better to
// use connection object instead
HintFromMatcherEvent hintEvent = (HintFromMatcherEvent) event;
logger.debug("opening connection based on hint {}", event);
getEventListenerContext().getWonMessageSender().sendWonMessage(createConnectWonMessage(hintEvent.getMatch().getFromNeed(), hintEvent.getMatch().getToNeed(), FacetType.OwnerFacet.getURI(), FacetType.OwnerFacet.getURI()));
}
}
Aggregations