private void sendResult(Action action) { if (sender == null) { throw new IllegalStateException("ActionPluginSender is not present in the plugin"); } if (action == null) { throw new IllegalStateException("Action to update result must be not null"); } ActionResponseMessage newMessage = sender.createMessage(ActionResponseMessage.Operation.RESULT); newMessage.getPayload().put("action", JsonUtil.toJson(action)); try { sender.send(newMessage); } catch (Exception e) { msgLog.error("Error sending ActionResponseMessage", e); } }
@Override public void process(ActionMessage msg) throws Exception { try { if (!isConnected()) { connect(msg.getAction().getProperties()); } send(msg.getAction(), Boolean.parseBoolean(detail)); msgLog.infoActionReceived("irc", msg.toString()); Action successAction = msg.getAction(); successAction.setResult(MESSAGE_PROCESSED); sendResult(successAction); } catch (Exception e) { Action failedAction = msg.getAction(); failedAction.setResult(MESSAGE_FAILED); sendResult(failedAction); } }