java.lang.Object
org.gcube.informationsystem.resourceregistry.api.exceptions.ExceptionMapper

public abstract class ExceptionMapper extends Object
The Class ExceptionMapper.
Author:
Luca Frosini (ISTI - CNR)
  • Field Details

    • mapper

      protected static final org.gcube.com.fasterxml.jackson.databind.ObjectMapper mapper
      The 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 given OutputStream .
      Type Parameters:
      T - the generic type
      RRE - the generic type
      Parameters:
      object - the resource
      stream - 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 exception
      org.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 given Writer .
      Type Parameters:
      T - the generic type
      RRE - the generic type
      Parameters:
      object - the resource
      writer - 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 exception
      org.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 given Reader.
      Type Parameters:
      RRE - the generic type
      Parameters:
      clz - the class of the resource
      reader - the reader
      Returns:
      the resource
      Throws:
      org.gcube.com.fasterxml.jackson.core.JsonParseException - the json parse exception
      org.gcube.com.fasterxml.jackson.databind.JsonMappingException - the json mapping exception
      IOException - 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 given InputStream.
      Type Parameters:
      RRE - the generic type
      Parameters:
      clz - the class of the resource
      stream - 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 exception
      org.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 resource
      string - the string
      Returns:
      the resource
      Throws:
      org.gcube.com.fasterxml.jackson.core.JsonParseException - the json parse exception
      org.gcube.com.fasterxml.jackson.databind.JsonMappingException - the json mapping exception
      IOException - Signals that an I/O exception has occurred.