com.instantbank.lettertemplate.editor.applet
Class TemplateEditorProxy

java.lang.Object
  |
  +--com.instantbank.lettertemplate.editor.applet.TemplateEditorProxy

public class TemplateEditorProxy
extends java.lang.Object

Proxy for the Template Editor servlet. Sends commands and receives results from the servlet.

Author:
InstantBank (Rodrigo Lopez)

Field Summary
(package private)  java.io.ObjectInputStream in
          Input stream from the servlet.
(package private)  java.net.URL servlet
          The fully-qualified URL to the called servlet.
(package private)  java.net.URL timeout
          The URL of the timeout page
(package private)  java.net.URL webBase
          The complete URL to the servlet web server (for instance, 'http://www.sun.com:8080').
 
Constructor Summary
TemplateEditorProxy(java.net.URL web)
          TemplateEditorProxy constructor.
 
Method Summary
 boolean controlTimeout(java.applet.AppletContext appContext)
          Goes to the server and verifies if time out has delayed.
 void exit(java.lang.String url)
          exit
 java.lang.String extraservice()
          Asks for an extra "debugging" service.
 CodeDescription[] loadCategories()
          Asks for code and description of the template categories
 CodeDescription[] loadCodesStamps(long category, int printType, java.lang.String template, java.lang.String header, java.lang.String body, java.lang.String closing)
          Asks the service of loading code and stamp of a template and components.
 java.util.ArrayList loadComponent(long code)
          Asks for the service of loading a full LetterComponent from the dadabase.
 CodeDescription loadComponentCode(int compType, int printType, java.lang.String name)
          Loads the < code,stamp> of a component from the database.
 CodeDescription[] loadComponentsDescription(int cmpType, int pType)
          Asks for code and description of the components, for a given component type and print type.
 byte[] loadImageRepository(java.lang.String name)
          Asks the service of loading an image --of the current company-- from the data base.
 java.lang.String[] loadImagesNamesRepository()
          Loads the names of the images from the data base.
 java.util.ArrayList loadTemplate(long code)
          Loads a template from the data base.
 CodeDescription[] loadTemplateCodes(long code)
          Asks for the service of loading < code, stamp> for a template and its components.
 CodeDescription[] loadTemplatesDescription(long category, int pType)
          Asks for code and description of the templates, for a given category and print type.
 CodeDescription[] loadVariableFormats()
          Asks for the service of loading variable formats.
 java.util.ArrayList loadVariables()
          Asks for the service of loading loan variables.
 CodeDescription storeComponent(LetterComponent component)
          Asks for the service of storing a letter component without changing its links with any component.
 CodeDescription storeComponentAs(long templateCode, LetterComponent component)
          Asks for the service of storing a letter component bound to a template.
 CodeDescription[] storeTemplate(Template template)
          Asks for the service of storing a template.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

servlet

java.net.URL servlet
The fully-qualified URL to the called servlet.

webBase

java.net.URL webBase
The complete URL to the servlet web server (for instance, 'http://www.sun.com:8080').

timeout

java.net.URL timeout
The URL of the timeout page

in

java.io.ObjectInputStream in
Input stream from the servlet.
Constructor Detail

TemplateEditorProxy

public TemplateEditorProxy(java.net.URL web)
                    throws java.net.MalformedURLException
TemplateEditorProxy constructor.
Parameters:
web - Servlet's Web server URL (excluding servlet path).
Throws:
java.net.MalformedURLException - Description of the Exception
Method Detail

controlTimeout

public boolean controlTimeout(java.applet.AppletContext appContext)
Goes to the server and verifies if time out has delayed. If it has, control flows to the timeout page; otherwise it returns silently.
Parameters:
appContext - Context of the applet that invokes the service.
Returns:
boolean: true if it exists timeout, false otherwise

loadImagesNamesRepository

public java.lang.String[] loadImagesNamesRepository()
                                             throws java.lang.Exception
Loads the names of the images from the data base.
Returns:
An array of images names.
Throws:
java.lang.Exception - Description of the Exception

storeTemplate

public CodeDescription[] storeTemplate(Template template)
                                throws java.lang.Exception
Asks for the service of storing a template.
Parameters:
template - The full "in memory" representation of a template.
Returns:
An array of < code, stamp> of the stored elements in the THBC order.
Throws:
java.lang.Exception - Description of the Exception

loadImageRepository

public byte[] loadImageRepository(java.lang.String name)
                           throws java.lang.Exception
Asks the service of loading an image --of the current company-- from the data base.
Parameters:
name - The name of the image in the data base.
Returns:
An array containing the raw bytes of the image. see LetterTemplate.loadImageRepository(String) and TemplateEditorServlet.doPost(HttpServletRequest,HttpServletResponse)
Throws:
java.lang.Exception - Description of the Exception

exit

public void exit(java.lang.String url)
          throws java.lang.Exception
exit
Parameters:
url -  
Throws:
java.lang.Exception - Description of the Exception

loadCategories

public CodeDescription[] loadCategories()
                                 throws java.lang.Exception
Asks for code and description of the template categories
Returns:
An array of < code,name> pairs of categories sorted by name.
Throws:
java.lang.Exception - Description of the Exception

loadTemplatesDescription

public CodeDescription[] loadTemplatesDescription(long category,
                                                  int pType)
                                           throws java.lang.Exception
Asks for code and description of the templates, for a given category and print type.
Parameters:
category - The category code for the enquired templates.
pType - Print type.
Returns:
An array of < code,name> pairs of templates sorted by name.
Throws:
java.lang.Exception - Description of the Exception

loadTemplateCodes

public CodeDescription[] loadTemplateCodes(long code)
                                    throws java.lang.Exception
Asks for the service of loading < code, stamp> for a template and its components.
Parameters:
code - The template's code.
Returns:
A < code, stamp> array of the template in the THBC order.
Throws:
java.lang.Exception - Description of the Exception

loadComponentsDescription

public CodeDescription[] loadComponentsDescription(int cmpType,
                                                   int pType)
                                            throws java.lang.Exception
Asks for code and description of the components, for a given component type and print type.
Parameters:
cmpType - Component type.
pType - Print type.
Returns:
An array of < code,name> pairs of components sorted by name.
Throws:
java.lang.Exception - Description of the Exception

loadTemplate

public java.util.ArrayList loadTemplate(long code)
                                 throws java.lang.Exception
Loads a template from the data base.
Parameters:
code - The template's code.
Returns:
A pair containing the full template structure extracted from the data base and a message containing the names of the variables with inconsistent date offsets. Those offsets are forced to zero.
Throws:
java.lang.Exception - Description of the Exception

loadCodesStamps

public CodeDescription[] loadCodesStamps(long category,
                                         int printType,
                                         java.lang.String template,
                                         java.lang.String header,
                                         java.lang.String body,
                                         java.lang.String closing)
                                  throws java.lang.Exception
Asks the service of loading code and stamp of a template and components. The template and components don't have to be related.
Parameters:
category - Category of template
printType - Print type
header - Name of the header component
body - Name of the body component
closing - Name of the closing component
template -  
Returns:
A < code,stamp> array of the template and components in the THBC order. In all cases, if the template or component doesn't exist the returned value is: < LetterTemplateGlobals.UNDEF, LetterTemplateGlobals.STR_UNDEF> .
Throws:
java.lang.Exception - Description of the Exception

loadComponentCode

public CodeDescription loadComponentCode(int compType,
                                         int printType,
                                         java.lang.String name)
                                  throws java.lang.Exception
Loads the < code,stamp> of a component from the database.
Parameters:
compType - Type of the component (Header/Body/Closing).
printType - LASER/TYPEWRITTER
name - Component's name
Returns:
The < code, stamp> of the component. If the component doesn't exists the returned value is < LetterTemplateGlobals.UNDEF, LetterTemplateGlobals.STR_UNDEF> .
Throws:
java.lang.Exception - Description of the Exception

loadComponent

public java.util.ArrayList loadComponent(long code)
                                  throws java.lang.Exception
Asks for the service of loading a full LetterComponent from the dadabase.
Parameters:
code - The code of the component.
Returns:
A pair containing the full component structure extracted from the data base and a message containing the names of the variables with inconsistent date offsets. Those offsets are forced to zero.
Throws:
java.lang.Exception - Description of the Exception

storeComponent

public CodeDescription storeComponent(LetterComponent component)
                               throws java.lang.Exception
Asks for the service of storing a letter component without changing its links with any component. An old version of the component must exist before asking the service.
Parameters:
component - The component to be saved.
Returns:
The < code, stamp> of the saved component.
Throws:
java.lang.Exception - Description of the Exception

storeComponentAs

public CodeDescription storeComponentAs(long templateCode,
                                        LetterComponent component)
                                 throws java.lang.Exception
Asks for the service of storing a letter component bound to a template. Following its type (header, body, closing) it also replaces the corresponding component of the template.
Parameters:
templateCode - Code of the template bound to the component.
component - The component to be saved and linked to the template.
Returns:
The < code,stamp> of the saved component.
Throws:
java.lang.Exception - Description of the Exception

loadVariables

public java.util.ArrayList loadVariables()
                                  throws java.lang.Exception
Asks for the service of loading loan variables.
Returns:
An ArrayList of ArrayLists containing the information about all loan variables. The internal ArrayList contains [code, name, type] of a variable.
Throws:
java.lang.Exception - Description of the Exception

loadVariableFormats

public CodeDescription[] loadVariableFormats()
                                      throws java.lang.Exception
Asks for the service of loading variable formats.
Returns:
An array of CodeDescription containing [code,description] of all variable formats.
Throws:
java.lang.Exception - Description of the Exception

extraservice

public java.lang.String extraservice()
                              throws java.lang.Exception
Asks for an extra "debugging" service.
Returns:
Description of the Return Value
Throws:
java.lang.Exception - Description of the Exception