Search in sources :

Example 1 with JsonProcessingException

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;
}
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 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 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 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 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)646 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)204 IOException (java.io.IOException)156 HashMap (java.util.HashMap)105 Map (java.util.Map)77 ArrayList (java.util.ArrayList)67 JsonNode (com.fasterxml.jackson.databind.JsonNode)53 List (java.util.List)50 Test (org.junit.Test)44 InputStream (java.io.InputStream)24 Collectors (java.util.stream.Collectors)24 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)23 Json (com.sequenceiq.cloudbreak.domain.json.Json)21 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)20 Function (java.util.function.Function)18 Test (org.testng.annotations.Test)18 File (java.io.File)17 Date (java.util.Date)17 UnsupportedEncodingException (java.io.UnsupportedEncodingException)15 URL (java.net.URL)15