public void addValidationError( String message ) { ValidationMessage e = new ValidationMessage( String.valueOf( key++ ), message ); addValidationError( e ); }
public void addValidationError( String message, Throwable t ) { ValidationMessage e = new ValidationMessage( String.valueOf( key++ ), message, t ); addValidationError( e ); }
public void addValidationWarning( String message ) { ValidationMessage e = new ValidationMessage( String.valueOf( key++ ), message ); addValidationWarning( e ); }
public void validateTime(String key, Date date) throws InvalidConfigurationException { if (date.before(new Date())) { ValidationResponse vr = new ApplicationValidationResponse(); ValidationMessage vm = new ValidationMessage(key, "Time cannot be in the past."); vr.addValidationError(vm); throw new InvalidConfigurationException(vr); } }
public void validateTime( String key, Date date ) throws InvalidConfigurationException { if ( date.before( new Date() ) ) { ValidationResponse vr = new ApplicationValidationResponse(); ValidationMessage vm = new ValidationMessage( key, "Time cannot be in the past." ); vr.addValidationError( vm ); throw new InvalidConfigurationException( vr ); } }
public void validateStartDate(String date) throws InvalidConfigurationException { Calendar cal = Calendar.getInstance(); Date startDate = new Date(Long.parseLong(date)); cal.setTime(startDate); Calendar nowCal = Calendar.getInstance(); nowCal.add(Calendar.DAY_OF_YEAR, -1); nowCal.set(Calendar.HOUR, 0); nowCal.set(Calendar.MINUTE, 0); nowCal.set(Calendar.SECOND, 0); nowCal.set(Calendar.MILLISECOND, 0); // This is checking just the year/month/day, time isn't of concern right now // basic check that the day timestamp is roughly in the correct range if (cal.before(nowCal)) { if (getLogger().isDebugEnabled()) { getLogger().debug("Validation error for startDate: " + startDate.toString()); } ValidationResponse vr = new ApplicationValidationResponse(); ValidationMessage vm = new ValidationMessage("startDate", "Date cannot be in the past."); vr.addValidationError(vm); throw new InvalidConfigurationException(vr); } }
public void validateStartDate( String date ) throws InvalidConfigurationException { Calendar cal = Calendar.getInstance(); Date startDate = new Date( Long.parseLong( date ) ); cal.setTime( startDate ); Calendar nowCal = Calendar.getInstance(); nowCal.add( Calendar.DAY_OF_YEAR, -1 ); nowCal.set( Calendar.HOUR, 0 ); nowCal.set( Calendar.MINUTE, 0 ); nowCal.set( Calendar.SECOND, 0 ); nowCal.set( Calendar.MILLISECOND, 0 ); // This is checking just the year/month/day, time isn't of concern right now // basic check that the day timestamp is roughly in the correct range if ( cal.before( nowCal ) ) { if ( getLogger().isDebugEnabled() ) { getLogger().debug( "Validation error for startDate: " + startDate.toString() ); } ValidationResponse vr = new ApplicationValidationResponse(); ValidationMessage vm = new ValidationMessage( "startDate", "Date cannot be in the past." ); vr.addValidationError( vm ); throw new InvalidConfigurationException( vr ); } }
public ValidationResponse validateSmtpConfiguration( ApplicationValidationContext ctx, CSmtpConfiguration settings ) { ValidationResponse response = new ApplicationValidationResponse(); if ( ctx != null ) { response.setContext( ctx ); } if ( StringUtils.isEmpty( settings.getHostname() ) ) { ValidationMessage msg = new ValidationMessage( "host", "SMTP Host is empty." ); response.addValidationError( msg ); } if ( settings.getPort() < 0 ) { ValidationMessage msg = new ValidationMessage( "port", "SMTP Port is inavlid. Enter a port greater than 0." ); response.addValidationError( msg ); } if ( StringUtils.isEmpty( settings.getSystemEmailAddress() ) ) { ValidationMessage msg = new ValidationMessage( "systemEmailAddress", "System Email Address is empty." ); response.addValidationError( msg ); } return response; }
ValidationMessage msg = new ValidationMessage("baseUrl", "Base Url cannot be empty."); response.addValidationError(msg); ValidationMessage msg = new ValidationMessage("baseUrl", "Base Url is not valid: " + e.getMessage()); response.addValidationError(msg); ValidationMessage msg = new ValidationMessage("emailDomain", "Email domain cannot be empty."); response.addValidationError(msg); ValidationMessage msg = new ValidationMessage("defaultRole", "Default role cannot be empty."); response.addValidationError(msg); ValidationMessage msg = new ValidationMessage("defaultRole", "Failed to find role."); response.addValidationError(msg);
public ValidationResponse validateErrorReporting( ApplicationValidationContext ctx, CErrorReporting settings ) { ValidationResponse response = new ApplicationValidationResponse(); if ( ctx != null ) { response.setContext( ctx ); } if ( settings.isEnabled() ) { if ( StringUtils.isEmpty( settings.getJiraUrl() ) ) { ValidationMessage msg = new ValidationMessage( "jiraUrl", "JIRA URL is empty." ); response.addValidationError( msg ); } if ( StringUtils.isEmpty( settings.getJiraProject() ) ) { ValidationMessage msg = new ValidationMessage( "jiraProject", "JIRA Project is empty." ); response.addValidationError( msg ); } } return response; }
ValidationMessage msg = new ValidationMessage( "url", "Url cannot be empty." ); response.addValidationError( msg ); ValidationMessage msg = new ValidationMessage( "url", "Url is not valid: " + e.getMessage() ); response.addValidationError( msg ); ValidationMessage msg = new ValidationMessage( "emailDomain", "Email domain cannot be empty." ); response.addValidationError( msg ); ValidationMessage msg = new ValidationMessage( "defaultRole", "Default role cannot be empty." ); response.addValidationError( msg ); ValidationMessage msg = new ValidationMessage( "defaultRole", "Failed to find role." ); response.addValidationError( msg );
protected void checkUsersStatus(String status) throws InvalidConfigurationException { boolean found = false; for (UserStatus userStatus : UserStatus.values()) { if (userStatus.name().equals(status)) { found = true; } } if (!found) { ValidationResponse response = new ValidationResponse(); response.addValidationError(new ValidationMessage("status", "Users status is not valid.")); throw new InvalidConfigurationException(response); } }
protected void checkUsersStatus( String status ) throws InvalidConfigurationException { boolean found = false; for ( UserStatus userStatus : UserStatus.values() ) { if ( userStatus.name().equals( status ) ) { found = true; } } if ( !found ) { ValidationResponse response = new ValidationResponse(); response.addValidationError( new ValidationMessage( "status", "Users status is not valid." ) ); throw new InvalidConfigurationException( response ); } }
response.addValidationError( new ValidationMessage( "id", "Repository ID's may not be empty!" ) ); new ValidationMessage( "id", "Only letters, digits, underscores(_), hyphens(-), and dots(.) are allowed in Repository ID" ) ); response.addValidationWarning( new ValidationMessage( "id", "Repository with ID='" + repo.getId() + "' has no name, defaulted to it's ID." ) ); new ValidationMessage( "id", "LocalStatus of repository with ID='" + repo.getId() ) + "' is wrong " + repo.getLocalStatus() + "! (Allowed values are: '" + LocalStatus.IN_SERVICE + "' and '" + LocalStatus.OUT_OF_SERVICE + "')" ); response.addValidationError( new ValidationMessage( "id", "Repository with ID=" + repo.getId() + " already exists!" ) ); response.addValidationError( new ValidationMessage( "id", "Repository " + repo.getId() + " conflicts with existing Shadow with same ID='" + repo.getId() + "'!" ) ); response.addValidationError( new ValidationMessage( "id", "Repository " + repo.getId() + " conflicts with existing Group with same ID='" + repo.getId() + "'!" ) );
response.addValidationError( new ValidationMessage( "id", "Repository ID must not be blank!" ) ); .addValidationError( new ValidationMessage( "id", "Only letters, digits, underscores, hyphens, and dots are allowed in Repository ID" ) ); response.addValidationError( new ValidationMessage( "id", "Repository ID can't be 'all', reserved word" ) ); response.addValidationWarning( new ValidationMessage( "id", "Repository with ID='" + cfg.getId() + "' has no name, defaulted it's name to it's ID." ) ); response.addValidationError( new ValidationMessage( "localStatus", "LocalStatus of repository with ID=\"" + cfg.getId() + "\" has unacceptable value \"" + cfg.getLocalStatus() + "\"! (Allowed values are: \"" + LocalStatus.IN_SERVICE + "\" and \"" + LocalStatus.OUT_OF_SERVICE + "\")", e ) ); response.addValidationWarning( new ValidationMessage( "indexable", "Indexing isn't supported for \"" + cfg.getProviderHint() + "\" repositories, only Maven2 repositories are indexable!" ) );
new ValidationMessage( "overrideLocalStorageUrl", "Repository has an invalid local storage URL '" + localUrl, "Invalid file location" );
new ValidationMessage( "shadowOf", e.getMessage(), "The source nexus repository is of an invalid Format." ); new ValidationMessage( "shadowOf", e.getMessage(), "The source nexus repository is not existing." );
public void createUserRoleMapping( CUserRoleMapping userRoleMapping, SecurityValidationContext context ) throws InvalidConfigurationException { if ( context == null ) { context = this.initializeContext(); } try { // this will throw a NoSuchRoleMappingException, if there isn't one readUserRoleMapping( userRoleMapping.getUserId(), userRoleMapping.getSource() ); ValidationResponse vr = new ValidationResponse(); vr.addValidationError( new ValidationMessage( "*", "User Role Mapping for user '" + userRoleMapping.getUserId() + "' already exists." ) ); throw new InvalidConfigurationException( vr ); } catch ( NoSuchRoleMappingException e ) { // expected } ValidationResponse vr = validator.validateUserRoleMapping( context, userRoleMapping, false ); if ( vr.getValidationErrors().size() > 0 ) { throw new InvalidConfigurationException( vr ); } getConfiguration().addUserRoleMapping( userRoleMapping ); logValidationWarnings( vr ); }
public void updateUserRoleMapping( CUserRoleMapping userRoleMapping, SecurityValidationContext context ) throws InvalidConfigurationException, NoSuchRoleMappingException { if ( context == null ) { context = initializeContext(); } if ( readUserRoleMapping( userRoleMapping.getUserId(), userRoleMapping.getSource() ) == null ) { ValidationResponse vr = new ValidationResponse(); vr.addValidationError( new ValidationMessage( "*", "No User Role Mapping found for user '" + userRoleMapping.getUserId() + "'." ) ); throw new InvalidConfigurationException( vr ); } ValidationResponse vr = validator.validateUserRoleMapping( context, userRoleMapping, true ); if ( vr.getValidationErrors().size() > 0 ) { throw new InvalidConfigurationException( vr ); } deleteUserRoleMapping( userRoleMapping.getUserId(), userRoleMapping.getSource() ); getConfiguration().addUserRoleMapping( userRoleMapping ); }
ValidationMessage error = new ValidationMessage( "remoteStorageUrl", e.getMessage(), e.getMessage() );