1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
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;
255 boolean matchesNodeName = true;
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> _getActionsTaken(String documentId) {
281 return getActionsTaken(documentId);
282 }
283
284 @Override
285 public List<ActionTaken> getAllActionsTaken(String documentId){
286 if(StringUtils.isEmpty(documentId)){
287 throw new RiceIllegalArgumentException("documentId is null or empty.");
288 }
289
290 List<ActionTaken> actionsTaken = new ArrayList<ActionTaken>();
291 Collection<ActionTakenValue> actionTakenBos = KEWServiceLocator.getActionTakenService().findByDocumentIdIgnoreCurrentInd(documentId);
292 for (ActionTakenValue actionTakenBo : actionTakenBos) {
293 actionsTaken.add(ActionTakenValue.to(actionTakenBo));
294 }
295 return actionsTaken;
296 }
297
298 @Override
299 public DocumentDetail getDocumentDetail(@WebParam(name = "documentId") String documentId) {
300 if (StringUtils.isBlank(documentId)) {
301 throw new RiceIllegalArgumentException("documentId was null or blank");
302 }
303 if ( LOG.isDebugEnabled() ) {
304 LOG.debug("Fetching DocumentDetail [id="+documentId+"]");
305 }
306 DocumentRouteHeaderValue document = KEWServiceLocator.getRouteHeaderService().getRouteHeader(documentId);
307 if (document == null) {
308 return null;
309 }
310 DocumentDetail documentDetailVO = DTOConverter.convertDocumentDetailNew(document);
311 if ( LOG.isDebugEnabled() ) {
312 LOG.debug("Returning DocumentDetailVO [id=" + documentId + "]");
313 }
314 return documentDetailVO;
315 }
316
317 @Override
318 public List<org.kuali.rice.kew.api.document.DocumentStatusTransition> getDocumentStatusTransitionHistory(String documentId) {
319 if (StringUtils.isBlank(documentId)) {
320 throw new RiceIllegalArgumentException("documentId was null or blank");
321 }
322 if ( LOG.isDebugEnabled() ) {
323 LOG.debug("Fetching document status transition history [id="+documentId+"]");
324 }
325 DocumentRouteHeaderValue document = KEWServiceLocator.getRouteHeaderService().getRouteHeader(documentId);;
326
327 List<DocumentStatusTransition> list = document.getAppDocStatusHistory();
328
329 List<org.kuali.rice.kew.api.document.DocumentStatusTransition> transitionHistory = new ArrayList<org.kuali.rice.kew.api.document.DocumentStatusTransition>(list.size());
330
331 for (DocumentStatusTransition transition : list) {
332 transitionHistory.add(DocumentStatusTransition.to(transition));
333 }
334 return transitionHistory;
335 }
336
337 @Override
338 public List<RouteNodeInstance> getRouteNodeInstances(String documentId) {
339 if (StringUtils.isBlank(documentId)) {
340 throw new RiceIllegalArgumentException("documentId was null or blank");
341 }
342
343 if ( LOG.isDebugEnabled() ) {
344 LOG.debug("Fetching RouteNodeInstances [documentId=" + documentId + "]");
345 }
346 DocumentRouteHeaderValue documentBo = KEWServiceLocator.getRouteHeaderService().getRouteHeader(documentId);
347 if (documentBo == null) {
348 return Collections.emptyList();
349 }
350 return convertRouteNodeInstances(KEWServiceLocator.getRouteNodeService().getFlattenedNodeInstances(documentBo, true));
351 }
352
353 @Override
354 public List<RouteNodeInstance> getActiveRouteNodeInstances(String documentId) {
355 if (StringUtils.isBlank(documentId)) {
356 throw new RiceIllegalArgumentException("documentId was null or blank");
357 }
358
359 if ( LOG.isDebugEnabled() ) {
360 LOG.debug("Fetching active RouteNodeInstances [documentId=" + documentId + "]");
361 }
362 return convertRouteNodeInstances(KEWServiceLocator.getRouteNodeService().getActiveNodeInstances(documentId));
363 }
364
365 @Override
366 public List<RouteNodeInstance> getTerminalRouteNodeInstances(String documentId) {
367 if (StringUtils.isBlank(documentId)) {
368 throw new RiceIllegalArgumentException("documentId was null or blank");
369 }
370
371 if ( LOG.isDebugEnabled() ) {
372 LOG.debug("Fetching terminal RouteNodeInstanceVOs [docId=" + documentId + "]");
373 }
374 return convertRouteNodeInstances(KEWServiceLocator.getRouteNodeService().getTerminalNodeInstances(documentId));
375 }
376
377 public List<RouteNodeInstance> getCurrentRouteNodeInstances(String documentId) {
378 if (StringUtils.isBlank(documentId)) {
379 throw new RiceIllegalArgumentException("documentId was null or blank");
380 }
381
382 if ( LOG.isDebugEnabled() ) {
383 LOG.debug("Fetching current RouteNodeInstanceVOs [docId=" + documentId + "]");
384 }
385 return convertRouteNodeInstances(KEWServiceLocator.getRouteNodeService().getCurrentNodeInstances(documentId));
386 }
387
388 public List<String> getActiveRouteNodeNames(String documentId) {
389 if (StringUtils.isBlank(documentId)) {
390 throw new RiceIllegalArgumentException("documentId was null or blank");
391 }
392
393 final List<String> nodes = KEWServiceLocator.getRouteNodeService().getActiveRouteNodeNames(documentId);
394 return nodes != null ? Collections.unmodifiableList(nodes) : Collections.<String>emptyList();
395 }
396
397 public List<String> getTerminalRouteNodeNames(String documentId) {
398 if (StringUtils.isBlank(documentId)) {
399 throw new RiceIllegalArgumentException("documentId was null or blank");
400 }
401
402 final List<String> nodes = KEWServiceLocator.getRouteNodeService().getTerminalRouteNodeNames(documentId);
403 return nodes != null ? Collections.unmodifiableList(nodes) : Collections.<String>emptyList();
404 }
405
406 public List<String> getCurrentRouteNodeNames(String documentId) {
407 if (StringUtils.isBlank(documentId)) {
408 throw new RiceIllegalArgumentException("documentId was null or blank");
409 }
410
411 final List<String> nodes = KEWServiceLocator.getRouteNodeService().getCurrentRouteNodeNames(documentId);
412 return nodes != null ? Collections.unmodifiableList(nodes) : Collections.<String>emptyList();
413 }
414
415 private List<RouteNodeInstance> convertRouteNodeInstances(List<org.kuali.rice.kew.engine.node.RouteNodeInstance> routeNodeInstanceBos) {
416 List<RouteNodeInstance> routeNodeInstances = new ArrayList<RouteNodeInstance>();
417 for (org.kuali.rice.kew.engine.node.RouteNodeInstance routeNodeInstanceBo : routeNodeInstanceBos) {
418 routeNodeInstances.add(org.kuali.rice.kew.engine.node.RouteNodeInstance.to(routeNodeInstanceBo));
419 }
420 return Collections.unmodifiableList(routeNodeInstances);
421 }
422
423 @Override
424 public List<String> getPreviousRouteNodeNames(String documentId) {
425
426 if (StringUtils.isBlank(documentId)) {
427 throw new RiceIllegalArgumentException("documentId was null or blank");
428 }
429 if ( LOG.isDebugEnabled() ) {
430 LOG.debug("Fetching previous node names [documentId=" + documentId + "]");
431 }
432 return new ArrayList<String>(KEWServiceLocator.getRouteNodeService().findPreviousNodeNames(documentId));
433 }
434
435 @Override
436 public List<String> getPrincipalIdsWithPendingActionRequestByActionRequestedAndDocId(String actionRequestedCd, String documentId){
437 if (StringUtils.isEmpty(actionRequestedCd)) {
438 throw new RiceIllegalArgumentException("actionRequestCd was blank or null");
439 }
440 if (StringUtils.isEmpty(documentId)) {
441 throw new RiceIllegalArgumentException("documentId was blank or null");
442 }
443 return KEWServiceLocator.getActionRequestService().
444 getPrincipalIdsWithPendingActionRequestByActionRequestedAndDocId(actionRequestedCd, documentId);
445 }
446
447 @Override
448 public String getDocumentInitiatorPrincipalId(String documentId) {
449 if (StringUtils.isEmpty(documentId)) {
450 throw new RiceIllegalArgumentException("documentId was blank or null");
451 }
452
453 DocumentRouteHeaderValue header = KEWServiceLocator.getRouteHeaderService().getRouteHeader(documentId, false);
454 if ( header == null) {
455 return null;
456 }
457 return header.getInitiatorWorkflowId();
458 }
459
460 @Override
461 public String getRoutedByPrincipalIdByDocumentId(String documentId) {
462 if (StringUtils.isEmpty(documentId)) {
463 throw new RiceIllegalArgumentException("documentId was blank or null");
464 }
465
466 DocumentRouteHeaderValue header = KEWServiceLocator.getRouteHeaderService().getRouteHeader(documentId, false);
467 if ( header == null) {
468 return null;
469 }
470 return header.getRoutedByUserWorkflowId();
471 }
472
473 @Override
474 public DocumentLink addDocumentLink(DocumentLink documentLink) throws RiceIllegalArgumentException {
475 if (documentLink == null) {
476 throw new RiceIllegalArgumentException("documentLink was null");
477 }
478 if (documentLink.getId() != null) {
479 throw new RiceIllegalArgumentException("the given documentLink already has an id, cannot add a document link with an existing id");
480 }
481 org.kuali.rice.kew.documentlink.DocumentLink documentLinkBo = org.kuali.rice.kew.documentlink.DocumentLink.from(documentLink);
482 KEWServiceLocator.getDocumentLinkService().saveDocumentLink(documentLinkBo);
483 return org.kuali.rice.kew.documentlink.DocumentLink.to(documentLinkBo);
484 }
485
486 @Override
487 public DocumentLink deleteDocumentLink(String documentLinkId) throws RiceIllegalArgumentException {
488 if (StringUtils.isBlank(documentLinkId)) {
489 throw new RiceIllegalArgumentException("documentLinkId was null or blank");
490 }
491 org.kuali.rice.kew.documentlink.DocumentLink documentLinkBo = KEWServiceLocator.getDocumentLinkService().getDocumentLink(Long.valueOf(documentLinkId));
492 if (documentLinkBo == null) {
493 throw new RiceIllegalStateException("Failed to locate document link with the given documentLinkId: " + documentLinkId);
494 }
495 KEWServiceLocator.getDocumentLinkService().deleteDocumentLink(documentLinkBo);
496 return org.kuali.rice.kew.documentlink.DocumentLink.to(documentLinkBo);
497 }
498
499 @Override
500 public List<DocumentLink> deleteDocumentLinksByDocumentId(String originatingDocumentId) throws RiceIllegalArgumentException {
501 if (StringUtils.isBlank(originatingDocumentId)) {
502 throw new RiceIllegalArgumentException("originatingDocumentId was null or blank");
503 }
504 List<org.kuali.rice.kew.documentlink.DocumentLink> documentLinkBos = KEWServiceLocator.getDocumentLinkService().getLinkedDocumentsByDocId(originatingDocumentId);
505 if (documentLinkBos == null || documentLinkBos.isEmpty()) {
506 return Collections.emptyList();
507 }
508 List<DocumentLink> deletedDocumentLinks = new ArrayList<DocumentLink>();
509 for (org.kuali.rice.kew.documentlink.DocumentLink documentLinkBo : documentLinkBos) {
510 deletedDocumentLinks.add(org.kuali.rice.kew.documentlink.DocumentLink.to(documentLinkBo));
511 KEWServiceLocator.getDocumentLinkService().deleteDocumentLink(documentLinkBo);
512 }
513 return Collections.unmodifiableList(deletedDocumentLinks);
514 }
515
516 @Override
517 public List<DocumentLink> getOutgoingDocumentLinks(String originatingDocumentId) throws RiceIllegalArgumentException {
518 if (StringUtils.isBlank(originatingDocumentId)) {
519 throw new RiceIllegalArgumentException("originatingDocumentId was null or blank");
520 }
521 List<org.kuali.rice.kew.documentlink.DocumentLink> outgoingDocumentLinkBos = KEWServiceLocator.getDocumentLinkService().getLinkedDocumentsByDocId(originatingDocumentId);
522 List<DocumentLink> outgoingDocumentLinks = new ArrayList<DocumentLink>();
523 for (org.kuali.rice.kew.documentlink.DocumentLink outgoingDocumentLinkBo : outgoingDocumentLinkBos) {
524 outgoingDocumentLinks.add(org.kuali.rice.kew.documentlink.DocumentLink.to(outgoingDocumentLinkBo));
525 }
526 return Collections.unmodifiableList(outgoingDocumentLinks);
527 }
528
529 @Override
530 public List<DocumentLink> getIncomingDocumentLinks(String destinationDocumentId) throws RiceIllegalArgumentException {
531 if (StringUtils.isBlank(destinationDocumentId)) {
532 throw new RiceIllegalArgumentException("destinationDocumentId was null or blank");
533 }
534 List<org.kuali.rice.kew.documentlink.DocumentLink> incomingDocumentLinkBos = KEWServiceLocator.getDocumentLinkService().getOutgoingLinkedDocumentsByDocId(destinationDocumentId);
535 List<DocumentLink> incomingDocumentLinks = new ArrayList<DocumentLink>();
536 for (org.kuali.rice.kew.documentlink.DocumentLink incomingDocumentLinkBo : incomingDocumentLinkBos) {
537 incomingDocumentLinks.add(org.kuali.rice.kew.documentlink.DocumentLink.to(incomingDocumentLinkBo));
538 }
539 return Collections.unmodifiableList(incomingDocumentLinks);
540 }
541
542 @Override
543 public DocumentLink getDocumentLink(String documentLinkId) throws RiceIllegalArgumentException {
544 if (StringUtils.isBlank(documentLinkId)) {
545 throw new RiceIllegalArgumentException("documentLinkId was null or blank");
546 }
547 org.kuali.rice.kew.documentlink.DocumentLink documentLinkBo = KEWServiceLocator.getDocumentLinkService().getDocumentLink(Long.valueOf(documentLinkId));
548 return org.kuali.rice.kew.documentlink.DocumentLink.to(documentLinkBo);
549 }
550
551 }