use of io.automatiko.engine.api.workflow.ProcessInstanceDuplicatedException in project automatiko-engine by automatiko-io.
the class FileSystemProcessInstances method create.
@SuppressWarnings("unchecked")
@Override
public void create(String id, ProcessInstance instance) {
String resolvedId = resolveId(id, instance);
if (isActive(instance)) {
Path processInstanceStorage = Paths.get(storage.toString(), resolvedId);
if (Files.exists(processInstanceStorage)) {
throw new ProcessInstanceDuplicatedException(id);
}
cachedInstances.remove(resolvedId);
cachedInstances.remove(id);
storeProcessInstance(processInstanceStorage, instance);
} else if (isPending(instance)) {
if (cachedInstances.putIfAbsent(resolvedId, instance) != null) {
throw new ProcessInstanceDuplicatedException(id);
}
} else {
cachedInstances.remove(resolvedId);
cachedInstances.remove(id);
}
}
Aggregations