List of usage examples for com.fasterxml.jackson.core JsonProcessingException getMessage
@Override
public String getMessage()
From source file:io.fabric8.maven.plugin.AbstractDeployMojo.java
public static Ingress createIngressForService(String routeDomainPostfix, String namespace, Service service, Log log) {/* w w w . ja v a 2 s. c o m*/ Ingress ingress = null; String serviceName = KubernetesHelper.getName(service); ServiceSpec serviceSpec = service.getSpec(); if (serviceSpec != null && Strings.isNotBlank(serviceName) && shouldCreateExternalURLForService(log, service, serviceName)) { String ingressId = serviceName; String host = ""; if (Strings.isNotBlank(routeDomainPostfix)) { host = serviceName + "." + namespace + "." + Strings.stripPrefix(routeDomainPostfix, "."); } List<HTTPIngressPath> paths = new ArrayList<>(); List<ServicePort> ports = serviceSpec.getPorts(); if (ports != null) { for (ServicePort port : ports) { Integer portNumber = port.getPort(); if (portNumber != null) { HTTPIngressPath path = new HTTPIngressPathBuilder().withNewBackend() .withServiceName(serviceName) .withServicePort(createIntOrString(portNumber.intValue())).endBackend().build(); paths.add(path); } } } if (paths.isEmpty()) { return ingress; } ingress = new IngressBuilder().withNewMetadata().withName(ingressId).withNamespace(namespace) .endMetadata().withNewSpec().addNewRule().withHost(host).withNewHttp().withPaths(paths) .endHttp().endRule().endSpec().build(); String json; try { json = KubernetesHelper.toJson(ingress); } catch (JsonProcessingException e) { json = e.getMessage() + ". object: " + ingress; } log.debug("Created ingress: " + json); } return ingress; }
From source file:io.fabric8.maven.core.util.KubernetesResourceUtil.java
private static Map<String, Object> readFragment(File file, String ext) throws IOException { ObjectMapper mapper = new ObjectMapper("json".equals(ext) ? new JsonFactory() : new YAMLFactory()); TypeReference<HashMap<String, Object>> typeRef = new TypeReference<HashMap<String, Object>>() { };//w w w.j av a2s . co m try { Map<String, Object> ret = mapper.readValue(file, typeRef); return ret != null ? ret : new HashMap<String, Object>(); } catch (JsonProcessingException e) { throw new JsonMappingException(String.format("[%s] %s", file, e.getMessage()), e.getLocation(), e); } }
From source file:com.unboundid.scim2.common.utils.JsonUtils.java
/** * Utility method to convert Jackson JSON array node to a list of POJOs. * * @param <T> Actual node type./*from w w w.j a v a2 s .c om*/ * @param fromNode node to convert. * @param valueType The value type. * @return converted list of POJOs. * @throws JsonProcessingException if an error occurs while binding the JSON * node to the value type. */ public static <T> List<T> nodeToValues(final ArrayNode fromNode, final Class<T> valueType) throws JsonProcessingException { final CollectionType collectionType = SDK_OBJECT_MAPPER.getTypeFactory().constructCollectionType(List.class, valueType); try { return SDK_OBJECT_MAPPER.readValue(SDK_OBJECT_MAPPER.treeAsTokens(fromNode), collectionType); } catch (JsonProcessingException e) { throw e; } catch (IOException e) { throw new IllegalArgumentException(e.getMessage(), e); } }
From source file:io.werval.modules.json.JsonPluginException.java
JsonPluginException(JsonProcessingException cause) { super(cause.getMessage(), cause); }
From source file:net.anyflow.lannister.httphandler.Topics.java
private String allString() { try {// w w w .java2s. com return (new ObjectMapper()).writeValueAsString(Topic.NEXUS.map()); } catch (JsonProcessingException e) { logger.error(e.getMessage(), e); return null; } }
From source file:feign.jackson.JacksonEncoder.java
@Override public void encode(Object object, RequestTemplate template) throws EncodeException { try {/*from ww w. j a v a 2 s .c o m*/ template.body(mapper.writeValueAsString(object)); } catch (JsonProcessingException e) { throw new EncodeException(e.getMessage(), e); } }
From source file:org.ocelotds.marshallers.TemplateMarshaller.java
@Override public String toJson(Object obj) throws JsonMarshallingException { try {//from ww w .ja v a 2s .c om return objectMapper.writeValueAsString(obj); } catch (JsonProcessingException ex) { throw new JsonMarshallingException(ex.getMessage()); } }
From source file:puma.application.evaluation.metrics.MetricsController.java
@RequestMapping(value = "/metrics/results", method = RequestMethod.GET, produces = "text/plain") public @ResponseBody String results() { try {/* ww w .jav a2 s . c o m*/ ObjectMapper mapper = new ObjectMapper(); ObjectWriter writer = mapper.writerWithDefaultPrettyPrinter(); return writer.writeValueAsString(TimerFactory.getInstance().getMetricRegistry()); } catch (JsonProcessingException e) { return e.getMessage(); } }
From source file:com.orange.clara.cloud.servicedbdumper.converter.MetadataConverter.java
@Override public String convertToDatabaseColumn(Metadata metadata) { if (metadata == null) { return null; }//from w w w. j a va2s .com ObjectMapper objectMapper = new ObjectMapper(); try { return objectMapper.writeValueAsString(metadata); } catch (JsonProcessingException e) { throw new RuntimeException(e.getMessage(), e); } }
From source file:com.acme.SyndEntryJsonTransformer.java
/** * Convert from SyndEntry to JSON string * @param entry the SyndEntry/* w w w . java2s . c o m*/ * @return JSON string */ public String toJson(SyndEntry entry) { try { return mapper.writer().writeValueAsString(entry); } catch (JsonProcessingException e) { throw new RuntimeException(e.getMessage(), e); } }