Example usage for javax.persistence EntityExistsException getClass

List of usage examples for javax.persistence EntityExistsException getClass

Introduction

In this page you can find the example usage for javax.persistence EntityExistsException getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:com.clustercontrol.notify.util.MonitorResultStatusUpdater.java

/**
 * ?????????????????DB?????????/*from  w w  w.  j av  a 2s . c  om*/
 * ????true?
 * ?????????????DB
 * ????false?
 *
 * @param facilityId ID
 * @param pluginId ID
 * @param monitorId ID
 * @param generateDate ??
 * @param currentPriority ??????
 * @return ???:true / :false
 */
private static boolean update(String facilityId, String pluginId, String monitorId, String subkey,
        Long generateDate, int currentPriority) {
    m_log.debug("update() facilityId = " + facilityId + ", pluginId = " + pluginId + ", monitorId = "
            + monitorId + ", subkey = " + subkey + ", generateDate = " + generateDate + ", currentPriority = "
            + currentPriority);

    MonitorStatusPK pk = new MonitorStatusPK(facilityId, pluginId, monitorId, subkey);

    MonitorStatusEntity monitorStatus = MonitorStatusCache.get(pk);
    if (monitorStatus == null) {
        m_log.debug("create new entity. " + pk);

        // ??
        try {
            // ????1??
            // ?
            monitorStatus = new MonitorStatusEntity(facilityId, pluginId, monitorId, subkey);
            // ??
            monitorStatus.setPriority(currentPriority);
            monitorStatus.setLastUpdate(generateDate);
            monitorStatus.setCounter(1l);
            MonitorStatusCache.add(monitorStatus);
            return true;
        } catch (EntityExistsException e1) {
            m_log.info("update() : " + e1.getClass().getSimpleName() + ", " + e1.getMessage());
            return true;
        }
    }

    // ????????
    if (currentPriority != monitorStatus.getPriority()) {
        if (m_log.isDebugEnabled()) {
            m_log.debug("prioityChangeFlag = true. " + pk + " ," + monitorStatus.getPriority() + " to "
                    + currentPriority);
        }

        // ??
        monitorStatus.setPriority(currentPriority);

        // ???1?
        monitorStatus.setCounter(1l);
        MonitorStatusCache.update(monitorStatus);

        return true;
    } else {
        // ????????
        // 50???????
    }

    // ???
    long oldCount = monitorStatus.getCounter();
    // ????????????????
    int maxInitialCount = HinemosPropertyUtil
            .getHinemosPropertyNum("notify.initial.count.max", Long.valueOf(10)).intValue();

    // ?????????DB??update????
    if (oldCount <= maxInitialCount) {
        monitorStatus.setCounter(oldCount + 1);
        monitorStatus.setLastUpdate(generateDate);
        MonitorStatusCache.update(monitorStatus);
    }
    return false;
}

From source file:com.clustercontrol.performance.factory.OperateCollectCalcMaster.java

/**
 * ???//  ww  w. jav  a2  s  .  c  om
 * 
 * @param data 
 * @return ?????true
 * @throws EntityExistsException
 * 
 */
public boolean add(CollectorCalcMethodMstData data) throws EntityExistsException {

    JpaTransactionManager jtm = new JpaTransactionManager();

    // ?
    try {
        // ?
        CollectorCalcMethodMstEntity entity = new CollectorCalcMethodMstEntity(data.getCalcMethod());
        // ??
        jtm.checkEntityExists(CollectorCalcMethodMstEntity.class, entity.getCalcMethod());
        entity.setClassName(data.getClassName());
        entity.setExpression(data.getExpression());
    } catch (EntityExistsException e) {
        m_log.info("add() : " + e.getClass().getSimpleName() + ", " + e.getMessage());
        throw e;
    }
    return true;
}

From source file:com.clustercontrol.performance.factory.OperateCollectCategoryMaster.java

/**
 * ????/*from  ww w . j a va 2  s .co  m*/
 * 
 * @param data ?
 * @return ?????true
 * @throws EntityExistsException
 * 
 */
public boolean add(CollectorCategoryMstData data) throws EntityExistsException {

    JpaTransactionManager jtm = new JpaTransactionManager();

    // ??
    try {
        // ?
        CollectorCategoryMstEntity entity = new CollectorCategoryMstEntity(data.getCategoryCode());
        // ??
        jtm.checkEntityExists(CollectorCategoryMstEntity.class, entity.getCategoryCode());
        entity.setCategoryName(data.getCategoryName());
    } catch (EntityExistsException e) {
        m_log.info("add() : " + e.getClass().getSimpleName() + ", " + e.getMessage());
        throw e;
    }

    return true;
}

From source file:com.clustercontrol.maintenance.factory.ModifyHinemosProperty.java

/**
 * ???//from w  w w  .j  a va2 s .com
 *
 * @param info 
 * @param loginUser ??
 * @return
 * @throws EntityExistsException
 * @throws HinemosUnknown
 */
public boolean addHinemosProperty(HinemosPropertyInfo info, String loginUser)
        throws EntityExistsException, InvalidRole, HinemosUnknown {

    JpaTransactionManager jtm = new JpaTransactionManager();

    // Entity??
    try {
        // ??
        jtm.checkEntityExists(HinemosPropertyInfo.class, info.getKey());
        jtm.getEntityManager().persist(info);

        long now = HinemosTime.currentTimeMillis();

        info.setCreateUserId(loginUser);
        info.setCreateDatetime(now);
        info.setModifyUserId(loginUser);
        info.setModifyDatetime(now);
    } catch (EntityExistsException e) {
        m_log.info("addHinemosProperty() : " + e.getClass().getSimpleName() + ", " + e.getMessage(), e);
        throw e;
    }

    return true;
}

From source file:com.clustercontrol.performance.factory.OperateCollectCategoryCollectMaster.java

/**
 * ????/* w  w w.  ja  va2 s  .  co m*/
 * 
 * @param data ?
 * @return ?????true
 * @throws EntityExistsException
 * @throws CollectorNotFound
 * @throws FacilityNotFound
 * 
 */
public boolean add(CollectorCategoryCollectMstData data)
        throws EntityExistsException, CollectorNotFound, FacilityNotFound {

    JpaTransactionManager jtm = new JpaTransactionManager();

    // ??
    try {
        CollectorCategoryMstEntity collectorCategoryMstEntity = QueryUtil
                .getCollectorCategoryMstPK(data.getCategoryCode());
        CollectorPlatformMstEntity collectorPlatformMstEntity = com.clustercontrol.repository.util.QueryUtil
                .getCollectorPlatformMstPK(data.getPlatformId());

        // ?
        CollectorCategoryCollectMstEntity entity = new CollectorCategoryCollectMstEntity(
                collectorPlatformMstEntity, collectorCategoryMstEntity, data.getSubPlatformId());
        // ??
        jtm.checkEntityExists(CollectorCategoryCollectMstEntity.class, entity.getId());
        entity.setCollectMethod(data.getCollectMethod());
    } catch (EntityExistsException e) {
        m_log.info("add() : " + e.getClass().getSimpleName() + ", " + e.getMessage());
        throw e;
    } catch (CollectorNotFound e) {
        m_log.info("add() : " + e.getClass().getSimpleName() + ", " + e.getMessage());
        throw e;
    } catch (FacilityNotFound e) {
        m_log.info("add() : " + e.getClass().getSimpleName() + ", " + e.getMessage());
        throw e;
    }

    return true;
}

From source file:com.clustercontrol.notify.mail.factory.ModifyMailTemplate.java

/**
 * ????/*from   ww  w  .  j a v  a2 s . c om*/
 * <p>
 * <ol>
 *  <li>????</li>
 * </ol>
 * 
 * @param info ??
 * @param name ?????
 * @return ???????<code> true </code>
 * @throws MailTemplateDuplicate
 * 
 * @see com.clustercontrol.notify.ejb.entity.MailTemplateInfoBean
 */
public boolean add(MailTemplateInfo data, String name) throws MailTemplateDuplicate {

    JpaTransactionManager jtm = new JpaTransactionManager();

    long now = HinemosTime.currentTimeMillis();

    //Bean
    try {
        // ??
        jtm.checkEntityExists(MailTemplateInfo.class, data.getMailTemplateId());
        data.setRegDate(now);
        data.setRegUser(name);
        data.setUpdateDate(now);
        data.setUpdateUser(name);

        HinemosEntityManager em = new JpaTransactionManager().getEntityManager();
        em.persist(data);
    } catch (EntityExistsException e) {
        m_log.info("add() : " + e.getClass().getSimpleName() + ", " + e.getMessage());
        throw new MailTemplateDuplicate(e.getMessage(), e);
    }

    return true;
}

From source file:com.clustercontrol.notify.factory.ModifyNotify.java

/**
 * ????//ww  w. j  a v  a2 s. co  m
 * <p>
 * <ol>
 *  <li>????</li>
 *  <li>???????</li>
 *  <li>?????????
 *      ??????????????</li>
 * </ol>
 * 
 * @param info ??
 * @return ???????<code> true </code>
 * @throws HinemosUnknown
 * @throws NotifyDuplicate
 * 
 * @see com.clustercontrol.notify.ejb.entity.NotifyInfoBean
 * @see com.clustercontrol.notify.ejb.entity.NotifyEventInfoBean
 */
public boolean add(NotifyInfo info, String user) throws HinemosUnknown, NotifyDuplicate {
    m_log.debug("add " + "NotifyID = " + info.getNotifyId());

    JpaTransactionManager jtm = new JpaTransactionManager();

    try {
        long now = HinemosTime.currentTimeMillis();

        // ??
        jtm.checkEntityExists(NotifyInfo.class, info.getNotifyId());

        info.setRegDate(now);
        info.setRegUser(user);
        info.setUpdateDate(now);
        info.setUpdateUser(user);

        info.persistSelf(jtm.getEntityManager());
    } catch (EntityExistsException e) {
        m_log.info("add() : " + e.getClass().getSimpleName() + ", " + e.getMessage());
        throw new NotifyDuplicate(e.getMessage(), e);
    } catch (Exception e) {
        m_log.warn("add() : " + e.getClass().getSimpleName() + ", " + e.getMessage(), e);
        throw new HinemosUnknown(e.getMessage(), e);
    }

    return true;
}

From source file:com.clustercontrol.jmx.session.JmxMasterControllerBean.java

/**
 * JMX ???/*from  w  w  w  .  ja  va2  s.c  om*/
 * 
 * @param datas JMX 
 * @return ??????true
 * @throws HinemosUnknown
 * @throws InvalidSetting
 */
public boolean addJmxMasterList(List<JmxMasterInfo> datas) throws HinemosUnknown, InvalidSetting {
    boolean ret = false;

    for (JmxMasterInfo m : datas) {
        validateJmxMasterInfo(m);
    }

    JpaTransactionManager jtm = new JpaTransactionManager();
    try {
        jtm.begin();

        // ?
        for (JmxMasterInfo data : datas) {
            // ??
            jtm.checkEntityExists(JmxMasterInfo.class, data.getId());
            jtm.getEntityManager().persist(data);
        }

        jtm.commit();

        ret = true;
    } catch (EntityExistsException e) {
        jtm.rollback();
        throw new HinemosUnknown(e.getMessage(), e);
    } catch (Exception e) {
        m_log.warn("addJmxMasterList() : " + e.getClass().getSimpleName() + ", " + e.getMessage(), e);
        jtm.rollback();
        throw new HinemosUnknown(e.getMessage(), e);
    } finally {
        if (jtm != null) {
            jtm.close();
        }
    }

    return ret;
}

From source file:com.clustercontrol.repository.factory.FacilityModifier.java

/** ?<BR>
 *
 * @param CollectorPlatformMstData //from   www  .ja va2s . co  m
 * @throws CollectorPlatformMstData
 * @throws EntityExistsException
 */
public static void addCollectorPratformMst(CollectorPlatformMstData data) throws EntityExistsException {
    JpaTransactionManager jtm = new JpaTransactionManager();

    try {
        // ?
        CollectorPlatformMstEntity entity = new CollectorPlatformMstEntity(data.getPlatformId());
        // ??
        jtm.checkEntityExists(CollectorPlatformMstEntity.class, entity.getPlatformId());
        entity.setOrderNo(data.getOrderNo().intValue());
        entity.setPlatformName(data.getPlatformName());
    } catch (EntityExistsException e) {
        m_log.info("addCollectorPratformMst() : " + e.getClass().getSimpleName() + ", " + e.getMessage());
        throw e;
    }
}

From source file:com.clustercontrol.repository.factory.FacilityModifier.java

/** ?<BR>
 *
 * @param addCollectorSubPratformMst //from w ww .ja  v a 2 s . co  m
 * @throws addCollectorSubPratformMst
 * @throws EntityExistsException
 */
public static void addCollectorSubPratformMst(CollectorSubPlatformMstData data) throws EntityExistsException {
    JpaTransactionManager jtm = new JpaTransactionManager();

    try {
        // ?
        CollectorSubPlatformMstEntity entity = new CollectorSubPlatformMstEntity(data.getSubPlatformId());
        // ??
        jtm.checkEntityExists(CollectorSubPlatformMstEntity.class, entity.getSubPlatformId());
        entity.setSubPlatformName(data.getSubPlatformName());
        entity.setType(data.getType());
        entity.setOrderNo(data.getOrderNo());
    } catch (EntityExistsException e) {
        m_log.info("addCollectorSubPratformMst() : " + e.getClass().getSimpleName() + ", " + e.getMessage());
        throw e;
    }
}