org.sandev.tools.FileEditor
Class XHTMLFileEditorServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by org.sandev.tools.FileEditor.XHTMLFileEditorServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class XHTMLFileEditorServlet
extends javax.servlet.http.HttpServlet

An XHTML servlet UI for editing a SAND XML file such as a TestScript. AUTOGENERATED FILE, DO NOT EDIT DIRECTLY.
source: declared in build
generator: org.sandev.generator.FileEditorGenerator
time: Jul 31, 2008 4:34:17 PM

See Also:
Serialized Form

Field Summary
protected static java.lang.String doneLink
          The link we write out for noting when we are done editing a specific instance.
protected  java.lang.String filename
          The name of the file we are currently working with.
static java.lang.String FILENAMEPARAM
          The name of the parameter specifying the name of the file or directory we are currently editing.
protected static XHTMLFormEditor singleton_editor
          Singleton XHTMLFormEditor reference.
static java.lang.String TITLE
          The title of the editing application
 
Constructor Summary
XHTMLFileEditorServlet()
           
 
Method Summary
 void doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          Pass HTTP 'GET' request over to handleRequest method.
protected  boolean doneEditing(javax.servlet.http.HttpServletRequest req)
          Return true if we are done editing the instance we were working with, false otherwise.
 void doPost(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          Pass HTTP 'POST' request over to handleRequest method.
protected  void dumpDescription(java.io.PrintWriter out, java.lang.String dirname, java.lang.String filename)
          Read the specified XML file to grab the comment or description field out of it.
protected  void dumpDirLink(java.io.PrintWriter out, java.lang.String dirname, java.lang.String text)
          Write out a link to the specified directory.
protected  void dumpFileLink(java.io.PrintWriter out, java.lang.String dirname, java.lang.String filename)
          Write out a link to the specified directory.
protected  void dumpNewFileForm(java.io.PrintWriter out)
          Dump out a form allowing the user to enter a new filename and submit it back as a URL param.
protected  void failout(java.lang.String text, javax.servlet.http.HttpServletResponse res)
          Die with the appropriate message
 java.lang.String getFilename()
          accessor for filename
protected  java.lang.String getFileShortname(java.lang.String filename)
          Given a filename, return the unqualified part of it.
protected  java.lang.String getURLParam(javax.servlet.http.HttpServletRequest req, java.lang.String key)
          Get the filename specification from the URL and return it.
protected  void handleRequest(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          Process the file specified in the URL, or pass the request on to our XHTMLFormEditor if we are already editing.
protected  void initXHTMLFormEditor(java.lang.String filename, java.lang.String msgClass)
           
protected  void listDirectorySelections(java.io.File dir, javax.servlet.http.HttpServletResponse res)
          List the files in the given directory as links for editing, and an option to create a new file.
protected  void plog(java.lang.String text)
          Wrapper for general servlet log so we can shut it off or on in one place.
 void setFilename(java.lang.String val)
          mutator for filename
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FILENAMEPARAM

public static final java.lang.String FILENAMEPARAM
The name of the parameter specifying the name of the file or directory we are currently editing. If this is a directory, then the .xml files in that directory are displayed for selection and editing.

See Also:
Constant Field Values

TITLE

public static final java.lang.String TITLE
The title of the editing application

See Also:
Constant Field Values

filename

protected java.lang.String filename
The name of the file we are currently working with. Read from the URL file parameter.


doneLink

protected static final java.lang.String doneLink
The link we write out for noting when we are done editing a specific instance.

See Also:
Constant Field Values

singleton_editor

protected static XHTMLFormEditor singleton_editor
Singleton XHTMLFormEditor reference. There's no reason to have more than one XHTMLFormEditor instance kicking around, or to incur the setup overhead more than once. So we maintain a single reference for use.

Constructor Detail

XHTMLFileEditorServlet

public XHTMLFileEditorServlet()
Method Detail

getFilename

public java.lang.String getFilename()
accessor for filename


setFilename

public void setFilename(java.lang.String val)
mutator for filename


doGet

public void doGet(javax.servlet.http.HttpServletRequest req,
                  javax.servlet.http.HttpServletResponse res)
Pass HTTP 'GET' request over to handleRequest method.

Overrides:
doGet in class javax.servlet.http.HttpServlet

doPost

public void doPost(javax.servlet.http.HttpServletRequest req,
                   javax.servlet.http.HttpServletResponse res)
Pass HTTP 'POST' request over to handleRequest method.

Overrides:
doPost in class javax.servlet.http.HttpServlet

handleRequest

protected void handleRequest(javax.servlet.http.HttpServletRequest req,
                             javax.servlet.http.HttpServletResponse res)
Process the file specified in the URL, or pass the request on to our XHTMLFormEditor if we are already editing.


getURLParam

protected java.lang.String getURLParam(javax.servlet.http.HttpServletRequest req,
                                       java.lang.String key)
Get the filename specification from the URL and return it. Returns null if not found. The filename is specified in the "file" URL parameter.


doneEditing

protected boolean doneEditing(javax.servlet.http.HttpServletRequest req)
Return true if we are done editing the instance we were working with, false otherwise. This looks for "done=true" in the URL parameters and returns true if it finds it, false otherwise.


listDirectorySelections

protected void listDirectorySelections(java.io.File dir,
                                       javax.servlet.http.HttpServletResponse res)
List the files in the given directory as links for editing, and an option to create a new file. Basically this dumps out each of the existing filenames ending in .xml as a link with a parameter of the filename. A text entry form allows specification of a new filename which is posted as a URL parameter on submit.


dumpDirLink

protected void dumpDirLink(java.io.PrintWriter out,
                           java.lang.String dirname,
                           java.lang.String text)
Write out a link to the specified directory. If the text is null then the filename is used.


dumpFileLink

protected void dumpFileLink(java.io.PrintWriter out,
                            java.lang.String dirname,
                            java.lang.String filename)
Write out a link to the specified directory. If the text is null then the filename is used.


dumpDescription

protected void dumpDescription(java.io.PrintWriter out,
                               java.lang.String dirname,
                               java.lang.String filename)
Read the specified XML file to grab the comment or description field out of it. Write it to the specified output.


getFileShortname

protected java.lang.String getFileShortname(java.lang.String filename)
Given a filename, return the unqualified part of it.


dumpNewFileForm

protected void dumpNewFileForm(java.io.PrintWriter out)
Dump out a form allowing the user to enter a new filename and submit it back as a URL param.


failout

protected void failout(java.lang.String text,
                       javax.servlet.http.HttpServletResponse res)
Die with the appropriate message


plog

protected void plog(java.lang.String text)
Wrapper for general servlet log so we can shut it off or on in one place. Named it "print log" to avoid conflicts with javax.servlet.GenericServlet.log which pretty much just crashes due to lack of servlet context.


initXHTMLFormEditor

protected void initXHTMLFormEditor(java.lang.String filename,
                                   java.lang.String msgClass)