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.fieldType.fieldChange.apply.CustomMultipleSelectFieldChangeApply.java
/** * Sets the workItemBean's attribute//from w w w . jav a 2 s .c o m * @param workItemContext * @param workItemBean * @param fieldID * @param parameterCode * @param value * @return ErrorData if an error is found */ @Override public List<ErrorData> setWorkItemAttribute(WorkItemContext workItemContext, TWorkItemBean workItemBean, Integer parameterCode, Object value) { if (getSetter() == FieldChangeSetters.SET_NULL || getSetter() == FieldChangeSetters.SET_REQUIRED) { return super.setWorkItemAttribute(workItemContext, workItemBean, parameterCode, value); } Object originalValue = workItemBean.getAttribute(activityType, parameterCode); Object[] originalSelections = null; if (originalValue != null) { try { //multiple values are loaded in the workItem as Object[], not as Integer[] !!! originalSelections = (Object[]) originalValue; } catch (Exception e) { LOGGER.info( "Getting the original object array value for " + value + " failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } } Set<Integer> originalSet = new HashSet<Integer>(); if (originalSelections != null && originalSelections.length > 0) { for (int i = 0; i < originalSelections.length; i++) { try { originalSet.add((Integer) originalSelections[i]); } catch (Exception e) { LOGGER.info("Transforming the original object value " + originalSelections[i] + " to Integer failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } } } Integer[] newValue = (Integer[]) value; Set<Integer> bulkSelectionsSet = GeneralUtils.createSetFromIntegerArr(newValue); switch (getSetter()) { case FieldChangeSetters.SET_TO: workItemBean.setAttribute(activityType, parameterCode, newValue); break; case FieldChangeSetters.ADD_ITEMS: originalSet.addAll(bulkSelectionsSet); workItemBean.setAttribute(activityType, parameterCode, GeneralUtils.createIntegerArrFromCollection(originalSet)); break; case FieldChangeSetters.REMOVE_ITEMS: originalSet.removeAll(bulkSelectionsSet); workItemBean.setAttribute(activityType, parameterCode, GeneralUtils.createIntegerArrFromCollection(originalSet)); break; default: break; } return null; }
From source file:com.gatf.executor.executor.ScenarioTestCaseExecutor.java
public List<TestCaseReport> execute(TestCase testCase, TestCaseExecutorUtil testCaseExecutorUtil) { List<TestCaseReport> lst = new ArrayList<TestCaseReport>(); WorkflowContextHandler workflowContextHandler = testCaseExecutorUtil.getContext() .getWorkflowContextHandler(); int numParallel = Runtime.getRuntime().availableProcessors() * 2; List<ListenableFuture<TestCaseReport>> futures = new ArrayList<ListenableFuture<TestCaseReport>>(); for (Map<String, String> scenarioMap : testCase.getRepeatScenarios()) { logger.info("Running with Scenario map = " + scenarioMap); TestCase testCaseCopy = new TestCase(testCase); TestCaseReport testCaseReport = new TestCaseReport(); testCaseReport.setTestCase(testCaseCopy); testCaseReport.setNumberOfRuns(1); testCaseCopy.setCurrentScenarioVariables(scenarioMap); try {//from w ww . j a va 2s .c o m workflowContextHandler.handleContextVariables(testCaseCopy, scenarioMap, testCaseExecutorUtil.getContext()); } catch (Exception e) { testCaseReport.setExecutionTime(0L); testCaseReport.setStatus(TestStatus.Failed.status); testCaseReport.setFailureReason(TestFailureReason.Exception.status); testCaseReport.setError(e.getMessage()); testCaseReport.setErrorText(ExceptionUtils.getStackTrace(e)); if (e.getMessage() == null && testCaseReport.getErrorText() != null && testCaseReport.getErrorText().indexOf("\n") != -1) { testCaseReport.setError(testCaseReport.getErrorText().substring(0, testCaseReport.getErrorText().indexOf("\n"))); } lst.add(testCaseReport); e.printStackTrace(); continue; } ListenableFuture<TestCaseReport> listenableFuture = testCaseExecutorUtil.executeTestCase(testCaseCopy, testCaseReport); if (!testCaseReport.getTestCase().isRepeatScenariosConcurrentExecution()) { try { testCaseReport = listenableFuture.get(); ResponseValidator.validateLogicalConditions(testCaseReport.getTestCase(), testCaseExecutorUtil.getContext(), scenarioMap); testCaseReport.getTestCase().setCurrentScenarioVariables(null); } catch (Exception e) { testCaseReport.setStatus(TestStatus.Failed.status); testCaseReport.setFailureReason(TestFailureReason.Exception.status); testCaseReport.setError(e.getMessage()); testCaseReport.setErrorText(ExceptionUtils.getStackTrace(e)); e.printStackTrace(); } catch (AssertionError e) { testCaseReport.setStatus(TestStatus.Failed.status); testCaseReport.setFailureReason(TestFailureReason.NodeValidationFailed.status); testCaseReport.setError(e.getMessage()); testCaseReport.setErrorText(ExceptionUtils.getStackTrace(e)); e.printStackTrace(); } lst.add(testCaseReport); } else { futures.add(listenableFuture); } if (futures.size() == numParallel) { for (ListenableFuture<TestCaseReport> listenableFutureT : futures) { TestCaseReport testCaseReportT = null; try { testCaseReportT = listenableFutureT.get(); ResponseValidator.validateLogicalConditions(testCaseReport.getTestCase(), testCaseExecutorUtil.getContext(), scenarioMap); testCaseReport.getTestCase().setCurrentScenarioVariables(null); } catch (Exception e) { testCaseReportT.setStatus(TestStatus.Failed.status); testCaseReport.setFailureReason(TestFailureReason.Exception.status); testCaseReportT.setError(e.getMessage()); testCaseReportT.setErrorText(ExceptionUtils.getStackTrace(e)); e.printStackTrace(); } catch (AssertionError e) { testCaseReport.setStatus(TestStatus.Failed.status); testCaseReport.setFailureReason(TestFailureReason.NodeValidationFailed.status); testCaseReport.setError(e.getMessage()); testCaseReport.setErrorText(ExceptionUtils.getStackTrace(e)); e.printStackTrace(); } lst.add(testCaseReportT); } futures.clear(); } } for (ListenableFuture<TestCaseReport> listenableFuture : futures) { TestCaseReport testCaseReport = null; try { testCaseReport = listenableFuture.get(); ResponseValidator.validateLogicalConditions(testCaseReport.getTestCase(), testCaseExecutorUtil.getContext(), testCaseReport.getTestCase().getCurrentScenarioVariables()); testCaseReport.getTestCase().setCurrentScenarioVariables(null); } catch (Exception e) { testCaseReport.setStatus(TestStatus.Failed.status); testCaseReport.setFailureReason(TestFailureReason.Exception.status); testCaseReport.setError(e.getMessage()); testCaseReport.setErrorText(ExceptionUtils.getStackTrace(e)); e.printStackTrace(); } catch (AssertionError e) { testCaseReport.setStatus(TestStatus.Failed.status); testCaseReport.setFailureReason(TestFailureReason.NodeValidationFailed.status); testCaseReport.setError(e.getMessage()); testCaseReport.setErrorText(ExceptionUtils.getStackTrace(e)); e.printStackTrace(); } lst.add(testCaseReport); } return lst; }
From source file:ke.co.tawi.babblesms.server.persistence.contacts.EmailDAO.java
/** * * @param uuid//w ww.j ava 2 s .co m * @return an {@link Email} */ @Override public Email getEmail(String uuid) { Email email = null; try (Connection conn = dbCredentials.getConnection(); PreparedStatement pstmt = conn.prepareStatement("SELECT * FROM Email WHERE uuid = ?;");) { pstmt.setString(1, uuid); try (ResultSet rset = pstmt.executeQuery();) { if (rset.next()) { email = beanProcessor.toBean(rset, Email.class); } } } catch (SQLException e) { logger.error("SQL Exception when getting email with uuid: " + uuid); logger.error(ExceptionUtils.getStackTrace(e)); } return email; }
From source file:io.hops.hopsworks.common.exception.RESTException.java
public JsonResponse buildJsonResponse(JsonResponse jsonResponse, Settings.LOG_LEVEL logLevel) { if (jsonResponse == null) { throw new IllegalArgumentException("jsonResponse was not provided."); }/*from w w w . j av a2 s.c om*/ jsonResponse.setErrorMsg(errorCode.getMessage()); jsonResponse.setErrorCode(errorCode.getCode()); if (logLevel.getLevel() <= Settings.LOG_LEVEL.PROD.getLevel()) { jsonResponse.setUsrMsg(usrMsg); } if (logLevel.getLevel() <= Settings.LOG_LEVEL.TEST.getLevel()) { jsonResponse.setDevMsg(devMsg); } if (logLevel.getLevel() <= Settings.LOG_LEVEL.DEV.getLevel()) { jsonResponse.setTrace(ExceptionUtils.getStackTrace(this)); } return jsonResponse; }
From source file:com.aurel.track.fieldType.runtime.matchers.run.SystemSelectMatcherRT.java
/** * Whether the value matches or not/*w w w . java2s . com*/ * @param attributeValue * @return */ @Override public boolean match(Object attributeValue) { Boolean nullMatch = nullMatcher(attributeValue); if (nullMatch != null) { return nullMatch.booleanValue(); } if (attributeValue == null || matchValue == null) { return false; } Integer attributeValueSystemOption = null; Integer matcherValueSystemOption = null; try { attributeValueSystemOption = (Integer) attributeValue; } catch (Exception e) { LOGGER.warn("Converting the attribute value " + attributeValue + " of type " + attributeValue.getClass().getName() + " to Integer failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); return false; } try { Integer[] matchValueArr = (Integer[]) matchValue; if (matchValueArr.length > 0) { matcherValueSystemOption = matchValueArr[0]; } } 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 false; } switch (relation) { case MatchRelations.EQUAL: return attributeValueSystemOption.equals(matcherValueSystemOption); case MatchRelations.NOT_EQUAL: return !attributeValueSystemOption.equals(matcherValueSystemOption); default: return false; } }
From source file:it.unibo.alchemist.utils.L.java
/** * @param e//from w w w. j ava 2 s. c o m * the Throwable to get and print the stacktrace */ @Deprecated public static void warn(final Throwable e) { log(Level.WARNING, ExceptionUtils.getStackTrace(e)); }
From source file:com.aurel.track.persist.TComputedValuesPeer.java
/** * Loads a computedValuesBean from the TComputedValues table * @param objectID/*from w ww. j a v a2 s . com*/ * @return */ @Override public TComputedValuesBean loadByPrimaryKey(Integer objectID) { TComputedValues tComputedValues = null; try { tComputedValues = retrieveByPK(objectID); } catch (Exception e) { LOGGER.warn( "Loading of a computed value by primary key " + objectID + " failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } if (tComputedValues != null) { return tComputedValues.getBean(); } return null; }
From source file:com.aurel.track.persist.TDashboardFieldPeer.java
/** * Loads the DashboardField by primary key * @param objectID/*from w w w. j a v a 2s . c o m*/ * @return */ @Override public TDashboardFieldBean loadByPrimaryKey(Integer objectID) { Connection con = null; TDashboardFieldBean field = null; try { con = Transaction.begin(DATABASE_NAME); TDashboardField tobject = retrieveByPK(objectID, con); if (tobject != null) { field = tobject.getBean(); setParamaters(field, con); } Transaction.commit(con); } catch (Exception e) { Transaction.safeRollback(con); LOGGER.warn( "Loading of a DashboardField by primary key " + objectID + " failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } return field; }
From source file:mseries.nvspycamera.PinConfigurer.java
protected GpioPinDigital getPin(String gpioName, String name, String type, String value) { Pin raspiPin = null;//from w ww .j a v a 2s .c o m GpioPinDigital pin; logger.debug(gpioName + ", " + name + ", " + type + ", " + value); try { Class<?> c = Class.forName("com.pi4j.io.gpio.RaspiPin"); Field f = c.getDeclaredField(gpioName); raspiPin = (Pin) f.get(null); switch (type) { case "INPUT": c = Class.forName("com.pi4j.io.gpio.PinPullResistance"); f = c.getDeclaredField(value); pin = gpioController.provisionDigitalInputPin(raspiPin, name, (PinPullResistance) f.get(null)); pin.setShutdownOptions(true, PinState.LOW, PinPullResistance.OFF); return pin; case "OUTPUT": c = Class.forName("com.pi4j.io.gpio.PinState"); f = c.getDeclaredField(value); pin = gpioController.provisionDigitalOutputPin(raspiPin, name, (PinState) f.get(null)); pin.setShutdownOptions(true, PinState.LOW); return pin; default: logger.error("Type code:" + type + " is not valid"); } } catch (Exception e) { logger.error(ExceptionUtils.getStackTrace(e)); } return null; }
From source file:ke.co.tawi.babblesms.server.persistence.accounts.AccountDAO.java
/** * @see ke.co.tawi.babblesms.server.persistence.accounts.BabbleAccountDAO#getAccount(java.lang.String) *//* ww w .j ava 2 s .c o m*/ @Override public Account getAccount(String uuid) { Account account = null; try (Connection conn = dbCredentials.getConnection(); PreparedStatement pstmt = conn.prepareStatement("SELECT * FROM Account WHERE Uuid = ?;");) { pstmt.setString(1, uuid); ResultSet rset = pstmt.executeQuery(); if (rset.next()) { account = beanProcessor.toBean(rset, Account.class); } rset.close(); } catch (SQLException e) { logger.error("SQL Exception when getting an account with uuid: " + uuid); logger.error(ExceptionUtils.getStackTrace(e)); } return account; }