/** * Returns current workflows, i.e., workflows that are active. * * @param userPrincipal a user principal * @return a list of WorkflowVOs representing all active workflows * @throws SystemException if an error occurs while finding the current workflows */ public List<WorkflowVO> getCurrentWorkflowVOList(InfoGluePrincipal userPrincipal) throws SystemException { List<WorkflowVO> list = new ArrayList<WorkflowVO>(); Session session = null; net.sf.hibernate.Transaction tx = null; try { session = hibernateSessionFactory.openSession(); tx = session.beginTransaction(); WorkflowFacade wf = new WorkflowFacade(userPrincipal, hibernateSessionFactory, session); list = wf.getActiveWorkflows(); session.flush(); tx.commit(); } catch (Exception e) { logger.error( "An error occurred when we tries to execute getCurrentWorkflowVOList():" + 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 list; }