001: /*
002: * Coefficient - facilitates project based collaboration
003: * Copyright (C) 2003, Dylan Etkin, CSIR icomtek
004: * PO Box 395
005: * Pretoria 0001, RSA
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or (at your option) any later version.
010: * This library is distributed in the hope that it will be useful,
011: * but WITHOUT ANY WARRANTY; without even the implied warranty of
012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013: * Lesser General Public License for more details.
014: *
015: * You should have received a copy of the GNU Lesser General Public
016: * License along with this library; if not, write to the Free Software
017: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
018: */
019:
020: package za.org.coefficient.interfaces;
021:
022: import org.apache.commons.fileupload.FileUploadException;
023: import org.apache.commons.httpclient.Cookie;
024:
025: import za.co.csir.icomtek.workflow.interfaces.WorkflowContext;
026: import za.org.coefficient.authentication.CoefficientUser;
027: import za.org.coefficient.core.Project;
028: import za.org.coefficient.exception.ConfigurationException;
029: import za.org.coefficient.html.Page;
030: import za.org.coefficient.util.common.BaseMultipartRequest;
031: import za.org.coefficient.util.common.UploadedFile;
032:
033: import java.io.IOException;
034: import java.util.Date;
035: import java.util.HashMap;
036:
037: /**
038: * DOCUMENT ME!
039: *
040: * @author $author$
041: * @version $Revision: 1.7 $
042: */
043: public interface CoefficientContext extends WorkflowContext {
044: //~ Methods ================================================================
045:
046: public void setCookie(Cookie cookie);
047:
048: public Cookie[] getCookies();
049:
050: /**
051: * If a user is logged in this will return that user otherwise it will
052: * return null
053: *
054: * @return the logged in user or null if not logged in
055: */
056: public CoefficientUser getCurrentUser();
057:
058: /**
059: * Passthru method to set the error content on the internal Page object
060: *
061: * @param html a String containing the html content defining an error
062: * display
063: */
064: public void setError(String html);
065:
066: public boolean isError();
067:
068: /**
069: * This will forward to the module and perform its main method
070: */
071: public void setForward(String moduleName)
072: throws ConfigurationException;
073:
074: /**
075: * This will forward to the module and perform the method specified by
076: * op and will pass no other parameters
077: */
078: public void setForward(String moduleName, String opName)
079: throws ConfigurationException;
080:
081: /**
082: * This method is used to force a redirect after the current iteration
083: * of the interceptor chain has completed.
084: *
085: * @param moduleName is the module to forward control to, this must not
086: * be null
087: * @param opName is the operation that the forwarded module should perform
088: * if this value is null then it will use the MainMethod
089: * @param params is a hashmap containing key-value pairs that will be
090: * additional parameters included on the request line to the
091: * specified module. If null no additional parameters will
092: * be sent
093: *
094: * @exception configuationException is thrown if module name is empty
095: * or null
096: */
097: public void setForward(String moduleName, String opName,
098: HashMap params) throws ConfigurationException;
099:
100: /**
101: * Passthru method to set the module content on the internal Page object
102: *
103: * @param html a String containing the html content the module wants to
104: * display
105: * @param name is the result of the call to getModuleName on the module
106: * setting the content
107: */
108: public void setModuleContent(String html, String name)
109: throws RuntimeException;
110:
111: /**
112: * force a specific theme - used primarily for printing
113: */
114: public void setModuleContent(String html, String name, String theme)
115: throws RuntimeException;
116:
117: /**
118: * This method can be used to clear a modules set content from the
119: * page before it has been rendered. The content is returned so you
120: * can do what you would like with the content but it will not show
121: * up in the page unless placed there manually.
122: *
123: * @param moduleName is the name of the modules content to clear.
124: * @return is the content html string if content has been set for the
125: * module, null otherwise.
126: */
127: public String clearModuleContent(String name);
128:
129: public BaseMultipartRequest getMultipartRequest()
130: throws FileUploadException;
131:
132: public Page getPage();
133:
134: public String getTheme();
135:
136: public void setTheme(String theme);
137:
138: /**
139: * Passthru method to the request object.
140: *
141: * @param name a String containing the paramameter name.
142: * @return a String containing the parameter value.
143: *
144: *
145: * @see #getParameter(String,String) The getParameter() with a default value.
146: *
147: */
148: public String getParameter(String name);
149:
150: /**
151: * Passthru method to the request object.
152: *
153: * @param name a String with the name of the parameter
154: * @param defaultValue if no parameter with that name is defined
155: * the return value is the defaultValue
156: * @return a String with the parameter value or
157: * the default value.
158: */
159: public String getParameter(String name, String defaultValue);
160:
161: public boolean getParameterAsBoolean(String name);
162:
163: public Date getParameterAsDate(String name);
164:
165: public Double getParameterAsDouble(String name, double defaultValue);
166:
167: public Double getParameterAsDouble(String name);
168:
169: public double getParameterAsDoublePrimitive(String name,
170: double defaultValue);
171:
172: public int getParameterAsInt(String name, int defaultValue);
173:
174: public Integer getParameterAsInteger(String name, int defaultValue);
175:
176: public Integer getParameterAsInteger(String name);
177:
178: public Long getParameterAsLong(String name, long defaultValue);
179:
180: public Long getParameterAsLong(String name);
181:
182: public long getParameterAsLongPrimitive(String name,
183: long defaultValue);
184:
185: /**
186: * Passthru method to the request object. If request
187: * is null, return an empty array of String.
188: *
189: * @param name a String containing the parameter name.
190: * @return an array of Strings with all values associated
191: *
192: */
193: public String[] getParameterValues(String name);
194:
195: /**
196: * Passthru method to the request object. If request
197: * is null, return an empty array of String.
198: *
199: * @param name a String containing the parameter name.
200: * @return an array of Strings with all values associated
201: *
202: */
203: public Long[] getParameterValuesLong(String name);
204:
205: public String[] getParametersValues(String name);
206:
207: public void setProject(Project project);
208:
209: public Project getProject();
210:
211: /**
212: * Uses bean introspection to set writable properties of bean from the
213: * parameters, where a (case-insensitive) name match between the bean
214: * property and the parameter is looked for
215: *
216: * @param bean an object
217: * @return if true then all properties were successfully set, else some
218: * were not
219: */
220: public boolean setProperties(Object bean);
221:
222: public Object getRequestAttribute(String name);
223:
224: public String getRequestURL();
225:
226: public String getLastNonHelpOp();
227:
228: public void setSessionAttribute(String name, Object value);
229:
230: public Object getSessionAttribute(String name);
231:
232: public UploadedFile getUploadedFile(String name)
233: throws FileUploadException;
234:
235: public void setWorkflowUser(CoefficientUser workflowUser);
236:
237: public void invalidateSession();
238:
239: public void removeSessionAttribute(String name);
240:
241: }
|