use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonMappingException in project OpenClinica by OpenClinica.
the class XformMetaDataService method executeIndividualCrf.
public void executeIndividualCrf(ExecuteIndividualCrfObject eicObject) {
for (OCodmComplexTypeDefinitionFormLayoutDef formLayoutDef : eicObject.formLayoutDefs) {
List<String> fileLinks = null;
String vForm = "";
RestTemplate rest = new RestTemplate();
if (eicObject.form != null) {
List<FormVersion> versions = eicObject.form.getVersions();
for (FormVersion version : versions) {
if (version.getName().equals(formLayoutDef.getOID())) {
fileLinks = version.getFileLinks();
for (String fileLink : fileLinks) {
if (fileLink.endsWith(VERSION)) {
vForm = rest.getForObject(fileLink, String.class);
break;
}
}
if (!eicObject.errors.hasErrors()) {
ObjectMapper mapper = new ObjectMapper();
TypeReference<List<XformGroup>> mapType = new TypeReference<List<XformGroup>>() {
};
List<XformGroup> jsonList = null;
try {
jsonList = mapper.readValue(vForm, mapType);
} catch (JsonParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JsonMappingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
XformContainer xformContainer = new XformContainer();
xformContainer.setGroups(jsonList);
eicObject.setContainer(xformContainer);
if (eicObject.errors.hasErrors()) {
return;
}
// Save meta-data in database
saveFormMetadata(eicObject, version, eicObject.container, formLayoutDef, fileLinks);
}
}
}
}
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonMappingException in project jackson-databind by FasterXML.
the class TestInferredMutators method testFinalFieldIgnoral.
/*
/**********************************************************
/* Unit tests
/**********************************************************
*/
// for #190
public void testFinalFieldIgnoral() throws Exception {
ObjectMapper mapper = new ObjectMapper();
// default value is 'enabled', for backwards compatibility
assertTrue(mapper.isEnabled(MapperFeature.ALLOW_FINAL_FIELDS_AS_MUTATORS));
mapper.disable(MapperFeature.ALLOW_FINAL_FIELDS_AS_MUTATORS);
try {
/*p =*/
mapper.readValue("{\"x\":2}", FixedPoint.class);
fail("Should not try to use final field");
} catch (JsonMappingException e) {
verifyException(e, "unrecognized field \"x\"");
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonMappingException in project jackson-databind by FasterXML.
the class TestSubtypes method testErrorMessage.
public void testErrorMessage() throws Exception {
ObjectMapper mapper = new ObjectMapper();
try {
mapper.readValue("{ \"type\": \"z\"}", BaseX.class);
fail("Should have failed");
} catch (JsonMappingException e) {
verifyException(e, "known type ids =");
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonMappingException in project jackson-databind by FasterXML.
the class ClassUtil method throwAsMappingException.
/**
* @since 2.9
*/
public static <T> T throwAsMappingException(DeserializationContext ctxt, IOException e0) throws JsonMappingException {
if (e0 instanceof JsonMappingException) {
throw (JsonMappingException) e0;
}
JsonMappingException e = JsonMappingException.from(ctxt, e0.getMessage());
e.initCause(e0);
throw e;
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonMappingException in project jackson-databind by FasterXML.
the class FromStringDeserializer method deserialize.
/*
/**********************************************************
/* Deserializer implementations
/**********************************************************
*/
@SuppressWarnings("unchecked")
@Override
public T deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
// 22-Sep-2012, tatu: For 2.1, use this new method, may force coercion:
String text = p.getValueAsString();
if (text != null) {
// has String representation
if (text.length() == 0 || (text = text.trim()).length() == 0) {
// 04-Feb-2013, tatu: Usually should become null; but not always
return _deserializeFromEmptyString();
}
Exception cause = null;
try {
T result = _deserialize(text, ctxt);
if (result != null) {
return result;
}
} catch (IllegalArgumentException iae) {
cause = iae;
} catch (MalformedURLException me) {
cause = me;
}
String msg = "not a valid textual representation";
if (cause != null) {
String m2 = cause.getMessage();
if (m2 != null) {
msg = msg + ", problem: " + m2;
}
}
// 05-May-2016, tatu: Unlike most usage, this seems legit, so...
JsonMappingException e = ctxt.weirdStringException(text, _valueClass, msg);
if (cause != null) {
e.initCause(cause);
}
throw e;
// nothing to do here, yet? We'll fail anyway
}
JsonToken t = p.getCurrentToken();
// [databind#381]
if (t == JsonToken.START_ARRAY && ctxt.isEnabled(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS)) {
p.nextToken();
final T value = deserialize(p, ctxt);
if (p.nextToken() != JsonToken.END_ARRAY) {
handleMissingEndArrayForSingle(p, ctxt);
}
return value;
}
if (t == JsonToken.VALUE_EMBEDDED_OBJECT) {
// Trivial cases; null to null, instance of type itself returned as is
Object ob = p.getEmbeddedObject();
if (ob == null) {
return null;
}
if (_valueClass.isAssignableFrom(ob.getClass())) {
return (T) ob;
}
return _deserializeEmbedded(ob, ctxt);
}
return (T) ctxt.handleUnexpectedToken(_valueClass, p);
}
Aggregations