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.kuali.rice.kew.api.KewApiServiceLocator;
19 import org.kuali.rice.kew.api.WorkflowDocument;
20 import org.kuali.rice.kew.api.document.Document;
21 import org.kuali.rice.kew.api.document.DocumentContentUpdate;
22 import org.kuali.rice.kew.api.document.DocumentUpdate;
23 import org.kuali.rice.kew.service.KEWServiceLocator;
24
25
26
27
28
29
30
31 public final class DefaultWorkflowDocumentProvider implements WorkflowDocumentProvider {
32
33 @Override
34 public WorkflowDocument createDocument(String principalId, String documentTypeName, DocumentUpdate documentUpdate, DocumentContentUpdate documentContentUpdate) {
35 Document document = KewApiServiceLocator.getWorkflowDocumentActionsService().create(documentTypeName, principalId, documentUpdate, documentContentUpdate);
36 return initializePrototype(principalId, document);
37 }
38
39 @Override
40 public WorkflowDocument loadDocument(String principalId, String documentId) {
41 Document document = KewApiServiceLocator.getWorkflowDocumentService().getDocument(documentId);
42 if (document == null) {
43 throw new IllegalArgumentException("Failed to locate workflow document for given documentId: " + documentId);
44 }
45 return initializePrototype(principalId, document);
46 }
47
48 private WorkflowDocumentPrototype initializePrototype(String principalId, Document document) {
49 WorkflowDocumentPrototype prototype = KEWServiceLocator.getWorkflowDocumentPrototype();
50 prototype.init(principalId, document);
51 return prototype;
52 }
53
54 }