no.ntnu.item.router.utilities
Class UserInputHandler

java.lang.Object
  extended by no.ntnu.item.router.utilities.UserInputHandler
All Implemented Interfaces:
com.sun.net.httpserver.HttpHandler

 class UserInputHandler
extends java.lang.Object
implements com.sun.net.httpserver.HttpHandler

This is a handler for the user input.
When a user makes changes in the Web UI, a message will be sent here.

NOTE: Why did we do this over http? Why not make the UI write to the xml
file where it reads the data? Because then the RouterControl would have to
poll for changes in the file and compare to what it has locally.
In addition, we might create a stand-alone control panel, which
reads the xml and sends messages to the server with preferences

Author:
Kristian Haugene

Field Summary
private  ServiceSessionBank serviceBank
          The ServiceSessionBank object to report measurements to
 
Constructor Summary
UserInputHandler(ServiceSessionBank serviceBank)
          Constructor
 
Method Summary
private  java.lang.String getRedirectLocation(java.lang.String request)
          Will examine the http request body and return the location given by the redirect parameter
 void handle(com.sun.net.httpserver.HttpExchange t)
           
private  java.lang.String removeTrailingRedirectParameter(java.lang.String request)
          Helper method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serviceBank

private ServiceSessionBank serviceBank
The ServiceSessionBank object to report measurements to

Constructor Detail

UserInputHandler

public UserInputHandler(ServiceSessionBank serviceBank)
Constructor

Parameters:
serviceBank -
Method Detail

handle

public void handle(com.sun.net.httpserver.HttpExchange t)
            throws java.io.IOException
Specified by:
handle in interface com.sun.net.httpserver.HttpHandler
Throws:
java.io.IOException

removeTrailingRedirectParameter

private java.lang.String removeTrailingRedirectParameter(java.lang.String request)
Helper method. Will take a string and remove everything after and including "&redirect=" tag. This is done before parsing the input as user preferences

Parameters:
request - the http request body
Returns:
the request body where the redirect parameter is stripped

getRedirectLocation

private java.lang.String getRedirectLocation(java.lang.String request)
Will examine the http request body and return the location given by the redirect parameter

Parameters:
request - to look for redirect address
Returns:
the address given as parameter