Package org.cyclos.server.utils
Class JsonConverter
- java.lang.Object
-
- org.cyclos.server.utils.JsonConverter
-
@Component public class JsonConverter extends Object
Extends Jackson'sObjectMapperwith custom configuration
-
-
Field Summary
Fields Modifier and Type Field Description static List<String>BLACKLISTED_ERROR_PROPERTIES
-
Constructor Summary
Constructors Constructor Description JsonConverter()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanbeanIsSimpleLogNode(Bean bean)com.fasterxml.jackson.databind.node.ObjectNodeerrorToLogNode(Throwable error)Wraps an exception as a suitable object to be converted to JSON in a logcom.fasterxml.jackson.databind.ObjectMappergetObjectMapper()voidintialize()static Objectmask(Object owner, String property, Object value)If the given value should be masked, returns '***', otherwise, returns the value as is NOTE: In case there is a corresponding entity log handler implementation please ensure the property value is masked too.ObjectnodeValue(com.fasterxml.jackson.databind.JsonNode node)com.fasterxml.jackson.databind.JsonNodereadTree(byte[] content)com.fasterxml.jackson.databind.JsonNodereadTree(File file)com.fasterxml.jackson.databind.JsonNodereadTree(InputStream in)com.fasterxml.jackson.databind.JsonNodereadTree(Reader r)com.fasterxml.jackson.databind.JsonNodereadTree(String content)<T> TreadValue(byte[] src, Class<T> valueType)<T> TreadValue(File src, Class<T> valueType)<T> TreadValue(InputStream src, Class<T> valueType)<T> TreadValue(Reader src, Class<T> valueType)<T> TreadValue(String content, Class<T> valueType)<T> TreadValue(URL src, Class<T> valueType)com.fasterxml.jackson.databind.JsonNodetoLogNode(Object value, boolean input)booleanuseLogJsonAsProperty(com.fasterxml.jackson.databind.JsonNode json, Class<?> type)voidwriteValue(File resultFile, Object value)voidwriteValue(OutputStream out, Object value)voidwriteValue(Writer w, Object value)byte[]writeValueAsBytes(Object value)StringwriteValueAsString(Object value)
-
-
-
Method Detail
-
mask
public static Object mask(Object owner, String property, Object value)
If the given value should be masked, returns '***', otherwise, returns the value as is NOTE: In case there is a corresponding entity log handler implementation please ensure the property value is masked too. See EntityLogHandler (impl project)
-
beanIsSimpleLogNode
public boolean beanIsSimpleLogNode(Bean bean)
-
errorToLogNode
public com.fasterxml.jackson.databind.node.ObjectNode errorToLogNode(Throwable error) throws com.fasterxml.jackson.core.JsonProcessingException
Wraps an exception as a suitable object to be converted to JSON in a log- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
getObjectMapper
public com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
-
intialize
@PostConstruct public void intialize()
-
nodeValue
public Object nodeValue(com.fasterxml.jackson.databind.JsonNode node)
-
readTree
public com.fasterxml.jackson.databind.JsonNode readTree(byte[] content) throws com.fasterxml.jackson.core.JsonProcessingException- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
readTree
public com.fasterxml.jackson.databind.JsonNode readTree(File file) throws IOException, com.fasterxml.jackson.core.JsonProcessingException
- Throws:
IOExceptioncom.fasterxml.jackson.core.JsonProcessingException
-
readTree
public com.fasterxml.jackson.databind.JsonNode readTree(InputStream in) throws IOException, com.fasterxml.jackson.core.JsonProcessingException
- Throws:
IOExceptioncom.fasterxml.jackson.core.JsonProcessingException
-
readTree
public com.fasterxml.jackson.databind.JsonNode readTree(Reader r) throws IOException, com.fasterxml.jackson.core.JsonProcessingException
- Throws:
IOExceptioncom.fasterxml.jackson.core.JsonProcessingException
-
readTree
public com.fasterxml.jackson.databind.JsonNode readTree(String content) throws com.fasterxml.jackson.core.JsonProcessingException
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
readValue
public <T> T readValue(byte[] src, Class<T> valueType) throws com.fasterxml.jackson.core.JsonParseException, com.fasterxml.jackson.databind.JsonMappingException- Throws:
com.fasterxml.jackson.core.JsonParseExceptioncom.fasterxml.jackson.databind.JsonMappingException
-
readValue
public <T> T readValue(File src, Class<T> valueType) throws IOException, com.fasterxml.jackson.core.JsonParseException, com.fasterxml.jackson.databind.JsonMappingException
- Throws:
IOExceptioncom.fasterxml.jackson.core.JsonParseExceptioncom.fasterxml.jackson.databind.JsonMappingException
-
readValue
public <T> T readValue(InputStream src, Class<T> valueType) throws IOException, com.fasterxml.jackson.core.JsonParseException, com.fasterxml.jackson.databind.JsonMappingException
- Throws:
IOExceptioncom.fasterxml.jackson.core.JsonParseExceptioncom.fasterxml.jackson.databind.JsonMappingException
-
readValue
public <T> T readValue(Reader src, Class<T> valueType) throws IOException, com.fasterxml.jackson.core.JsonParseException, com.fasterxml.jackson.databind.JsonMappingException
- Throws:
IOExceptioncom.fasterxml.jackson.core.JsonParseExceptioncom.fasterxml.jackson.databind.JsonMappingException
-
readValue
public <T> T readValue(String content, Class<T> valueType) throws com.fasterxml.jackson.core.JsonParseException, com.fasterxml.jackson.databind.JsonMappingException
- Throws:
com.fasterxml.jackson.core.JsonParseExceptioncom.fasterxml.jackson.databind.JsonMappingException
-
readValue
public <T> T readValue(URL src, Class<T> valueType) throws IOException, com.fasterxml.jackson.core.JsonParseException, com.fasterxml.jackson.databind.JsonMappingException
- Throws:
IOExceptioncom.fasterxml.jackson.core.JsonParseExceptioncom.fasterxml.jackson.databind.JsonMappingException
-
toLogNode
public com.fasterxml.jackson.databind.JsonNode toLogNode(Object value, boolean input)
-
useLogJsonAsProperty
public boolean useLogJsonAsProperty(com.fasterxml.jackson.databind.JsonNode json, Class<?> type)
-
writeValue
public void writeValue(File resultFile, Object value) throws IOException, com.fasterxml.jackson.core.JsonGenerationException, com.fasterxml.jackson.databind.JsonMappingException
- Throws:
IOExceptioncom.fasterxml.jackson.core.JsonGenerationExceptioncom.fasterxml.jackson.databind.JsonMappingException
-
writeValue
public void writeValue(OutputStream out, Object value) throws IOException, com.fasterxml.jackson.core.JsonGenerationException, com.fasterxml.jackson.databind.JsonMappingException
- Throws:
IOExceptioncom.fasterxml.jackson.core.JsonGenerationExceptioncom.fasterxml.jackson.databind.JsonMappingException
-
writeValue
public void writeValue(Writer w, Object value) throws IOException, com.fasterxml.jackson.core.JsonGenerationException, com.fasterxml.jackson.databind.JsonMappingException
- Throws:
IOExceptioncom.fasterxml.jackson.core.JsonGenerationExceptioncom.fasterxml.jackson.databind.JsonMappingException
-
writeValueAsBytes
public byte[] writeValueAsBytes(Object value) throws IOException, com.fasterxml.jackson.core.JsonGenerationException, com.fasterxml.jackson.databind.JsonMappingException
- Throws:
IOExceptioncom.fasterxml.jackson.core.JsonGenerationExceptioncom.fasterxml.jackson.databind.JsonMappingException
-
-