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.beanutils.PropertyUtils;
19 import org.apache.commons.collections.CollectionUtils;
20 import org.apache.commons.lang.StringUtils;
21 import org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException;
22 import org.apache.struts.action.ActionForm;
23 import org.apache.struts.action.ActionForward;
24 import org.apache.struts.action.ActionMapping;
25 import org.apache.struts.upload.FormFile;
26 import org.kuali.rice.core.api.CoreApiServiceLocator;
27 import org.kuali.rice.core.api.encryption.EncryptionService;
28 import org.kuali.rice.core.api.util.ClassLoaderUtils;
29 import org.kuali.rice.core.api.util.RiceConstants;
30 import org.kuali.rice.core.api.util.RiceKeyConstants;
31 import org.kuali.rice.core.web.format.Formatter;
32 import org.kuali.rice.kew.api.KewApiConstants;
33 import org.kuali.rice.kim.api.identity.Person;
34 import org.kuali.rice.kns.datadictionary.MaintainableCollectionDefinition;
35 import org.kuali.rice.kns.datadictionary.MaintenanceDocumentEntry;
36 import org.kuali.rice.kns.document.MaintenanceDocument;
37 import org.kuali.rice.kns.document.MaintenanceDocumentBase;
38 import org.kuali.rice.kns.document.authorization.MaintenanceDocumentAuthorizer;
39 import org.kuali.rice.kns.document.authorization.MaintenanceDocumentRestrictions;
40 import org.kuali.rice.kns.lookup.LookupResultsService;
41 import org.kuali.rice.kns.maintenance.Maintainable;
42 import org.kuali.rice.kns.rule.event.KualiAddLineEvent;
43 import org.kuali.rice.kns.service.KNSServiceLocator;
44 import org.kuali.rice.kns.service.MaintenanceDocumentDictionaryService;
45 import org.kuali.rice.kns.util.KNSGlobalVariables;
46 import org.kuali.rice.kns.util.MaintenanceUtils;
47 import org.kuali.rice.kns.util.WebUtils;
48 import org.kuali.rice.kns.web.struts.form.InquiryForm;
49 import org.kuali.rice.kns.web.struts.form.KualiDocumentFormBase;
50 import org.kuali.rice.kns.web.struts.form.KualiForm;
51 import org.kuali.rice.kns.web.struts.form.KualiMaintenanceForm;
52 import org.kuali.rice.kns.web.ui.Field;
53 import org.kuali.rice.kns.web.ui.Row;
54 import org.kuali.rice.kns.web.ui.Section;
55 import org.kuali.rice.krad.bo.DocumentAttachment;
56 import org.kuali.rice.krad.bo.MultiDocumentAttachment;
57 import org.kuali.rice.krad.bo.PersistableAttachment;
58 import org.kuali.rice.krad.bo.PersistableAttachmentList;
59 import org.kuali.rice.krad.bo.PersistableBusinessObject;
60 import org.kuali.rice.krad.exception.DocumentTypeAuthorizationException;
61 import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
62 import org.kuali.rice.krad.service.LookupService;
63 import org.kuali.rice.krad.util.GlobalVariables;
64 import org.kuali.rice.krad.util.KRADConstants;
65 import org.kuali.rice.krad.util.KRADPropertyConstants;
66 import org.kuali.rice.krad.util.ObjectUtils;
67
68 import javax.servlet.http.HttpServletRequest;
69 import javax.servlet.http.HttpServletResponse;
70 import java.lang.reflect.InvocationTargetException;
71 import java.lang.reflect.Method;
72 import java.security.GeneralSecurityException;
73 import java.util.ArrayList;
74 import java.util.Collection;
75 import java.util.Enumeration;
76 import java.util.HashMap;
77 import java.util.Iterator;
78 import java.util.List;
79 import java.util.Map;
80
81
82
83
84 public class KualiMaintenanceDocumentAction extends KualiDocumentActionBase {
85 protected static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(KualiMaintenanceDocumentAction.class);
86
87 protected MaintenanceDocumentDictionaryService maintenanceDocumentDictionaryService = null;
88 protected EncryptionService encryptionService;
89 protected LookupService lookupService;
90 protected LookupResultsService lookupResultsService;
91
92 public KualiMaintenanceDocumentAction() {
93 super();
94 maintenanceDocumentDictionaryService = KNSServiceLocator.getMaintenanceDocumentDictionaryService();
95 encryptionService = CoreApiServiceLocator.getEncryptionService();
96 }
97
98 @Override
99 public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
100 request.setAttribute(KRADConstants.PARAM_MAINTENANCE_VIEW_MODE, KRADConstants.PARAM_MAINTENANCE_VIEW_MODE_MAINTENANCE);
101 return super.execute(mapping, form, request, response);
102 }
103
104
105
106
107 public ActionForward start(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
108 request.setAttribute(KRADConstants.MAINTENANCE_ACTN, KRADConstants.MAINTENANCE_NEW_ACTION);
109 return setupMaintenance(mapping, form, request, response, KRADConstants.MAINTENANCE_NEW_ACTION);
110 }
111
112
113
114
115 public ActionForward copy(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
116
117 if (request.getParameter("document." + KRADPropertyConstants.DOCUMENT_NUMBER) == null) {
118 return setupMaintenance(mapping, form, request, response, KRADConstants.MAINTENANCE_COPY_ACTION);
119 }
120 else {
121 throw new UnsupportedOperationException("System does not support copying of maintenance documents.");
122 }
123 }
124
125
126
127
128 public ActionForward edit(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
129
130 return setupMaintenance(mapping, form, request, response, KRADConstants.MAINTENANCE_EDIT_ACTION);
131 }
132
133
134
135
136 public ActionForward delete(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
137 if (isFormRepresentingLockObject((KualiDocumentFormBase)form)) {
138 return super.delete(mapping, form, request, response);
139 }
140 KNSGlobalVariables.getMessageList().add(RiceKeyConstants.MESSAGE_DELETE);
141 return setupMaintenance(mapping, form, request, response, KRADConstants.MAINTENANCE_DELETE_ACTION);
142 }
143
144
145
146
147 public ActionForward newWithExisting(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
148 return setupMaintenance(mapping, form, request, response, KRADConstants.MAINTENANCE_NEWWITHEXISTING_ACTION);
149 }
150
151
152
153
154
155
156
157 protected ActionForward setupMaintenance(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response, String maintenanceAction) throws Exception {
158 KualiMaintenanceForm maintenanceForm = (KualiMaintenanceForm) form;
159 MaintenanceDocument document = null;
160
161
162 if (maintenanceForm.getDocument() == null) {
163 if (StringUtils.isEmpty(maintenanceForm.getBusinessObjectClassName()) && StringUtils.isEmpty(maintenanceForm.getDocTypeName())) {
164 throw new IllegalArgumentException("Document type name or bo class not given!");
165 }
166
167 String documentTypeName = maintenanceForm.getDocTypeName();
168
169 if (StringUtils.isEmpty(documentTypeName)) {
170 documentTypeName = maintenanceDocumentDictionaryService.getDocumentTypeName(Class.forName(maintenanceForm.getBusinessObjectClassName()));
171 maintenanceForm.setDocTypeName(documentTypeName);
172 }
173
174 if (StringUtils.isEmpty(documentTypeName)) {
175 throw new RuntimeException("documentTypeName is empty; does this Business Object have a maintenance document definition? " + maintenanceForm.getBusinessObjectClassName());
176 }
177
178
179 if (KRADConstants.MAINTENANCE_NEW_ACTION.equals(maintenanceAction) || KRADConstants.MAINTENANCE_COPY_ACTION.equals(maintenanceAction)) {
180 Class boClass = maintenanceDocumentDictionaryService.getDataObjectClass(documentTypeName);
181 boolean allowsNewOrCopy = getBusinessObjectAuthorizationService().canCreate(boClass, GlobalVariables.getUserSession().getPerson(), documentTypeName);
182 if (!allowsNewOrCopy) {
183 LOG.error("Document type " + documentTypeName + " does not allow new or copy actions.");
184 throw new DocumentTypeAuthorizationException(GlobalVariables.getUserSession().getPerson().getPrincipalId(), "newOrCopy", documentTypeName);
185 }
186 }
187
188
189 document = (MaintenanceDocument) getDocumentService().getNewDocument(maintenanceForm.getDocTypeName());
190
191
192
193
194
195
196
197
198
199 maintenanceForm.setDocument(document);
200 }
201 else {
202 document = (MaintenanceDocument) maintenanceForm.getDocument();
203 }
204
205
206 if (!(KRADConstants.MAINTENANCE_NEW_ACTION.equals(maintenanceAction))
207 && !(KRADConstants.MAINTENANCE_NEWWITHEXISTING_ACTION.equals(maintenanceAction))) {
208 Map requestParameters = buildKeyMapFromRequest(document.getNewMaintainableObject(), request);
209 PersistableBusinessObject oldBusinessObject = null;
210 try {
211 oldBusinessObject = (PersistableBusinessObject) getLookupService().findObjectBySearch(Class.forName(maintenanceForm.getBusinessObjectClassName()), requestParameters);
212 } catch ( ClassNotPersistenceCapableException ex ) {
213 if ( !document.getOldMaintainableObject().isExternalBusinessObject() ) {
214 throw new RuntimeException( "BO Class: " + maintenanceForm.getBusinessObjectClassName() + " is not persistable and is not externalizable - configuration error" );
215 }
216
217 }
218 if (oldBusinessObject == null && !document.getOldMaintainableObject().isExternalBusinessObject()) {
219 throw new RuntimeException("Cannot retrieve old record for maintenance document, incorrect parameters passed on maint url: " + requestParameters );
220 }
221
222 if(document.getOldMaintainableObject().isExternalBusinessObject()){
223 if ( oldBusinessObject == null ) {
224 try {
225 oldBusinessObject = (PersistableBusinessObject)document.getOldMaintainableObject().getBoClass().newInstance();
226 } catch ( Exception ex ) {
227 throw new RuntimeException( "External BO maintainable was null and unable to instantiate for old maintainable object.", ex );
228 }
229 }
230 populateBOWithCopyKeyValues(request, oldBusinessObject, document.getOldMaintainableObject());
231 document.getOldMaintainableObject().prepareBusinessObject(oldBusinessObject);
232 oldBusinessObject = document.getOldMaintainableObject().getBusinessObject();
233 }
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260 PersistableBusinessObject newBusinessObject = (PersistableBusinessObject) ObjectUtils.deepCopy(oldBusinessObject);
261
262
263 Class<? extends PersistableBusinessObject> businessObjectClass = ClassLoaderUtils.getClass(maintenanceForm.getBusinessObjectClassName(), PersistableBusinessObject.class);
264 document.getOldMaintainableObject().setBusinessObject(oldBusinessObject);
265 document.getOldMaintainableObject().setBoClass(businessObjectClass);
266 document.getNewMaintainableObject().setBusinessObject(newBusinessObject);
267 document.getNewMaintainableObject().setBoClass(businessObjectClass);
268
269
270
271
272 if (KRADConstants.MAINTENANCE_COPY_ACTION.equals(maintenanceAction)) {
273 if (!document.isFieldsClearedOnCopy()) {
274
275 Class boClass = maintenanceDocumentDictionaryService.getDataObjectClass(
276 maintenanceForm.getDocTypeName());
277 if (!maintenanceDocumentDictionaryService.getPreserveLockingKeysOnCopy(boClass)) {
278 clearPrimaryKeyFields(document);
279 }
280
281 clearUnauthorizedNewFields(document);
282
283 Maintainable maintainable = document.getNewMaintainableObject();
284
285 maintainable.processAfterCopy( document, request.getParameterMap() );
286
287
288 document.setFieldsClearedOnCopy(true);
289
290
291 maintainable.setGenerateBlankRequiredValues(maintenanceForm.getDocTypeName());
292 }
293 }
294 else if (KRADConstants.MAINTENANCE_EDIT_ACTION.equals(maintenanceAction)) {
295 boolean allowsEdit = getBusinessObjectAuthorizationService().canMaintain(oldBusinessObject, GlobalVariables.getUserSession().getPerson(), document.getDocumentHeader().getWorkflowDocument().getDocumentTypeName());
296 if (!allowsEdit) {
297 LOG.error("Document type " + document.getDocumentHeader().getWorkflowDocument().getDocumentTypeName() + " does not allow edit actions.");
298 throw new DocumentTypeAuthorizationException(GlobalVariables.getUserSession().getPerson().getPrincipalId(), "edit", document.getDocumentHeader().getWorkflowDocument().getDocumentTypeName());
299 }
300 document.getNewMaintainableObject().processAfterEdit( document, request.getParameterMap() );
301 }
302
303 else if (KRADConstants.MAINTENANCE_DELETE_ACTION.equals(maintenanceAction)) {
304 boolean allowsDelete = getBusinessObjectAuthorizationService().canMaintain(oldBusinessObject, GlobalVariables.getUserSession().getPerson(), document.getDocumentHeader().getWorkflowDocument().getDocumentTypeName());
305 if (!allowsDelete) {
306 LOG.error("Document type " + document.getDocumentHeader().getWorkflowDocument().getDocumentTypeName() + " does not allow delete actions.");
307 throw new DocumentTypeAuthorizationException(GlobalVariables.getUserSession().getPerson().getPrincipalId(), "delete", document.getDocumentHeader().getWorkflowDocument().getDocumentTypeName());
308 }
309
310 }
311
312
313
314
315
316
317
318 }
319
320 if (KRADConstants.MAINTENANCE_NEWWITHEXISTING_ACTION.equals(maintenanceAction)) {
321
322
323
324 PersistableBusinessObject newBO = document.getNewMaintainableObject().getBusinessObject();
325 Map<String, String> parameters = buildKeyMapFromRequest(document.getNewMaintainableObject(), request);
326 copyParametersToBO(parameters, newBO);
327 newBO.refresh();
328 document.getNewMaintainableObject().setupNewFromExisting( document, request.getParameterMap() );
329 }
330
331
332 if (KRADConstants.MAINTENANCE_NEW_ACTION.equals(maintenanceAction)) {
333 document.getNewMaintainableObject().setGenerateDefaultValues(maintenanceForm.getDocTypeName());
334 document.getNewMaintainableObject().processAfterNew( document, request.getParameterMap() );
335
336
337 MaintenanceUtils.checkForLockingDocument(document.getNewMaintainableObject(), false);
338 }
339
340
341 document.getNewMaintainableObject().setMaintenanceAction(maintenanceAction);
342 maintenanceForm.setMaintenanceAction(maintenanceAction);
343
344
345 MaintenanceDocumentEntry entry = maintenanceDocumentDictionaryService.getMaintenanceDocumentEntry(document.getDocumentHeader().getWorkflowDocument().getDocumentTypeName());
346 if (LOG.isDebugEnabled()) {
347 LOG.debug("maintenanceForm.getAdditionalScriptFiles(): " + maintenanceForm.getAdditionalScriptFiles());
348 }
349 if (maintenanceForm.getAdditionalScriptFiles().isEmpty()) {
350 maintenanceForm.getAdditionalScriptFiles().addAll(entry.getWebScriptFiles());
351 }
352
353
354 document.setDisplayTopicFieldInNotes(entry.getDisplayTopicFieldInNotes());
355
356 return mapping.findForward(RiceConstants.MAPPING_BASIC);
357 }
358
359 protected void populateBOWithCopyKeyValues(HttpServletRequest request, PersistableBusinessObject oldBusinessObject, Maintainable oldMaintainableObject) throws Exception{
360 List keyFieldNamesToCopy = new ArrayList();
361 Map<String, String> parametersToCopy;
362 if (!StringUtils.isBlank(request.getParameter(KRADConstants.COPY_KEYS))) {
363 String[] copyKeys = request.getParameter(KRADConstants.COPY_KEYS).split(KRADConstants.FIELD_CONVERSIONS_SEPARATOR);
364 for (String copyKey: copyKeys) {
365 keyFieldNamesToCopy.add(copyKey);
366 }
367 }
368 parametersToCopy = getRequestParameters(keyFieldNamesToCopy, oldMaintainableObject, request);
369 if(parametersToCopy!=null && parametersToCopy.size()>0){
370 copyParametersToBO(parametersToCopy, oldBusinessObject);
371 }
372 }
373
374 protected void copyParametersToBO(Map<String, String> parameters, PersistableBusinessObject newBO) throws Exception{
375 for (String parmName : parameters.keySet()) {
376 String propertyValue = parameters.get(parmName);
377
378 if (StringUtils.isNotBlank(propertyValue)) {
379 String propertyName = parmName;
380
381 if (PropertyUtils.isWriteable(newBO, propertyName)) {
382 Class type = ObjectUtils.easyGetPropertyType(newBO, propertyName);
383 if (type != null && Formatter.getFormatter(type) != null) {
384 Formatter formatter = Formatter.getFormatter(type);
385 Object obj = formatter.convertFromPresentationFormat(propertyValue);
386 ObjectUtils.setObjectProperty(newBO, propertyName, obj.getClass(), obj);
387 }
388 else {
389 ObjectUtils.setObjectProperty(newBO, propertyName, String.class, propertyValue);
390 }
391 }
392 }
393 }
394 }
395
396
397
398
399
400
401
402
403
404
405
406 public ActionForward downloadAttachment(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
407 KualiDocumentFormBase documentForm = (KualiDocumentFormBase) form;
408 MaintenanceDocumentBase document = (MaintenanceDocumentBase) documentForm.getDocument();
409
410 int line = getSelectedLine(request);
411 if (line < 0) {
412 DocumentAttachment documentAttachment = document.getAttachment();
413 if (documentAttachment != null
414 && documentAttachment.getAttachmentContent() != null) {
415
416 streamToResponse(documentAttachment.getAttachmentContent(), documentAttachment.getFileName(), documentAttachment.getContentType(), response);
417 return null;
418 }
419 PersistableAttachment attachment = (PersistableAttachment) document.getNewMaintainableObject().getBusinessObject();
420 String attachmentPropNm = document.getAttachmentPropertyName();
421 FormFile attachmentFromBusinessObject = null;
422 byte[] attachmentContent;
423 String fileName = attachment.getFileName();
424 String contentType = attachment.getContentType();
425 if (StringUtils.isNotBlank(attachmentPropNm)) {
426 String attachmentPropNmSetter = "get" + attachmentPropNm.substring(0, 1).toUpperCase() + attachmentPropNm.substring(1, attachmentPropNm.length());
427 attachmentFromBusinessObject = (FormFile)(attachment.getClass().getDeclaredMethod(attachmentPropNmSetter).invoke(attachment));
428 }
429 if (attachmentFromBusinessObject != null
430 && attachmentFromBusinessObject.getInputStream() != null) {
431 attachmentContent = attachmentFromBusinessObject.getFileData();
432 fileName = attachmentFromBusinessObject.getFileName();
433 contentType = attachmentFromBusinessObject.getContentType();
434 } else {
435 attachmentContent = attachment.getAttachmentContent();
436 }
437 if (StringUtils.isNotBlank(fileName)
438 && contentType != null
439 && attachmentContent != null) {
440 streamToResponse(attachmentContent, fileName, contentType, response);
441 }
442 } else {
443
444
445 PersistableAttachmentList<PersistableAttachment> attachmentsBo = (PersistableAttachmentList<PersistableAttachment>) document.getNewMaintainableObject().getBusinessObject();
446 if (CollectionUtils.isEmpty(attachmentsBo.getAttachments())) {
447 document.populateAttachmentListForBO();
448 }
449
450 List<? extends PersistableAttachment> attachments = attachmentsBo.getAttachments();
451 if (CollectionUtils.isNotEmpty(attachments)
452 && attachments.size() > line) {
453 PersistableAttachment attachment = attachmentsBo.getAttachments().get(line);
454
455
456
457 byte[] attachmentContent;
458 String fileName = attachment.getFileName();
459 String contentType = attachment.getContentType();
460 String attachmentPropNm = document.getAttachmentListPropertyName();
461 FormFile attachmentFromBusinessObject = null;
462 if (StringUtils.isNotBlank(attachmentPropNm)) {
463 String attachmentPropNmSetter = "get" + attachmentPropNm.substring(0, 1).toUpperCase() + attachmentPropNm.substring(1, attachmentPropNm.length());
464 attachmentFromBusinessObject = (FormFile)(attachment.getClass().getDeclaredMethod(attachmentPropNmSetter).invoke(attachment));
465 }
466
467
468
469 if (attachmentFromBusinessObject != null
470 && attachmentFromBusinessObject.getInputStream() != null) {
471 attachmentContent = attachmentFromBusinessObject.getFileData();
472 fileName = attachmentFromBusinessObject.getFileName();
473 contentType = attachmentFromBusinessObject.getContentType();
474 } else {
475 attachmentContent = attachment.getAttachmentContent();
476 }
477
478 if (attachmentContent != null) {
479 streamToResponse(attachmentContent, fileName, contentType, response);
480 } else {
481
482
483 List<MultiDocumentAttachment> multiDocumentAttachs = document.getAttachments();
484 if (CollectionUtils.isNotEmpty(multiDocumentAttachs)) {
485 for (MultiDocumentAttachment multiAttach : multiDocumentAttachs) {
486 if (multiAttach.getFileName().equals(fileName)
487 && multiAttach.getContentType().equals(contentType)) {
488 streamToResponse(multiAttach.getAttachmentContent(), multiAttach.getFileName(), multiAttach.getContentType(), response);
489 break;
490 }
491 }
492 }
493 }
494 }
495 }
496 return null;
497 }
498
499
500
501
502
503
504
505
506
507
508
509
510 public ActionForward replaceAttachment(ActionMapping mapping, ActionForm form, HttpServletRequest request,
511 HttpServletResponse response) throws Exception {
512 KualiDocumentFormBase documentForm = (KualiDocumentFormBase) form;
513 MaintenanceDocumentBase document = (MaintenanceDocumentBase) documentForm.getDocument();
514
515 int lineNum = getSelectedLine(request);
516
517 if (lineNum < 0) {
518
519 document.refreshReferenceObject("attachment");
520 documentForm.setAttachmentFile(null);
521 document.setFileAttachment(null);
522 getBusinessObjectService().delete(document.getAttachment());
523 document.setAttachment(null);
524
525 PersistableAttachment attachment = (PersistableAttachment) document.getNewMaintainableObject().getBusinessObject();
526
527 attachment.setAttachmentContent(null);
528 attachment.setContentType(null);
529 attachment.setFileName(null);
530
531
532 String attachmentPropNm = document.getAttachmentPropertyName();
533 String attachmentPropNmSetter = "set" + attachmentPropNm.substring(0, 1).toUpperCase() + attachmentPropNm.substring(1, attachmentPropNm.length());
534 Class propNameSetterSig = null;
535
536 try {
537 Method[] methods = attachment.getClass().getMethods();
538 for (Method method : methods) {
539 if (method.getName().equals(attachmentPropNmSetter)) {
540 propNameSetterSig = method.getParameterTypes()[0];
541 attachment.getClass().getDeclaredMethod(attachmentPropNmSetter, propNameSetterSig).invoke(attachment, (Object) null);
542 break;
543 }
544 }
545 } catch (Exception e) {
546 LOG.error("Not able to get the attachment " + e.getMessage());
547 throw new RuntimeException(
548 "Not able to get the attachment " + e.getMessage());
549 }
550 } else {
551 document.refreshReferenceObject("attachments");
552 getBusinessObjectService().delete(document.getAttachment());
553
554 PersistableAttachmentList<PersistableAttachment> attachmentListBo = (PersistableAttachmentList<PersistableAttachment>) document.getNewMaintainableObject().getBusinessObject();
555
556 PersistableAttachment attachment = (PersistableAttachment)attachmentListBo.getAttachments().get(lineNum);
557 attachment.setAttachmentContent(null);
558 attachment.setContentType(null);
559 attachment.setFileName(null);
560
561 String attachmentPropNm = document.getAttachmentListPropertyName();
562 String attachmentPropNmSetter = "set" + attachmentPropNm.substring(0, 1).toUpperCase() + attachmentPropNm.substring(1, attachmentPropNm.length());
563 Class propNameSetterSig = null;
564
565 try {
566 Method[] methods = attachment.getClass().getMethods();
567 for (Method method : methods) {
568 if (method.getName().equals(attachmentPropNmSetter)) {
569 propNameSetterSig = method.getParameterTypes()[0];
570 attachment.getClass().getDeclaredMethod(attachmentPropNmSetter, propNameSetterSig).invoke(attachment, (Object) null);
571 break;
572 }
573 }
574 } catch (Exception e) {
575 LOG.error("Not able to get the attachment " + e.getMessage());
576 throw new RuntimeException(
577 "Not able to get the attachment " + e.getMessage());
578 }
579 }
580
581 return mapping.findForward(RiceConstants.MAPPING_BASIC);
582 }
583
584
585
586
587
588
589
590
591
592
593
594 @Override
595 public ActionForward route(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
596 KualiDocumentFormBase documentForm = (KualiDocumentFormBase) form;
597 MaintenanceDocumentBase document = (MaintenanceDocumentBase) documentForm.getDocument();
598
599 ActionForward forward = super.route(mapping, form, request, response);
600 PersistableBusinessObject businessObject = document.getNewMaintainableObject().getBusinessObject();
601 if(businessObject instanceof PersistableAttachment) {
602 document.populateAttachmentForBO();
603 String fileName = ((PersistableAttachment) businessObject).getFileName();
604 if(StringUtils.isEmpty(fileName)) {
605 PersistableAttachment existingBO = (PersistableAttachment) getBusinessObjectService().retrieve(document.getNewMaintainableObject().getBusinessObject());
606 if (existingBO == null) {
607 if (document.getAttachment() != null) {
608 fileName = document.getAttachment().getFileName();
609 } else {
610 fileName = "";
611 }
612 } else {
613 fileName = (existingBO != null ? existingBO.getFileName() : "");
614 }
615 request.setAttribute("fileName", fileName);
616 }
617 }
618 return forward;
619 }
620
621
622
623
624 @Override
625 public ActionForward docHandler(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
626 ActionForward af = super.docHandler(mapping, form, request, response);
627 if (af.getName().equals(KRADConstants.KRAD_INITIATED_DOCUMENT_VIEW_NAME))
628 {
629 return af;
630 }
631 KualiMaintenanceForm kualiMaintenanceForm = (KualiMaintenanceForm) form;
632
633 if (KewApiConstants.ACTIONLIST_COMMAND.equals(kualiMaintenanceForm.getCommand()) || KewApiConstants.DOCSEARCH_COMMAND.equals(kualiMaintenanceForm.getCommand()) || KewApiConstants.SUPERUSER_COMMAND.equals(kualiMaintenanceForm.getCommand()) || KewApiConstants.HELPDESK_ACTIONLIST_COMMAND.equals(kualiMaintenanceForm.getCommand()) && kualiMaintenanceForm.getDocId() != null) {
634 if (kualiMaintenanceForm.getDocument() instanceof MaintenanceDocument) {
635 kualiMaintenanceForm.setReadOnly(true);
636 kualiMaintenanceForm.setMaintenanceAction(((MaintenanceDocument) kualiMaintenanceForm.getDocument()).getNewMaintainableObject().getMaintenanceAction());
637
638
639 Maintainable tmpMaintainable = ((MaintenanceDocument) kualiMaintenanceForm.getDocument()).getNewMaintainableObject();
640 if(tmpMaintainable.getBusinessObject() instanceof PersistableAttachment) {
641 PersistableAttachment bo = (PersistableAttachment) getBusinessObjectService().retrieve(tmpMaintainable.getBusinessObject());
642 if (bo != null) {
643 request.setAttribute("fileName", bo.getFileName());
644 }
645 }
646 }
647 else {
648 LOG.error("Illegal State: document is not a maintenance document");
649 throw new IllegalStateException("Document is not a maintenance document");
650 }
651 }
652 else if (KewApiConstants.INITIATE_COMMAND.equals(kualiMaintenanceForm.getCommand())) {
653 kualiMaintenanceForm.setReadOnly(false);
654 return setupMaintenance(mapping, form, request, response, KRADConstants.MAINTENANCE_NEW_ACTION);
655 }
656 else {
657 LOG.error("We should never have gotten to here");
658 throw new IllegalStateException("docHandler called with invalid parameters");
659 }
660 return mapping.findForward(RiceConstants.MAPPING_BASIC);
661 }
662
663
664
665
666 @Override
667 public ActionForward refresh(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
668 KualiMaintenanceForm maintenanceForm = (KualiMaintenanceForm) form;
669
670 WebUtils.reuseErrorMapFromPreviousRequest(maintenanceForm);
671 maintenanceForm.setDerivedValuesOnForm(request);
672
673 refreshAdHocRoutingWorkgroupLookups(request, maintenanceForm);
674 MaintenanceDocument document = (MaintenanceDocument) maintenanceForm.getDocument();
675
676
677 Map<String, String> requestParams = new HashMap<String, String>();
678 for (Enumeration i = request.getParameterNames(); i.hasMoreElements();) {
679 String requestKey = (String) i.nextElement();
680 String requestValue = request.getParameter(requestKey);
681 requestParams.put(requestKey, requestValue);
682 }
683
684
685 Collection<PersistableBusinessObject> rawValues = null;
686 if (StringUtils.equals(KRADConstants.MULTIPLE_VALUE, maintenanceForm.getRefreshCaller())) {
687 String lookupResultsSequenceNumber = maintenanceForm.getLookupResultsSequenceNumber();
688 if (StringUtils.isNotBlank(lookupResultsSequenceNumber)) {
689
690 String lookupResultsBOClassName = maintenanceForm.getLookupResultsBOClassName();
691 Class lookupResultsBOClass = Class.forName(lookupResultsBOClassName);
692
693 rawValues = getLookupResultsService().retrieveSelectedResultBOs(lookupResultsSequenceNumber, lookupResultsBOClass, GlobalVariables.getUserSession().getPerson().getPrincipalId());
694 }
695 }
696
697 if (rawValues != null) {
698
699
700
701
702 String collectionName = maintenanceForm.getLookedUpCollectionName();
703
704
705
706
707
708
709
710
711
712
713
714
715
716 document.getNewMaintainableObject().addMultipleValueLookupResults(document, collectionName, rawValues, false, document.getNewMaintainableObject().getBusinessObject());
717 if (LOG.isInfoEnabled()) {
718 LOG.info("********************doing editing 3 in refersh()***********************.");
719 }
720 boolean isEdit = KRADConstants.MAINTENANCE_EDIT_ACTION.equals(maintenanceForm.getMaintenanceAction());
721 boolean isCopy = KRADConstants.MAINTENANCE_COPY_ACTION.equals(maintenanceForm.getMaintenanceAction());
722
723 if (isEdit || isCopy) {
724 document.getOldMaintainableObject().addMultipleValueLookupResults(document, collectionName, rawValues, true, document.getOldMaintainableObject().getBusinessObject());
725 document.getOldMaintainableObject().refresh(maintenanceForm.getRefreshCaller(), requestParams, document);
726 }
727 }
728
729 document.getNewMaintainableObject().refresh(maintenanceForm.getRefreshCaller(), requestParams, document);
730
731
732 String fullParameter = (String) request.getAttribute(KRADConstants.METHOD_TO_CALL_ATTRIBUTE);
733 if(StringUtils.contains(fullParameter, KRADConstants.CUSTOM_ACTION)){
734 String customAction = StringUtils.substringBetween(fullParameter, KRADConstants.METHOD_TO_CALL_PARM1_LEFT_DEL, KRADConstants.METHOD_TO_CALL_PARM1_RIGHT_DEL);
735 String[] actionValue = new String[1];
736 actionValue[0]= StringUtils.substringAfter(customAction, ".");
737 Map<String,String[]> paramMap = new HashMap<String,String[]>(request.getParameterMap());
738 paramMap.put(KRADConstants.CUSTOM_ACTION, actionValue);
739 doProcessingAfterPost( (KualiMaintenanceForm) form, paramMap );
740 }
741
742 return mapping.findForward(RiceConstants.MAPPING_BASIC);
743 }
744
745
746
747
748
749 protected Map buildKeyMapFromRequest(Maintainable maintainable, HttpServletRequest request) {
750 List keyFieldNames = null;
751
752
753 if (!StringUtils.isBlank(request.getParameter(KRADConstants.OVERRIDE_KEYS))) {
754 String[] overrideKeys = request.getParameter(KRADConstants.OVERRIDE_KEYS).split(KRADConstants.FIELD_CONVERSIONS_SEPARATOR);
755 keyFieldNames = new ArrayList();
756 for (String overrideKey : overrideKeys) {
757 keyFieldNames.add(overrideKey);
758 }
759 }
760 else {
761 keyFieldNames = getBusinessObjectMetaDataService().listPrimaryKeyFieldNames(maintainable.getBusinessObject().getClass());
762 }
763 return getRequestParameters(keyFieldNames, maintainable, request);
764 }
765
766 protected Map<String, String> getRequestParameters(List keyFieldNames, Maintainable maintainable, HttpServletRequest request){
767
768 Map<String, String> requestParameters = new HashMap<String, String>();
769
770
771 for (Iterator iter = keyFieldNames.iterator(); iter.hasNext();) {
772 String keyPropertyName = (String) iter.next();
773
774 if (request.getParameter(keyPropertyName) != null) {
775 String keyValue = request.getParameter(keyPropertyName);
776
777
778 if (getBusinessObjectAuthorizationService().attributeValueNeedsToBeEncryptedOnFormsAndLinks(maintainable.getBoClass(), keyPropertyName)) {
779 try {
780 keyValue = StringUtils.removeEnd(keyValue, EncryptionService.ENCRYPTION_POST_PREFIX);
781 keyValue = encryptionService.decrypt(keyValue);
782 }
783 catch (GeneralSecurityException e) {
784 throw new RuntimeException(e);
785 }
786 }
787
788
789 requestParameters.put(keyPropertyName, keyValue);
790 }
791 }
792
793 return requestParameters;
794
795 }
796
797
798
799
800
801
802 String extractCollectionName(HttpServletRequest request, String methodToCall) {
803
804 String parameterName = (String) request.getAttribute(KRADConstants.METHOD_TO_CALL_ATTRIBUTE);
805 String collectionName = null;
806 if (StringUtils.isNotBlank(parameterName)) {
807 collectionName = StringUtils.substringBetween(parameterName, methodToCall + ".", ".(");
808 }
809 return collectionName;
810 }
811
812 Collection extractCollection(PersistableBusinessObject bo, String collectionName) {
813
814 Collection maintCollection = (Collection) ObjectUtils.getPropertyValue(bo, collectionName);
815 return maintCollection;
816 }
817
818 Class extractCollectionClass(String docTypeName, String collectionName) {
819 return maintenanceDocumentDictionaryService.getCollectionBusinessObjectClass(docTypeName, collectionName);
820 }
821
822
823
824
825 public ActionForward addLine(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
826 KualiMaintenanceForm maintenanceForm = (KualiMaintenanceForm) form;
827 MaintenanceDocument document = (MaintenanceDocument) maintenanceForm.getDocument();
828 Maintainable oldMaintainable = document.getOldMaintainableObject();
829 Maintainable newMaintainable = document.getNewMaintainableObject();
830
831 String collectionName = extractCollectionName(request, KRADConstants.ADD_LINE_METHOD);
832 if (collectionName == null) {
833 LOG.error("Unable to get find collection name and class in request.");
834 throw new RuntimeException("Unable to get find collection name and class in request.");
835 }
836
837
838 if ((StringUtils.lastIndexOf(collectionName, "]") + 1) == collectionName.length()) {
839 collectionName = StringUtils.substringBeforeLast(collectionName, "[");
840 }
841
842 PersistableBusinessObject bo = newMaintainable.getBusinessObject();
843 Collection maintCollection = extractCollection(bo, collectionName);
844 Class collectionClass = extractCollectionClass(((MaintenanceDocument) maintenanceForm.getDocument()).getDocumentHeader().getWorkflowDocument().getDocumentTypeName(), collectionName);
845
846
847
848
849 PersistableBusinessObject addBO = newMaintainable.getNewCollectionLine(collectionName);
850 if (LOG.isDebugEnabled()) {
851 LOG.debug("obtained addBO from newCollectionLine: " + addBO);
852 }
853
854
855 getBusinessObjectService().linkUserFields(addBO);
856
857
858 newMaintainable.processBeforeAddLine(collectionName, collectionClass, addBO);
859
860
861 boolean rulePassed = false;
862 if (LOG.isDebugEnabled()) {
863 LOG.debug("about to call AddLineEvent applyRules: document=" + document + "\ncollectionName=" + collectionName + "\nBO=" + addBO);
864 }
865 rulePassed = getKualiRuleService().applyRules(new KualiAddLineEvent(document, collectionName, addBO));
866
867
868 if (rulePassed) {
869 if (LOG.isInfoEnabled()) {
870 LOG.info("********************doing editing 4 in addline()***********************.");
871 }
872
873 boolean isEdit = KRADConstants.MAINTENANCE_EDIT_ACTION.equals(maintenanceForm.getMaintenanceAction());
874 boolean isCopy = KRADConstants.MAINTENANCE_COPY_ACTION.equals(maintenanceForm.getMaintenanceAction());
875
876
877 if (isEdit || isCopy) {
878 PersistableBusinessObject oldBo = oldMaintainable.getBusinessObject();
879 Collection oldMaintCollection = (Collection) ObjectUtils.getPropertyValue(oldBo, collectionName);
880
881 if (oldMaintCollection == null) {
882 oldMaintCollection = new ArrayList();
883 }
884 if (PersistableBusinessObject.class.isAssignableFrom(collectionClass)) {
885 PersistableBusinessObject placeholder = (PersistableBusinessObject) collectionClass.newInstance();
886
887
888
889
890
891 placeholder.setNewCollectionRecord(true);
892 ((List) oldMaintCollection).add(placeholder);
893 }
894 else {
895 LOG.warn("Should be a instance of PersistableBusinessObject");
896 ((List) oldMaintCollection).add(collectionClass.newInstance());
897 }
898
899 ObjectUtils.setObjectProperty(oldBo, collectionName, List.class, oldMaintCollection);
900 }
901
902 newMaintainable.addNewLineToCollection(collectionName);
903 int subCollectionIndex = 0;
904 for (Object aSubCollection : maintCollection) {
905 subCollectionIndex += getSubCollectionIndex(aSubCollection, maintenanceForm.getDocTypeName());
906 }
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938 }
939 doProcessingAfterPost( (KualiMaintenanceForm) form, request );
940
941 return mapping.findForward(RiceConstants.MAPPING_BASIC);
942 }
943
944 protected int getSubCollectionIndex(Object object, String documentTypeName) {
945 int index = 1;
946 MaintainableCollectionDefinition theCollectionDefinition = null;
947 for (MaintainableCollectionDefinition maintainableCollectionDefinition : maintenanceDocumentDictionaryService.getMaintainableCollections(documentTypeName)) {
948 if (maintainableCollectionDefinition.getBusinessObjectClass().equals(object.getClass())) {
949
950 theCollectionDefinition = maintainableCollectionDefinition;
951 break;
952 }
953 }
954 if (theCollectionDefinition != null) {
955 for (MaintainableCollectionDefinition subCollDef : theCollectionDefinition.getMaintainableCollections()) {
956 String name = subCollDef.getName();
957 String capitalFirst = name.substring(0, 1).toUpperCase();
958 String methodName = "get" + capitalFirst + name.substring(1);
959 List subCollectionList = new ArrayList();
960 try {
961 subCollectionList = (List) object.getClass().getMethod(methodName).invoke(object);
962 }
963 catch (InvocationTargetException ite) {
964
965 }
966 catch (IllegalAccessException iae) {
967
968 }
969 catch (NoSuchMethodException nme) {
970
971 }
972 index += subCollectionList.size();
973 }
974 }
975 return index;
976 }
977
978
979
980
981
982
983 public ActionForward deleteLine(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
984 KualiMaintenanceForm maintenanceForm = (KualiMaintenanceForm) form;
985 MaintenanceDocument document = (MaintenanceDocument) maintenanceForm.getDocument();
986 Maintainable oldMaintainable = document.getOldMaintainableObject();
987 Maintainable newMaintainable = document.getNewMaintainableObject();
988
989 String collectionName = extractCollectionName(request, KRADConstants.DELETE_LINE_METHOD);
990 if (collectionName == null) {
991 LOG.error("Unable to get find collection name in request.");
992 throw new RuntimeException("Unable to get find collection class in request.");
993 }
994
995 PersistableBusinessObject bo = newMaintainable.getBusinessObject();
996 Collection maintCollection = extractCollection(bo, collectionName);
997 if (collectionName == null) {
998 LOG.error("Collection is null in parent business object.");
999 throw new RuntimeException("Collection is null in parent business object.");
1000 }
1001
1002 int deleteRecordIndex = getLineToDelete(request);
1003 if (deleteRecordIndex < 0 || deleteRecordIndex > maintCollection.size() - 1) {
1004 if (collectionName == null) {
1005 LOG.error("Invalid index for deletion of collection record: " + deleteRecordIndex);
1006 throw new RuntimeException("Invalid index for deletion of collection record: " + deleteRecordIndex);
1007 }
1008 }
1009
1010 ((List) maintCollection).remove(deleteRecordIndex);
1011
1012
1013 if (KRADConstants.MAINTENANCE_EDIT_ACTION.equals(maintenanceForm.getMaintenanceAction()) ||
1014 KRADConstants.MAINTENANCE_COPY_ACTION.equals(maintenanceForm.getMaintenanceAction())) {
1015 bo = oldMaintainable.getBusinessObject();
1016 maintCollection = extractCollection(bo, collectionName);
1017
1018 if (collectionName == null) {
1019 LOG.error("Collection is null in parent business object.");
1020 throw new RuntimeException("Collection is null in parent business object.");
1021 }
1022
1023 ((List) maintCollection).remove(deleteRecordIndex);
1024 }
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064 doProcessingAfterPost( (KualiMaintenanceForm) form, request );
1065
1066 return mapping.findForward(RiceConstants.MAPPING_BASIC);
1067 }
1068
1069
1070
1071
1072 public ActionForward toggleInactiveRecordDisplay(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
1073 KualiMaintenanceForm maintenanceForm = (KualiMaintenanceForm) form;
1074 MaintenanceDocument document = (MaintenanceDocument) maintenanceForm.getDocument();
1075 Maintainable oldMaintainable = document.getOldMaintainableObject();
1076 Maintainable newMaintainable = document.getNewMaintainableObject();
1077
1078 String collectionName = extractCollectionName(request, KRADConstants.TOGGLE_INACTIVE_METHOD);
1079 if (collectionName == null) {
1080 LOG.error("Unable to get find collection name in request.");
1081 throw new RuntimeException("Unable to get find collection class in request.");
1082 }
1083
1084 String parameterName = (String) request.getAttribute(KRADConstants.METHOD_TO_CALL_ATTRIBUTE);
1085 boolean showInactive = Boolean.parseBoolean(StringUtils.substringBetween(parameterName, KRADConstants.METHOD_TO_CALL_BOPARM_LEFT_DEL, "."));
1086
1087 oldMaintainable.setShowInactiveRecords(collectionName, showInactive);
1088 newMaintainable.setShowInactiveRecords(collectionName, showInactive);
1089
1090 return mapping.findForward(RiceConstants.MAPPING_BASIC);
1091 }
1092
1093
1094
1095
1096
1097
1098 protected void clearPrimaryKeyFields(MaintenanceDocument document) {
1099
1100 PersistableBusinessObject bo = document.getNewMaintainableObject().getBusinessObject();
1101 List<String> keyFieldNames = getBusinessObjectMetaDataService().listPrimaryKeyFieldNames(bo.getClass());
1102
1103 for (String keyFieldName : keyFieldNames) {
1104 try {
1105 ObjectUtils.setObjectProperty(bo, keyFieldName, null);
1106 }
1107 catch (Exception e) {
1108 LOG.error("Unable to clear primary key field: " + e.getMessage());
1109 throw new RuntimeException("Unable to clear primary key field: " + e.getMessage());
1110 }
1111 }
1112 bo.setObjectId(null);
1113 bo.setVersionNumber(new Long(1));
1114 }
1115
1116
1117
1118
1119
1120
1121
1122 protected void clearUnauthorizedNewFields(MaintenanceDocument document) {
1123
1124 Person user = GlobalVariables.getUserSession().getPerson();
1125
1126
1127 MaintenanceDocumentAuthorizer documentAuthorizer = (MaintenanceDocumentAuthorizer) getDocumentHelperService().getDocumentAuthorizer(document);
1128
1129
1130 MaintenanceDocumentRestrictions maintenanceDocumentRestrictions = getBusinessObjectAuthorizationService().getMaintenanceDocumentRestrictions(document, user);
1131
1132
1133 PersistableBusinessObject newBo = document.getNewMaintainableObject().getBusinessObject();
1134
1135 document.getNewMaintainableObject().clearBusinessObjectOfRestrictedValues(maintenanceDocumentRestrictions);
1136 }
1137
1138
1139
1140
1141
1142
1143 @SuppressWarnings("unchecked")
1144 protected void doProcessingAfterPost( KualiForm form, HttpServletRequest request ) {
1145 MaintenanceDocument document = (MaintenanceDocument) ((KualiMaintenanceForm)form).getDocument();
1146 Maintainable maintainable = document.getNewMaintainableObject();
1147 PersistableBusinessObject bo = maintainable.getBusinessObject();
1148
1149 getBusinessObjectService().linkUserFields(bo);
1150
1151 maintainable.processAfterPost(document, request.getParameterMap() );
1152 }
1153
1154 protected void doProcessingAfterPost( KualiForm form, Map<String,String[]> parameters ) {
1155 MaintenanceDocument document = (MaintenanceDocument) ((KualiMaintenanceForm)form).getDocument();
1156 Maintainable maintainable = document.getNewMaintainableObject();
1157 PersistableBusinessObject bo = maintainable.getBusinessObject();
1158
1159 getBusinessObjectService().linkUserFields(bo);
1160
1161 maintainable.processAfterPost(document, parameters );
1162 }
1163
1164 protected void populateAuthorizationFields(KualiDocumentFormBase formBase){
1165 super.populateAuthorizationFields(formBase);
1166
1167 KualiMaintenanceForm maintenanceForm = (KualiMaintenanceForm) formBase;
1168 MaintenanceDocument maintenanceDocument = (MaintenanceDocument) maintenanceForm.getDocument();
1169 MaintenanceDocumentAuthorizer maintenanceDocumentAuthorizer = (MaintenanceDocumentAuthorizer) getDocumentHelperService().getDocumentAuthorizer(maintenanceDocument);
1170 Person user = GlobalVariables.getUserSession().getPerson();
1171 maintenanceForm.setReadOnly(!formBase.getDocumentActions().containsKey(KRADConstants.KUALI_ACTION_CAN_EDIT));
1172 MaintenanceDocumentRestrictions maintenanceDocumentAuthorizations = getBusinessObjectAuthorizationService().getMaintenanceDocumentRestrictions(maintenanceDocument, user);
1173 maintenanceForm.setAuthorizations(maintenanceDocumentAuthorizations);
1174 }
1175
1176 public LookupService getLookupService() {
1177 if ( lookupService == null ) {
1178 lookupService = KRADServiceLocatorWeb.getLookupService();
1179 }
1180 return this.lookupService;
1181 }
1182
1183 public LookupResultsService getLookupResultsService() {
1184 if ( lookupResultsService == null ) {
1185 lookupResultsService = KNSServiceLocator.getLookupResultsService();
1186 }
1187 return this.lookupResultsService;
1188 }
1189
1190 }