use of won.bot.framework.eventbot.event.impl.atomlifecycle.AtomDeactivatedEvent in project webofneeds by researchstudio-sat.
the class DeactivateAllAtomsOfListAction method doRun.
@Override
protected void doRun(Event event, EventListener executingListener) throws Exception {
EventListenerContext ctx = getEventListenerContext();
Collection<URI> toDeactivate = ctx.getBotContext().getUriList(uriListName);
for (URI uri : toDeactivate) {
ctx.getWonMessageSender().prepareAndSendMessage(WonMessageBuilder.deactivate().direction().fromOwner().atom(uri).build());
ctx.getEventBus().publish(new AtomDeactivatedEvent(uri));
}
}
use of won.bot.framework.eventbot.event.impl.atomlifecycle.AtomDeactivatedEvent in project webofneeds by researchstudio-sat.
the class TwoPhaseCommitDeactivateOnCloseAction method doRun.
@Override
protected void doRun(Event event, EventListener executingListener) throws Exception {
// If we receive a close event, it must carry a commit message.
if (event instanceof CloseFromOtherAtomEvent) {
URI atomURI = ((CloseFromOtherAtomEvent) event).getAtomURI();
WonMessage wonMessage = ((CloseFromOtherAtomEvent) event).getWonMessage();
NodeIterator ni = RdfUtils.visitFlattenedToNodeIterator(wonMessage.getMessageContent(), model -> model.listObjectsOfProperty(model.createProperty(WON_TX.COORDINATION_MESSAGE.getURI())));
assert ni.hasNext() : "no additional content found in close message, expected a commit";
String coordinationMessageUri = ni.toList().get(0).asResource().getURI();
assert coordinationMessageUri.equals(WON_TX.COORDINATION_MESSAGE_COMMIT.getURI()) : "expected a " + "Commit message";
getEventListenerContext().getWonMessageSender().prepareAndSendMessage(WonMessageBuilder.deactivate().direction().fromOwner().atom(atomURI).build());
getEventListenerContext().getEventBus().publish(new AtomDeactivatedEvent(atomURI));
}
}
use of won.bot.framework.eventbot.event.impl.atomlifecycle.AtomDeactivatedEvent in project webofneeds by researchstudio-sat.
the class TwoPhaseCommitNoVoteDeactivateAllAtomsAction method doRun.
@Override
protected void doRun(Event event, EventListener executingListener) throws Exception {
// check the global COORDINATION_MESSAGE (must be ABORT)
if (event instanceof CloseFromOtherAtomEvent) {
WonMessage wonMessage = ((CloseFromOtherAtomEvent) event).getWonMessage();
NodeIterator ni = RdfUtils.visitFlattenedToNodeIterator(wonMessage.getMessageContent(), model -> model.listObjectsOfProperty(model.createProperty(WON_TX.COORDINATION_MESSAGE.getURI())));
if (ni.hasNext()) {
String coordinationMessageUri = ni.toList().get(0).asResource().getURI();
if (coordinationMessageUri.equals(WON_TX.COORDINATION_MESSAGE_ABORT.getURI()))
logger.debug("Sent COORDINATION_MESSAGE: {}", coordinationMessageUri);
else
logger.error("Content of the COORDINATION_MESSAGE must be: {}. Currently it is: {}", WON_TX.COORDINATION_MESSAGE_ABORT.getURI(), coordinationMessageUri);
}
}
Collection<URI> toDeactivate = getEventListenerContext().getBotContextWrapper().retrieveAllAtomUris();
for (URI uri : toDeactivate) {
getEventListenerContext().getWonMessageSender().prepareAndSendMessage(createWonMessage(uri));
getEventListenerContext().getEventBus().publish(new AtomDeactivatedEvent(uri));
}
}
use of won.bot.framework.eventbot.event.impl.atomlifecycle.AtomDeactivatedEvent in project webofneeds by researchstudio-sat.
the class DeactivateAllAtomsAction method doRun.
@Override
protected void doRun(Event event, EventListener executingListener) throws Exception {
Collection<URI> toDeactivate = getEventListenerContext().getBotContextWrapper().retrieveAllAtomUris();
for (URI uri : toDeactivate) {
getEventListenerContext().getWonMessageSender().prepareAndSendMessage(WonMessageBuilder.deactivate().direction().fromOwner().atom(uri).build());
getEventListenerContext().getEventBus().publish(new AtomDeactivatedEvent(uri));
}
}
Aggregations