Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,24 @@ public class AttachableResponseDeserializer extends JsonDeserializer<AttachableR
* variable ATTACHABLE
*/
private static final String ATTACHABLE = "Attachable";


/** Shared ObjectMapper instance (thread-safe, reuse for performance) */
@SuppressWarnings("deprecation")
private static final ObjectMapper mapper;
static {
mapper = new ObjectMapper();
mapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS, true);
AnnotationIntrospector primary = new JaxbAnnotationIntrospector();
AnnotationIntrospector secondary = new JacksonAnnotationIntrospector();
mapper.setAnnotationIntrospector(new AnnotationIntrospectorPair(primary, secondary));
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}

/**
* {@inheritDoc}}
*/
@SuppressWarnings("deprecation")
@Override
public AttachableResponse deserialize(JsonParser jp, DeserializationContext desContext) throws IOException {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS,true);
//Make the mapper JAXB annotations aware
AnnotationIntrospector primary = new JaxbAnnotationIntrospector();
AnnotationIntrospector secondary = new JacksonAnnotationIntrospector();
AnnotationIntrospector pair = new AnnotationIntrospectorPair(primary, secondary);
mapper.setAnnotationIntrospector(pair);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

//Read the QueryResponse as a tree
JsonNode jn = jp.readValueAsTree();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,17 @@ public class BatchItemRequestSerializer extends JsonSerializer<BatchItemRequest>
*/
private static final String OPTIONS_DATA = "optionsData";

/** Shared ObjectMapper instance (thread-safe, reuse for performance) */
@SuppressWarnings("deprecation")
private static final ObjectMapper mapper;
static {
mapper = new ObjectMapper();
AnnotationIntrospector primary = new JacksonAnnotationIntrospector();
AnnotationIntrospector secondary = new JaxbAnnotationIntrospector(mapper.getTypeFactory());
mapper.setAnnotationIntrospector(new AnnotationIntrospectorPair(primary, secondary));
mapper.setSerializationInclusion(Include.NON_NULL);
}

@Override
public void serialize(BatchItemRequest batchItemRequest, JsonGenerator jgen, SerializerProvider provider) throws IOException {

Expand Down Expand Up @@ -161,14 +172,6 @@ private String getCDCQueryJson(CDCQuery cdcQuery) throws SerializationException
* @return ObjectMapper the object mapper
*/
private ObjectMapper getObjectMapper() {
ObjectMapper mapper = new ObjectMapper();
AnnotationIntrospector primary = new JacksonAnnotationIntrospector();
AnnotationIntrospector secondary = new JaxbAnnotationIntrospector(mapper.getTypeFactory());
AnnotationIntrospector pair = new AnnotationIntrospectorPair(primary, secondary);

mapper.setAnnotationIntrospector(pair);
mapper.setSerializationInclusion(Include.NON_NULL);

return mapper;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,23 @@ public class BatchItemResponseDeserializer extends JsonDeserializer<BatchItemRes
*/
private ObjectFactory objFactory = new ObjectFactory();

/** Shared ObjectMapper instance (thread-safe, reuse for performance) */
@SuppressWarnings("deprecation")
private static final ObjectMapper mapper;
static {
mapper = new ObjectMapper();
mapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS, true);
AnnotationIntrospector primary = new JaxbAnnotationIntrospector();
AnnotationIntrospector secondary = new JacksonAnnotationIntrospector();
mapper.setAnnotationIntrospector(new AnnotationIntrospectorPair(primary, secondary));
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}

/**
* {@inheritDoc}}
*/
@SuppressWarnings("deprecation")
@Override
public BatchItemResponse deserialize(JsonParser jp, DeserializationContext desContext) throws IOException {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS,true);
//Make the mapper JAXB annotations aware
AnnotationIntrospector primary = new JaxbAnnotationIntrospector();
AnnotationIntrospector secondary = new JacksonAnnotationIntrospector();
AnnotationIntrospector pair = new AnnotationIntrospectorPair(primary, secondary);
mapper.setAnnotationIntrospector(pair);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

//Read the QueryResponse as a tree
JsonNode jn = jp.readValueAsTree();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,21 @@ public class CDCQueryResponseDeserializer extends JsonDeserializer<CDCResponse>
* variable QUERY_RESPONSE
*/
private static final String QUERY_RESPONSE = "QueryResponse";


/** Shared ObjectMapper instance (thread-safe, reuse for performance) */
@SuppressWarnings("deprecation")
@Override
public CDCResponse deserialize(JsonParser jp, DeserializationContext desContext) throws IOException {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS,true);
//Make the mapper JAXB annotations aware
private static final ObjectMapper mapper;
static {
mapper = new ObjectMapper();
mapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS, true);
AnnotationIntrospector primary = new JaxbAnnotationIntrospector();
AnnotationIntrospector secondary = new JacksonAnnotationIntrospector();
AnnotationIntrospector pair = new AnnotationIntrospectorPair(primary, secondary);
mapper.setAnnotationIntrospector(pair);
mapper.setAnnotationIntrospector(new AnnotationIntrospectorPair(primary, secondary));
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}

@Override
public CDCResponse deserialize(JsonParser jp, DeserializationContext desContext) throws IOException {

//Read the QueryResponse as a tree
JsonNode jn = jp.readValueAsTree();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,21 @@ public class CustomFieldDefinitionDeserializer extends JsonDeserializer<CustomFi
* variable FAULT
*/
private static final String TYPE = "Type";


/** Shared ObjectMapper instance (thread-safe, reuse for performance) */
@SuppressWarnings("deprecation")
@Override
public CustomFieldDefinition deserialize(JsonParser jp, DeserializationContext desContext) throws IOException {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS,true);
//Make the mapper JAXB annotations aware
private static final ObjectMapper mapper;
static {
mapper = new ObjectMapper();
mapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS, true);
AnnotationIntrospector primary = new JaxbAnnotationIntrospector();
AnnotationIntrospector secondary = new JacksonAnnotationIntrospector();
AnnotationIntrospector pair = new AnnotationIntrospectorPair(primary, secondary);
mapper.setAnnotationIntrospector(pair);
mapper.setAnnotationIntrospector(new AnnotationIntrospectorPair(primary, secondary));
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}

@Override
public CustomFieldDefinition deserialize(JsonParser jp, DeserializationContext desContext) throws IOException {

//Read the CustomFieldDefinition as a tree
JsonNode jn = jp.readValueAsTree();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,23 +135,25 @@ public class IntuitResponseDeserializer extends JsonDeserializer<IntuitResponse>
*/
private ObjectFactory objFactory = new ObjectFactory();

/** Shared ObjectMapper instance (thread-safe, reuse for performance) */
@SuppressWarnings("deprecation")
private static final ObjectMapper mapper;
static {
mapper = new ObjectMapper();
mapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS, true);
AnnotationIntrospector primary = new JaxbAnnotationIntrospector();
AnnotationIntrospector secondary = new JacksonAnnotationIntrospector();
mapper.setAnnotationIntrospector(new AnnotationIntrospectorPair(primary, secondary));
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}

/**
* {@inheritDoc}}
*/
@SuppressWarnings("deprecation")
@Override
public IntuitResponse deserialize(JsonParser jp, DeserializationContext desContext)
throws IOException {
ObjectMapper mapper = new ObjectMapper();
Report report = new Report();
mapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS,true);
//Make the mapper JAXB annotations aware
AnnotationIntrospector primary = new JaxbAnnotationIntrospector();
AnnotationIntrospector secondary = new JacksonAnnotationIntrospector();
AnnotationIntrospector pair = new AnnotationIntrospectorPair(primary, secondary);
mapper.setAnnotationIntrospector(pair);

mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);


//Read the QueryResponse as a tree
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,31 @@ public class JSONSerializer implements IEntitySerializer {
*/
private static final org.slf4j.Logger LOG = Logger.getLogger();

/** Shared ObjectMapper for serialization (thread-safe, reuse for performance) */
@SuppressWarnings("deprecation")
private static final ObjectMapper serializeMapper;
static {
serializeMapper = new ObjectMapper();
AnnotationIntrospector primary = new JacksonAnnotationIntrospector();
AnnotationIntrospector secondary = new JaxbAnnotationIntrospector(serializeMapper.getTypeFactory());
serializeMapper.setAnnotationIntrospector(new AnnotationIntrospectorPair(primary, secondary));
serializeMapper.setSerializationInclusion(Include.NON_NULL);
}

/** Shared ObjectMapper for deserialization (thread-safe, reuse for performance) */
private static final ObjectMapper deserializeMapper;
static {
deserializeMapper = new ObjectMapper();
deserializeMapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS, true);
SimpleModule simpleModule = new SimpleModule("IntuitResponseDeserializer", new Version(1, 0, 0, null));
simpleModule.addDeserializer(IntuitResponse.class, new IntuitResponseDeserializer());
deserializeMapper.registerModule(simpleModule);
simpleModule = new SimpleModule("TaxServiceDeserializer", new Version(1, 0, 0, null));
simpleModule.addDeserializer(TaxService.class, new TaxServiceDeserializer());
deserializeMapper.registerModule(simpleModule);
deserializeMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}

/**
* {@inheritDoc}
*/
Expand All @@ -244,14 +269,7 @@ public <T> String serialize(T object) throws SerializationException {
return null;
}

ObjectMapper mapper = new ObjectMapper();
AnnotationIntrospector primary = new JacksonAnnotationIntrospector();
AnnotationIntrospector secondary = new JaxbAnnotationIntrospector(mapper.getTypeFactory());
AnnotationIntrospector pair = new AnnotationIntrospectorPair(primary, secondary);

mapper.setAnnotationIntrospector(pair);
mapper.setSerializationInclusion(Include.NON_NULL);

ObjectMapper mapper = serializeMapper.copy();
registerModulesForEnum(mapper);

SimpleModule testModule = new SimpleModule("BatchItemRequest", new Version(1, 0, 0, null));
Expand Down Expand Up @@ -285,16 +303,7 @@ public <T> String serialize(T object) throws SerializationException {
public Response deserialize(String json, Class<?> cl) throws SerializationException {

Response intuitResponse = null;
ObjectMapper mapper = new ObjectMapper();
mapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS,true);
SimpleModule simpleModule = new SimpleModule("IntuitResponseDeserializer", new Version(1, 0, 0, null));
simpleModule.addDeserializer(IntuitResponse.class, new IntuitResponseDeserializer());
mapper.registerModule(simpleModule);

simpleModule = new SimpleModule("TaxServiceDeserializer", new Version(1, 0, 0, null));
simpleModule.addDeserializer(TaxService.class, new TaxServiceDeserializer());
mapper.registerModule(simpleModule);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
ObjectMapper mapper = deserializeMapper;



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,20 @@ public class QueryResponseDeserializer extends JsonDeserializer<QueryResponse> {
*/
private ObjectFactory objFactory = new ObjectFactory();

/** Shared ObjectMapper instance (thread-safe, reuse for performance) */
@SuppressWarnings("deprecation")
@Override
public QueryResponse deserialize(JsonParser jp, DeserializationContext desContext) throws IOException {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS,true);
//Make the mapper JAXB annotations aware
private static final ObjectMapper mapper;
static {
mapper = new ObjectMapper();
mapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS, true);
AnnotationIntrospector primary = new JaxbAnnotationIntrospector();
AnnotationIntrospector secondary = new JacksonAnnotationIntrospector();
AnnotationIntrospector pair = new AnnotationIntrospectorPair(primary, secondary);
mapper.setAnnotationIntrospector(pair);
mapper.setAnnotationIntrospector(new AnnotationIntrospectorPair(primary, secondary));
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}

@Override
public QueryResponse deserialize(JsonParser jp, DeserializationContext desContext) throws IOException {

//Read the QueryResponse as a tree
JsonNode jn = jp.readValueAsTree();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,17 @@
import com.intuit.ipp.util.Logger;

public class SyncErrorDeserializer extends JsonDeserializer<SyncError> {

ObjectMapper mapper = new ObjectMapper();

/** Shared ObjectMapper instance (thread-safe, reuse for performance) */
@SuppressWarnings("deprecation")
private static final ObjectMapper mapper;
static {
mapper = new ObjectMapper();
AnnotationIntrospector primary = new JaxbAnnotationIntrospector();
AnnotationIntrospector secondary = new JacksonAnnotationIntrospector();
mapper.setAnnotationIntrospector(new AnnotationIntrospectorPair(primary, secondary));
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}

/**
* logger instance
Expand Down Expand Up @@ -74,17 +83,8 @@ public class SyncErrorDeserializer extends JsonDeserializer<SyncError> {
*/
private ObjectFactory objFactory = new ObjectFactory();

@SuppressWarnings("deprecation")
@Override
public SyncError deserialize(JsonParser jp, DeserializationContext desContext) throws IOException {


//Make the mapper JAXB annotations aware
AnnotationIntrospector primary = new JaxbAnnotationIntrospector();
AnnotationIntrospector secondary = new JacksonAnnotationIntrospector();
AnnotationIntrospector pair = new AnnotationIntrospectorPair(primary, secondary);
mapper.setAnnotationIntrospector(pair);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

//Read the QueryResponse as a tree
JsonNode jn = jp.readValueAsTree();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,20 @@ public class SyncErrorResponseDeserializer extends JsonDeserializer<SyncErrorRes
*/
private static final String LATESTUPLOADTIME = "latestUploadTime";

/** Shared ObjectMapper instance (thread-safe, reuse for performance) */
@SuppressWarnings("deprecation")
@Override
public SyncErrorResponse deserialize(JsonParser jp, DeserializationContext desContext) throws IOException {
ObjectMapper mapper = new ObjectMapper();

DateFormat date = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");


//Make the mapper JAXB annotations aware
private static final ObjectMapper mapper;
static {
mapper = new ObjectMapper();
AnnotationIntrospector primary = new JaxbAnnotationIntrospector();
AnnotationIntrospector secondary = new JacksonAnnotationIntrospector();
AnnotationIntrospector pair = new AnnotationIntrospectorPair(primary, secondary);
mapper.setAnnotationIntrospector(pair);
mapper.setAnnotationIntrospector(new AnnotationIntrospectorPair(primary, secondary));
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}

@Override
public SyncErrorResponse deserialize(JsonParser jp, DeserializationContext desContext) throws IOException {
DateFormat date = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");

//Read the QueryResponse as a tree
JsonNode jn = jp.readValueAsTree();
Expand Down
Loading