@Override public URI getNeedURI() { return message.getReceiverNeedURI(); } }
@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)); } }
public void run(){ try { logger.debug("onSuccessResponse for message {} ",successfulMessageUri); URI needUri = wonMessage.getReceiverNeedURI(); getBotForNeedUri(needUri).onSuccessResponse(successfulMessageUri, wonMessage); } catch (Exception e) { logger.warn("error while handling onSuccessResponse()",e); } } }, new Date());
public void run(){ try { logger.debug("onFailureResponse for message {} ",failedMessageUri); URI needUri = wonMessage.getReceiverNeedURI(); getBotForNeedUri(needUri).onFailureResponse(failedMessageUri, wonMessage); } catch (Exception e) { logger.warn("error while handling onFailureResponse()",e); } } }, new Date());
@Override public URI getRemoteNeedURI() { return getWonMessage().getReceiverNeedURI(); } }
public void process(Exchange exchange) throws Exception { Message message = exchange.getIn(); WonMessage wonMessage = (WonMessage) message.getHeader(WonCamelConstants.MESSAGE_HEADER); URI receiverNeedURI = wonMessage.getReceiverNeedURI(); if (receiverNeedURI == null) throw new IllegalArgumentException("receiverNeedURI is not set"); matcherProtocolMatcherClient.needActivated(receiverNeedURI, wonMessage); }
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; }
private void checkReceivers(final WonNodeInfo receiverNodeInfo, final WonMessage message) { checkNodeConformance(receiverNodeInfo, message.getReceiverNeedURI(), message.getReceiverURI(), null); }
/** * Returns the need that this message belongs to. * @param message * @return */ public static URI getParentNeedUri(final WonMessage message){ WonMessageDirection direction = message.getEnvelopeType(); if (direction == WonMessageDirection.FROM_EXTERNAL ){ return message.getReceiverNeedURI(); } else if (direction == WonMessageDirection.FROM_OWNER || direction == WonMessageDirection.FROM_SYSTEM){ return message.getSenderNeedURI(); } else { throw new IllegalArgumentException("Unexpected message direction: " + direction); } }
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); }
@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()); } } }
public void process(final Exchange exchange) throws Exception { WonMessage wonMessage = (WonMessage) exchange.getIn().getHeader(WonCamelConstants.MESSAGE_HEADER); URI receiverNeedURI = wonMessage.getReceiverNeedURI(); logger.debug("DEACTIVATING need. needURI:{}", receiverNeedURI); if (receiverNeedURI == null) throw new WonMessageProcessingException("receiverNeedURI is not set"); Need need = DataAccessUtils.loadNeed(needRepository, receiverNeedURI); need.getEventContainer().getEvents().add(messageEventRepository.findOneByMessageURIforUpdate(wonMessage.getMessageURI())); need.setState(NeedState.INACTIVE); need = needRepository.save(need); }
@Override public void process(Exchange exchange) throws Exception { Message message = exchange.getIn(); WonMessage wonMessage = (WonMessage) message.getHeader(WonCamelConstants.MESSAGE_HEADER); URI receiverNeedURI = wonMessage.getReceiverNeedURI(); URI senderNeedURI = wonMessage.getSenderNeedURI(); if (receiverNeedURI== null){ throw new MissingMessagePropertyException(URI.create(WONMSG.RECEIVER_NEED_PROPERTY.toString())); } if (senderNeedURI == null){ throw new MissingMessagePropertyException(URI.create(WONMSG.SENDER_NEED_PROPERTY.toString())); } if (!receiverNeedURI.equals(senderNeedURI)) { throw new IllegalArgumentException("sender need uri " + senderNeedURI +" does not equal receiver need uri " + receiverNeedURI); } Need need = needRepository.findOneByNeedURI(senderNeedURI); if (need == null){ throw new IllegalArgumentException("need not found - cannot send need message to: " + senderNeedURI); } need.getEventContainer().getEvents().add(messageEventRepository.findOneByMessageURIforUpdate(wonMessage.getMessageURI())); need = needRepository.save(need); } }
@Override protected void doRun(Event event, EventListener executingListener) throws Exception { if (!(event instanceof MessageFromOtherNeedEvent)) { return; } logger.debug("eagerly caching data in reaction to event {}", event); MessageFromOtherNeedEvent msgEvent = (MessageFromOtherNeedEvent) event; WonMessage wonMessage = msgEvent.getWonMessage(); LinkedDataSource linkedDataSource = context.getLinkedDataSource(); if (linkedDataSource instanceof CachingLinkedDataSource) { ((CachingLinkedDataSource) linkedDataSource).addToCache(wonMessage.getCompleteDataset(), wonMessage.getMessageURI(), wonMessage.getReceiverNeedURI()); URI requester = wonMessage.getReceiverNeedURI(); Set<URI> toLoad = new HashSet<URI>(); addIfNotNull(toLoad, wonMessage.getCorrespondingRemoteMessageURI()); List<URI> previous = WonRdfUtils.MessageUtils.getPreviousMessageUrisIncludingRemote(wonMessage); addIfNotNull(toLoad, previous); toLoad.forEach(uri -> linkedDataSource.getDataForResource(uri, requester)); } }
@Override public void process(Exchange exchange) throws Exception { WonMessage wonMessage = (WonMessage) exchange.getIn().getHeader(WonCamelConstants.MESSAGE_HEADER); URI receiverNeedURI = wonMessage.getReceiverNeedURI(); URI senderNeedURI = wonMessage.getSenderNeedURI(); if (receiverNeedURI== null){ throw new MissingMessagePropertyException(URI.create(WONMSG.RECEIVER_NEED_PROPERTY.toString())); } if (senderNeedURI == null){ throw new MissingMessagePropertyException(URI.create(WONMSG.SENDER_NEED_PROPERTY.toString())); } if (!receiverNeedURI.equals(senderNeedURI)) { throw new IllegalArgumentException("sender need uri " + senderNeedURI +" does not equal receiver need uri " + receiverNeedURI); } logger.debug("DEACTIVATING need. needURI:{}", receiverNeedURI); Need need = DataAccessUtils.loadNeed(needRepository, receiverNeedURI); need.getEventContainer().getEvents().add(messageEventRepository.findOneByMessageURIforUpdate(wonMessage.getMessageURI())); need.setState(NeedState.INACTIVE); need = needRepository.save(need); } }
public void process(final Exchange exchange) throws Exception { WonMessage wonMessage = (WonMessage) exchange.getIn().getHeader(WonCamelConstants.MESSAGE_HEADER); URI receiverNeedURI = wonMessage.getReceiverNeedURI(); logger.debug("DEACTIVATING need. needURI:{}", receiverNeedURI); if (receiverNeedURI == null) throw new WonMessageProcessingException("receiverNeedURI is not set"); Need need = DataAccessUtils.loadNeed(needRepository, receiverNeedURI); matcherProtocolMatcherClient.needDeactivated(need.getNeedURI(), wonMessage); //close all connections Collection<Connection> conns = connectionRepository.getConnectionsByNeedURIAndNotInStateForUpdate(need.getNeedURI (), ConnectionState.CLOSED); for (Connection con: conns) { closeConnection(need, con); } }
public void process(final Exchange exchange) throws Exception { WonMessage wonMessage = (WonMessage) exchange.getIn().getHeader(WonCamelConstants.MESSAGE_HEADER); URI receiverNeedURI = wonMessage.getReceiverNeedURI(); logger.debug("DEACTIVATING need. needURI:{}", receiverNeedURI); if (receiverNeedURI == null) throw new WonMessageProcessingException("receiverNeedURI is not set"); Need need = DataAccessUtils.loadNeed(needRepository, receiverNeedURI); matcherProtocolMatcherClient.needDeactivated(need.getNeedURI(), wonMessage); //close all connections Collection<Connection> conns = connectionRepository.getConnectionsByNeedURIAndNotInStateForUpdate(need.getNeedURI (), ConnectionState.CLOSED); for (Connection con: conns) { closeConnection(need, con); } }
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; }
/** * Converts the specified hint message into a Match object. * @param wonMessage * @return a match object or null if the message is not a hint message. */ public static Match toMatch(final WonMessage wonMessage) { if (!WONMSG.TYPE_HINT.equals(wonMessage.getMessageType().getResource())){ return null; } Match match = new Match(); match.setFromNeed(wonMessage.getReceiverNeedURI()); Dataset messageContent = wonMessage.getMessageContent(); RDFNode score = findOnePropertyFromResource(messageContent, wonMessage.getMessageURI(), WON.HAS_MATCH_SCORE); if (!score.isLiteral()) return null; match.setScore(score.asLiteral().getDouble()); RDFNode counterpart = findOnePropertyFromResource(messageContent, wonMessage.getMessageURI(), WON.HAS_MATCH_COUNTERPART); if (!counterpart.isResource()) return null; match.setToNeed(URI.create(counterpart.asResource().getURI())); return match; }
/** * 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; }