1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
package org.kuali.rice.kns.web.struts.action; |
18 | |
|
19 | |
import org.apache.commons.lang.ObjectUtils; |
20 | |
import org.apache.commons.lang.StringUtils; |
21 | |
import org.apache.struts.action.ActionForm; |
22 | |
import org.apache.struts.action.ActionForward; |
23 | |
import org.apache.struts.action.ActionMapping; |
24 | |
import org.apache.struts.actions.DispatchAction; |
25 | |
import org.kuali.rice.core.api.CoreApiServiceLocator; |
26 | |
import org.kuali.rice.core.api.encryption.EncryptionService; |
27 | |
import org.kuali.rice.core.api.util.RiceConstants; |
28 | |
import org.kuali.rice.kim.api.services.KimApiServiceLocator; |
29 | |
import org.kuali.rice.kim.util.KimConstants; |
30 | |
import org.kuali.rice.kns.lookup.LookupUtils; |
31 | |
import org.kuali.rice.kns.service.BusinessObjectAuthorizationService; |
32 | |
import org.kuali.rice.kns.service.KNSServiceLocator; |
33 | |
import org.kuali.rice.kns.util.KNSGlobalVariables; |
34 | |
import org.kuali.rice.kns.util.WebUtils; |
35 | |
import org.kuali.rice.kns.web.struts.form.KualiDocumentFormBase; |
36 | |
import org.kuali.rice.kns.web.struts.form.KualiForm; |
37 | |
import org.kuali.rice.kns.web.struts.form.LookupForm; |
38 | |
import org.kuali.rice.kns.web.struts.form.pojo.PojoForm; |
39 | |
import org.kuali.rice.kns.web.struts.form.pojo.PojoFormBase; |
40 | |
import org.kuali.rice.krad.bo.BusinessObject; |
41 | |
import org.kuali.rice.krad.document.authorization.DocumentAuthorizerBase; |
42 | |
import org.kuali.rice.krad.exception.AuthorizationException; |
43 | |
import org.kuali.rice.krad.service.KRADServiceLocator; |
44 | |
import org.kuali.rice.krad.service.KRADServiceLocatorWeb; |
45 | |
import org.kuali.rice.krad.service.KualiModuleService; |
46 | |
import org.kuali.rice.krad.service.ModuleService; |
47 | |
import org.kuali.rice.krad.util.GlobalVariables; |
48 | |
import org.kuali.rice.krad.util.KRADConstants; |
49 | |
import org.kuali.rice.krad.util.KRADUtils; |
50 | |
import org.kuali.rice.krad.util.UrlFactory; |
51 | |
|
52 | |
import javax.servlet.http.HttpServletRequest; |
53 | |
import javax.servlet.http.HttpServletResponse; |
54 | |
import java.util.Arrays; |
55 | |
import java.util.Enumeration; |
56 | |
import java.util.HashMap; |
57 | |
import java.util.HashSet; |
58 | |
import java.util.Map; |
59 | |
import java.util.Properties; |
60 | |
import java.util.Set; |
61 | |
|
62 | |
|
63 | |
|
64 | |
|
65 | |
|
66 | |
|
67 | |
|
68 | |
|
69 | |
|
70 | |
|
71 | |
|
72 | 0 | public abstract class KualiAction extends DispatchAction { |
73 | 0 | private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(KualiAction.class); |
74 | |
|
75 | 0 | private static KualiModuleService kualiModuleService = null; |
76 | 0 | private static BusinessObjectAuthorizationService businessObjectAuthorizationService = null; |
77 | 0 | private static EncryptionService encryptionService = null; |
78 | 0 | private static Boolean OUTPUT_ENCRYPTION_WARNING = null; |
79 | 0 | private static String applicationBaseUrl = null; |
80 | |
|
81 | 0 | private Set<String> methodToCallsToNotCheckAuthorization = new HashSet<String>(); |
82 | |
|
83 | |
{ |
84 | 0 | methodToCallsToNotCheckAuthorization.add( "performLookup" ); |
85 | 0 | methodToCallsToNotCheckAuthorization.add( "performQuestion" ); |
86 | 0 | methodToCallsToNotCheckAuthorization.add( "performQuestionWithInput" ); |
87 | 0 | methodToCallsToNotCheckAuthorization.add( "performQuestionWithInputAgainBecauseOfErrors" ); |
88 | 0 | methodToCallsToNotCheckAuthorization.add( "performQuestionWithoutInput" ); |
89 | 0 | methodToCallsToNotCheckAuthorization.add( "performWorkgroupLookup" ); |
90 | 0 | } |
91 | |
|
92 | |
|
93 | |
|
94 | |
|
95 | |
|
96 | |
|
97 | |
|
98 | |
|
99 | |
|
100 | |
|
101 | |
|
102 | |
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { |
103 | 0 | ActionForward returnForward = null; |
104 | |
|
105 | 0 | String methodToCall = findMethodToCall(form, request); |
106 | 0 | if (form instanceof KualiForm && StringUtils.isNotEmpty(((KualiForm) form).getMethodToCall())) { |
107 | 0 | if (StringUtils.isNotBlank(getImageContext(request, KRADConstants.ANCHOR))) { |
108 | 0 | ((KualiForm) form).setAnchor(getImageContext(request, KRADConstants.ANCHOR)); |
109 | |
} |
110 | 0 | else if (StringUtils.isNotBlank(request.getParameter(KRADConstants.ANCHOR))) { |
111 | 0 | ((KualiForm) form).setAnchor(request.getParameter(KRADConstants.ANCHOR)); |
112 | |
} |
113 | |
else { |
114 | 0 | ((KualiForm) form).setAnchor(KRADConstants.ANCHOR_TOP_OF_FORM); |
115 | |
} |
116 | |
} |
117 | |
|
118 | 0 | if (StringUtils.isNotBlank(methodToCall)) { |
119 | 0 | if ( LOG.isDebugEnabled() ) { |
120 | 0 | LOG.debug("methodToCall: '" + methodToCall+"'"); |
121 | |
} |
122 | 0 | returnForward = dispatchMethod(mapping, form, request, response, methodToCall); |
123 | |
} |
124 | |
else { |
125 | 0 | returnForward = defaultDispatch(mapping, form, request, response); |
126 | |
} |
127 | |
|
128 | |
|
129 | 0 | if ( !methodToCallsToNotCheckAuthorization.contains(methodToCall) ) { |
130 | 0 | if ( LOG.isDebugEnabled() ) { |
131 | 0 | LOG.debug( "'" + methodToCall + "' not in set of excempt methods: " + methodToCallsToNotCheckAuthorization); |
132 | |
} |
133 | 0 | checkAuthorization(form, methodToCall); |
134 | |
} else { |
135 | 0 | if ( LOG.isDebugEnabled() ) { |
136 | 0 | LOG.debug("'" + methodToCall + "' is exempt from auth checks." ); |
137 | |
} |
138 | |
} |
139 | |
|
140 | |
|
141 | |
|
142 | |
|
143 | 0 | if(KNSGlobalVariables.getKualiForm() == null) { |
144 | 0 | KNSGlobalVariables.setKualiForm((KualiForm)form); |
145 | |
} |
146 | |
|
147 | 0 | return returnForward; |
148 | |
} |
149 | |
|
150 | |
|
151 | |
|
152 | |
|
153 | |
|
154 | |
protected ActionForward defaultDispatch(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { |
155 | 0 | return mapping.findForward(RiceConstants.MAPPING_BASIC); |
156 | |
} |
157 | |
|
158 | |
@Override |
159 | |
protected ActionForward dispatchMethod(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response, String methodToCall) throws Exception { |
160 | 0 | GlobalVariables.getUserSession().addObject(DocumentAuthorizerBase.USER_SESSION_METHOD_TO_CALL_OBJECT_KEY, methodToCall); |
161 | 0 | return super.dispatchMethod(mapping, form, request, response, methodToCall); |
162 | |
} |
163 | |
|
164 | |
protected String findMethodToCall(ActionForm form, HttpServletRequest request) throws Exception { |
165 | |
String methodToCall; |
166 | 0 | if (form instanceof KualiForm && StringUtils.isNotEmpty(((KualiForm) form).getMethodToCall())) { |
167 | 0 | methodToCall = ((KualiForm) form).getMethodToCall(); |
168 | |
} |
169 | |
else { |
170 | |
|
171 | 0 | methodToCall = WebUtils.parseMethodToCall(form, request); |
172 | |
} |
173 | 0 | return methodToCall; |
174 | |
} |
175 | |
|
176 | |
|
177 | |
|
178 | |
|
179 | |
|
180 | |
|
181 | |
|
182 | |
|
183 | |
|
184 | |
|
185 | |
|
186 | |
public ActionForward toggleTab(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { |
187 | 0 | KualiForm kualiForm = (KualiForm) form; |
188 | 0 | String tabToToggle = getTabToToggle(request); |
189 | 0 | if (StringUtils.isNotBlank(tabToToggle)) { |
190 | 0 | if (kualiForm.getTabState(tabToToggle).equals("OPEN")) { |
191 | 0 | kualiForm.getTabStates().remove(tabToToggle); |
192 | 0 | kualiForm.getTabStates().put(tabToToggle, "CLOSE"); |
193 | |
} |
194 | |
else { |
195 | 0 | kualiForm.getTabStates().remove(tabToToggle); |
196 | 0 | kualiForm.getTabStates().put(tabToToggle, "OPEN"); |
197 | |
} |
198 | |
} |
199 | |
|
200 | 0 | doProcessingAfterPost( kualiForm, request ); |
201 | 0 | return mapping.findForward(RiceConstants.MAPPING_BASIC); |
202 | |
} |
203 | |
|
204 | |
|
205 | |
|
206 | |
|
207 | |
|
208 | |
|
209 | |
|
210 | |
|
211 | |
|
212 | |
|
213 | |
|
214 | |
public ActionForward showAllTabs(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { |
215 | 0 | return this.doTabOpenOrClose(mapping, form, request, response, true); |
216 | |
} |
217 | |
|
218 | |
|
219 | |
|
220 | |
|
221 | |
|
222 | |
|
223 | |
|
224 | |
|
225 | |
|
226 | |
|
227 | |
|
228 | |
public ActionForward hideAllTabs(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { |
229 | 0 | return this.doTabOpenOrClose(mapping, form, request, response, false); |
230 | |
} |
231 | |
|
232 | |
|
233 | |
|
234 | |
|
235 | |
|
236 | |
|
237 | |
|
238 | |
|
239 | |
|
240 | |
|
241 | |
|
242 | |
|
243 | |
private ActionForward doTabOpenOrClose(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response, boolean open) { |
244 | 0 | KualiForm kualiForm = (KualiForm) form; |
245 | |
|
246 | 0 | Map<String, String> tabStates = kualiForm.getTabStates(); |
247 | 0 | Map<String, String> newTabStates = new HashMap<String, String>(); |
248 | 0 | for (String tabKey: tabStates.keySet()) { |
249 | 0 | newTabStates.put(tabKey, open ? "OPEN" : "CLOSE"); |
250 | |
} |
251 | 0 | kualiForm.setTabStates(newTabStates); |
252 | 0 | doProcessingAfterPost( kualiForm, request ); |
253 | 0 | return mapping.findForward(RiceConstants.MAPPING_BASIC); |
254 | |
} |
255 | |
|
256 | |
|
257 | |
|
258 | |
|
259 | |
|
260 | |
|
261 | |
|
262 | |
|
263 | |
|
264 | |
|
265 | |
|
266 | |
public ActionForward refresh(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { |
267 | 0 | return mapping.findForward(RiceConstants.MAPPING_BASIC); |
268 | |
} |
269 | |
|
270 | |
|
271 | |
|
272 | |
|
273 | |
|
274 | |
|
275 | |
|
276 | |
|
277 | |
protected int getLineToDelete(HttpServletRequest request) { |
278 | 0 | return getSelectedLine(request); |
279 | |
} |
280 | |
|
281 | |
|
282 | |
|
283 | |
|
284 | |
|
285 | |
|
286 | |
|
287 | |
protected int getSelectedLine(HttpServletRequest request) { |
288 | 0 | int selectedLine = -1; |
289 | 0 | String parameterName = (String) request.getAttribute(KRADConstants.METHOD_TO_CALL_ATTRIBUTE); |
290 | 0 | if (StringUtils.isNotBlank(parameterName)) { |
291 | 0 | String lineNumber = StringUtils.substringBetween(parameterName, ".line", "."); |
292 | 0 | selectedLine = Integer.parseInt(lineNumber); |
293 | |
} |
294 | |
|
295 | 0 | return selectedLine; |
296 | |
} |
297 | |
|
298 | |
|
299 | |
|
300 | |
|
301 | |
|
302 | |
|
303 | |
|
304 | |
protected String getTabToToggle(HttpServletRequest request) { |
305 | 0 | String tabToToggle = ""; |
306 | 0 | String parameterName = (String) request.getAttribute(KRADConstants.METHOD_TO_CALL_ATTRIBUTE); |
307 | 0 | if (StringUtils.isNotBlank(parameterName)) { |
308 | 0 | tabToToggle = StringUtils.substringBetween(parameterName, ".tab", "."); |
309 | |
} |
310 | |
|
311 | 0 | return tabToToggle; |
312 | |
} |
313 | |
|
314 | |
|
315 | |
|
316 | |
|
317 | |
|
318 | |
|
319 | |
|
320 | |
protected String getHeaderTabNavigateTo(HttpServletRequest request) { |
321 | 0 | String headerTabNavigateTo = RiceConstants.MAPPING_BASIC; |
322 | 0 | String imageContext = getImageContext(request, KRADConstants.NAVIGATE_TO); |
323 | 0 | if (StringUtils.isNotBlank(imageContext)) { |
324 | 0 | headerTabNavigateTo = imageContext; |
325 | |
} |
326 | 0 | return headerTabNavigateTo; |
327 | |
} |
328 | |
|
329 | |
|
330 | |
|
331 | |
|
332 | |
|
333 | |
|
334 | |
|
335 | |
protected String getHeaderTabDispatch(HttpServletRequest request) { |
336 | 0 | String headerTabDispatch = null; |
337 | 0 | String imageContext = getImageContext(request, KRADConstants.HEADER_DISPATCH); |
338 | 0 | if (StringUtils.isNotBlank(imageContext)) { |
339 | 0 | headerTabDispatch = imageContext; |
340 | |
} |
341 | |
else { |
342 | |
|
343 | 0 | headerTabDispatch = request.getParameter(KRADConstants.METHOD_TO_CALL_ATTRIBUTE); |
344 | |
} |
345 | 0 | return headerTabDispatch; |
346 | |
} |
347 | |
|
348 | |
|
349 | |
|
350 | |
|
351 | |
|
352 | |
|
353 | |
|
354 | |
|
355 | |
protected String getImageContext(HttpServletRequest request, String contextKey) { |
356 | 0 | String imageContext = ""; |
357 | 0 | String parameterName = (String) request.getAttribute(KRADConstants.METHOD_TO_CALL_ATTRIBUTE); |
358 | 0 | if (StringUtils.isBlank(parameterName)) { |
359 | 0 | parameterName = request.getParameter("methodToCallPath"); |
360 | |
} |
361 | 0 | if (StringUtils.isNotBlank(parameterName)) { |
362 | 0 | imageContext = StringUtils.substringBetween(parameterName, contextKey, "."); |
363 | |
} |
364 | 0 | return imageContext; |
365 | |
} |
366 | |
|
367 | |
protected String getReturnLocation(HttpServletRequest request, ActionMapping mapping) { |
368 | 0 | String mappingPath = mapping.getPath(); |
369 | 0 | String basePath = getApplicationBaseUrl(); |
370 | 0 | return basePath + ("/lookup".equals(mappingPath) || "/maintenance".equals(mappingPath) || "/multipleValueLookup".equals(mappingPath) ? "/kr" : "") + mappingPath + ".do"; |
371 | |
} |
372 | |
|
373 | |
|
374 | |
|
375 | |
|
376 | |
|
377 | |
|
378 | |
|
379 | |
|
380 | |
|
381 | |
|
382 | |
|
383 | |
|
384 | |
|
385 | |
protected String retrieveLookupParameterValue(Class<? extends BusinessObject> boClass, String parameterName, String parameterValuePropertyName, ActionForm form, HttpServletRequest request) throws Exception { |
386 | |
String value; |
387 | 0 | if (StringUtils.contains(parameterValuePropertyName, "'")) { |
388 | 0 | value = StringUtils.replace(parameterValuePropertyName, "'", ""); |
389 | |
} |
390 | 0 | else if (request.getParameterMap().containsKey(parameterValuePropertyName)) { |
391 | 0 | value = request.getParameter(parameterValuePropertyName); |
392 | |
} |
393 | |
else { |
394 | 0 | if (form instanceof KualiForm) { |
395 | 0 | value = ((KualiForm) form).retrieveFormValueForLookupInquiryParameters(parameterName, parameterValuePropertyName); |
396 | |
} else { |
397 | 0 | if (LOG.isDebugEnabled()) { |
398 | 0 | LOG.debug("Unable to retrieve lookup/inquiry parameter value for parameter name " + parameterName + " parameter value property " + parameterValuePropertyName); |
399 | |
} |
400 | 0 | value = null; |
401 | |
} |
402 | |
} |
403 | |
|
404 | 0 | if (value != null && boClass != null && getBusinessObjectAuthorizationService().attributeValueNeedsToBeEncryptedOnFormsAndLinks(boClass, parameterName)) { |
405 | 0 | value = getEncryptionService().encrypt(value) + EncryptionService.ENCRYPTION_POST_PREFIX; |
406 | |
} |
407 | 0 | return value; |
408 | |
} |
409 | |
|
410 | |
|
411 | |
|
412 | |
|
413 | |
|
414 | |
|
415 | |
|
416 | |
|
417 | |
|
418 | |
|
419 | |
|
420 | |
@SuppressWarnings("unchecked") |
421 | |
public ActionForward performLookup(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { |
422 | |
|
423 | 0 | String fullParameter = (String) request.getAttribute(KRADConstants.METHOD_TO_CALL_ATTRIBUTE); |
424 | 0 | validateLookupInquiryFullParameter(request, form, fullParameter); |
425 | |
|
426 | 0 | KualiForm kualiForm = (KualiForm) form; |
427 | |
|
428 | |
|
429 | 0 | kualiForm.registerEditableProperty(KRADConstants.DISPATCH_REQUEST_PARAMETER); |
430 | |
|
431 | |
|
432 | 0 | String baseLookupUrl = StringUtils.substringBetween(fullParameter, KRADConstants.METHOD_TO_CALL_PARM14_LEFT_DEL, KRADConstants.METHOD_TO_CALL_PARM14_RIGHT_DEL); |
433 | |
|
434 | |
|
435 | 0 | String boClassName = StringUtils.substringBetween(fullParameter, KRADConstants.METHOD_TO_CALL_BOPARM_LEFT_DEL, KRADConstants.METHOD_TO_CALL_BOPARM_RIGHT_DEL); |
436 | 0 | if (StringUtils.isBlank(boClassName)) { |
437 | 0 | throw new RuntimeException("Illegal call to perform lookup, no business object class name specified."); |
438 | |
} |
439 | 0 | Class boClass = null; |
440 | |
try{ |
441 | 0 | boClass = Class.forName(boClassName); |
442 | 0 | } catch(ClassNotFoundException cnfex){ |
443 | |
|
444 | 0 | if (StringUtils.isBlank(baseLookupUrl)) { |
445 | 0 | if ( LOG.isDebugEnabled() ) { |
446 | 0 | LOG.debug( "BO Class " + boClassName + " not found in the current context, checking the RiceApplicationConfigurationService." ); |
447 | |
} |
448 | 0 | baseLookupUrl = KRADServiceLocatorWeb.getRiceApplicationConfigurationMediationService().getBaseLookupUrl(boClassName); |
449 | 0 | if ( LOG.isDebugEnabled() ) { |
450 | 0 | LOG.debug( "URL Returned from KSB: " + baseLookupUrl ); |
451 | |
} |
452 | 0 | if ( StringUtils.isBlank(baseLookupUrl)) { |
453 | 0 | throw new IllegalArgumentException("The classname (" + boClassName + ") does not represent a valid class and no base URL could be found on the bus."); |
454 | |
} |
455 | |
} |
456 | 0 | } |
457 | |
|
458 | |
|
459 | 0 | Properties parameters = new Properties(); |
460 | 0 | String conversionFields = StringUtils.substringBetween(fullParameter, KRADConstants.METHOD_TO_CALL_PARM1_LEFT_DEL, KRADConstants.METHOD_TO_CALL_PARM1_RIGHT_DEL); |
461 | 0 | if (StringUtils.isNotBlank(conversionFields)) { |
462 | 0 | parameters.put(KRADConstants.CONVERSION_FIELDS_PARAMETER, conversionFields); |
463 | |
|
464 | |
|
465 | 0 | String[] fieldConversions = conversionFields.split(KRADConstants.FIELD_CONVERSIONS_SEPARATOR); |
466 | 0 | for (String fieldConversion : fieldConversions) { |
467 | 0 | String destination = fieldConversion.split(KRADConstants.FIELD_CONVERSION_PAIR_SEPARATOR)[1]; |
468 | 0 | kualiForm.registerEditableProperty(destination); |
469 | |
} |
470 | |
} |
471 | |
|
472 | |
|
473 | 0 | String parameterFields = StringUtils.substringBetween(fullParameter, KRADConstants.METHOD_TO_CALL_PARM2_LEFT_DEL, KRADConstants.METHOD_TO_CALL_PARM2_RIGHT_DEL); |
474 | 0 | if ( LOG.isDebugEnabled() ) { |
475 | 0 | LOG.debug( "fullParameter: " + fullParameter ); |
476 | 0 | LOG.debug( "parameterFields: " + parameterFields ); |
477 | |
} |
478 | 0 | if (StringUtils.isNotBlank(parameterFields)) { |
479 | 0 | String[] lookupParams = parameterFields.split(KRADConstants.FIELD_CONVERSIONS_SEPARATOR); |
480 | 0 | if ( LOG.isDebugEnabled() ) { |
481 | 0 | LOG.debug( "lookupParams: " + Arrays.toString(lookupParams) ); |
482 | |
} |
483 | 0 | for (String lookupParam : lookupParams) { |
484 | 0 | String[] keyValue = lookupParam.split(KRADConstants.FIELD_CONVERSION_PAIR_SEPARATOR); |
485 | 0 | if (keyValue.length != 2) { |
486 | 0 | throw new RuntimeException("malformed field conversion pair: " + Arrays.toString(keyValue)); |
487 | |
} |
488 | |
|
489 | 0 | String lookupParameterValue = retrieveLookupParameterValue(boClass, keyValue[1], keyValue[0], form, request); |
490 | 0 | if (StringUtils.isNotBlank(lookupParameterValue)) { |
491 | 0 | parameters.put(keyValue[1], lookupParameterValue); |
492 | |
} |
493 | |
|
494 | 0 | if ( LOG.isDebugEnabled() ) { |
495 | 0 | LOG.debug( "keyValue[0]: " + keyValue[0] ); |
496 | 0 | LOG.debug( "keyValue[1]: " + keyValue[1] ); |
497 | |
} |
498 | |
} |
499 | |
} |
500 | |
|
501 | |
|
502 | 0 | String readOnlyFields = StringUtils.substringBetween(fullParameter, KRADConstants.METHOD_TO_CALL_PARM8_LEFT_DEL, KRADConstants.METHOD_TO_CALL_PARM8_RIGHT_DEL); |
503 | 0 | if (StringUtils.isNotBlank(readOnlyFields)) { |
504 | 0 | parameters.put(KRADConstants.LOOKUP_READ_ONLY_FIELDS, readOnlyFields); |
505 | |
} |
506 | |
|
507 | 0 | if ( LOG.isDebugEnabled() ) { |
508 | 0 | LOG.debug( "fullParameter: " + fullParameter ); |
509 | 0 | LOG.debug( "readOnlyFields: " + readOnlyFields ); |
510 | |
} |
511 | |
|
512 | |
|
513 | 0 | String hideReturnLink = StringUtils.substringBetween(fullParameter, KRADConstants.METHOD_TO_CALL_PARM3_LEFT_DEL, KRADConstants.METHOD_TO_CALL_PARM3_RIGHT_DEL); |
514 | 0 | if (StringUtils.isNotBlank(hideReturnLink)) { |
515 | 0 | parameters.put(KRADConstants.HIDE_LOOKUP_RETURN_LINK, hideReturnLink); |
516 | |
} |
517 | |
|
518 | |
|
519 | 0 | String extraButtonSource = StringUtils.substringBetween(fullParameter, KRADConstants.METHOD_TO_CALL_PARM4_LEFT_DEL, KRADConstants.METHOD_TO_CALL_PARM4_RIGHT_DEL); |
520 | 0 | if (StringUtils.isNotBlank(extraButtonSource)) { |
521 | 0 | parameters.put(KRADConstants.EXTRA_BUTTON_SOURCE, extraButtonSource); |
522 | |
} |
523 | 0 | String extraButtonParams = StringUtils.substringBetween(fullParameter, KRADConstants.METHOD_TO_CALL_PARM5_LEFT_DEL, KRADConstants.METHOD_TO_CALL_PARM5_RIGHT_DEL); |
524 | 0 | if (StringUtils.isNotBlank(extraButtonParams)) { |
525 | 0 | parameters.put(KRADConstants.EXTRA_BUTTON_PARAMS, extraButtonParams); |
526 | |
} |
527 | |
|
528 | 0 | String lookupAction = KRADConstants.LOOKUP_ACTION; |
529 | |
|
530 | |
|
531 | 0 | boolean isMultipleValue = false; |
532 | 0 | String multipleValues = StringUtils.substringBetween(fullParameter, KRADConstants.METHOD_TO_CALL_PARM6_LEFT_DEL, KRADConstants.METHOD_TO_CALL_PARM6_RIGHT_DEL); |
533 | 0 | if ((new Boolean(multipleValues).booleanValue())) { |
534 | 0 | parameters.put(KRADConstants.MULTIPLE_VALUE, multipleValues); |
535 | 0 | lookupAction = KRADConstants.MULTIPLE_VALUE_LOOKUP_ACTION; |
536 | 0 | isMultipleValue = true; |
537 | |
} |
538 | |
|
539 | |
|
540 | 0 | String lookedUpCollectionName = StringUtils.substringBetween(fullParameter, KRADConstants.METHOD_TO_CALL_PARM11_LEFT_DEL, KRADConstants.METHOD_TO_CALL_PARM11_RIGHT_DEL); |
541 | 0 | if (StringUtils.isNotBlank(lookedUpCollectionName)) { |
542 | 0 | parameters.put(KRADConstants.LOOKED_UP_COLLECTION_NAME, lookedUpCollectionName); |
543 | |
} |
544 | |
|
545 | |
|
546 | 0 | String supressActions = StringUtils.substringBetween(fullParameter, KRADConstants.METHOD_TO_CALL_PARM7_LEFT_DEL, KRADConstants.METHOD_TO_CALL_PARM7_RIGHT_DEL); |
547 | 0 | if (StringUtils.isNotBlank(supressActions)) { |
548 | 0 | parameters.put(KRADConstants.SUPPRESS_ACTIONS, supressActions); |
549 | |
} |
550 | |
|
551 | |
|
552 | 0 | String referencesToRefresh = StringUtils.substringBetween(fullParameter, KRADConstants.METHOD_TO_CALL_PARM10_LEFT_DEL, KRADConstants.METHOD_TO_CALL_PARM10_RIGHT_DEL); |
553 | 0 | if (StringUtils.isNotBlank(referencesToRefresh)) { |
554 | 0 | parameters.put(KRADConstants.REFERENCES_TO_REFRESH, referencesToRefresh); |
555 | |
} |
556 | |
|
557 | |
|
558 | 0 | if (form instanceof KualiForm && StringUtils.isNotEmpty(((KualiForm) form).getAnchor())) { |
559 | 0 | parameters.put(KRADConstants.LOOKUP_ANCHOR, ((KualiForm) form).getAnchor()); |
560 | |
} |
561 | |
|
562 | |
|
563 | 0 | parameters.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, "start"); |
564 | |
|
565 | |
|
566 | 0 | String autoSearch = StringUtils.substringBetween(fullParameter, KRADConstants.METHOD_TO_CALL_PARM9_LEFT_DEL, KRADConstants.METHOD_TO_CALL_PARM9_RIGHT_DEL); |
567 | |
|
568 | 0 | if (StringUtils.isNotBlank(autoSearch)) { |
569 | 0 | parameters.put(KRADConstants.LOOKUP_AUTO_SEARCH, autoSearch); |
570 | 0 | if ("YES".equalsIgnoreCase(autoSearch)){ |
571 | 0 | parameters.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, "search"); |
572 | |
} |
573 | |
} |
574 | |
|
575 | 0 | parameters.put(KRADConstants.DOC_FORM_KEY, GlobalVariables.getUserSession().addObjectWithGeneratedKey(form)); |
576 | 0 | parameters.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, boClassName); |
577 | |
|
578 | 0 | parameters.put(KRADConstants.RETURN_LOCATION_PARAMETER, getReturnLocation(request, mapping)); |
579 | |
|
580 | 0 | if (form instanceof KualiDocumentFormBase) { |
581 | 0 | String docNum = ((KualiDocumentFormBase) form).getDocument().getDocumentNumber(); |
582 | 0 | if(docNum != null){ |
583 | 0 | parameters.put(KRADConstants.DOC_NUM, docNum); |
584 | |
} |
585 | 0 | }else if(form instanceof LookupForm){ |
586 | 0 | String docNum = ((LookupForm) form).getDocNum(); |
587 | 0 | if(docNum != null){ |
588 | 0 | parameters.put(KRADConstants.DOC_NUM, ((LookupForm) form).getDocNum()); |
589 | |
} |
590 | |
} |
591 | |
|
592 | 0 | if (boClass != null) { |
593 | 0 | ModuleService responsibleModuleService = getKualiModuleService().getResponsibleModuleService(boClass); |
594 | 0 | if(responsibleModuleService!=null && responsibleModuleService.isExternalizable(boClass)){ |
595 | 0 | Map<String, String> parameterMap = new HashMap<String, String>(); |
596 | 0 | Enumeration<Object> e = parameters.keys(); |
597 | 0 | while (e.hasMoreElements()) { |
598 | 0 | String paramName = (String) e.nextElement(); |
599 | 0 | parameterMap.put(paramName, parameters.getProperty(paramName)); |
600 | 0 | } |
601 | 0 | return new ActionForward(responsibleModuleService.getExternalizableBusinessObjectLookupUrl(boClass, parameterMap), true); |
602 | |
} |
603 | |
} |
604 | |
|
605 | 0 | if (StringUtils.isBlank(baseLookupUrl)) { |
606 | 0 | baseLookupUrl = getApplicationBaseUrl() + "/kr/" + lookupAction; |
607 | |
} else { |
608 | 0 | if (isMultipleValue) { |
609 | 0 | LookupUtils.transformLookupUrlToMultiple(baseLookupUrl); |
610 | |
} |
611 | |
} |
612 | 0 | String lookupUrl = UrlFactory.parameterizeUrl(baseLookupUrl, parameters); |
613 | 0 | return new ActionForward(lookupUrl, true); |
614 | |
} |
615 | |
|
616 | |
protected void validateLookupInquiryFullParameter(HttpServletRequest request, ActionForm form, String fullParameter){ |
617 | 0 | PojoFormBase pojoFormBase = (PojoFormBase) form; |
618 | 0 | if(WebUtils.isFormSessionDocument((PojoFormBase) form)){ |
619 | 0 | if(!pojoFormBase.isPropertyEditable(fullParameter)) { |
620 | 0 | throw new RuntimeException("The methodToCallAttribute is not registered as an editable property."); |
621 | |
} |
622 | |
} |
623 | 0 | } |
624 | |
|
625 | |
@SuppressWarnings("unchecked") |
626 | |
public ActionForward performInquiry(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { |
627 | |
|
628 | 0 | String fullParameter = (String) request.getAttribute(KRADConstants.METHOD_TO_CALL_ATTRIBUTE); |
629 | 0 | validateLookupInquiryFullParameter(request, form, fullParameter); |
630 | |
|
631 | |
|
632 | |
|
633 | 0 | KualiForm kualiForm = (KualiForm) form; |
634 | 0 | kualiForm.registerEditableProperty(KRADConstants.DISPATCH_REQUEST_PARAMETER); |
635 | |
|
636 | |
|
637 | 0 | String boClassName = StringUtils.substringBetween(fullParameter, KRADConstants.METHOD_TO_CALL_BOPARM_LEFT_DEL, KRADConstants.METHOD_TO_CALL_BOPARM_RIGHT_DEL); |
638 | 0 | if (StringUtils.isBlank(boClassName)) { |
639 | 0 | throw new RuntimeException("Illegal call to perform inquiry, no business object class name specified."); |
640 | |
} |
641 | |
|
642 | |
|
643 | 0 | Properties parameters = new Properties(); |
644 | 0 | parameters.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, boClassName); |
645 | |
|
646 | 0 | parameters.put(KRADConstants.RETURN_LOCATION_PARAMETER, getReturnLocation(request, mapping)); |
647 | |
|
648 | |
|
649 | 0 | String parameterFields = StringUtils.substringBetween(fullParameter, KRADConstants.METHOD_TO_CALL_PARM2_LEFT_DEL, KRADConstants.METHOD_TO_CALL_PARM2_RIGHT_DEL); |
650 | 0 | if ( LOG.isDebugEnabled() ) { |
651 | 0 | LOG.debug( "fullParameter: " + fullParameter ); |
652 | 0 | LOG.debug( "parameterFields: " + parameterFields ); |
653 | |
} |
654 | 0 | if (StringUtils.isNotBlank(parameterFields)) { |
655 | |
|
656 | 0 | String[] inquiryParams = parameterFields.split(KRADConstants.FIELD_CONVERSIONS_SEPARATOR); |
657 | 0 | if ( LOG.isDebugEnabled() ) { |
658 | 0 | LOG.debug( "inquiryParams: " + inquiryParams ); |
659 | |
} |
660 | 0 | Class<? extends BusinessObject> boClass = (Class<? extends BusinessObject>) Class.forName(boClassName); |
661 | 0 | for (String inquiryParam : inquiryParams) { |
662 | 0 | String[] keyValue = inquiryParam.split(KRADConstants.FIELD_CONVERSION_PAIR_SEPARATOR); |
663 | |
|
664 | 0 | String inquiryParameterValue = retrieveLookupParameterValue(boClass, keyValue[1], keyValue[0], form, request); |
665 | 0 | if (inquiryParameterValue == null) { |
666 | 0 | parameters.put(keyValue[1], "directInquiryKeyNotSpecified"); |
667 | |
} |
668 | |
else { |
669 | 0 | parameters.put(keyValue[1], inquiryParameterValue); |
670 | |
} |
671 | |
|
672 | 0 | if ( LOG.isDebugEnabled() ) { |
673 | 0 | LOG.debug( "keyValue[0]: " + keyValue[0] ); |
674 | 0 | LOG.debug( "keyValue[1]: " + keyValue[1] ); |
675 | |
} |
676 | |
} |
677 | |
} |
678 | 0 | parameters.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, "start"); |
679 | 0 | parameters.put(KRADConstants.DOC_FORM_KEY, GlobalVariables.getUserSession().addObjectWithGeneratedKey(form)); |
680 | 0 | String inquiryUrl = null; |
681 | |
try { |
682 | 0 | Class.forName(boClassName); |
683 | 0 | inquiryUrl = getApplicationBaseUrl() + "/kr/" + KRADConstants.DIRECT_INQUIRY_ACTION; |
684 | 0 | } catch ( ClassNotFoundException ex ) { |
685 | 0 | inquiryUrl = KRADServiceLocatorWeb.getRiceApplicationConfigurationMediationService().getBaseInquiryUrl(boClassName); |
686 | 0 | } |
687 | 0 | inquiryUrl = UrlFactory.parameterizeUrl(inquiryUrl, parameters); |
688 | 0 | return new ActionForward(inquiryUrl, true); |
689 | |
|
690 | |
} |
691 | |
|
692 | |
|
693 | |
|
694 | |
|
695 | |
|
696 | |
|
697 | |
|
698 | |
|
699 | |
|
700 | |
|
701 | |
|
702 | |
|
703 | |
|
704 | |
|
705 | |
|
706 | |
|
707 | |
protected ActionForward performQuestionWithoutInput(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response, String questionId, String questionText, String questionType, String caller, String context) throws Exception { |
708 | 0 | return performQuestion(mapping, form, request, response, questionId, questionText, questionType, caller, context, false, "", "", "", ""); |
709 | |
} |
710 | |
|
711 | |
|
712 | |
|
713 | |
|
714 | |
|
715 | |
|
716 | |
|
717 | |
|
718 | |
|
719 | |
|
720 | |
|
721 | |
|
722 | |
|
723 | |
|
724 | |
|
725 | |
|
726 | |
protected ActionForward performQuestionWithInput(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response, String questionId, String questionText, String questionType, String caller, String context) throws Exception { |
727 | 0 | return performQuestion(mapping, form, request, response, questionId, questionText, questionType, caller, context, true, "", "", "", ""); |
728 | |
} |
729 | |
|
730 | |
|
731 | |
|
732 | |
|
733 | |
|
734 | |
|
735 | |
|
736 | |
|
737 | |
|
738 | |
|
739 | |
|
740 | |
|
741 | |
|
742 | |
|
743 | |
|
744 | |
|
745 | |
|
746 | |
|
747 | |
|
748 | |
|
749 | |
protected ActionForward performQuestionWithInputAgainBecauseOfErrors(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response, String questionId, String questionText, String questionType, String caller, String context, String reason, String errorKey, String errorPropertyName, String errorParameter) throws Exception { |
750 | 0 | return performQuestion(mapping, form, request, response, questionId, questionText, questionType, caller, context, true, reason, errorKey, errorPropertyName, errorParameter); |
751 | |
} |
752 | |
|
753 | |
|
754 | |
|
755 | |
|
756 | |
|
757 | |
|
758 | |
|
759 | |
|
760 | |
|
761 | |
|
762 | |
|
763 | |
|
764 | |
|
765 | |
|
766 | |
|
767 | |
|
768 | |
|
769 | |
|
770 | |
|
771 | |
|
772 | |
|
773 | |
private ActionForward performQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response, String questionId, String questionText, String questionType, String caller, String context, boolean showReasonField, String reason, String errorKey, String errorPropertyName, String errorParameter) throws Exception { |
774 | 0 | Properties parameters = new Properties(); |
775 | |
|
776 | 0 | parameters.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, "start"); |
777 | 0 | parameters.put(KRADConstants.DOC_FORM_KEY, GlobalVariables.getUserSession().addObjectWithGeneratedKey(form)); |
778 | 0 | parameters.put(KRADConstants.CALLING_METHOD, caller); |
779 | 0 | parameters.put(KRADConstants.QUESTION_INST_ATTRIBUTE_NAME, questionId); |
780 | 0 | parameters.put(KRADConstants.QUESTION_IMPL_ATTRIBUTE_NAME, questionType); |
781 | 0 | parameters.put(KRADConstants.QUESTION_TEXT_ATTRIBUTE_NAME, questionText); |
782 | 0 | parameters.put(KRADConstants.RETURN_LOCATION_PARAMETER, getReturnLocation(request, mapping)); |
783 | 0 | parameters.put(KRADConstants.QUESTION_CONTEXT, context); |
784 | 0 | parameters.put(KRADConstants.QUESTION_SHOW_REASON_FIELD, Boolean.toString(showReasonField)); |
785 | 0 | parameters.put(KRADConstants.QUESTION_REASON_ATTRIBUTE_NAME, reason); |
786 | 0 | parameters.put(KRADConstants.QUESTION_ERROR_KEY, errorKey); |
787 | 0 | parameters.put(KRADConstants.QUESTION_ERROR_PROPERTY_NAME, errorPropertyName); |
788 | 0 | parameters.put(KRADConstants.QUESTION_ERROR_PARAMETER, errorParameter); |
789 | 0 | parameters.put(KRADConstants.QUESTION_ANCHOR, form instanceof KualiForm ? ObjectUtils.toString(((KualiForm) form).getAnchor()) : ""); |
790 | 0 | Object methodToCallAttribute = request.getAttribute(KRADConstants.METHOD_TO_CALL_ATTRIBUTE); |
791 | 0 | if (methodToCallAttribute != null) { |
792 | 0 | parameters.put(KRADConstants.METHOD_TO_CALL_PATH, methodToCallAttribute); |
793 | 0 | ((PojoForm) form).registerEditableProperty(String.valueOf(methodToCallAttribute)); |
794 | |
} |
795 | |
|
796 | 0 | if (form instanceof KualiDocumentFormBase) { |
797 | 0 | String docNum = ((KualiDocumentFormBase) form).getDocument().getDocumentNumber(); |
798 | 0 | if(docNum != null){ |
799 | 0 | parameters.put(KRADConstants.DOC_NUM, ((KualiDocumentFormBase) form) |
800 | |
.getDocument().getDocumentNumber()); |
801 | |
} |
802 | |
} |
803 | |
|
804 | 0 | String questionUrl = UrlFactory.parameterizeUrl(getApplicationBaseUrl() + "/kr/" + KRADConstants.QUESTION_ACTION, parameters); |
805 | 0 | return new ActionForward(questionUrl, true); |
806 | |
} |
807 | |
|
808 | |
|
809 | |
|
810 | |
|
811 | |
|
812 | |
|
813 | |
|
814 | |
|
815 | |
|
816 | |
|
817 | |
|
818 | |
|
819 | |
public ActionForward performWorkgroupLookup(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { |
820 | 0 | String returnUrl = null; |
821 | 0 | if ("/kr".equals(mapping.getModuleConfig().getPrefix())) { |
822 | 0 | returnUrl = getApplicationBaseUrl() + mapping.getModuleConfig().getPrefix() + mapping.getPath() + ".do"; |
823 | |
} else { |
824 | 0 | returnUrl = getApplicationBaseUrl() + mapping.getPath() + ".do"; |
825 | |
} |
826 | |
|
827 | |
|
828 | 0 | String fullParameter = (String) request.getAttribute(KRADConstants.METHOD_TO_CALL_ATTRIBUTE); |
829 | 0 | String conversionFields = StringUtils.substringBetween(fullParameter, KRADConstants.METHOD_TO_CALL_PARM1_LEFT_DEL, KRADConstants.METHOD_TO_CALL_PARM1_RIGHT_DEL); |
830 | |
|
831 | 0 | String deploymentBaseUrl = KRADServiceLocator.getKualiConfigurationService().getPropertyValueAsString( |
832 | |
KRADConstants.WORKFLOW_URL_KEY); |
833 | 0 | String workgroupLookupUrl = deploymentBaseUrl + "/Lookup.do?lookupableImplServiceName=WorkGroupLookupableImplService&methodToCall=start&docFormKey=" + GlobalVariables.getUserSession().addObjectWithGeneratedKey(form); |
834 | |
|
835 | 0 | if (conversionFields != null) { |
836 | 0 | workgroupLookupUrl += "&conversionFields=" + conversionFields; |
837 | |
} |
838 | 0 | if (form instanceof KualiDocumentFormBase) { |
839 | 0 | workgroupLookupUrl +="&docNum="+ ((KualiDocumentFormBase) form).getDocument().getDocumentNumber(); |
840 | |
} |
841 | |
|
842 | 0 | workgroupLookupUrl += "&returnLocation=" + returnUrl; |
843 | |
|
844 | 0 | return new ActionForward(workgroupLookupUrl, true); |
845 | |
} |
846 | |
|
847 | |
|
848 | |
|
849 | |
|
850 | |
|
851 | |
|
852 | |
|
853 | |
|
854 | |
|
855 | |
|
856 | |
|
857 | |
public ActionForward headerTab(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { |
858 | |
|
859 | |
|
860 | 0 | String headerTabDispatch = getHeaderTabDispatch(request); |
861 | 0 | if (StringUtils.isNotEmpty(headerTabDispatch)) { |
862 | 0 | ActionForward forward = dispatchMethod(mapping, form, request, response, headerTabDispatch); |
863 | 0 | if (GlobalVariables.getMessageMap().getNumberOfPropertiesWithErrors() > 0) { |
864 | 0 | return mapping.findForward(RiceConstants.MAPPING_BASIC); |
865 | |
} |
866 | 0 | this.doTabOpenOrClose(mapping, form, request, response, false); |
867 | 0 | if (forward.getRedirect()) { |
868 | 0 | return forward; |
869 | |
} |
870 | |
} |
871 | 0 | return dispatchMethod(mapping, form, request, response, getHeaderTabNavigateTo(request)); |
872 | |
} |
873 | |
|
874 | |
|
875 | |
|
876 | |
|
877 | |
|
878 | |
|
879 | |
|
880 | |
protected void checkAuthorization( ActionForm form, String methodToCall) throws AuthorizationException |
881 | |
{ |
882 | 0 | String principalId = GlobalVariables.getUserSession().getPrincipalId(); |
883 | 0 | Map<String, String> roleQualifier = new HashMap<String, String>(getRoleQualification(form, methodToCall)); |
884 | 0 | Map<String, String> permissionDetails = KRADUtils.getNamespaceAndActionClass(this.getClass()); |
885 | |
|
886 | 0 | if (!KimApiServiceLocator.getPermissionService().isAuthorizedByTemplateName(principalId, KRADConstants.KRAD_NAMESPACE, |
887 | |
KimConstants.PermissionTemplateNames.USE_SCREEN, permissionDetails, roleQualifier )) |
888 | |
{ |
889 | 0 | throw new AuthorizationException(GlobalVariables.getUserSession().getPerson().getPrincipalName(), |
890 | |
methodToCall, |
891 | |
this.getClass().getSimpleName()); |
892 | |
} |
893 | 0 | } |
894 | |
|
895 | |
|
896 | |
|
897 | |
|
898 | |
protected Map<String,String> getRoleQualification(ActionForm form, String methodToCall) { |
899 | 0 | return new HashMap<String,String>(); |
900 | |
} |
901 | |
|
902 | |
protected static KualiModuleService getKualiModuleService() { |
903 | 0 | if ( kualiModuleService == null ) { |
904 | 0 | kualiModuleService = KRADServiceLocatorWeb.getKualiModuleService(); |
905 | |
} |
906 | 0 | return kualiModuleService; |
907 | |
} |
908 | |
|
909 | |
|
910 | |
|
911 | |
|
912 | |
|
913 | |
public static final String TEXT_AREA_FIELD_NAME="textAreaFieldName"; |
914 | |
|
915 | |
|
916 | |
|
917 | |
|
918 | |
public static final String TEXT_AREA_FIELD_LABEL="textAreaFieldLabel"; |
919 | |
|
920 | |
|
921 | |
|
922 | |
|
923 | |
public static final String TEXT_AREA_READ_ONLY="textAreaReadOnly"; |
924 | |
|
925 | |
|
926 | |
|
927 | |
|
928 | |
public static final String TEXT_AREA_FIELD_ANCHOR="textAreaFieldAnchor"; |
929 | |
|
930 | |
|
931 | |
|
932 | |
|
933 | |
public static final String TEXT_AREA_MAX_LENGTH="textAreaMaxLength"; |
934 | |
|
935 | |
|
936 | |
|
937 | |
|
938 | |
public static final String FORM_ACTION="htmlFormAction"; |
939 | |
|
940 | |
|
941 | |
|
942 | |
|
943 | |
public static final String METHOD_TO_CALL="methodToCall"; |
944 | |
|
945 | |
|
946 | |
|
947 | |
|
948 | |
|
949 | |
public static final String FORWARD_TEXT_AREA_UPDATE="updateTextArea"; |
950 | |
|
951 | |
|
952 | |
|
953 | |
|
954 | |
public static final String POST_TEXT_AREA_TO_PARENT="postTextAreaToParent"; |
955 | |
|
956 | |
|
957 | |
|
958 | |
|
959 | |
|
960 | |
public static final String FORWARD_NEXT="forwardNext"; |
961 | |
|
962 | |
|
963 | |
|
964 | |
|
965 | |
|
966 | |
|
967 | |
|
968 | |
|
969 | |
|
970 | |
|
971 | |
|
972 | |
|
973 | |
|
974 | |
|
975 | |
public ActionForward updateTextArea(ActionMapping mapping, |
976 | |
ActionForm form, |
977 | |
HttpServletRequest request, |
978 | |
HttpServletResponse response) { |
979 | 0 | if (LOG.isTraceEnabled()) { |
980 | 0 | String lm=String.format("ENTRY %s%n%s", form.getClass().getSimpleName(), |
981 | |
request.getRequestURI()); |
982 | 0 | LOG.trace(lm); |
983 | |
} |
984 | |
|
985 | 0 | final String[] keyValue = getTextAreaParams(request); |
986 | |
|
987 | 0 | request.setAttribute(TEXT_AREA_FIELD_NAME, keyValue[0]); |
988 | 0 | request.setAttribute(FORM_ACTION,keyValue[1]); |
989 | 0 | request.setAttribute(TEXT_AREA_FIELD_LABEL,keyValue[2]); |
990 | 0 | request.setAttribute(TEXT_AREA_READ_ONLY,keyValue[3]); |
991 | 0 | request.setAttribute(TEXT_AREA_MAX_LENGTH,keyValue[4]); |
992 | 0 | if (form instanceof KualiForm && StringUtils.isNotEmpty(((KualiForm) form).getAnchor())) { |
993 | 0 | request.setAttribute(TEXT_AREA_FIELD_ANCHOR,((KualiForm) form).getAnchor()); |
994 | |
} |
995 | |
|
996 | |
|
997 | 0 | String docWebScope=(String)request.getAttribute(KRADConstants.DOCUMENT_WEB_SCOPE); |
998 | 0 | if (docWebScope != null && docWebScope.trim().length() >= 0) { |
999 | 0 | request.setAttribute(KRADConstants.DOCUMENT_WEB_SCOPE, docWebScope); |
1000 | |
} |
1001 | |
|
1002 | 0 | request.setAttribute(KRADConstants.DOC_FORM_KEY, GlobalVariables.getUserSession().addObjectWithGeneratedKey(form)); |
1003 | |
|
1004 | 0 | ActionForward forward=mapping.findForward(FORWARD_TEXT_AREA_UPDATE); |
1005 | |
|
1006 | 0 | if (LOG.isTraceEnabled()) { |
1007 | 0 | String lm=String.format("EXIT %s", (forward==null)?"null":forward.getPath()); |
1008 | 0 | LOG.trace(lm); |
1009 | |
} |
1010 | |
|
1011 | 0 | return forward; |
1012 | |
} |
1013 | |
|
1014 | |
|
1015 | |
|
1016 | |
|
1017 | |
|
1018 | |
|
1019 | |
|
1020 | |
|
1021 | |
|
1022 | |
|
1023 | |
|
1024 | |
|
1025 | |
|
1026 | |
|
1027 | |
|
1028 | |
|
1029 | |
private String[] getTextAreaParams(HttpServletRequest request) { |
1030 | |
|
1031 | 0 | String fullParameter = (String) request.getAttribute( |
1032 | |
KRADConstants.METHOD_TO_CALL_ATTRIBUTE); |
1033 | |
|
1034 | |
|
1035 | 0 | String parameterFields = StringUtils.substringBetween(fullParameter, |
1036 | |
KRADConstants.METHOD_TO_CALL_PARM2_LEFT_DEL, |
1037 | |
KRADConstants.METHOD_TO_CALL_PARM2_RIGHT_DEL); |
1038 | 0 | if ( LOG.isDebugEnabled() ) { |
1039 | 0 | LOG.debug( "fullParameter: " + fullParameter ); |
1040 | 0 | LOG.debug( "parameterFields: " + parameterFields ); |
1041 | |
} |
1042 | 0 | String[] keyValue = null; |
1043 | 0 | if (StringUtils.isNotBlank(parameterFields)) { |
1044 | 0 | String[] textAreaParams = parameterFields.split( |
1045 | |
KRADConstants.FIELD_CONVERSIONS_SEPARATOR); |
1046 | 0 | if ( LOG.isDebugEnabled() ) { |
1047 | 0 | LOG.debug( "lookupParams: " + textAreaParams ); |
1048 | |
} |
1049 | 0 | for (final String textAreaParam : textAreaParams) { |
1050 | 0 | keyValue = textAreaParam.split(KRADConstants.FIELD_CONVERSION_PAIR_SEPARATOR); |
1051 | |
|
1052 | 0 | if ( LOG.isDebugEnabled() ) { |
1053 | 0 | LOG.debug( "keyValue[0]: " + keyValue[0] ); |
1054 | 0 | LOG.debug( "keyValue[1]: " + keyValue[1] ); |
1055 | 0 | LOG.debug( "keyValue[2]: " + keyValue[2] ); |
1056 | 0 | LOG.debug( "keyValue[3]: " + keyValue[3] ); |
1057 | 0 | LOG.debug( "keyValue[4]: " + keyValue[4] ); |
1058 | |
} |
1059 | |
} |
1060 | |
} |
1061 | |
|
1062 | 0 | return keyValue; |
1063 | |
} |
1064 | |
|
1065 | |
|
1066 | |
|
1067 | |
|
1068 | |
|
1069 | |
|
1070 | |
|
1071 | |
|
1072 | |
|
1073 | |
|
1074 | |
|
1075 | |
|
1076 | |
|
1077 | |
public ActionForward postTextAreaToParent(ActionMapping mapping, |
1078 | |
ActionForm form, |
1079 | |
HttpServletRequest request, |
1080 | |
HttpServletResponse response) { |
1081 | |
|
1082 | 0 | if (LOG.isTraceEnabled()) { |
1083 | 0 | String lm=String.format("ENTRY %s%n%s", form.getClass().getSimpleName(), |
1084 | |
request.getRequestURI()); |
1085 | 0 | LOG.trace(lm); |
1086 | |
} |
1087 | |
|
1088 | 0 | String forwardingId=request.getParameter(FORWARD_NEXT); |
1089 | 0 | if (forwardingId == null) { |
1090 | 0 | forwardingId=RiceConstants.MAPPING_BASIC; |
1091 | |
} |
1092 | 0 | ActionForward forward=mapping.findForward(forwardingId); |
1093 | |
|
1094 | 0 | if (LOG.isTraceEnabled()) { |
1095 | 0 | String lm=String.format("EXIT %s", (forward==null)?"null":forward.getPath()); |
1096 | 0 | LOG.trace(lm); |
1097 | |
} |
1098 | |
|
1099 | 0 | return forward; |
1100 | |
} |
1101 | |
|
1102 | |
|
1103 | |
|
1104 | |
|
1105 | |
|
1106 | |
|
1107 | |
protected final void addMethodToCallToUncheckedList( String methodToCall ) { |
1108 | 0 | methodToCallsToNotCheckAuthorization.add(methodToCall); |
1109 | 0 | } |
1110 | |
|
1111 | |
|
1112 | |
|
1113 | |
|
1114 | |
protected void doProcessingAfterPost( KualiForm form, HttpServletRequest request ) { |
1115 | |
|
1116 | 0 | } |
1117 | |
|
1118 | |
protected BusinessObjectAuthorizationService getBusinessObjectAuthorizationService() { |
1119 | 0 | if (businessObjectAuthorizationService == null) { |
1120 | 0 | businessObjectAuthorizationService = KNSServiceLocator.getBusinessObjectAuthorizationService(); |
1121 | |
} |
1122 | 0 | return businessObjectAuthorizationService; |
1123 | |
} |
1124 | |
|
1125 | |
protected EncryptionService getEncryptionService() { |
1126 | 0 | if (encryptionService == null) { |
1127 | 0 | encryptionService = CoreApiServiceLocator.getEncryptionService(); |
1128 | |
} |
1129 | 0 | return encryptionService; |
1130 | |
} |
1131 | |
|
1132 | |
public static String getApplicationBaseUrl() { |
1133 | 0 | if ( applicationBaseUrl == null ) { |
1134 | 0 | applicationBaseUrl = KRADServiceLocator.getKualiConfigurationService().getPropertyValueAsString( |
1135 | |
KRADConstants.APPLICATION_URL_KEY); |
1136 | |
} |
1137 | 0 | return applicationBaseUrl; |
1138 | |
} |
1139 | |
} |