use of org.kie.internal.runtime.manager.InternalRuntimeManager in project jbpm by kiegroup.
the class MigrationManager method validate.
private void validate() {
if (migrationSpec == null) {
report.addEntry(Type.ERROR, "no process data given for migration");
return;
}
// source (active) process instance information
if (isEmpty(migrationSpec.getDeploymentId())) {
report.addEntry(Type.ERROR, "No deployment id set");
}
if (migrationSpec.getProcessInstanceId() == null) {
report.addEntry(Type.ERROR, "No process instance id set");
}
// target process information
if (isEmpty(migrationSpec.getToDeploymentId())) {
report.addEntry(Type.ERROR, "No target deployment id set");
}
if (isEmpty(migrationSpec.getToProcessId())) {
report.addEntry(Type.ERROR, "No target process id set");
}
// verify if given runtime manager exists - registered under source deployment id
if (!RuntimeManagerRegistry.get().isRegistered(migrationSpec.getDeploymentId())) {
report.addEntry(Type.ERROR, "No deployment found for " + migrationSpec.getDeploymentId());
}
// verify if given runtime manager exists - registered under target deployment id
if (!RuntimeManagerRegistry.get().isRegistered(migrationSpec.getToDeploymentId())) {
report.addEntry(Type.ERROR, "No target deployment found for " + migrationSpec.getToDeploymentId());
}
// verify if given target process id exists in target runtime manager
InternalRuntimeManager manager = (InternalRuntimeManager) RuntimeManagerRegistry.get().getManager(migrationSpec.getToDeploymentId());
if (manager.getEnvironment().getKieBase().getProcess(migrationSpec.getToProcessId()) == null) {
report.addEntry(Type.ERROR, "No process found for " + migrationSpec.getToProcessId() + " in deployment " + migrationSpec.getToDeploymentId());
}
// verify that source and target runtime manager is of the same type - represent the same runtime strategy
InternalRuntimeManager sourceManager = (InternalRuntimeManager) RuntimeManagerRegistry.get().getManager(migrationSpec.getDeploymentId());
if (!sourceManager.getClass().isAssignableFrom(manager.getClass())) {
report.addEntry(Type.ERROR, "Source (" + sourceManager.getClass().getName() + ") and target (" + manager.getClass().getName() + ") deployments are of different type (they represent different runtime strategies)");
}
String auditPu = manager.getDeploymentDescriptor().getAuditPersistenceUnit();
EntityManagerFactory emf = EntityManagerFactoryManager.get().getOrCreate(auditPu);
JPAAuditLogService auditService = new JPAAuditLogService(emf);
try {
ProcessInstanceLog log = auditService.findProcessInstance(migrationSpec.getProcessInstanceId());
if (log == null || log.getStatus() != ProcessInstance.STATE_ACTIVE) {
report.addEntry(Type.ERROR, "No process instance found or it is not active (id " + migrationSpec.getProcessInstanceId() + " in status " + (log == null ? "-1" : log.getStatus()));
}
} finally {
auditService.dispose();
}
}
Aggregations