Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

openfuture.editxml.servlet
Class EditorServlet  view EditorServlet download EditorServlet.java

java.lang.Object
  extended byjavax.servlet.GenericServlet
      extended byjavax.servlet.http.HttpServlet
          extended byopenfuture.util.servlet.HttpActionServlet
              extended byopenfuture.editxml.servlet.EditorServlet
All Implemented Interfaces:
openfuture.editxml.model.JspConstants, java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class EditorServlet
extends openfuture.util.servlet.HttpActionServlet
implements openfuture.editxml.model.JspConstants

Servlet managing the edit process of XML files. Created: Thu Apr 26 13:58:45 2001

Version:
$Revision: 1.2 $

Field Summary
private  org.apache.struts.action.ActionErrors errors
           
private  java.util.Hashtable forwards
           
private  boolean isNewError
           
private  boolean serializeRequest
           
 
Fields inherited from class openfuture.util.servlet.HttpActionServlet
EQUAL_SIGN, SEPARATOR
 
Fields inherited from class javax.servlet.http.HttpServlet
 
Fields inherited from class javax.servlet.GenericServlet
 
Fields inherited from interface openfuture.editxml.model.JspConstants
DOMAINMANAGER, LOCALES, NEXT_PAGE, QUERY, QUERYSTRING, RESULT, SERVLETPATH, USER, XML_DOMAINS, XMLFORM
 
Constructor Summary
EditorServlet()
           
 
Method Summary
protected  void addError(javax.servlet.http.HttpServletRequest req, java.lang.String result)
          Add an error.
protected  void addError(javax.servlet.http.HttpServletRequest req, java.lang.String result, java.lang.Exception e)
          Add an error.
protected  void addError(javax.servlet.http.HttpServletRequest req, java.lang.String result, java.lang.String arg0)
          Add an error.
protected  void addError(javax.servlet.http.HttpServletRequest req, java.lang.String result, java.lang.String arg0, java.lang.String arg1)
          Add an error.
protected  void editForm(openfuture.editxml.model.XmlDomain domain, java.lang.String filename, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          Continue editing the JspConstants.XMLFORM>JspConstants.XMLFORM 55 .
protected  openfuture.util.error.I18NException error2Exception()
          Converts the first error from getErrors() 55 into an I18NException.
protected  void forward(java.lang.String path, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          Forward the HTTP request.
protected  void forwardError(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          Forward the request to the error page.
protected  void forwardFailure(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, java.lang.String domainname, java.lang.String filename)
          Forward the request to the original page.
protected  org.w3c.dom.Document getDocument(java.lang.String directory, java.lang.String xmlfile)
          Load the XML file and parse it.
 org.apache.struts.action.ActionErrors getErrors()
          Get the value of errors (lazily instantiated).
protected  void getForm(openfuture.editxml.model.XmlDomain domain, java.lang.String filename, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          Fills the XmlForm from the file filename contained in the XML domain domainname.
protected  java.lang.String getMessage(javax.servlet.http.HttpServletRequest req, java.lang.String key, java.lang.Object[] args)
          Translate a message with the given key using the current locale and the message resources stored in Action.MESSAGES_KEY.
protected  java.lang.String getParameter(java.util.Hashtable parameters, java.lang.String name)
          Extracts a single parameter from the parameter hashtable.
protected  void handleAction(java.util.Hashtable parameters, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          Dispatcher for the action commands.
 void init(javax.servlet.ServletConfig config)
          Initializes the servlet.
 boolean isNewError()
          Get the value of isNewError.
 boolean isSerializeRequest()
          Get the value of serializeRequest.
protected  openfuture.editxml.form.XmlForm loadForm(openfuture.editxml.model.XmlDomain domain, java.lang.String filename, javax.servlet.http.HttpServletRequest req)
          Read the XML file and convert it into an XML domain.
protected  void saveDocument(org.w3c.dom.Document doc, java.lang.String directory, java.lang.String xmlfile)
          Serialize the XML document and save it.
protected  void saveErrors(javax.servlet.http.HttpServletRequest request, org.apache.struts.action.ActionErrors errors)
          Save the errors as request attribute.
protected  void saveForm(openfuture.editxml.model.XmlDomain domain, java.lang.String oldfile, java.lang.String newfile, java.util.Hashtable parameters, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          Save the XML form to the XML file.
 void setErrors(org.apache.struts.action.ActionErrors v)
          Set the value of errors.
 void setIsNewError(boolean v)
          Set the value of isNewError.
 void setSerializeRequest(boolean v)
          Set the value of serializeRequest.
protected  java.lang.String toHtml(java.lang.String text)
          Convert the given text into HTML and translates < into &lt; respectively > into &gt;.
 
Methods inherited from class openfuture.util.servlet.HttpActionServlet
addParameter, doGet, doPost, logException
 
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, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

forwards

private java.util.Hashtable forwards

errors

private org.apache.struts.action.ActionErrors errors

isNewError

private boolean isNewError

serializeRequest

private boolean serializeRequest
Constructor Detail

EditorServlet

public EditorServlet()
Method Detail

init

public void init(javax.servlet.ServletConfig config)
          throws javax.servlet.ServletException
Initializes the servlet. The following init parameters are recognized:
  • forwardError: URL where the error should be forwarded to.
  • forwardSuccess: URL where a success will be displayed.

Specified by:
init in interface javax.servlet.Servlet

handleAction

protected void handleAction(java.util.Hashtable parameters,
                            javax.servlet.http.HttpServletRequest req,
                            javax.servlet.http.HttpServletResponse res)
                     throws java.io.IOException
Dispatcher for the action commands. The following actions are recognized:
  • get.form: Fills the XmlForm from a file contained in the XML domain. The following request parameters are recognized:
  • save.form: Update the JspConstants.XMLFORM>JspConstants.XMLFORM 55 , convert it into XML structure and save it. The following request parameters are recognized:
  • edit.form: Continue editing the JspConstants.XMLFORM>JspConstants.XMLFORM 55 .
  • get.domain: Return the requested XmlDomain. The following request parameters are recognized:
    • domain: name of the XML domain.
    • serialize: Must be set to true, since this request may only be sent by the EditXmlApplet.
  • get.all.domains: Return a table of XmlDomains. The following request parameters are recognized:
    • serialize: Must be set to true, since this request may only be sent by the EditXmlApplet.
  • get.all.filenames: Return a table of filenames. The following request parameters are recognized:
    • serialize: Must be set to true, since this request may only be sent by the EditXmlApplet.


getForm

protected void getForm(openfuture.editxml.model.XmlDomain domain,
                       java.lang.String filename,
                       javax.servlet.http.HttpServletRequest req,
                       javax.servlet.http.HttpServletResponse res)
                throws java.io.IOException
Fills the XmlForm from the file filename contained in the XML domain domainname. If #isSerializedRequest() returns true, we send the XmlForm via the response input stream to the applet. Otherwise, it is stored in the session as JspConstants.XMLFORM>JspConstants.XMLFORM 55 .


loadForm

protected openfuture.editxml.form.XmlForm loadForm(openfuture.editxml.model.XmlDomain domain,
                                                   java.lang.String filename,
                                                   javax.servlet.http.HttpServletRequest req)
                                            throws java.io.IOException
Read the XML file and convert it into an XML domain.


editForm

protected void editForm(openfuture.editxml.model.XmlDomain domain,
                        java.lang.String filename,
                        javax.servlet.http.HttpServletRequest req,
                        javax.servlet.http.HttpServletResponse res)
                 throws java.io.IOException
Continue editing the JspConstants.XMLFORM>JspConstants.XMLFORM 55 .


saveForm

protected void saveForm(openfuture.editxml.model.XmlDomain domain,
                        java.lang.String oldfile,
                        java.lang.String newfile,
                        java.util.Hashtable parameters,
                        javax.servlet.http.HttpServletRequest req,
                        javax.servlet.http.HttpServletResponse res)
                 throws java.io.IOException
Save the XML form to the XML file. If #isSerializedRequest() returns false, the JspConstants.XMLFORM>JspConstants.XMLFORM 55 is updated by the XmlForm read from the output stream of the request object. Otherwise, the JspConstants.XMLFORM>JspConstants.XMLFORM 55 is updated from the request parameters.


getErrors

public org.apache.struts.action.ActionErrors getErrors()
Get the value of errors (lazily instantiated).


setErrors

public void setErrors(org.apache.struts.action.ActionErrors v)
Set the value of errors.


saveErrors

protected void saveErrors(javax.servlet.http.HttpServletRequest request,
                          org.apache.struts.action.ActionErrors errors)
Save the errors as request attribute.


getDocument

protected org.w3c.dom.Document getDocument(java.lang.String directory,
                                           java.lang.String xmlfile)
                                    throws java.io.FileNotFoundException,
                                           org.xml.sax.SAXException,
                                           java.io.IOException
Load the XML file and parse it.


saveDocument

protected void saveDocument(org.w3c.dom.Document doc,
                            java.lang.String directory,
                            java.lang.String xmlfile)
                     throws org.xml.sax.SAXException,
                            java.io.IOException
Serialize the XML document and save it.


forward

protected void forward(java.lang.String path,
                       javax.servlet.http.HttpServletRequest req,
                       javax.servlet.http.HttpServletResponse res)
                throws javax.servlet.ServletException,
                       java.io.IOException
Forward the HTTP request.


forwardError

protected void forwardError(javax.servlet.http.HttpServletRequest req,
                            javax.servlet.http.HttpServletResponse res)
Forward the request to the error page. If #isSerializedRequest() returns true, a I18NException is created and written to the output stream.


forwardFailure

protected void forwardFailure(javax.servlet.http.HttpServletRequest req,
                              javax.servlet.http.HttpServletResponse res,
                              java.lang.String domainname,
                              java.lang.String filename)
Forward the request to the original page. If #isSerializedRequest() returns true, a I18NException is created and written to the output stream.


getMessage

protected java.lang.String getMessage(javax.servlet.http.HttpServletRequest req,
                                      java.lang.String key,
                                      java.lang.Object[] args)
Translate a message with the given key using the current locale and the message resources stored in Action.MESSAGES_KEY.


toHtml

protected java.lang.String toHtml(java.lang.String text)
Convert the given text into HTML and translates < into &lt; respectively > into &gt;.


getParameter

protected java.lang.String getParameter(java.util.Hashtable parameters,
                                        java.lang.String name)
Extracts a single parameter from the parameter hashtable. In the hashtable, the parameter values for the same parameter key are stored as an array. The first value is returned.


error2Exception

protected openfuture.util.error.I18NException error2Exception()
Converts the first error from getErrors() 55 into an I18NException.


addError

protected void addError(javax.servlet.http.HttpServletRequest req,
                        java.lang.String result)
Add an error.


addError

protected void addError(javax.servlet.http.HttpServletRequest req,
                        java.lang.String result,
                        java.lang.String arg0)
Add an error.


addError

protected void addError(javax.servlet.http.HttpServletRequest req,
                        java.lang.String result,
                        java.lang.String arg0,
                        java.lang.String arg1)
Add an error.


addError

protected void addError(javax.servlet.http.HttpServletRequest req,
                        java.lang.String result,
                        java.lang.Exception e)
Add an error. The exception message is handed over to #addError(java.lang.String, java.lang.String).


isNewError

public boolean isNewError()
Get the value of isNewError.


setIsNewError

public void setIsNewError(boolean v)
Set the value of isNewError.


isSerializeRequest

public boolean isSerializeRequest()
Get the value of serializeRequest.


setSerializeRequest

public void setSerializeRequest(boolean v)
Set the value of serializeRequest.