List of usage examples for javax.persistence EntityExistsException getMessage
public String getMessage()
From source file:com.clustercontrol.notify.util.MonitorResultStatusUpdater.java
/** * ?????????????????DB?????????/*from w ww . j a v a2s .co m*/ * ????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
/** * ???/*from w w w .ja v a 2 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 w w w. j a v a 2s .c o 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 ww . j a va 2s . c o m * * @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
/** * ????//from w w w. j a v a 2s . c o 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 w w w . j av a 2s .c o m*/ * <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.jmx.session.JmxMasterControllerBean.java
/** * JMX ???//from w ww . j a v a 2s . 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.jobmanagement.factory.OperateMaintenanceOfJob.java
/** * ?[]???//from w w w .j a va2s.c om * * @param sessionId ID * @param jobunitId ?ID * @param jobId ID * @param facilityId ID * @param endValue * @throws JobInfoNotFound * @throws InvalidRole * @throws HinemosUnknown */ public void maintenanceNode(String sessionId, String jobunitId, String jobId, String facilityId, Integer endValue) throws JobInfoNotFound, InvalidRole, HinemosUnknown { m_log.debug("maintenanceJob() : sessionId=" + sessionId + ", jobunitId=" + jobunitId + ", jobId=" + jobId + ", facilityId=" + facilityId + ", endValue=" + endValue); //ID?ID??? JobSessionNodeEntity sessionNode = QueryUtil.getJobSessionNodePK(sessionId, jobunitId, jobId, facilityId); if (sessionNode != null) { //?????????? if (sessionNode.getStatus() == StatusConstant.TYPE_RUNNING) { JpaTransactionManager jtm = new JpaTransactionManager(); jtm.addCallback(new FromRunningAfterCommitCallback(sessionNode.getId())); } else if (sessionNode.getStatus() == StatusConstant.TYPE_WAIT) { JobMultiplicityCache.removeWait(sessionNode.getId()); } //?? sessionNode.setStatus(StatusConstant.TYPE_MODIFIED); // sessionNode.setEndValue(endValue); // sessionNode.setEndDate(HinemosTime.currentTimeMillis()); //? try { new JobSessionNodeImpl().endNodeFinish(sessionId, jobunitId, jobId, facilityId, null, null); } catch (EntityExistsException e) { // TODO // throw?ExceptionHinemosUnknown?????????? m_log.warn("maintenanceNode " + e, e); throw new HinemosUnknown(e.getMessage(), e); } catch (FacilityNotFound e) { m_log.warn("maintenanceNode " + e, e); throw new HinemosUnknown(e.getMessage(), e); } } }
From source file:com.clustercontrol.jobmanagement.factory.OperateForceStopOfJob.java
/** * ?[]???/* w w w.java 2 s.com*/ * * @param sessionId ID * @param jobunitId ?ID * @param jobId ID * @param facilityId ID * @param endValue * @throws JobInfoNotFound * @throws InvalidRole * @throws HinemosUnknown */ public void forceStopNode(String sessionId, String jobunitId, String jobId, String facilityId, Integer endValue) throws JobInfoNotFound, InvalidRole, HinemosUnknown { m_log.debug("forceStopJob() : sessionId=" + sessionId + ", jobunitId=" + jobunitId + ", jobId=" + jobId + ", facilityId=" + facilityId + ", endValue=" + endValue); forceStopNode2(sessionId, jobunitId, jobId, facilityId, endValue); //? try { new JobSessionNodeImpl().endNodeFinish(sessionId, jobunitId, jobId, facilityId, null, null); } catch (EntityExistsException e) { // TODO // throw?ExceptionHinemosUnknown?????????? m_log.warn("maintenanceNode " + e, e); throw new HinemosUnknown(e.getMessage(), e); } catch (FacilityNotFound e) { m_log.warn("maintenanceNode " + e, e); throw new HinemosUnknown(e.getMessage(), e); } }
From source file:com.clustercontrol.notify.factory.ModifyNotify.java
/** * ????//from w ww . ja v a 2 s . c o 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; }