001: /*
002: * (C) Copyright 2004 Nabh Information Systems, Inc.
003: *
004: * All copyright notices regarding Nabh's products MUST remain
005: * intact in the scripts and in the outputted HTML.
006: * This program is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public License
008: * as published by the Free Software Foundation; either version 2.1
009: * of the License, or (at your option) any later version.
010: *
011: * This program is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014: * GNU Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public License
017: * along with this program; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
019: *
020: */
021: package com.nabhinc.portlet.mvcportlet.core;
022:
023: /**
024: * Configuration associated with an action type, i.e., a
025: * request type used in processAction method of ControllerPortlet.
026: *
027: * @author Padmanabh Dabke
028: * (c) 2004 Nabh Information Systems, Inc. All Rights Reserved.
029: */
030: public class ActionConfig extends RequestConfig {
031:
032: /**
033: * Should we validate the form associated with this action type.
034: */
035: private boolean acValidateForm = true;
036:
037: /**
038: * Should we transfer parameters on ActionRequest to render
039: * request or session.
040: */
041: private boolean acSetRenderParameters = true;
042:
043: /**
044: * Associated ActionProcessor
045: */
046: private ActionProcessor acActionProcessor = null;
047:
048: /**
049: * Maximum size of an uploaded file.
050: * Relevant only when this action is used to upload files.
051: */
052: private long acMaxFileSize = 1000000;
053:
054: /**
055: * File size threshold beyond which the file is
056: * temporarily written down to a disk.
057: * Relevant only when this action is used to upload files.
058: */
059: private int acThreshold = 500000;
060:
061: /**
062: * Should we wrap multipart requests (i.e. file upload
063: * requests) in a wrapper request that provides seamless
064: * access to request parameters and uploaded files.
065: */
066: private boolean acWrapMultipart = true;
067:
068: /**
069: * Scope of this action. This is used in transferring ActionRequest
070: * parameters to render request/portlet session.
071: */
072: private int acScope = Constants.SCOPE_UNSPECIFIED;
073:
074: /**
075: * Returns the ActionProcessor associated with this action type.
076: * @return ActionProcessor associated with this action type.
077: */
078: public ActionProcessor getActionProcessor() {
079: return acActionProcessor;
080: }
081:
082: /**
083: * Sets ActionProcessor associated with this action type.
084: * @param pr ActionProcessor object corresponding to this action type.
085: */
086: public void setActionProcessor(ActionProcessor pr) {
087: acActionProcessor = pr;
088: }
089:
090: /**
091: * Returns the flag indicating whether the form associated with this
092: * action type should be validated in processAction method.
093: */
094: public boolean isValidateForm() {
095: return acValidateForm;
096: }
097:
098: /**
099: * Sets the flag indicating whether form validation is on or off.
100: * @param validate Validation flag
101: */
102:
103: public void setValidateForm(boolean validate) {
104: acValidateForm = validate;
105: }
106:
107: /**
108: * Returns flag indicating if ActionRequest parameters are to
109: * be copied to render request/portlet session.
110: * @return Flag indicating if ActionRequest parameters are to
111: * be transferred.
112: */
113: public boolean isSetRenderParameters() {
114: return acSetRenderParameters;
115: }
116:
117: /**
118: * Sets the flag indicating if ActionRequest parameters are to
119: * be copied to render request/portlet session.
120: * @param flag
121: */
122: public void setSetRenderParameters(boolean flag) {
123: acSetRenderParameters = flag;
124: }
125:
126: /**
127: * Sets the maximum size of an uploaded file.
128: * Relevant only when this action is used to upload files.
129: * @param fileSize Maximum upload file size in bytes.
130: */
131: public void setMaxFileSize(long fileSize) {
132: acMaxFileSize = fileSize;
133: }
134:
135: /**
136: * Returns the maximum size of an uploaded file.
137: * Relevant only when this action is used to upload files.
138: * @return Maximum upload file size in bytes
139: */
140: public long getMaxFileSize() {
141: return acMaxFileSize;
142: }
143:
144: /**
145: * Sets the file size threshold beyond which the file is
146: * temporarily written down to a disk.
147: * Relevant only when this action is used to upload files.
148: * @param threshold Threshold in bytes
149: */
150: public void setThreshold(int threshold) {
151: acThreshold = threshold;
152: }
153:
154: /**
155: * Sets the file size threshold beyond which the file is
156: * temporarily written down to a disk.
157: * Relevant only when this action is used to upload files.
158: * @return Threshold in bytes.
159: */
160: public int getThreshold() {
161: return acThreshold;
162: }
163:
164: /**
165: * Retrieves action scope. This value affects the way ActionRequest
166: * parameters are processed. If the scope is Constants.SCOPE_REQUEST,
167: * action paramters are copied to render parameters. If the scope
168: * is Constants.SCOPE_PORTLET_SESSION, the action parameters are
169: * copied as attributes on portlet session within the portlet scope.
170: * If the scope is Constants.SCOPE_APPLICATION_SESSION, the action
171: * parameters are coped to attributes on portlet session under
172: * application scope, else those parameters will be set as
173: * attributes under the portlet context.
174: * @return Scope of this action: Constants.SCOPE_REQUEST,
175: * Constants.SCOPE_PORTLET_SESSION, Costants.SCOPE_APPLICATION_SESSION,
176: * or Constants.SCOPE_PORTLET_CONTEXT
177: */
178: public int getScope() {
179: return acScope;
180: }
181:
182: /**
183: * Sets action scope. This value affects the way ActionRequest
184: * parameters are processed. If the scope is Constants.SCOPE_REQUEST,
185: * action paramters are copied to render parameters. If the scope
186: * is Constants.SCOPE_PORTLET_SESSION, the action parameters are
187: * copied as attributes on portlet session within the portlet scope.
188: * If the scope is Constants.SCOPE_APPLICATION_SESSION, the action
189: * parameters are copied to attributes on portlet session under
190: * application scope, else those parameters will be set as
191: * portlet context attributes so that they are available globally.
192: * @param scope Scope of this action: Constants.SCOPE_REQUEST,
193: * Constants.SCOPE_PORTLET_SESSION, Costants.SCOPE_APPLICATION_SESSION,
194: * or Constants.SCOPE_PORTLET_CONTEXT.
195: */
196: public void setScope(int scope) {
197: acScope = scope;
198: }
199:
200: /**
201: * Get the flag indicating if a multipart (file upload) request
202: * should be wrapped in a convenience request wrapper that makes
203: * the request parameters and files accessible as regular parameters
204: * and attributes.
205: * @return Returns true multipart requests would be wrapped in a
206: * request wrapper.
207: */
208: public boolean isWrapMultipart() {
209: return acWrapMultipart;
210: }
211:
212: /**
213: * Sets the flag indicating if a multipart (file upload) request
214: * should be wrapped in a convenience request wrapper that makes
215: * the request parameters and files accessible as regular parameters
216: * and attributes.
217: * @param flag If true multipart requests would be wrapped in a
218: * request wrapper.
219: */
220: public void setWrapMultipart(boolean flag) {
221: acWrapMultipart = flag;
222: }
223: }
|