List of usage examples for org.apache.commons.lang3.exception ExceptionUtils getStackTrace
public static String getStackTrace(final Throwable throwable)
Gets the stack trace from a Throwable as a String.
The result of this method vary by JDK version as this method uses Throwable#printStackTrace(java.io.PrintWriter) .
From source file:ke.co.tawi.babblesms.server.persistence.accounts.StatusDAO.java
/** * @see ke.co.tawi.babblesms.server.persistence.accounts.BabbleStatusDAO#getAllStatus() *//*from w w w . j ava2 s . c o m*/ @Override public List<Status> getAllStatus() { List<Status> list = null; try (Connection conn = dbCredentials.getConnection(); PreparedStatement pstmt = conn.prepareStatement("SELECT * FROM Status;"); ResultSet rset = pstmt.executeQuery();) { list = beanProcessor.toBeanList(rset, Status.class); } catch (SQLException e) { logger.error("SQLException when getting all Status"); logger.error(ExceptionUtils.getStackTrace(e)); } return list; }
From source file:com.aurel.track.vc.cvss.ExtConnection.java
@Override public void verify() { try {/*from w w w. ja va 2s.co m*/ open(); verifyProtocol(); close(); } catch (Exception e) { LOGGER.error(ExceptionUtils.getStackTrace(e)); } }
From source file:com.cynertia.track.iCalendar.ICalendarSynchronizeAction.java
public String sendIcs() { if (!ApplicationStarter.getInstance().isServerReady()) { return ""; }//from w w w . j a va2s . c om HttpServletRequest request = org.apache.struts2.ServletActionContext.getRequest(); TPersonBean user = this.authenticate(request); if (user == null) { LOGGER.error("User not found or invalid password"); return null; } String project = ""; try { project = request.getParameter("project").trim(); } catch (Exception ex) { LOGGER.error("Missing project parameter in iCalendarURL of user " + user.getFullName()); } Calendar calendar = null; try { calendar = generateCalendar(user, project); } catch (Exception e) { LOGGER.error(ExceptionUtils.getStackTrace(e)); } if (calendar == null) { LOGGER.error("Error generating the calendar"); return null; } HttpServletResponse response = org.apache.struts2.ServletActionContext.getResponse(); response.setContentType("text/calendar"); response.setCharacterEncoding("UTF-8"); response.setHeader("Content-Disposition", "inline; filename=\"TrackPlusCalendar.ics\""); final CalendarOutputter calendarOutputter = new CalendarOutputter(false); try { calendarOutputter.output(calendar, response.getOutputStream()); LOGGER.debug("ICalendar Plugin: Sent Calendar for Projects '" + project + "' to " + user.getFullName()); } catch (Exception e) { LOGGER.error(ExceptionUtils.getStackTrace(e)); } return null; }
From source file:com.aurel.track.fieldType.runtime.custom.text.CustomDoubleRT.java
/** * Get the value to be shown /*from ww w . java2 s . c o m*/ */ @Override public String getShowValue(Object value, Locale locale) { if (value != null) { try { Double doubleValue = (Double) value; DoubleNumberFormatUtil doubleNumberFormatUtil = DoubleNumberFormatUtil.getInstance(); return doubleNumberFormatUtil.formatGUI(doubleValue, locale); } catch (Exception e) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Getting the showValue for double " + value + " failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } return value.toString(); } } return ""; }
From source file:com.garethahealy.camel.dynamic.loadbalancer.statistics.mbeans.BaseMBeanAttributeCollector.java
private Object getAttribute(ObjectName routeMBean, String attributeName) { Object attribute = null;//from w ww. j a v a 2 s . co m if (routeMBean != null) { try { attribute = mBeanServer.getAttribute(routeMBean, attributeName); } catch (MBeanException ex) { LOG.error(ExceptionUtils.getStackTrace(ex)); } catch (AttributeNotFoundException ex) { LOG.error(ExceptionUtils.getStackTrace(ex)); } catch (InstanceNotFoundException ex) { LOG.error(ExceptionUtils.getStackTrace(ex)); } catch (ReflectionException ex) { LOG.error(ExceptionUtils.getStackTrace(ex)); } } return attribute; }
From source file:com.sri.ai.praise.sgsolver.solver.HOGMQueryError.java
@Override public String toString() { StringJoiner sj = new StringJoiner(""); if (context == Context.UNKNOWN) { sj.add("General Error: "); } else if (context == Context.QUERY) { sj.add("Error in Query "); } else if (context == Context.MODEL) { sj.add("Error in Model "); }// w w w . java2s . c o m if (context != Context.UNKNOWN) { sj.add("at Line " + line + ": "); } sj.add(errorMessage); if (throwable != null) { sj.add("\n"); sj.add(ExceptionUtils.getStackTrace(throwable)); } return sj.toString(); }
From source file:ke.co.tawi.babblesms.server.persistence.creditmgmt.SmsBalanceDAO.java
/** * @see ke.co.tawi.babblesms.server.persistence.creditmgmt.BabbleSmsBalanceDAO#hasBalance(Account, SMSSource, int) */// w w w . j a va 2 s . c o m @Override public boolean hasBalance(Account account, SMSSource smsSource, int count) { boolean hasBalance = false; int smsCount = 0; try (Connection conn = dbCredentials.getConnection(); PreparedStatement pstmt = conn.prepareStatement( "SELECT count FROM ShortcodeBalance " + "WHERE accountUuid=? AND Shortcodeuuid=?;"); PreparedStatement pstmt2 = conn.prepareStatement( "SELECT count FROM MaskBalance " + "WHERE accountUuid=? AND maskuuid=?;");) { pstmt.setString(1, account.getUuid()); pstmt.setString(2, smsSource.getUuid()); pstmt2.setString(1, account.getUuid()); pstmt2.setString(2, smsSource.getUuid()); try (ResultSet rset = pstmt.executeQuery(); ResultSet rset2 = pstmt2.executeQuery();) { if (rset.next()) { smsCount = rset.getInt("count"); hasBalance = (smsCount >= count) ? true : false; } else if (rset2.next()) { smsCount = rset2.getInt("count"); hasBalance = (smsCount >= count) ? true : false; } } } catch (SQLException e) { logger.error("SQLException exception while checking whether '" + account + "' has balance of " + count + " for '" + smsSource + "'."); logger.error(ExceptionUtils.getStackTrace(e)); } return hasBalance; }
From source file:com.aurel.track.fieldType.runtime.matchers.converter.AccountingTimeMatcherConverter.java
/** * Convert the xml string to object value after load * @param value//from www .j a v a 2 s. com * @param matcherRelation * @return */ @Override public Object fromXMLString(String value, Integer matcherRelation) { if (value == null || "".equals(value) || matcherRelation == null) { return null; } switch (matcherRelation.intValue()) { case MatchRelations.EQUAL: case MatchRelations.NOT_EQUAL: case MatchRelations.GREATHER_THAN: case MatchRelations.GREATHER_THAN_EQUAL: case MatchRelations.LESS_THAN: case MatchRelations.LESS_THAN_EQUAL: AccountingTimeTO accountingTimeTO = new AccountingTimeTO(); String[] partsArr = value.split(SPLITTER_STRING); if (partsArr != null && partsArr.length > 0) { try { String doubleStr = partsArr[0]; if (doubleStr != null && !"".equals(doubleStr) && !"null".equals(doubleStr)) { accountingTimeTO.setValue(Double.valueOf(doubleStr)); } } catch (Exception e) { LOGGER.warn("Converting the " + partsArr[0] + " to Double from xml string failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } if (partsArr.length > 1) { try { String unitStr = partsArr[1]; if (unitStr != null && !"".equals(unitStr) && !"null".equals(unitStr)) { accountingTimeTO.setUnit(Integer.valueOf(unitStr)); } } catch (Exception e) { LOGGER.warn("Converting the " + partsArr[1] + " to Integer from xml string failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } } } return accountingTimeTO; } return null; }
From source file:com.aurel.track.fieldType.runtime.matchers.converter.DateMatcherConverter.java
/** * Convert the xml string to object value after load * @param value/*from w w w . j a v a 2 s . c o m*/ * @param matcherRelation * @return */ @Override public Object fromXMLString(String value, Integer matcherRelation) { if (value == null || value.trim().length() == 0 || value.trim().equals("null") || matcherRelation == null) { return null; } switch (matcherRelation.intValue()) { case MatchRelations.MORE_THAN_DAYS_AGO: case MatchRelations.MORE_THAN_EQUAL_DAYS_AGO: case MatchRelations.LESS_THAN_DAYS_AGO: case MatchRelations.LESS_THAN_EQUAL_DAYS_AGO: case MatchRelations.IN_MORE_THAN_DAYS: case MatchRelations.IN_MORE_THAN_EQUAL_DAYS: case MatchRelations.IN_LESS_THAN_DAYS: case MatchRelations.IN_LESS_THAN_EQUAL_DAYS: Integer intValue = null; try { intValue = Integer.valueOf(value); } catch (Exception e) { LOGGER.warn( "Converting the " + value + " to Integer from xml string failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } return intValue; case MatchRelations.EQUAL_DATE: case MatchRelations.NOT_EQUAL_DATE: case MatchRelations.GREATHER_THAN_DATE: case MatchRelations.GREATHER_THAN_EQUAL_DATE: case MatchRelations.LESS_THAN_DATE: case MatchRelations.LESS_THAN_EQUAL_DATE: return DateTimeUtils.getInstance().parseISODateTime(value); } return null; }
From source file:com.aurel.track.lucene.index.associatedFields.ExpenseIndexer.java
/** * Adds an attachment to the attachment index * Used by attaching a new file to the workItem * @param attachFile//from ww w.ja v a 2s. c o m */ @Override public void addToIndex(Object object, boolean add) { if (!LuceneUtil.isUseLucene()) { return; } if (!ClusterBL.indexInstantly()) { LOGGER.debug("Index instantly is false"); return; } IndexWriter indexWriter = LuceneIndexer.getIndexWriter(getIndexWriterID()); if (indexWriter == null) { LOGGER.error("IndexWriter null by adding an expense"); return; } if (LOGGER.isDebugEnabled()) { LOGGER.debug("Save a new " + add + " " + getLuceneFieldName()); } TCostBean costBean = (TCostBean) object; if (!add) { Integer objectID = costBean.getObjectID(); if (objectID != null) { Term keyTerm = new Term(getObjectIDFieldName(), objectID.toString()); try { indexWriter.deleteDocuments(keyTerm); indexWriter.commit(); } catch (IOException e) { LOGGER.error("Removing the entity " + objectID + " failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } } } try { Document doc = createDocument(costBean); if (doc != null) { indexWriter.addDocument(doc); } } catch (IOException e) { LOGGER.error("Adding an expense to the index failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } try { indexWriter.commit(); } catch (IOException e) { LOGGER.error("Flushing the expense failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } }