Search in sources :

Example 16 with ProcessInstanceDuplicatedException

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);
    }
}
Also used : Path(java.nio.file.Path) ProcessInstanceDuplicatedException(io.automatiko.engine.api.workflow.ProcessInstanceDuplicatedException)

Aggregations

ProcessInstanceDuplicatedException (io.automatiko.engine.api.workflow.ProcessInstanceDuplicatedException)16 ProcessInstance (io.automatiko.engine.api.workflow.ProcessInstance)9 AbstractProcessInstance (io.automatiko.engine.workflow.AbstractProcessInstance)9 ExportedProcessInstance (io.automatiko.engine.api.workflow.ExportedProcessInstance)6 TrustedIdentityProvider (io.automatiko.engine.api.auth.TrustedIdentityProvider)3 LinkedHashSet (java.util.LinkedHashSet)3 Model (io.automatiko.engine.api.Model)2 WorkflowProcessInstance (io.automatiko.engine.api.runtime.process.WorkflowProcessInstance)2 IOException (java.io.IOException)2 UncheckedIOException (java.io.UncheckedIOException)2 Collection (java.util.Collection)2 HashMap (java.util.HashMap)2 Document (org.bson.Document)2 ResultSet (com.datastax.oss.driver.api.core.cql.ResultSet)1 QueryExecutionException (com.datastax.oss.driver.api.core.servererrors.QueryExecutionException)1 Insert (com.datastax.oss.driver.api.querybuilder.insert.Insert)1 ConflictingVersionException (io.automatiko.engine.api.workflow.ConflictingVersionException)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 Optional (java.util.Optional)1