use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonProcessingException in project compss by bsc-wdc.
the class Consumer method processRegularRecord.
private static void processRegularRecord(String value) throws ConsumerException {
// Read the encoded information in the message
JsonNode msg = null;
try {
msg = new ObjectMapper().readTree(value);
} catch (JsonProcessingException jpe) {
jpe.printStackTrace();
throw new ConsumerException("ERROR: Cannot read regular message", jpe);
} catch (IOException ioe) {
ioe.printStackTrace();
throw new ConsumerException("ERROR: Cannot read regular message", ioe);
}
// Retrieve the message type
switch(msg.get(Messages.FIELD_TYPE).asText()) {
case Messages.TYPE_MESSAGE:
long latency = (long) ((System.nanoTime() * 1e-9 - msg.get(Messages.FIELD_T).asDouble()) * 1_000);
Result.addValue(latency);
break;
case Messages.TYPE_STATS:
// Whenever we receive a stats message we log its retrieval
if (DEBUG) {
System.out.println("[LOG] Stats message received");
}
break;
default:
throw new ConsumerException("ERROR: Unrecognised message type: " + msg.get(Messages.FIELD_TYPE).asText());
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonProcessingException in project atlasdb by palantir.
the class SerializableErrorDecoderTest method assertCanSerializeAndDeserializeErrorWithName.
private void assertCanSerializeAndDeserializeErrorWithName(String errorName) throws JsonProcessingException {
SerializableError serializableError = SerializableError.of(EXCEPTION_MESSAGE, errorName);
Response response = createResponseForEntity(serializableError);
Exception exception = decoder.decode(SOME_METHOD_KEY, response);
assertThat(exception).isInstanceOf(AtlasDbRemoteException.class).satisfies(remoteException -> assertHasErrorName(remoteException, errorName));
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonProcessingException in project joynr by bmwcarit.
the class DefaultJoynrRuntimeFactory method provisionAccessControl.
private void provisionAccessControl(Properties properties, String domain, String[] interfaceNames) {
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.enableDefaultTypingAsProperty(DefaultTyping.JAVA_LANG_OBJECT, "_typeName");
List<MasterAccessControlEntry> allEntries = new ArrayList<>();
for (String interfaceName : interfaceNames) {
MasterAccessControlEntry newMasterAccessControlEntry = new MasterAccessControlEntry("*", domain, interfaceName, TrustLevel.LOW, new TrustLevel[] { TrustLevel.LOW }, TrustLevel.LOW, new TrustLevel[] { TrustLevel.LOW }, "*", Permission.YES, new Permission[] { joynr.infrastructure.DacTypes.Permission.YES });
allEntries.add(newMasterAccessControlEntry);
}
MasterAccessControlEntry[] provisionedAccessControlEntries = allEntries.toArray(new MasterAccessControlEntry[allEntries.size()]);
String provisionedAccessControlEntriesAsJson;
try {
provisionedAccessControlEntriesAsJson = objectMapper.writeValueAsString(provisionedAccessControlEntries);
properties.setProperty(StaticDomainAccessControlProvisioning.PROPERTY_PROVISIONED_MASTER_ACCESSCONTROLENTRIES, provisionedAccessControlEntriesAsJson);
} catch (JsonProcessingException e) {
LOG.error("Error parsing JSON.", e);
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonProcessingException in project Discord4J by Discord4J.
the class NickHolder method moveToVoiceChannel.
@Override
public void moveToVoiceChannel(IVoiceChannel channel) {
IVoiceChannel oldChannel = getVoiceStateForGuild(channel.getGuild()).getChannel();
if (oldChannel == null)
throw new DiscordException("User must already be in a voice channel before they can be moved to another.");
// client must have permission to both move members and connect to the channel.
PermissionUtils.requirePermissions(channel, client.getOurUser(), Permissions.VOICE_MOVE_MEMBERS, Permissions.VOICE_CONNECT);
try {
((DiscordClientImpl) client).REQUESTS.PATCH.makeRequest(DiscordEndpoints.GUILDS + channel.getGuild().getStringID() + "/members/" + id, DiscordUtils.MAPPER_NO_NULLS.writeValueAsString(new MemberEditRequest.Builder().channel(channel.getStringID()).build()));
} catch (JsonProcessingException e) {
Discord4J.LOGGER.error(LogMarkers.HANDLE, "Discord4J Internal Exception", e);
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonProcessingException in project gravitee-management-rest-api by gravitee-io.
the class PlanServiceImpl method create.
@Override
public PlanEntity create(NewPlanEntity newPlan) {
try {
logger.debug("Create a new plan {} for API {}", newPlan.getName(), newPlan.getApi());
Plan plan = new Plan();
plan.setId(UUID.toString(UUID.random()));
plan.setApis(Collections.singleton(newPlan.getApi()));
plan.setName(newPlan.getName());
plan.setDescription(newPlan.getDescription());
plan.setCreatedAt(new Date());
plan.setUpdatedAt(plan.getCreatedAt());
plan.setType(Plan.PlanType.valueOf(newPlan.getType().name()));
plan.setSecurity(Plan.PlanSecurityType.valueOf(newPlan.getSecurity().name()));
plan.setSecurityDefinition(newPlan.getSecurityDefinition());
plan.setStatus(Plan.Status.valueOf(newPlan.getStatus().name()));
plan.setExcludedGroups(newPlan.getExcludedGroups());
if (plan.getSecurity() == Plan.PlanSecurityType.KEY_LESS) {
// There is no need for a validation when authentication is KEY_LESS, force to AUTO
plan.setValidation(Plan.PlanValidationType.AUTO);
} else {
plan.setValidation(Plan.PlanValidationType.valueOf(newPlan.getValidation().name()));
}
plan.setCharacteristics(newPlan.getCharacteristics());
String planPolicies = objectMapper.writeValueAsString(newPlan.getPaths());
plan.setDefinition(planPolicies);
plan = planRepository.create(plan);
auditService.createApiAuditLog(newPlan.getApi(), Collections.singletonMap(PLAN, plan.getId()), PLAN_CREATED, plan.getCreatedAt(), null, plan);
return convert(plan);
} catch (TechnicalException ex) {
logger.error("An error occurs while trying to create a plan {} for API {}", newPlan.getName(), newPlan.getApi(), ex);
throw new TechnicalManagementException(String.format("An error occurs while trying to create a plan %s for API %s", newPlan.getName(), newPlan.getApi()), ex);
} catch (JsonProcessingException jse) {
logger.error("Unexpected error while generating plan definition", jse);
throw new TechnicalManagementException(String.format("An error occurs while trying to create a plan %s for API %s", newPlan.getName(), newPlan.getApi()), jse);
}
}
Aggregations