| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.kuali.rice.kew.impl.action; |
| 17 | |
|
| 18 | |
import java.util.HashSet; |
| 19 | |
import java.util.Set; |
| 20 | |
|
| 21 | |
import org.apache.commons.lang.StringUtils; |
| 22 | |
import org.kuali.rice.core.api.exception.RiceIllegalArgumentException; |
| 23 | |
import org.kuali.rice.kew.actions.BlanketApproveAction; |
| 24 | |
import org.kuali.rice.kew.actions.MoveDocumentAction; |
| 25 | |
import org.kuali.rice.kew.actiontaken.ActionTakenValue; |
| 26 | |
import org.kuali.rice.kew.api.KewApiServiceLocator; |
| 27 | |
import org.kuali.rice.kew.api.WorkflowRuntimeException; |
| 28 | |
import org.kuali.rice.kew.api.document.DocumentOrchestrationQueue; |
| 29 | |
import org.kuali.rice.kew.api.document.DocumentProcessingOptions; |
| 30 | |
import org.kuali.rice.kew.api.document.OrchestrationConfig; |
| 31 | |
import org.kuali.rice.kew.api.document.attribute.DocumentAttributeIndexingQueue; |
| 32 | |
import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue; |
| 33 | |
import org.kuali.rice.kew.service.KEWServiceLocator; |
| 34 | |
import org.kuali.rice.kim.api.identity.principal.Principal; |
| 35 | |
|
| 36 | |
import javax.jws.WebParam; |
| 37 | |
|
| 38 | |
|
| 39 | |
|
| 40 | |
|
| 41 | |
|
| 42 | |
|
| 43 | 0 | public class DocumentOrchestrationQueueImpl implements DocumentOrchestrationQueue { |
| 44 | |
|
| 45 | 0 | private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(DocumentOrchestrationQueueImpl.class); |
| 46 | |
|
| 47 | |
@Override |
| 48 | |
public void orchestrateDocument(String documentId, String principalId, OrchestrationConfig orchestrationConfig, |
| 49 | |
DocumentProcessingOptions documentProcessingOptions) { |
| 50 | 0 | if (StringUtils.isBlank(principalId)) { |
| 51 | 0 | throw new RiceIllegalArgumentException("principalId is null or blank"); |
| 52 | |
} |
| 53 | |
|
| 54 | 0 | if (StringUtils.isBlank(documentId)) { |
| 55 | 0 | throw new RiceIllegalArgumentException("documentId is null"); |
| 56 | |
} |
| 57 | |
|
| 58 | 0 | if (orchestrationConfig == null) { |
| 59 | 0 | throw new RiceIllegalArgumentException("orchestrationConfig is null"); |
| 60 | |
} |
| 61 | 0 | if (documentProcessingOptions == null) { |
| 62 | 0 | documentProcessingOptions = DocumentProcessingOptions.createDefault(); |
| 63 | |
} |
| 64 | |
|
| 65 | 0 | LOG.info("Performing document orchestration on documentId=" + documentId); |
| 66 | 0 | KEWServiceLocator.getRouteHeaderService().lockRouteHeader(documentId, true); |
| 67 | 0 | DocumentRouteHeaderValue document = KEWServiceLocator.getRouteHeaderService().getRouteHeader(documentId); |
| 68 | 0 | ActionTakenValue actionTaken = KEWServiceLocator.getActionTakenService().findByActionTakenId(orchestrationConfig.getActionTakenId()); |
| 69 | 0 | Principal principal = KEWServiceLocator.getIdentityHelperService().getPrincipal(principalId); |
| 70 | 0 | BlanketApproveAction blanketApprove = new BlanketApproveAction(document, principal, "", orchestrationConfig.getNodeNames()); |
| 71 | |
try { |
| 72 | 0 | blanketApprove.performDeferredBlanketApproveWork(actionTaken, documentProcessingOptions); |
| 73 | 0 | } catch (Exception e) { |
| 74 | 0 | if (e instanceof RuntimeException) { |
| 75 | 0 | throw (RuntimeException)e; |
| 76 | |
} |
| 77 | 0 | throw new WorkflowRuntimeException(e); |
| 78 | 0 | } |
| 79 | 0 | if (documentProcessingOptions.isIndexSearchAttributes()) { |
| 80 | 0 | DocumentAttributeIndexingQueue queue = KewApiServiceLocator.getDocumentAttributeIndexingQueue(document.getDocumentType().getApplicationId()); |
| 81 | 0 | queue.indexDocument(documentId); |
| 82 | |
} |
| 83 | 0 | LOG.info("Document orchestration complete against documentId=" + documentId); |
| 84 | 0 | } |
| 85 | |
|
| 86 | |
} |