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 IllegalArgumentException("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 IllegalArgumentException("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 if(CoreApiServiceLocator.getEncryptionService().isEnabled()) {
782 keyValue = encryptionService.decrypt(keyValue);
783 }
784 }
785 catch (GeneralSecurityException e) {
786 throw new RuntimeException(e);
787 }
788 }
789
790
791 requestParameters.put(keyPropertyName, keyValue);
792 }
793 }
794
795 return requestParameters;
796
797 }
798
799
800
801
802
803
804 String extractCollectionName(HttpServletRequest request, String methodToCall) {
805
806 String parameterName = (String) request.getAttribute(KRADConstants.METHOD_TO_CALL_ATTRIBUTE);
807 String collectionName = null;
808 if (StringUtils.isNotBlank(parameterName)) {
809 collectionName = StringUtils.substringBetween(parameterName, methodToCall + ".", ".(");
810 }
811 return collectionName;
812 }
813
814 Collection extractCollection(PersistableBusinessObject bo, String collectionName) {
815
816 Collection maintCollection = (Collection) ObjectUtils.getPropertyValue(bo, collectionName);
817 return maintCollection;
818 }
819
820 Class extractCollectionClass(String docTypeName, String collectionName) {
821 return maintenanceDocumentDictionaryService.getCollectionBusinessObjectClass(docTypeName, collectionName);
822 }
823
824
825
826
827 public ActionForward addLine(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
828 KualiMaintenanceForm maintenanceForm = (KualiMaintenanceForm) form;
829 MaintenanceDocument document = (MaintenanceDocument) maintenanceForm.getDocument();
830 Maintainable oldMaintainable = document.getOldMaintainableObject();
831 Maintainable newMaintainable = document.getNewMaintainableObject();
832
833 String collectionName = extractCollectionName(request, KRADConstants.ADD_LINE_METHOD);
834 if (collectionName == null) {
835 LOG.error("Unable to get find collection name and class in request.");
836 throw new RuntimeException("Unable to get find collection name and class in request.");
837 }
838
839
840 if ((StringUtils.lastIndexOf(collectionName, "]") + 1) == collectionName.length()) {
841 collectionName = StringUtils.substringBeforeLast(collectionName, "[");
842 }
843
844 PersistableBusinessObject bo = newMaintainable.getBusinessObject();
845 Collection maintCollection = extractCollection(bo, collectionName);
846 Class collectionClass = extractCollectionClass(((MaintenanceDocument) maintenanceForm.getDocument()).getDocumentHeader().getWorkflowDocument().getDocumentTypeName(), collectionName);
847
848
849
850
851 PersistableBusinessObject addBO = newMaintainable.getNewCollectionLine(collectionName);
852 if (LOG.isDebugEnabled()) {
853 LOG.debug("obtained addBO from newCollectionLine: " + addBO);
854 }
855
856
857 getBusinessObjectService().linkUserFields(addBO);
858
859
860 newMaintainable.processBeforeAddLine(collectionName, collectionClass, addBO);
861
862
863 boolean rulePassed = false;
864 if (LOG.isDebugEnabled()) {
865 LOG.debug("about to call AddLineEvent applyRules: document=" + document + "\ncollectionName=" + collectionName + "\nBO=" + addBO);
866 }
867 rulePassed = getKualiRuleService().applyRules(new KualiAddLineEvent(document, collectionName, addBO));
868
869
870 if (rulePassed) {
871 if (LOG.isInfoEnabled()) {
872 LOG.info("********************doing editing 4 in addline()***********************.");
873 }
874
875 boolean isEdit = KRADConstants.MAINTENANCE_EDIT_ACTION.equals(maintenanceForm.getMaintenanceAction());
876 boolean isCopy = KRADConstants.MAINTENANCE_COPY_ACTION.equals(maintenanceForm.getMaintenanceAction());
877
878
879 if (isEdit || isCopy) {
880 PersistableBusinessObject oldBo = oldMaintainable.getBusinessObject();
881 Collection oldMaintCollection = (Collection) ObjectUtils.getPropertyValue(oldBo, collectionName);
882
883 if (oldMaintCollection == null) {
884 oldMaintCollection = new ArrayList();
885 }
886 if (PersistableBusinessObject.class.isAssignableFrom(collectionClass)) {
887 PersistableBusinessObject placeholder = (PersistableBusinessObject) collectionClass.newInstance();
888
889
890
891
892
893 placeholder.setNewCollectionRecord(true);
894 ((List) oldMaintCollection).add(placeholder);
895 }
896 else {
897 LOG.warn("Should be a instance of PersistableBusinessObject");
898 ((List) oldMaintCollection).add(collectionClass.newInstance());
899 }
900
901 ObjectUtils.setObjectProperty(oldBo, collectionName, List.class, oldMaintCollection);
902 }
903
904 newMaintainable.addNewLineToCollection(collectionName);
905 int subCollectionIndex = 0;
906 for (Object aSubCollection : maintCollection) {
907 subCollectionIndex += getSubCollectionIndex(aSubCollection, maintenanceForm.getDocTypeName());
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
940 }
941 doProcessingAfterPost( (KualiMaintenanceForm) form, request );
942
943 return mapping.findForward(RiceConstants.MAPPING_BASIC);
944 }
945
946 protected int getSubCollectionIndex(Object object, String documentTypeName) {
947 int index = 1;
948 MaintainableCollectionDefinition theCollectionDefinition = null;
949 for (MaintainableCollectionDefinition maintainableCollectionDefinition : maintenanceDocumentDictionaryService.getMaintainableCollections(documentTypeName)) {
950 if (maintainableCollectionDefinition.getBusinessObjectClass().equals(object.getClass())) {
951
952 theCollectionDefinition = maintainableCollectionDefinition;
953 break;
954 }
955 }
956 if (theCollectionDefinition != null) {
957 for (MaintainableCollectionDefinition subCollDef : theCollectionDefinition.getMaintainableCollections()) {
958 String name = subCollDef.getName();
959 String capitalFirst = name.substring(0, 1).toUpperCase();
960 String methodName = "get" + capitalFirst + name.substring(1);
961 List subCollectionList = new ArrayList();
962 try {
963 subCollectionList = (List) object.getClass().getMethod(methodName).invoke(object);
964 }
965 catch (InvocationTargetException ite) {
966
967 }
968 catch (IllegalAccessException iae) {
969
970 }
971 catch (NoSuchMethodException nme) {
972
973 }
974 index += subCollectionList.size();
975 }
976 }
977 return index;
978 }
979
980
981
982
983
984
985 public ActionForward deleteLine(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
986 KualiMaintenanceForm maintenanceForm = (KualiMaintenanceForm) form;
987 MaintenanceDocument document = (MaintenanceDocument) maintenanceForm.getDocument();
988 Maintainable oldMaintainable = document.getOldMaintainableObject();
989 Maintainable newMaintainable = document.getNewMaintainableObject();
990
991 String collectionName = extractCollectionName(request, KRADConstants.DELETE_LINE_METHOD);
992 if (collectionName == null) {
993 LOG.error("Unable to get find collection name in request.");
994 throw new RuntimeException("Unable to get find collection class in request.");
995 }
996
997 PersistableBusinessObject bo = newMaintainable.getBusinessObject();
998 Collection maintCollection = extractCollection(bo, collectionName);
999 if (collectionName == null) {
1000 LOG.error("Collection is null in parent business object.");
1001 throw new RuntimeException("Collection is null in parent business object.");
1002 }
1003
1004 int deleteRecordIndex = getLineToDelete(request);
1005 if (deleteRecordIndex < 0 || deleteRecordIndex > maintCollection.size() - 1) {
1006 if (collectionName == null) {
1007 LOG.error("Invalid index for deletion of collection record: " + deleteRecordIndex);
1008 throw new RuntimeException("Invalid index for deletion of collection record: " + deleteRecordIndex);
1009 }
1010 }
1011
1012 ((List) maintCollection).remove(deleteRecordIndex);
1013
1014
1015 if (KRADConstants.MAINTENANCE_EDIT_ACTION.equals(maintenanceForm.getMaintenanceAction()) ||
1016 KRADConstants.MAINTENANCE_COPY_ACTION.equals(maintenanceForm.getMaintenanceAction())) {
1017 bo = oldMaintainable.getBusinessObject();
1018 maintCollection = extractCollection(bo, collectionName);
1019
1020 if (collectionName == null) {
1021 LOG.error("Collection is null in parent business object.");
1022 throw new RuntimeException("Collection is null in parent business object.");
1023 }
1024
1025 ((List) maintCollection).remove(deleteRecordIndex);
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
1065
1066 doProcessingAfterPost( (KualiMaintenanceForm) form, request );
1067
1068 return mapping.findForward(RiceConstants.MAPPING_BASIC);
1069 }
1070
1071
1072
1073
1074 public ActionForward toggleInactiveRecordDisplay(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
1075 KualiMaintenanceForm maintenanceForm = (KualiMaintenanceForm) form;
1076 MaintenanceDocument document = (MaintenanceDocument) maintenanceForm.getDocument();
1077 Maintainable oldMaintainable = document.getOldMaintainableObject();
1078 Maintainable newMaintainable = document.getNewMaintainableObject();
1079
1080 String collectionName = extractCollectionName(request, KRADConstants.TOGGLE_INACTIVE_METHOD);
1081 if (collectionName == null) {
1082 LOG.error("Unable to get find collection name in request.");
1083 throw new RuntimeException("Unable to get find collection class in request.");
1084 }
1085
1086 String parameterName = (String) request.getAttribute(KRADConstants.METHOD_TO_CALL_ATTRIBUTE);
1087 boolean showInactive = Boolean.parseBoolean(StringUtils.substringBetween(parameterName, KRADConstants.METHOD_TO_CALL_BOPARM_LEFT_DEL, "."));
1088
1089 oldMaintainable.setShowInactiveRecords(collectionName, showInactive);
1090 newMaintainable.setShowInactiveRecords(collectionName, showInactive);
1091
1092 return mapping.findForward(RiceConstants.MAPPING_BASIC);
1093 }
1094
1095
1096
1097
1098
1099
1100 protected void clearPrimaryKeyFields(MaintenanceDocument document) {
1101
1102 PersistableBusinessObject bo = document.getNewMaintainableObject().getBusinessObject();
1103 List<String> keyFieldNames = getBusinessObjectMetaDataService().listPrimaryKeyFieldNames(bo.getClass());
1104
1105 for (String keyFieldName : keyFieldNames) {
1106 try {
1107 ObjectUtils.setObjectProperty(bo, keyFieldName, null);
1108 }
1109 catch (Exception e) {
1110 LOG.error("Unable to clear primary key field: " + e.getMessage());
1111 throw new RuntimeException("Unable to clear primary key field: " + e.getMessage());
1112 }
1113 }
1114 bo.setObjectId(null);
1115 bo.setVersionNumber(new Long(1));
1116 }
1117
1118
1119
1120
1121
1122
1123
1124 protected void clearUnauthorizedNewFields(MaintenanceDocument document) {
1125
1126 Person user = GlobalVariables.getUserSession().getPerson();
1127
1128
1129 MaintenanceDocumentAuthorizer documentAuthorizer = (MaintenanceDocumentAuthorizer) getDocumentHelperService().getDocumentAuthorizer(document);
1130
1131
1132 MaintenanceDocumentRestrictions maintenanceDocumentRestrictions = getBusinessObjectAuthorizationService().getMaintenanceDocumentRestrictions(document, user);
1133
1134
1135 PersistableBusinessObject newBo = document.getNewMaintainableObject().getBusinessObject();
1136
1137 document.getNewMaintainableObject().clearBusinessObjectOfRestrictedValues(maintenanceDocumentRestrictions);
1138 }
1139
1140
1141
1142
1143
1144
1145 @SuppressWarnings("unchecked")
1146 protected void doProcessingAfterPost( KualiForm form, HttpServletRequest request ) {
1147 MaintenanceDocument document = (MaintenanceDocument) ((KualiMaintenanceForm)form).getDocument();
1148 Maintainable maintainable = document.getNewMaintainableObject();
1149 PersistableBusinessObject bo = maintainable.getBusinessObject();
1150
1151 getBusinessObjectService().linkUserFields(bo);
1152
1153 maintainable.processAfterPost(document, request.getParameterMap() );
1154 }
1155
1156 protected void doProcessingAfterPost( KualiForm form, Map<String,String[]> parameters ) {
1157 MaintenanceDocument document = (MaintenanceDocument) ((KualiMaintenanceForm)form).getDocument();
1158 Maintainable maintainable = document.getNewMaintainableObject();
1159 PersistableBusinessObject bo = maintainable.getBusinessObject();
1160
1161 getBusinessObjectService().linkUserFields(bo);
1162
1163 maintainable.processAfterPost(document, parameters );
1164 }
1165
1166 protected void populateAuthorizationFields(KualiDocumentFormBase formBase){
1167 super.populateAuthorizationFields(formBase);
1168
1169 KualiMaintenanceForm maintenanceForm = (KualiMaintenanceForm) formBase;
1170 MaintenanceDocument maintenanceDocument = (MaintenanceDocument) maintenanceForm.getDocument();
1171 MaintenanceDocumentAuthorizer maintenanceDocumentAuthorizer = (MaintenanceDocumentAuthorizer) getDocumentHelperService().getDocumentAuthorizer(maintenanceDocument);
1172 Person user = GlobalVariables.getUserSession().getPerson();
1173 maintenanceForm.setReadOnly(!formBase.getDocumentActions().containsKey(KRADConstants.KUALI_ACTION_CAN_EDIT));
1174 MaintenanceDocumentRestrictions maintenanceDocumentAuthorizations = getBusinessObjectAuthorizationService().getMaintenanceDocumentRestrictions(maintenanceDocument, user);
1175 maintenanceForm.setAuthorizations(maintenanceDocumentAuthorizations);
1176 }
1177
1178 public LookupService getLookupService() {
1179 if ( lookupService == null ) {
1180 lookupService = KRADServiceLocatorWeb.getLookupService();
1181 }
1182 return this.lookupService;
1183 }
1184
1185 public LookupResultsService getLookupResultsService() {
1186 if ( lookupResultsService == null ) {
1187 lookupResultsService = KNSServiceLocator.getLookupResultsService();
1188 }
1189 return this.lookupResultsService;
1190 }
1191
1192 }