public String toString() { StringWriter sw = new StringWriter(); sw.append(" o ").append(getKey()).append(" - ").append(getMessage()); if (getCause() != null) { sw.append("\n"); sw.append(" Cause:\n"); getCause().printStackTrace(new PrintWriter(sw)); } return sw.toString(); } }
public void addValidationError( String message ) { ValidationMessage e = new ValidationMessage( String.valueOf( key++ ), message ); addValidationError( e ); }
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); } }
/** * 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()); }
public ValidationMessage getValidationError(String key) { if (validationErrors != null) { for (ValidationMessage vm : validationErrors) { if (vm.getKey().equals(key)) { return vm; } } } return null; }
@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 ); } }
/** * 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() ); }
public ValidationMessage getValidationWarning(String key) { if (validationWarnings != null) { for (ValidationMessage vm : validationWarnings) { if (vm.getKey().equals(key)) { return vm; } } } return null; }
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 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); }
public String toString() { StringWriter sw = new StringWriter(); sw.append( " o " ).append( getKey() ).append( " - " ).append( getMessage() ); if ( getCause() != null ) { sw.append( "\n" ); sw.append( " Cause:\n" ); getCause().printStackTrace( new PrintWriter( sw ) ); } return sw.toString(); } }
public ValidationMessage getValidationError( String key ) { if ( validationErrors != null ) { for ( ValidationMessage vm : validationErrors ) { if ( vm.getKey().equals( key ) ) { return vm; } } } return null; }
public void addValidationError(String message, Throwable t) { ValidationMessage e = new ValidationMessage(String.valueOf(key++), message, t); addValidationError(e); }
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 ); }
public ValidationMessage getValidationWarning( String key ) { if ( validationWarnings != null ) { for ( ValidationMessage vm : validationWarnings ) { if ( vm.getKey().equals( key ) ) { return vm; } } } return null; }
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 addValidationError(String message) { ValidationMessage e = new ValidationMessage(String.valueOf(key++), message); addValidationError(e); }
public void addValidationWarning(String message) { ValidationMessage e = new ValidationMessage(String.valueOf(key++), message); addValidationWarning(e); }