Search in sources :

Example 56 with JsonMappingException

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonMappingException in project spring-boot by spring-projects.

the class JsonObjectDeserializer method deserialize.

@Override
public final T deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
    try {
        ObjectCodec codec = jp.getCodec();
        JsonNode tree = codec.readTree(jp);
        return deserializeObject(jp, ctxt, codec, tree);
    } catch (Exception ex) {
        if (ex instanceof IOException) {
            throw (IOException) ex;
        }
        throw new JsonMappingException(jp, "Object deserialize error", ex);
    }
}
Also used : JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) JsonNode(com.fasterxml.jackson.databind.JsonNode) ObjectCodec(com.fasterxml.jackson.core.ObjectCodec) IOException(java.io.IOException) IOException(java.io.IOException) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException)

Example 57 with JsonMappingException

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonMappingException in project dhis2-core by dhis2.

the class JacksonRelationshipService method addRelationshipsXml.

@Override
public ImportSummaries addRelationshipsXml(InputStream inputStream, ImportOptions importOptions) throws IOException {
    String input = StreamUtils.copyToString(inputStream, Charset.forName("UTF-8"));
    List<Relationship> relationships = new ArrayList<>();
    try {
        Relationships fromXml = fromXml(input, Relationships.class);
        relationships.addAll(fromXml.getRelationships());
    } catch (JsonMappingException ex) {
        Relationship fromXml = fromXml(input, Relationship.class);
        relationships.add(fromXml);
    }
    return processRelationshipList(relationships, updateImportOptions(importOptions));
}
Also used : Relationships(org.hisp.dhis.dxf2.events.trackedentity.Relationships) Relationship(org.hisp.dhis.dxf2.events.trackedentity.Relationship) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) ArrayList(java.util.ArrayList)

Example 58 with JsonMappingException

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonMappingException in project uPortal by Jasig.

the class AnalyticsIncorporationComponent method serializePortletRenderExecutionEvents.

protected String serializePortletRenderExecutionEvents(final Set<PortalEvent> portalEvents) {
    // Filter to include just portlet render events
    final Map<String, PortletRenderExecutionEvent> renderEvents = new HashMap<>();
    for (final PortalEvent portalEvent : portalEvents) {
        if (portalEvent instanceof PortletRenderExecutionEvent) {
            final PortletRenderExecutionEvent portletRenderEvent = (PortletRenderExecutionEvent) portalEvent;
            // Don't write out info for minimized portlets
            if (!WindowState.MINIMIZED.equals(portletRenderEvent.getWindowState())) {
                final IPortletWindowId portletWindowId = portletRenderEvent.getPortletWindowId();
                final String eventKey = portletWindowId != null ? portletWindowId.getStringId() : portletRenderEvent.getFname();
                renderEvents.put(eventKey, portletRenderEvent);
            }
        }
    }
    try {
        return portletEventWriter.writeValueAsString(renderEvents);
    } catch (JsonParseException e) {
        logger.warn("Failed to convert this request's render events to JSON, no portlet level analytics will be included", e);
    } catch (JsonMappingException e) {
        logger.warn("Failed to convert this request's render events to JSON, no portlet level analytics will be included", e);
    } catch (IOException e) {
        logger.warn("Failed to convert this request's render events to JSON, no portlet level analytics will be included", e);
    }
    return "{}";
}
Also used : PortalEvent(org.apereo.portal.events.PortalEvent) HashMap(java.util.HashMap) PortletRenderExecutionEvent(org.apereo.portal.events.PortletRenderExecutionEvent) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) IOException(java.io.IOException) JsonParseException(com.fasterxml.jackson.core.JsonParseException) IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId)

Example 59 with JsonMappingException

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonMappingException in project graylog2-server by Graylog2.

the class RetentionStrategyResource method getRetentionStrategyDescription.

private RetentionStrategyDescription getRetentionStrategyDescription(@ApiParam(name = "strategy", value = "The name of the retention strategy", required = true) @PathParam("strategy") @NotEmpty String strategyName) {
    final Provider<RetentionStrategy> provider = retentionStrategies.get(strategyName);
    if (provider == null) {
        throw new NotFoundException("Couldn't find retention strategy for given type " + strategyName);
    }
    final RetentionStrategy retentionStrategy = provider.get();
    final RetentionStrategyConfig defaultConfig = retentionStrategy.defaultConfiguration();
    final SchemaFactoryWrapper visitor = new SchemaFactoryWrapper();
    try {
        objectMapper.acceptJsonFormatVisitor(objectMapper.constructType(retentionStrategy.configurationClass()), visitor);
    } catch (JsonMappingException e) {
        throw new InternalServerErrorException("Couldn't generate JSON schema for retention strategy " + strategyName, e);
    }
    return RetentionStrategyDescription.create(strategyName, defaultConfig, visitor.finalSchema());
}
Also used : RetentionStrategyConfig(org.graylog2.plugin.indexer.retention.RetentionStrategyConfig) RetentionStrategy(org.graylog2.plugin.indexer.retention.RetentionStrategy) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) NotFoundException(javax.ws.rs.NotFoundException) SchemaFactoryWrapper(com.fasterxml.jackson.module.jsonSchema.factories.SchemaFactoryWrapper) InternalServerErrorException(javax.ws.rs.InternalServerErrorException)

Example 60 with JsonMappingException

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonMappingException in project graylog2-server by Graylog2.

the class EncryptedValueDeserializer method parseFromDatabase.

private EncryptedValue parseFromDatabase(JsonParser p, JsonNode node) throws JsonProcessingException {
    final JsonNode value = node.path("encrypted_value");
    final JsonNode salt = node.path("salt");
    if (value.isTextual() && salt.isTextual()) {
        return EncryptedValue.builder().value(value.asText()).salt(salt.asText()).isKeepValue(false).isDeleteValue(false).build();
    }
    throw new JsonMappingException(p, "Couldn't deserialize value: " + node.toString() + " (encrypted_value and salt must be a strings and cannot missing)");
}
Also used : JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Aggregations

JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)185 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)93 IOException (java.io.IOException)80 JsonParseException (com.fasterxml.jackson.core.JsonParseException)57 Test (org.junit.Test)45 ATTest (org.jboss.eap.additional.testsuite.annotations.ATTest)33 JsonGenerationException (com.fasterxml.jackson.core.JsonGenerationException)24 ArrayList (java.util.ArrayList)16 Map (java.util.Map)16 JsonNode (com.fasterxml.jackson.databind.JsonNode)15 File (java.io.File)15 HashMap (java.util.HashMap)15 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)13 InputStream (java.io.InputStream)11 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)10 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)8 ByteArrayOutputStream (java.io.ByteArrayOutputStream)8 List (java.util.List)8 Writer (org.alfresco.rest.framework.jacksonextensions.JacksonHelper.Writer)7 Test (org.junit.jupiter.api.Test)6