Tricia Help
Last edited Nov 8, 2011
Tags: no tags assigned  

Class Handler

in package de.infoasset.platform.handler

Declaration
public abstract class Handler
extends Object
Hierarchy
java.lang.Object
  extendsde.infoasset.platform.handler.Handler
Known Direct Subclasses
Subclasses of this class are responsible for handling HTTP requests in Tricia.

The handling of a request happens in 6 stages. A visualization of these stages can be found here:

  1. At first the session (see Session) is identified and the client context is initialized (see RequestLocal and ServerMode). This is done automatically by the class HttpServer.
  2. In a second step the handler which is responsible for handling the request is identified. This is done by the HandlerDispatcher, which creates an instance of the identified handler class.
  3. The handler checks whether the current session is allowed to call this handler. This is done by implementing the method checkAccess().
  4. The handler executes business logic, which in most cases involves the manipulation of the state of Assets. This is done by implementing the method doBusinessLogic(). This method returns an object of type Station, which is responsible for the next step.
  5. The Station either forwards the request to another Handler (this is done by Lines, step 6a in the figure above) or sends an answer page back (using a subclass of AnswerStation, step 6b in the figure above).

A typical handler will have the following attributes:

  • One variable per request parameter, which should be set in the checkAccess() or doBusinessLogic() method using a static method of Parameters.
  • All Stations, which are defined as a final field using anonymous inner classes.
  • Constructor Summary

    Handler()

    Method Summary

    protected void
    afterStationHook()
    void
    checkAccess()
    Based on the extracted parameters a handler performs in this method all operations necessary to evaluate whether the current session user is authorized to do the operation of this handler.
    void
    checkAccessExtensions()
    static Station
    createJSONErrorStation()
    static Station
    createJSONErrorStation(String errorMessage)
    static Station
    createJSONErrorStation(String errorMessage, Map additionalParameters)
    static Station
    createJSONSuccessStation()
    static Station
    createJSONSuccessStation(Map keyValues)
    abstract Station
    doBusinessLogic()
    Only in this method manipulations on the persistent state of Assets is permitted.
    protected Station
    extension(Station station)
    Message
    getBreadcrumbLabel()
    static String
    getDateTime(Date date)
    Print a date and time depending on its value.
    protected Line
    getDefaultGoToEditStation(Entity entity)
    Response
    getResponse()
    static NameValue[]
    getTagNameValues(String[] tags, NameValue[] params)
    Message
    getTargetLabel()
    void
    goToParentBreadCrumb(Forwarder f)
    boolean
    hideForAnonymousUsers()

    Field Detail

    DELETE_CONFIRMATION

    public static final ParameterizedMessage DELETE_CONFIRMATION

    protectedActionError

    public static final Message protectedActionError

    GET_STATIONS

    public static final String GET_STATIONS

    withoutYearDateFormat

    public static SimpleDateFormat withoutYearDateFormat

    withYearDateFormat

    public static final SimpleDateFormat withYearDateFormat

    timeDifferenceLessOneMinute

    public static final Message timeDifferenceLessOneMinute

    timeDifferenceMinutesPostfix

    public static final Message timeDifferenceMinutesPostfix

    timeDifferenceOneHour

    public static final Message timeDifferenceOneHour

    timeDifferenceHoursPostfix

    public static final Message timeDifferenceHoursPostfix

    secondsOfADay

    public static int secondsOfADay

    PARAMETER_TAG

    public static final String PARAMETER_TAG

    Constructor Detail

    Handler

    public Handler()

    Method Detail

    getResponse

    public final Response getResponse()
                               throws Throwable

    afterStationHook

    protected void afterStationHook()

    checkAccessExtensions

    public void checkAccessExtensions()

    doBusinessLogic

    public abstract Station doBusinessLogic()

    checkAccess

    public void checkAccess()

    getDateTime

    public static String getDateTime(Date date)

    extension

    protected Station extension(Station station)

    getDefaultGoToEditStation

    protected Line getDefaultGoToEditStation(Entity entity)

    goToParentBreadCrumb

    public void goToParentBreadCrumb(Forwarder f)

    getBreadcrumbLabel

    public Message getBreadcrumbLabel()

    getTargetLabel

    public Message getTargetLabel()

    createJSONSuccessStation

    public static Station createJSONSuccessStation()

    createJSONSuccessStation

    public static Station createJSONSuccessStation(Map keyValues)

    createJSONErrorStation

    public static Station createJSONErrorStation()

    createJSONErrorStation

    public static Station createJSONErrorStation(String errorMessage)

    createJSONErrorStation

    public static Station createJSONErrorStation(String errorMessage,
                                                 Map additionalParameters)

    hideForAnonymousUsers

    public boolean hideForAnonymousUsers()

    getTagNameValues

    public static NameValue[] getTagNameValues(String[] tags,
                                             NameValue[] params)

    0 Comments