1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kns.web.struts.action; |
17 | |
|
18 | |
import java.io.ByteArrayOutputStream; |
19 | |
import java.io.IOException; |
20 | |
import java.util.ArrayList; |
21 | |
import java.util.Enumeration; |
22 | |
import java.util.HashMap; |
23 | |
import java.util.Iterator; |
24 | |
import java.util.List; |
25 | |
import java.util.Map; |
26 | |
import java.util.Properties; |
27 | |
import java.util.Set; |
28 | |
|
29 | |
import javax.persistence.EntityManagerFactory; |
30 | |
import javax.servlet.http.HttpServletRequest; |
31 | |
import javax.servlet.http.HttpServletResponse; |
32 | |
|
33 | |
import org.apache.commons.lang.ArrayUtils; |
34 | |
import org.apache.commons.lang.StringUtils; |
35 | |
import org.apache.ojb.broker.OptimisticLockException; |
36 | |
import org.apache.struts.action.ActionForm; |
37 | |
import org.apache.struts.action.ActionForward; |
38 | |
import org.apache.struts.action.ActionMapping; |
39 | |
import org.apache.struts.upload.FormFile; |
40 | |
import org.kuali.rice.core.util.KeyLabelPair; |
41 | |
import org.kuali.rice.core.util.RiceConstants; |
42 | |
import org.kuali.rice.kew.exception.WorkflowException; |
43 | |
import org.kuali.rice.kew.util.KEWConstants; |
44 | |
import org.kuali.rice.kim.bo.Group; |
45 | |
import org.kuali.rice.kim.bo.Person; |
46 | |
import org.kuali.rice.kim.service.IdentityManagementService; |
47 | |
import org.kuali.rice.kim.service.KIMServiceLocator; |
48 | |
import org.kuali.rice.kim.util.KimConstants; |
49 | |
import org.kuali.rice.kns.UserSession; |
50 | |
import org.kuali.rice.kns.bo.AdHocRoutePerson; |
51 | |
import org.kuali.rice.kns.bo.AdHocRouteRecipient; |
52 | |
import org.kuali.rice.kns.bo.AdHocRouteWorkgroup; |
53 | |
import org.kuali.rice.kns.bo.Attachment; |
54 | |
import org.kuali.rice.kns.bo.DocumentHeader; |
55 | |
import org.kuali.rice.kns.bo.Note; |
56 | |
import org.kuali.rice.kns.bo.PersistableBusinessObject; |
57 | |
import org.kuali.rice.kns.datadictionary.DataDictionary; |
58 | |
import org.kuali.rice.kns.datadictionary.DocumentEntry; |
59 | |
import org.kuali.rice.kns.document.Document; |
60 | |
import org.kuali.rice.kns.document.MaintenanceDocument; |
61 | |
import org.kuali.rice.kns.document.authorization.DocumentAuthorizer; |
62 | |
import org.kuali.rice.kns.document.authorization.DocumentAuthorizerBase; |
63 | |
import org.kuali.rice.kns.document.authorization.DocumentPresentationController; |
64 | |
import org.kuali.rice.kns.document.authorization.PessimisticLock; |
65 | |
import org.kuali.rice.kns.exception.AuthorizationException; |
66 | |
import org.kuali.rice.kns.exception.DocumentAuthorizationException; |
67 | |
import org.kuali.rice.kns.exception.UnknownDocumentIdException; |
68 | |
import org.kuali.rice.kns.exception.ValidationException; |
69 | |
import org.kuali.rice.kns.question.ConfirmationQuestion; |
70 | |
import org.kuali.rice.kns.rule.PromptBeforeValidation; |
71 | |
import org.kuali.rice.kns.rule.event.AddAdHocRoutePersonEvent; |
72 | |
import org.kuali.rice.kns.rule.event.AddAdHocRouteWorkgroupEvent; |
73 | |
import org.kuali.rice.kns.rule.event.AddNoteEvent; |
74 | |
import org.kuali.rice.kns.rule.event.PromptBeforeValidationEvent; |
75 | |
import org.kuali.rice.kns.rule.event.SaveDocumentEvent; |
76 | |
import org.kuali.rice.kns.rule.event.SendAdHocRequestsEvent; |
77 | |
import org.kuali.rice.kns.service.AttachmentService; |
78 | |
import org.kuali.rice.kns.service.BusinessObjectAuthorizationService; |
79 | |
import org.kuali.rice.kns.service.BusinessObjectMetaDataService; |
80 | |
import org.kuali.rice.kns.service.BusinessObjectService; |
81 | |
import org.kuali.rice.kns.service.DataDictionaryService; |
82 | |
import org.kuali.rice.kns.service.DocumentHelperService; |
83 | |
import org.kuali.rice.kns.service.DocumentService; |
84 | |
import org.kuali.rice.kns.service.KNSServiceLocator; |
85 | |
import org.kuali.rice.kns.service.KualiConfigurationService; |
86 | |
import org.kuali.rice.kns.service.KualiRuleService; |
87 | |
import org.kuali.rice.kns.service.NoteService; |
88 | |
import org.kuali.rice.kns.service.ParameterConstants; |
89 | |
import org.kuali.rice.kns.service.ParameterService; |
90 | |
import org.kuali.rice.kns.service.PessimisticLockService; |
91 | |
import org.kuali.rice.kns.util.GlobalVariables; |
92 | |
import org.kuali.rice.kns.util.KNSConstants; |
93 | |
import org.kuali.rice.kns.util.KNSPropertyConstants; |
94 | |
import org.kuali.rice.kns.util.ObjectUtils; |
95 | |
import org.kuali.rice.kns.util.RiceKeyConstants; |
96 | |
import org.kuali.rice.kns.util.SessionTicket; |
97 | |
import org.kuali.rice.kns.util.UrlFactory; |
98 | |
import org.kuali.rice.kns.util.WebUtils; |
99 | |
import org.kuali.rice.kns.web.struts.form.BlankFormFile; |
100 | |
import org.kuali.rice.kns.web.struts.form.KualiDocumentFormBase; |
101 | |
import org.kuali.rice.kns.web.struts.form.KualiForm; |
102 | |
import org.kuali.rice.kns.web.struts.form.KualiMaintenanceForm; |
103 | |
import org.kuali.rice.kns.workflow.service.KualiWorkflowDocument; |
104 | |
import org.springmodules.orm.ojb.OjbOperationException; |
105 | |
|
106 | |
|
107 | |
|
108 | |
|
109 | |
|
110 | |
|
111 | 0 | public class KualiDocumentActionBase extends KualiAction { |
112 | 0 | private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(KualiDocumentActionBase.class); |
113 | |
|
114 | |
|
115 | 0 | protected static final String[] DOCUMENT_LOAD_COMMANDS = { |
116 | |
KEWConstants.ACTIONLIST_COMMAND, |
117 | |
KEWConstants.DOCSEARCH_COMMAND, |
118 | |
KEWConstants.SUPERUSER_COMMAND, |
119 | |
KEWConstants.HELPDESK_ACTIONLIST_COMMAND }; |
120 | |
|
121 | |
private DataDictionaryService dataDictionaryService; |
122 | |
private DocumentHelperService documentHelperService; |
123 | |
private DocumentService documentService; |
124 | |
private KualiConfigurationService kualiConfigurationService; |
125 | |
private ParameterService parameterService; |
126 | |
private PessimisticLockService pessimisticLockService; |
127 | |
private KualiRuleService kualiRuleService; |
128 | |
private IdentityManagementService identityManagementService; |
129 | |
private AttachmentService attachmentService; |
130 | |
private NoteService noteService; |
131 | |
private BusinessObjectAuthorizationService businessObjectAuthorizationService; |
132 | |
private BusinessObjectService businessObjectService; |
133 | |
private BusinessObjectMetaDataService businessObjectMetaDataService; |
134 | |
private EntityManagerFactory entityManagerFactory; |
135 | |
|
136 | |
protected void checkAuthorization( ActionForm form, String methodToCall ) throws AuthorizationException { |
137 | 0 | if ( !(form instanceof KualiDocumentFormBase) ) { |
138 | 0 | super.checkAuthorization(form, methodToCall); |
139 | |
} |
140 | 0 | } |
141 | |
|
142 | |
|
143 | |
|
144 | |
|
145 | |
|
146 | |
|
147 | |
|
148 | |
|
149 | |
|
150 | |
|
151 | |
|
152 | |
@Override |
153 | |
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { |
154 | 0 | ActionForward returnForward = mapping.findForward(RiceConstants.MAPPING_BASIC); |
155 | |
|
156 | |
|
157 | |
try { |
158 | 0 | returnForward = super.execute(mapping, form, request, response); |
159 | 0 | } |
160 | 0 | catch (OjbOperationException e) { |
161 | |
|
162 | 0 | OjbOperationException ooe = (OjbOperationException) e; |
163 | |
|
164 | 0 | Throwable cause = ooe.getCause(); |
165 | 0 | if (cause instanceof OptimisticLockException) { |
166 | 0 | OptimisticLockException ole = (OptimisticLockException) cause; |
167 | 0 | GlobalVariables.getMessageMap().putError(KNSConstants.DOCUMENT_ERRORS, RiceKeyConstants.ERROR_OPTIMISTIC_LOCK); |
168 | 0 | logOjbOptimisticLockException(ole); |
169 | 0 | } |
170 | |
else { |
171 | |
|
172 | 0 | throw e; |
173 | |
} |
174 | 0 | } |
175 | |
finally { |
176 | 0 | if (form instanceof KualiDocumentFormBase) { |
177 | 0 | ((KualiDocumentFormBase) form).setMessageMapFromPreviousRequest(GlobalVariables.getMessageMap()); |
178 | |
} |
179 | 0 | } |
180 | |
|
181 | 0 | if (form instanceof KualiDocumentFormBase |
182 | |
&& ((KualiDocumentFormBase)form).isHasWorkflowDocument() ) { |
183 | 0 | KualiDocumentFormBase formBase = (KualiDocumentFormBase) form; |
184 | 0 | Document document = formBase.getDocument(); |
185 | |
|
186 | |
|
187 | 0 | KualiWorkflowDocument workflowDocument = formBase.getDocument().getDocumentHeader().getWorkflowDocument(); |
188 | 0 | formBase.populateHeaderFields(workflowDocument); |
189 | 0 | formBase.setDocId(document.getDocumentNumber()); |
190 | |
|
191 | |
|
192 | |
|
193 | 0 | if (isFormRepresentingLockObject(formBase)) { |
194 | |
|
195 | 0 | if ( LOG.isDebugEnabled() ) { |
196 | 0 | LOG.debug("Form " + formBase + " represents a PessimisticLock BO object"); |
197 | |
} |
198 | |
} else { |
199 | |
|
200 | |
|
201 | |
|
202 | |
|
203 | 0 | populateAuthorizationFields(formBase); |
204 | 0 | populateAdHocActionRequestCodes(formBase); |
205 | |
|
206 | |
|
207 | 0 | UserSession userSession = (UserSession) request.getSession().getAttribute(KNSConstants.USER_SESSION_KEY); |
208 | |
|
209 | 0 | if (WebUtils.isDocumentSession(document, formBase)) { |
210 | 0 | String formKey = formBase.getFormKey(); |
211 | 0 | if (StringUtils.isBlank(formBase.getFormKey()) || userSession.retrieveObject(formBase.getFormKey()) == null) { |
212 | |
|
213 | 0 | formKey = GlobalVariables.getUserSession().addObject(form); |
214 | 0 | formBase.setFormKey(formKey); |
215 | |
} |
216 | |
} |
217 | |
|
218 | |
|
219 | |
|
220 | 0 | request.getSession().setAttribute(KNSConstants.DOCUMENT_HTTP_SESSION_KEY, document.getDocumentNumber()); |
221 | |
|
222 | 0 | if ("displayActionListView".equals(formBase.getCommand())) { |
223 | 0 | formBase.setReturnToActionList(true); |
224 | |
} |
225 | |
|
226 | 0 | String attachmentEnabled= |
227 | |
getKualiConfigurationService().getPropertyString( |
228 | |
KNSConstants.NOTE_ATTACHMENT_ENABLED); |
229 | |
|
230 | 0 | if (attachmentEnabled != null) { |
231 | |
|
232 | |
|
233 | |
|
234 | |
|
235 | 0 | DataDictionary dataDictionary = getDataDictionaryService().getDataDictionary(); |
236 | |
|
237 | 0 | DocumentEntry entry = dataDictionary.getDocumentEntry(document.getClass().getName()); |
238 | 0 | entry.setAllowsNoteAttachments(Boolean.parseBoolean(attachmentEnabled)); |
239 | |
} |
240 | |
|
241 | 0 | if(exitingDocument()){ |
242 | 0 | request.setAttribute(KNSConstants.EXITING_DOCUMENT, Boolean.TRUE); |
243 | |
} |
244 | |
|
245 | |
|
246 | 0 | String methodCalledViaDispatch = (String) GlobalVariables.getUserSession().retrieveObject(DocumentAuthorizerBase.USER_SESSION_METHOD_TO_CALL_OBJECT_KEY); |
247 | 0 | if ( (StringUtils.isNotBlank(methodCalledViaDispatch)) && (exitingDocument()) ) { |
248 | 0 | GlobalVariables.getUserSession().removeObject(DocumentAuthorizerBase.USER_SESSION_METHOD_TO_CALL_COMPLETE_OBJECT_KEY); |
249 | 0 | attemptLockRelease(document, methodCalledViaDispatch); |
250 | |
} |
251 | 0 | setupPessimisticLockMessages(document, request); |
252 | 0 | if (!document.getPessimisticLocks().isEmpty()) { |
253 | 0 | String warningMinutes = getParameterService().getParameterValue(KNSConstants.KNS_NAMESPACE, KNSConstants.DetailTypes.DOCUMENT_DETAIL_TYPE, KNSConstants.SESSION_TIMEOUT_WARNING_MESSAGE_TIME_PARM_NM); |
254 | 0 | request.setAttribute(KNSConstants.SESSION_TIMEOUT_WARNING_MINUTES, warningMinutes); |
255 | 0 | request.setAttribute(KNSConstants.SESSION_TIMEOUT_WARNING_MILLISECONDS, (request.getSession().getMaxInactiveInterval() - (Integer.valueOf(warningMinutes) * 60)) * 1000); |
256 | |
} |
257 | |
} |
258 | |
} |
259 | |
|
260 | 0 | return returnForward; |
261 | |
} |
262 | |
|
263 | |
protected boolean isFormRepresentingLockObject(KualiDocumentFormBase form) throws Exception { |
264 | 0 | if (form instanceof KualiMaintenanceForm) { |
265 | 0 | KualiMaintenanceForm maintForm = (KualiMaintenanceForm) form; |
266 | 0 | if (ObjectUtils.isNotNull(maintForm.getBusinessObjectClassName())) { |
267 | 0 | return PessimisticLock.class.isAssignableFrom(Class.forName(((KualiMaintenanceForm) form).getBusinessObjectClassName())); |
268 | |
} |
269 | |
} |
270 | 0 | return false; |
271 | |
} |
272 | |
|
273 | |
protected void attemptLockRelease(Document document, String methodToCall) { |
274 | 0 | if ( (document != null) && (!document.getPessimisticLocks().isEmpty()) ) { |
275 | 0 | releaseLocks(document, methodToCall); |
276 | |
|
277 | 0 | document.refreshPessimisticLocks(); |
278 | |
} |
279 | 0 | } |
280 | |
|
281 | |
protected void releaseLocks(Document document, String methodToCall) { |
282 | |
|
283 | 0 | if (document.getLockClearningMethodNames().contains(methodToCall)) { |
284 | |
|
285 | 0 | getPessimisticLockService().releaseAllLocksForUser(document.getPessimisticLocks(), GlobalVariables.getUserSession().getPerson()); |
286 | |
} |
287 | 0 | } |
288 | |
|
289 | |
protected void setupPessimisticLockMessages(Document document, HttpServletRequest request) { |
290 | 0 | List<String> lockMessages = new ArrayList<String>(); |
291 | 0 | for (PessimisticLock lock : document.getPessimisticLocks()) { |
292 | |
|
293 | 0 | if (!lock.isOwnedByUser(GlobalVariables.getUserSession().getPerson())) { |
294 | 0 | lockMessages.add(generatePessimisticLockMessage(lock)); |
295 | |
} |
296 | |
} |
297 | 0 | request.setAttribute(KNSConstants.PESSIMISTIC_LOCK_MESSAGES, lockMessages); |
298 | 0 | } |
299 | |
|
300 | |
protected String generatePessimisticLockMessage(PessimisticLock lock) { |
301 | 0 | String descriptor = (lock.getLockDescriptor() != null) ? lock.getLockDescriptor() : ""; |
302 | |
|
303 | 0 | return "This document currently has a " + descriptor + " lock owned by " + lock.getOwnedByUser().getName() + " as of " + RiceConstants.getDefaultTimeFormat().format(lock.getGeneratedTimestamp()) + " on " + RiceConstants.getDefaultDateFormat().format(lock.getGeneratedTimestamp()); |
304 | |
} |
305 | |
|
306 | |
|
307 | |
|
308 | |
|
309 | |
|
310 | |
|
311 | |
|
312 | |
|
313 | |
|
314 | |
|
315 | |
|
316 | |
|
317 | |
|
318 | |
|
319 | |
|
320 | |
|
321 | |
|
322 | |
|
323 | |
|
324 | |
|
325 | |
public ActionForward docHandler(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { |
326 | 0 | KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form; |
327 | 0 | String command = kualiDocumentFormBase.getCommand(); |
328 | |
|
329 | |
|
330 | 0 | if (ArrayUtils.contains(DOCUMENT_LOAD_COMMANDS, command) && kualiDocumentFormBase.getDocId() != null) { |
331 | 0 | loadDocument(kualiDocumentFormBase); |
332 | |
} |
333 | 0 | else if (KEWConstants.INITIATE_COMMAND.equals(command)) { |
334 | 0 | createDocument(kualiDocumentFormBase); |
335 | |
} |
336 | |
else { |
337 | 0 | LOG.error("docHandler called with invalid parameters"); |
338 | 0 | throw new IllegalStateException("docHandler called with invalid parameters"); |
339 | |
} |
340 | |
|
341 | |
|
342 | 0 | if (LOG.isDebugEnabled()) { |
343 | 0 | LOG.debug("kualiDocumentFormBase.getAdditionalScriptFiles(): " + kualiDocumentFormBase.getAdditionalScriptFiles()); |
344 | |
} |
345 | 0 | if ( kualiDocumentFormBase.getAdditionalScriptFiles().isEmpty() ) { |
346 | 0 | DocumentEntry docEntry = getDataDictionaryService().getDataDictionary().getDocumentEntry( kualiDocumentFormBase.getDocument().getDocumentHeader().getWorkflowDocument().getDocumentType() ); |
347 | 0 | kualiDocumentFormBase.getAdditionalScriptFiles().addAll(docEntry.getWebScriptFiles()); |
348 | |
} |
349 | 0 | if (KEWConstants.SUPERUSER_COMMAND.equalsIgnoreCase(command)) { |
350 | 0 | kualiDocumentFormBase.setSuppressAllButtons(true); |
351 | |
} |
352 | 0 | return mapping.findForward(RiceConstants.MAPPING_BASIC); |
353 | |
} |
354 | |
|
355 | |
|
356 | |
|
357 | |
|
358 | |
|
359 | |
|
360 | |
|
361 | |
|
362 | |
protected void loadDocument(KualiDocumentFormBase kualiDocumentFormBase) throws WorkflowException { |
363 | 0 | String docId = kualiDocumentFormBase.getDocId(); |
364 | 0 | Document doc = null; |
365 | 0 | doc = getDocumentService().getByDocumentHeaderId(docId); |
366 | 0 | if (doc == null) { |
367 | 0 | throw new UnknownDocumentIdException("Document no longer exists. It may have been cancelled before being saved."); |
368 | |
} |
369 | 0 | KualiWorkflowDocument workflowDocument = doc.getDocumentHeader().getWorkflowDocument(); |
370 | 0 | if (!getDocumentHelperService().getDocumentAuthorizer(doc).canOpen(doc, GlobalVariables.getUserSession().getPerson())) { |
371 | 0 | throw buildAuthorizationException("open", doc); |
372 | |
} |
373 | |
|
374 | 0 | if ( workflowDocument != doc.getDocumentHeader().getWorkflowDocument() ) { |
375 | 0 | LOG.warn( "Workflow document changed via canOpen check" ); |
376 | 0 | doc.getDocumentHeader().setWorkflowDocument(workflowDocument); |
377 | |
} |
378 | 0 | kualiDocumentFormBase.setDocument(doc); |
379 | 0 | KualiWorkflowDocument workflowDoc = doc.getDocumentHeader().getWorkflowDocument(); |
380 | 0 | kualiDocumentFormBase.setDocTypeName(workflowDoc.getDocumentType()); |
381 | |
|
382 | 0 | GlobalVariables.getUserSession().setWorkflowDocument(workflowDoc); |
383 | 0 | } |
384 | |
|
385 | |
|
386 | |
|
387 | |
|
388 | |
|
389 | |
|
390 | |
|
391 | |
|
392 | |
|
393 | |
protected void createDocument(KualiDocumentFormBase kualiDocumentFormBase) throws WorkflowException { |
394 | 0 | Document doc = getDocumentService().getNewDocument(kualiDocumentFormBase.getDocTypeName()); |
395 | |
|
396 | 0 | kualiDocumentFormBase.setDocument(doc); |
397 | 0 | kualiDocumentFormBase.setDocTypeName(doc.getDocumentHeader().getWorkflowDocument().getDocumentType()); |
398 | 0 | } |
399 | |
|
400 | |
|
401 | |
|
402 | |
|
403 | |
|
404 | |
|
405 | |
|
406 | |
|
407 | |
|
408 | |
|
409 | |
|
410 | |
|
411 | |
public ActionForward insertAdHocRoutePerson(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { |
412 | 0 | KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form; |
413 | 0 | Document document = kualiDocumentFormBase.getDocument(); |
414 | |
|
415 | |
|
416 | |
|
417 | 0 | DocumentAuthorizer documentAuthorizer = getDocumentHelperService().getDocumentAuthorizer(document); |
418 | 0 | if(!documentAuthorizer.canSendAdHocRequests(document, kualiDocumentFormBase.getNewAdHocRoutePerson().getActionRequested(), GlobalVariables.getUserSession().getPerson())){ |
419 | 0 | throw buildAuthorizationException("ad-hoc route", document); |
420 | |
} |
421 | |
|
422 | |
|
423 | 0 | boolean rulePassed = getKualiRuleService().applyRules(new AddAdHocRoutePersonEvent(document, (AdHocRoutePerson) kualiDocumentFormBase.getNewAdHocRoutePerson())); |
424 | |
|
425 | |
|
426 | 0 | if (rulePassed) { |
427 | |
|
428 | |
|
429 | 0 | kualiDocumentFormBase.getNewAdHocRoutePerson().setId(kualiDocumentFormBase.getNewAdHocRoutePerson().getId()); |
430 | 0 | kualiDocumentFormBase.getAdHocRoutePersons().add(kualiDocumentFormBase.getNewAdHocRoutePerson()); |
431 | 0 | AdHocRoutePerson person = new AdHocRoutePerson(); |
432 | 0 | kualiDocumentFormBase.setNewAdHocRoutePerson(person); |
433 | |
} |
434 | |
|
435 | 0 | return mapping.findForward(RiceConstants.MAPPING_BASIC); |
436 | |
} |
437 | |
|
438 | |
|
439 | |
|
440 | |
|
441 | |
|
442 | |
|
443 | |
|
444 | |
|
445 | |
|
446 | |
|
447 | |
|
448 | |
|
449 | |
public ActionForward deleteAdHocRoutePerson(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { |
450 | 0 | KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form; |
451 | |
|
452 | |
|
453 | 0 | kualiDocumentFormBase.getAdHocRoutePersons().remove(this.getLineToDelete(request)); |
454 | 0 | return mapping.findForward(RiceConstants.MAPPING_BASIC); |
455 | |
} |
456 | |
|
457 | |
|
458 | |
|
459 | |
|
460 | |
|
461 | |
|
462 | |
|
463 | |
|
464 | |
|
465 | |
|
466 | |
|
467 | |
|
468 | |
public ActionForward insertAdHocRouteWorkgroup(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { |
469 | 0 | KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form; |
470 | 0 | Document document = kualiDocumentFormBase.getDocument(); |
471 | |
|
472 | |
|
473 | 0 | DocumentAuthorizer documentAuthorizer = getDocumentHelperService().getDocumentAuthorizer(document); |
474 | 0 | if(!documentAuthorizer.canSendAdHocRequests(document, kualiDocumentFormBase.getNewAdHocRouteWorkgroup().getActionRequested(), GlobalVariables.getUserSession().getPerson())){ |
475 | 0 | throw buildAuthorizationException("ad-hoc route", document); |
476 | |
} |
477 | |
|
478 | |
|
479 | 0 | boolean rulePassed = getKualiRuleService().applyRules(new AddAdHocRouteWorkgroupEvent(document, (AdHocRouteWorkgroup) kualiDocumentFormBase.getNewAdHocRouteWorkgroup())); |
480 | |
|
481 | |
|
482 | 0 | if (rulePassed) { |
483 | |
|
484 | 0 | AdHocRouteWorkgroup newWorkgroup = kualiDocumentFormBase.getNewAdHocRouteWorkgroup(); |
485 | 0 | if (newWorkgroup.getId() == null) { |
486 | 0 | newWorkgroup.setId(KIMServiceLocator.getIdentityManagementService().getGroupByName(newWorkgroup.getRecipientNamespaceCode(), newWorkgroup.getRecipientName()).getGroupId()); |
487 | |
} |
488 | 0 | kualiDocumentFormBase.getAdHocRouteWorkgroups().add(newWorkgroup); |
489 | 0 | AdHocRouteWorkgroup workgroup = new AdHocRouteWorkgroup(); |
490 | 0 | kualiDocumentFormBase.setNewAdHocRouteWorkgroup(workgroup); |
491 | |
} |
492 | |
|
493 | 0 | return mapping.findForward(RiceConstants.MAPPING_BASIC); |
494 | |
} |
495 | |
|
496 | |
|
497 | |
|
498 | |
|
499 | |
|
500 | |
|
501 | |
|
502 | |
|
503 | |
|
504 | |
|
505 | |
|
506 | |
|
507 | |
public ActionForward deleteAdHocRouteWorkgroup(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { |
508 | 0 | KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form; |
509 | |
|
510 | 0 | kualiDocumentFormBase.getAdHocRouteWorkgroups().remove(this.getLineToDelete(request)); |
511 | 0 | return mapping.findForward(RiceConstants.MAPPING_BASIC); |
512 | |
} |
513 | |
|
514 | |
public ActionForward sendAdHocRequests(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { |
515 | 0 | KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form; |
516 | 0 | Document document = kualiDocumentFormBase.getDocument(); |
517 | |
|
518 | 0 | boolean rulePassed = getKualiRuleService().applyRules(new SendAdHocRequestsEvent(document)); |
519 | |
|
520 | 0 | if (rulePassed) { |
521 | 0 | getDocumentService().sendAdHocRequests(document, kualiDocumentFormBase.getAnnotation(), combineAdHocRecipients(kualiDocumentFormBase)); |
522 | 0 | GlobalVariables.getMessageList().add(RiceKeyConstants.MESSAGE_SEND_AD_HOC_REQUESTS_SUCCESSFUL); |
523 | |
} |
524 | |
|
525 | 0 | return mapping.findForward(RiceConstants.MAPPING_BASIC); |
526 | |
} |
527 | |
|
528 | |
|
529 | |
|
530 | |
|
531 | |
|
532 | |
|
533 | |
|
534 | |
|
535 | |
|
536 | |
|
537 | |
public ActionForward reload(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { |
538 | 0 | KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form; |
539 | 0 | Document document = kualiDocumentFormBase.getDocument(); |
540 | |
|
541 | |
|
542 | 0 | kualiDocumentFormBase.setDocId(document.getDocumentNumber()); |
543 | 0 | kualiDocumentFormBase.setCommand(DOCUMENT_LOAD_COMMANDS[1]); |
544 | |
|
545 | |
|
546 | 0 | ActionForward actionForward = docHandler(mapping, form, request, response); |
547 | |
|
548 | 0 | GlobalVariables.getMessageList().add(RiceKeyConstants.MESSAGE_RELOADED); |
549 | |
|
550 | |
|
551 | |
|
552 | |
|
553 | |
|
554 | |
|
555 | |
|
556 | |
|
557 | |
|
558 | 0 | return actionForward; |
559 | |
} |
560 | |
|
561 | |
|
562 | |
|
563 | |
|
564 | |
|
565 | |
|
566 | |
|
567 | |
|
568 | |
|
569 | |
|
570 | |
|
571 | |
public ActionForward save(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { |
572 | 0 | KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form; |
573 | 0 | doProcessingAfterPost( kualiDocumentFormBase, request ); |
574 | |
|
575 | 0 | refreshAdHocRoutingWorkgroupLookups(request, kualiDocumentFormBase); |
576 | 0 | Document document = kualiDocumentFormBase.getDocument(); |
577 | |
|
578 | 0 | ActionForward forward = checkAndWarnAboutSensitiveData(mapping, form, request, response, KNSPropertyConstants.DOCUMENT_EXPLANATION, document.getDocumentHeader().getExplanation(), "save", ""); |
579 | 0 | if (forward != null) { |
580 | 0 | return forward; |
581 | |
} |
582 | |
|
583 | |
|
584 | 0 | getDocumentService().saveDocument(document); |
585 | |
|
586 | 0 | GlobalVariables.getMessageList().add(RiceKeyConstants.MESSAGE_SAVED); |
587 | 0 | kualiDocumentFormBase.setAnnotation(""); |
588 | |
|
589 | |
|
590 | |
|
591 | |
|
592 | |
|
593 | |
|
594 | |
|
595 | |
|
596 | |
|
597 | |
|
598 | 0 | return mapping.findForward(RiceConstants.MAPPING_BASIC); |
599 | |
} |
600 | |
|
601 | |
|
602 | |
|
603 | |
|
604 | |
|
605 | |
|
606 | |
|
607 | |
|
608 | |
|
609 | |
|
610 | |
|
611 | |
|
612 | |
|
613 | |
|
614 | |
|
615 | |
|
616 | |
|
617 | |
|
618 | |
protected ActionForward checkAndWarnAboutSensitiveData(ActionMapping mapping, ActionForm form, |
619 | |
HttpServletRequest request, HttpServletResponse response, String fieldName, String fieldValue, String caller, String context) |
620 | |
throws Exception { |
621 | 0 | KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form; |
622 | 0 | Document document = kualiDocumentFormBase.getDocument(); |
623 | |
|
624 | 0 | boolean containsSensitiveData = WebUtils.containsSensitiveDataPatternMatch(fieldValue); |
625 | |
|
626 | |
|
627 | 0 | boolean warnForSensitiveData = KNSServiceLocator.getParameterService().getIndicatorParameter( |
628 | |
KNSConstants.KNS_NAMESPACE, ParameterConstants.ALL_COMPONENT, |
629 | |
KNSConstants.SystemGroupParameterNames.SENSITIVE_DATA_PATTERNS_WARNING_IND); |
630 | |
|
631 | |
|
632 | 0 | Map<String, String> ticketContext = new HashMap<String, String>(); |
633 | 0 | ticketContext.put(KNSPropertyConstants.DOCUMENT_NUMBER, document.getDocumentNumber()); |
634 | 0 | ticketContext.put(KNSConstants.CALLING_METHOD, caller); |
635 | 0 | ticketContext.put(KNSPropertyConstants.NAME, fieldName); |
636 | |
|
637 | 0 | boolean questionAsked = GlobalVariables.getUserSession().hasMatchingSessionTicket( |
638 | |
KNSConstants.SENSITIVE_DATA_QUESTION_SESSION_TICKET, ticketContext); |
639 | |
|
640 | |
|
641 | 0 | if (containsSensitiveData && warnForSensitiveData && !questionAsked) { |
642 | 0 | Object question = request.getParameter(KNSConstants.QUESTION_INST_ATTRIBUTE_NAME); |
643 | 0 | if (question == null || !KNSConstants.DOCUMENT_SENSITIVE_DATA_QUESTION.equals(question)) { |
644 | |
|
645 | |
|
646 | 0 | return this.performQuestionWithoutInput(mapping, form, request, response, |
647 | |
KNSConstants.DOCUMENT_SENSITIVE_DATA_QUESTION, getKualiConfigurationService() |
648 | |
.getPropertyString(RiceKeyConstants.QUESTION_SENSITIVE_DATA_DOCUMENT), |
649 | |
KNSConstants.CONFIRMATION_QUESTION, caller, context); |
650 | |
} |
651 | |
|
652 | 0 | Object buttonClicked = request.getParameter(KNSConstants.QUESTION_CLICKED_BUTTON); |
653 | 0 | if (question != null && KNSConstants.DOCUMENT_SENSITIVE_DATA_QUESTION.equals(question)) { |
654 | |
|
655 | 0 | if (ConfirmationQuestion.NO.equals(buttonClicked)) { |
656 | |
|
657 | 0 | return mapping.findForward(RiceConstants.MAPPING_BASIC); |
658 | |
} |
659 | |
|
660 | |
|
661 | 0 | SessionTicket ticket = new SessionTicket(KNSConstants.SENSITIVE_DATA_QUESTION_SESSION_TICKET); |
662 | 0 | ticket.setTicketContext(ticketContext); |
663 | 0 | GlobalVariables.getUserSession().putSessionTicket(ticket); |
664 | |
} |
665 | |
} |
666 | |
|
667 | |
|
668 | 0 | return null; |
669 | |
} |
670 | |
|
671 | |
|
672 | |
|
673 | |
|
674 | |
|
675 | |
|
676 | |
|
677 | |
|
678 | |
|
679 | |
|
680 | |
|
681 | |
public ActionForward delete(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { |
682 | 0 | KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form; |
683 | 0 | if (isFormRepresentingLockObject(kualiDocumentFormBase)) { |
684 | 0 | String idValue = request.getParameter(KNSPropertyConstants.ID); |
685 | 0 | getPessimisticLockService().delete(idValue); |
686 | 0 | return returnToSender(request, mapping, kualiDocumentFormBase); |
687 | |
} |
688 | 0 | throw buildAuthorizationException(KNSConstants.DELETE_METHOD, kualiDocumentFormBase.getDocument()); |
689 | |
} |
690 | |
|
691 | |
|
692 | |
|
693 | |
|
694 | |
|
695 | |
|
696 | |
|
697 | |
|
698 | |
|
699 | |
|
700 | |
|
701 | |
public ActionForward performRouteReport(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { |
702 | 0 | KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form; |
703 | |
|
704 | 0 | kualiDocumentFormBase.setDerivedValuesOnForm(request); |
705 | 0 | ActionForward preRulesForward = promptBeforeValidation(mapping, form, request, response); |
706 | 0 | if (preRulesForward != null) { |
707 | 0 | return preRulesForward; |
708 | |
} |
709 | |
|
710 | 0 | Document document = kualiDocumentFormBase.getDocument(); |
711 | |
|
712 | |
|
713 | 0 | if (!kualiDocumentFormBase.getDocumentActions().containsKey(KNSConstants.KUALI_ACTION_PERFORM_ROUTE_REPORT)) { |
714 | 0 | throw buildAuthorizationException("perform route report", document); |
715 | |
} |
716 | |
|
717 | 0 | String backUrlBase = getReturnLocation(request, mapping); |
718 | 0 | String globalVariableFormKey = GlobalVariables.getUserSession().addObject(form); |
719 | |
|
720 | 0 | request.setAttribute("backUrlBase", backUrlBase); |
721 | 0 | List<KeyLabelPair> backFormParameters = new ArrayList<KeyLabelPair>(); |
722 | 0 | backFormParameters.add(new KeyLabelPair(KNSConstants.DISPATCH_REQUEST_PARAMETER,KNSConstants.RETURN_METHOD_TO_CALL)); |
723 | 0 | backFormParameters.add(new KeyLabelPair(KNSConstants.DOC_FORM_KEY,globalVariableFormKey)); |
724 | 0 | request.setAttribute("backFormHiddenVariables", backFormParameters); |
725 | |
|
726 | |
|
727 | 0 | request.setAttribute("workflowRouteReportUrl", getKualiConfigurationService().getPropertyString(KNSConstants.WORKFLOW_URL_KEY) + "/" + KEWConstants.DOCUMENT_ROUTING_REPORT_PAGE); |
728 | 0 | List<KeyLabelPair> generalRouteReportFormParameters = new ArrayList<KeyLabelPair>(); |
729 | 0 | generalRouteReportFormParameters.add(new KeyLabelPair(KEWConstants.INITIATOR_ID_ATTRIBUTE_NAME, document.getDocumentHeader().getWorkflowDocument().getRouteHeader().getInitiatorPrincipalId())); |
730 | 0 | generalRouteReportFormParameters.add(new KeyLabelPair(KEWConstants.DOCUMENT_TYPE_NAME_ATTRIBUTE_NAME,document.getDocumentHeader().getWorkflowDocument().getDocumentType())); |
731 | |
|
732 | 0 | String xml = document.getXmlForRouteReport(); |
733 | 0 | if ( LOG.isDebugEnabled() ) { |
734 | 0 | LOG.debug("XML being used for Routing Report is: " + xml); |
735 | |
} |
736 | 0 | generalRouteReportFormParameters.add(new KeyLabelPair(KEWConstants.DOCUMENT_CONTENT_ATTRIBUTE_NAME,xml)); |
737 | |
|
738 | |
|
739 | 0 | List<KeyLabelPair> javaScriptFormParameters = new ArrayList<KeyLabelPair>(); |
740 | 0 | javaScriptFormParameters.addAll(generalRouteReportFormParameters); |
741 | 0 | javaScriptFormParameters.add(new KeyLabelPair(KEWConstants.DISPLAY_CLOSE_BUTTON_ATTRIBUTE_NAME, KEWConstants.DISPLAY_CLOSE_BUTTON_TRUE_VALUE)); |
742 | 0 | request.setAttribute("javaScriptFormVariables", javaScriptFormParameters); |
743 | |
|
744 | |
|
745 | 0 | List<KeyLabelPair> noJavaScriptFormParameters = new ArrayList<KeyLabelPair>(); |
746 | 0 | noJavaScriptFormParameters.addAll(generalRouteReportFormParameters); |
747 | 0 | Properties parameters = new Properties(); |
748 | 0 | for (KeyLabelPair pair : backFormParameters) { |
749 | 0 | parameters.put(pair.getKey(), pair.getLabel()); |
750 | |
} |
751 | 0 | noJavaScriptFormParameters.add(new KeyLabelPair(KEWConstants.RETURN_URL_ATTRIBUTE_NAME,UrlFactory.parameterizeUrl(backUrlBase, parameters))); |
752 | 0 | request.setAttribute("noJavaScriptFormVariables", noJavaScriptFormParameters); |
753 | |
|
754 | 0 | return mapping.findForward(KNSConstants.MAPPING_ROUTE_REPORT); |
755 | |
} |
756 | |
|
757 | |
|
758 | |
|
759 | |
|
760 | |
|
761 | |
|
762 | |
|
763 | |
|
764 | |
|
765 | |
|
766 | |
|
767 | |
public ActionForward route(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { |
768 | 0 | KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form; |
769 | 0 | doProcessingAfterPost( kualiDocumentFormBase, request ); |
770 | |
|
771 | 0 | kualiDocumentFormBase.setDerivedValuesOnForm(request); |
772 | 0 | ActionForward preRulesForward = promptBeforeValidation(mapping, form, request, response); |
773 | 0 | if (preRulesForward != null) { |
774 | 0 | return preRulesForward; |
775 | |
} |
776 | |
|
777 | 0 | Document document = kualiDocumentFormBase.getDocument(); |
778 | |
|
779 | 0 | ActionForward forward = checkAndWarnAboutSensitiveData(mapping, form, request, response, KNSPropertyConstants.DOCUMENT_EXPLANATION, document.getDocumentHeader().getExplanation(), "route", ""); |
780 | 0 | if (forward != null) { |
781 | 0 | return forward; |
782 | |
} |
783 | |
|
784 | 0 | getDocumentService().routeDocument(document, kualiDocumentFormBase.getAnnotation(), combineAdHocRecipients(kualiDocumentFormBase)); |
785 | 0 | GlobalVariables.getMessageList().add(RiceKeyConstants.MESSAGE_ROUTE_SUCCESSFUL); |
786 | 0 | kualiDocumentFormBase.setAnnotation(""); |
787 | |
|
788 | |
|
789 | 0 | return mapping.findForward(RiceConstants.MAPPING_BASIC); |
790 | |
} |
791 | |
|
792 | |
|
793 | |
|
794 | |
|
795 | |
|
796 | |
|
797 | |
|
798 | |
|
799 | |
|
800 | |
|
801 | |
|
802 | |
public ActionForward blanketApprove(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { |
803 | 0 | KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form; |
804 | 0 | doProcessingAfterPost( kualiDocumentFormBase, request ); |
805 | |
|
806 | 0 | kualiDocumentFormBase.setDerivedValuesOnForm(request); |
807 | 0 | ActionForward preRulesForward = promptBeforeValidation(mapping, form, request, response); |
808 | 0 | if (preRulesForward != null) { |
809 | 0 | return preRulesForward; |
810 | |
} |
811 | |
|
812 | 0 | Document document = kualiDocumentFormBase.getDocument(); |
813 | |
|
814 | 0 | ActionForward forward = checkAndWarnAboutSensitiveData(mapping, form, request, response, KNSPropertyConstants.DOCUMENT_EXPLANATION, document.getDocumentHeader().getExplanation(), "blanketApprove", ""); |
815 | 0 | if (forward != null) { |
816 | 0 | return forward; |
817 | |
} |
818 | |
|
819 | 0 | getDocumentService().blanketApproveDocument(document, kualiDocumentFormBase.getAnnotation(), combineAdHocRecipients(kualiDocumentFormBase)); |
820 | 0 | GlobalVariables.getMessageList().add(RiceKeyConstants.MESSAGE_ROUTE_APPROVED); |
821 | 0 | kualiDocumentFormBase.setAnnotation(""); |
822 | 0 | return returnToSender(request, mapping, kualiDocumentFormBase); |
823 | |
} |
824 | |
|
825 | |
|
826 | |
|
827 | |
|
828 | |
|
829 | |
|
830 | |
|
831 | |
|
832 | |
|
833 | |
|
834 | |
|
835 | |
public ActionForward approve(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { |
836 | 0 | KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form; |
837 | 0 | doProcessingAfterPost( kualiDocumentFormBase, request ); |
838 | |
|
839 | 0 | kualiDocumentFormBase.setDerivedValuesOnForm(request); |
840 | 0 | ActionForward preRulesForward = promptBeforeValidation(mapping, form, request, response); |
841 | 0 | if (preRulesForward != null) { |
842 | 0 | return preRulesForward; |
843 | |
} |
844 | |
|
845 | 0 | Document document = kualiDocumentFormBase.getDocument(); |
846 | |
|
847 | 0 | ActionForward forward = checkAndWarnAboutSensitiveData(mapping, form, request, response, KNSPropertyConstants.DOCUMENT_EXPLANATION, document.getDocumentHeader().getExplanation(), "approve", ""); |
848 | 0 | if (forward != null) { |
849 | 0 | return forward; |
850 | |
} |
851 | |
|
852 | 0 | getDocumentService().approveDocument(document, kualiDocumentFormBase.getAnnotation(), combineAdHocRecipients(kualiDocumentFormBase)); |
853 | 0 | GlobalVariables.getMessageList().add(RiceKeyConstants.MESSAGE_ROUTE_APPROVED); |
854 | 0 | kualiDocumentFormBase.setAnnotation(""); |
855 | 0 | return returnToSender(request, mapping, kualiDocumentFormBase); |
856 | |
} |
857 | |
|
858 | |
|
859 | |
|
860 | |
|
861 | |
|
862 | |
|
863 | |
|
864 | |
|
865 | |
|
866 | |
|
867 | |
|
868 | |
public ActionForward disapprove(ActionMapping mapping, ActionForm form, HttpServletRequest request, |
869 | |
HttpServletResponse response) throws Exception { |
870 | 0 | Object question = request.getParameter(KNSConstants.QUESTION_INST_ATTRIBUTE_NAME); |
871 | 0 | String reason = request.getParameter(KNSConstants.QUESTION_REASON_ATTRIBUTE_NAME); |
872 | |
|
873 | 0 | if (StringUtils.isBlank(reason)) { |
874 | 0 | String context = request.getParameter(KNSConstants.QUESTION_CONTEXT); |
875 | 0 | if (context != null && StringUtils.contains(context, KNSConstants.QUESTION_REASON_ATTRIBUTE_NAME + "=")) { |
876 | 0 | reason = StringUtils.substringAfter(context, KNSConstants.QUESTION_REASON_ATTRIBUTE_NAME + "="); |
877 | |
} |
878 | |
} |
879 | |
|
880 | 0 | String disapprovalNoteText = ""; |
881 | |
|
882 | |
|
883 | 0 | if (question == null) { |
884 | |
|
885 | 0 | return this.performQuestionWithInput(mapping, form, request, response, |
886 | |
KNSConstants.DOCUMENT_DISAPPROVE_QUESTION, |
887 | |
getKualiConfigurationService().getPropertyString(RiceKeyConstants.QUESTION_DISAPPROVE_DOCUMENT), |
888 | |
KNSConstants.CONFIRMATION_QUESTION, KNSConstants.MAPPING_DISAPPROVE, ""); |
889 | |
} |
890 | 0 | Object buttonClicked = request.getParameter(KNSConstants.QUESTION_CLICKED_BUTTON); |
891 | 0 | if ((KNSConstants.DOCUMENT_DISAPPROVE_QUESTION.equals(question)) |
892 | |
&& ConfirmationQuestion.NO.equals(buttonClicked)) { |
893 | |
|
894 | 0 | return mapping.findForward(RiceConstants.MAPPING_BASIC); |
895 | |
} |
896 | |
|
897 | |
|
898 | 0 | String introNoteMessage = getKualiConfigurationService().getPropertyString( |
899 | |
RiceKeyConstants.MESSAGE_DISAPPROVAL_NOTE_TEXT_INTRO) |
900 | |
+ KNSConstants.BLANK_SPACE; |
901 | |
|
902 | |
|
903 | 0 | disapprovalNoteText = introNoteMessage + reason; |
904 | |
|
905 | |
|
906 | 0 | boolean warnForSensitiveData = KNSServiceLocator.getParameterService().getIndicatorParameter( |
907 | |
KNSConstants.KNS_NAMESPACE, ParameterConstants.ALL_COMPONENT, |
908 | |
KNSConstants.SystemGroupParameterNames.SENSITIVE_DATA_PATTERNS_WARNING_IND); |
909 | 0 | if (warnForSensitiveData) { |
910 | 0 | String context = KNSConstants.QUESTION_REASON_ATTRIBUTE_NAME + "=" + reason; |
911 | 0 | ActionForward forward = checkAndWarnAboutSensitiveData(mapping, form, request, response, |
912 | |
KNSConstants.QUESTION_REASON_ATTRIBUTE_NAME, disapprovalNoteText, "disapprove", context); |
913 | 0 | if (forward != null) { |
914 | 0 | return forward; |
915 | |
} |
916 | 0 | } else { |
917 | 0 | if (WebUtils.containsSensitiveDataPatternMatch(disapprovalNoteText)) { |
918 | 0 | return this |
919 | |
.performQuestionWithInputAgainBecauseOfErrors(mapping, form, request, response, |
920 | |
KNSConstants.DOCUMENT_DISAPPROVE_QUESTION, getKualiConfigurationService() |
921 | |
.getPropertyString(RiceKeyConstants.QUESTION_DISAPPROVE_DOCUMENT), |
922 | |
KNSConstants.CONFIRMATION_QUESTION, KNSConstants.MAPPING_DISAPPROVE, "", reason, |
923 | |
RiceKeyConstants.ERROR_DOCUMENT_FIELD_CONTAINS_POSSIBLE_SENSITIVE_DATA, |
924 | |
KNSConstants.QUESTION_REASON_ATTRIBUTE_NAME, "reason"); |
925 | |
} |
926 | |
} |
927 | |
|
928 | 0 | int disapprovalNoteTextLength = disapprovalNoteText.length(); |
929 | |
|
930 | |
|
931 | 0 | int noteTextMaxLength = getDataDictionaryService().getAttributeMaxLength(Note.class, |
932 | |
KNSConstants.NOTE_TEXT_PROPERTY_NAME).intValue(); |
933 | |
|
934 | 0 | if (StringUtils.isBlank(reason) || (disapprovalNoteTextLength > noteTextMaxLength)) { |
935 | |
|
936 | 0 | int reasonLimit = noteTextMaxLength - disapprovalNoteTextLength; |
937 | |
|
938 | 0 | if (reason == null) { |
939 | |
|
940 | 0 | reason = ""; |
941 | |
} |
942 | 0 | return this.performQuestionWithInputAgainBecauseOfErrors(mapping, form, request, response, |
943 | |
KNSConstants.DOCUMENT_DISAPPROVE_QUESTION, |
944 | |
getKualiConfigurationService().getPropertyString(RiceKeyConstants.QUESTION_DISAPPROVE_DOCUMENT), |
945 | |
KNSConstants.CONFIRMATION_QUESTION, KNSConstants.MAPPING_DISAPPROVE, "", reason, |
946 | |
RiceKeyConstants.ERROR_DOCUMENT_DISAPPROVE_REASON_REQUIRED, |
947 | |
KNSConstants.QUESTION_REASON_ATTRIBUTE_NAME, new Integer(reasonLimit).toString()); |
948 | |
} |
949 | |
|
950 | 0 | KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form; |
951 | 0 | doProcessingAfterPost(kualiDocumentFormBase, request); |
952 | 0 | getDocumentService().disapproveDocument(kualiDocumentFormBase.getDocument(), disapprovalNoteText); |
953 | 0 | GlobalVariables.getMessageList().add(RiceKeyConstants.MESSAGE_ROUTE_DISAPPROVED); |
954 | 0 | kualiDocumentFormBase.setAnnotation(""); |
955 | |
|
956 | 0 | return returnToSender(request, mapping, kualiDocumentFormBase); |
957 | |
} |
958 | |
|
959 | |
|
960 | |
|
961 | |
|
962 | |
|
963 | |
|
964 | |
|
965 | |
|
966 | |
|
967 | |
|
968 | |
|
969 | |
public ActionForward cancel(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { |
970 | 0 | Object question = request.getParameter(KNSConstants.QUESTION_INST_ATTRIBUTE_NAME); |
971 | |
|
972 | |
|
973 | 0 | if (question == null) { |
974 | |
|
975 | 0 | return this.performQuestionWithoutInput(mapping, form, request, response, KNSConstants.DOCUMENT_CANCEL_QUESTION, getKualiConfigurationService().getPropertyString("document.question.cancel.text"), KNSConstants.CONFIRMATION_QUESTION, KNSConstants.MAPPING_CANCEL, ""); |
976 | |
} |
977 | |
else { |
978 | 0 | Object buttonClicked = request.getParameter(KNSConstants.QUESTION_CLICKED_BUTTON); |
979 | 0 | if ((KNSConstants.DOCUMENT_CANCEL_QUESTION.equals(question)) && ConfirmationQuestion.NO.equals(buttonClicked)) { |
980 | |
|
981 | 0 | return mapping.findForward(RiceConstants.MAPPING_BASIC); |
982 | |
} |
983 | |
|
984 | |
} |
985 | |
|
986 | 0 | KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form; |
987 | 0 | doProcessingAfterPost( kualiDocumentFormBase, request ); |
988 | |
|
989 | 0 | if ( getDocumentService().documentExists(kualiDocumentFormBase.getDocId())) |
990 | |
{ |
991 | 0 | getDocumentService().cancelDocument(kualiDocumentFormBase.getDocument(), kualiDocumentFormBase.getAnnotation()); |
992 | |
} |
993 | |
|
994 | 0 | return returnToSender(request, mapping, kualiDocumentFormBase); |
995 | |
} |
996 | |
|
997 | |
|
998 | |
|
999 | |
|
1000 | |
|
1001 | |
|
1002 | |
|
1003 | |
|
1004 | |
|
1005 | |
|
1006 | |
|
1007 | |
|
1008 | |
public ActionForward close(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { |
1009 | 0 | KualiDocumentFormBase docForm = (KualiDocumentFormBase) form; |
1010 | 0 | doProcessingAfterPost( docForm, request ); |
1011 | 0 | Document document = docForm.getDocument(); |
1012 | |
|
1013 | 0 | if (canSave(docForm)) { |
1014 | 0 | Object question = getQuestion(request); |
1015 | |
|
1016 | 0 | if (question == null) { |
1017 | |
|
1018 | 0 | return this.performQuestionWithoutInput(mapping, form, request, response, KNSConstants.DOCUMENT_SAVE_BEFORE_CLOSE_QUESTION, getKualiConfigurationService().getPropertyString(RiceKeyConstants.QUESTION_SAVE_BEFORE_CLOSE), KNSConstants.CONFIRMATION_QUESTION, KNSConstants.MAPPING_CLOSE, ""); |
1019 | |
} |
1020 | |
else { |
1021 | 0 | Object buttonClicked = request.getParameter(KNSConstants.QUESTION_CLICKED_BUTTON); |
1022 | 0 | if ((KNSConstants.DOCUMENT_SAVE_BEFORE_CLOSE_QUESTION.equals(question)) && ConfirmationQuestion.YES.equals(buttonClicked)) { |
1023 | |
|
1024 | 0 | ActionForward forward = checkAndWarnAboutSensitiveData(mapping, form, request, response, KNSPropertyConstants.DOCUMENT_EXPLANATION, document.getDocumentHeader().getExplanation(), "save", ""); |
1025 | 0 | if (forward != null) { |
1026 | 0 | return forward; |
1027 | |
} |
1028 | |
|
1029 | 0 | getDocumentService().saveDocument(docForm.getDocument()); |
1030 | |
} |
1031 | |
|
1032 | |
} |
1033 | |
} |
1034 | |
|
1035 | 0 | return returnToSender(request, mapping, docForm); |
1036 | |
} |
1037 | |
|
1038 | |
protected boolean canSave(ActionForm form){ |
1039 | 0 | KualiDocumentFormBase docForm = (KualiDocumentFormBase) form; |
1040 | 0 | return docForm.getDocumentActions().containsKey(KNSConstants.KUALI_ACTION_CAN_SAVE); |
1041 | |
} |
1042 | |
|
1043 | |
protected Object getQuestion(HttpServletRequest request){ |
1044 | 0 | return request.getParameter(KNSConstants.QUESTION_INST_ATTRIBUTE_NAME); |
1045 | |
} |
1046 | |
|
1047 | |
|
1048 | |
|
1049 | |
|
1050 | |
|
1051 | |
|
1052 | |
|
1053 | |
|
1054 | |
|
1055 | |
|
1056 | |
|
1057 | |
public ActionForward fyi(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { |
1058 | 0 | KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form; |
1059 | 0 | doProcessingAfterPost( kualiDocumentFormBase, request ); |
1060 | 0 | getDocumentService().clearDocumentFyi(kualiDocumentFormBase.getDocument(), combineAdHocRecipients(kualiDocumentFormBase)); |
1061 | 0 | GlobalVariables.getMessageList().add(RiceKeyConstants.MESSAGE_ROUTE_FYIED); |
1062 | 0 | kualiDocumentFormBase.setAnnotation(""); |
1063 | 0 | return returnToSender(request, mapping, kualiDocumentFormBase); |
1064 | |
} |
1065 | |
|
1066 | |
|
1067 | |
|
1068 | |
|
1069 | |
|
1070 | |
|
1071 | |
|
1072 | |
|
1073 | |
|
1074 | |
|
1075 | |
|
1076 | |
public ActionForward acknowledge(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { |
1077 | 0 | KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form; |
1078 | 0 | doProcessingAfterPost( kualiDocumentFormBase, request ); |
1079 | 0 | getDocumentService().acknowledgeDocument(kualiDocumentFormBase.getDocument(), kualiDocumentFormBase.getAnnotation(), combineAdHocRecipients(kualiDocumentFormBase)); |
1080 | 0 | GlobalVariables.getMessageList().add(RiceKeyConstants.MESSAGE_ROUTE_ACKNOWLEDGED); |
1081 | 0 | kualiDocumentFormBase.setAnnotation(""); |
1082 | 0 | return returnToSender(request, mapping, kualiDocumentFormBase); |
1083 | |
} |
1084 | |
|
1085 | |
|
1086 | |
|
1087 | |
|
1088 | |
|
1089 | |
|
1090 | |
|
1091 | |
|
1092 | |
|
1093 | |
|
1094 | |
|
1095 | |
public ActionForward supervisorFunctions(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { |
1096 | 0 | KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form; |
1097 | |
|
1098 | |
|
1099 | 0 | String workflowSuperUserUrl = getKualiConfigurationService().getPropertyString(KNSConstants.WORKFLOW_URL_KEY) + "/SuperUser.do?methodToCall=displaySuperUserDocument&routeHeaderId=" + kualiDocumentFormBase.getDocument().getDocumentHeader().getDocumentNumber(); |
1100 | 0 | response.sendRedirect(workflowSuperUserUrl); |
1101 | |
|
1102 | 0 | return null; |
1103 | |
} |
1104 | |
|
1105 | |
|
1106 | |
|
1107 | |
|
1108 | |
|
1109 | |
|
1110 | |
|
1111 | |
|
1112 | |
protected List<AdHocRouteRecipient> combineAdHocRecipients(KualiDocumentFormBase kualiDocumentFormBase) { |
1113 | 0 | List<AdHocRouteRecipient> adHocRecipients = new ArrayList<AdHocRouteRecipient>(); |
1114 | 0 | adHocRecipients.addAll(kualiDocumentFormBase.getAdHocRoutePersons()); |
1115 | 0 | adHocRecipients.addAll(kualiDocumentFormBase.getAdHocRouteWorkgroups()); |
1116 | 0 | return adHocRecipients; |
1117 | |
} |
1118 | |
|
1119 | |
|
1120 | |
|
1121 | |
|
1122 | |
|
1123 | |
|
1124 | |
@Override |
1125 | |
public ActionForward refresh(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { |
1126 | 0 | KualiDocumentFormBase kualiForm = (KualiDocumentFormBase) form; |
1127 | 0 | kualiForm.setDerivedValuesOnForm(request); |
1128 | |
|
1129 | 0 | super.refresh(mapping, form, request, response); |
1130 | 0 | refreshAdHocRoutingWorkgroupLookups(request, kualiForm); |
1131 | |
|
1132 | 0 | return mapping.findForward(RiceConstants.MAPPING_BASIC); |
1133 | |
} |
1134 | |
|
1135 | |
|
1136 | |
|
1137 | |
|
1138 | |
|
1139 | |
|
1140 | |
|
1141 | |
|
1142 | |
@SuppressWarnings("unchecked") |
1143 | |
protected void refreshAdHocRoutingWorkgroupLookups(HttpServletRequest request, KualiDocumentFormBase kualiForm) throws WorkflowException { |
1144 | 0 | for (Enumeration<String> i = request.getParameterNames(); i.hasMoreElements();) { |
1145 | 0 | String parameterName = i.nextElement(); |
1146 | 0 | if (parameterName.equals("newAdHocRouteWorkgroup.recipientName") && !"".equals(request.getParameter(parameterName))) { |
1147 | |
|
1148 | 0 | String namespace = KimConstants.KIM_GROUP_DEFAULT_NAMESPACE_CODE; |
1149 | 0 | if (request.getParameter("newAdHocRouteWorkgroup.recipientNamespaceCode") != null && !"".equals(request.getParameter("newAdHocRouteWorkgroup.recipientName").trim())) { |
1150 | 0 | namespace = request.getParameter("newAdHocRouteWorkgroup.recipientNamespaceCode").trim(); |
1151 | |
} |
1152 | 0 | Group group = getIdentityManagementService().getGroupByName(namespace, request.getParameter(parameterName)); |
1153 | 0 | if (group != null) { |
1154 | 0 | kualiForm.getNewAdHocRouteWorkgroup().setId(group.getGroupId()); |
1155 | 0 | kualiForm.getNewAdHocRouteWorkgroup().setRecipientName(group.getGroupName()); |
1156 | 0 | kualiForm.getNewAdHocRouteWorkgroup().setRecipientNamespaceCode(group.getNamespaceCode()); |
1157 | |
} else { |
1158 | 0 | throw new RuntimeException("Invalid workgroup id passed as parameter."); |
1159 | |
} |
1160 | |
} |
1161 | 0 | if (parameterName.startsWith("adHocRouteWorkgroup[") && !"".equals(request.getParameter(parameterName))) { |
1162 | 0 | if (parameterName.endsWith(".recipientName")) { |
1163 | 0 | int lineNumber = Integer.parseInt(StringUtils.substringBetween(parameterName, "[", "]")); |
1164 | |
|
1165 | 0 | String namespaceParam = "adHocRouteWorkgroup[" + lineNumber + "].recipientNamespaceCode"; |
1166 | 0 | String namespace = KimConstants.KIM_GROUP_DEFAULT_NAMESPACE_CODE; |
1167 | 0 | if (request.getParameter(namespaceParam) != null && !"".equals(request.getParameter(namespaceParam).trim())) { |
1168 | 0 | namespace = request.getParameter(namespaceParam).trim(); |
1169 | |
} |
1170 | 0 | Group group = getIdentityManagementService().getGroupByName(namespace, request.getParameter(parameterName)); |
1171 | 0 | if (group != null) { |
1172 | 0 | kualiForm.getAdHocRouteWorkgroup(lineNumber).setId(group.getGroupId()); |
1173 | 0 | kualiForm.getAdHocRouteWorkgroup(lineNumber).setRecipientName(group.getGroupName()); |
1174 | 0 | kualiForm.getAdHocRouteWorkgroup(lineNumber).setRecipientNamespaceCode(group.getNamespaceCode()); |
1175 | |
} else { |
1176 | 0 | throw new RuntimeException("Invalid workgroup id passed as parameter."); |
1177 | |
} |
1178 | |
} |
1179 | |
} |
1180 | |
|
1181 | |
|
1182 | |
|
1183 | |
|
1184 | |
|
1185 | |
|
1186 | |
|
1187 | |
|
1188 | |
|
1189 | |
|
1190 | |
|
1191 | |
|
1192 | |
|
1193 | |
|
1194 | |
|
1195 | |
|
1196 | |
|
1197 | |
|
1198 | |
|
1199 | |
|
1200 | |
|
1201 | 0 | } |
1202 | 0 | } |
1203 | |
|
1204 | |
|
1205 | |
|
1206 | |
|
1207 | |
|
1208 | |
|
1209 | |
|
1210 | |
|
1211 | |
|
1212 | |
|
1213 | |
|
1214 | |
|
1215 | |
public ActionForward cancelBOAttachment(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { |
1216 | 0 | KualiDocumentFormBase documentForm = (KualiDocumentFormBase) form; |
1217 | |
|
1218 | |
|
1219 | 0 | documentForm.setAttachmentFile(new BlankFormFile()); |
1220 | |
|
1221 | |
|
1222 | 0 | Note note = documentForm.getNewNote(); |
1223 | 0 | note.removeAttachment(); |
1224 | 0 | documentForm.setNewNote(note); |
1225 | |
|
1226 | 0 | return mapping.findForward(RiceConstants.MAPPING_BASIC); |
1227 | |
} |
1228 | |
|
1229 | |
|
1230 | |
|
1231 | |
|
1232 | |
|
1233 | |
|
1234 | |
|
1235 | |
|
1236 | |
protected void streamToResponse(byte[] fileContents, String fileName, String fileContentType,HttpServletResponse response) throws Exception{ |
1237 | 0 | ByteArrayOutputStream baos = null; |
1238 | |
try{ |
1239 | 0 | baos = new ByteArrayOutputStream(fileContents.length); |
1240 | 0 | baos.write(fileContents); |
1241 | 0 | WebUtils.saveMimeOutputStreamAsFile(response, fileContentType, baos, fileName); |
1242 | 0 | }finally{ |
1243 | 0 | try{ |
1244 | 0 | if(baos!=null){ |
1245 | 0 | baos.close(); |
1246 | 0 | baos = null; |
1247 | |
} |
1248 | 0 | }catch(IOException ioEx){ |
1249 | 0 | LOG.error("Error while downloading attachment"); |
1250 | 0 | throw new RuntimeException("IOException occurred while downloading attachment", ioEx); |
1251 | 0 | } |
1252 | 0 | } |
1253 | 0 | } |
1254 | |
|
1255 | |
|
1256 | |
|
1257 | |
|
1258 | |
|
1259 | |
|
1260 | |
|
1261 | |
|
1262 | |
|
1263 | |
|
1264 | |
|
1265 | |
public ActionForward downloadBOAttachment(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { |
1266 | 0 | int attachmentIndex = selectedAttachmentIndex(request); |
1267 | |
|
1268 | 0 | Note newNote = ((KualiDocumentFormBase) form).getNewNote(); |
1269 | 0 | PersistableBusinessObject noteParent = getNoteParent(((KualiDocumentFormBase) form).getDocument(), newNote); |
1270 | |
|
1271 | |
|
1272 | 0 | if (attachmentIndex >= 0) { |
1273 | 0 | Note note = noteParent.getBoNote(attachmentIndex); |
1274 | 0 | Attachment attachment = note.getAttachment(); |
1275 | |
|
1276 | 0 | attachment.setNote(note); |
1277 | |
|
1278 | |
|
1279 | 0 | KualiDocumentFormBase documentForm = (KualiDocumentFormBase) form; |
1280 | 0 | documentForm.copyPopulateEditablePropertiesToActionEditableProperties(); |
1281 | |
|
1282 | 0 | WebUtils.saveMimeInputStreamAsFile(response, attachment.getAttachmentMimeTypeCode(), attachment.getAttachmentContents(), attachment.getAttachmentFileName(), attachment.getAttachmentFileSize().intValue()); |
1283 | 0 | return null; |
1284 | |
} |
1285 | |
|
1286 | 0 | return mapping.findForward(RiceConstants.MAPPING_BASIC); |
1287 | |
} |
1288 | |
|
1289 | |
|
1290 | |
|
1291 | |
|
1292 | |
|
1293 | |
|
1294 | |
protected int selectedAttachmentIndex(HttpServletRequest request) { |
1295 | 0 | int attachmentIndex = -1; |
1296 | |
|
1297 | 0 | String parameterName = (String) request.getAttribute(KNSConstants.METHOD_TO_CALL_ATTRIBUTE); |
1298 | 0 | if (StringUtils.isNotBlank(parameterName)) { |
1299 | 0 | String attachmentIndexParam = StringUtils.substringBetween(parameterName, ".attachment[", "]."); |
1300 | |
|
1301 | |
try { |
1302 | 0 | attachmentIndex = Integer.parseInt(attachmentIndexParam); |
1303 | |
} |
1304 | 0 | catch (NumberFormatException ignored) { |
1305 | 0 | } |
1306 | |
} |
1307 | |
|
1308 | 0 | return attachmentIndex; |
1309 | |
} |
1310 | |
|
1311 | |
|
1312 | |
|
1313 | |
|
1314 | |
|
1315 | |
|
1316 | |
|
1317 | |
|
1318 | |
|
1319 | |
|
1320 | |
|
1321 | |
|
1322 | |
public ActionForward insertBONote(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { |
1323 | 0 | KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form; |
1324 | 0 | Document document = kualiDocumentFormBase.getDocument(); |
1325 | 0 | Note newNote = kualiDocumentFormBase.getNewNote(); |
1326 | 0 | newNote.setNotePostedTimestampToCurrent(); |
1327 | |
|
1328 | 0 | String attachmentTypeCode = null; |
1329 | |
|
1330 | 0 | FormFile attachmentFile = kualiDocumentFormBase.getAttachmentFile(); |
1331 | 0 | if (attachmentFile == null) { |
1332 | 0 | GlobalVariables.getMessageMap().putError( |
1333 | |
String.format("%s.%s", |
1334 | |
KNSConstants.NEW_DOCUMENT_NOTE_PROPERTY_NAME, |
1335 | |
KNSConstants.NOTE_ATTACHMENT_FILE_PROPERTY_NAME), |
1336 | |
RiceKeyConstants.ERROR_UPLOADFILE_NULL); |
1337 | |
|
1338 | |
|
1339 | |
} |
1340 | |
|
1341 | 0 | if(newNote.getAttachment() != null){ |
1342 | 0 | attachmentTypeCode = newNote.getAttachment().getAttachmentTypeCode(); |
1343 | |
} |
1344 | |
|
1345 | |
|
1346 | 0 | DocumentAuthorizer documentAuthorizer = getDocumentHelperService().getDocumentAuthorizer(document); |
1347 | 0 | if(!documentAuthorizer.canAddNoteAttachment(document, attachmentTypeCode, GlobalVariables.getUserSession().getPerson())){ |
1348 | 0 | throw buildAuthorizationException("annotate", document); |
1349 | |
} |
1350 | |
|
1351 | 0 | PersistableBusinessObject noteParent = getNoteParent(document, newNote); |
1352 | |
|
1353 | |
|
1354 | |
|
1355 | |
|
1356 | 0 | Attachment attachment = null; |
1357 | 0 | if (attachmentFile != null && !StringUtils.isBlank(attachmentFile.getFileName())) { |
1358 | 0 | if (attachmentFile.getFileSize() == 0) { |
1359 | 0 | GlobalVariables.getMessageMap().putError( |
1360 | |
String.format("%s.%s", |
1361 | |
KNSConstants.NEW_DOCUMENT_NOTE_PROPERTY_NAME, |
1362 | |
KNSConstants.NOTE_ATTACHMENT_FILE_PROPERTY_NAME), |
1363 | |
RiceKeyConstants.ERROR_UPLOADFILE_EMPTY, |
1364 | |
attachmentFile.getFileName()); |
1365 | |
|
1366 | |
|
1367 | |
} |
1368 | |
else { |
1369 | 0 | String attachmentType = null; |
1370 | 0 | Attachment newAttachment = kualiDocumentFormBase.getNewNote().getAttachment(); |
1371 | 0 | if (newAttachment != null) { |
1372 | 0 | attachmentType = newAttachment.getAttachmentTypeCode(); |
1373 | |
} |
1374 | 0 | attachment = getAttachmentService().createAttachment(noteParent, attachmentFile.getFileName(), attachmentFile.getContentType(), attachmentFile.getFileSize(), attachmentFile.getInputStream(), attachmentType); |
1375 | |
} |
1376 | |
} |
1377 | |
|
1378 | 0 | DataDictionary dataDictionary = getDataDictionaryService().getDataDictionary(); |
1379 | 0 | DocumentEntry entry = dataDictionary.getDocumentEntry(document.getClass().getName()); |
1380 | |
|
1381 | 0 | if(entry.getDisplayTopicFieldInNotes()) { |
1382 | 0 | String topicText = kualiDocumentFormBase.getNewNote().getNoteTopicText(); |
1383 | 0 | if(StringUtils.isBlank(topicText)) { |
1384 | 0 | GlobalVariables.getMessageMap().putError( |
1385 | |
String.format("%s.%s", |
1386 | |
KNSConstants.NEW_DOCUMENT_NOTE_PROPERTY_NAME, |
1387 | |
KNSConstants.NOTE_TOPIC_TEXT_PROPERTY_NAME), |
1388 | |
RiceKeyConstants.ERROR_REQUIRED, |
1389 | |
"Note Topic (Note Topic)"); |
1390 | |
} |
1391 | |
} |
1392 | |
|
1393 | |
|
1394 | 0 | Note tmpNote = getNoteService().createNote(newNote, noteParent); |
1395 | |
|
1396 | 0 | ActionForward forward = checkAndWarnAboutSensitiveData(mapping, form, request, response, KNSPropertyConstants.NOTE, tmpNote.getNoteText(), "insertBONote", ""); |
1397 | 0 | if (forward != null) { |
1398 | 0 | return forward; |
1399 | |
} |
1400 | |
|
1401 | |
|
1402 | 0 | boolean rulePassed = getKualiRuleService().applyRules(new AddNoteEvent(document, tmpNote)); |
1403 | |
|
1404 | |
|
1405 | 0 | if (rulePassed) { |
1406 | 0 | tmpNote.refresh(); |
1407 | |
|
1408 | |
|
1409 | 0 | DocumentHeader documentHeader = kualiDocumentFormBase.getDocument().getDocumentHeader(); |
1410 | |
|
1411 | |
|
1412 | 0 | noteParent.addNote(tmpNote); |
1413 | |
|
1414 | |
|
1415 | |
|
1416 | |
|
1417 | 0 | if (!documentHeader.getWorkflowDocument().stateIsInitiated()&&StringUtils.isNotEmpty(noteParent.getObjectId()) |
1418 | |
&& !(document instanceof MaintenanceDocument && KNSConstants.NoteTypeEnum.BUSINESS_OBJECT_NOTE_TYPE.getCode().equals(tmpNote.getNoteTypeCode())) |
1419 | |
) { |
1420 | 0 | getNoteService().save(tmpNote); |
1421 | |
} |
1422 | |
|
1423 | |
|
1424 | |
|
1425 | 0 | if (attachment != null) { |
1426 | 0 | tmpNote.addAttachment(attachment); |
1427 | |
|
1428 | |
|
1429 | 0 | if (!documentHeader.getWorkflowDocument().stateIsInitiated()&&StringUtils.isNotEmpty(noteParent.getObjectId()) |
1430 | |
&& !(document instanceof MaintenanceDocument && KNSConstants.NoteTypeEnum.BUSINESS_OBJECT_NOTE_TYPE.getCode().equals(tmpNote.getNoteTypeCode())) |
1431 | |
) { |
1432 | 0 | getNoteService().save(tmpNote); |
1433 | |
} |
1434 | |
} |
1435 | |
|
1436 | |
|
1437 | |
|
1438 | 0 | kualiDocumentFormBase.setNewNote(new Note()); |
1439 | |
} |
1440 | |
|
1441 | |
|
1442 | 0 | return mapping.findForward(RiceConstants.MAPPING_BASIC); |
1443 | |
} |
1444 | |
|
1445 | |
|
1446 | |
|
1447 | |
|
1448 | |
|
1449 | |
|
1450 | |
|
1451 | |
private PersistableBusinessObject getNoteParent(Document document, Note newNote) { |
1452 | |
|
1453 | 0 | String propertyName = getNoteService().extractNoteProperty(newNote); |
1454 | |
|
1455 | 0 | PersistableBusinessObject noteParent = (PersistableBusinessObject)ObjectUtils.getPropertyValue(document, propertyName); |
1456 | 0 | return noteParent; |
1457 | |
} |
1458 | |
|
1459 | |
|
1460 | |
|
1461 | |
|
1462 | |
|
1463 | |
|
1464 | |
|
1465 | |
|
1466 | |
|
1467 | |
|
1468 | |
|
1469 | |
public ActionForward deleteBONote(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { |
1470 | 0 | KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form; |
1471 | 0 | Document document = kualiDocumentFormBase.getDocument(); |
1472 | |
|
1473 | |
|
1474 | |
|
1475 | |
|
1476 | |
|
1477 | |
|
1478 | |
|
1479 | |
|
1480 | |
|
1481 | |
|
1482 | |
|
1483 | |
|
1484 | |
|
1485 | |
|
1486 | 0 | Note newNote = kualiDocumentFormBase.getNewNote(); |
1487 | 0 | PersistableBusinessObject noteParent = this.getNoteParent(document, newNote); |
1488 | 0 | Note note = noteParent.getBoNote(getLineToDelete(request)); |
1489 | 0 | Attachment attachment = note.getAttachment(); |
1490 | 0 | String attachmentTypeCode = null; |
1491 | 0 | if(attachment != null){ |
1492 | 0 | attachmentTypeCode = attachment.getAttachmentTypeCode(); |
1493 | |
} |
1494 | 0 | String authorUniversalIdentifier = note.getAuthorUniversalIdentifier(); |
1495 | 0 | if(!WebUtils.canDeleteNoteAttachment(document, attachmentTypeCode, authorUniversalIdentifier) ){ |
1496 | 0 | throw buildAuthorizationException("annotate", document); |
1497 | |
} |
1498 | |
|
1499 | 0 | if (attachment != null) { |
1500 | |
|
1501 | |
|
1502 | |
|
1503 | 0 | if (note.getNoteIdentifier() != null) { |
1504 | 0 | attachment.refreshNonUpdateableReferences(); |
1505 | |
} |
1506 | 0 | getAttachmentService().deleteAttachmentContents(attachment); |
1507 | |
} |
1508 | |
|
1509 | 0 | if (!document.getDocumentHeader().getWorkflowDocument().stateIsInitiated()) { |
1510 | 0 | getNoteService().deleteNote(note); |
1511 | |
} |
1512 | 0 | noteParent.deleteNote(note); |
1513 | |
|
1514 | 0 | return mapping.findForward(RiceConstants.MAPPING_BASIC); |
1515 | |
} |
1516 | |
|
1517 | |
|
1518 | |
|
1519 | |
|
1520 | |
|
1521 | |
|
1522 | |
|
1523 | |
|
1524 | |
|
1525 | |
protected String determineNoteWorkflowNotificationAction(HttpServletRequest request, KualiDocumentFormBase kualiDocumentFormBase, Note note) { |
1526 | 0 | return getParameterService().getParameterValue(KNSConstants.KNS_NAMESPACE, KNSConstants.DetailTypes.DOCUMENT_DETAIL_TYPE, KNSConstants.SEND_NOTE_WORKFLOW_NOTIFICATION_ACTIONS_PARM_NM); |
1527 | |
} |
1528 | |
|
1529 | |
public ActionForward sendNoteWorkflowNotification(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { |
1530 | 0 | KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form; |
1531 | 0 | Document document = kualiDocumentFormBase.getDocument(); |
1532 | |
|
1533 | |
|
1534 | 0 | PersistableBusinessObject noteParent = this.getNoteParent(document, kualiDocumentFormBase.getNewNote()); |
1535 | 0 | Note note = noteParent.getBoNote(getSelectedLine(request)); |
1536 | |
|
1537 | |
|
1538 | 0 | if (StringUtils.isBlank(note.getAdHocRouteRecipient().getId())) { |
1539 | 0 | GlobalVariables.getMessageMap().putError(KNSPropertyConstants.NEW_DOCUMENT_NOTE, RiceKeyConstants.ERROR_SEND_NOTE_NOTIFICATION_RECIPIENT); |
1540 | 0 | return mapping.findForward(RiceConstants.MAPPING_BASIC); |
1541 | |
} |
1542 | |
|
1543 | |
else { |
1544 | 0 | note.getAdHocRouteRecipient().setActionRequested(determineNoteWorkflowNotificationAction(request, kualiDocumentFormBase, note)); |
1545 | |
|
1546 | 0 | boolean rulePassed = getKualiRuleService().applyRules(new AddAdHocRoutePersonEvent(KNSPropertyConstants.NEW_DOCUMENT_NOTE, document, (AdHocRoutePerson) note.getAdHocRouteRecipient())); |
1547 | 0 | if (!rulePassed) { |
1548 | 0 | return mapping.findForward(RiceConstants.MAPPING_BASIC); |
1549 | |
} |
1550 | |
} |
1551 | |
|
1552 | |
|
1553 | 0 | if (!document.getDocumentHeader().getWorkflowDocument().stateIsInitiated()) { |
1554 | 0 | getNoteService().sendNoteRouteNotification(document, note, GlobalVariables.getUserSession().getPerson()); |
1555 | |
|
1556 | |
|
1557 | 0 | GlobalVariables.getMessageList().add(RiceKeyConstants.MESSAGE_SEND_NOTE_NOTIFICATION_SUCCESSFUL); |
1558 | |
} |
1559 | |
else { |
1560 | 0 | GlobalVariables.getMessageMap().putError(KNSPropertyConstants.NEW_DOCUMENT_NOTE, RiceKeyConstants.ERROR_SEND_NOTE_NOTIFICATION_DOCSTATUS); |
1561 | |
} |
1562 | |
|
1563 | 0 | return mapping.findForward(RiceConstants.MAPPING_BASIC); |
1564 | |
} |
1565 | |
|
1566 | |
|
1567 | |
|
1568 | |
|
1569 | |
|
1570 | |
|
1571 | |
|
1572 | |
private final void logOjbOptimisticLockException(OptimisticLockException e) { |
1573 | 0 | if ( LOG.isInfoEnabled() ) { |
1574 | 0 | StringBuffer message = new StringBuffer("caught OptimisticLockException, caused by "); |
1575 | 0 | Object sourceObject = e.getSourceObject(); |
1576 | 0 | String infix = null; |
1577 | |
try { |
1578 | |
|
1579 | 0 | infix = sourceObject.toString(); |
1580 | |
} |
1581 | 0 | catch (Exception e2) { |
1582 | |
|
1583 | 0 | infix = sourceObject.getClass().getName(); |
1584 | 0 | } |
1585 | 0 | message.append(infix); |
1586 | |
|
1587 | 0 | if (sourceObject instanceof PersistableBusinessObject) { |
1588 | 0 | PersistableBusinessObject persistableObject = (PersistableBusinessObject) sourceObject; |
1589 | 0 | message.append(" [versionNumber = " ).append( persistableObject.getVersionNumber() ).append( "]" ); |
1590 | |
} |
1591 | |
|
1592 | 0 | LOG.info(message.toString(), e); |
1593 | |
} |
1594 | 0 | } |
1595 | |
|
1596 | |
|
1597 | |
|
1598 | |
|
1599 | |
|
1600 | |
|
1601 | |
|
1602 | |
|
1603 | |
|
1604 | |
|
1605 | |
|
1606 | |
|
1607 | |
|
1608 | |
public ActionForward promptBeforeValidation(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { |
1609 | 0 | return promptBeforeValidation(mapping, form, request, response, "route"); |
1610 | |
} |
1611 | |
|
1612 | |
|
1613 | |
|
1614 | |
|
1615 | |
|
1616 | |
|
1617 | |
|
1618 | |
|
1619 | |
|
1620 | |
|
1621 | |
|
1622 | |
|
1623 | |
|
1624 | |
public ActionForward promptBeforeValidation(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response, String methodToCall) throws Exception { |
1625 | 0 | KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form; |
1626 | |
|
1627 | |
|
1628 | 0 | Class<? extends PromptBeforeValidation> promptBeforeValidationClass = getDataDictionaryService().getPromptBeforeValidationClass(kualiDocumentFormBase.getDocTypeName()); |
1629 | 0 | if (LOG.isDebugEnabled()) { |
1630 | 0 | LOG.debug("PromptBeforeValidationClass: " + promptBeforeValidationClass); |
1631 | |
} |
1632 | 0 | if (promptBeforeValidationClass != null) { |
1633 | 0 | PromptBeforeValidation promptBeforeValidation = promptBeforeValidationClass.newInstance(); |
1634 | 0 | PromptBeforeValidationEvent event = new PromptBeforeValidationEvent("Pre Maint route Check", "", kualiDocumentFormBase.getDocument()); |
1635 | 0 | boolean continueRoute = promptBeforeValidation.processPrompts(form, request, event); |
1636 | 0 | if (!continueRoute) { |
1637 | 0 | if (event.isPerformQuestion()) { |
1638 | 0 | return super.performQuestionWithoutInput(mapping, kualiDocumentFormBase, request, response, event.getQuestionId(), event.getQuestionText(), event.getQuestionType(), methodToCall, event.getQuestionContext()); |
1639 | |
} |
1640 | |
else { |
1641 | |
|
1642 | |
|
1643 | |
|
1644 | |
|
1645 | |
|
1646 | |
|
1647 | |
|
1648 | 0 | ActionForward actionForward = mapping.findForward(event.getActionForwardName()); |
1649 | 0 | if (actionForward == null) { |
1650 | 0 | throw new RuntimeException("No ActionForwardName defined on this Event, no further actions will be processed."); |
1651 | |
} |
1652 | 0 | return actionForward; |
1653 | |
} |
1654 | |
} |
1655 | |
} |
1656 | |
|
1657 | 0 | return null; |
1658 | |
} |
1659 | |
|
1660 | |
|
1661 | |
|
1662 | |
|
1663 | |
|
1664 | |
|
1665 | |
|
1666 | |
|
1667 | |
protected DocumentAuthorizationException buildAuthorizationException(String action, Document document) { |
1668 | 0 | return new DocumentAuthorizationException(GlobalVariables.getUserSession().getPerson().getPrincipalName(), action, document.getDocumentNumber()); |
1669 | |
} |
1670 | |
|
1671 | |
protected boolean exitingDocument() { |
1672 | 0 | Boolean isMethodComplete = (Boolean) GlobalVariables.getUserSession().retrieveObject(DocumentAuthorizerBase.USER_SESSION_METHOD_TO_CALL_COMPLETE_OBJECT_KEY); |
1673 | 0 | return isMethodComplete != null && isMethodComplete; |
1674 | |
} |
1675 | |
|
1676 | |
protected void setupDocumentExit() { |
1677 | 0 | GlobalVariables.getUserSession().addObject(DocumentAuthorizerBase.USER_SESSION_METHOD_TO_CALL_COMPLETE_OBJECT_KEY,Boolean.TRUE); |
1678 | 0 | } |
1679 | |
|
1680 | |
|
1681 | |
|
1682 | |
|
1683 | |
|
1684 | |
|
1685 | |
|
1686 | |
|
1687 | |
protected ActionForward returnToSender(HttpServletRequest request, ActionMapping mapping, KualiDocumentFormBase form) { |
1688 | |
final ActionForward dest; |
1689 | 0 | if (form.isReturnToActionList()) { |
1690 | 0 | String workflowBase = getKualiConfigurationService().getPropertyString(KNSConstants.WORKFLOW_URL_KEY); |
1691 | 0 | String actionListUrl = workflowBase + "/ActionList.do"; |
1692 | |
|
1693 | 0 | dest = new ActionForward(actionListUrl, true); |
1694 | 0 | } |
1695 | 0 | else if(StringUtils.isNotBlank(form.getBackLocation())){ |
1696 | 0 | dest = new ActionForward(form.getBackLocation(), true); |
1697 | |
} else{ |
1698 | 0 | dest = mapping.findForward(KNSConstants.MAPPING_PORTAL); |
1699 | |
} |
1700 | |
|
1701 | 0 | setupDocumentExit(); |
1702 | 0 | return dest; |
1703 | |
} |
1704 | |
|
1705 | |
@SuppressWarnings("unchecked") |
1706 | |
protected void populateAuthorizationFields(KualiDocumentFormBase formBase){ |
1707 | 0 | if (formBase.isFormDocumentInitialized()) { |
1708 | 0 | Document document = formBase.getDocument(); |
1709 | 0 | Person user = GlobalVariables.getUserSession().getPerson(); |
1710 | 0 | DocumentPresentationController documentPresentationController = KNSServiceLocator.getDocumentHelperService().getDocumentPresentationController(document); |
1711 | 0 | DocumentAuthorizer documentAuthorizer = getDocumentHelperService().getDocumentAuthorizer(document); |
1712 | 0 | Set<String> documentActions = documentPresentationController.getDocumentActions(document); |
1713 | 0 | documentActions = documentAuthorizer.getDocumentActions(document, user, documentActions); |
1714 | |
|
1715 | 0 | if (getDataDictionaryService().getDataDictionary().getDocumentEntry(document.getClass().getName()).getUsePessimisticLocking()) { |
1716 | 0 | documentActions = getPessimisticLockService().getDocumentActions(document, user, documentActions); |
1717 | |
} |
1718 | |
|
1719 | |
|
1720 | 0 | formBase.setDocumentActions(convertSetToMap(documentActions)); |
1721 | |
|
1722 | |
} |
1723 | 0 | } |
1724 | |
|
1725 | |
protected void populateAdHocActionRequestCodes(KualiDocumentFormBase formBase){ |
1726 | 0 | Document document = formBase.getDocument(); |
1727 | 0 | DocumentAuthorizer documentAuthorizer = getDocumentHelperService().getDocumentAuthorizer(document); |
1728 | 0 | Map<String,String> adHocActionRequestCodes = new HashMap<String,String>(); |
1729 | |
|
1730 | 0 | if (documentAuthorizer.canSendAdHocRequests(document, KEWConstants.ACTION_REQUEST_FYI_REQ, GlobalVariables.getUserSession().getPerson())) { |
1731 | 0 | adHocActionRequestCodes.put(KEWConstants.ACTION_REQUEST_FYI_REQ, KEWConstants.ACTION_REQUEST_FYI_REQ_LABEL); |
1732 | |
} |
1733 | 0 | if (!document.getDocumentHeader().getWorkflowDocument().stateIsFinal() && documentAuthorizer.canSendAdHocRequests(document, KEWConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ, GlobalVariables.getUserSession().getPerson())) { |
1734 | 0 | adHocActionRequestCodes.put(KEWConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ, KEWConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ_LABEL); |
1735 | |
} |
1736 | 0 | if (!(document.getDocumentHeader().getWorkflowDocument().stateIsApproved() || document.getDocumentHeader().getWorkflowDocument().stateIsProcessed() || document.getDocumentHeader().getWorkflowDocument().stateIsFinal()) && documentAuthorizer.canSendAdHocRequests(document, KEWConstants.ACTION_REQUEST_APPROVE_REQ, GlobalVariables.getUserSession().getPerson())) { |
1737 | 0 | adHocActionRequestCodes.put(KEWConstants.ACTION_REQUEST_APPROVE_REQ, KEWConstants.ACTION_REQUEST_APPROVE_REQ_LABEL); |
1738 | |
} |
1739 | |
|
1740 | 0 | formBase.setAdHocActionRequestCodes(adHocActionRequestCodes); |
1741 | |
|
1742 | 0 | } |
1743 | |
|
1744 | |
|
1745 | |
@SuppressWarnings("unchecked") |
1746 | |
protected Map convertSetToMap(Set s){ |
1747 | 0 | Map map = new HashMap(); |
1748 | 0 | Iterator i = s.iterator(); |
1749 | 0 | while(i.hasNext()) { |
1750 | 0 | Object key = i.next(); |
1751 | 0 | map.put(key,KNSConstants.KUALI_DEFAULT_TRUE_VALUE); |
1752 | 0 | } |
1753 | 0 | return map; |
1754 | |
} |
1755 | |
|
1756 | |
|
1757 | |
|
1758 | |
|
1759 | |
protected DataDictionaryService getDataDictionaryService() { |
1760 | 0 | if ( dataDictionaryService == null ) { |
1761 | 0 | dataDictionaryService = KNSServiceLocator.getDataDictionaryService(); |
1762 | |
} |
1763 | 0 | return dataDictionaryService; |
1764 | |
} |
1765 | |
|
1766 | |
protected DocumentHelperService getDocumentHelperService() { |
1767 | 0 | if ( documentHelperService == null ) { |
1768 | 0 | documentHelperService = KNSServiceLocator.getDocumentHelperService(); |
1769 | |
} |
1770 | 0 | return this.documentHelperService; |
1771 | |
} |
1772 | |
|
1773 | |
protected DocumentService getDocumentService() { |
1774 | 0 | if ( documentService == null ) { |
1775 | 0 | documentService = KNSServiceLocator.getDocumentService(); |
1776 | |
} |
1777 | 0 | return this.documentService; |
1778 | |
} |
1779 | |
|
1780 | |
protected KualiConfigurationService getKualiConfigurationService() { |
1781 | 0 | if ( kualiConfigurationService == null ) { |
1782 | 0 | kualiConfigurationService = KNSServiceLocator.getKualiConfigurationService(); |
1783 | |
} |
1784 | 0 | return this.kualiConfigurationService; |
1785 | |
} |
1786 | |
|
1787 | |
protected ParameterService getParameterService() { |
1788 | 0 | if ( parameterService == null ) { |
1789 | 0 | parameterService = KNSServiceLocator.getParameterService(); |
1790 | |
} |
1791 | 0 | return this.parameterService; |
1792 | |
} |
1793 | |
|
1794 | |
protected PessimisticLockService getPessimisticLockService() { |
1795 | 0 | if ( pessimisticLockService == null ) { |
1796 | 0 | pessimisticLockService = KNSServiceLocator.getPessimisticLockService(); |
1797 | |
} |
1798 | 0 | return this.pessimisticLockService; |
1799 | |
} |
1800 | |
|
1801 | |
protected KualiRuleService getKualiRuleService() { |
1802 | 0 | if ( kualiRuleService == null ) { |
1803 | 0 | kualiRuleService = KNSServiceLocator.getKualiRuleService(); |
1804 | |
} |
1805 | 0 | return this.kualiRuleService; |
1806 | |
} |
1807 | |
|
1808 | |
protected IdentityManagementService getIdentityManagementService() { |
1809 | 0 | if ( identityManagementService == null ) { |
1810 | 0 | identityManagementService = KIMServiceLocator.getIdentityManagementService(); |
1811 | |
} |
1812 | 0 | return this.identityManagementService; |
1813 | |
} |
1814 | |
|
1815 | |
protected AttachmentService getAttachmentService() { |
1816 | 0 | if ( attachmentService == null ) { |
1817 | 0 | attachmentService = KNSServiceLocator.getAttachmentService(); |
1818 | |
} |
1819 | 0 | return this.attachmentService; |
1820 | |
} |
1821 | |
|
1822 | |
protected NoteService getNoteService() { |
1823 | 0 | if ( noteService == null ) { |
1824 | 0 | noteService = KNSServiceLocator.getNoteService(); |
1825 | |
} |
1826 | 0 | return this.noteService; |
1827 | |
} |
1828 | |
|
1829 | |
protected BusinessObjectService getBusinessObjectService() { |
1830 | 0 | if ( businessObjectService == null ) { |
1831 | 0 | businessObjectService = KNSServiceLocator.getBusinessObjectService(); |
1832 | |
} |
1833 | 0 | return this.businessObjectService; |
1834 | |
} |
1835 | |
|
1836 | |
protected BusinessObjectAuthorizationService getBusinessObjectAuthorizationService() { |
1837 | 0 | if ( businessObjectAuthorizationService == null ) { |
1838 | 0 | businessObjectAuthorizationService = KNSServiceLocator.getBusinessObjectAuthorizationService(); |
1839 | |
} |
1840 | 0 | return businessObjectAuthorizationService; |
1841 | |
} |
1842 | |
|
1843 | |
public BusinessObjectMetaDataService getBusinessObjectMetaDataService() { |
1844 | 0 | if ( businessObjectMetaDataService == null ) { |
1845 | 0 | businessObjectMetaDataService = KNSServiceLocator.getBusinessObjectMetaDataService(); |
1846 | |
} |
1847 | 0 | return this.businessObjectMetaDataService; |
1848 | |
} |
1849 | |
|
1850 | |
public EntityManagerFactory getEntityManagerFactory() { |
1851 | 0 | if ( entityManagerFactory == null ) { |
1852 | 0 | entityManagerFactory = KNSServiceLocator.getEntityManagerFactory(); |
1853 | |
} |
1854 | 0 | return this.entityManagerFactory; |
1855 | |
} |
1856 | |
|
1857 | |
|
1858 | |
|
1859 | |
|
1860 | |
@Override |
1861 | |
public ActionForward hideAllTabs(ActionMapping mapping, ActionForm form, |
1862 | |
HttpServletRequest request, HttpServletResponse response) |
1863 | |
throws Exception { |
1864 | 0 | if (form instanceof KualiDocumentFormBase) { |
1865 | 0 | WebUtils.reuseErrorMapFromPreviousRequest((KualiDocumentFormBase) form); |
1866 | |
} |
1867 | 0 | return super.hideAllTabs(mapping, form, request, response); |
1868 | |
} |
1869 | |
|
1870 | |
|
1871 | |
|
1872 | |
|
1873 | |
@Override |
1874 | |
public ActionForward showAllTabs(ActionMapping mapping, ActionForm form, |
1875 | |
HttpServletRequest request, HttpServletResponse response) |
1876 | |
throws Exception { |
1877 | 0 | if (form instanceof KualiDocumentFormBase) { |
1878 | 0 | WebUtils.reuseErrorMapFromPreviousRequest((KualiDocumentFormBase) form); |
1879 | |
} |
1880 | 0 | return super.showAllTabs(mapping, form, request, response); |
1881 | |
} |
1882 | |
|
1883 | |
|
1884 | |
|
1885 | |
|
1886 | |
@Override |
1887 | |
public ActionForward toggleTab(ActionMapping mapping, ActionForm form, |
1888 | |
HttpServletRequest request, HttpServletResponse response) |
1889 | |
throws Exception { |
1890 | 0 | if (form instanceof KualiDocumentFormBase) { |
1891 | 0 | WebUtils.reuseErrorMapFromPreviousRequest((KualiDocumentFormBase) form); |
1892 | |
} |
1893 | 0 | return super.toggleTab(mapping, form, request, response); |
1894 | |
} |
1895 | |
|
1896 | |
protected void doProcessingAfterPost( KualiForm form, HttpServletRequest request ) { |
1897 | 0 | super.doProcessingAfterPost(form, request); |
1898 | 0 | if ( form instanceof KualiDocumentFormBase ) { |
1899 | 0 | Document document = ((KualiDocumentFormBase)form).getDocument(); |
1900 | |
|
1901 | 0 | getBusinessObjectService().linkUserFields(document); |
1902 | |
} |
1903 | 0 | } |
1904 | |
} |
1905 | |
|