diff options
Diffstat (limited to 'eaaf_modules')
-rw-r--r-- | eaaf_modules/eaaf_module_auth_sl20/src/main/java/at/gv/egiz/eaaf/modules/auth/sl20/utils/JsonMapper.java | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/eaaf_modules/eaaf_module_auth_sl20/src/main/java/at/gv/egiz/eaaf/modules/auth/sl20/utils/JsonMapper.java b/eaaf_modules/eaaf_module_auth_sl20/src/main/java/at/gv/egiz/eaaf/modules/auth/sl20/utils/JsonMapper.java index 043a39bc..b33649e1 100644 --- a/eaaf_modules/eaaf_module_auth_sl20/src/main/java/at/gv/egiz/eaaf/modules/auth/sl20/utils/JsonMapper.java +++ b/eaaf_modules/eaaf_module_auth_sl20/src/main/java/at/gv/egiz/eaaf/modules/auth/sl20/utils/JsonMapper.java @@ -1,6 +1,7 @@ package at.gv.egiz.eaaf.modules.auth.sl20.utils; import java.io.IOException; +import java.io.InputStream; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -51,7 +52,7 @@ public class JsonMapper implements IJsonMapper { log.debug("JSON object-mapper initialized"); } - + /* (non-Javadoc) * @at.gv.egiz.eaaf.core.api.utils.IJsonMapper#getMapper() @@ -86,8 +87,7 @@ public class JsonMapper implements IJsonMapper { try { if (clazz != null) { if (clazz.isAssignableFrom(TypeReference.class)) - return mapper.readValue(value, clazz); - + return mapper.readValue(value, clazz); else { final JavaType javaType = TypeFactory.defaultInstance().constructType(clazz); return mapper.readValue(value, javaType); @@ -104,5 +104,28 @@ public class JsonMapper implements IJsonMapper { } } + + @Override + public <T> Object deserialize(InputStream is, Class<T> clazz) throws EAAFJsonMapperException { + try { + if (clazz != null) { + if (clazz.isAssignableFrom(TypeReference.class)) + return mapper.readValue(is, clazz); + else { + final JavaType javaType = TypeFactory.defaultInstance().constructType(clazz); + return mapper.readValue(is, javaType); + + } + + } else + return mapper.readValue(is, Object.class); + + } catch (final IOException e) { + log.warn("JSON mapping FAILED with error: {}", e.getMessage()); + throw new EAAFJsonMapperException(e.getMessage(), e); + + } + + } } |