use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonProcessingException in project data-prep by Talend.
the class PreparationUpdate method onExecute.
private HttpRequestBase onExecute(String id, Preparation preparation) {
try {
final byte[] preparationJSONValue = objectMapper.writeValueAsBytes(preparation);
final HttpPut preparationCreation = new HttpPut(preparationServiceUrl + "/preparations/" + id);
preparationCreation.setHeader(CONTENT_TYPE, APPLICATION_JSON_VALUE);
preparationCreation.setEntity(new ByteArrayEntity(preparationJSONValue));
return preparationCreation;
} catch (JsonProcessingException e) {
throw new TDPException(CommonErrorCodes.UNEXPECTED_EXCEPTION, e);
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonProcessingException in project knox by apache.
the class DefaultServiceRegistryService method renderAsJsonString.
private String renderAsJsonString(HashMap<String, HashMap<String, RegEntry>> registry) {
String json = null;
ObjectMapper mapper = new ObjectMapper();
try {
// write JSON to a file
json = mapper.writeValueAsString((Object) registry);
} catch (JsonProcessingException e) {
// TODO: I18N
e.printStackTrace();
}
return json;
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonProcessingException in project libsignal-service-java by signalapp.
the class PushServiceSocket method makeServiceRequest.
private String makeServiceRequest(String urlFragment, String method, String body) throws NonSuccessfulResponseCodeException, PushNetworkException {
Response response = getServiceConnection(urlFragment, method, body);
int responseCode;
String responseMessage;
String responseBody;
try {
responseCode = response.code();
responseMessage = response.message();
responseBody = response.body().string();
} catch (IOException ioe) {
throw new PushNetworkException(ioe);
}
switch(responseCode) {
case 413:
throw new RateLimitException("Rate limit exceeded: " + responseCode);
case 401:
case 403:
throw new AuthorizationFailedException("Authorization failed!");
case 404:
throw new NotFoundException("Not found");
case 409:
MismatchedDevices mismatchedDevices;
try {
mismatchedDevices = JsonUtil.fromJson(responseBody, MismatchedDevices.class);
} catch (JsonProcessingException e) {
Log.w(TAG, e);
throw new NonSuccessfulResponseCodeException("Bad response: " + responseCode + " " + responseMessage);
} catch (IOException e) {
throw new PushNetworkException(e);
}
throw new MismatchedDevicesException(mismatchedDevices);
case 410:
StaleDevices staleDevices;
try {
staleDevices = JsonUtil.fromJson(responseBody, StaleDevices.class);
} catch (JsonProcessingException e) {
throw new NonSuccessfulResponseCodeException("Bad response: " + responseCode + " " + responseMessage);
} catch (IOException e) {
throw new PushNetworkException(e);
}
throw new StaleDevicesException(staleDevices);
case 411:
DeviceLimit deviceLimit;
try {
deviceLimit = JsonUtil.fromJson(responseBody, DeviceLimit.class);
} catch (JsonProcessingException e) {
throw new NonSuccessfulResponseCodeException("Bad response: " + responseCode + " " + responseMessage);
} catch (IOException e) {
throw new PushNetworkException(e);
}
throw new DeviceLimitExceededException(deviceLimit);
case 417:
throw new ExpectationFailedException();
case 423:
RegistrationLockFailure accountLockFailure;
try {
accountLockFailure = JsonUtil.fromJson(responseBody, RegistrationLockFailure.class);
} catch (JsonProcessingException e) {
Log.w(TAG, e);
throw new NonSuccessfulResponseCodeException("Bad response: " + responseCode + " " + responseMessage);
} catch (IOException e) {
throw new PushNetworkException(e);
}
throw new LockedException(accountLockFailure.length, accountLockFailure.timeRemaining);
}
if (responseCode != 200 && responseCode != 204) {
throw new NonSuccessfulResponseCodeException("Bad response: " + responseCode + " " + responseMessage);
}
return responseBody;
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonProcessingException in project feign-reactive by kptfh.
the class DefaultMethodTest method shouldWrapExceptionWithFlux.
@Test
public void shouldWrapExceptionWithFlux() throws JsonProcessingException {
IceCreamOrder orderGenerated = new OrderGenerator().generate(1);
IcecreamServiceApi client = ReactiveFeign.<IcecreamServiceApi>builder().webClient(WebClient.create()).target(IcecreamServiceApi.class, "http://localhost:" + wireMockRule.port());
IceCreamOrder errorOrder = client.throwExceptionFlux().onErrorReturn(throwable -> throwable.equals(IcecreamServiceApi.RUNTIME_EXCEPTION), orderGenerated).blockFirst();
assertThat(errorOrder).isEqualToComparingFieldByField(orderGenerated);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonProcessingException in project feign-reactive by kptfh.
the class DefaultMethodTest method shouldWrapExceptionWithMono.
@Test
public void shouldWrapExceptionWithMono() throws JsonProcessingException {
IceCreamOrder orderGenerated = new OrderGenerator().generate(1);
IcecreamServiceApi client = ReactiveFeign.<IcecreamServiceApi>builder().webClient(WebClient.create()).target(IcecreamServiceApi.class, "http://localhost:" + wireMockRule.port());
IceCreamOrder errorOrder = client.throwExceptionMono().onErrorReturn(throwable -> throwable.equals(IcecreamServiceApi.RUNTIME_EXCEPTION), orderGenerated).block();
assertThat(errorOrder).isEqualToComparingFieldByField(orderGenerated);
}
Aggregations