@Override public URI getConnectionURI() { return message.getReceiverURI(); }
if (wonMessage.getReceiverURI() != null) { executorService.execute(new Runnable()
public void process(final Exchange exchange) throws Exception { Message message = exchange.getIn(); WonMessage wonMessage = (WonMessage) message.getHeader(WonCamelConstants.MESSAGE_HEADER); URI connectionURIFromWonMessage = wonMessage.getReceiverURI(); Connection con = dataService.nextConnectionState( connectionURIFromWonMessage, ConnectionEventType.PARTNER_CLOSE); }
private void checkReceivers(final WonNodeInfo receiverNodeInfo, final WonMessage message) { checkNodeConformance(receiverNodeInfo, message.getReceiverNeedURI(), message.getReceiverURI(), null); }
private static URI getParentUriFromReceiverProperties(WonMessage message) { URI parentURI; parentURI = message.getReceiverURI(); if (parentURI == null) { parentURI = message.getReceiverNeedURI(); } if (parentURI == null) { parentURI = message.getReceiverNodeURI(); } return parentURI; }
public void process(final Exchange exchange) throws Exception { Message message = exchange.getIn(); WonMessage wonMessage = (WonMessage) message.getHeader(WonCamelConstants.MESSAGE_HEADER); URI connectionUri = wonMessage.getReceiverURI(); if (connectionUri == null){ throw new MissingMessagePropertyException(URI.create(WONMSG.RECEIVER_PROPERTY.toString())); } Connection con = connectionRepository.findOneByConnectionURIForUpdate(connectionUri); if (con.getState() != ConnectionState.CONNECTED) { throw new IllegalMessageForConnectionStateException(connectionUri, "CONNECTION_MESSAGE", con.getState()); } }
@Override public void process(Exchange exchange) throws Exception { Object msg = exchange.getIn().getHeader(WON_MESSAGE_HEADER); if (msg == null) { throw new IllegalArgumentException("expected a WonMessage object in the '"+ WON_MESSAGE_HEADER + " header but header was null"); } if (! (msg instanceof WonMessage) ) { throw new IllegalArgumentException("expected a WonMessage object in the '"+ WON_MESSAGE_HEADER + " header but the object is of type " + msg.getClass()); } if (logger.isDebugEnabled()){ logger.debug("calling adaptee {} with message {} (type: {}, direction: {}, recipient: {})", new Object[]{adaptee, msg, ((WonMessage) msg).getMessageType(), ((WonMessage) msg).getEnvelopeType(), ((WonMessage) msg).getReceiverURI()}); } //call the process method WonMessage resultMsg = null; try { resultMsg = adaptee.process((WonMessage) msg); if (logger.isDebugEnabled()){ logger.debug("returning from adaptee {} with message {} (type: {}, direction: {}, recipient: {})", new Object[]{adaptee, msg, ((WonMessage) msg).getMessageType(), ((WonMessage) msg).getEnvelopeType(), ((WonMessage) msg).getReceiverURI()}); } } catch (Exception e) { logger.info("re-throwing exception {} caught calling adaptee {} with message {} (type: {}, direction: {}, recipient:{})", new Object[]{ e, adaptee, msg, ((WonMessage) msg).getMessageType(), ((WonMessage) msg).getEnvelopeType(), ((WonMessage) msg).getReceiverURI()}); throw e; } //set the result of the call as the new message in the exchange's in exchange.getIn().setHeader(WON_MESSAGE_HEADER, resultMsg); } }
@Override public void doRun(final Event event, EventListener executingListener) throws Exception { 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; hintEvent.getWonMessage().getReceiverURI(); boolean feedbackValue = random.nextBoolean(); WonMessage message = createFeedbackMessage(hintEvent.getWonMessage().getReceiverURI(), feedbackValue); logger.debug("sending {} feedback for hint {} in message {}",new Object[]{ (feedbackValue ? "positive":"negative"), event, message.getMessageURI()}); getEventListenerContext().getWonMessageSender().sendWonMessage(message); } }
@Override public boolean matches(Exchange exchange) { WonMessage message = (WonMessage) exchange.getIn().getHeader(WonCamelConstants.ORIGINAL_MESSAGE_HEADER); if (message == null) return false; if (message.getEnvelopeType() != WonMessageDirection.FROM_SYSTEM) return false; if (message.getSenderURI() != null) { return message.getSenderURI().equals(message.getReceiverURI()); } else { if (message.getSenderNeedURI() == null) return false; return message.getSenderNeedURI().equals(message.getReceiverNeedURI()); } } }
if (con.getConnectionURI() == null) throw new IllegalStateException("connection uri must not be null"); if (!con.getConnectionURI().equals(wonMessage.getSenderURI())) throw new IllegalStateException("connection uri must be equal to sender uri"); if (wonMessage.getReceiverURI() != null) { if (!wonMessage.getReceiverURI().equals(con.getRemoteConnectionURI())) throw new IllegalStateException("remote connection uri must be equal to receiver uri"); if (con.getRemoteConnectionURI() == null) { con.setRemoteConnectionURI(wonMessage.getReceiverURI());
public void process(final Exchange exchange) throws Exception { Message message = exchange.getIn(); WonMessage wonMessage = (WonMessage) message.getHeader(WonCamelConstants.MESSAGE_HEADER); URI connectionUri = wonMessage.getSenderURI(); if (connectionUri == null){ throw new MissingMessagePropertyException(URI.create(WONMSG.SENDER_PROPERTY.toString())); } Connection con = connectionRepository.findOneByConnectionURIForUpdate(connectionUri); if (con.getState() != ConnectionState.CONNECTED) { throw new IllegalMessageForConnectionStateException(connectionUri, "CONNECTION_MESSAGE", con.getState()); } URI remoteMessageUri = wonNodeInformationService .generateEventURI(wonMessage.getReceiverNodeURI()); if (wonMessage.getReceiverURI() == null){ //set the sender uri in the envelope TODO: TwoMsgs: do not set sender here wonMessage.addMessageProperty(WONMSG.RECEIVER_PROPERTY, con.getRemoteConnectionURI()); } //add the information about the remote message to the locally stored one wonMessage.addMessageProperty(WONMSG.HAS_CORRESPONDING_REMOTE_MESSAGE, remoteMessageUri); //the persister will pick it up later //put the factory into the outbound message factory header. It will be used to generate the outbound message //after the wonMessage has been processed and saved, to make sure that the outbound message contains //all the data that we also store locally OutboundMessageFactory outboundMessageFactory = new OutboundMessageFactory(remoteMessageUri, con); exchange.getIn().setHeader(WonCamelConstants.OUTBOUND_MESSAGE_FACTORY_HEADER, outboundMessageFactory); }
public void process(final Exchange exchange) throws Exception { Message message = exchange.getIn(); WonMessage wonMessage = (WonMessage) message.getHeader(WonCamelConstants.MESSAGE_HEADER); URI connectionUri = wonMessage.getSenderURI(); if (connectionUri == null){ throw new MissingMessagePropertyException(URI.create(WONMSG.SENDER_PROPERTY.toString())); } Connection con = connectionRepository.findOneByConnectionURIForUpdate(connectionUri); if (con.getState() != ConnectionState.CONNECTED) { throw new IllegalMessageForConnectionStateException(connectionUri, "CONNECTION_MESSAGE", con.getState()); } URI remoteMessageUri = wonNodeInformationService .generateEventURI(wonMessage.getReceiverNodeURI()); if (wonMessage.getReceiverURI() == null){ //set the sender uri in the envelope TODO: TwoMsgs: do not set sender here wonMessage.addMessageProperty(WONMSG.RECEIVER_PROPERTY, con.getRemoteConnectionURI()); } //add the information about the remote message to the locally stored one wonMessage.addMessageProperty(WONMSG.HAS_CORRESPONDING_REMOTE_MESSAGE, remoteMessageUri); //the persister will pick it up later //put the factory into the outbound message factory header. It will be used to generate the outbound message //after the wonMessage has been processed and saved, to make sure that the outbound message contains //all the data that we also store locally OutboundMessageFactory outboundMessageFactory = new OutboundMessageFactory(remoteMessageUri, con); exchange.getIn().setHeader(WonCamelConstants.OUTBOUND_MESSAGE_FACTORY_HEADER, outboundMessageFactory); }
public MessageEventPlaceholder(URI parentURI, WonMessage wonMessage, EventContainer eventContainer) { this.parentURI = parentURI; this.messageURI = wonMessage.getMessageURI(); this.messageType = wonMessage.getMessageType(); this.senderURI = wonMessage.getSenderURI(); this.senderNeedURI = wonMessage.getSenderNeedURI(); this.senderNodeURI = wonMessage.getSenderNodeURI(); this.receiverURI = wonMessage.getReceiverURI(); this.receiverNeedURI = wonMessage.getReceiverNeedURI(); this.receiverNodeURI = wonMessage.getReceiverNodeURI(); this.creationDate = new Date(); this.correspondingRemoteMessageURI = wonMessage.getCorrespondingRemoteMessageURI(); this.referencedByOtherMessage = false; this.innermostMessageURI = wonMessage.getInnermostMessageURI(); this.eventContainer = eventContainer; }
WonMessage wonMessage = (WonMessage) message.getHeader(WonCamelConstants.MESSAGE_HEADER); URI connectionURIFromWonMessage = wonMessage.getReceiverURI(); Connection con = null; if (connectionURIFromWonMessage == null) {
@Override protected void doRun(Event event, EventListener executingListener) throws Exception { EventListenerContext ctx = getEventListenerContext(); if (event instanceof HintFromMatcherEvent && ctx.getBotContextWrapper() instanceof MailBotContextWrapper){ MailBotContextWrapper botContextWrapper = (MailBotContextWrapper) ctx.getBotContextWrapper(); Match match = ((HintFromMatcherEvent) event).getMatch(); WonMessage message = ((HintFromMatcherEvent) event).getWonMessage(); URI responseTo = match.getFromNeed(); URI remoteNeedUri = match.getToNeed(); MimeMessage originalMail = botContextWrapper.getMimeMessageForURI(responseTo); logger.debug( "Found a hint for URI: " + responseTo + " sending a mail to the creator: " + MailContentExtractor .getFromAddressString(originalMail)); WonMimeMessage answerMessage = mailGenerator.createHintMail(originalMail, remoteNeedUri); botContextWrapper.addMailIdWonURIRelation(answerMessage.getMessageID(), new WonURI(message.getReceiverURI(), UriType.CONNECTION)); sendChannel.send(new GenericMessage<>(answerMessage)); } } }
URI remoteConnectionUri = wonMessage.getSenderURI(); URI facetURI = WonRdfUtils.FacetUtils.getFacet(wonMessage); URI connectionURI = wonMessage.getReceiverURI(); //if the uri is known already, we can load the connection!
@Override protected void doRun(Event event, EventListener executingListener) throws Exception { EventListenerContext ctx = getEventListenerContext(); if (event instanceof HintFromMatcherEvent && ctx.getBotContextWrapper() instanceof TelegramBotContextWrapper) { TelegramBotContextWrapper botContextWrapper = (TelegramBotContextWrapper) ctx.getBotContextWrapper(); Match match = ((HintFromMatcherEvent) event).getMatch(); WonMessage wonMessage = ((HintFromMatcherEvent) event).getWonMessage(); URI yourNeedUri = match.getFromNeed(); URI remoteNeedUri = match.getToNeed(); Long chatId = botContextWrapper.getChatIdForURI(yourNeedUri); if(chatId == null) { logger.error("No chatId found for the specified needUri"); return; } try{ Message message = wonTelegramBotHandler.sendMessage(wonTelegramBotHandler.getTelegramMessageGenerator().getHintMessage(chatId, remoteNeedUri, yourNeedUri)); botContextWrapper.addMessageIdWonURIRelation(message.getMessageId(), new WonURI(wonMessage.getReceiverURI(), UriType.CONNECTION)); }catch (TelegramApiException te){ logger.error(te.getMessage()); } } } }
equalsOrBothNull(processedMessage.getReceiverURI(), message.getReceiverURI()) && equalsOrBothNull(processedMessage.getSenderNodeURI(), message.getSenderNodeURI())
/** * Copies the envelope properties from the specified message to this message. * * Note that this does not copy the original envelope graph, only the * standard envelope properties. * * @param wonMessage * @return */ public static WonMessageBuilder copyEnvelopeFromWonMessage(final WonMessage wonMessage) { WonMessageBuilder builder = new WonMessageBuilder(wonMessage.getMessageURI()) .setWonMessageType(wonMessage.getMessageType()) .setReceiverURI(wonMessage.getReceiverURI()) .setReceiverNeedURI(wonMessage.getReceiverNeedURI()) .setReceiverNodeURI(wonMessage.getReceiverNodeURI()) .setSenderURI(wonMessage.getSenderURI()) .setSenderNeedURI(wonMessage.getSenderNeedURI()) .setSenderNodeURI(wonMessage.getSenderNodeURI()); if (wonMessage.getIsResponseToMessageType() != null){ builder.setIsResponseToMessageType(wonMessage.getIsResponseToMessageType()); } if (wonMessage.getIsResponseToMessageURI() != null){ builder.setIsResponseToMessageURI(wonMessage.getIsResponseToMessageURI()); } if (wonMessage.getIsRemoteResponseToMessageURI() != null){ builder.setIsRemoteResponseToMessageURI(wonMessage.getIsRemoteResponseToMessageURI()); } return builder; }
.setSenderNodeURI(originalMessage.getReceiverNodeURI()) .setSenderNeedURI(originalMessage.getReceiverNeedURI()) .setSenderURI(originalMessage.getReceiverURI()) .setIsRemoteResponseToMessageURI(originalMessage.getCorrespondingRemoteMessageURI()); } else if (WonMessageDirection.FROM_OWNER == origDirection|| WonMessageDirection.FROM_SYSTEM == origDirection ){