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