Search in sources :

Example 31 with WonMessage

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);
    }
}
Also used : WonMessageProcessingException(won.protocol.message.processor.exception.WonMessageProcessingException) WonMessage(won.protocol.message.WonMessage) URI(java.net.URI)

Example 32 with WonMessage

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);
}
Also used : WonMessage(won.protocol.message.WonMessage)

Example 33 with WonMessage

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));
}
Also used : WonMessage(won.protocol.message.WonMessage)

Example 34 with WonMessage

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;
}
Also used : Dataset(org.apache.jena.query.Dataset) WonMessage(won.protocol.message.WonMessage)

Example 35 with WonMessage

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);
}
Also used : Need(won.protocol.model.Need) Message(org.apache.camel.Message) WonMessage(won.protocol.message.WonMessage) WonMessage(won.protocol.message.WonMessage) URI(java.net.URI)

Aggregations

WonMessage (won.protocol.message.WonMessage)89 URI (java.net.URI)47 Connection (won.protocol.model.Connection)19 Test (org.junit.Test)18 Message (org.apache.camel.Message)17 Dataset (org.apache.jena.query.Dataset)17 Exchange (org.apache.camel.Exchange)13 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)13 DefaultExchange (org.apache.camel.impl.DefaultExchange)13 WonMessageProcessingException (won.protocol.message.processor.exception.WonMessageProcessingException)11 EventListenerContext (won.bot.framework.eventbot.EventListenerContext)10 MissingMessagePropertyException (won.protocol.message.processor.exception.MissingMessagePropertyException)9 Event (won.bot.framework.eventbot.event.Event)8 FailureResponseEvent (won.bot.framework.eventbot.event.impl.wonmessage.FailureResponseEvent)8 EventListener (won.bot.framework.eventbot.listener.EventListener)7 Need (won.protocol.model.Need)7 WonNodeInformationService (won.protocol.service.WonNodeInformationService)7 Model (org.apache.jena.rdf.model.Model)5 WonURI (won.bot.framework.eventbot.action.impl.mail.model.WonURI)5 DefaultNeedModelWrapper (won.protocol.util.DefaultNeedModelWrapper)4