List of usage examples for com.jgoodies.validation.util ValidationUtils isNumeric
public static boolean isNumeric(String str)
From source file:gov.nih.nci.cacore.workbench.portal.panel.AppServerSettingsPanel.java
License:BSD License
public ValidationResult validateInput() { ValidationResult result = new ValidationResult(); // Turns out that the External Server HTTP URL is not a required field // if (ValidationUtils.isBlank(getExternalServerHttpUrlField().getText())) { // result.add(new SimpleValidationMessage(SERVER_HTTP_URL + " must not be blank.", Severity.ERROR, SERVER_HTTP_URL)); // } // w w w .j a v a2 s.c o m String serverType = getServerType(); if (ValidationUtils.isBlank(serverType)) { result.add( new SimpleValidationMessage(SERVER_TYPE + " must not be blank.", Severity.ERROR, SERVER_TYPE)); } //Tomcat Server Components if (serverType.equalsIgnoreCase(TOMCAT)) { if (ValidationUtils.isBlank(this.getTomcatHostnameField().getText())) { result.add(new SimpleValidationMessage(TOMCAT_HOSTNAME + " must not be blank.", Severity.ERROR, TOMCAT_HOSTNAME)); } String tomcatAjpPort = this.getTomcatPortAjpField().getText(); if (ValidationUtils.isBlank(tomcatAjpPort)) { result.add(new SimpleValidationMessage(TOMCAT_PORT_AJP + " must not be blank.", Severity.ERROR, TOMCAT_PORT_AJP)); } if (!ValidationUtils.isNumeric(tomcatAjpPort)) { result.add(new SimpleValidationMessage(TOMCAT_PORT_AJP + " must be numeric.", Severity.ERROR, TOMCAT_PORT_AJP)); } String tomcatHttpPort = this.getTomcatPortHttpField().getText(); if (ValidationUtils.isBlank(tomcatHttpPort)) { result.add(new SimpleValidationMessage(TOMCAT_PORT_HTTP + " must not be blank.", Severity.ERROR, TOMCAT_PORT_HTTP)); } if (!ValidationUtils.isNumeric(tomcatHttpPort)) { result.add(new SimpleValidationMessage(TOMCAT_PORT_HTTP + " must be numeric.", Severity.ERROR, TOMCAT_PORT_HTTP)); } String tomcatShutdownPort = this.getTomcatPortShutdownField().getText(); if (ValidationUtils.isBlank(tomcatShutdownPort)) { result.add(new SimpleValidationMessage(TOMCAT_PORT_SHUTDOWN + " must not be blank.", Severity.ERROR, TOMCAT_PORT_SHUTDOWN)); } if (!ValidationUtils.isNumeric(tomcatShutdownPort)) { result.add(new SimpleValidationMessage(TOMCAT_PORT_SHUTDOWN + " must be numeric.", Severity.ERROR, TOMCAT_PORT_SHUTDOWN)); } String tomcatSslPort = this.getTomcatPortSslField().getText(); if (ValidationUtils.isBlank(tomcatSslPort)) { result.add(new SimpleValidationMessage(TOMCAT_PORT_SSL + " must not be blank.", Severity.ERROR, TOMCAT_PORT_SSL)); } if (!ValidationUtils.isNumeric(tomcatSslPort)) { result.add(new SimpleValidationMessage(TOMCAT_PORT_SSL + " must be numeric.", Severity.ERROR, TOMCAT_PORT_SSL)); } } else if (serverType.equalsIgnoreCase(JBOSS)) { if (ValidationUtils.isBlank(this.getJbossPortNameComboBox().getSelectedItem().toString())) { result.add(new SimpleValidationMessage(JBOSS_PORT_NAME + " must not be blank.", Severity.ERROR, JBOSS_PORT_NAME)); } if (ValidationUtils.isBlank(this.getJbossServerHostnameField().getText())) { result.add(new SimpleValidationMessage(JBOSS_SERVER_HOSTNAME + " must not be blank.", Severity.ERROR, JBOSS_SERVER_HOSTNAME)); } String JbossAjpPort = this.getJbossServerAjpPortField().getText(); if (ValidationUtils.isBlank(JbossAjpPort)) { result.add(new SimpleValidationMessage(JBOSS_SERVER_AJP_PORT + " must not be blank.", Severity.ERROR, JBOSS_SERVER_AJP_PORT)); } if (!ValidationUtils.isNumeric(JbossAjpPort)) { result.add(new SimpleValidationMessage(JBOSS_SERVER_AJP_PORT + " must be numeric.", Severity.ERROR, JBOSS_SERVER_AJP_PORT)); } String jbossJndiPort = this.getJbossServerJndiPortField().getText(); if (ValidationUtils.isBlank(jbossJndiPort)) { result.add(new SimpleValidationMessage(JBOSS_SERVER_JNDI_PORT + " must not be blank.", Severity.ERROR, JBOSS_SERVER_JNDI_PORT)); } if (!ValidationUtils.isNumeric(jbossJndiPort)) { result.add(new SimpleValidationMessage(JBOSS_SERVER_JNDI_PORT + " must be numeric.", Severity.ERROR, JBOSS_SERVER_JNDI_PORT)); } String jbossPort = this.getJbossServerPortField().getText(); if (ValidationUtils.isBlank(jbossPort)) { result.add(new SimpleValidationMessage(JBOSS_SERVER_PORT + " must not be blank.", Severity.ERROR, JBOSS_SERVER_PORT)); } if (!ValidationUtils.isNumeric(jbossPort)) { result.add(new SimpleValidationMessage(JBOSS_SERVER_PORT + " must be numeric.", Severity.ERROR, JBOSS_SERVER_PORT)); } String jbossSslPort = this.getJbossServerSslPortField().getText(); if (ValidationUtils.isBlank(jbossSslPort)) { result.add(new SimpleValidationMessage(JBOSS_SERVER_SSL_PORT + " must not be blank.", Severity.ERROR, JBOSS_SERVER_SSL_PORT)); } if (!ValidationUtils.isNumeric(jbossSslPort)) { result.add(new SimpleValidationMessage(JBOSS_SERVER_SSL_PORT + " must be numeric.", Severity.ERROR, JBOSS_SERVER_SSL_PORT)); } } return result; }
From source file:gov.nih.nci.cacore.workbench.portal.panel.ClmSettingsPanel.java
License:BSD License
public ValidationResult validateInput() { ValidationResult result = new ValidationResult(); //CLM Settings Validation if (parentContainer.isClmEnabled()) { String clmDbConnectionUrlField = this.getClmDbConnectionUrlField().getText(); if (ValidationUtils.isBlank(clmDbConnectionUrlField)) { result.add(new SimpleValidationMessage(CLM_DB_CONNECTION_URL + " must not be blank.", Severity.ERROR, CLM_DB_CONNECTION_URL)); }/* w w w .j a va2 s. co m*/ if (ValidationUtils.isBlank(getClmDbHostnameField().getText())) { result.add(new SimpleValidationMessage(CLM_DB_SERVER + " must not be blank.", Severity.ERROR, CLM_DB_SERVER)); } String clmDbPort = getClmDbPortField().getText(); if (ValidationUtils.isBlank(clmDbPort)) { result.add(new SimpleValidationMessage(CLM_DB_SERVER_PORT + " must not be blank.", Severity.ERROR, CLM_DB_SERVER_PORT)); } if (!ValidationUtils.isNumeric(clmDbPort)) { result.add(new SimpleValidationMessage(CLM_DB_SERVER_PORT + " must be numeric.", Severity.ERROR, CLM_DB_SERVER_PORT)); } if (ValidationUtils.isBlank(getClmDbSchemaField().getText())) { result.add(new SimpleValidationMessage(CLM_DB_NAME + " must not be blank.", Severity.ERROR, CLM_DB_NAME)); } if (ValidationUtils.isBlank(this.getClmDbUsernameField().getText())) { result.add(new SimpleValidationMessage(CLM_DB_USERNAME + " must not be blank.", Severity.ERROR, CLM_DB_USERNAME)); } if (ValidationUtils.isBlank(this.getClmDbPasswordField().getText())) { result.add(new SimpleValidationMessage(CLM_DB_PASSWORD + " must not be blank.", Severity.ERROR, CLM_DB_PASSWORD)); } if (getClmDbDropSchemaCheckBox().isSelected() && !parentContainer.isAppDbAndClmSchemaSame()) { if (ValidationUtils.isBlank(this.getClmDbSqlFileField().getText())) { result.add(new SimpleValidationMessage( CLM_DB_SQL_FILE + " must not be blank when " + CLM_DB_DROP_SCHEMA + " is selected.", Severity.ERROR, CLM_DB_SQL_FILE)); } } if (getClmDbDropSchemaCheckBox().isSelected() && !parentContainer.isCsmDbAndClmSchemaSame()) { if (ValidationUtils.isBlank(this.getClmDbSqlFileField().getText())) { result.add(new SimpleValidationMessage( CLM_DB_SQL_FILE + " must not be blank when " + CLM_DB_DROP_SCHEMA + " is selected.", Severity.ERROR, CLM_DB_SQL_FILE)); } } String clmDbSchema = getClmDbSchemaField().getText(); if (ValidationUtils.isNotBlank(clmDbSchema) && parentContainer.isAppDbAndClmSchemaSame() && parentContainer.isAppDbDropSchemaSelected()) { //TODO :: investigate if there is a way to visually signal that a CheckBox has a validation error. // Currently, creating a validation error for the CheckBox has no effect. As a result, // using toggleReCreateClmDBFields() instead to enforce rule // if (getClmDbDropSchemaCheckBox().isSelected()){ // log.debug("* * * Validation error: App DB and CLM Schema are the same, and CLM Drop Schema CheckBox is selected."); // result.add(new SimpleValidationMessage(CLM_DB_DROP_SCHEMA + " must not selected when both the App DB and CLM schema are the same.", Severity.ERROR, CLM_DB_DROP_SCHEMA)); // } if (ValidationUtils.isBlank(this.getClmDbSqlFileField().getText())) { result.add(new SimpleValidationMessage(CLM_DB_SQL_FILE + " must not be blank when the application DB is being dropped, and both the App DB and CLM DB schema are the same.", Severity.ERROR, CLM_DB_SQL_FILE)); } } if (ValidationUtils.isNotBlank(clmDbSchema) && parentContainer.isCsmDbAndClmSchemaSame() && parentContainer.isCsmDbDropSchemaSelected()) { //TODO :: investigate if there is a way to visually signal that a CheckBox has a validation error. // Currently, creating a validation error for the CheckBox has no effect. As a result, // using toggleReCreateClmDBFields() instead to enforce rule // if (getClmDbDropSchemaCheckBox().isSelected()){ // log.debug("* * * Validation error: App DB and CLM Schema are the same, and CLM Drop Schema CheckBox is selected."); // result.add(new SimpleValidationMessage(CLM_DB_DROP_SCHEMA + " must not selected when both the App DB and CLM schema are the same.", Severity.ERROR, CLM_DB_DROP_SCHEMA)); // } if (ValidationUtils.isBlank(this.getClmDbSqlFileField().getText())) { result.add(new SimpleValidationMessage(CLM_DB_SQL_FILE + " must not be blank when the CSM DB is being dropped, and both the CSM DB and CLM DB schema are the same.", Severity.ERROR, CLM_DB_SQL_FILE)); } } if (ValidationUtils.isNotBlank(this.getClmDbSqlFileField().getText())) { File file = new File(this.getClmDbSqlFileField().getText()); if (!file.exists()) { result.add(new SimpleValidationMessage( CLM_DB_SQL_FILE + " does not exist. Please select or enter a valid absolute path to the file.", Severity.ERROR, CLM_DB_SQL_FILE)); } if (!this.getClmDbSqlFileField().getText().endsWith("sql")) { result.add(new SimpleValidationMessage(CLM_DB_SQL_FILE + " must refer to a SQL (*.sql) file.", Severity.ERROR, CLM_DB_SQL_FILE)); } } } return result; }
From source file:gov.nih.nci.cacore.workbench.portal.panel.CsmDbConnectionSettingsPanel.java
License:BSD License
public ValidationResult validateDbConnectionInput() { ValidationResult result = new ValidationResult(); if (isEnableSecuritySelected && !getCsmUseDbConnectionSettingsCheckBox().isSelected()) { if (ValidationUtils.isBlank(getCsmDbHostnameField().getText())) { result.add(new SimpleValidationMessage(CSM_DB_SERVER + " must not be blank.", Severity.ERROR, CSM_DB_SERVER));/* w w w . java 2s . com*/ } String csmDbPort = getCsmDbPortField().getText(); if (ValidationUtils.isBlank(csmDbPort)) { result.add(new SimpleValidationMessage(CSM_DB_SERVER_PORT + " must not be blank.", Severity.ERROR, CSM_DB_SERVER_PORT)); } if (!ValidationUtils.isNumeric(csmDbPort)) { result.add(new SimpleValidationMessage(CSM_DB_SERVER_PORT + " must be numeric.", Severity.ERROR, CSM_DB_SERVER_PORT)); } if (ValidationUtils.isBlank(getCsmDbSchemaField().getText())) { result.add(new SimpleValidationMessage(CSM_DB_NAME + " must not be blank.", Severity.ERROR, CSM_DB_NAME)); } if (ValidationUtils.isBlank(this.getCsmDbUsernameField().getText())) { result.add(new SimpleValidationMessage(CSM_DB_USERNAME + " must not be blank.", Severity.ERROR, CSM_DB_USERNAME)); } if (ValidationUtils.isBlank(this.getCsmDbPasswordField().getText())) { result.add(new SimpleValidationMessage(CSM_DB_PASSWORD + " must not be blank.", Severity.ERROR, CSM_DB_PASSWORD)); } } return result; }
From source file:gov.nih.nci.cacore.workbench.portal.panel.DbConnectionSettingsPanel.java
License:BSD License
public ValidationResult validateDbConnectionInput() { ValidationResult result = new ValidationResult(); //DB Connection Settings Validation if (ValidationUtils.isBlank(getDbHostnameField().getText())) { result.add(new SimpleValidationMessage(DB_SERVER + " must not be blank.", Severity.ERROR, DB_SERVER)); }/*w ww . j a v a 2s . c o m*/ String dbPort = getDbPortField().getText(); if (ValidationUtils.isBlank(dbPort)) { result.add(new SimpleValidationMessage(DB_SERVER_PORT + " must not be blank.", Severity.ERROR, DB_SERVER_PORT)); } if (!ValidationUtils.isNumeric(dbPort)) { result.add(new SimpleValidationMessage(DB_SERVER_PORT + " must be numeric.", Severity.ERROR, DB_SERVER_PORT)); } if (ValidationUtils.isBlank(getDbSchemaField().getText())) { result.add(new SimpleValidationMessage(DB_NAME + " must not be blank.", Severity.ERROR, DB_NAME)); } if (ValidationUtils.isBlank(this.getDbUsernameField().getText())) { result.add( new SimpleValidationMessage(DB_USERNAME + " must not be blank.", Severity.ERROR, DB_USERNAME)); } if (ValidationUtils.isBlank(this.getDbPasswordField().getText())) { result.add( new SimpleValidationMessage(DB_PASSWORD + " must not be blank.", Severity.ERROR, DB_PASSWORD)); } return result; }
From source file:gov.nih.nci.cacore.workbench.portal.panel.RemoteSshSettingsPanel.java
License:BSD License
public ValidationResult validateInput() { ValidationResult result = new ValidationResult(); if (parentContainer.isRemoteDeployment()) { if (ValidationUtils.isBlank(this.getSshServerUsernameField().getText())) { result.add(new SimpleValidationMessage(SSH_SERVER_USERNAME + " must not be blank.", Severity.ERROR, SSH_SERVER_USERNAME)); }/*from w ww . ja va2s .c o m*/ if (ValidationUtils.isBlank(this.getSshServerHostnameField().getText())) { result.add(new SimpleValidationMessage(SSH_SERVER_HOSTNAME + " must not be blank.", Severity.ERROR, SSH_SERVER_HOSTNAME)); } String sshPort = getSshPortField().getText(); if (ValidationUtils.isBlank(this.getSshPortField().getText())) { result.add(new SimpleValidationMessage(SSH_PORT + " must not be blank.", Severity.ERROR, SSH_PORT)); } if (!ValidationUtils.isNumeric(sshPort)) { result.add(new SimpleValidationMessage(SSH_PORT + " must be numeric.", Severity.ERROR, SSH_PORT)); } if (ValidationUtils.isBlank(this.getSshKeyFileField().getText())) { result.add(new SimpleValidationMessage(SSH_KEY_FILE + " must not be blank.", Severity.ERROR, SSH_KEY_FILE)); } else { File file = new File(this.getSshKeyFileField().getText()); if (!file.exists()) { result.add(new SimpleValidationMessage( SSH_KEY_FILE + " does not exist. Please select or enter a valid absolute path to the file.", Severity.ERROR, SSH_KEY_FILE)); } } if (ValidationUtils.isBlank(this.getSshTempDirField().getText())) { result.add(new SimpleValidationMessage(SSH_TEMP_DIR + " must not be blank.", Severity.ERROR, SSH_TEMP_DIR)); } else { // Cannot validate if it is a valid directory as it is remote. // File file = new File(this.getSshTempDirField().getText()); // if(!file.exists()){ // result.add(new SimpleValidationMessage(SSH_TEMP_DIR + " does not exist. Please select or enter a valid absolute path to the directory.", Severity.ERROR, SSH_TEMP_DIR)); // } } } return result; }