use of com.fasterxml.jackson.core.JsonProcessingException in project photo-picker-plus-android by chute.
the class MediaModel method serializeImageDataModel.
public String serializeImageDataModel() {
FilterProvider filters = new SimpleFilterProvider().addFilter("imageDataModelFilter", SimpleBeanPropertyFilter.filterOutAllExcept("options", "media"));
String result = null;
try {
result = JsonUtil.getMapper().writer(filters).writeValueAsString(this);
} catch (JsonProcessingException e) {
Log.d(TAG, "", e);
}
return result;
}
use of com.fasterxml.jackson.core.JsonProcessingException in project pinot by linkedin.
the class TableViews method getTableState.
// we use name "view" to closely match underlying names and to not
// confuse with table state of enable/disable
private Representation getTableState(String tableName, String view, TableType tableType) {
TableView tableView;
if (view.equalsIgnoreCase(IDEALSTATE)) {
tableView = getTableIdealState(tableName, tableType);
} else if (view.equalsIgnoreCase(EXTERNALVIEW)) {
tableView = getTableExternalView(tableName, tableType);
} else {
return responseRepresentation(Status.CLIENT_ERROR_BAD_REQUEST, "{\"error\" : \"Bad view name: " + view + ". Expected idealstate or externalview\" }");
}
if (tableView.offline == null && tableView.realtime == null) {
return responseRepresentation(Status.CLIENT_ERROR_NOT_FOUND, "{\"error\" : \"Table not found}");
}
ObjectMapper mapper = new ObjectMapper();
try {
String response = mapper.writeValueAsString(tableView);
return responseRepresentation(Status.SUCCESS_OK, response);
} catch (JsonProcessingException e) {
LOGGER.error("Failed to serialize {} for table {}", tableName, view, e);
return responseRepresentation(Status.SERVER_ERROR_INTERNAL, "{\"error\": \"Error serializing response\"}");
}
}
use of com.fasterxml.jackson.core.JsonProcessingException in project killbill by killbill.
the class ProfilingContainerResponseFilter method filter.
@Override
public ContainerResponse filter(final ContainerRequest request, final ContainerResponse response) {
try {
final ProfilingData rawData = Profiling.getPerThreadProfilingData();
if (rawData != null) {
if (rawData.getProfileFeature().isProfilingJAXRS()) {
rawData.addEnd(ProfilingFeatureType.JAXRS, request.getPath());
}
final ProfilingDataJson profilingData = new ProfilingDataJson(rawData);
final String value;
try {
value = mapper.writeValueAsString(profilingData);
response.getHttpHeaders().add(PROFILING_HEADER_RESP, value);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
}
} finally {
Profiling.resetPerThreadProfilingData();
}
return response;
}
use of com.fasterxml.jackson.core.JsonProcessingException in project pinot by linkedin.
the class MonitorJobRunner method createTasks.
public List<Long> createTasks() {
List<Long> taskIds = new ArrayList<>();
try {
LOG.info("Creating monitor tasks");
List<MonitorTaskInfo> monitorTasks = taskGenerator.createMonitorTasks(monitorJobContext);
LOG.info("Monitor tasks {}", monitorTasks);
for (MonitorTaskInfo taskInfo : monitorTasks) {
String taskInfoJson = null;
try {
taskInfoJson = OBJECT_MAPPER.writeValueAsString(taskInfo);
} catch (JsonProcessingException e) {
LOG.error("Exception when converting MonitorTaskInfo {} to jsonString", taskInfo, e);
}
TaskDTO taskSpec = new TaskDTO();
taskSpec.setTaskType(TaskType.MONITOR);
taskSpec.setJobName(monitorJobContext.getJobName());
taskSpec.setStatus(TaskStatus.WAITING);
taskSpec.setStartTime(System.currentTimeMillis());
taskSpec.setTaskInfo(taskInfoJson);
taskSpec.setJobId(monitorJobContext.getJobExecutionId());
long taskId = taskDAO.save(taskSpec);
taskIds.add(taskId);
LOG.info("Created monitorTask {} with taskId {}", taskSpec, taskId);
}
} catch (Exception e) {
LOG.error("Exception in creating anomaly tasks", e);
}
return taskIds;
}
use of com.fasterxml.jackson.core.JsonProcessingException in project pinot by linkedin.
the class AlertJobRunner method createTasks.
private List<Long> createTasks(DateTime monitoringWindowStartTime, DateTime monitoringWindowEndTime) {
List<Long> taskIds = new ArrayList<>();
try {
List<AlertTaskInfo> tasks = taskGenerator.createAlertTasks(alertJobContext, monitoringWindowStartTime, monitoringWindowEndTime);
for (AlertTaskInfo taskInfo : tasks) {
String taskInfoJson = null;
try {
taskInfoJson = OBJECT_MAPPER.writeValueAsString(taskInfo);
} catch (JsonProcessingException e) {
LOG.error("Exception when converting AlertTaskInfo {} to jsonString", taskInfo, e);
}
TaskDTO taskSpec = new TaskDTO();
taskSpec.setTaskType(TaskType.ALERT);
taskSpec.setJobName(alertJobContext.getJobName());
taskSpec.setStatus(TaskStatus.WAITING);
taskSpec.setStartTime(System.currentTimeMillis());
taskSpec.setTaskInfo(taskInfoJson);
taskSpec.setJobId(alertJobContext.getJobExecutionId());
long taskId = taskDAO.save(taskSpec);
taskIds.add(taskId);
LOG.info("Created alert task {} with taskId {}", taskSpec, taskId);
}
} catch (Exception e) {
LOG.error("Exception in creating alert tasks", e);
}
return taskIds;
}
Aggregations