Example usage for org.apache.commons.lang3.exception ExceptionUtils getStackTrace

List of usage examples for org.apache.commons.lang3.exception ExceptionUtils getStackTrace

Introduction

In this page you can find the example usage for org.apache.commons.lang3.exception ExceptionUtils getStackTrace.

Prototype

public static String getStackTrace(final Throwable throwable) 

Source Link

Document

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) .

Usage

From source file:com.aurel.track.fieldType.runtime.system.select.SystemSelectBaseLocalizedRT.java

/**
 * Get the show value called when an item result set is implied
 * @param fieldID/*from ww  w  .  ja  va 2 s.  co m*/
 * @param parameterCode
 * @param value
 * @param workItemID
 * @param localLookupContainer
 * @param locale 
 * @return
 */
public String getShowValue(Integer fieldID, Integer parameterCode, Object value, Integer workItemID,
        LocalLookupContainer localLookupContainer, Locale locale) {
    Integer optionID = null;
    if (value != null) {
        try {
            optionID = (Integer) value;
        } catch (Exception e) {
            LOGGER.error("Casting the value type " + value.getClass().getName()
                    + " to Integer in getShowValue() failed with " + e.getMessage());
            LOGGER.debug(ExceptionUtils.getStackTrace(e));
        }
        if (optionID != null) {
            ILabelBean labelBean = LookupContainer.getLocalizedLabelBean(getDropDownMapFieldKey(fieldID),
                    optionID, locale);
            if (labelBean != null) {
                return labelBean.getLabel();
            }
        }
    }
    //try from the database although quite superfluous when the dropdown container is loaded correcly
    LOGGER.debug("The field number " + fieldID + " and parametercode " + parameterCode
            + " was not found in the dropdown container for getting the show value ");
    return getShowValue(value, locale);
}

From source file:com.aurel.track.struts2.interceptor.SystemAdminOrManagerAuthenticationInterceptor.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 {// w  w w .  ja  va2 s .co 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()) {
            if (LOGGER.isDebugEnabled()) {
                return ActionLogBL.logActionTime(actionInvocation, LOGGER);
            } else {
                return actionInvocation.invoke();
            }
        } else {
            return "cockpit";
        }

    }
}

From source file:com.aurel.track.persist.TListPeer.java

/**
 * Loads a list by primary key//from   w w w .jav a2s . c o  m
 * @param objectID
 * @return
 */
@Override
public TListBean loadByPrimaryKey(Integer objectID) {
    TList tList = null;
    try {
        tList = retrieveByPK(objectID);
    } catch (Exception e) {
        LOGGER.info("Loading of a list by primary key " + objectID + " failed with " + e.getMessage());
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
    }
    if (tList != null) {
        return tList.getBean();
    }
    return null;
}

From source file:io.jmnarloch.cd.go.plugin.gradle.GradleTaskExecutor.java

/**
 * {@inheritDoc}/*from ww w.j  av  a 2s  .co  m*/
 */
@Override
public ExecutionResult execute(ExecutionContext context, ExecutionConfiguration config,
        JobConsoleLogger console) {

    try {
        final ProcessBuilder gradle = buildGradleProcess(config, context);

        int result = execute(gradle, console);

        if (!isSuccess(result)) {
            return ExecutionResult.failure(FAILURE);
        }

        return ExecutionResult.success(SUCCESS);
    } catch (Exception e) {
        logger.error("Build failed with error", e);

        console.printLine(e.getMessage());
        console.printLine(ExceptionUtils.getStackTrace(e));

        return ExecutionResult.failure(FAILURE, e);
    }
}

From source file:mamo.vanillaVotifier.Logger.java

@NotNull
public String toString(@Nullable Object object) {
    if (object == null) {
        return "";
    }/*from w  w  w .j  a  va2s . c  o  m*/
    if (!(object instanceof Throwable)) {
        return object.toString();
    } else {
        return ExceptionUtils.getStackTrace((Throwable) object);
    }
}

From source file:com.aurel.track.persist.TMailTemplatePeer.java

/**
 * Loads a mail bean by primary key//ww w .j  av a2s  .com
 * @param objectID
 * @return
 */
@Override
public TMailTemplateBean loadByPrimaryKey(Integer objectID) {
    TMailTemplate tMailTemplate = null;
    try {
        tMailTemplate = retrieveByPK(objectID);
    } catch (Exception e) {
        LOGGER.warn("Loading the mail template by primary key " + objectID + " failed with " + e.getMessage());
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
    }
    if (tMailTemplate != null) {
        return tMailTemplate.getBean();
    }
    return null;
}

From source file:com.aurel.track.persist.TWorkItemLockPeer.java

/**
 * Loads a workItemLockBean by primary key
 * @param objectID/*  ww  w . j a va2 s.  c  om*/
 * @return
 */
@Override
public TWorkItemLockBean loadByPrimaryKey(Integer objectID) {
    TWorkItemLock tWorkItemLock = null;
    try {
        tWorkItemLock = retrieveByPK(objectID);
    } catch (Exception e) {
        //no logging because this can happen quite oft
        LOGGER.debug(
                "Loading of a workItemLockBean by primary key " + objectID + " failed with " + e.getMessage());
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
    }
    if (tWorkItemLock != null) {
        return tWorkItemLock.getBean();
    }
    return null;
}

From source file:com.aurel.track.fieldType.fieldChange.apply.TextAreaFieldChangeApply.java

/**
 * Sets the workItemBean's attribute//from   w  w  w .ja  va 2s. com
 * @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);
    }
    String strValue = null;
    try {
        strValue = (String) value;
    } catch (Exception e) {
        LOGGER.info("Getting the string value for " + value + " failed with " + e.getMessage());
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
    }
    switch (getSetter()) {
    case FieldChangeSetters.SET_TO:
    case FieldChangeSetters.ADD_COMMENT:
        workItemBean.setAttribute(activityType, parameterCode, strValue);
        break;
    case FieldChangeSetters.ADD_TEXT_TO_BEGIN:
        if (strValue != null) {
            String originalValue = (String) workItemBean.getAttribute(activityType, parameterCode);
            if (originalValue != null) {
                String newValue = strValue + " " + originalValue;
                workItemBean.setAttribute(activityType, parameterCode, newValue);
            } else {
                workItemBean.setAttribute(activityType, parameterCode, strValue);
            }
        }
        break;
    case FieldChangeSetters.ADD_TEXT_TO_END:
        if (strValue != null) {
            String originalValue = (String) workItemBean.getAttribute(activityType, parameterCode);
            if (originalValue != null) {
                String newValue = originalValue + " " + strValue;
                workItemBean.setAttribute(activityType, parameterCode, newValue);
            } else {
                workItemBean.setAttribute(activityType, parameterCode, strValue);
            }
        }
        break;
    case FieldChangeSetters.REMOVE_TEXT:
        if (strValue != null) {
            String originalValue = (String) workItemBean.getAttribute(activityType, parameterCode);
            if (originalValue != null) {
                workItemBean.setAttribute(activityType, parameterCode, originalValue.replaceAll(strValue, ""));
            }
        }
        break;
    }
    return null;
}

From source file:com.aurel.track.fieldType.runtime.matchers.converter.MultipleSelectMatcherConverter.java

/**
 * Convert the object value to xml string for save
 * @param value/*from  w w  w  . jav  a 2  s .  com*/
 * @param matcherRelation
 * @return
 */
@Override
public String toXMLString(Object value, Integer matcherRelation) {
    if (value == null || matcherRelation == null) {
        return null;
    }
    switch (matcherRelation.intValue()) {
    case MatchRelations.EQUAL:
    case MatchRelations.NOT_EQUAL:
        Integer[] intArr = null;
        try {
            intArr = (Integer[]) value;
        } catch (Exception e) {
            LOGGER.warn(
                    "Converting the " + value + " to Integer[] for XML string failed with " + e.getMessage());
            LOGGER.debug(ExceptionUtils.getStackTrace(e));
        }
        if (intArr != null && intArr.length > 0) {
            return GeneralUtils.createCommaSeparatedStringFromIntegerArr(intArr);
        }
    }
    return "";
}

From source file:com.aurel.track.fieldType.fieldChange.converter.ItemPickerSetterConverter.java

/**
 * Gets the show value transformed form the stored configuration in database 
 * @param value/* w  w w .  j  av a  2  s. co  m*/
 * @param fieldID
 * @param setter
 * @param locale
 * @return
 */
@Override
public String getDisplayValueFromStoredString(String value, Integer fieldID, Integer setter, Locale locale) {
    if (value != null) {
        Integer[] itemIDs = (Integer[]) getActualValueFromStoredString(value, setter);
        if (itemIDs != null && itemIDs.length > 0) {
            Integer itemID = itemIDs[0];
            if (itemID != null) {
                try {
                    TWorkItemBean workItemBean = ItemBL.loadWorkItem(itemID);
                    if (workItemBean != null) {
                        return ItemBL.getItemNo(workItemBean) + " " + workItemBean.getSynopsis();
                    }
                } catch (ItemLoaderException e) {
                    LOGGER.info("Loading the item " + itemID + " failed with " + e.getMessage());
                    LOGGER.debug(ExceptionUtils.getStackTrace(e));
                }
            }
        }
    }
    return null;
}