List of usage examples for com.fasterxml.jackson.databind.exc UnrecognizedPropertyException getLocation
public JsonLocation getLocation()
From source file:org.darkware.wpman.config.ReloadableWordpressConfig.java
/** * Reload the profile data.//from www . j av a 2 s . c o m */ public void reload() { WPManager.log.debug("Loading profile data: {}", this.policyFile); try { WordpressConfigData newData = this.mapper.readValue(this.policyFile.toFile(), WordpressConfigData.class); if (newData != null) { // Set a smart default for the policy root if (newData.getPolicyRoot() == null) newData.setPolicyRoot(this.policyFile.getParent()); // Set source files on existing plugins and themes newData.getPluginListConfig().getItems().values().forEach(p -> p.setPolicyFile(this.policyFile)); newData.getThemeListConfig().getItems().values().forEach(t -> t.setPolicyFile(this.policyFile)); // Reload plugin fragments Path pluginsDir = this.policyFile.getParent().resolve("plugins"); this.loadPlugins(newData.getPluginListConfig(), pluginsDir); // Reload theme fragments Path themesDir = this.policyFile.getParent().resolve("themes"); this.loadThemes(newData.getThemeListConfig(), themesDir); // Apply the new profile if (this.data != null) WPManager.log.info("Reloaded configuration."); this.data = newData; } } catch (UnrecognizedPropertyException e) { WPManager.log.error("Unrecognized property in {}: {} at {}", this.policyFile, e.getPropertyName(), e.getLocation()); } catch (IOException e) { WPManager.log.error("Failed to load policy configuration: {}", this.policyFile, e); } }
From source file:de.thomaskrille.dropwizard.environment_configuration.EnvironmentConfigurationFactory.java
private T build(JsonNode node, String path) throws IOException, ConfigurationException { replaceEnvironmentVariables(node);/*from www .j ava 2 s .com*/ 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); } }