View Javadoc

1   /**
2    * Copyright 2005-2012 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.kew.impl.document;
17  
18  import org.apache.commons.lang.StringUtils;
19  import org.apache.log4j.Logger;
20  import org.joda.time.DateTime;
21  import org.kuali.rice.core.api.exception.RiceIllegalArgumentException;
22  import org.kuali.rice.core.api.exception.RiceIllegalStateException;
23  import org.kuali.rice.kew.actionrequest.ActionRequestValue;
24  import org.kuali.rice.kew.actiontaken.ActionTakenValue;
25  import org.kuali.rice.kew.api.action.ActionRequest;
26  import org.kuali.rice.kew.api.action.ActionTaken;
27  import org.kuali.rice.kew.api.doctype.RouteNode;
28  import org.kuali.rice.kew.api.document.Document;
29  import org.kuali.rice.kew.api.document.DocumentContent;
30  import org.kuali.rice.kew.api.document.DocumentDetail;
31  import org.kuali.rice.kew.api.document.DocumentLink;
32  import org.kuali.rice.kew.api.document.DocumentStatus;
33  import org.kuali.rice.kew.api.document.WorkflowDocumentService;
34  import org.kuali.rice.kew.api.document.search.DocumentSearchCriteria;
35  import org.kuali.rice.kew.api.document.search.DocumentSearchResults;
36  import org.kuali.rice.kew.api.document.node.RouteNodeInstance;
37  import org.kuali.rice.kew.dto.DTOConverter;
38  import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue;
39  import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValueContent;
40  import org.kuali.rice.kew.routeheader.DocumentStatusTransition;
41  import org.kuali.rice.kew.service.KEWServiceLocator;
42  
43  import javax.jws.WebParam;
44  import java.math.BigDecimal;
45  import java.sql.Timestamp;
46  import java.util.ArrayList;
47  import java.util.Collection;
48  import java.util.Collections;
49  import java.util.HashMap;
50  import java.util.LinkedHashSet;
51  import java.util.List;
52  import java.util.Map;
53  import java.util.Set;
54  
55  /**
56   * 
57   * @author Kuali Rice Team (rice.collab@kuali.org)
58   *
59   */
60  public class WorkflowDocumentServiceImpl implements WorkflowDocumentService {
61  
62  	private static final Logger LOG = Logger.getLogger(WorkflowDocumentServiceImpl.class);
63  	
64  	@Override
65  	public Document getDocument(String documentId) {
66  		if (StringUtils.isBlank(documentId)) {
67  			throw new RiceIllegalArgumentException("documentId was blank or null");
68  		}
69  		DocumentRouteHeaderValue documentBo = KEWServiceLocator.getRouteHeaderService().getRouteHeader(documentId);
70  		return DocumentRouteHeaderValue.to(documentBo);
71  	}
72  
73  	@Override
74  	public boolean doesDocumentExist(String documentId) {
75  	    if (StringUtils.isBlank(documentId)) {
76              throw new RiceIllegalArgumentException("documentId was blank or null");
77          }
78  	    DocumentRouteHeaderValue documentBo = KEWServiceLocator.getRouteHeaderService().getRouteHeader(documentId);
79  	    return documentBo != null;
80  	}
81  
82      @Override
83      public DocumentDetail getDocumentDetailByAppId(String documentTypeName, String appId) {
84          if (StringUtils.isEmpty(documentTypeName)) {
85              throw new RiceIllegalArgumentException("documentTypeName was blank or null");
86          }
87          if (StringUtils.isEmpty(appId)) {
88              throw new RiceIllegalArgumentException("appId was blank or null");
89          }
90  
91          Collection documentIds = KEWServiceLocator.getRouteHeaderService().findByDocTypeAndAppId(documentTypeName, appId);
92          if(documentIds==null||documentIds.isEmpty()){
93              throw new RiceIllegalStateException("No RouteHeader Ids found for documentTypName: " + documentTypeName + ", appId: " + appId);
94          }
95          if(documentIds.size()>1){
96              throw new RiceIllegalStateException("Multiple RouteHeader Ids found for documentTypName: " + documentTypeName + ", appId: " + appId);
97  		}
98  
99          return getDocumentDetail((String)documentIds.iterator().next());
100 	}
101 
102     public RouteNodeInstance getRouteNodeInstance(String nodeInstanceId)  {
103         if (StringUtils.isEmpty(nodeInstanceId)) {
104             throw new RiceIllegalArgumentException("nodeInstanceId was blank or null");
105         }
106         if ( LOG.isDebugEnabled() ) {
107         	LOG.debug("Fetching RouteNodeInstanceVO [id="+nodeInstanceId+"]");
108         }
109         org.kuali.rice.kew.engine.node.RouteNodeInstance nodeInstance = KEWServiceLocator.getRouteNodeService().findRouteNodeInstanceById(nodeInstanceId);
110         return org.kuali.rice.kew.engine.node.RouteNodeInstance.to(nodeInstance);
111     }
112 
113     @Override
114     public DocumentStatus getDocumentStatus(String documentId) {
115         if (StringUtils.isEmpty(documentId)) {
116             throw new RiceIllegalArgumentException("documentId was blank or null");
117         }
118         String documentStatus = KEWServiceLocator.getRouteHeaderService().getDocumentStatus(documentId);
119         if (StringUtils.isEmpty(documentStatus)) {
120             throw new RiceIllegalStateException("DocumentStatus not found for documentId: " + documentId);
121         }
122         return DocumentStatus.fromCode(documentStatus);
123     }
124 
125     @Override
126     public String getApplicationDocumentId(String documentId) {
127         if (StringUtils.isEmpty(documentId)) {
128             throw new RiceIllegalArgumentException("documentId was blank or null");
129         }
130  	 	return KEWServiceLocator.getRouteHeaderService().getAppDocId(documentId);
131  	}
132 
133     @Override
134     public DocumentSearchResults documentSearch(String principalId, DocumentSearchCriteria criteria) {
135         if (criteria == null) {
136             throw new RiceIllegalArgumentException("criteria was null");
137         }
138         return KEWServiceLocator.getDocumentSearchService().lookupDocuments(principalId, criteria);
139     }
140 
141     @Override
142     public List<String> getSearchableAttributeStringValuesByKey(String documentId, String key) {
143         if (StringUtils.isEmpty(documentId)) {
144             throw new RiceIllegalArgumentException("documentId was blank or null");
145         }
146         if (StringUtils.isEmpty(key)) {
147             throw new RiceIllegalArgumentException("key was blank or null");
148         }
149 		return KEWServiceLocator.getRouteHeaderService().getSearchableAttributeStringValuesByKey(documentId, key);
150 	}
151 
152     @Override
153 	public List<DateTime> getSearchableAttributeDateTimeValuesByKey(String documentId, String key) {
154 		if (StringUtils.isEmpty(documentId)) {
155             throw new RiceIllegalArgumentException("documentId was blank or null");
156         }
157         if (StringUtils.isEmpty(key)) {
158             throw new RiceIllegalArgumentException("key was blank or null");
159         }
160 
161         List<Timestamp> results = KEWServiceLocator.getRouteHeaderService().getSearchableAttributeDateTimeValuesByKey(documentId, key);
162         if (results == null) {
163             return null;
164         }
165         List<DateTime> dateTimes = new ArrayList<DateTime>();
166 
167 		for(Timestamp time : results) {
168             dateTimes.add(new DateTime(time.getTime()));
169         }
170         return dateTimes;
171 	}
172 
173     @Override
174 	public List<BigDecimal> getSearchableAttributeFloatValuesByKey(String documentId, String key) {
175         if (StringUtils.isEmpty(documentId)) {
176             throw new RiceIllegalArgumentException("documentId was blank or null");
177         }
178         if (StringUtils.isEmpty(key)) {
179             throw new RiceIllegalArgumentException("key was blank or null");
180         }
181 		return KEWServiceLocator.getRouteHeaderService().getSearchableAttributeFloatValuesByKey(documentId, key);
182 	}
183 
184     @Override
185     public List<Long> getSearchableAttributeLongValuesByKey(String documentId, String key) {
186         if (StringUtils.isEmpty(documentId)) {
187             throw new RiceIllegalArgumentException("documentId was blank or null");
188         }
189         if (StringUtils.isEmpty(key)) {
190             throw new RiceIllegalArgumentException("key was blank or null");
191         }
192 		return KEWServiceLocator.getRouteHeaderService().getSearchableAttributeLongValuesByKey(documentId, key);
193 	}
194 	
195 	@Override
196 	public DocumentContent getDocumentContent(String documentId) {
197 		if (StringUtils.isBlank(documentId)) {
198 			throw new RiceIllegalArgumentException("documentId was blank or null");
199 		}
200 		DocumentRouteHeaderValueContent content = KEWServiceLocator.getRouteHeaderService().getContent(documentId);
201 		return DocumentRouteHeaderValueContent.to(content);
202 	}
203 
204 	@Override
205 	public List<ActionRequest> getRootActionRequests(String documentId) {
206         if (StringUtils.isBlank(documentId)) {
207 			throw new RiceIllegalArgumentException("documentId was blank or null");
208 		}
209 		List<ActionRequest> actionRequests = new ArrayList<ActionRequest>();
210 		List<ActionRequestValue> actionRequestBos = KEWServiceLocator.getActionRequestService().findAllRootActionRequestsByDocumentId(documentId);
211 		for (ActionRequestValue actionRequestBo : actionRequestBos) {
212 			actionRequests.add(ActionRequestValue.to(actionRequestBo));
213 		}
214 		return Collections.unmodifiableList(actionRequests);
215 	}
216 	
217 	@Override
218 	public List<ActionRequest> getPendingActionRequests(String documentId) {
219 		if (StringUtils.isBlank(documentId)) {
220 			throw new RiceIllegalArgumentException("documentId was blank or null");
221 		}
222 		List<ActionRequest> actionRequests = new ArrayList<ActionRequest>();
223 		List<ActionRequestValue> actionRequestBos = KEWServiceLocator.getActionRequestService().findAllPendingRequests(documentId);
224 		for (ActionRequestValue actionRequestBo : actionRequestBos) {
225 			actionRequests.add(ActionRequestValue.to(actionRequestBo));
226 		}
227 		return Collections.unmodifiableList(actionRequests);
228 	}
229 	
230 	@Override
231 	public List<ActionRequest> getActionRequestsForPrincipalAtNode(String documentId, String nodeName,
232             String principalId) {
233         if (StringUtils.isBlank(documentId)) {
234         	throw new RiceIllegalArgumentException("documentId was null or blank");
235         }
236         if ( LOG.isDebugEnabled() ) {
237         	LOG.debug("Fetching ActionRequests [docId="+documentId+", nodeName="+nodeName+", principalId="+principalId+"]");
238         }
239         List<ActionRequestValue> actionRequestBos = KEWServiceLocator.getActionRequestService().findAllActionRequestsByDocumentId(documentId);
240         List<ActionRequestValue> matchingActionRequests = new ArrayList<ActionRequestValue>();
241         for (ActionRequestValue actionRequestValue : actionRequestBos) {
242             if (actionRequestMatches(actionRequestValue, nodeName, principalId)) {
243                 matchingActionRequests.add(actionRequestValue);
244             }
245         }
246         List<ActionRequest> actionRequests = new ArrayList<ActionRequest>(matchingActionRequests.size());
247         for (ActionRequestValue matchingActionRequest : matchingActionRequests) {
248         	actionRequests.add(ActionRequestValue.to(matchingActionRequest));
249         }
250         return actionRequests;
251     }
252 	
253     protected boolean actionRequestMatches(ActionRequestValue actionRequest, String nodeName, String principalId) {
254         boolean matchesUserId = true;  // assume a match in case user is empty
255         boolean matchesNodeName = true;  // assume a match in case node name is empty
256         if (StringUtils.isNotBlank(nodeName)) {
257             matchesNodeName = nodeName.equals(actionRequest.getPotentialNodeName());
258         }
259         if (principalId != null) {
260             matchesUserId = actionRequest.isRecipientRoutedRequest(principalId);
261         }
262         return matchesNodeName && matchesUserId;
263     }
264 
265 
266 	@Override
267 	public List<ActionTaken> getActionsTaken(String documentId) {
268         if (StringUtils.isEmpty(documentId)) {
269             throw new RiceIllegalArgumentException("documentId is null or empty.");
270         }
271 		List<ActionTaken> actionTakens = new ArrayList<ActionTaken>();
272 		Collection<ActionTakenValue> actionTakenBos = KEWServiceLocator.getActionTakenService().findByDocumentId(documentId);
273 		for (ActionTakenValue actionTakenBo : actionTakenBos) {
274 			actionTakens.add(ActionTakenValue.to(actionTakenBo));
275 		}
276 		return actionTakens;
277 	}
278 
279     @Override
280     public List<ActionTaken> getAllActionsTaken(String documentId){
281         if(StringUtils.isEmpty(documentId)){
282             throw new RiceIllegalArgumentException("documentId is null or empty.");
283         }
284 
285 		List<ActionTaken> actionsTaken = new ArrayList<ActionTaken>();
286         Collection<ActionTakenValue> actionTakenBos = KEWServiceLocator.getActionTakenService().findByDocumentIdIgnoreCurrentInd(documentId);
287 		for (ActionTakenValue actionTakenBo : actionTakenBos) {
288 			actionsTaken.add(ActionTakenValue.to(actionTakenBo));
289 		}
290        return actionsTaken;
291     }
292 	
293 	@Override
294 	public DocumentDetail getDocumentDetail(@WebParam(name = "documentId") String documentId) {
295 		if (StringUtils.isBlank(documentId)) {
296             throw new RiceIllegalArgumentException("documentId was null or blank");
297         }
298         if ( LOG.isDebugEnabled() ) {
299         	LOG.debug("Fetching DocumentDetail [id="+documentId+"]");
300         }
301         DocumentRouteHeaderValue document = KEWServiceLocator.getRouteHeaderService().getRouteHeader(documentId);
302         if (document == null) {
303         	return null;
304         }
305         DocumentDetail documentDetailVO = DTOConverter.convertDocumentDetailNew(document);
306         if ( LOG.isDebugEnabled() ) {
307         	LOG.debug("Returning DocumentDetailVO [id=" + documentId + "]");
308         }
309         return documentDetailVO;
310 	}
311 
312     @Override
313     public List<org.kuali.rice.kew.api.document.DocumentStatusTransition> getDocumentStatusTransitionHistory(String documentId) {
314 		if (StringUtils.isBlank(documentId)) {
315             throw new RiceIllegalArgumentException("documentId was null or blank");
316         }
317         if ( LOG.isDebugEnabled() ) {
318             LOG.debug("Fetching document status transition history [id="+documentId+"]");
319         }
320         DocumentRouteHeaderValue document = KEWServiceLocator.getRouteHeaderService().getRouteHeader(documentId);;
321 
322         List<DocumentStatusTransition> list = document.getAppDocStatusHistory();
323 
324         List<org.kuali.rice.kew.api.document.DocumentStatusTransition> transitionHistory = new ArrayList<org.kuali.rice.kew.api.document.DocumentStatusTransition>(list.size());
325 
326         for (DocumentStatusTransition transition : list) {
327             transitionHistory.add(DocumentStatusTransition.to(transition));
328         }
329         return transitionHistory;
330     }
331 	
332 	@Override
333 	public List<RouteNodeInstance> getRouteNodeInstances(String documentId) {
334     	if (StringUtils.isBlank(documentId)) {
335             throw new RiceIllegalArgumentException("documentId was null or blank");
336         }
337 
338         if ( LOG.isDebugEnabled() ) {
339     		LOG.debug("Fetching RouteNodeInstances [documentId=" + documentId + "]");
340     	}
341     	DocumentRouteHeaderValue documentBo = KEWServiceLocator.getRouteHeaderService().getRouteHeader(documentId);
342     	if (documentBo == null) {
343     		return Collections.emptyList();
344     	}
345     	return convertRouteNodeInstances(KEWServiceLocator.getRouteNodeService().getFlattenedNodeInstances(documentBo, true));
346     }	
347 	
348 	@Override
349 	public List<RouteNodeInstance> getActiveRouteNodeInstances(String documentId) {
350 		if (StringUtils.isBlank(documentId)) {
351             throw new RiceIllegalArgumentException("documentId was null or blank");
352         }
353 
354         if ( LOG.isDebugEnabled() ) {
355     		LOG.debug("Fetching active RouteNodeInstances [documentId=" + documentId + "]");
356     	}
357         return convertRouteNodeInstances(KEWServiceLocator.getRouteNodeService().getActiveNodeInstances(documentId));
358 	}
359 
360     @Override
361     public List<RouteNodeInstance> getTerminalRouteNodeInstances(String documentId) {
362     	if (StringUtils.isBlank(documentId)) {
363             throw new RiceIllegalArgumentException("documentId was null or blank");
364         }
365 
366         if ( LOG.isDebugEnabled() ) {
367     		LOG.debug("Fetching terminal RouteNodeInstanceVOs [docId=" + documentId + "]");
368     	}
369         return convertRouteNodeInstances(KEWServiceLocator.getRouteNodeService().getTerminalNodeInstances(documentId));
370     }
371 
372     public List<RouteNodeInstance> getCurrentRouteNodeInstances(String documentId) {
373     	if (StringUtils.isBlank(documentId)) {
374             throw new RiceIllegalArgumentException("documentId was null or blank");
375         }
376 
377         if ( LOG.isDebugEnabled() ) {
378     		LOG.debug("Fetching current RouteNodeInstanceVOs [docId=" + documentId + "]");
379     	}
380     	return convertRouteNodeInstances(KEWServiceLocator.getRouteNodeService().getCurrentNodeInstances(documentId));
381     }
382 
383 	private List<RouteNodeInstance> convertRouteNodeInstances(List<org.kuali.rice.kew.engine.node.RouteNodeInstance> routeNodeInstanceBos) {
384 		List<RouteNodeInstance> routeNodeInstances = new ArrayList<RouteNodeInstance>();
385         for (org.kuali.rice.kew.engine.node.RouteNodeInstance routeNodeInstanceBo : routeNodeInstanceBos) {
386         	routeNodeInstances.add(org.kuali.rice.kew.engine.node.RouteNodeInstance.to(routeNodeInstanceBo));
387         }
388         return Collections.unmodifiableList(routeNodeInstances);
389 	}
390 	
391 	@Override
392 	public List<String> getPreviousRouteNodeNames(String documentId) {
393 
394 		if (StringUtils.isBlank(documentId)) {
395             throw new RiceIllegalArgumentException("documentId was null or blank");
396         }
397         if ( LOG.isDebugEnabled() ) {
398 			LOG.debug("Fetching previous node names [documentId=" + documentId + "]");
399 		}
400         return new ArrayList<String>(KEWServiceLocator.getRouteNodeService().findPreviousNodeNames(documentId));
401 	}
402 
403     @Override
404     public List<String> getPrincipalIdsWithPendingActionRequestByActionRequestedAndDocId(String actionRequestedCd, String documentId){
405     	if (StringUtils.isEmpty(actionRequestedCd)) {
406             throw new RiceIllegalArgumentException("actionRequestCd was blank or null");
407         }
408         if (StringUtils.isEmpty(documentId)) {
409             throw new RiceIllegalArgumentException("documentId was blank or null");
410         }
411         return KEWServiceLocator.getActionRequestService().
412     				getPrincipalIdsWithPendingActionRequestByActionRequestedAndDocId(actionRequestedCd, documentId);
413     }
414 
415     @Override
416     public String getDocumentInitiatorPrincipalId(String documentId) {
417         if (StringUtils.isEmpty(documentId)) {
418             throw new RiceIllegalArgumentException("documentId was blank or null");
419         }
420 
421         DocumentRouteHeaderValue header = KEWServiceLocator.getRouteHeaderService().getRouteHeader(documentId, false);
422         if ( header == null) {
423         	return null;
424         }
425     	return header.getInitiatorWorkflowId();
426     }
427 
428     @Override
429     public String getRoutedByPrincipalIdByDocumentId(String documentId) {
430         if (StringUtils.isEmpty(documentId)) {
431             throw new RiceIllegalArgumentException("documentId was blank or null");
432         }
433 
434         DocumentRouteHeaderValue header = KEWServiceLocator.getRouteHeaderService().getRouteHeader(documentId, false);
435         if ( header == null) {
436         	return null;
437         }
438     	return header.getRoutedByUserWorkflowId();
439     }
440 
441 	@Override
442 	public DocumentLink addDocumentLink(DocumentLink documentLink) throws RiceIllegalArgumentException {
443 		if (documentLink == null) {
444 			throw new RiceIllegalArgumentException("documentLink was null");
445 		}
446 		if (documentLink.getId() != null) {
447 			throw new RiceIllegalArgumentException("the given documentLink already has an id, cannot add a document link with an existing id");
448 		}
449 		org.kuali.rice.kew.documentlink.DocumentLink documentLinkBo = org.kuali.rice.kew.documentlink.DocumentLink.from(documentLink);
450 		KEWServiceLocator.getDocumentLinkService().saveDocumentLink(documentLinkBo);
451 		return org.kuali.rice.kew.documentlink.DocumentLink.to(documentLinkBo);
452 	}
453 
454 	@Override
455 	public DocumentLink deleteDocumentLink(String documentLinkId) throws RiceIllegalArgumentException {
456 		if (StringUtils.isBlank(documentLinkId)) {
457 			throw new RiceIllegalArgumentException("documentLinkId was null or blank");
458 		}
459 		org.kuali.rice.kew.documentlink.DocumentLink documentLinkBo = KEWServiceLocator.getDocumentLinkService().getDocumentLink(Long.valueOf(documentLinkId));
460 		if (documentLinkBo == null) {
461 			throw new RiceIllegalStateException("Failed to locate document link with the given documentLinkId: " + documentLinkId);
462 		}
463 		KEWServiceLocator.getDocumentLinkService().deleteDocumentLink(documentLinkBo);
464 		return org.kuali.rice.kew.documentlink.DocumentLink.to(documentLinkBo);
465 	}
466 	    
467 	@Override
468 	public List<DocumentLink> deleteDocumentLinksByDocumentId(String originatingDocumentId) throws RiceIllegalArgumentException {
469 		if (StringUtils.isBlank(originatingDocumentId)) {
470 			throw new RiceIllegalArgumentException("originatingDocumentId was null or blank");
471 		}
472 		List<org.kuali.rice.kew.documentlink.DocumentLink> documentLinkBos = KEWServiceLocator.getDocumentLinkService().getLinkedDocumentsByDocId(originatingDocumentId);
473 		if (documentLinkBos == null || documentLinkBos.isEmpty()) {
474 			return Collections.emptyList();
475 		}
476 		List<DocumentLink> deletedDocumentLinks = new ArrayList<DocumentLink>();
477 		for (org.kuali.rice.kew.documentlink.DocumentLink documentLinkBo : documentLinkBos) {
478 			deletedDocumentLinks.add(org.kuali.rice.kew.documentlink.DocumentLink.to(documentLinkBo));
479 			KEWServiceLocator.getDocumentLinkService().deleteDocumentLink(documentLinkBo);
480 		}
481 		return Collections.unmodifiableList(deletedDocumentLinks);
482     }
483 	    
484 	@Override
485 	public List<DocumentLink> getOutgoingDocumentLinks(String originatingDocumentId) throws RiceIllegalArgumentException {
486 		if (StringUtils.isBlank(originatingDocumentId)) {
487 			throw new RiceIllegalArgumentException("originatingDocumentId was null or blank");
488 		}
489 		List<org.kuali.rice.kew.documentlink.DocumentLink> outgoingDocumentLinkBos = KEWServiceLocator.getDocumentLinkService().getLinkedDocumentsByDocId(originatingDocumentId);
490 		List<DocumentLink> outgoingDocumentLinks = new ArrayList<DocumentLink>();
491 		for (org.kuali.rice.kew.documentlink.DocumentLink outgoingDocumentLinkBo : outgoingDocumentLinkBos) {
492 			outgoingDocumentLinks.add(org.kuali.rice.kew.documentlink.DocumentLink.to(outgoingDocumentLinkBo));
493 		}
494 		return Collections.unmodifiableList(outgoingDocumentLinks);
495     }
496 	
497 	@Override
498 	public List<DocumentLink> getIncomingDocumentLinks(String destinationDocumentId) throws RiceIllegalArgumentException {
499 		if (StringUtils.isBlank(destinationDocumentId)) {
500 			throw new RiceIllegalArgumentException("destinationDocumentId was null or blank");
501 		}
502 		List<org.kuali.rice.kew.documentlink.DocumentLink> incomingDocumentLinkBos = KEWServiceLocator.getDocumentLinkService().getOutgoingLinkedDocumentsByDocId(destinationDocumentId);
503 		List<DocumentLink> incomingDocumentLinks = new ArrayList<DocumentLink>();
504 		for (org.kuali.rice.kew.documentlink.DocumentLink incomingDocumentLinkBo : incomingDocumentLinkBos) {
505 			incomingDocumentLinks.add(org.kuali.rice.kew.documentlink.DocumentLink.to(incomingDocumentLinkBo));
506 		}
507 		return Collections.unmodifiableList(incomingDocumentLinks);
508     }
509 	    
510 	@Override
511 	public DocumentLink getDocumentLink(String documentLinkId) throws RiceIllegalArgumentException {
512 		if (StringUtils.isBlank(documentLinkId)) {
513 			throw new RiceIllegalArgumentException("documentLinkId was null or blank");
514 		}
515 		org.kuali.rice.kew.documentlink.DocumentLink documentLinkBo = KEWServiceLocator.getDocumentLinkService().getDocumentLink(Long.valueOf(documentLinkId));
516 		return org.kuali.rice.kew.documentlink.DocumentLink.to(documentLinkBo);
517     }
518 	
519 }