za.org.coefficient.core
Class BaseCoefficientContext

java.lang.Object
  extended by za.org.coefficient.core.BaseCoefficientContext
All Implemented Interfaces:
za.co.csir.icomtek.workflow.interfaces.WorkflowContext, CoefficientContext
Direct Known Subclasses:
CoefficientTestingContext, CoefficientWebContext

public abstract class BaseCoefficientContext
extends java.lang.Object
implements CoefficientContext

Project: coefficient

Description:

Copyright: Copyright (c) 2003

Company: CSIR

Author:
tfogwill

Field Summary
static java.lang.String CURRENT_PROJECT
           
protected  java.lang.String domain
           
protected  java.util.Map fileUploadData
           
protected  boolean invalidateSession
           
protected  boolean inWorkflowAction
           
static java.lang.String LAST_NON_HELP_OP
           
protected  MultipartRequest multipartRequest
           
protected  Page page_
          The page to handle this request
protected  java.lang.String redirectionURL
          URL to redirect to if set
protected  java.util.ArrayList removedSessionKeys
           
protected  java.util.Map requestAttributes
           
protected  java.util.Map requestData
           
protected  java.lang.String requestURL
           
protected  org.apache.commons.httpclient.Cookie[] serializableExistingCookies
           
protected  java.util.ArrayList serializableNewCookies
           
protected  java.util.Map session
           
private  CoefficientUser tempUser
           
protected static java.lang.String URL_PREFIX
           
private  CoefficientUser workflowUser
           
 
Constructor Summary
BaseCoefficientContext()
           
 
Method Summary
 void beginWorkflowAction()
          This is used to do anything that needs doing for a workflow action to succeed
 java.lang.String clearModuleContent(java.lang.String name)
          This method can be used to clear a modules set content from the page before it has been rendered.
protected  void clearPage()
           
protected  void createPageObject()
           
 void endWorkflowAction()
          This should reset the state if need be
private  java.lang.String getCallerClassName()
           
 org.apache.commons.httpclient.Cookie[] getCookies()
           
 CoefficientUser getCurrentUser()
          If a user is logged in this will return that user otherwise it will return null
 java.lang.String getLastNonHelpOp()
           
 BaseMultipartRequest getMultipartRequest()
           
 Page getPage()
           
 java.lang.String getParameter(java.lang.String name)
          Passthru method to the request object.
 java.lang.String getParameter(java.lang.String name, java.lang.String defaultValue)
          Passthru method to the request object.
 boolean getParameterAsBoolean(java.lang.String name)
           
 java.util.Date getParameterAsDate(java.lang.String name)
           
 java.lang.Double getParameterAsDouble(java.lang.String name)
           
 java.lang.Double getParameterAsDouble(java.lang.String name, double defaultValue)
           
 double getParameterAsDoublePrimitive(java.lang.String name, double defaultValue)
           
 int getParameterAsInt(java.lang.String name, int defaultValue)
           
 java.lang.Integer getParameterAsInteger(java.lang.String name)
           
 java.lang.Integer getParameterAsInteger(java.lang.String name, int defaultValue)
           
 java.lang.Long getParameterAsLong(java.lang.String name)
           
 java.lang.Long getParameterAsLong(java.lang.String name, long defaultValue)
           
 long getParameterAsLongPrimitive(java.lang.String name, long defaultValue)
           
 java.lang.String[] getParametersValues(java.lang.String name)
           
 java.lang.String[] getParameterValues(java.lang.String name)
          Passthru method to the request object.
 java.lang.Long[] getParameterValuesLong(java.lang.String name)
          Method to the request values as longs.
 Project getProject()
           
 java.lang.Object getRequestAttribute(java.lang.String name)
           
 java.util.Map getRequestAttributes()
           
 java.util.Map getRequestData()
           
 java.lang.String getRequestURL()
           
 java.util.Map getSession()
           
 java.lang.Object getSessionAttribute(java.lang.String name)
           
 java.lang.String getTheme()
           
 UploadedFile getUploadedFile(java.lang.String name)
           
 void invalidateSession()
           
 boolean isError()
           
 void removeRequestAttribute(java.lang.String name)
           
 void removeSessionAttribute(java.lang.String name)
           
 void setCookie(org.apache.commons.httpclient.Cookie cookie)
           
 void setError(java.lang.String html)
          Passthru method to set the error content on the internal Page object
 void setForward(java.lang.String moduleName)
          This will forward to the module and perform its main method
 void setForward(java.lang.String moduleName, java.lang.String opName)
          This will forward to the module and perform the method specified by op and will pass no other parameters
 void setForward(java.lang.String moduleName, java.lang.String opName, java.util.HashMap params)
          This method is used to force a redirect after the current iteration of the interceptor chain has completed.
 void setModuleContent(java.lang.String html, java.lang.String name)
          Passthru method to set the module content on the internal Page object
 void setModuleContent(java.lang.String html, java.lang.String name, java.lang.String theme)
          force a specific theme - used primarily for printing
 void setProject(Project project)
           
 boolean setProperties(java.lang.Object bean)
          Uses bean introspection to set writable properties of bean from the parameters, where a (case-insensitive) name match between the bean property and the parameter is looked for
protected  void setProperty(java.lang.Object bean, java.beans.PropertyDescriptor prop)
          Set the property 'prop' in the bean to the value of the corresponding parameters.
 void setRequestAttribute(java.lang.String name, java.lang.Object value)
           
 void setRequestAttributes(java.util.Map requestAttributes)
           
 void setRequestData(java.util.Map requestData)
           
 void setSession(java.util.Map session)
           
 void setSessionAttribute(java.lang.String name, java.lang.Object value)
           
 void setTheme(java.lang.String theme)
           
 void setWorkflowUser(CoefficientUser workflowUser)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CURRENT_PROJECT

public static final java.lang.String CURRENT_PROJECT
See Also:
Constant Field Values

LAST_NON_HELP_OP

public static final java.lang.String LAST_NON_HELP_OP
See Also:
Constant Field Values

URL_PREFIX

protected static final java.lang.String URL_PREFIX
See Also:
Constant Field Values

page_

protected Page page_
The page to handle this request


redirectionURL

protected java.lang.String redirectionURL
URL to redirect to if set


domain

protected java.lang.String domain

requestURL

protected java.lang.String requestURL

inWorkflowAction

protected boolean inWorkflowAction

invalidateSession

protected boolean invalidateSession

tempUser

private CoefficientUser tempUser

workflowUser

private CoefficientUser workflowUser

multipartRequest

protected MultipartRequest multipartRequest

session

protected java.util.Map session

requestData

protected java.util.Map requestData

requestAttributes

protected java.util.Map requestAttributes

fileUploadData

protected java.util.Map fileUploadData

serializableExistingCookies

protected org.apache.commons.httpclient.Cookie[] serializableExistingCookies

serializableNewCookies

protected java.util.ArrayList serializableNewCookies

removedSessionKeys

protected java.util.ArrayList removedSessionKeys
Constructor Detail

BaseCoefficientContext

public BaseCoefficientContext()
Method Detail

setError

public void setError(java.lang.String html)
Passthru method to set the error content on the internal Page object

Specified by:
setError in interface CoefficientContext
Parameters:
html - a String containing the html content defining an error display

isError

public boolean isError()
Specified by:
isError in interface CoefficientContext

getPage

public Page getPage()
Specified by:
getPage in interface CoefficientContext

getTheme

public java.lang.String getTheme()
Specified by:
getTheme in interface CoefficientContext

setTheme

public void setTheme(java.lang.String theme)
Specified by:
setTheme in interface CoefficientContext

setForward

public void setForward(java.lang.String moduleName)
                throws ConfigurationException
This will forward to the module and perform its main method

Specified by:
setForward in interface CoefficientContext
Throws:
ConfigurationException

setForward

public void setForward(java.lang.String moduleName,
                       java.lang.String opName)
                throws ConfigurationException
This will forward to the module and perform the method specified by op and will pass no other parameters

Specified by:
setForward in interface CoefficientContext
Throws:
ConfigurationException

setForward

public void setForward(java.lang.String moduleName,
                       java.lang.String opName,
                       java.util.HashMap params)
                throws ConfigurationException
This method is used to force a redirect after the current iteration of the interceptor chain has completed.

Specified by:
setForward in interface CoefficientContext
Parameters:
moduleName - is the module to forward control to, this must not be null
opName - is the operation that the forwarded module should perform if this value is null then it will use the MainMethod
params - is a hashmap containing key-value pairs that will be additional parameters included on the request line to the specified module. If null no additional parameters will be sent
Throws:
configuationException - is thrown if module name is empty or null
ConfigurationException

setModuleContent

public void setModuleContent(java.lang.String html,
                             java.lang.String name)
                      throws java.lang.RuntimeException
Passthru method to set the module content on the internal Page object

Specified by:
setModuleContent in interface CoefficientContext
Parameters:
html - a String containing the html content the module wants to display
name - is the result of the call to getModuleName on the module setting the content
Throws:
java.lang.RuntimeException

setModuleContent

public void setModuleContent(java.lang.String html,
                             java.lang.String name,
                             java.lang.String theme)
                      throws java.lang.RuntimeException
force a specific theme - used primarily for printing

Specified by:
setModuleContent in interface CoefficientContext
Throws:
java.lang.RuntimeException

clearModuleContent

public java.lang.String clearModuleContent(java.lang.String name)
Description copied from interface: CoefficientContext
This method can be used to clear a modules set content from the page before it has been rendered. The content is returned so you can do what you would like with the content but it will not show up in the page unless placed there manually.

Specified by:
clearModuleContent in interface CoefficientContext
Returns:
is the content html string if content has been set for the module, null otherwise.

setCookie

public void setCookie(org.apache.commons.httpclient.Cookie cookie)
Specified by:
setCookie in interface CoefficientContext

getCookies

public org.apache.commons.httpclient.Cookie[] getCookies()
Specified by:
getCookies in interface CoefficientContext

getMultipartRequest

public BaseMultipartRequest getMultipartRequest()
                                         throws org.apache.commons.fileupload.FileUploadException
Specified by:
getMultipartRequest in interface CoefficientContext
Throws:
org.apache.commons.fileupload.FileUploadException

getParameter

public java.lang.String getParameter(java.lang.String name)
Passthru method to the request object.

Specified by:
getParameter in interface CoefficientContext
Parameters:
name - a String containing the paramameter name.
Returns:
a String containing the parameter value.
See Also:
The getParameter() with a default value.

getParameterValues

public java.lang.String[] getParameterValues(java.lang.String name)
Passthru method to the request object. If request is null, return an empty array of String.

Specified by:
getParameterValues in interface CoefficientContext
Parameters:
name - a String containing the parameter name.
Returns:
an array of Strings with all values associated

getParametersValues

public java.lang.String[] getParametersValues(java.lang.String name)
Specified by:
getParametersValues in interface CoefficientContext

setProperties

public boolean setProperties(java.lang.Object bean)
Uses bean introspection to set writable properties of bean from the parameters, where a (case-insensitive) name match between the bean property and the parameter is looked for

Specified by:
setProperties in interface CoefficientContext
Parameters:
bean - an object
Returns:
if true then all properties were successfully set, else some were not

setRequestAttribute

public void setRequestAttribute(java.lang.String name,
                                java.lang.Object value)
Specified by:
setRequestAttribute in interface za.co.csir.icomtek.workflow.interfaces.WorkflowContext

getRequestAttribute

public java.lang.Object getRequestAttribute(java.lang.String name)
Specified by:
getRequestAttribute in interface CoefficientContext

setSessionAttribute

public void setSessionAttribute(java.lang.String name,
                                java.lang.Object value)
Specified by:
setSessionAttribute in interface CoefficientContext

getSessionAttribute

public java.lang.Object getSessionAttribute(java.lang.String name)
Specified by:
getSessionAttribute in interface CoefficientContext

removeRequestAttribute

public void removeRequestAttribute(java.lang.String name)
Specified by:
removeRequestAttribute in interface za.co.csir.icomtek.workflow.interfaces.WorkflowContext

removeSessionAttribute

public void removeSessionAttribute(java.lang.String name)
Specified by:
removeSessionAttribute in interface CoefficientContext

getParameter

public java.lang.String getParameter(java.lang.String name,
                                     java.lang.String defaultValue)
Passthru method to the request object.

Specified by:
getParameter in interface CoefficientContext
Parameters:
name - a String with the name of the parameter
defaultValue - if no parameter with that name is defined the return value is the defaultValue
Returns:
a String with the parameter value or the default value.

getParameterAsBoolean

public boolean getParameterAsBoolean(java.lang.String name)
Specified by:
getParameterAsBoolean in interface CoefficientContext

getParameterAsDate

public java.util.Date getParameterAsDate(java.lang.String name)
Specified by:
getParameterAsDate in interface CoefficientContext

getParameterAsDouble

public java.lang.Double getParameterAsDouble(java.lang.String name,
                                             double defaultValue)
Specified by:
getParameterAsDouble in interface CoefficientContext

getParameterAsDouble

public java.lang.Double getParameterAsDouble(java.lang.String name)
Specified by:
getParameterAsDouble in interface CoefficientContext

getParameterAsDoublePrimitive

public double getParameterAsDoublePrimitive(java.lang.String name,
                                            double defaultValue)
Specified by:
getParameterAsDoublePrimitive in interface CoefficientContext

getParameterAsInt

public int getParameterAsInt(java.lang.String name,
                             int defaultValue)
Specified by:
getParameterAsInt in interface CoefficientContext

getParameterAsInteger

public java.lang.Integer getParameterAsInteger(java.lang.String name,
                                               int defaultValue)
Specified by:
getParameterAsInteger in interface CoefficientContext

getParameterAsInteger

public java.lang.Integer getParameterAsInteger(java.lang.String name)
Specified by:
getParameterAsInteger in interface CoefficientContext

getParameterAsLong

public java.lang.Long getParameterAsLong(java.lang.String name,
                                         long defaultValue)
Specified by:
getParameterAsLong in interface CoefficientContext

getParameterAsLong

public java.lang.Long getParameterAsLong(java.lang.String name)
Specified by:
getParameterAsLong in interface CoefficientContext

getParameterAsLongPrimitive

public long getParameterAsLongPrimitive(java.lang.String name,
                                        long defaultValue)
Specified by:
getParameterAsLongPrimitive in interface CoefficientContext

getParameterValuesLong

public java.lang.Long[] getParameterValuesLong(java.lang.String name)
Method to the request values as longs.

Specified by:
getParameterValuesLong in interface CoefficientContext
Parameters:
name - a String containing the parameter name.
Returns:
an array of Longs with all values associated

getUploadedFile

public UploadedFile getUploadedFile(java.lang.String name)
                             throws org.apache.commons.fileupload.FileUploadException
Specified by:
getUploadedFile in interface CoefficientContext
Throws:
org.apache.commons.fileupload.FileUploadException

setWorkflowUser

public void setWorkflowUser(CoefficientUser workflowUser)
Specified by:
setWorkflowUser in interface CoefficientContext

beginWorkflowAction

public void beginWorkflowAction()
This is used to do anything that needs doing for a workflow action to succeed

Specified by:
beginWorkflowAction in interface za.co.csir.icomtek.workflow.interfaces.WorkflowContext

endWorkflowAction

public void endWorkflowAction()
This should reset the state if need be

Specified by:
endWorkflowAction in interface za.co.csir.icomtek.workflow.interfaces.WorkflowContext

getLastNonHelpOp

public java.lang.String getLastNonHelpOp()
Specified by:
getLastNonHelpOp in interface CoefficientContext

setProject

public void setProject(Project project)
Specified by:
setProject in interface CoefficientContext

getProject

public Project getProject()
Specified by:
getProject in interface CoefficientContext

invalidateSession

public void invalidateSession()
Specified by:
invalidateSession in interface CoefficientContext

getCurrentUser

public CoefficientUser getCurrentUser()
If a user is logged in this will return that user otherwise it will return null

Specified by:
getCurrentUser in interface CoefficientContext
Returns:
the logged in user or null if not logged in

getRequestURL

public java.lang.String getRequestURL()
Specified by:
getRequestURL in interface CoefficientContext

setProperty

protected void setProperty(java.lang.Object bean,
                           java.beans.PropertyDescriptor prop)
                    throws java.lang.Exception
Set the property 'prop' in the bean to the value of the corresponding parameters. Supports all types supported by getXXX methods plus a few more that come for free because primitives have to be wrapped before being passed to invoke anyway.

Parameters:
bean - An Object.
prop - A PropertyDescriptor.
Throws:
java.lang.Exception - a generic exception.

clearPage

protected void clearPage()
                  throws java.io.IOException
Throws:
java.io.IOException

createPageObject

protected void createPageObject()
                         throws java.io.IOException
Throws:
java.io.IOException

getCallerClassName

private java.lang.String getCallerClassName()

getRequestAttributes

public java.util.Map getRequestAttributes()

setRequestAttributes

public void setRequestAttributes(java.util.Map requestAttributes)

getRequestData

public java.util.Map getRequestData()

setRequestData

public void setRequestData(java.util.Map requestData)

getSession

public java.util.Map getSession()

setSession

public void setSession(java.util.Map session)


Copyright CSIR. All Rights Reserved.