use of won.protocol.message.WonMessage in project webofneeds by researchstudio-sat.
the class SuccessResponder method process.
@Override
public void process(final Exchange exchange) throws Exception {
WonMessage originalMessage = (WonMessage) exchange.getIn().getHeader(WonCamelConstants.MESSAGE_HEADER);
if (originalMessage == null)
throw new WonMessageProcessingException("did not find the original message in the " + "exchange header '" + WonCamelConstants.MESSAGE_HEADER + "'");
// with other means which ownerapplications to send the response to.
if (originalMessage.getSenderNeedURI() == null)
return;
if (originalMessage.getMessageType() == WonMessageType.HINT_MESSAGE) {
// we don't want to send a SuccessResponse for a hint message as matchers
// are not fully compatible messaging agents (needs), so sending this message will fail.
logger.debug("suppressing success response for HINT message");
return;
}
URI newMessageURI = this.wonNodeInformationService.generateEventURI();
WonMessage responseMessage = WonMessageBuilder.setPropertiesForNodeResponse(originalMessage, true, newMessageURI).build();
if (WonMessageDirection.FROM_OWNER == originalMessage.getEnvelopeType()) {
sendSystemMessageToOwner(responseMessage);
} else if (WonMessageDirection.FROM_EXTERNAL == originalMessage.getEnvelopeType()) {
sendSystemMessage(responseMessage);
}
}
use of won.protocol.message.WonMessage in project webofneeds by researchstudio-sat.
the class ToNodeSender method process.
@Override
public void process(final Exchange exchange) throws Exception {
WonMessage message = (WonMessage) exchange.getIn().getHeader(WonCamelConstants.MESSAGE_HEADER);
sendMessageToNode(message);
}
use of won.protocol.message.WonMessage in project webofneeds by researchstudio-sat.
the class ToOwnerSender method process.
@Override
public void process(final Exchange exchange) throws Exception {
WonMessage message = (WonMessage) exchange.getIn().getHeader(WonCamelConstants.MESSAGE_HEADER);
sendMessageToOwner(message, message.getReceiverNeedURI(), (String) exchange.getIn().getHeader(WonCamelConstants.OWNER_APPLICATION_ID));
}
use of won.protocol.message.WonMessage in project webofneeds by researchstudio-sat.
the class UriAlreadyUsedCheckingWonMessageProcessor method isDuplicateMessage.
private boolean isDuplicateMessage(final WonMessage message, MessageEventPlaceholder event) {
// retrieve already processed message
Dataset processedDataset = event.getDatasetHolder().getDataset();
// compare with received message
// TODO ideally, here, only signatures of the corresponding envelopes have to be compared.
// But as of now, before saving, the receiving side can add any number of envelopes.
// Therefore, temporarily, before we know better how to retrieve the right envelope,
// we compare here the main envelope data and the contents, without envelope signatures.
WonMessage processedMessage = new WonMessage(processedDataset);
boolean sameEnvelope = hasSameEnvelopeData(processedMessage, message);
boolean sameContent = hasSameContent(processedMessage, message);
if (sameEnvelope && sameContent) {
return true;
}
return false;
}
use of won.protocol.message.WonMessage in project webofneeds by researchstudio-sat.
the class ActivateNeedMessageProcessor method process.
public void process(Exchange exchange) throws Exception {
Message message = exchange.getIn();
WonMessage wonMessage = (WonMessage) message.getHeader(WonCamelConstants.MESSAGE_HEADER);
URI receiverNeedURI = wonMessage.getReceiverNeedURI();
logger.debug("ACTIVATING need. needURI:{}", receiverNeedURI);
if (receiverNeedURI == null)
throw new IllegalArgumentException("receiverNeedURI is not set");
Need need = DataAccessUtils.loadNeed(needRepository, receiverNeedURI);
need.getEventContainer().getEvents().add(messageEventRepository.findOneByMessageURIforUpdate(wonMessage.getMessageURI()));
need.setState(NeedState.ACTIVE);
logger.debug("Setting Need State: " + need.getState());
needRepository.save(need);
}
Aggregations