private synchronized void persistWorkflowInstance(WorkflowInstance wInst) throws EngineException { try { if (wInst.getId() == null || (wInst.getId() != null && wInst.getId().equals(""))) { // we have to persist it by adding it // rather than updating it instRep.addWorkflowInstance(wInst); } else { // persist by update instRep.updateWorkflowInstance(wInst); } } catch (InstanceRepositoryException e) { e.printStackTrace(); throw new EngineException(e.getMessage()); } }