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.persist.TNotifySettingsPeer.java
/** * Loads a notifySettingsBean by primary key * @param objectID/* w ww . ja v a 2 s. c om*/ * @return */ @Override public TNotifySettingsBean loadByPrimaryKey(Integer objectID) { TNotifySettings tNotifySettings = null; try { tNotifySettings = retrieveByPK(objectID); } catch (Exception e) { LOGGER.warn("Loading of a notificationSettings by primary key " + objectID + " failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } if (tNotifySettings != null) { return tNotifySettings.getBean(); } return null; }
From source file:com.threewks.thundr.deferred.DeferredTaskService.java
private void run(String message) { DeferredTask deferredTask = null;/* ww w .j av a 2 s . c om*/ try { deferredTask = serializer.deserialize(message); deferredTask.run(); } catch (ClassNotFoundException e) { String errorMessage = "Unable to deserialize task from queue. Class %s not found."; Logger.error(errorMessage, e.getMessage()); throw new ThundrDeferredException(e, errorMessage, e.getMessage()); } catch (Exception e) { Logger.error("Running deferred task failed. Cause: %s", ExceptionUtils.getStackTrace(e)); if (deferredTask != null && deferredTask instanceof RetryableDeferredTask) { Logger.info("Task is retryable, attempting to schedule retry...", e.getMessage()); attemptRetry(((RetryableDeferredTask) deferredTask)); } else { Logger.warn("Task is not retryable. Giving up!"); throw new ThundrDeferredException(e, "Running deferred task failed permanently. Reason: %s", e.getMessage()); } } }
From source file:com.aurel.track.persist.TActionPeer.java
/** * Loads the action by primary key/*from www . j a v a 2 s. c o m*/ * @param objectID * @return */ @Override public TActionBean loadByPrimaryKey(Integer objectID) { TAction tobject = null; try { tobject = retrieveByPK(objectID); } catch (Exception e) { LOGGER.warn("Loading of a action by primary key " + objectID + " failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } if (tobject != null) { return tobject.getBean(); } return null; }
From source file:com.aurel.track.struts2.interceptor.SystemAdminAuthenticationInterceptor.java
@Override public String intercept(ActionInvocation actionInvocation) throws Exception { Map session = actionInvocation.getInvocationContext().getSession(); HttpServletRequest request = ServletActionContext.getRequest(); HttpServletResponse response = ServletActionContext.getResponse(); TPersonBean user = (TPersonBean) session.get(Constants.USER_KEY); if (user == null) { boolean fromAjax = false; try {/*from w ww .j a v a2 s .c o m*/ fromAjax = "true".equalsIgnoreCase(request.getParameter("fromAjax")); } catch (Exception ex) { LOGGER.error(ExceptionUtils.getStackTrace(ex)); } if (fromAjax) { Locale locale = (Locale) session.get(Constants.LOCALE_KEY); if (locale == null) { locale = Locale.getDefault(); } JSONUtility.encodeJSONFailure(response, LocalizeUtil.getLocalizedTextFromApplicationResources("common.noLoggedUser", locale), JSONUtility.ERROR_CODE_NO_USER_LOGIN); return null; } AuthenticationBL.storeUrlOnSession(ServletActionContext.getRequest(), session); return "logon";//TODO rename to Action.LOGIN; } else { if (user.getIsSysAdmin()) { if (LOGGER.isDebugEnabled()) { return ActionLogBL.logActionTime(actionInvocation, LOGGER); } else { return actionInvocation.invoke(); } } else { return "cockpit"; } } }
From source file:io.galeb.router.handlers.RootHandler.java
@Override public void handleRequest(HttpServerExchange exchange) throws Exception { if (enableAccessLog) exchange.addExchangeCompleteListener(accessLogCompletionListener); if (enableStatsd) exchange.addExchangeCompleteListener(statsdCompletionListener); try {//from ww w . j a va 2 s . co m nameVirtualHostHandler.handleRequest(exchange); } catch (Exception e) { logger.error(ExceptionUtils.getStackTrace(e)); ResponseCodeOnError.ROOT_HANDLER_FAILED.getHandler().handleRequest(exchange); } }
From source file:com.aurel.track.fieldType.runtime.matchers.run.IntegerMatcherRT.java
/** * Whether the value matches or not// w ww .j a v a2 s . c o m * @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 attributeValueInteger = null; Integer matcherValueInteger = null; try { attributeValueInteger = (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 { matcherValueInteger = (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 false; } switch (relation) { case MatchRelations.EQUAL: return attributeValueInteger.intValue() == matcherValueInteger.intValue(); case MatchRelations.NOT_EQUAL: return attributeValueInteger.intValue() != matcherValueInteger.intValue(); case MatchRelations.GREATHER_THAN: return attributeValueInteger.intValue() > matcherValueInteger.intValue(); case MatchRelations.GREATHER_THAN_EQUAL: return attributeValueInteger.intValue() >= matcherValueInteger.intValue(); case MatchRelations.LESS_THAN: return attributeValueInteger.intValue() < matcherValueInteger.intValue(); case MatchRelations.LESS_THAN_EQUAL: return attributeValueInteger.intValue() <= matcherValueInteger.intValue(); default: return false; } }
From source file:com.google.refine.model.medadata.PackageExtension.java
/** * To build a Package object from a template file contains empty metadata * //w w w. ja v a 2s . c om * @param templateFile */ public static Package buildPackageFromTemplate() { try { ClassLoader classLoader = PackageExtension.class.getClassLoader(); File file = new File(classLoader.getResource(DATAPACKAGE_TEMPLATE_FILE).getFile()); return new Package(FileUtils.readFileToString(file), false); } catch (ValidationException e) { logger.error("validation failed", ExceptionUtils.getStackTrace(e)); } catch (DataPackageException e) { logger.error("DataPackage Exception", ExceptionUtils.getStackTrace(e)); } catch (IOException e) { logger.error("IOException when build package from template", ExceptionUtils.getStackTrace(e)); } return null; }
From source file:com.aurel.track.fieldType.fieldChange.apply.DoubleFieldChangeApply.java
/** * Sets the workItemBean's attribute/*from w ww. ja v a 2s . co 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); } Double doubleValue = null; try { doubleValue = (Double) value; } catch (Exception e) { LOGGER.warn("Getting the double value for " + value + " failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } switch (getSetter()) { case FieldChangeSetters.SET_TO: workItemBean.setAttribute(activityType, parameterCode, doubleValue); break; case FieldChangeSetters.ADD_IF_SET: if (doubleValue != null) { Double originalValue = (Double) workItemBean.getAttribute(activityType, parameterCode); if (originalValue != null) { double newValue = originalValue.doubleValue() + doubleValue.doubleValue(); workItemBean.setAttribute(activityType, parameterCode, Double.valueOf(newValue)); } } break; case FieldChangeSetters.ADD_OR_SET: if (doubleValue != null) { Double originalValue = (Double) workItemBean.getAttribute(activityType, parameterCode); if (originalValue != null) { double newValue = originalValue.doubleValue() + doubleValue.doubleValue(); workItemBean.setAttribute(activityType, parameterCode, new Double(newValue)); } else { workItemBean.setAttribute(activityType, parameterCode, doubleValue); } } break; } return null; }
From source file:com.aurel.track.fieldType.fieldChange.apply.IntegerFieldChangeApply.java
/** * Sets the workItemBean's attribute/*w ww . j a v a2 s. co 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); } Integer intValue = null; try { intValue = (Integer) value; } catch (Exception e) { LOGGER.warn("Getting the integer value for " + value + " failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } switch (getSetter()) { case FieldChangeSetters.SET_TO: workItemBean.setAttribute(activityType, parameterCode, intValue); break; case FieldChangeSetters.ADD_IF_SET: if (intValue != null) { Integer originalValue = (Integer) workItemBean.getAttribute(activityType, parameterCode); if (originalValue != null) { int newValue = originalValue.intValue() + intValue.intValue(); workItemBean.setAttribute(activityType, parameterCode, Integer.valueOf(newValue)); } } break; case FieldChangeSetters.ADD_OR_SET: if (intValue != null) { Integer originalValue = (Integer) workItemBean.getAttribute(activityType, parameterCode); if (originalValue != null) { int newValue = originalValue.intValue() + intValue.intValue(); workItemBean.setAttribute(activityType, parameterCode, Integer.valueOf(newValue)); } else { workItemBean.setAttribute(activityType, parameterCode, intValue); } } break; } return null; }
From source file:com.aurel.track.struts2.interceptor.ProjectOrSystemAdminAuthenticationInterceptor.java
@Override public String intercept(ActionInvocation actionInvocation) throws Exception { Map session = actionInvocation.getInvocationContext().getSession(); HttpServletResponse response = ServletActionContext.getResponse(); HttpServletRequest request = ServletActionContext.getRequest(); TPersonBean user = (TPersonBean) session.get(Constants.USER_KEY); if (user == null) { boolean fromAjax = false; try {/* w w w. j a va 2s.c o m*/ fromAjax = "true".equalsIgnoreCase(request.getParameter("fromAjax")); } catch (Exception ex) { LOGGER.error(ExceptionUtils.getStackTrace(ex)); } if (fromAjax) { Locale locale = (Locale) session.get(Constants.LOCALE_KEY); if (locale == null) { locale = Locale.getDefault(); } JSONUtility.encodeJSONFailure(response, LocalizeUtil.getLocalizedTextFromApplicationResources("common.noLoggedUser", locale), JSONUtility.ERROR_CODE_NO_USER_LOGIN); return null; } AuthenticationBL.storeUrlOnSession(ServletActionContext.getRequest(), session); return "logon";//TODO rename to Action.LOGIN; } else { if (user.isSys() || user.isProjAdmin()) { if (LOGGER.isDebugEnabled()) { return ActionLogBL.logActionTime(actionInvocation, LOGGER); } else { return actionInvocation.invoke(); } } else { return "cockpit"; } } }