public void addValidationError( ValidationMessage message ) { getValidationErrors().add( message ); this.valid = false; }
public void addValidationError(ValidationMessage message) { getValidationErrors().add(message); this.valid = false; }
@Override public String getMessage() { StringWriter sw = new StringWriter(); sw.append(super.getMessage()); if (getValidationResponse() != null) { if (getValidationResponse().getValidationErrors().size() > 0) { sw.append("\nValidation errors follows:\n"); for (ValidationMessage error : getValidationResponse().getValidationErrors()) { sw.append(error.toString()); } sw.append("\n"); } if (getValidationResponse().getValidationWarnings().size() > 0) { sw.append("\nValidation warnings follows:\n"); for (ValidationMessage warning : getValidationResponse().getValidationWarnings()) { sw.append(warning.toString()); } sw.append("\n"); } } return sw.toString(); }
protected void handleValidationResponse(ValidationResponse validationResponse) throws PlexusResourceException { ErrorResponse nexusErrorResponse = new ErrorResponse(); if (validationResponse != null && validationResponse.getValidationErrors().size() > 0) { for (ValidationMessage vm : validationResponse.getValidationErrors()) { nexusErrorResponse.addError(createNexusError(vm.getKey(), vm.getShortMessage())); } throw new PlexusResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "Configuration error.", nexusErrorResponse); } }
@Override public void updateUserAndGroupConfiguration(CUserAndGroupAuthConfiguration userAndGroupConfig) throws InvalidConfigurationException { lock.lock(); try { final ValidationResponse vr = validator.validateUserAndGroupAuthConfiguration(null, userAndGroupConfig); if (vr.getValidationErrors().size() > 0) { throw new InvalidConfigurationException(vr); } getConfiguration().setUserAndGroupConfig(userAndGroupConfig); } finally { lock.unlock(); } }
protected void handleValidationResponse( ValidationResponse validationResponse ) throws PlexusResourceException { ErrorResponse nexusErrorResponse = new ErrorResponse(); if ( validationResponse != null && validationResponse.getValidationErrors().size() > 0 ) { for ( ValidationMessage vm : validationResponse.getValidationErrors() ) { nexusErrorResponse.addError( createNexusError( vm.getKey(), vm.getShortMessage() ) ); } throw new PlexusResourceException( Status.CLIENT_ERROR_BAD_REQUEST, "Configuration error.", nexusErrorResponse ); } }
@Override public void updateConnectionInfo(CConnectionInfo connectionInfo) throws InvalidConfigurationException { lock.lock(); try { final ValidationResponse vr = validator.validateConnectionInfo(null, connectionInfo); if (vr.getValidationErrors().size() > 0) { throw new InvalidConfigurationException(vr); } getConfiguration().setConnectionInfo(connectionInfo); } finally { lock.unlock(); } }
public void updateUserAndGroupConfiguration( CUserAndGroupAuthConfiguration userAndGroupConfig ) throws InvalidConfigurationException { lock.lock(); try { ValidationResponse vr = validator.validateUserAndGroupAuthConfiguration( null, userAndGroupConfig ); if ( vr.getValidationErrors().size() > 0 ) { throw new InvalidConfigurationException( vr ); } getConfiguration().setUserAndGroupConfig( userAndGroupConfig ); } finally { lock.unlock(); } }
public void updateConnectionInfo( CConnectionInfo connectionInfo ) throws InvalidConfigurationException { lock.lock(); try { ValidationResponse vr = validator.validateConnectionInfo( null, connectionInfo ); if ( vr.getValidationErrors().size() > 0 ) { throw new InvalidConfigurationException( vr ); } getConfiguration().setConnectionInfo( connectionInfo ); } finally { lock.unlock(); } }
public String getMessage() { StringWriter sw = new StringWriter(); sw.append( super.getMessage() ); if ( getValidationResponse() != null ) { if ( getValidationResponse().getValidationErrors().size() > 0 ) { sw.append( "\nValidation errors follows:\n" ); for ( ValidationMessage error : getValidationResponse().getValidationErrors() ) { sw.append( error.toString() ); } sw.append( "\n" ); } if ( getValidationResponse().getValidationWarnings().size() > 0 ) { sw.append( "\nValidation warnings follows:\n" ); for ( ValidationMessage warning : getValidationResponse().getValidationWarnings() ) { sw.append( warning.toString() ); } sw.append( "\n" ); } } return sw.toString(); }
protected ValidationResponse mergeValidationResponse(ValidationResponse source, ValidationResponse dest) { for (ValidationMessage message : source.getValidationErrors()) { dest.addValidationError(message); } for (ValidationMessage message : source.getValidationWarnings()) { dest.addValidationError(message); } return dest; } }
protected ValidationResponse mergeValidationResponse(ValidationResponse source, ValidationResponse dest) { for ( ValidationMessage message : source.getValidationErrors() ) { dest.addValidationError( message ); } for ( ValidationMessage message : source.getValidationWarnings() ) { dest.addValidationError( message ); } return dest; } }
protected void handleConfigurationException(InvalidConfigurationException e) throws PlexusResourceException { getLogger().debug("Configuration error!", e); ErrorResponse nexusErrorResponse = new ErrorResponse(); ValidationResponse vr = ((InvalidConfigurationException) e).getValidationResponse(); if (vr != null && vr.getValidationErrors().size() > 0) { for (ValidationMessage vm : vr.getValidationErrors()) { nexusErrorResponse.addError(createNexusError(vm.getKey(), vm.getShortMessage())); } } else { nexusErrorResponse.addError(createNexusError("*", e.getMessage())); } throw new PlexusResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "Configuration error.", nexusErrorResponse); }
protected void handleConfigurationException( InvalidConfigurationException e ) throws PlexusResourceException { getLogger().warn( "Configuration error!", e ); ErrorResponse nexusErrorResponse = new ErrorResponse(); ValidationResponse vr = ( (InvalidConfigurationException) e ).getValidationResponse(); if ( vr != null && vr.getValidationErrors().size() > 0 ) { for ( ValidationMessage vm : vr.getValidationErrors() ) { nexusErrorResponse.addError( createNexusError( vm.getKey(), vm.getShortMessage() ) ); } } else { nexusErrorResponse.addError( createNexusError( "*", e.getMessage() ) ); } throw new PlexusResourceException( Status.CLIENT_ERROR_BAD_REQUEST, "Configuration error.", nexusErrorResponse ); }
if ( vr.getValidationErrors().size() > 0 )
if (vr.getValidationErrors().size() > 0) { log.warn("Invalid LDAP configuration, defaulting configuration", new InvalidConfigurationException(vr)); configuration = getDefaultConfiguration();
/** * A method to append a validation response to this validation response. The errors list and warnings list are * simply appended, and the isValid is logically AND-ed and isModified is logically OR-ed. */ public void append(ValidationResponse response) { for (ValidationMessage msg : response.getValidationErrors()) { if (getValidationError(msg.getKey()) != null) { msg.setKey(msg.getKey() + "(" + key++ + ")"); } addValidationError(msg); } for (ValidationMessage msg : response.getValidationWarnings()) { if (getValidationWarning(msg.getKey()) != null) { msg.setKey(msg.getKey() + "(" + key++ + ")"); } addValidationWarning(msg); } setValid(isValid() && response.isValid()); setModified(isModified() || response.isModified()); }
/** * A method to append a validation response to this validation response. The errors list and warnings list are * simply appended, and the isValid is logically AND-ed and isModified is logically OR-ed. * * @param response */ public void append( ValidationResponse response ) { for ( ValidationMessage msg : response.getValidationErrors() ) { if ( getValidationError( msg.getKey() ) != null ) { msg.setKey( msg.getKey() + "(" + key++ + ")" ); } addValidationError( msg ); } for ( ValidationMessage msg : response.getValidationWarnings() ) { if ( getValidationWarning( msg.getKey() ) != null ) { msg.setKey( msg.getKey() + "(" + key++ + ")" ); } addValidationWarning( msg ); } setValid( isValid() && response.isValid() ); setModified( isModified() || response.isModified() ); }