Class ExceptionMapper
java.lang.Object
org.gcube.informationsystem.resourceregistry.api.exceptions.ExceptionMapper
The Class ExceptionMapper.
- Author:
- Luca Frosini (ISTI - CNR)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final org.gcube.com.fasterxml.jackson.databind.ObjectMapperThe mapper. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.gcube.com.fasterxml.jackson.databind.ObjectMapperGets the object mapper.static <RRE extends ResourceRegistryException>
Stringmarshal(RRE object) Return the String serialization of a given resource.static <T extends OutputStream,RRE extends ResourceRegistryException>
Tmarshal(RRE object, T stream) Write the serialization of a given resource to a givenOutputStream.static <RRE extends ResourceRegistryException>
RREunmarshal(Class<RRE> clz, InputStream stream) Creates a resource of given class from its serialization in a givenInputStream.static <RRE extends ResourceRegistryException>
RRECreates a resource of given class from its serialization in a givenReader.static <RRE extends ResourceRegistryException>
RRECreates a resource of given class from its serialization in a given String.
-
Field Details
-
mapper
protected static final org.gcube.com.fasterxml.jackson.databind.ObjectMapper mapperThe mapper.
-
-
Constructor Details
-
ExceptionMapper
public ExceptionMapper()
-
-
Method Details
-
getObjectMapper
public static org.gcube.com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()Gets the object mapper.- Returns:
- the ObjectMapper
-
marshal
public static <T extends OutputStream,RRE extends ResourceRegistryException> T marshal(RRE object, T stream) throws org.gcube.com.fasterxml.jackson.core.JsonGenerationException, org.gcube.com.fasterxml.jackson.databind.JsonMappingException, IOException Write the serialization of a given resource to a givenOutputStream.- Type Parameters:
T- the generic typeRRE- the generic type- Parameters:
object- the resourcestream- the stream in input- Returns:
- the t
- Throws:
IOException- Signals that an I/O exception has occurred.org.gcube.com.fasterxml.jackson.databind.JsonMappingException- the json mapping exceptionorg.gcube.com.fasterxml.jackson.core.JsonGenerationException- the json generation exception
-
marshal
public static <T extends Writer,RRE extends ResourceRegistryException> T marshal(RRE object, T writer) throws org.gcube.com.fasterxml.jackson.core.JsonGenerationException, org.gcube.com.fasterxml.jackson.databind.JsonMappingException, IOException Write the serialization of a given resource to a givenWriter.- Type Parameters:
T- the generic typeRRE- the generic type- Parameters:
object- the resourcewriter- the writer in input- Returns:
- the t
- Throws:
IOException- Signals that an I/O exception has occurred.org.gcube.com.fasterxml.jackson.databind.JsonMappingException- the json mapping exceptionorg.gcube.com.fasterxml.jackson.core.JsonGenerationException- the json generation exception
-
marshal
public static <RRE extends ResourceRegistryException> String marshal(RRE object) throws org.gcube.com.fasterxml.jackson.core.JsonProcessingException Return the String serialization of a given resource.- Type Parameters:
RRE- the generic type- Parameters:
object- the resource- Returns:
- the String serialization of a given resource
- Throws:
org.gcube.com.fasterxml.jackson.core.JsonProcessingException- the json processing exception
-
unmarshal
public static <RRE extends ResourceRegistryException> RRE unmarshal(Class<RRE> clz, Reader reader) throws org.gcube.com.fasterxml.jackson.core.JsonParseException, org.gcube.com.fasterxml.jackson.databind.JsonMappingException, IOException Creates a resource of given class from its serialization in a givenReader.- Type Parameters:
RRE- the generic type- Parameters:
clz- the class of the resourcereader- the reader- Returns:
- the resource
- Throws:
org.gcube.com.fasterxml.jackson.core.JsonParseException- the json parse exceptionorg.gcube.com.fasterxml.jackson.databind.JsonMappingException- the json mapping exceptionIOException- Signals that an I/O exception has occurred.
-
unmarshal
public static <RRE extends ResourceRegistryException> RRE unmarshal(Class<RRE> clz, InputStream stream) throws org.gcube.com.fasterxml.jackson.core.JsonParseException, org.gcube.com.fasterxml.jackson.databind.JsonMappingException, IOException Creates a resource of given class from its serialization in a givenInputStream.- Type Parameters:
RRE- the generic type- Parameters:
clz- the class of the resourcestream- the stream- Returns:
- the resource
- Throws:
IOException- Signals that an I/O exception has occurred.org.gcube.com.fasterxml.jackson.databind.JsonMappingException- the json mapping exceptionorg.gcube.com.fasterxml.jackson.core.JsonParseException- the json parse exception
-
unmarshal
public static <RRE extends ResourceRegistryException> RRE unmarshal(Class<RRE> clz, String string) throws org.gcube.com.fasterxml.jackson.core.JsonParseException, org.gcube.com.fasterxml.jackson.databind.JsonMappingException, IOException Creates a resource of given class from its serialization in a given String.- Type Parameters:
RRE- the generic type- Parameters:
clz- the class of the resourcestring- the string- Returns:
- the resource
- Throws:
org.gcube.com.fasterxml.jackson.core.JsonParseException- the json parse exceptionorg.gcube.com.fasterxml.jackson.databind.JsonMappingException- the json mapping exceptionIOException- Signals that an I/O exception has occurred.
-