Class RequestTypeManager

java.lang.Object
org.aktin.broker.util.RequestTypeManager

public class RequestTypeManager
extends Object
A request type manager allows verification of request resources against a specified media type as well as conversion to other types.

The type conversion is done on demand per request. The result is transferred to the client and not stored in the database.

Author:
R.W.Majeed
  • Constructor Details

    • RequestTypeManager

      public RequestTypeManager()
  • Method Details

    • converterForType

      public RequestConverter converterForType​(String out, String in)
      If a GET request with a specified Accept media type can not be satisfied from the database, a converter is searched (which is expected to produce that type).

      If a converter is available for the specified media type, the converter's input type is retrieved and checked that the input type can be satisfied from the database or if additional converters need to be chained.

      Parameters:
      out - produced type
      in - consumed type
      Returns:
      converter converting between the given types, or null if not found.
    • buildConverterChain

      public RequestConverter buildConverterChain​(List<javax.ws.rs.core.MediaType> accept, List<javax.ws.rs.core.MediaType> resources)
      Build a converter chain which produces an acceptable (in order of preference) request and consumes one of the available resource types.

      The returned RequestConverter may be a virtual converter which invokes multiple chained converters to produce the desired result. The chained converter path may be cached to speed up successive requests.

      Parameters:
      accept - list of accepted types
      resources - list of available resource types
      Returns:
      converter or null if not possible.
    • createMediaTypes

      public javax.ws.rs.core.MediaType[] createMediaTypes​(List<String> types)