agave-monitors/monitors-core/src/main/java/org/iplantc/service/monitor/dao/MonitorDao.java
/**
	 * Saves or updates the InternalUser
	 * @param monitor the monitor to persist
	 * @throws MonitorException
	 */
Saves or updates the InternalUser
@param monitor the monitor to persist
@throws MonitorException
Saves or updates the InternalUser @param monitor the monitor to persist @throws MonitorException
public void persist(Monitor monitor) throws MonitorException
	{
		if (monitor == null)
			throw new MonitorException("Monitor cannot be null");
		boolean exceptionThrown = false;
		try
		{	
			HibernateUtil.beginTransaction();
			Session session = HibernateUtil.getSession();
			session.clear();
			session.saveOrUpdate(monitor);
			session.flush();
		}
		catch (ConstraintViolationException ex) {
			exceptionThrown = true;
			throw new MonitorException("A monitor already exists for this user on system " + 
					monitor.getSystem().getSystemId(), ex);
		}
		catch (HibernateException ex)
		{
			exceptionThrown = true;
			try
			{
				if (HibernateUtil.getSession().isOpen()) {
					HibernateUtil.rollbackTransaction();
				}
			}
			catch (Exception ignore) {}
			throw new MonitorException("Failed to save monitor", ex);
		}
		finally {
			try {
				if (!exceptionThrown) {
					HibernateUtil.commitTransaction();
				}
			} catch (Exception ignore) {}
		}
	}
public void persist ( Monitor monitor ) throws MonitorException { if ( monitor == null ) throw new MonitorException ( "Monitor cannot be null" ) ; boolean exceptionThrown = false ; try { HibernateUtil . beginTransaction ( ) ; Session session = HibernateUtil . getSession ( ) ; session . clear ( ) ; session . saveOrUpdate ( monitor ) ; session . flush ( ) ; } catch ( ConstraintViolationException ex ) { exceptionThrown = true ; throw new MonitorException ( "A monitor already exists for this user on system " + monitor . getSystem ( ) . getSystemId ( ) , ex ) ; } catch ( HibernateException ex ) { exceptionThrown = true ; try { if ( HibernateUtil . getSession ( ) . isOpen ( ) ) { HibernateUtil . rollbackTransaction ( ) ; } } catch ( Exception ignore ) { } throw new MonitorException ( "Failed to save monitor" , ex ) ; } finally { try { if ( ! exceptionThrown ) { HibernateUtil . commitTransaction ( ) ; } } catch ( Exception ignore ) { } } }
Saves or updates the InternalUser
 @param monitor the monitor to persist
 @throws MonitorException
Saves or updates the InternalUser @param monitor the monitor to persist @throws MonitorException