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.document.Document;
28 import org.kuali.rice.kew.api.document.DocumentContent;
29 import org.kuali.rice.kew.api.document.DocumentDetail;
30 import org.kuali.rice.kew.api.document.DocumentLink;
31 import org.kuali.rice.kew.api.document.DocumentStatus;
32 import org.kuali.rice.kew.api.document.WorkflowDocumentService;
33 import org.kuali.rice.kew.api.document.node.RouteNodeInstance;
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.doctype.bo.DocumentType;
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.List;
50
51
52
53
54
55
56 public class WorkflowDocumentServiceImpl implements WorkflowDocumentService {
57
58 private static final Logger LOG = Logger.getLogger(WorkflowDocumentServiceImpl.class);
59
60 @Override
61 public Document getDocument(String documentId) {
62 if (StringUtils.isBlank(documentId)) {
63 throw new RiceIllegalArgumentException("documentId was blank or null");
64 }
65 DocumentRouteHeaderValue documentBo = KEWServiceLocator.getRouteHeaderService().getRouteHeader(documentId);
66 return DocumentRouteHeaderValue.to(documentBo);
67 }
68
69 @Override
70 public boolean doesDocumentExist(String documentId) {
71 if (StringUtils.isBlank(documentId)) {
72 throw new RiceIllegalArgumentException("documentId was blank or null");
73 }
74 DocumentRouteHeaderValue documentBo = KEWServiceLocator.getRouteHeaderService().getRouteHeader(documentId);
75 return documentBo != null;
76 }
77
78 @Override
79 public String getDocumentTypeName(String documentId) {
80 if (StringUtils.isBlank(documentId)) {
81 throw new RiceIllegalArgumentException("documentId was blank or null");
82 }
83 DocumentType documentType = KEWServiceLocator.getDocumentTypeService().findByDocumentId(documentId);
84 if (documentType == null) {
85 throw new RiceIllegalArgumentException("Failed to determine document type name for document with id "
86 + documentId
87 + ". Perhaps document does not exist?");
88 }
89 return documentType.getName();
90 }
91
92
93 @Override
94 public DocumentDetail getDocumentDetailByAppId(String documentTypeName, String appId) {
95 if (StringUtils.isEmpty(documentTypeName)) {
96 throw new RiceIllegalArgumentException("documentTypeName was blank or null");
97 }
98 if (StringUtils.isEmpty(appId)) {
99 throw new RiceIllegalArgumentException("appId was blank or null");
100 }
101
102 Collection documentIds = KEWServiceLocator.getRouteHeaderService().findByDocTypeAndAppId(documentTypeName, appId);
103 if(documentIds==null||documentIds.isEmpty()){
104 throw new RiceIllegalStateException("No RouteHeader Ids found for documentTypName: " + documentTypeName + ", appId: " + appId);
105 }
106 if(documentIds.size()>1){
107 throw new RiceIllegalStateException("Multiple RouteHeader Ids found for documentTypName: " + documentTypeName + ", appId: " + appId);
108 }
109
110 return getDocumentDetail((String)documentIds.iterator().next());
111 }
112
113 public RouteNodeInstance getRouteNodeInstance(String nodeInstanceId) {
114 if (StringUtils.isEmpty(nodeInstanceId)) {
115 throw new RiceIllegalArgumentException("nodeInstanceId was blank or null");
116 }
117 if ( LOG.isDebugEnabled() ) {
118 LOG.debug("Fetching RouteNodeInstanceVO [id="+nodeInstanceId+"]");
119 }
120 org.kuali.rice.kew.engine.node.RouteNodeInstance nodeInstance = KEWServiceLocator.getRouteNodeService().findRouteNodeInstanceById(nodeInstanceId);
121 return org.kuali.rice.kew.engine.node.RouteNodeInstance.to(nodeInstance);
122 }
123
124 @Override
125 public DocumentStatus getDocumentStatus(String documentId) {
126 if (StringUtils.isEmpty(documentId)) {
127 throw new RiceIllegalArgumentException("documentId was blank or null");
128 }
129 String documentStatus = KEWServiceLocator.getRouteHeaderService().getDocumentStatus(documentId);
130 if (StringUtils.isEmpty(documentStatus)) {
131 throw new RiceIllegalStateException("DocumentStatus not found for documentId: " + documentId);
132 }
133 return DocumentStatus.fromCode(documentStatus);
134 }
135
136 @Override
137 public String getApplicationDocumentId(String documentId) {
138 if (StringUtils.isEmpty(documentId)) {
139 throw new RiceIllegalArgumentException("documentId was blank or null");
140 }
141 return KEWServiceLocator.getRouteHeaderService().getAppDocId(documentId);
142 }
143
144 @Override
145 public String getApplicationDocumentStatus(String documentId)
146 throws RiceIllegalArgumentException {
147 if (StringUtils.isEmpty(documentId)) {
148 throw new RiceIllegalArgumentException("documentId was blank or null");
149 }
150 return KEWServiceLocator.getRouteHeaderService().getAppDocStatus(documentId);
151 }
152
153 @Override
154 public DocumentSearchResults documentSearch(String principalId, DocumentSearchCriteria criteria) {
155 if (criteria == null) {
156 throw new RiceIllegalArgumentException("criteria was null");
157 }
158 return KEWServiceLocator.getDocumentSearchService().lookupDocuments(principalId, criteria);
159 }
160
161 @Override
162 public List<String> getSearchableAttributeStringValuesByKey(String documentId, String key) {
163 if (StringUtils.isEmpty(documentId)) {
164 throw new RiceIllegalArgumentException("documentId was blank or null");
165 }
166 if (StringUtils.isEmpty(key)) {
167 throw new RiceIllegalArgumentException("key was blank or null");
168 }
169 return KEWServiceLocator.getRouteHeaderService().getSearchableAttributeStringValuesByKey(documentId, key);
170 }
171
172 @Override
173 public List<DateTime> getSearchableAttributeDateTimeValuesByKey(String documentId, String key) {
174 if (StringUtils.isEmpty(documentId)) {
175 throw new RiceIllegalArgumentException("documentId was blank or null");
176 }
177 if (StringUtils.isEmpty(key)) {
178 throw new RiceIllegalArgumentException("key was blank or null");
179 }
180
181 List<Timestamp> results = KEWServiceLocator.getRouteHeaderService().getSearchableAttributeDateTimeValuesByKey(documentId, key);
182 if (results == null) {
183 return null;
184 }
185 List<DateTime> dateTimes = new ArrayList<DateTime>();
186
187 for(Timestamp time : results) {
188 dateTimes.add(new DateTime(time.getTime()));
189 }
190 return dateTimes;
191 }
192
193 @Override
194 public List<BigDecimal> getSearchableAttributeFloatValuesByKey(String documentId, String key) {
195 if (StringUtils.isEmpty(documentId)) {
196 throw new RiceIllegalArgumentException("documentId was blank or null");
197 }
198 if (StringUtils.isEmpty(key)) {
199 throw new RiceIllegalArgumentException("key was blank or null");
200 }
201 return KEWServiceLocator.getRouteHeaderService().getSearchableAttributeFloatValuesByKey(documentId, key);
202 }
203
204 @Override
205 public List<Long> getSearchableAttributeLongValuesByKey(String documentId, String key) {
206 if (StringUtils.isEmpty(documentId)) {
207 throw new RiceIllegalArgumentException("documentId was blank or null");
208 }
209 if (StringUtils.isEmpty(key)) {
210 throw new RiceIllegalArgumentException("key was blank or null");
211 }
212 return KEWServiceLocator.getRouteHeaderService().getSearchableAttributeLongValuesByKey(documentId, key);
213 }
214
215 @Override
216 public DocumentContent getDocumentContent(String documentId) {
217 if (StringUtils.isBlank(documentId)) {
218 throw new RiceIllegalArgumentException("documentId was blank or null");
219 }
220 DocumentRouteHeaderValueContent content = KEWServiceLocator.getRouteHeaderService().getContent(documentId);
221 return DocumentRouteHeaderValueContent.to(content);
222 }
223
224 @Override
225 public List<ActionRequest> getRootActionRequests(String documentId) {
226 if (StringUtils.isBlank(documentId)) {
227 throw new RiceIllegalArgumentException("documentId was blank or null");
228 }
229 List<ActionRequest> actionRequests = new ArrayList<ActionRequest>();
230 List<ActionRequestValue> actionRequestBos = KEWServiceLocator.getActionRequestService().findAllRootActionRequestsByDocumentId(documentId);
231 for (ActionRequestValue actionRequestBo : actionRequestBos) {
232 actionRequests.add(ActionRequestValue.to(actionRequestBo));
233 }
234 return Collections.unmodifiableList(actionRequests);
235 }
236
237 @Override
238 public List<ActionRequest> getPendingActionRequests(String documentId) {
239 if (StringUtils.isBlank(documentId)) {
240 throw new RiceIllegalArgumentException("documentId was blank or null");
241 }
242 List<ActionRequest> actionRequests = new ArrayList<ActionRequest>();
243 List<ActionRequestValue> actionRequestBos = KEWServiceLocator.getActionRequestService().findAllPendingRequests(documentId);
244 for (ActionRequestValue actionRequestBo : actionRequestBos) {
245 actionRequests.add(ActionRequestValue.to(actionRequestBo));
246 }
247 return Collections.unmodifiableList(actionRequests);
248 }
249
250 @Override
251 public List<ActionRequest> getActionRequestsForPrincipalAtNode(String documentId, String nodeName,
252 String principalId) {
253 if (StringUtils.isBlank(documentId)) {
254 throw new RiceIllegalArgumentException("documentId was null or blank");
255 }
256 if ( LOG.isDebugEnabled() ) {
257 LOG.debug("Fetching ActionRequests [docId="+documentId+", nodeName="+nodeName+", principalId="+principalId+"]");
258 }
259 List<ActionRequestValue> actionRequestBos = KEWServiceLocator.getActionRequestService().findAllActionRequestsByDocumentId(documentId);
260 List<ActionRequestValue> matchingActionRequests = new ArrayList<ActionRequestValue>();
261 for (ActionRequestValue actionRequestValue : actionRequestBos) {
262 if (actionRequestMatches(actionRequestValue, nodeName, principalId)) {
263 matchingActionRequests.add(actionRequestValue);
264 }
265 }
266 List<ActionRequest> actionRequests = new ArrayList<ActionRequest>(matchingActionRequests.size());
267 for (ActionRequestValue matchingActionRequest : matchingActionRequests) {
268 actionRequests.add(ActionRequestValue.to(matchingActionRequest));
269 }
270 return actionRequests;
271 }
272
273 protected boolean actionRequestMatches(ActionRequestValue actionRequest, String nodeName, String principalId) {
274 boolean matchesUserId = true;
275 boolean matchesNodeName = true;
276 if (StringUtils.isNotBlank(nodeName)) {
277 matchesNodeName = nodeName.equals(actionRequest.getPotentialNodeName());
278 }
279 if (principalId != null) {
280 matchesUserId = actionRequest.isRecipientRoutedRequest(principalId);
281 }
282 return matchesNodeName && matchesUserId;
283 }
284
285
286 @Override
287 public List<ActionTaken> getActionsTaken(String documentId) {
288 if (StringUtils.isEmpty(documentId)) {
289 throw new RiceIllegalArgumentException("documentId is null or empty.");
290 }
291 List<ActionTaken> actionTakens = new ArrayList<ActionTaken>();
292 Collection<ActionTakenValue> actionTakenBos = KEWServiceLocator.getActionTakenService().findByDocumentId(documentId);
293 for (ActionTakenValue actionTakenBo : actionTakenBos) {
294 actionTakens.add(ActionTakenValue.to(actionTakenBo));
295 }
296 return actionTakens;
297 }
298
299 @Override
300 public List<ActionTaken> _getActionsTaken(String documentId) {
301 return getActionsTaken(documentId);
302 }
303
304 @Override
305 public List<ActionTaken> getAllActionsTaken(String documentId){
306 if(StringUtils.isEmpty(documentId)){
307 throw new RiceIllegalArgumentException("documentId is null or empty.");
308 }
309
310 List<ActionTaken> actionsTaken = new ArrayList<ActionTaken>();
311 Collection<ActionTakenValue> actionTakenBos = KEWServiceLocator.getActionTakenService().findByDocumentIdIgnoreCurrentInd(documentId);
312 for (ActionTakenValue actionTakenBo : actionTakenBos) {
313 actionsTaken.add(ActionTakenValue.to(actionTakenBo));
314 }
315 return actionsTaken;
316 }
317
318 @Override
319 public DocumentDetail getDocumentDetail(@WebParam(name = "documentId") String documentId) {
320 if (StringUtils.isBlank(documentId)) {
321 throw new RiceIllegalArgumentException("documentId was null or blank");
322 }
323 if ( LOG.isDebugEnabled() ) {
324 LOG.debug("Fetching DocumentDetail [id="+documentId+"]");
325 }
326 DocumentRouteHeaderValue document = KEWServiceLocator.getRouteHeaderService().getRouteHeader(documentId);
327 if (document == null) {
328 return null;
329 }
330 DocumentDetail documentDetailVO = DTOConverter.convertDocumentDetailNew(document);
331 if ( LOG.isDebugEnabled() ) {
332 LOG.debug("Returning DocumentDetailVO [id=" + documentId + "]");
333 }
334 return documentDetailVO;
335 }
336
337 @Override
338 public List<org.kuali.rice.kew.api.document.DocumentStatusTransition> getDocumentStatusTransitionHistory(String documentId) {
339 if (StringUtils.isBlank(documentId)) {
340 throw new RiceIllegalArgumentException("documentId was null or blank");
341 }
342 if ( LOG.isDebugEnabled() ) {
343 LOG.debug("Fetching document status transition history [id="+documentId+"]");
344 }
345 DocumentRouteHeaderValue document = KEWServiceLocator.getRouteHeaderService().getRouteHeader(documentId);;
346
347 List<DocumentStatusTransition> list = document.getAppDocStatusHistory();
348
349 List<org.kuali.rice.kew.api.document.DocumentStatusTransition> transitionHistory = new ArrayList<org.kuali.rice.kew.api.document.DocumentStatusTransition>(list.size());
350
351 for (DocumentStatusTransition transition : list) {
352 transitionHistory.add(DocumentStatusTransition.to(transition));
353 }
354 return transitionHistory;
355 }
356
357 @Override
358 public List<RouteNodeInstance> getRouteNodeInstances(String documentId) {
359 if (StringUtils.isBlank(documentId)) {
360 throw new RiceIllegalArgumentException("documentId was null or blank");
361 }
362
363 if ( LOG.isDebugEnabled() ) {
364 LOG.debug("Fetching RouteNodeInstances [documentId=" + documentId + "]");
365 }
366 DocumentRouteHeaderValue documentBo = KEWServiceLocator.getRouteHeaderService().getRouteHeader(documentId);
367 if (documentBo == null) {
368 return Collections.emptyList();
369 }
370 return convertRouteNodeInstances(KEWServiceLocator.getRouteNodeService().getFlattenedNodeInstances(documentBo, true));
371 }
372
373 @Override
374 public List<RouteNodeInstance> getActiveRouteNodeInstances(String documentId) {
375 if (StringUtils.isBlank(documentId)) {
376 throw new RiceIllegalArgumentException("documentId was null or blank");
377 }
378
379 if ( LOG.isDebugEnabled() ) {
380 LOG.debug("Fetching active RouteNodeInstances [documentId=" + documentId + "]");
381 }
382 return convertRouteNodeInstances(KEWServiceLocator.getRouteNodeService().getActiveNodeInstances(documentId));
383 }
384
385 @Override
386 public List<RouteNodeInstance> getTerminalRouteNodeInstances(String documentId) {
387 if (StringUtils.isBlank(documentId)) {
388 throw new RiceIllegalArgumentException("documentId was null or blank");
389 }
390
391 if ( LOG.isDebugEnabled() ) {
392 LOG.debug("Fetching terminal RouteNodeInstanceVOs [docId=" + documentId + "]");
393 }
394 return convertRouteNodeInstances(KEWServiceLocator.getRouteNodeService().getTerminalNodeInstances(documentId));
395 }
396
397 public List<RouteNodeInstance> getCurrentRouteNodeInstances(String documentId) {
398 if (StringUtils.isBlank(documentId)) {
399 throw new RiceIllegalArgumentException("documentId was null or blank");
400 }
401
402 if ( LOG.isDebugEnabled() ) {
403 LOG.debug("Fetching current RouteNodeInstanceVOs [docId=" + documentId + "]");
404 }
405 return convertRouteNodeInstances(KEWServiceLocator.getRouteNodeService().getCurrentNodeInstances(documentId));
406 }
407
408 public List<String> getActiveRouteNodeNames(String documentId) {
409 if (StringUtils.isBlank(documentId)) {
410 throw new RiceIllegalArgumentException("documentId was null or blank");
411 }
412
413 final List<String> nodes = KEWServiceLocator.getRouteNodeService().getActiveRouteNodeNames(documentId);
414 return nodes != null ? Collections.unmodifiableList(nodes) : Collections.<String>emptyList();
415 }
416
417 public List<String> getTerminalRouteNodeNames(String documentId) {
418 if (StringUtils.isBlank(documentId)) {
419 throw new RiceIllegalArgumentException("documentId was null or blank");
420 }
421
422 final List<String> nodes = KEWServiceLocator.getRouteNodeService().getTerminalRouteNodeNames(documentId);
423 return nodes != null ? Collections.unmodifiableList(nodes) : Collections.<String>emptyList();
424 }
425
426 public List<String> getCurrentRouteNodeNames(String documentId) {
427 if (StringUtils.isBlank(documentId)) {
428 throw new RiceIllegalArgumentException("documentId was null or blank");
429 }
430
431 final List<String> nodes = KEWServiceLocator.getRouteNodeService().getCurrentRouteNodeNames(documentId);
432 return nodes != null ? Collections.unmodifiableList(nodes) : Collections.<String>emptyList();
433 }
434
435 private List<RouteNodeInstance> convertRouteNodeInstances(List<org.kuali.rice.kew.engine.node.RouteNodeInstance> routeNodeInstanceBos) {
436 List<RouteNodeInstance> routeNodeInstances = new ArrayList<RouteNodeInstance>();
437 for (org.kuali.rice.kew.engine.node.RouteNodeInstance routeNodeInstanceBo : routeNodeInstanceBos) {
438 routeNodeInstances.add(org.kuali.rice.kew.engine.node.RouteNodeInstance.to(routeNodeInstanceBo));
439 }
440 return Collections.unmodifiableList(routeNodeInstances);
441 }
442
443 @Override
444 public List<String> getPreviousRouteNodeNames(String documentId) {
445
446 if (StringUtils.isBlank(documentId)) {
447 throw new RiceIllegalArgumentException("documentId was null or blank");
448 }
449 if ( LOG.isDebugEnabled() ) {
450 LOG.debug("Fetching previous node names [documentId=" + documentId + "]");
451 }
452 return new ArrayList<String>(KEWServiceLocator.getRouteNodeService().findPreviousNodeNames(documentId));
453 }
454
455 @Override
456 public List<String> getPrincipalIdsWithPendingActionRequestByActionRequestedAndDocId(String actionRequestedCd, String documentId){
457 if (StringUtils.isEmpty(actionRequestedCd)) {
458 throw new RiceIllegalArgumentException("actionRequestCd was blank or null");
459 }
460 if (StringUtils.isEmpty(documentId)) {
461 throw new RiceIllegalArgumentException("documentId was blank or null");
462 }
463 return KEWServiceLocator.getActionRequestService().
464 getPrincipalIdsWithPendingActionRequestByActionRequestedAndDocId(actionRequestedCd, documentId);
465 }
466
467 @Override
468 public String getDocumentInitiatorPrincipalId(String documentId) {
469 if (StringUtils.isEmpty(documentId)) {
470 throw new RiceIllegalArgumentException("documentId was blank or null");
471 }
472
473 DocumentRouteHeaderValue header = KEWServiceLocator.getRouteHeaderService().getRouteHeader(documentId, false);
474 if ( header == null) {
475 return null;
476 }
477 return header.getInitiatorWorkflowId();
478 }
479
480 @Override
481 public String getRoutedByPrincipalIdByDocumentId(String documentId) {
482 if (StringUtils.isEmpty(documentId)) {
483 throw new RiceIllegalArgumentException("documentId was blank or null");
484 }
485
486 DocumentRouteHeaderValue header = KEWServiceLocator.getRouteHeaderService().getRouteHeader(documentId, false);
487 if ( header == null) {
488 return null;
489 }
490 return header.getRoutedByUserWorkflowId();
491 }
492
493 @Override
494 public DocumentLink addDocumentLink(DocumentLink documentLink) throws RiceIllegalArgumentException {
495 if (documentLink == null) {
496 throw new RiceIllegalArgumentException("documentLink was null");
497 }
498 if (documentLink.getId() != null) {
499 throw new RiceIllegalArgumentException("the given documentLink already has an id, cannot add a document link with an existing id");
500 }
501 org.kuali.rice.kew.documentlink.DocumentLink documentLinkBo = org.kuali.rice.kew.documentlink.DocumentLink.from(documentLink);
502 documentLinkBo = KEWServiceLocator.getDocumentLinkService().saveDocumentLink(documentLinkBo);
503 return org.kuali.rice.kew.documentlink.DocumentLink.to(documentLinkBo);
504 }
505
506 @Override
507 public DocumentLink deleteDocumentLink(String documentLinkId) throws RiceIllegalArgumentException {
508 if (StringUtils.isBlank(documentLinkId)) {
509 throw new RiceIllegalArgumentException("documentLinkId was null or blank");
510 }
511 org.kuali.rice.kew.documentlink.DocumentLink documentLinkBo = KEWServiceLocator.getDocumentLinkService().getDocumentLink(documentLinkId);
512 if (documentLinkBo == null) {
513 throw new RiceIllegalStateException("Failed to locate document link with the given documentLinkId: " + documentLinkId);
514 }
515 KEWServiceLocator.getDocumentLinkService().deleteDocumentLink(documentLinkBo);
516 return org.kuali.rice.kew.documentlink.DocumentLink.to(documentLinkBo);
517 }
518
519 @Override
520 public List<DocumentLink> deleteDocumentLinksByDocumentId(String originatingDocumentId) throws RiceIllegalArgumentException {
521 if (StringUtils.isBlank(originatingDocumentId)) {
522 throw new RiceIllegalArgumentException("originatingDocumentId was null or blank");
523 }
524 List<org.kuali.rice.kew.documentlink.DocumentLink> documentLinkBos = KEWServiceLocator.getDocumentLinkService().getLinkedDocumentsByDocId(originatingDocumentId);
525 if (documentLinkBos == null || documentLinkBos.isEmpty()) {
526 return Collections.emptyList();
527 }
528 List<DocumentLink> deletedDocumentLinks = new ArrayList<DocumentLink>();
529 for (org.kuali.rice.kew.documentlink.DocumentLink documentLinkBo : documentLinkBos) {
530 deletedDocumentLinks.add(org.kuali.rice.kew.documentlink.DocumentLink.to(documentLinkBo));
531 KEWServiceLocator.getDocumentLinkService().deleteDocumentLink(documentLinkBo);
532 }
533 return Collections.unmodifiableList(deletedDocumentLinks);
534 }
535
536 @Override
537 public List<DocumentLink> getOutgoingDocumentLinks(String originatingDocumentId) throws RiceIllegalArgumentException {
538 if (StringUtils.isBlank(originatingDocumentId)) {
539 throw new RiceIllegalArgumentException("originatingDocumentId was null or blank");
540 }
541 List<org.kuali.rice.kew.documentlink.DocumentLink> outgoingDocumentLinkBos = KEWServiceLocator.getDocumentLinkService().getLinkedDocumentsByDocId(originatingDocumentId);
542 List<DocumentLink> outgoingDocumentLinks = new ArrayList<DocumentLink>();
543 for (org.kuali.rice.kew.documentlink.DocumentLink outgoingDocumentLinkBo : outgoingDocumentLinkBos) {
544 outgoingDocumentLinks.add(org.kuali.rice.kew.documentlink.DocumentLink.to(outgoingDocumentLinkBo));
545 }
546 return Collections.unmodifiableList(outgoingDocumentLinks);
547 }
548
549 @Override
550 public List<DocumentLink> getIncomingDocumentLinks(String destinationDocumentId) throws RiceIllegalArgumentException {
551 if (StringUtils.isBlank(destinationDocumentId)) {
552 throw new RiceIllegalArgumentException("destinationDocumentId was null or blank");
553 }
554 List<org.kuali.rice.kew.documentlink.DocumentLink> incomingDocumentLinkBos = KEWServiceLocator.getDocumentLinkService().getOutgoingLinkedDocumentsByDocId(destinationDocumentId);
555 List<DocumentLink> incomingDocumentLinks = new ArrayList<DocumentLink>();
556 for (org.kuali.rice.kew.documentlink.DocumentLink incomingDocumentLinkBo : incomingDocumentLinkBos) {
557 incomingDocumentLinks.add(org.kuali.rice.kew.documentlink.DocumentLink.to(incomingDocumentLinkBo));
558 }
559 return Collections.unmodifiableList(incomingDocumentLinks);
560 }
561
562 @Override
563 public DocumentLink getDocumentLink(String documentLinkId) throws RiceIllegalArgumentException {
564 if (StringUtils.isBlank(documentLinkId)) {
565 throw new RiceIllegalArgumentException("documentLinkId was null or blank");
566 }
567 org.kuali.rice.kew.documentlink.DocumentLink documentLinkBo = KEWServiceLocator.getDocumentLinkService().getDocumentLink(documentLinkId);
568 return org.kuali.rice.kew.documentlink.DocumentLink.to(documentLinkBo);
569 }
570
571 }