class CaseRuntimeDataServiceImpl implements CaseRuntimeDataService, DeploymentEventListener {

    @Override
    public Collection<CaseStageInstance> getCaseInstanceStages(String caseId, boolean activeOnly, QueryContext queryContext) {
        ProcessInstanceDesc pi = runtimeDataService.getProcessInstanceByCorrelationKey(correlationKeyFactory.newCorrelationKey(caseId));        
        if (pi == null || !pi.getState().equals(ProcessInstance.STATE_ACTIVE)) {
            throw new CaseNotFoundException("No case instance found with id " + caseId + " or it's not active anymore");
        }
        
        CaseDefinition caseDef = getCase(pi.getDeploymentId(), pi.getProcessId());
        List<CaseStageInstance> stages = internalGetCaseStages(caseDef, caseId, activeOnly, queryContext);
        
        return applyPagination(stages, queryContext);
    }

    public  CaseRuntimeDataServiceImpl();

}