Java Code Examples for com.fasterxml.jackson.core.JsonProcessingException#getMessage()

The following examples show how to use com.fasterxml.jackson.core.JsonProcessingException#getMessage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AdformAdapter.java    From prebid-server-java with Apache License 2.0 6 votes vote down vote up
/**
 * Converts {@link AdUnitBid} to masterTagId. In case of any problem to retrieve or validate masterTagId, throws
 * {@link PreBidException}
 */
private AdformParams toAdformParams(AdUnitBid adUnitBid) {
    final ObjectNode params = adUnitBid.getParams();
    if (params == null) {
        throw new PreBidException("Adform params section is missing");
    }
    final AdformParams adformParams;
    try {
        adformParams = mapper.mapper().treeToValue(params, AdformParams.class);
    } catch (JsonProcessingException e) {
        throw new PreBidException(e.getMessage(), e.getCause());
    }
    final Long masterTagId = adformParams.getMid();
    if (masterTagId != null && masterTagId > 0) {
        return adformParams;
    } else {
        throw new PreBidException(String.format("master tag(placement) id is invalid=%s", masterTagId));
    }
}
 
Example 2
Source File: KubernetesV2Service.java    From halyard with Apache License 2.0 6 votes vote down vote up
default String getTolerations(AccountDeploymentDetails<KubernetesAccount> details) {
  List<Toleration> toleration =
      details
          .getDeploymentConfiguration()
          .getDeploymentEnvironment()
          .getTolerations()
          .getOrDefault(getService().getServiceName(), new ArrayList<>());

  if (toleration.isEmpty()) {
    toleration =
        details
            .getDeploymentConfiguration()
            .getDeploymentEnvironment()
            .getTolerations()
            .getOrDefault(getService().getBaseCanonicalName(), new ArrayList<>());
  }

  try {
    return getObjectMapper().writeValueAsString(toleration);
  } catch (JsonProcessingException e) {
    throw new HalException(
        Problem.Severity.FATAL, "Invalid tolerations format: " + e.getMessage(), e);
  }
}
 
Example 3
Source File: UpdateJsonDryRunRenderer.java    From incubator-heron with Apache License 2.0 6 votes vote down vote up
public String render() {
  StringBuilder builder = new StringBuilder();
  JsonFormatterUtils newFormatter = new JsonFormatterUtils();
  JsonFormatterUtils oldFormatter = new JsonFormatterUtils();

  String topologyName = response.getTopology().getName();
  String packingClassName = Context.packingClass(response.getConfig());
  PackingPlan newPackingPlan = response.getPackingPlan();
  PackingPlan oldPackingPlan = response.getOldPackingPlan();

  try {
    String newPackingPlanJson = newFormatter.renderPackingPlan(topologyName, packingClassName,
        newPackingPlan);
    String oldPackingPlanJson = oldFormatter.renderPackingPlan(topologyName, packingClassName,
        oldPackingPlan);

    builder.append("New packing plan:\n");
    builder.append(newPackingPlanJson).append("\n");
    builder.append("Old packing plan:\n");
    builder.append(oldPackingPlanJson).append("\n");

    return builder.toString();
  } catch (JsonProcessingException e) {
    return "ERROR: " + e.getMessage();
  }
}
 
Example 4
Source File: AppnexusBidder.java    From prebid-server-java with Apache License 2.0 5 votes vote down vote up
private AppnexusBidExt parseAppnexusBidExt(ObjectNode bidExt) {
    if (bidExt == null) {
        throw new PreBidException("bidResponse.bid.ext should be defined for appnexus");
    }

    final AppnexusBidExt appnexusBidExt;
    try {
        appnexusBidExt = mapper.mapper().treeToValue(bidExt, AppnexusBidExt.class);
    } catch (JsonProcessingException e) {
        throw new PreBidException(e.getMessage(), e);
    }
    return appnexusBidExt;
}
 
Example 5
Source File: ModifyKeyRelDeviceListApi.java    From JAVA-HTTP-SDK with MIT License 5 votes vote down vote up
public ModifyKeyRelDeviceListApi(List<String> addDevIds, List<String> delDevIds, String apiKey, String masterKey) {
    this.apiKey = apiKey;
    this.addDevIds = addDevIds;
    this.delDevIds = delDevIds;
    this.key = masterKey;
    this.method = RequestInfo.Method.PUT;
    this.HttpMethod = new HttpPutMethod(method);
    this.url = Config.getString("test.url") + "/keys/"+apiKey+"/devices" ;
    Map<String, Object> headmap = new HashMap<String, Object>();
    Map<String, Object> body = new HashMap<String, Object>();
    if(addDevIds!=null&&!addDevIds.isEmpty()){
        body.put("add_dev_ids",addDevIds);
    }
    if(delDevIds!=null&&!delDevIds.isEmpty()){
        body.put("del_dev_ids",delDevIds);
    }
    String json = null;
    try {
        json = mapper.writeValueAsString(body);
    } catch (JsonProcessingException e) {
        logger.error("json error {}", e.getMessage());
        throw new OnenetApiException(e.getMessage());
    }
    headmap.put("api-key", masterKey);
    HttpMethod.setHeader(headmap);
    HttpMethod.setcompleteUrl(url,null);
    HttpMethod.setEntity(json);
}
 
Example 6
Source File: Tf2OnnxImportTestCase.java    From vespa with Apache License 2.0 5 votes vote down vote up
public String toString() {
    ArrayNode array = mapper.createArrayNode();
    results.forEach((key, value) -> array.add(mapper.createObjectNode().
            put("model", key).
            set("tests", value)));
    try {
        return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(array);
    } catch (JsonProcessingException e) {
        return e.getMessage();
    }
}
 
Example 7
Source File: SeaCloudsMonitoringInitializationPolicies.java    From SeaCloudsPlatform with Apache License 2.0 5 votes vote down vote up
private void postSeaCloudsDcConfiguration(SeaCloudsDcRequestDto requestBody) {
    try {
        String jsonBody = new ObjectMapper().writeValueAsString(requestBody);
        postSeaCloudsDcConfiguration(jsonBody);
    } catch (JsonProcessingException e) {
        throw new RuntimeException("Something went wrong creating Request body to " +
                "configure the SeaCloudsDc for type" + requestBody.getType() + " and " +
                "url " + requestBody.getUrl() + ". Message: " + e.getMessage());
    }
}
 
Example 8
Source File: DataTagValueUpdateConverter.java    From c2mon with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Converts a {@link DataTagValueUpdate} to a JMS {@link Message}
 *
 * @param tag     the tag to convert
 * @param session the session in which the message must be created
 *
 * @return the resulting message
 * @throws JMSException if an error occurs in creating the message
 */
@Override
public Message toMessage(final Object tag, final Session session) throws JMSException {
  try {
    String json = mapper.writeValueAsString(tag);
    return session.createTextMessage(json);

  } catch (JsonProcessingException e) {
    log.error("Exception caught on update reception", e.getMessage());
    throw new MessageConversionException("Exception caught in converting dataTagValueUpdate to a json String:"
        + e.getMessage());
  }
}
 
Example 9
Source File: RequestValidator.java    From prebid-server-java with Apache License 2.0 5 votes vote down vote up
private void validateSource(Source source) throws ValidationException {
    if (source != null && source.getExt() != null) {
        try {
            mapper.mapper().treeToValue(source.getExt(), ExtSource.class);
        } catch (JsonProcessingException e) {
            throw new ValidationException("request.source.ext is invalid: %s", e.getMessage());
        }
    }
}
 
Example 10
Source File: GraphqlContext.java    From pandaria with MIT License 5 votes vote down vote up
public String request() {
    try {

        Builder<String, String> builder = ImmutableMap.<String, String>builder()
                .put("query", this.query);


        variables.ifPresent(variables -> builder.put("variables", variables));
        operationName.ifPresent(operationName -> builder.put("operationName", operationName));

        return toJsonString(builder.build());
    } catch (JsonProcessingException exception) {
        throw new RuntimeException(exception.getMessage(), exception);
    }
}
 
Example 11
Source File: PersistentJsonObjectAsString.java    From jadira with Apache License 2.0 5 votes vote down vote up
@Override
  public String objectToSQLString(final Object object) {
  	
  	if (object == null) {
  		return null;
  	}

  	try {
	return objectWriter.writeValueAsString(object);
} catch (JsonProcessingException e) {
	throw new HibernateException("Cannot serialize JSON object: " + e.getMessage(), e);
}
  }
 
Example 12
Source File: JsonUtil.java    From multiapps with Apache License 2.0 5 votes vote down vote up
public static String toJson(Object object, boolean indentedOutput) {
    try {
        return getObjectWriter(indentedOutput).writeValueAsString(object);
    } catch (JsonProcessingException e) {
        throw new IllegalArgumentException(e.getMessage(), e);
    }
}
 
Example 13
Source File: RequestValidator.java    From prebid-server-java with Apache License 2.0 5 votes vote down vote up
private void validateApp(App app) throws ValidationException {
    if (app != null) {
        if (app.getExt() != null) {
            try {
                mapper.mapper().treeToValue(app.getExt(), ExtApp.class);
            } catch (JsonProcessingException e) {
                throw new ValidationException("request.app.ext object is not valid: %s", e.getMessage());
            }
        }
    }
}
 
Example 14
Source File: WorkflowDataContext.java    From flowing-retail with Apache License 2.0 5 votes vote down vote up
public String asJson() {
  try {
    return new ObjectMapper().writeValueAsString(this);
  } catch (JsonProcessingException e) {
    throw new RuntimeException("Could not serialize context to JSON: " + e.getMessage(), e);
  }
}
 
Example 15
Source File: RequestValidator.java    From prebid-server-java with Apache License 2.0 5 votes vote down vote up
private ExtBidRequest parseAndValidateExtBidRequest(BidRequest bidRequest) throws ValidationException {
    ExtBidRequest extBidRequest = null;
    if (bidRequest.getExt() != null) {
        try {
            extBidRequest = mapper.mapper().treeToValue(bidRequest.getExt(), ExtBidRequest.class);
        } catch (JsonProcessingException e) {
            throw new ValidationException("request.ext is invalid: %s", e.getMessage());
        }
    }
    return extBidRequest;
}
 
Example 16
Source File: AppnexusAdapter.java    From prebid-server-java with Apache License 2.0 5 votes vote down vote up
private AppnexusBidExt parseAppnexusBidExt(ObjectNode bidExt) {
    if (bidExt == null) {
        throw new PreBidException("bidResponse.bid.ext should be defined for appnexus");
    }

    final AppnexusBidExt appnexusBidExt;
    try {
        appnexusBidExt = mapper.mapper().treeToValue(bidExt, AppnexusBidExt.class);
    } catch (JsonProcessingException e) {
        throw new PreBidException(e.getMessage(), e);
    }
    return appnexusBidExt;
}
 
Example 17
Source File: ModifySpaceOp.java    From xyz-hub with Apache License 2.0 5 votes vote down vote up
@Override
public Space fromMap(Map<String, Object> map) throws ModifyOpError, HttpException {
  try {
    return Json.mapper.readValue(Json.encode(map), Space.class);
  } catch (JsonProcessingException e) {
    throw new HttpException(BAD_REQUEST, "Invalid space definition: " + e.getMessage(), e);
  }
}
 
Example 18
Source File: JsonReadException.java    From dropbox-sdk-java with MIT License 5 votes vote down vote up
public static JsonReadException fromJackson(JsonProcessingException ex)
{
    String message = ex.getMessage();

    // Strip off location.
    int locPos = message.lastIndexOf(" at [Source");
    if (locPos >= 0) {
        message = message.substring(0, locPos);
    }

    return new JsonReadException(message, ex.getLocation());
}
 
Example 19
Source File: SwaggerError.java    From KaiZen-OpenAPI-Editor with Eclipse Public License 1.0 4 votes vote down vote up
public static SwaggerError newJsonError(JsonProcessingException exception) {
    int line = (exception.getLocation() != null) ? exception.getLocation().getLineNr() : 1;
    return new SwaggerError(line, IMarker.SEVERITY_ERROR, 0, exception.getMessage());
}
 
Example 20
Source File: JwtProxyConfigBuilder.java    From che with Eclipse Public License 2.0 4 votes vote down vote up
public String build() throws InternalInfrastructureException {
  List<VerifierProxyConfig> proxyConfigs = new ArrayList<>();
  Config config =
      new Config()
          .withJWTProxy(
              new JWTProxy()
                  .withSignerProxy(new SignerProxyConfig().withEnabled(false))
                  .withVerifiedProxyConfigs(proxyConfigs));

  for (VerifierProxy verifierProxy : verifierProxies) {
    VerifierConfig verifierConfig =
        new VerifierConfig()
            .withAudience(workspaceId)
            .withUpstream(verifierProxy.upstream)
            .withMaxSkew("1m")
            .withMaxTtl(ttl)
            .withKeyServer(
                new RegistrableComponentConfig()
                    .withType("preshared")
                    .withOptions(
                        ImmutableMap.of(
                            "issuer",
                            issuer,
                            "key_id",
                            workspaceId,
                            "public_key_path",
                            JWT_PROXY_CONFIG_FOLDER + '/' + JWT_PROXY_PUBLIC_KEY_FILE)))
            .withCookiesEnabled(verifierProxy.cookiesAuthEnabled)
            .withCookiePath(ensureStartsWithSlash(verifierProxy.cookiePath))
            .withClaimsVerifier(
                Collections.singleton(
                    new RegistrableComponentConfig()
                        .withType("static")
                        .withOptions(ImmutableMap.of("iss", issuer))))
            .withNonceStorage(new RegistrableComponentConfig().withType("void"));

    if (!verifierProxy.excludes.isEmpty()) {
      verifierConfig.setExcludes(verifierProxy.excludes);
    }

    if (verifierProxy.cookiesAuthEnabled && authPageUrl != null) {
      verifierConfig.setAuthUrl(authPageUrl.toString());
    }

    if (verifierProxy.publicBasePath != null) {
      verifierConfig.setPublicBasePath(verifierProxy.publicBasePath);
    }

    VerifierProxyConfig proxyConfig =
        new VerifierProxyConfig()
            .withListenAddr(":" + verifierProxy.listenPort)
            .withVerifierConfig(verifierConfig);

    proxyConfigs.add(proxyConfig);
  }

  try {
    return YAML_PARSER.writeValueAsString(config);
  } catch (JsonProcessingException e) {
    throw new InternalInfrastructureException(
        "Error during creation of JWTProxy config YAML: " + e.getMessage(), e);
  }
}