Class HTTPControllerClient

  • All Implemented Interfaces:
    Controller

    public class HTTPControllerClient
    extends Object
    implements Controller
    Client side communication with http controller server. This class works on a specific response object, simply forwarding it to the given url. Thus an instance of this class is a use-once-object.

    The class is supposed to be used in JSP pages in order to make sure that the remote URI is requested through the browser, so communication with the HTTPControllerServer is done to the one currently set as viewer proxy.

    • Constructor Detail

      • HTTPControllerClient

        public HTTPControllerClient​(javax.servlet.http.HttpServletResponse response,
                                    javax.servlet.jsp.JspWriter out,
                                    String returnURL)
        Make an HTTP controller client. Commands are sent using redirect on the given http response object. For commands with no output, the page is then forwarded to the response url.
        Parameters:
        response - The response object to use for redirect.
        out - The JspWriter used to communicate with the users.
        returnURL - The URL to return to afterwards if no output is given. This must not be null or not empty if either startRecordingURIs, stopRecordingURIs, changeIndex or clearRecordedURIs are called.
    • Method Detail

      • startRecordingURIs

        public void startRecordingURIs()
        Start recording URIs and return to return URL.
        Specified by:
        startRecordingURIs in interface Controller
      • stopRecordingURIs

        public void stopRecordingURIs()
        Stop recording URIs and return to return URL.
        Specified by:
        stopRecordingURIs in interface Controller
      • clearRecordedURIs

        public void clearRecordedURIs()
        Clear recorded URIs and return to return URL.
        Specified by:
        clearRecordedURIs in interface Controller
      • redirectForSimpleCommand

        protected void redirectForSimpleCommand​(String command,
                                                boolean useReturnURL)
        Perform the necessary redirection to execute a simple (parameterless) command. Checks, that the returnURL is neither null or not empty.
        Parameters:
        command - One of the three parameterless commands START_COMMAND,
        useReturnURL - Whether to append the returnURL parameter
      • getRecordedURIs

        public Set<URI> getRecordedURIs()
        Write recorded URIs to response. NOTE! This does not respect the Controller! The URIs are *not* returned!
        Specified by:
        getRecordedURIs in interface Controller
        Returns:
        null in all cases. The URIs are written in response by the forwarded call instead.
      • changeIndex

        public void changeIndex​(Set<Long> jobList,
                                String label)
        Change current index to work on these jobs. Then return to returnURL.

        Since post data cannot be transferred through a regular redirect, we instead build a page that uses javascript to immediately repost the data to the url.

        Specified by:
        changeIndex in interface Controller
        Parameters:
        jobList - The list of jobs.
        label - An arbitrary label that will be used to indicate this index
      • getStatus

        public String getStatus​(Locale locale)
        Write the current status of viewerproxy to response. NOTE! This does not respect the Controller API! The URIs are *not* returned!
        Specified by:
        getStatus in interface Controller
        Parameters:
        locale - The locale (da, en, ...) that the response should be written using.
        Returns:
        null. The status is written in response by the forwarded call instead.