use of org.jbpm.casemgmt.impl.command.ReopenCaseCommand in project jbpm by kiegroup.
the class CaseServiceImpl method reopenCase.
@Override
public void reopenCase(String caseId, String deploymentId, String caseDefinitionId, Map<String, Object> data) throws CaseNotFoundException {
authorizationManager.checkOperationAuthorization(caseId, ProtectedOperation.REOPEN_CASE);
ProcessInstanceDesc pi = runtimeDataService.getProcessInstanceByCorrelationKey(correlationKeyFactory.newCorrelationKey(caseId));
if (pi != null) {
throw new CaseActiveException("Case with id " + caseId + " is still active and cannot be reopened");
}
Map<String, Object> params = new HashMap<String, Object>();
params.put("caseId", caseId);
params.put("maxResults", 1);
List<Long> caseIdMapping = commandService.execute(new QueryNameCommand<List<Long>>("findCaseIdContextMapping", params));
if (caseIdMapping.isEmpty()) {
throw new CaseNotFoundException("Case with id " + caseId + " was not found");
}
logger.debug("About to reopen case {} by starting process instance {} from deployment {} with additional data {}", caseId, caseDefinitionId, deploymentId, data);
processService.execute(deploymentId, CaseContext.get(caseId), new ReopenCaseCommand(identityProvider, caseId, deploymentId, caseDefinitionId, data, processService));
}
Aggregations