List of usage examples for com.fasterxml.jackson.databind.exc UnrecognizedPropertyException getMessage
public String getMessage()
From source file:io.gravitee.management.rest.provider.UnrecognizedPropertyExceptionMapper.java
@Override public Response toResponse(UnrecognizedPropertyException e) { return Response.status(Response.Status.BAD_REQUEST).type(MediaType.APPLICATION_JSON_TYPE) .entity(e.getMessage()).build(); }
From source file:com.netflix.spinnaker.halyard.config.errors.v1.config.ParseConfigException.java
public ParseConfigException(UnrecognizedPropertyException e) { Problem problem = new ProblemBuilder(Problem.Severity.FATAL, "Unrecognized property in your halconfig: " + e.getMessage()).build(); getProblems().add(problem);//w w w. j a v a2 s.c o m }
From source file:com.netflix.spinnaker.halyard.config.error.v1.ParseConfigException.java
public ParseConfigException(UnrecognizedPropertyException e) { Problem problem = new ConfigProblemBuilder(Problem.Severity.FATAL, "Unrecognized property in your halconfig: " + e.getMessage()).build(); getProblems().add(problem);/*from w w w . j ava 2s.c o m*/ }
From source file:org.osiam.resources.exception.OsiamExceptionHandler.java
@ExceptionHandler(UnrecognizedPropertyException.class) @ResponseStatus(HttpStatus.CONFLICT)// w w w.j a v a2 s .c o m @ResponseBody public ErrorResponse handleUnrecognizedProperty(UnrecognizedPropertyException e) { LOGGER.error("Unknown property", e); return produceErrorResponse(e.getMessage(), HttpStatus.CONFLICT, new JsonPropertyMessageTransformer()); }
From source file:com.networknt.client.oauth.OauthHelper.java
private static Result<TokenResponse> handleResponse(ContentType contentType, String responseBody) { TokenResponse tokenResponse;//from w ww .j a v a 2 s .c om Result<TokenResponse> result; try { //only accept json format response so that can map to a TokenResponse, otherwise escapes server's response and return to the client. if (!contentType.equals(ContentType.APPLICATION_JSON)) { return Failure.of(new Status(GET_TOKEN_ERROR, escapeBasedOnType(contentType, responseBody))); } if (responseBody != null && responseBody.length() > 0) { tokenResponse = Config.getInstance().getMapper().readValue(responseBody, TokenResponse.class); if (tokenResponse != null) { result = Success.of(tokenResponse); } else { result = Failure.of(new Status(GET_TOKEN_ERROR, responseBody)); } } else { result = Failure.of(new Status(GET_TOKEN_ERROR, "no auth server response")); logger.error("Error in token retrieval, response = " + responseBody); } } catch (UnrecognizedPropertyException e) { //in this case, cannot parse success token, which means the server doesn't response a successful token but some messages, we need to pass this message out. result = Failure.of(new Status(GET_TOKEN_ERROR, escapeBasedOnType(contentType, responseBody))); } catch (IOException | RuntimeException e) { result = Failure.of(new Status(GET_TOKEN_ERROR, e.getMessage())); logger.error("Error in token retrieval", e); } return result; }
From source file:org.jaqpot.core.service.filter.excmappers.UnrecognizedPropertyMapper.java
@Override public Response toResponse(UnrecognizedPropertyException exception) { LOG.log(Level.INFO, "UnrecognizedPropertyMapper exception caught", exception); StringWriter sw = new StringWriter(); exception.printStackTrace(new PrintWriter(sw)); String details = sw.toString(); ErrorReport error = ErrorReportBuilder.builderRandomId().setCode("UnrecognisedProperty") .setMessage(exception.getMessage()).setDetails(details).setHttpStatus(400).build(); return Response.ok(error, MediaType.APPLICATION_JSON).status(Response.Status.BAD_REQUEST).build(); }
From source file:com.cloudera.cli.validator.components.DescriptorRunner.java
/** * Run the validation against a byte array. * * @param name The name of the target that was loaded into the byte array. * @param data The byte array/*w w w .ja v a 2s.com*/ * @param writer to write validation errors to * @return true if validation passed, false otherwise * @throws IOException if we can't write to the outputStream */ public boolean run(String name, byte[] data, Writer writer) throws IOException { try { writer.write("Validating: " + name + "\n"); T descriptor = parser.parse(data); Set<String> errors = validator.validate(descriptor); for (String error : errors) { writer.write(String.format("==> %s\n", error)); } return errors.isEmpty(); } catch (UnrecognizedPropertyException e) { List<String> elements = Lists.newArrayList(); for (Reference r : e.getPath()) { elements.add(r.getFieldName()); } writer.write(String.format("==> Unrecognized field \"%s\". Recognized fields are \"%s\"\n", Joiner.on('.').join(elements), e.getKnownPropertyIds().toString())); return false; } catch (Exception e) { writer.write(String.format("==> %s\n", e.getMessage())); return false; } }
From source file:de.thomaskrille.dropwizard.environment_configuration.EnvironmentConfigurationFactory.java
private T build(JsonNode node, String path) throws IOException, ConfigurationException { replaceEnvironmentVariables(node);// w w w . j a v a2s . c o m for (Map.Entry<Object, Object> pref : System.getProperties().entrySet()) { final String prefName = (String) pref.getKey(); if (prefName.startsWith(propertyPrefix)) { final String configName = prefName.substring(propertyPrefix.length()); addOverride(node, configName, System.getProperty(prefName)); } } try { final T config = mapper.readValue(new TreeTraversingParser(node), klass); validate(path, config); return config; } catch (UnrecognizedPropertyException e) { Collection<Object> knownProperties = e.getKnownPropertyIds(); List<String> properties = new ArrayList<>(knownProperties.size()); for (Object property : knownProperties) { properties.add(property.toString()); } throw EnvironmentConfigurationParsingException.builder("Unrecognized field").setFieldPath(e.getPath()) .setLocation(e.getLocation()).addSuggestions(properties).setSuggestionBase(e.getPropertyName()) .setCause(e).build(path); } catch (InvalidFormatException e) { String sourceType = e.getValue().getClass().getSimpleName(); String targetType = e.getTargetType().getSimpleName(); throw EnvironmentConfigurationParsingException.builder("Incorrect type of value") .setDetail("is of type: " + sourceType + ", expected: " + targetType) .setLocation(e.getLocation()).setFieldPath(e.getPath()).setCause(e).build(path); } catch (JsonMappingException e) { throw EnvironmentConfigurationParsingException.builder("Failed to parse configuration") .setDetail(e.getMessage()).setFieldPath(e.getPath()).setLocation(e.getLocation()).setCause(e) .build(path); } }
From source file:org.xlcloud.service.provider.WebApplicationExceptionMapper.java
private VcmsException map(UnrecognizedPropertyException exception) { LOG.debug(exception.getMessage()); return new VcmsException(400, String.format("Bad data format ('%s' property not recognized)", exception.getUnrecognizedPropertyName())); }
From source file:rapture.server.ArgumentParser.java
public static <T> T parsePayload(String json, Class<T> tClass) { final int errorCode = HttpURLConnection.HTTP_BAD_REQUEST; try {/*from w w w .ja v a 2 s .c om*/ return JacksonUtilChecked.objectFromJson(json, tClass); } catch (UnrecognizedPropertyException e) { List<String> references = getReferences(e); if (references.size() > 1) { String referencesString = StringUtils.join(references.subList(0, references.size()), "->"); throw RaptureExceptionFactory.create(errorCode, String.format("Bad value for argument \"%s\". Child field \"%s\" not recognized.", references.get(0), referencesString), e); } else { throw RaptureExceptionFactory.create(errorCode, String.format( "Unrecognized parameter \"%s\" passed to API call", e.getUnrecognizedPropertyName()), e); } } catch (JsonMappingException e) { List<String> references = getReferences(e); if (references.size() > 1) { String referencesString = StringUtils.join(references.subList(0, references.size()), "->"); throw RaptureExceptionFactory.create(errorCode, String.format("Bad value for argument \"%s\". The problem is in the child field \"%s\": %s", references.get(0), referencesString, getReadableMessage(e)), e); } else if (references.size() > 0) { throw RaptureExceptionFactory.create(errorCode, String.format("Bad value for argument \"%s\": %s", references.get(0), getReadableMessage(e)), e); } else { RaptureException raptureException = RaptureExceptionFactory.create(errorCode, "Error reading arguments: " + e.getMessage(), e); log.error(String.format("exception id [%s]; json [%s]", raptureException.getId(), json)); throw raptureException; } } catch (JsonParseException e) { RaptureException raptureException = RaptureExceptionFactory.create(errorCode, "Bad/incomplete arguments passed in: " + e.getMessage(), e); log.error(String.format("exception id [%s]; json [%s]", raptureException.getId(), json)); throw raptureException; } catch (IOException e) { RaptureException raptureException = RaptureExceptionFactory.create(errorCode, "Error reading arguments: " + e.getMessage(), e); log.error(String.format("exception id [%s]; json [%s]", raptureException.getId(), json)); throw raptureException; } }