dk.netarkivet.viewerproxy.distribute
Class HTTPControllerServer

java.lang.Object
  extended by dk.netarkivet.viewerproxy.CommandResolver
      extended by dk.netarkivet.viewerproxy.distribute.HTTPControllerServer
All Implemented Interfaces:
URIResolver, URIResolverHandler

public class HTTPControllerServer
extends CommandResolver

Wrapper for an URIResolver, which calls the controller methods on given specific URLs, and forwards all others to the wrapped handler. This allows you to access control methods by giving specific urls to this class.


Field Summary
(package private) static java.lang.String CHANGE_INDEX_COMMAND
          Command for changing index.
(package private) static java.lang.String CLEAR_COMMAND
          Command for clearing collected urls.
(package private) static java.lang.String GET_RECORDED_URIS_COMMAND
          Command for getting collected urls.
(package private) static java.lang.String GET_STATUS_COMMAND
          Command for getting status.
(package private) static java.lang.String INDEX_LABEL_PARAMETER
          Parameter for label of an index.
(package private) static java.lang.String JOB_ID_PARAMETER
          Parameter for ids of jobs to change index to.
(package private) static java.lang.String LOCALE_PARAMETER
          Parameter for locale to generate status.
(package private) static java.lang.String RETURN_URL_PARAMETER
          Parameter defining the url to return to after doing start, stop, clear, or changeIndex.
(package private) static java.lang.String START_COMMAND
          Command for starting url collection.
(package private) static java.lang.String STOP_COMMAND
          Command for stopping url collection.
 
Fields inherited from class dk.netarkivet.viewerproxy.CommandResolver
ur, VIEWERPROXY_COMMAND_NAME
 
Fields inherited from interface dk.netarkivet.viewerproxy.URIResolver
NOT_FOUND
 
Constructor Summary
HTTPControllerServer(Controller c, URIResolver ur)
          Make a new HTTPControllerServer, which calls commands on the given controller, and forwards all other requests to the given URIResolver.
 
Method Summary
protected  boolean executeCommand(Request request, Response response)
          Handles parsing of the URL and delegating to relevant methods.
 
Methods inherited from class dk.netarkivet.viewerproxy.CommandResolver
isCommandHostRequest, lookup, setURIResolver
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

START_COMMAND

static final java.lang.String START_COMMAND
Command for starting url collection.

See Also:
Constant Field Values

STOP_COMMAND

static final java.lang.String STOP_COMMAND
Command for stopping url collection.

See Also:
Constant Field Values

CLEAR_COMMAND

static final java.lang.String CLEAR_COMMAND
Command for clearing collected urls.

See Also:
Constant Field Values

GET_RECORDED_URIS_COMMAND

static final java.lang.String GET_RECORDED_URIS_COMMAND
Command for getting collected urls.

See Also:
Constant Field Values

CHANGE_INDEX_COMMAND

static final java.lang.String CHANGE_INDEX_COMMAND
Command for changing index.

See Also:
Constant Field Values

GET_STATUS_COMMAND

static final java.lang.String GET_STATUS_COMMAND
Command for getting status.

See Also:
Constant Field Values

RETURN_URL_PARAMETER

static final java.lang.String RETURN_URL_PARAMETER
Parameter defining the url to return to after doing start, stop, clear, or changeIndex.

See Also:
Constant Field Values

JOB_ID_PARAMETER

static final java.lang.String JOB_ID_PARAMETER
Parameter for ids of jobs to change index to. May be repeated.

See Also:
Constant Field Values

INDEX_LABEL_PARAMETER

static final java.lang.String INDEX_LABEL_PARAMETER
Parameter for label of an index.

See Also:
Constant Field Values

LOCALE_PARAMETER

static final java.lang.String LOCALE_PARAMETER
Parameter for locale to generate status.

See Also:
Constant Field Values
Constructor Detail

HTTPControllerServer

public HTTPControllerServer(Controller c,
                            URIResolver ur)
Make a new HTTPControllerServer, which calls commands on the given controller, and forwards all other requests to the given URIResolver.

Parameters:
c - The controller which handles commands given in command URLs.
ur - The URIResolver to handle all other uris.
Throws:
ArgumentNotValid - if either argument is null.
Method Detail

executeCommand

protected boolean executeCommand(Request request,
                                 Response response)
Handles parsing of the URL and delegating to relevant methods. The commands are of the form http://<>/<>?<>=<>* Known commands are the following: start - params: returnURL - effect: start url collection return to returnURL stop - params: returnURL - effect: stop url collection return to returnURL clear - params: returnURL - effect: clear url collection return to returnURL getRecordedURIs - params: none - effect: write url collection to response changeIndex - params: jobID*, - effect: generate index for jobs, returnURL return to returnURL getStatus - params: locale - effect: write status to response.

Specified by:
executeCommand in class CommandResolver
Parameters:
request - The request to check
response - The response to give command results to if it is a command. If the request is one of these commands, the response code is set to 303 if page is redirected to return url; 200 if command url returns data; otherwise whatever is returned by the wrapped resolver
Returns:
Whether this was a command URL