/** * Check if database port is valid. * Derby does not check this so need to add code to check the port number. */ private void checkIfPortIsValid(final String port) throws CommandValidationException { try { Integer.parseInt(port); } catch (NumberFormatException e) { throw new CommandValidationException( strings.get("InvalidPortNumber", port)); } }
validateNode(node); } catch (CommandValidationException e) { logger.warning(e.getMessage()); report.setActionExitCode(ActionReport.ExitCode.FAILURE); report.setMessage(e.getMessage()); return;
report.setMessage(ex.getLocalizedMessage()); report.setActionExitCode(ActionReport.ExitCode.FAILURE); return; if (!force) { String m2 = Strings.get("create.node.ssh.not.created", getType().toString()); msg.append(StringUtils.cat(NL, m1, m2, e.getMessage())); report.setMessage(msg.toString()); report.setActionExitCode(ActionReport.ExitCode.FAILURE); msg.append(StringUtils.cat(NL, m1, e.getMessage(), m2));
validateNode(node); } catch (CommandValidationException e) { logger.warning(e.getMessage()); report.setActionExitCode(ActionReport.ExitCode.FAILURE); report.setMessage(e.getMessage()); return;
/** * Converts the port string to port int * * @param port the port number * @return the port number as an int * @throws CommandValidationException if port string is not numeric */ private int convertPortStr(final String port) throws CommandValidationException { try { return Integer.parseInt(port); } catch (Exception e) { throw new CommandValidationException( strings.get("InvalidPortNumber", port)); } }
rc = cmd.execute(args); } catch (CommandValidationException cve) { logger.severe(cve.getMessage()); logger.severe(cmd.getUsage()); rc = ERROR;
/** * Converts the port string to port int * * @param port the port number * @return the port number as an int * @throws CommandValidationException if port string is not numeric */ private int convertPortStr(final String port) throws CommandValidationException { try { return Integer.parseInt(port); } catch (Exception e) { throw new CommandValidationException( strings.get("InvalidPortNumber", port)); } }
logger.severe(cve.getMessage()); if (cmd != null) logger.severe(cmd.getUsage());
void validateHostName(String hostName) throws CommandValidationException { if (! StringUtils.ok(hostName)) { throw new CommandValidationException( Strings.get("nodehost.required")); } try { // Check if hostName is valid by looking up it's address InetAddress addr = InetAddress.getByName(hostName); } catch (UnknownHostException e) { throw new CommandValidationException( Strings.get("unknown.host", hostName), e); } }
if (!force) { String m2 = Strings.get("create.node.ssh.not.created"); msg.append(StringUtils.cat(NL, m1, m2, e.getMessage())); report.setMessage(msg.toString()); report.setActionExitCode(ActionReport.ExitCode.FAILURE); } else { String m2 = Strings.get("create.node.ssh.continue.force"); msg.append(StringUtils.cat(NL, m1, e.getMessage(), m2));
/** * Check if portbase option is specified. * Portbase is mutually exclusive to adminport and domainproperties options. * If portbase options is specfied and also adminport or domainproperties * is specified as well, then throw an exception. */ private boolean usePortBase() throws CommandValidationException { if (portBase != null) { if (adminPort != null) { throw new CommandValidationException( strings.get("MutuallyExclusiveOption", ADMIN_PORT, PORTBASE_OPTION)); } else if (instancePort != null) { throw new CommandValidationException( strings.get("MutuallyExclusiveOption", INSTANCE_PORT, PORTBASE_OPTION)); } else if (domainProperties != null) { throw new CommandValidationException( strings.get("MutuallyExclusiveOption", DOMAIN_PROPERTIES, PORTBASE_OPTION)); } else { return true; } } return false; }
return cmd.execute(argv); } catch (CommandValidationException cve) { logger.severe(cve.getMessage()); if (cmd == null) // error parsing program options printUsage();
private void validateNodeInstallDirLocal(String nodeInstallDir, String installDir) throws CommandValidationException { String canonicalNodeInstallDir = FileUtils.safeGetCanonicalPath(new File(nodeInstallDir)); String canonicalInstallDir = FileUtils.safeGetCanonicalPath(new File(installDir)); if (canonicalNodeInstallDir == null || canonicalInstallDir == null) { throw new CommandValidationException( Strings.get("Instance.installdir.null", node, canonicalInstallDir, canonicalNodeInstallDir)); } if ( !canonicalInstallDir.equals(canonicalNodeInstallDir) ) { throw new CommandValidationException( Strings.get("Instance.installdir.mismatch", node, canonicalInstallDir, canonicalNodeInstallDir)); } }
return result; } catch (CommandValidationException cve) { logger.severe(cve.getMessage()); if (cmd == null) // error parsing program options
/** * Check if portbase option is specified. Portbase is mutually exclusive to * adminport and domainproperties options. If portbase options is specfied * and also adminport or domainproperties is specified as well, then throw * an exception. */ private boolean usePortBase() throws CommandValidationException { if (portBase != null) { if (adminPort != null) { throw new CommandValidationException( strings.get("MutuallyExclusiveOption", ADMIN_PORT, PORTBASE_OPTION)); } else if (instancePort != null) { throw new CommandValidationException( strings.get("MutuallyExclusiveOption", INSTANCE_PORT, PORTBASE_OPTION)); } else if (domainProperties != null) { throw new CommandValidationException( strings.get("MutuallyExclusiveOption", DOMAIN_PROPERTIES, PORTBASE_OPTION)); } else { return true; } } return false; }
String m1 = Strings.get("ping.node.failure", name, theNode.getNodeHost()); msg.append(StringUtils.cat(NL, m1, e.getMessage())); report.setMessage(msg.toString()); report.setActionExitCode(ActionReport.ExitCode.FAILURE);
void validateHostName(String hostName) throws CommandValidationException { if (!StringUtils.ok(hostName)) { throw new CommandValidationException( Strings.get("nodehost.required")); } try { // Check if hostName is valid by looking up it's address InetAddress.getByName(hostName); } catch (UnknownHostException e) { throw new CommandValidationException( Strings.get("unknown.host", hostName), e); } }
if (!force) { String m2 = Strings.get("update.node.ssh.not.updated"); msg.append(StringUtils.cat(NL, m1, m2, e.getMessage())); report.setMessage(msg.toString()); report.setActionExitCode(ActionReport.ExitCode.FAILURE); } else { String m2 = Strings.get("update.node.ssh.continue.force"); msg.append(StringUtils.cat(NL, m1, e.getMessage(), m2));
private RemoteType parseType(ParameterMap map) throws CommandValidationException { try { return RemoteType.valueOf(map.getOne(PARAM_TYPE)); } catch (Exception e) { throw new CommandValidationException(e); } } }
String m1 = Strings.get("ping.node.failure", name, theNode.getNodeHost(), theNode.getType()); msg.append(StringUtils.cat(NL, m1, e.getMessage())); report.setMessage(msg.toString()); report.setActionExitCode(ActionReport.ExitCode.FAILURE);