throw new ActivitiObjectNotFoundException("Process definition does not exist: " + processDefinitionId, ProcessDefinitionEntity.class);
    }
    // Fetch the resource
    String resourceName = processDefinitionEntity.getResourceName();
    ResourceEntity resource = commandContext.getResourceEntityManager()
            .findResourceByDeploymentIdAndResourceName(processDefinitionEntity.getDeploymentId(), resourceName);
    if (resource == null) {
      if (commandContext.getDeploymentEntityManager().findDeploymentById(processDefinitionEntity.getDeploymentId()) == null) {
        throw new ActivitiObjectNotFoundException("deployment for process definition does not exist: " 
      + processDefinitionEntity.getDeploymentId(), Deployment.class);
      } else {
        throw new ActivitiObjectNotFoundException("no resource found with name '" + resourceName 
                + "' in deployment '" + processDefinitionEntity.getDeploymentId() + "'", InputStream.class);
      }
    }
    
    // Convert the bpmn 2.0 xml to a bpmn model
    BpmnXMLConverter bpmnXMLConverter = new BpmnXMLConverter();
    return bpmnXMLConverter.convertToBpmnModel(new BytesStreamSource(resource.getBytes()), false, false); // no need to validate schema, it was already validated on deploy
  }