public ValidationMessage getValidationError(String key) { if (validationErrors != null) { for (ValidationMessage vm : validationErrors) { if (vm.getKey().equals(key)) { return vm; } } } return null; }
public ValidationMessage getValidationWarning(String key) { if (validationWarnings != null) { for (ValidationMessage vm : validationWarnings) { if (vm.getKey().equals(key)) { return vm; } } } return null; }
public ValidationMessage getValidationError( String key ) { if ( validationErrors != null ) { for ( ValidationMessage vm : validationErrors ) { if ( vm.getKey().equals( key ) ) { return vm; } } } return null; }
public ValidationMessage getValidationWarning( String key ) { if ( validationWarnings != null ) { for ( ValidationMessage vm : validationWarnings ) { if ( vm.getKey().equals( key ) ) { return vm; } } } return null; }
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 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(); } }
/** * 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()); }
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() ); }
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 ); } }
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 ); }