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:com.aurel.track.plugin.JavaScriptPathExtenderAction.java
/**' * Return the textual content of the js file row by row * By first creating/instantiating such a report configuration class the loader will search for <TRACKPLUS_HOME>/plugins/<pluginName>/<className> * pluginName is configured in getDirs and put as get parameter * className is automatically passed by Ext js loader mechanism to the path/URL mapping specified by Ext.Loader.setPath() * @return/*from w w w . j av a2 s .co m*/ * @throws Exception */ @Override public String execute() throws Exception { String tpHome = HandleHome.getTrackplus_Home(); String jsDir = tpHome + File.separator + HandleHome.PLUGINS_DIR + File.separator + pluginDir + File.separator + "js"; int parameterIndex = jsFile.indexOf("?"); if (parameterIndex != -1) { //if caching is not disabled a timestamp parameter is added it should be removed from the file name because otherwise it will not be found on the disk jsFile = jsFile.substring(0, parameterIndex); } File file = new File(jsDir + jsFile); if (file != null && file.exists() && file.canRead()) { StringBuffer sb = new StringBuffer(); BufferedReader br = null; try { String sCurrentLine; br = new BufferedReader(new FileReader(file)); while ((sCurrentLine = br.readLine()) != null) { sb.append(sCurrentLine); } } catch (IOException e) { LOGGER.error(ExceptionUtils.getStackTrace(e)); } finally { try { if (br != null) { br.close(); } } catch (IOException ex) { LOGGER.error(ExceptionUtils.getStackTrace(ex)); } } JSONUtility.encodeJSON(servletResponse, sb.toString()); } return null; }
From source file:ke.co.tawi.babblesms.server.persistence.contacts.GroupDAO.java
/** * @see ke.co.tawi.babblesms.server.persistence.contacts.BabbleGroupDAO#getGroupByName(ke.co.tawi.babblesms.server.beans.account.Account, java.lang.String) *//* w w w . j a va 2s. c om*/ @Override public Group getGroupByName(Account account, String groupname) { Group group1 = null; try (Connection conn = dbCredentials.getConnection(); PreparedStatement pstmt = conn .prepareStatement("SELECT * FROM groups WHERE name = ? and accountuuid = ?;");) { pstmt.setString(1, groupname); pstmt.setString(2, account.getUuid()); try (ResultSet rset = pstmt.executeQuery()) { if (rset.next()) { group1 = beanProcessor.toBean(rset, Group.class); } } } catch (SQLException e) { logger.error("SQL Exception when getting Group with name: " + groupname + " for " + account); logger.error(ExceptionUtils.getStackTrace(e)); } return group1; }
From source file:com.aurel.track.persist.TQueryRepositoryPeer.java
/** * Loads a queryRepositoryBean by primary key *//*ww w . ja v a2s. c o m*/ @Override public TQueryRepositoryBean loadByPrimaryKey(Integer objectID) { TQueryRepository tQueryRepository = null; try { tQueryRepository = retrieveByPK(objectID); } catch (Exception e) { LOGGER.debug( "Loading of a queryRepository by primary key " + objectID + " failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } if (tQueryRepository != null) { return tQueryRepository.getBean(); } return null; }
From source file:com.aurel.track.report.execute.ShowableWorkItem.java
public Comparable getSortOrder(Integer fieldID) { Object sortOrderValue = sortOrderValuesMap.get(fieldID); if (sortOrderValue == null) { //try the direct value sortOrderValue = workItemBean.getAttribute(fieldID); }//from www .j av a 2 s . co m Comparable comparableValue = null; if (sortOrderValue != null) { try { comparableValue = (Comparable) sortOrderValue; } catch (Exception e) { LOGGER.info("The type of the sortOrder attribute for fieldID " + fieldID + " is " + sortOrderValue.getClass().getName() + ". Casting it to Comparable failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } } return comparableValue; }
From source file:com.aurel.track.exchange.docx.exporter.AssembleWordprocessingMLPackage.java
/** * Gets the WordprocessingMLPackage from report beans * @param workItemBean//from www . jav a2 s .co m * @param reportBeans * @param docxTemplate * @param personID * @param locale * @return */ public static WordprocessingMLPackage getWordMLPackage(TWorkItemBean workItemBean, ReportBeans reportBeans, String docxTemplateFilePath, Integer personID, Locale locale) { Set<Integer> explicitItemIDs = new HashSet<Integer>(); WordprocessingMLPackage wordMLPackage = null; File templateFile = new java.io.File(docxTemplateFilePath); if (templateFile.exists()) { try { wordMLPackage = WordprocessingMLPackage.load(templateFile); } catch (Docx4JException e) { LOGGER.error("Creating the WordprocessingMLPackage failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } } else { LOGGER.warn("The template file " + docxTemplateFilePath + " does not exist"); try { wordMLPackage = WordprocessingMLPackage.createPackage(); } catch (InvalidFormatException e) { LOGGER.error("Creating the WordprocessingMLPackage failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); return null; } } if (wordMLPackage == null) { LOGGER.warn("No template found"); return null; } Map<String, String> paragaphStylesMap = new HashMap<String, String>(); Map<String, String> characterStylesMap = new HashMap<String, String>(); Map<Integer, String> outlineStylesMap = new HashMap<Integer, String>(); StyleUtil.getStyles(wordMLPackage.getMainDocumentPart(), paragaphStylesMap, characterStylesMap, outlineStylesMap); addCustomXMLPart(wordMLPackage, workItemBean, personID, locale); boolean highlightInlineContent = GeneralSettings.isHighlightInlineContent(); String inlineContentStyleID = null; boolean inlineContentStyleIsParagraphStyle = false; if (highlightInlineContent) { String configuredInlineContentStyle = GeneralSettings.getExportDocxInlineContentStyle(); String defaultInlineContentStyleName = STANDARD_STYLE_NAMES.SUBTLE_EMPHASIS; String inlineContentStyleKey = GENERAL_CONFIG.EXPORT_DOCX_STYLE_INLINE_CONTENT; //search among the paragraph styles inlineContentStyleID = StyleUtil.getStyle(paragaphStylesMap, configuredInlineContentStyle, inlineContentStyleKey, defaultInlineContentStyleName); if (inlineContentStyleID == null) { //search among the character styles inlineContentStyleID = StyleUtil.getStyle(characterStylesMap, configuredInlineContentStyle, inlineContentStyleKey, defaultInlineContentStyleName); } else { inlineContentStyleIsParagraphStyle = true; } } SortedMap<String, ImageOrTableCaption> imageCaptionMap = new TreeMap<String, ImageOrTableCaption>(); SortedMap<String, ImageOrTableCaption> tableCaptionMap = new TreeMap<String, ImageOrTableCaption>(); PreprocessImage preprocessImage = new PreprocessImage(); PreprocessTable preprocessTable = new PreprocessTable(); assembleWordMLPackage(wordMLPackage, reportBeans.getReportBeansFirstLevel(), explicitItemIDs, personID, locale, outlineStylesMap, 0, 0, imageCaptionMap, tableCaptionMap, highlightInlineContent, inlineContentStyleID, inlineContentStyleIsParagraphStyle, preprocessImage, preprocessTable); String temporaryDirPath = DocxTemplateBL.getWordTemplatesDir() + personID; File temporaryDir = new File(temporaryDirPath); if (temporaryDir.exists()) { AttachBL.deleteDirectory(temporaryDir); } String configuredImageCaptionStyle = GeneralSettings.getExportDocxImageCaptionStyle(); String defaultImageCaptionStyleName = STANDARD_STYLE_NAMES.CAPTION_NAME; String imageStyleKey = GENERAL_CONFIG.EXPORT_DOCX_STYLE_IMAGE_CAPTION; String imageCaptionStyle = StyleUtil.getStyle(paragaphStylesMap, configuredImageCaptionStyle, imageStyleKey, defaultImageCaptionStyleName); try { new PostprocessImage().addCaption(wordMLPackage, locale, imageCaptionStyle, imageCaptionMap); } catch (Exception e) { LOGGER.warn("Adding the image captions failed with " + e.getMessage()); if (LOGGER.isDebugEnabled()) { LOGGER.debug(ExceptionUtils.getStackTrace(e)); } } try { new PostprocessTable().addCaption(wordMLPackage, locale, imageStyleKey, tableCaptionMap); } catch (Exception e) { LOGGER.warn("Adding the table captions failed with " + e.getMessage()); if (LOGGER.isDebugEnabled()) { LOGGER.debug(ExceptionUtils.getStackTrace(e)); } } return wordMLPackage; }
From source file:ke.co.tawi.babblesms.server.persistence.logs.IncomingLogDAO.java
/** * @see ke.co.tawi.babblesms.server.persistence.logs.BabbleIncomingLogDAO#getIncomingLog(java.util.List, int, int) *//* w w w. j av a 2 s . c o m*/ @Override public List<IncomingLog> getIncomingLog(Account account, int fromIndex, int toIndex) { List<IncomingLog> list = new ArrayList<>(); try (Connection conn = dbCredentials.getConnection(); PreparedStatement pstmt = conn.prepareStatement("SELECT * FROM incomingLog WHERE recipientuuid = ?" + " ORDER BY logTime DESC LIMIT ? OFFSET ? ;");) { pstmt.setString(1, account.getUuid()); pstmt.setInt(2, toIndex - fromIndex); pstmt.setInt(3, fromIndex); try (ResultSet rset = pstmt.executeQuery();) { list = beanProcessor.toBeanList(rset, IncomingLog.class); } } catch (SQLException e) { logger.error("SQLException while getting incomingLog from index " + fromIndex + " to index " + toIndex + "."); logger.error(ExceptionUtils.getStackTrace(e)); } return list; }
From source file:com.aurel.track.exchange.track.importer.ImporterDataParser.java
public List<ExchangeWorkItem> parse(File xml, Map<Integer, Integer> fieldMatcher) { this.fieldMatcher = fieldMatcher; //get a factory SAXParserFactory saxParserFactory = SAXParserFactory.newInstance(); try {/*from w w w.j a v a 2s.c om*/ SAXParser saxParser = saxParserFactory.newSAXParser(); LOGGER.debug("Data parser started..."); saxParser.parse(xml, this); LOGGER.debug("Data parser done"); return exchangeWorkItemsList; } catch (SAXException se) { LOGGER.error(ExceptionUtils.getStackTrace(se)); } catch (ParserConfigurationException pce) { LOGGER.error(ExceptionUtils.getStackTrace(pce)); } catch (IOException ie) { LOGGER.error(ExceptionUtils.getStackTrace(ie)); } return null; }
From source file:com.aurel.track.fieldType.runtime.base.InputFieldTypeRT.java
/** * Loads the field change attributes from the the history * @param fieldID// w w w . ja v a 2 s . c o m * @param parameterCode * @param fieldChangeMap: * - key: fieldID_parameterCode * - value: fieldChangeBean or list of fieldChangeBeans (for multiple selects) * @param newValuesHistoryMap: * - key: fieldID_parameterCode * - value: the valid field value from fieldChangeBean for the new value: Object or Object[] (for multiple selects) * @param oldValuesHistoryMap * - key: fieldID_parameterCode * - value: the valid field value from fieldChangeBean for the old value: Object or Object[] (for multiple selects) */ @Override public void processHistoryLoad(Integer fieldID, Integer parameterCode, Map<String, Object> fieldChangeMap, Map<String, Object> newValuesHistoryMap, Map<String, Object> oldValuesHistoryMap) { String mergeKey = MergeUtil.mergeKey(fieldID, parameterCode); if (isMultipleValues()) { List<TFieldChangeBean> fieldChangeBeanList = null; try { fieldChangeBeanList = (List<TFieldChangeBean>) fieldChangeMap.get(mergeKey); } catch (Exception e) { LOGGER.error("The type of the history fieldChanges for multiple values by loading is " + fieldChangeMap.get(mergeKey).getClass().getName() + ". Casting it to List failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); return; } if (fieldChangeBeanList == null) { return; } List<Object> newValues = new ArrayList<Object>(); List<Object> oldValues = new ArrayList<Object>(); Iterator<TFieldChangeBean> iterator = fieldChangeBeanList.iterator(); while (iterator.hasNext()) { TFieldChangeBean fieldChangeBean = iterator.next(); Object newValue = HistoryDAOUtils.getSpecificNewAttribute(fieldChangeBean, getValueType()); if (newValue != null) { newValues.add(newValue); } Object oldValue = HistoryDAOUtils.getSpecificOldAttribute(fieldChangeBean, getValueType()); if (oldValue != null) { oldValues.add(oldValue); } } //the values are Object[] see CustomSelectUtil.getSelectedOptions() newValuesHistoryMap.put(mergeKey, newValues.toArray()); oldValuesHistoryMap.put(mergeKey, oldValues.toArray()); } else { TFieldChangeBean fieldChangeBean = (TFieldChangeBean) fieldChangeMap.get(mergeKey); if (fieldChangeBean != null) { newValuesHistoryMap.put(mergeKey, HistoryDAOUtils.getSpecificNewAttribute(fieldChangeBean, getValueType())); oldValuesHistoryMap.put(mergeKey, HistoryDAOUtils.getSpecificOldAttribute(fieldChangeBean, getValueType())); } } }
From source file:com.aurel.track.fieldType.runtime.system.select.SystemSelectBaseLocalizedRT.java
/** * Get the value to be shown for a matcher * Typically same as for the getShowValue(), except the selects * (the value object's type differs for matchers compared to issue field values in getShowValue) * @param fieldID//www .j a v a 2s. c o m * @param value * @param locale * @return */ @Override public String getMatcherShowValue(Integer fieldID, Object value, Locale locale) { Integer[] optionIDs = null; if (value != null) { try { optionIDs = (Integer[]) value; } catch (Exception e) { LOGGER.warn("Casting the value type " + value.getClass().getName() + " to Integer[] failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); return ""; } return LookupContainer.getLocalizedLookupCommaSepatatedString(fieldID, optionIDs, locale); } return ""; }
From source file:com.aurel.track.admin.customize.category.report.ReportBL.java
public static void deleteWithTemplate(Integer objectID) { delete(objectID);/*from w ww . j ava2s .c o m*/ File templatDir = getDirTemplate(objectID); try { FileUtils.deleteDirectory(templatDir); } catch (IOException e) { LOGGER.info("Deleting the template " + templatDir + " failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } }