Class AbstractListenerHandler<ObjType>

  • Type Parameters:
    ObjType - A List of this type is expected in the input stream as JSON. Must be able to be converted to/from Map
    All Implemented Interfaces:
    ListenerHandler

    public abstract class AbstractListenerHandler<ObjType>
    extends Object
    implements ListenerHandler
    This is a simplified handler for announcement listeners. The input is expected to be a JSON list objects. Empty maps `{}` are taken care of at this level and never passed down to the subclass's handle method.
    • Constructor Detail

      • AbstractListenerHandler

        public AbstractListenerHandler​(com.fasterxml.jackson.core.type.TypeReference<ObjType> inObjTypeRef)
        The standard constructor takes in a type reference for the object and for a list of the object. This is to work around some limitations in Java with type erasure.
        Parameters:
        inObjTypeRef - The TypeReference for the input object type
    • Method Detail

      • handlePOST

        public final javax.ws.rs.core.Response handlePOST​(InputStream inputStream,
                                                          com.fasterxml.jackson.databind.ObjectMapper mapper,
                                                          String id)
        Specified by:
        handlePOST in interface ListenerHandler
      • handlePOSTAll

        public final javax.ws.rs.core.Response handlePOSTAll​(InputStream inputStream,
                                                             com.fasterxml.jackson.databind.ObjectMapper mapper)
        Specified by:
        handlePOSTAll in interface ListenerHandler
      • delete

        @Nullable
        protected abstract Object delete​(String id)
        Delete the object for a particular id
        Parameters:
        id - A string id of the object to be deleted. This id is never null or empty.
        Returns:
        The object to be returned in the entity. A NULL return will cause a 404 response. A non-null return will cause a 202 response. An Exception thrown will cause a 500 response.
      • get

        @Nullable
        protected abstract Object get​(String id)
        Get the object for a particular id
        Parameters:
        id - A string id of the object desired. This id is never null or empty.
        Returns:
        The object to be returned in the entity. A NULL return will cause a 404 response. A non-null return will cause a 200 response. An Exception thrown will cause a 500 response.
      • post

        @Nullable
        public abstract Object post​(Map<String,​ObjType> inputObject)
        Process a POST request of the input items
        Parameters:
        inputObject - A list of the objects which were POSTed
        Returns:
        An object to be returned in the entity of the response.