com.timeindexing.servlet
Class SelectServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by com.timeindexing.servlet.SelectServlet
All Implemented Interfaces:
IndexPrimaryEventListener, java.io.Serializable, java.util.EventListener, javax.servlet.Servlet, javax.servlet.ServletConfig
Direct Known Subclasses:
FlashStreamDownloadServlet, MP3DownloadServlet, MP3StreamServlet, MPEGDownloadServlet, OctetStreamDownloadServlet, SecurityCodeServlet

public class SelectServlet
extends javax.servlet.http.HttpServlet
implements IndexPrimaryEventListener

This servlet selects data from an index. Data is specified for an index, given a start time and an end time.

If an error occurs when checking the servlet setup or in the arguments are incorrect the response goes through various jsp files. The following values are currently defined as web.xml context-params, shown here with their default values.

param-nameparam-value
norepositorypage/error/no_repository.jsp
noindexspecifiedpage/error/no_index.jsp
nosecuritycodepage/error/no_code.jsp
badsecuritycodepage/error/bad_code.jsp
selectexceptionpage//error/select_exception.jsp

If an excpetion occurs, the exception is placed in the request attribute "exception".
The response is presented through /error/select_exception.jsp.

See Also:
Serialized Form

Nested Class Summary
 class SelectServlet.WriterOutputStream
          Wrap a Writer as an Output Stream.
 
Constructor Summary
SelectServlet()
           
 
Method Summary
protected  Selecter allocateSelecter(java.lang.String filename, java.io.OutputStream out)
          allocate a Selecter
 void closed(IndexPrimaryEvent ipe)
          A notification that an Index has been closed.
 void committed(IndexPrimaryEvent ipe)
          A notification that an Index has been committed.
 void created(IndexPrimaryEvent ipe)
          A notification that an Index has been created.
 void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           
protected  int doPlayBack(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, IndexProperties properties, int passedInStatus)
          Playback the data.
protected  boolean empty(java.lang.String name)
          Is a value empty.
protected  java.lang.String fileNameGenerator(IndexProperties properties)
          This filename generator, takes the arguments and generates a useful filename.
protected  java.lang.String getContentType()
          Get the content type for this response.
 void init(javax.servlet.ServletConfig config)
          Init the servlet.
protected  boolean isBrowser(javax.servlet.http.HttpServletRequest request)
          Is the client a browser.
protected  boolean isSecurityCodeOn()
          Is security on.
 void opened(IndexPrimaryEvent ipe)
          A notification that an Index has been opened.
protected  void postPlaybackError(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, int status)
          This is called if there is an error during to playback.
protected  void prePlaybackError(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, int status)
          This is called if there is an error prior to playback.
protected  void setContentType(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String type)
          Set the content type.
protected  void setFilename(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, IndexProperties properties)
          Set the filename for downloads.
 void viewAdded(IndexPrimaryEvent ipe)
          A notification that a view has been added to an Index.
 void viewRemoved(IndexPrimaryEvent ipe)
          A notification that a view has been removed to an Index.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SelectServlet

public SelectServlet()
Method Detail

init

public void init(javax.servlet.ServletConfig config)
          throws javax.servlet.ServletException
Init the servlet.

Specified by:
init in interface javax.servlet.Servlet
Overrides:
init in class javax.servlet.GenericServlet
Throws:
javax.servlet.ServletException

doGet

public void doGet(javax.servlet.http.HttpServletRequest request,
                  javax.servlet.http.HttpServletResponse response)
           throws java.io.IOException,
                  javax.servlet.ServletException
Overrides:
doGet in class javax.servlet.http.HttpServlet
Throws:
java.io.IOException
javax.servlet.ServletException

doPlayBack

protected int doPlayBack(javax.servlet.http.HttpServletRequest request,
                         javax.servlet.http.HttpServletResponse response,
                         IndexProperties properties,
                         int passedInStatus)
                  throws java.io.IOException
Playback the data.

Returns:
the status of doing the playback
Throws:
java.io.IOException

prePlaybackError

protected void prePlaybackError(javax.servlet.http.HttpServletRequest request,
                                javax.servlet.http.HttpServletResponse response,
                                int status)
                         throws java.io.IOException
This is called if there is an error prior to playback.

Throws:
java.io.IOException

postPlaybackError

protected void postPlaybackError(javax.servlet.http.HttpServletRequest request,
                                 javax.servlet.http.HttpServletResponse response,
                                 int status)
                          throws java.io.IOException
This is called if there is an error during to playback.

Throws:
java.io.IOException

empty

protected boolean empty(java.lang.String name)
Is a value empty.


isBrowser

protected boolean isBrowser(javax.servlet.http.HttpServletRequest request)
Is the client a browser.


isSecurityCodeOn

protected boolean isSecurityCodeOn()
Is security on.


allocateSelecter

protected Selecter allocateSelecter(java.lang.String filename,
                                    java.io.OutputStream out)
allocate a Selecter


setContentType

protected void setContentType(javax.servlet.http.HttpServletRequest request,
                              javax.servlet.http.HttpServletResponse response,
                              java.lang.String type)
Set the content type.


getContentType

protected java.lang.String getContentType()
Get the content type for this response.


setFilename

protected void setFilename(javax.servlet.http.HttpServletRequest request,
                           javax.servlet.http.HttpServletResponse response,
                           IndexProperties properties)
Set the filename for downloads.


fileNameGenerator

protected java.lang.String fileNameGenerator(IndexProperties properties)
This filename generator, takes the arguments and generates a useful filename. Returns filename-0:10-to-1:23.


opened

public void opened(IndexPrimaryEvent ipe)
A notification that an Index has been opened.

Specified by:
opened in interface IndexPrimaryEventListener

closed

public void closed(IndexPrimaryEvent ipe)
A notification that an Index has been closed.

Specified by:
closed in interface IndexPrimaryEventListener

committed

public void committed(IndexPrimaryEvent ipe)
A notification that an Index has been committed.

Specified by:
committed in interface IndexPrimaryEventListener

created

public void created(IndexPrimaryEvent ipe)
A notification that an Index has been created.

Specified by:
created in interface IndexPrimaryEventListener

viewAdded

public void viewAdded(IndexPrimaryEvent ipe)
A notification that a view has been added to an Index.

Specified by:
viewAdded in interface IndexPrimaryEventListener

viewRemoved

public void viewRemoved(IndexPrimaryEvent ipe)
A notification that a view has been removed to an Index.

Specified by:
viewRemoved in interface IndexPrimaryEventListener


Timeindexing 2008