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.network.NetworkDAO.java
/** * @see ke.co.tawi.babblesms.server.persistence.network.BabbleNetworkDAO#getNetwork(java.lang.String) */// www.j a va 2 s . c om @Override public Network getNetwork(String uuid) { Network network = null; ResultSet rset = null; try (Connection conn = dbCredentials.getConnection(); PreparedStatement pstmt = conn.prepareStatement("SELECT * FROM Network WHERE Uuid = ?;");) { pstmt.setString(1, uuid); rset = pstmt.executeQuery(); if (rset.next()) { network = beanProcessor.toBean(rset, Network.class); } } catch (SQLException e) { logger.error("SQL Exception when getting network with uuid: " + uuid); logger.error(ExceptionUtils.getStackTrace(e)); } return network; }
From source file:com.aurel.track.lucene.index.associatedFields.LinkIndexer.java
/** * Adds an attachment to the attachment index * Used by attaching a new file to the workItem * @param attachFile/*from www . ja v a 2 s . 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 a link"); return; } if (LOGGER.isDebugEnabled()) { LOGGER.debug("Save a new " + add + " " + getLuceneFieldName()); } TWorkItemLinkBean workItemLinkBean = (TWorkItemLinkBean) object; if (!add) { Integer objectID = workItemLinkBean.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(workItemLinkBean); if (doc != null) { indexWriter.addDocument(doc); } } catch (IOException e) { LOGGER.error("Adding an link to the index failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } try { indexWriter.commit(); } catch (IOException e) { LOGGER.error("Flushing the link failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } }
From source file:com.aurel.track.screen.dashboard.action.DashboardParamsConfigAction.java
@Override public String execute() { TDashboardFieldBean dashboardItem = (TDashboardFieldBean) DashboardFieldRuntimeBL.getInstance() .loadField(dashboardID);// w ww . j a va 2 s . c o m Map<String, String> itemParams = dashboardItem.getParametres(); IPluginDashboard plugin = DashboardUtil.getPlugin(dashboardItem); DashboardDescriptor descriptor = DashboardUtil.getDescriptor(dashboardItem); TPersonBean user = (TPersonBean) session.get(Constants.USER_KEY); String jsonData = plugin.createJsonDataConfig(itemParams, user, projectID, entityType); try { JSONUtility.prepareServletResponseJSON(ServletActionContext.getResponse()); PrintWriter out = ServletActionContext.getResponse().getWriter(); StringBuilder sb = new StringBuilder(); sb.append("{"); JSONUtility.appendBooleanValue(sb, JSONUtility.JSON_FIELDS.SUCCESS, true); sb.append("data:{"); JSONUtility.appendStringValue(sb, "cfgClass", descriptor.getJsConfigClass()); JSONUtility.appendIntegerValue(sb, "projectID", projectID); JSONUtility.appendIntegerValue(sb, "entityType", entityType); JSONUtility.appendJSONValue(sb, "jsonData", jsonData, true); sb.append("}"); sb.append("}"); out.println(sb); } catch (IOException e) { LOGGER.error(ExceptionUtils.getStackTrace(e)); } return null; }
From source file:kr.co.bitnine.octopus.frame.Session.java
@Override public void run() { LOCAL_SESSION.set(this); try {//from ww w.ja va 2 s. c o m boolean proceed = doStartup(); if (proceed) { doAuthentication(); messageLoop(); } } catch (Exception e) { LOG.fatal(ExceptionUtils.getStackTrace(e)); } LOCAL_SESSION.remove(); close(); }
From source file:application.Main.java
@Override public void start(Stage primaryStage) throws InterruptedException { System.out.println(applicationTitle + " initialized!"); // define working variables String text = ""; Boolean terminateExecution = Boolean.FALSE; // does the specified FXML XML file path exist? String fxmlXmlFileFullPath = fxmlPath.equals("") ? fxmlXmlFileName : fxmlPath + "/" + fxmlXmlFileName; URL urlXml = Main.class.getResource(fxmlXmlFileFullPath); if (urlXml == null) { terminateExecution = Boolean.TRUE; text = Main.class.getName() + ": FXML XML File '" + fxmlXmlFileFullPath + "' not found in resource path!"; GenericUtilities.outputToSystemErr(text, systemErrorsDesired); }/*from w ww. j a va2 s. co m*/ // does the specified FXML CSS file path exist? String fxmlCssFileFullPath = fxmlPath.equals("") ? fxmlCssFileName : fxmlPath + "/" + fxmlCssFileName; URL urlCss = Main.class.getResource(fxmlCssFileFullPath); if (urlCss == null) { terminateExecution = Boolean.TRUE; text = Main.class.getName() + ": FXML CSS File '" + fxmlCssFileFullPath + "' not found in resource path!"; GenericUtilities.outputToSystemErr(text, systemErrorsDesired); } if (terminateExecution) { text = Main.class.getName() + ": Execution terminated due to errors!"; GenericUtilities.outputToSystemErr(text, systemErrorsDesired); GenericUtilities.outputToSystemOut(text, systemOutputDesired); return; } // initialize and display the primary stage try { // load the FXML file and instantiate the "root" object FXMLLoader fxmlLoader = new FXMLLoader(urlXml); Parent root = (Parent) fxmlLoader.load(); controller = (FracKhemGUIController) fxmlLoader.getController(); controller.setStage(primaryStage); controller.setInitStageTitle(applicationTitle); // initialize and display the stage createTrayIcon(primaryStage); firstTime = Boolean.TRUE; Platform.setImplicitExit(Boolean.FALSE); Scene scene = new Scene(root); scene.getStylesheets().add(urlCss.toExternalForm()); primaryStage.setScene(scene); primaryStage.setTitle(applicationTitle + " - " + controller.getPropFileCurrFileVal()); primaryStage.show(); } catch (Exception e) { text = ExceptionUtils.getStackTrace(e); GenericUtilities.outputToSystemErr(text, systemErrorsDesired); text = Main.class.getName() + ": Execution terminated due to errors!"; GenericUtilities.outputToSystemErr(text, systemErrorsDesired); GenericUtilities.outputToSystemOut(text, systemOutputDesired); } }
From source file:ke.co.tawi.babblesms.server.persistence.maskcode.ShortcodeDAO.java
/** * *//*from w w w. j a v a 2 s. c o m*/ @Override public List<Shortcode> getShortcodes(Account account) { List<Shortcode> list = null; try (Connection conn = dbCredentials.getConnection(); PreparedStatement pstmt = conn.prepareStatement("SELECT * FROM Shortcode WHERE accountuuid=?;");) { pstmt.setString(1, account.getUuid()); try (ResultSet rset = pstmt.executeQuery();) { list = beanProcessor.toBeanList(rset, Shortcode.class); } } catch (SQLException e) { logger.error("SQL Exception when getting shortcodes of " + account); logger.error(ExceptionUtils.getStackTrace(e)); } return list; }
From source file:com.aurel.track.vc.action.VersionControlConfigAction.java
public String loadVCPlugin() { VersionControlDescriptor descriptor = VersionControlBL.getVersionControlDescriptor(pluginID); VersionControlBL.setIntegratedVersionControlBrowserValues(descriptor, projectID); StringBuilder sb = new StringBuilder(); sb.append("{"); JSONUtility.appendBooleanValue(sb, JSONUtility.JSON_FIELDS.SUCCESS, true); sb.append("data:{"); List<VersionControlDescriptor.BrowserDescriptor> browsers = descriptor.getBrowsers(); JSONUtility.appendJSONValue(sb, "browsers", VersionControlJSON.encodeBrowserDescriptor(browsers)); VersionControlTO vcTO = VersionControlBL.loadVersionControl(projectID); if (vcTO.getVersionControlType() != null && vcTO.getVersionControlType().equals(pluginID)) { VersionControlJSON.appendVersionControlTO(sb, vcTO, true); }/*from w w w . j a v a2s.c o m*/ sb.append("}}"); try { JSONUtility.prepareServletResponseJSON(ServletActionContext.getResponse()); PrintWriter out = ServletActionContext.getResponse().getWriter(); out.println(sb); } catch (IOException e) { // TODO Auto-generated catch block LOGGER.error(ExceptionUtils.getStackTrace(e)); } return null; }
From source file:ke.co.tawi.babblesms.server.persistence.contacts.PhoneDAO.java
/** * * @param phone// w w w . ja v a2s .c o m */ @Override public boolean putPhone(Phone phone) { boolean success = true; try (Connection conn = dbCredentials.getConnection(); PreparedStatement pstmt = conn.prepareStatement("INSERT INTo phone (uuid, phonenumber," + "contactuuid, statusuuid, networkuuid) VALUES (?,?,?,?,?);")) { pstmt.setString(1, phone.getUuid()); pstmt.setString(2, phone.getPhonenumber()); pstmt.setString(3, phone.getContactUuid()); pstmt.setString(4, phone.getStatusuuid()); pstmt.setString(5, phone.getNetworkuuid()); pstmt.execute(); } catch (SQLException e) { logger.error("SQLException when trying to put: " + phone); logger.error(ExceptionUtils.getStackTrace(e)); success = false; } return success; }
From source file:com.aurel.track.fieldType.runtime.matchers.run.CustomSelectMatcherRT.java
/** * Add a match expression to the criteria *///www .j a v a2 s .co m @Override public void addCriteria(Criteria crit) { Integer[] ids = null; if (matchValue != null) { try { ids = (Integer[]) matchValue; } catch (Exception e) { LOGGER.warn("Converting the matcher value " + matchValue + " of type " + matchValue.getClass().getName() + " to Integer failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); return; } } if (ids != null && ids.length != 0) { String alias = addAliasAndJoin(crit); if (systemOptionType == null) { crit.addIn(alias + "." + "CUSTOMOPTIONID", ids); } else { crit.addIn(alias + "." + "SYSTEMOPTIONID", ids); crit.add(alias + "." + "SYSTEMOPTIONTYPE", systemOptionType); } } else { String alias = addAliasAndJoin(crit); if (systemOptionType == null) { addNullExpressionToCriteria(crit, alias + "." + "CUSTOMOPTIONID"); } else { addNullExpressionToCriteria(crit, alias + "." + "SYSTEMOPTIONID"); crit.add(alias + "." + "SYSTEMOPTIONTYPE", systemOptionType); } } }
From source file:com.aurel.track.exchange.excel.ExcelFieldMatchAction.java
/** * Render the field match: first time and after a sheet change *//*from www . jav a 2s . c o m*/ @Override public String execute() { File fileOnDisk = new File(excelMappingsDirectory, fileName); workbook = ExcelFieldMatchBL.loadWorkbook(excelMappingsDirectory, fileName); if (workbook == null) { JSONUtility.encodeJSON(servletResponse, JSONUtility.encodeJSONFailure(getText("admin.actions.importExcel.err.noWorkbook")), false); fileOnDisk.delete(); return null; } if (selectedSheet == null) { //first rendering (not submit because of sheet change) selectedSheet = Integer.valueOf(0); } //get the previous field mappings Map<String, Integer> columNameToFieldIDMap = null; Set<Integer> lastSavedIdentifierFieldIDIsSet = null; try { FileInputStream fis = new FileInputStream(new File(excelMappingsDirectory, mappingFileName)); ObjectInputStream objectInputStream = new ObjectInputStream(fis); columNameToFieldIDMap = (Map<String, Integer>) objectInputStream.readObject(); lastSavedIdentifierFieldIDIsSet = (Set<Integer>) objectInputStream.readObject(); objectInputStream.close(); } catch (FileNotFoundException e) { LOGGER.info("Creating the input stream for mapping failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } catch (IOException e) { LOGGER.warn("Saving the mapping failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } catch (ClassNotFoundException e) { LOGGER.warn("Class not found for the mapping " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } //get the column index to header names from the excel sheet SortedMap<Integer, String> columnIndexToColumNameMap = ExcelFieldMatchBL.getFirstRowHeaders(workbook, selectedSheet); SortedSet<String> excelColumnNames = new TreeSet<String>(); excelColumnNames.addAll(columnIndexToColumNameMap.values()); //prepare the best field matching if (columNameToFieldIDMap == null) { columNameToFieldIDMap = new HashMap<String, Integer>(); } ExcelFieldMatchBL.prepareBestMatchByLabel(excelColumnNames, columNameToFieldIDMap, locale); columnIndexToFieldIDMap = ExcelFieldMatchBL.getColumnIndexToFieldIDMap(columNameToFieldIDMap, columnIndexToColumNameMap); columnIndexIsIdentifierMap = new HashMap<Integer, Boolean>(); //the saved identifier columns if (lastSavedIdentifierFieldIDIsSet != null && !lastSavedIdentifierFieldIDIsSet.isEmpty()) { for (Integer columnIndex : columnIndexToFieldIDMap.keySet()) { Integer fieldID = columnIndexToFieldIDMap.get(columnIndex); columnIndexIsIdentifierMap.put(columnIndex, new Boolean(lastSavedIdentifierFieldIDIsSet.contains(fieldID))); } } //if issueNo is present it is always identifier (first time it should be preselected and any time when mapped also preselected) if (columnIndexToFieldIDMap.values().contains(SystemFields.INTEGER_ISSUENO)) { for (Integer columnIndex : columnIndexToFieldIDMap.keySet()) { Integer fieldID = columnIndexToFieldIDMap.get(columnIndex); if (SystemFields.INTEGER_ISSUENO.equals(fieldID)) { columnIndexIsIdentifierMap.put(columnIndex, new Boolean(true)); } } } List<IntegerStringBean> sheetNames = ExcelFieldMatchBL.loadSheetNames(workbook); List<IntegerStringBean> matchableFieldsList = ExcelFieldMatchBL.getFieldConfigs(personID, locale); Map<Integer, String> columnIndexNumericToLetter = ExcelFieldMatchBL.getFirstRowNumericToLetter(workbook, selectedSheet); Set<Integer> possibleIdentifiersSet = ExcelFieldMatchBL.getPossibleIdentifierFields(); Set<Integer> mandatoryIdentifiersSet = ExcelFieldMatchBL.getMandatoryIdentifierFields(); JSONUtility.encodeJSON(servletResponse, ExcelImportJSON.getExcelFieldMatcherJSON(fileName, selectedSheet, sheetNames, matchableFieldsList, columnIndexToColumNameMap, columnIndexNumericToLetter, columnIndexToFieldIDMap, columnIndexIsIdentifierMap, possibleIdentifiersSet, mandatoryIdentifiersSet), false); return null; }