@Override public void run(Action action) throws ActionFailureException, ActionParameterException { // Look it up. final SshActionDefinition actionDef = actionDefinitions.get(action.getAppliesToActionDefinition()); if (actionDef == null) { throw new ActionFailureException("Action is not provided by the SSH provider. Please open a bug."); } actionDef.run(action); }
final PushMessage pushMessage = new PushMessage(); pushMessage.setTimeStamp(new Date()); pushMessage.setMessage(action.getParameters().get(MessageParameterDefinition.DEF_UUID)); pushMessage.setUser(action.getParameters().get(UserParameterDefinition.DEF_UUID)); pushMessage.setTitle(action.getParameters().get(TitleParameterDefinition.DEF_UUID)); pushMessage.setDevice(action.getParameters().get(DeviceParameterDefinition.DEF_UUID)); pushMessage.setUrl(action.getParameters().get(UrlParameterDefinition.DEF_UUID)); pushMessage.setUrlTitle(action.getParameters().get(UrlTitleParameterDefinition.DEF_UUID)); pushMessage.setSound(action.getParameters().get(SoundParameterDefinition.DEF_UUID)); final String priorityStr = action.getParameters().get(PriorityParameterDefinition.DEF_UUID); if (priorityStr != null && priorityStr.matches("-?\\d+")) { pushMessage.setPriority(Integer.parseInt(priorityStr)); final String apiToken = action.getParameters().get(TokenParameterDefinition.DEF_UUID); throw new ActionParameterException("Token is required."); throw new ActionParameterException("User is required."); throw new ActionParameterException("Message is required."); pushOverClient.sendPushMessage(pushMessage); } catch (PushOverException e) { throw new ActionParameterException(e.getMessage(), e); } catch (IOException e) { throw new ActionFailureException(e.getMessage(), e);
logger.entry(action); if (ShowNotificationActionDefinition.INSTANCE.getUUID().equals(action.getAppliesToActionDefinition())) { final String host = action.getParameters().get(HostParameterDefinition.DEF_UUID); if (host == null) { final ActionParameterException t = new ActionParameterException(HostParameterDefinition.INSTANCE.getName() + " is missing."); if (logger.isTraceEnabled()) { logger.throwing(t); final XbmcClient client = findClient(host); if (client == null) { final ActionParameterException t = new ActionParameterException("Host " + host + " could not be found."); if (logger.isTraceEnabled()) { logger.throwing(t);
UUID uuid = actionDef.getUUID(); if (uuid == null) { LOG.error("Provider, " + provider.getName() + " (" + provider.getUuid() + ") has an Action Definition with null UUID.");
@Override public void run(Action action) throws ActionFailureException, ActionParameterException { final String host = action.getParameters().get(HostParameterDefinition.DEF_UUID); final String portStr = action.getParameters().get(PortParameterDefinition.DEF_UUID); final String commandLine = action.getParameters().get(CommandLineParameterDefinition.DEF_UUID); final String returnCodeStr = action.getParameters().get(SuccessfulReturnCodeParameterDefinition.DEF_UUID); final String userName = action.getParameters().get(UserNameParameterDefinition.DEF_UUID); final String password = action.getParameters().get(PasswordParameterDefinition.DEF_UUID); throw new ActionParameterException("Host parameter is missing."); throw new ActionParameterException("UserName parameter is missing."); throw new ActionParameterException("Password parameter is missing."); throw new ActionParameterException("Command Line parameter is missing."); session = jsch.getSession(userName, host, port); } catch (JSchException e) { throw new ActionFailureException("Could not configure SSH client.", e); session.connect(); } catch (JSchException e) { throw new ActionFailureException("Could not connect to SSH server:" + e.getMessage(), e); channelExec = (ChannelExec) session.openChannel("exec"); } catch (JSchException e) { throw new ActionFailureException("Could not open a channel with SSH server:" + e.getMessage(), e); channelExec.connect();
@Override public void run(Action action) throws ActionFailureException, ActionParameterException { // Look it up. final AbstractPushMessageActionDefinition actionDef = actionDefinitions.get(action.getAppliesToActionDefinition()); if (actionDef == null) { throw new ActionFailureException("Action is not provided by the PushOver provider. Please open a bug."); } actionDef.run(action); }
@Override public void run(Action action) throws ActionFailureException, ActionParameterException { final String friendlyName = action.getParameters().get(FriendlyNameParameterDefinition.INSTANCE.getUUID()); final String onStr = action.getParameters().get(OnParameterDefinition.INSTANCE.getUUID()); throw new ActionParameterException(FriendlyNameParameterDefinition.INSTANCE.getName() + " parameter is required."); throw new ActionParameterException(OnParameterDefinition.INSTANCE.getName() + " parameter is required."); newSwitchOnValue = false; } else { throw new ActionParameterException(OnParameterDefinition.INSTANCE.getName() + " parameter value is not recognized."); failNames[i] = device.getFriendlyName() + " (" + device.getUniqueDeviceName() + ")"; throw new ActionFailureException("Could not switch all matching Wemo devices (" + Arrays.toString(failNames) + ')');
@Override public void run(Action action) throws ActionFailureException, ActionParameterException { // Look it up. final WemoActionDefinition actionDef = actionDefinitions.get(action.getAppliesToActionDefinition()); if (actionDef == null) { throw new ActionFailureException("Action is not provided by the " + getName() + " provider. Please open a bug."); } actionDef.run(action); }
final String title = action.getParameters().get(TitleParameterDefinition.DEF_UUID); if (title == null) { final ActionParameterException t = new ActionParameterException(TitleParameterDefinition.INSTANCE.getName() + " is missing."); if (logger.isTraceEnabled()) { logger.throwing(t); final String message = action.getParameters().get(MessageParameterDefinition.DEF_UUID); if (message == null) { final ActionParameterException t = new ActionParameterException(MessageParameterDefinition.INSTANCE.getName() + " is missing."); if (logger.isTraceEnabled()) { logger.throwing(t); final String icon = action.getParameters().get(NotificationIconParameterDefinition.DEF_UUID); if (icon == null) { final ActionParameterException t = new ActionParameterException(NotificationIconParameterDefinition.INSTANCE.getName() + " is missing."); if (logger.isTraceEnabled()) { logger.throwing(t); final String durationStr = action.getParameters().get(DurationParameterDefinition.DEF_UUID); if (durationStr == null) { final ActionParameterException t = new ActionParameterException(DurationParameterDefinition.INSTANCE.getName() + " is missing."); if (logger.isTraceEnabled()) { logger.throwing(t); client.sendMessage(rpcMessage); } catch (JsonProcessingException e) { final ActionFailureException t = new ActionFailureException("Failed to build show notification message.", e); if (logger.isTraceEnabled()) { logger.throwing(t);
@Override public void run(Action action) throws ActionFailureException, ActionParameterException { if (LOG.isTraceEnabled()) { LOG.entry(action); } final UUID actionDefinitionUuid = action.getAppliesToActionDefinition(); final UUID providerUuid = actionDefinitionToProvider.get(actionDefinitionUuid); final Provider provider = providers.get(providerUuid); try { provider.run(action); } catch (ActionFailureException | ActionParameterException e) { LOG.throwing(e); throw e; } catch (Exception e) { // Any unknown or unexpected exceptions are wrapped as a failure and thrown. final ActionFailureException afe = new ActionFailureException(e); LOG.throwing(afe); throw afe; } if (LOG.isTraceEnabled()) { LOG.exit(); } }