List of usage examples for org.springframework.dao DataAccessResourceFailureException getMessage
@Override
@Nullable
public String getMessage()
From source file:com.bcknds.demo.mongo.TodoServiceTests.java
@Before public void setUp() { trash = new Todo("Take out the trash", "Take out the trash", new Date()); dishes = new Todo("Do the dishes", "Do the dishes", new Date()); try {/*from ww w . j a v a2 s .c om*/ todoRepository.deleteAll(); } catch (DataAccessResourceFailureException ex) { LOG.info("Unable to connect to Mongo"); System.exit(1); } catch (Exception ex) { LOG.info(ex.getMessage()); System.exit(1); } }
From source file:net.cit.tetrad.rrd.dao.MongoStatusToMonitorImpl.java
public Set<String> readMongoCollectionName(Mongo mongo, String dbName) throws MongoException, Exception { Set<String> collNameLst = null; try {//from w w w . j a v a 2 s. c om DB db = mongo.getDB(dbName); collNameLst = db.getCollectionNames(); } catch (DataAccessResourceFailureException e) { e.printStackTrace(); throw new MongoException(e.getMessage()); } catch (MongoException e) { e.printStackTrace(); throw e; } catch (Exception e) { e.printStackTrace(); throw e; } finally { } return collNameLst; }
From source file:net.cit.tetrad.rrd.dao.MongoStatusToMonitorImpl.java
public CommandResult getCommandResult(Mongo mongo, Device device, String command, String databaseName) throws MongoException, Exception { CommandResult commandResult = null;/*w ww. j av a 2 s . c om*/ try { DB db = mongo.getDB(databaseName); commandResult = db.command(command); } catch (DataAccessResourceFailureException e) { e.printStackTrace(); throw new MongoException(e.getMessage()); } catch (MongoException e) { // alarm ? e.printStackTrace(); throw e; } catch (Exception e) { e.printStackTrace(); throw e; } finally { } return commandResult; }
From source file:net.cit.tetrad.rrd.dao.MongoStatusToMonitorImpl.java
public String getAllServerStatus(Mongo mongo, Device device, String command, String databaseName) throws MongoException, Exception { String objtoString;/*from w ww. j a v a2s . c o m*/ try { DB db = mongo.getDB(databaseName); CommandResult commandResult = db.command(command); objtoString = commandResult.toString(); } catch (DataAccessResourceFailureException e) { e.printStackTrace(); throw new MongoException(e.getMessage()); } catch (MongoException e) { // alarm ? e.printStackTrace(); throw e; } catch (Exception e) { e.printStackTrace(); throw e; } finally { } return objtoString; }
From source file:net.cit.tetrad.rrd.dao.MongoStatusToMonitorImpl.java
public Map<String, Object> readMongoStatus(Mongo mongo, Device device, String command, String databaseName) throws MongoException, Exception { Map<String, Object> deviceStatus = new HashMap<String, Object>(); try {//from w w w.j a v a2 s .com DB db = mongo.getDB(databaseName); CommandResult commandResult = db.command(command); deviceStatus = JasonUtil.getEntryValue(commandResult, "", deviceStatus); } catch (DataAccessResourceFailureException e) { e.printStackTrace(); throw new MongoException(e.getMessage()); } catch (MongoException e) { // alarm ? e.printStackTrace(); throw e; } catch (Exception e) { e.printStackTrace(); throw e; } finally { } return deviceStatus; }
From source file:net.cit.tetrad.rrd.dao.MongoStatusToMonitorImpl.java
public List<Object> readMongoShards(Mongo mongo, String collection, String databaseName) throws MongoException, Exception { List<Object> dboLst = new ArrayList<Object>(); try {/*from w w w . j a v a 2s. co m*/ DB db = mongo.getDB(databaseName); DBCollection dbcollection = db.getCollectionFromString(collection); DBCursor cr = dbcollection.find(); Iterator<DBObject> it = cr.iterator(); DBObject dbo; while (it.hasNext()) { dbo = it.next(); Map<String, Object> deviceStatus = new HashMap<String, Object>(); deviceStatus = JasonUtil.getEntryValue(dbo, "", deviceStatus); dboLst.add(deviceStatus); } } catch (DataAccessResourceFailureException e) { e.printStackTrace(); throw new MongoException(e.getMessage()); } catch (MongoException e) { e.printStackTrace(); throw e; } catch (Exception e) { e.printStackTrace(); throw e; } finally { } return dboLst; }
From source file:net.cit.tetrad.rrd.dao.MongoStatusToMonitorImpl.java
public List<Object> readMongoChunksGrp(Mongo mongo, String collName, List<Object> dboLst) throws MongoException, Exception { try {//from www . j a va2 s.c o m DB db = mongo.getDB("config"); DBCollection dbcollection = db.getCollectionFromString("chunks"); DBObject dbo = dbcollection.group(new BasicDBObject("shard", true), new BasicDBObject("ns", collName), new BasicDBObject("nChunks", 0), "function (doc, out) {out.nChunks++;}"); Iterator<String> keys = dbo.keySet().iterator(); BasicDBObject getDbo; while (keys.hasNext()) { String key = keys.next(); getDbo = (BasicDBObject) dbo.get(key); getDbo.put("collName", collName); dboLst.add(getDbo); } } catch (DataAccessResourceFailureException e) { e.printStackTrace(); throw new MongoException(e.getMessage()); } catch (MongoException e) { e.printStackTrace(); throw e; } catch (Exception e) { e.printStackTrace(); throw e; } finally { } return dboLst; }
From source file:edu.duke.cabig.c3pr.infrastructure.interceptor.NotificationInterceptor.java
/** * Gets the planned notifications for the list of sites that are passed in. * This method access the db using a new session from the hibernate session factory. * /* w w w . j av a2s . c o m*/ * @param hcsList the hcs list * @return the planned notifications */ public List<PlannedNotification> getPlannedNotifications(List<HealthcareSite> hcsList) { List<PlannedNotification> result; List<String> nciCodeList = new ArrayList<String>(); for (HealthcareSite hcs : hcsList) { if (hcs != null) { nciCodeList.add(hcs.getPrimaryIdentifier()); } } SessionFactory sessionFactory = (SessionFactory) applicationContext.getBean("sessionFactory"); Session session = sessionFactory.openSession(sessionFactory.getCurrentSession().connection()); session.setFlushMode(FlushMode.MANUAL); result = new ArrayList<PlannedNotification>(); try { Query query = session.createQuery( "select p from PlannedNotification p, HealthcareSite o, Identifier i where p = any elements(o.plannedNotificationsInternal) and " + "i = any elements(o.identifiersAssignedToOrganization) and i.primaryIndicator = 'true' and " + "i.value in (:nciCodeList)") .setParameterList("nciCodeList", nciCodeList); result = query.list(); } catch (DataAccessResourceFailureException e) { log.error(e.getMessage()); } catch (IllegalStateException e) { e.printStackTrace(); } catch (HibernateException e) { log.error(e.getMessage()); } catch (Exception e) { log.error(e.getMessage()); } finally { session.close(); } return result; }
From source file:edu.duke.cabig.c3pr.infrastructure.interceptor.NotificationInterceptor.java
/** * Gets the planned notifications for the list of sites that are passed in. * This method access the db using a new session from the hibernate session factory. * /*from w ww. j a va 2 s.com*/ * @param hcsList the hcs list * @return the planned notifications */ public List<PlannedNotification> getPlannedNotificationsForUpdateMasterSubject() { List<PlannedNotification> result; SessionFactory sessionFactory = (SessionFactory) applicationContext.getBean("sessionFactory"); Session session = sessionFactory.openSession(sessionFactory.getCurrentSession().connection()); session.setFlushMode(FlushMode.MANUAL); result = new ArrayList<PlannedNotification>(); try { Query query = session.createQuery("from PlannedNotification p where p.eventName = :var") .setString("var", NotificationEventTypeEnum.MASTER_SUBJECT_UPDATED_EVENT.toString()); result = query.list(); } catch (DataAccessResourceFailureException e) { log.error(e.getMessage()); } catch (IllegalStateException e) { e.printStackTrace(); } catch (HibernateException e) { log.error(e.getMessage()); } catch (Exception e) { log.error(e.getMessage()); } finally { session.close(); } return result; }
From source file:edu.duke.cabig.c3pr.infrastructure.interceptor.NotificationInterceptor.java
public List<PlannedNotification> getPlannedNotificationsForCorrespondence() { List<PlannedNotification> result; SessionFactory sessionFactory = (SessionFactory) applicationContext.getBean("sessionFactory"); Session session = sessionFactory.openSession(sessionFactory.getCurrentSession().connection()); session.setFlushMode(FlushMode.MANUAL); result = new ArrayList<PlannedNotification>(); try {/*from ww w . j a v a 2 s .c om*/ Query query = session.createQuery( "from PlannedNotification p left join fetch p.userBasedRecipientInternal where p.eventName = :var") .setString("var", NotificationEventTypeEnum.CORRESPONDENCE_CREATED_OR_UPDATED_EVENT.toString()); result = query.list().subList(0, 1); } catch (DataAccessResourceFailureException e) { log.error(e.getMessage()); } catch (IllegalStateException e) { e.printStackTrace(); } catch (HibernateException e) { log.error(e.getMessage()); } catch (Exception e) { log.error(e.getMessage()); } finally { session.close(); } return result; }