/** * Returns true if the workflow has terminated; false otherwise. * * @param workflowVO the workflow. * @return true if the workflow has terminated; false otherwise. */ public boolean hasTerminated(InfoGluePrincipal userPrincipal, long workflowId) throws WorkflowException { boolean isFinished = false; Session session = null; net.sf.hibernate.Transaction tx = null; try { session = hibernateSessionFactory.openSession(); tx = session.beginTransaction(); WorkflowFacade wf = new WorkflowFacade(userPrincipal, workflowId, hibernateSessionFactory, session); isFinished = wf.isFinished(); session.flush(); tx.commit(); } catch (Exception e) { logger.error("An error occurred when we tries to run hasTerminated:" + e.getMessage(), e); try { tx.rollback(); } catch (HibernateException he) { logger.error( "An error occurred when we tries to rollback transaction:" + he.getMessage(), he); } restoreSessionFactory(e); } finally { try { session.close(); } catch (HibernateException e) { logger.error("An error occurred when we tries to close session:" + e.getMessage(), e); } } return isFinished; // return new WorkflowFacade(userPrincipal, workflowId, true).isFinished(); }