List of usage examples for org.hibernate Session load
void load(Object object, Serializable id);
From source file:com.ikon.dao.NodeBaseDAO.java
License:Open Source License
/** * Test for category in a node// w w w .j av a2 s. c o m */ public boolean hasCategory(String uuid, String catId) throws PathNotFoundException, DatabaseException { log.debug("hasCategory({}, {})", uuid, catId); Session session = null; Transaction tx = null; boolean check; try { session = HibernateUtil.getSessionFactory().openSession(); tx = session.beginTransaction(); // Security Check NodeBase node = (NodeBase) session.load(NodeBase.class, uuid); SecurityHelper.checkRead(node); check = node.getCategories().contains(catId); HibernateUtil.commit(tx); log.debug("hasCategory: {}", check); return check; } catch (PathNotFoundException e) { HibernateUtil.rollback(tx); throw e; } catch (DatabaseException e) { HibernateUtil.rollback(tx); throw e; } catch (HibernateException e) { HibernateUtil.rollback(tx); throw new DatabaseException(e.getMessage(), e); } finally { HibernateUtil.close(session); } }
From source file:com.ikon.dao.NodeBaseDAO.java
License:Open Source License
/** * Add keyword to node/*from w ww .ja v a 2 s .c o m*/ */ public void addKeyword(String uuid, String keyword) throws PathNotFoundException, AccessDeniedException, DatabaseException { log.debug("addKeyword({}, {})", uuid, keyword); Session session = null; Transaction tx = null; try { session = HibernateUtil.getSessionFactory().openSession(); tx = session.beginTransaction(); // Security Check NodeBase node = (NodeBase) session.load(NodeBase.class, uuid); SecurityHelper.checkRead(node); SecurityHelper.checkWrite(node); if (!node.getKeywords().contains(keyword)) { node.getKeywords().add(keyword); } session.update(node); HibernateUtil.commit(tx); log.debug("addKeyword: void"); } catch (PathNotFoundException e) { HibernateUtil.rollback(tx); throw e; } catch (AccessDeniedException e) { HibernateUtil.rollback(tx); throw e; } catch (DatabaseException e) { HibernateUtil.rollback(tx); throw e; } catch (HibernateException e) { HibernateUtil.rollback(tx); throw new DatabaseException(e.getMessage(), e); } finally { HibernateUtil.close(session); } }
From source file:com.ikon.dao.NodeBaseDAO.java
License:Open Source License
/** * Remove keyword from node/*from ww w . j a va 2 s. c o m*/ */ public void removeKeyword(String uuid, String keyword) throws PathNotFoundException, AccessDeniedException, DatabaseException { log.debug("removeCategory({}, {})", uuid, keyword); Session session = null; Transaction tx = null; try { session = HibernateUtil.getSessionFactory().openSession(); tx = session.beginTransaction(); // Security Check NodeBase node = (NodeBase) session.load(NodeBase.class, uuid); SecurityHelper.checkRead(node); SecurityHelper.checkWrite(node); node.getKeywords().remove(keyword); session.update(node); HibernateUtil.commit(tx); log.debug("removeCategory: void"); } catch (PathNotFoundException e) { HibernateUtil.rollback(tx); throw e; } catch (AccessDeniedException e) { HibernateUtil.rollback(tx); throw e; } catch (DatabaseException e) { HibernateUtil.rollback(tx); throw e; } catch (HibernateException e) { HibernateUtil.rollback(tx); throw new DatabaseException(e.getMessage(), e); } finally { HibernateUtil.close(session); } }
From source file:com.ikon.dao.NodeBaseDAO.java
License:Open Source License
/** * Test for category in a node//www . ja v a 2 s .c om */ public boolean hasKeyword(String uuid, String keyword) throws PathNotFoundException, DatabaseException { log.debug("hasKeyword({}, {})", uuid, keyword); Session session = null; Transaction tx = null; boolean check; try { session = HibernateUtil.getSessionFactory().openSession(); tx = session.beginTransaction(); // Security Check NodeBase node = (NodeBase) session.load(NodeBase.class, uuid); SecurityHelper.checkRead(node); check = node.getKeywords().contains(keyword); HibernateUtil.commit(tx); log.debug("hasKeyword: {}", check); return check; } catch (PathNotFoundException e) { HibernateUtil.rollback(tx); throw e; } catch (DatabaseException e) { HibernateUtil.rollback(tx); throw e; } catch (HibernateException e) { HibernateUtil.rollback(tx); throw new DatabaseException(e.getMessage(), e); } finally { HibernateUtil.close(session); } }
From source file:com.ikon.dao.NodeBaseDAO.java
License:Open Source License
/** * Subscribe user to node// ww w. j av a2 s .co m */ public void subscribe(String uuid, String user) throws PathNotFoundException, DatabaseException { log.debug("subscribe({}, {})", uuid, user); Session session = null; Transaction tx = null; try { session = HibernateUtil.getSessionFactory().openSession(); tx = session.beginTransaction(); // Security Check NodeBase node = (NodeBase) session.load(NodeBase.class, uuid); SecurityHelper.checkRead(node); if (!node.getSubscriptors().contains(user)) { node.getSubscriptors().add(user); } session.update(node); HibernateUtil.commit(tx); log.debug("subscribe: void"); } catch (PathNotFoundException e) { HibernateUtil.rollback(tx); throw e; } catch (DatabaseException e) { HibernateUtil.rollback(tx); throw e; } catch (HibernateException e) { HibernateUtil.rollback(tx); throw new DatabaseException(e.getMessage(), e); } finally { HibernateUtil.close(session); } }
From source file:com.ikon.dao.NodeBaseDAO.java
License:Open Source License
/** * Remove user subscription/*from ww w. jav a 2 s . c o m*/ */ public void unsubscribe(String uuid, String user) throws PathNotFoundException, DatabaseException { log.debug("unsubscribe({}, {})", uuid, user); Session session = null; Transaction tx = null; try { session = HibernateUtil.getSessionFactory().openSession(); tx = session.beginTransaction(); // Security Check NodeBase node = (NodeBase) session.load(NodeBase.class, uuid); SecurityHelper.checkRead(node); node.getSubscriptors().remove(user); session.update(node); HibernateUtil.commit(tx); log.debug("unsubscribe: void"); } catch (PathNotFoundException e) { HibernateUtil.rollback(tx); throw e; } catch (DatabaseException e) { HibernateUtil.rollback(tx); throw e; } catch (HibernateException e) { HibernateUtil.rollback(tx); throw new DatabaseException(e.getMessage(), e); } finally { HibernateUtil.close(session); } }
From source file:com.ikon.dao.NodeBaseDAO.java
License:Open Source License
/** * Get node subscriptors/*from w ww . j a v a 2 s. c o m*/ */ public Set<String> getSubscriptors(String uuid) throws PathNotFoundException, DatabaseException { log.debug("getSubscriptors({})", uuid); Session session = null; try { session = HibernateUtil.getSessionFactory().openSession(); // Security Check NodeBase node = (NodeBase) session.load(NodeBase.class, uuid); SecurityHelper.checkRead(node); Set<String> subscriptors = node.getSubscriptors(); Hibernate.initialize(subscriptors); log.debug("getSubscriptors: {}", subscriptors); return subscriptors; } catch (PathNotFoundException e) { throw e; } catch (HibernateException e) { throw new DatabaseException(e.getMessage(), e); } finally { HibernateUtil.close(session); } }
From source file:com.ikon.dao.NodeBaseDAO.java
License:Open Source License
/** * Set node script//from www. ja va 2 s .c o m */ public void setScript(String uuid, String code) throws PathNotFoundException, AccessDeniedException, DatabaseException { log.debug("setScript({}, {})", uuid, code); Session session = null; Transaction tx = null; try { session = HibernateUtil.getSessionFactory().openSession(); tx = session.beginTransaction(); // Security Check NodeBase node = (NodeBase) session.load(NodeBase.class, uuid); SecurityHelper.checkRead(node); SecurityHelper.checkWrite(node); node.setScripting(true); node.setScriptCode(code); session.update(node); HibernateUtil.commit(tx); log.debug("setScript: void"); } catch (PathNotFoundException e) { HibernateUtil.rollback(tx); throw e; } catch (AccessDeniedException e) { HibernateUtil.rollback(tx); throw e; } catch (DatabaseException e) { HibernateUtil.rollback(tx); throw e; } catch (HibernateException e) { HibernateUtil.rollback(tx); throw new DatabaseException(e.getMessage(), e); } finally { HibernateUtil.close(session); } }
From source file:com.ikon.dao.NodeBaseDAO.java
License:Open Source License
/** * Remove node script/* ww w . j a va 2 s .c o m*/ */ public void removeScript(String uuid) throws PathNotFoundException, AccessDeniedException, DatabaseException { log.debug("removeScript({}, {})", uuid); Session session = null; Transaction tx = null; try { session = HibernateUtil.getSessionFactory().openSession(); tx = session.beginTransaction(); // Security Check NodeBase node = (NodeBase) session.load(NodeBase.class, uuid); SecurityHelper.checkRead(node); SecurityHelper.checkWrite(node); node.setScripting(false); node.setScriptCode(null); session.update(node); HibernateUtil.commit(tx); log.debug("removeScript: void"); } catch (PathNotFoundException e) { HibernateUtil.rollback(tx); throw e; } catch (AccessDeniedException e) { HibernateUtil.rollback(tx); throw e; } catch (DatabaseException e) { HibernateUtil.rollback(tx); throw e; } catch (HibernateException e) { HibernateUtil.rollback(tx); throw new DatabaseException(e.getMessage(), e); } finally { HibernateUtil.close(session); } }
From source file:com.ikon.dao.NodeBaseDAO.java
License:Open Source License
/** * Obtain script code//w w w . j av a 2s.c o m */ public String getScript(String uuid) throws PathNotFoundException, DatabaseException { log.debug("setScript({}, {})", uuid); Session session = null; try { session = HibernateUtil.getSessionFactory().openSession(); // Security Check NodeBase node = (NodeBase) session.load(NodeBase.class, uuid); SecurityHelper.checkRead(node); String code = node.getScriptCode(); log.debug("setScript: {}", code); return code; } catch (PathNotFoundException e) { throw e; } catch (HibernateException e) { throw new DatabaseException(e.getMessage(), e); } finally { HibernateUtil.close(session); } }