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