Search in sources :

Example 1 with JsonProcessingException

use of org.apache.flink.shaded.jackson2.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;
}
Also used : SimpleFilterProvider(com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) FilterProvider(com.fasterxml.jackson.databind.ser.FilterProvider) SimpleFilterProvider(com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider)

Example 2 with JsonProcessingException

use of org.apache.flink.shaded.jackson2.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\"}");
    }
}
Also used : JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 3 with JsonProcessingException

use of org.apache.flink.shaded.jackson2.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;
}
Also used : ProfilingDataJson(org.killbill.billing.jaxrs.json.ProfilingDataJson) ProfilingData(org.killbill.commons.profiling.ProfilingData) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Example 4 with JsonProcessingException

use of org.apache.flink.shaded.jackson2.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;
}
Also used : ArrayList(java.util.ArrayList) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) TaskDTO(com.linkedin.thirdeye.datalayer.dto.TaskDTO) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Example 5 with JsonProcessingException

use of org.apache.flink.shaded.jackson2.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;
}
Also used : ArrayList(java.util.ArrayList) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) TaskDTO(com.linkedin.thirdeye.datalayer.dto.TaskDTO) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) JobExecutionException(org.quartz.JobExecutionException)

Aggregations

JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)741 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)241 IOException (java.io.IOException)174 HashMap (java.util.HashMap)108 Map (java.util.Map)83 ArrayList (java.util.ArrayList)74 JsonNode (com.fasterxml.jackson.databind.JsonNode)73 Test (org.junit.Test)65 List (java.util.List)56 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)36 Collectors (java.util.stream.Collectors)30 InputStream (java.io.InputStream)26 Json (com.sequenceiq.cloudbreak.domain.json.Json)21 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)20 File (java.io.File)20 Function (java.util.function.Function)20 Logger (org.slf4j.Logger)20 Optional (java.util.Optional)19 Date (java.util.Date)18 Test (org.testng.annotations.Test)18