public void sendTextMessageToOwner(URI needURI, String message){ if (needURI == null){ logger.warn("sendTextMessageToOwner called but needUri is null - doing nothing"); return; } if (message == null || message.trim().length() == 0){ logger.warn("sendTextMessageToOwner called for need {}, but message is null or empty - doing nothing"); return; } logger.debug("Sending FromSystem text message to need {}", needURI); //check if we have that need (e.g. it's not a need living on another node, or does not exist at all) Need need = needRepository.findOneByNeedURI(needURI); if (need == null) { logger.debug("deactivateNeed called for need {} but that need was not found in the repository - doing nothing"); return; } URI wonNodeURI = wonNodeInformationService.getWonNodeUri(needURI); if (wonNodeURI == null) { logger.debug("deactivateNeed called for need {} but we could not find a WonNodeURI for that need - doing nothing"); return; } URI messageURI = wonNodeInformationService.generateEventURI(wonNodeURI); WonMessageBuilder builder = WonMessageBuilder .setMessagePropertiesForNeedMessageFromSystem(messageURI, needURI, wonNodeURI); builder.setTextMessage(message); sendSystemMessage(builder.build()); }
public void deactivateNeed(URI needURI, String optionalMessage){ if (needURI == null){ logger.warn("deactivateNeed called but needUri is null - doing nothing"); return; } logger.debug("Deactivating need {}", needURI); //check if we have that need (e.g. it's not a need living on another node, or does not exist at all) Need need = needRepository.findOneByNeedURI(needURI); if (need == null) { logger.debug("deactivateNeed called for need {} but that need was not found in the repository - doing nothing"); return; } URI wonNodeURI = wonNodeInformationService.getWonNodeUri(needURI); if (wonNodeURI == null) { logger.debug("deactivateNeed called for need {} but we could not find a WonNodeURI for that need - doing nothing"); return; } URI messageURI = wonNodeInformationService.generateEventURI(wonNodeURI); WonMessageBuilder builder = WonMessageBuilder .setMessagePropertiesForDeactivateFromSystem(messageURI, needURI, wonNodeURI); if (optionalMessage != null && optionalMessage.trim().length() > 0){ builder.setTextMessage(optionalMessage); } sendSystemMessage(builder.build()); }
public static WonMessageBuilder setMessagePropertiesForOpen( URI messageURI, URI localConnection, URI localNeed, URI localWonNode, URI remoteConnection, URI remoteNeed, URI remoteWonNode, String welcomeMessage) { return new WonMessageBuilder(messageURI) .setWonMessageDirection(WonMessageDirection.FROM_OWNER) .setWonMessageType(WonMessageType.OPEN) .setSenderURI(localConnection) .setSenderNeedURI(localNeed) .setSenderNodeURI(localWonNode) .setReceiverURI(remoteConnection) .setReceiverNeedURI(remoteNeed) .setReceiverNodeURI(remoteWonNode) .setTextMessage(welcomeMessage) .setSentTimestampToNow(); }
public static WonMessageBuilder setMessagePropertiesForClose( URI messageURI, WonMessageDirection direction, URI localConnection, URI localNeed, URI localWonNode, URI remoteConnection, URI remoteNeed, URI remoteWonNode, String farewellMessage) { return new WonMessageBuilder(messageURI) .setWonMessageDirection(direction) .setWonMessageType(WonMessageType.CLOSE) .setSenderURI(localConnection) .setSenderNeedURI(localNeed) .setSenderNodeURI(localWonNode) .setReceiverURI(remoteConnection) .setReceiverNeedURI(remoteNeed) .setReceiverNodeURI(remoteWonNode) .setTextMessage(farewellMessage) .setSentTimestampToNow(); }
.setReceiverNeedURI(remoteNeed) .setReceiverNodeURI(remoteWonNode) .setTextMessage(textMessage) .setSentTimestampToNow();