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.admin.customize.category.filter.execute.ReportQueryBL.java

private static String encrypt(String clearText, char[] password) {
    // Create PBE parameter set
    PBEParameterSpec pbeParamSpec = new PBEParameterSpec(salt, count);
    byte[] ciphertext = { 0 };

    PBEKeySpec pbeKeySpec = new PBEKeySpec(password);
    try {/*w w w . java  2  s .c o  m*/
        SecretKeyFactory keyFac = SecretKeyFactory.getInstance("PBEWithMD5AndDES");
        SecretKey pbeKey = keyFac.generateSecret(pbeKeySpec);

        // Create PBE Cipher
        Cipher pbeCipher = Cipher.getInstance("PBEWithMD5AndDES");

        // Initialize PBE Cipher with key and parameters
        pbeCipher.init(Cipher.ENCRYPT_MODE, pbeKey, pbeParamSpec);

        // Encrypt the cleartext
        ciphertext = pbeCipher.doFinal(clearText.getBytes());
    } catch (Exception e) {
        LOGGER.debug(ExceptionUtils.getStackTrace(e), e);
    }
    return new String(Base64.encodeBase64(ciphertext));
}

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

/**
 * Loads a FieldChangeBean by primary key 
 * @param objectID/*from   w  ww.  j  a v a2  s  .  co  m*/
 * @return
 */
@Override
public TFieldChangeBean loadByPrimaryKey(Integer objectID) {
    TFieldChange tFieldChange = null;
    try {
        tFieldChange = retrieveByPK(objectID);
    } catch (Exception e) {
        LOGGER.warn("Loading of a field change by primary key " + objectID + " failed with " + e.getMessage());
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
    }
    if (tFieldChange != null) {
        return tFieldChange.getBean();
    }
    return null;
}

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

/**
 * Loads the DashboardPanel by primary key
 * @param objectID/*from w w w .j a va2 s  .c o  m*/
 * @return
 */
@Override
public TDashboardPanelBean loadByPrimaryKey(Integer objectID) {
    TDashboardPanel tobject = null;
    try {
        tobject = retrieveByPK(objectID);
    } catch (Exception e) {
        LOGGER.warn(
                "Loading of a DashboardPanel 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.fieldType.runtime.matchers.converter.CompositSelectMatcherConverter.java

/**
 * Convert the object value to xml string for save
 * @param value/*www. j a va  2s. c o m*/
 * @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:
    case MatchRelations.PARTIAL_MATCH:
    case MatchRelations.PARTIAL_NOTMATCH:
        SortedMap<Integer, Integer[]> actualValuesMap = null;
        try {
            actualValuesMap = (SortedMap<Integer, Integer[]>) value;
        } catch (Exception e) {
            LOGGER.warn("Converting the " + value
                    + " to SortedMap<Integer, Integer[]> for display string failed with " + e.getMessage());
            LOGGER.debug(ExceptionUtils.getStackTrace(e));
        }
        if (actualValuesMap != null) {
            StringBuffer stringBuffer = new StringBuffer();
            Iterator<Integer> iterator = actualValuesMap.keySet().iterator();
            while (iterator.hasNext()) {
                Integer partNo = iterator.next();
                Integer[] partValueArr = null;
                try {
                    partValueArr = actualValuesMap.get(partNo);
                } catch (Exception e) {
                    LOGGER.warn("Converting the part " + partNo
                            + " to Integer[] for XML string string failed with " + e.getMessage());
                    LOGGER.debug(ExceptionUtils.getStackTrace(e));
                }
                String partValue = "";
                if (partValueArr != null && partValueArr.length > 0) {
                    //partValue is probably an integer array
                    //if there is a possibility that the composite contains also other
                    //datatypes for example date which should be formatted then 
                    //we would need to extend the API with further method parameters
                    partValue = partValueArr[0].toString();
                }
                stringBuffer.append(partValue);
                if (iterator.hasNext()) {
                    stringBuffer.append(PART_SPLITTER_STRING);
                }
            }
            return stringBuffer.toString().trim();
        }
    }
    return null;
}

From source file:com.aurel.track.fieldType.runtime.matchers.run.CustomSelectMatcherRT.java

/**
 * Whether the value matches or not/*from w  w w.  j  av  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;
    }
    Object[] attributeValueCustomOption = null;
    Integer[] matcherValueCustomOption = null;
    try {
        attributeValueCustomOption = (Object[]) attributeValue;
    } catch (Exception e) {
        LOGGER.warn("Converting the attribute value " + attributeValue + " of type "
                + attributeValue.getClass().getName() + " to Object[] failed with " + e.getMessage());
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
        return false;
    }
    try {
        matcherValueCustomOption = (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;
    }

    if (attributeValueCustomOption.length == 0) {
        //attributeValueCustomOption should have at least one element but could have more
        return false;
    }
    if (matcherValueCustomOption == null || matcherValueCustomOption.length == 0) {
        //matcherValueCustomOption should have one element
        return false;
    }

    switch (relation) {
    case MatchRelations.EQUAL:
        return containsValue(matcherValueCustomOption, attributeValueCustomOption);
    case MatchRelations.NOT_EQUAL:
        return !containsValue(matcherValueCustomOption, attributeValueCustomOption);
    default:
        return false;
    }
}

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

/**
 * Loads a severityBean by primary key /*from  www . j a v a  2  s  .  c om*/
 * @param objectID
 * @return
 */
@Override
public TSeverityBean loadByPrimaryKey(Integer objectID) {
    TSeverity tSeverity = null;
    try {
        tSeverity = retrieveByPK(objectID);
    } catch (Exception e) {
        LOGGER.info("Loading the severity by primary key " + objectID + " failed with " + e.getMessage());
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
    }
    if (tSeverity != null) {
        return tSeverity.getBean();
    }
    return null;
}

From source file:com.aurel.track.fieldType.runtime.matchers.run.CompositeSelectMatcherRT.java

/**
 * Whether the value matches or not//from ww  w .j ava 2 s.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;
    }
    Map<Integer, Object> attributeValueMap = null;
    try {
        attributeValueMap = (Map<Integer, Object>) attributeValue;
    } catch (Exception e) {
        LOGGER.warn("Converting the attribute value of type " + attributeValue.getClass().getName()
                + " to Map<Integer, Object failed with " + e.getMessage());
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
    }
    SortedMap<Integer, Object> matcherValueMap = null;
    try {
        matcherValueMap = (SortedMap<Integer, Object>) matchValue;
    } catch (Exception e) {
        LOGGER.warn("Converting the matcher value of type " + matchValue.getClass().getName()
                + " to SortedMap<Integer, Object> failed with " + e.getMessage());
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
    }
    if (attributeValueMap == null || matcherValueMap == null) {
        return false;
    }
    Iterator<Integer> iterator = matcherValueMap.keySet().iterator();
    while (iterator.hasNext()) {
        Integer parameterCode = iterator.next();
        Object[] attributeValueCustomOption = null;
        try {
            attributeValueCustomOption = (Object[]) attributeValueMap.get(parameterCode);
        } catch (Exception e) {
            LOGGER.warn("Converting the attribute value for part " + parameterCode + " to Object[] failed with "
                    + e.getMessage());
            LOGGER.debug(ExceptionUtils.getStackTrace(e));
            return false;
        }
        Integer[] matcherValueCustomOption = null;
        try {
            matcherValueCustomOption = (Integer[]) matcherValueMap.get(parameterCode);
        } catch (Exception e) {
            LOGGER.error("Converting the matcher value for part " + parameterCode + " to Integer[] failed with "
                    + e.getMessage());
            LOGGER.debug(ExceptionUtils.getStackTrace(e));
            return false;
        }

        if (attributeValueCustomOption == null) {
            attributeValueCustomOption = new Object[0];
        }
        if (matcherValueCustomOption == null) {
            matcherValueCustomOption = new Integer[0];
        }
        if (attributeValueCustomOption.length != matcherValueCustomOption.length) {
            return false;
        }

        if (matcherValueCustomOption.length == 0) {
            return matcherValueCustomOption.length == 0;
        }
        Integer matcherValueAtLevel = matcherValueCustomOption[0];
        switch (relation) {
        case MatchRelations.EQUAL:
            if (!containsValue(matcherValueAtLevel, attributeValueCustomOption)) {
                return false;
            }
            break;
        case MatchRelations.NOT_EQUAL:
            if (!containsValue(matcherValueAtLevel, attributeValueCustomOption)) {
                return true;
            }
            break;
        case MatchRelations.PARTIAL_MATCH:
            if (matcherValueAtLevel.equals(ANY_FROM_LEVEL)) {
                return true;
            } else {
                if (!containsValue(matcherValueAtLevel, attributeValueCustomOption)) {
                    return false;
                }
            }
            break;
        case MatchRelations.PARTIAL_NOTMATCH:
            if (!containsValue(matcherValueAtLevel, attributeValueCustomOption)
                    && !matcherValueCustomOption[0].equals(NONE_FROM_LEVEL)) {
                return true;
            }
            break;
        default:
            return false;
        }
    }
    if (relation == MatchRelations.NOT_EQUAL || relation == MatchRelations.PARTIAL_NOTMATCH) {
        return false;
    } else {
        return true;
    }
}

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

/**
 * Loads a TUserLevelBean by primary key
 * @param objectID//from  w ww. ja  v  a2 s  .  c o m
 * @return
 */
@Override
public TUserLevelBean loadByPrimaryKey(Integer objectID) {
    TUserLevel tUserLevel = null;
    try {
        tUserLevel = retrieveByPK(objectID);
    } catch (Exception e) {
        LOGGER.info("Loading the user level by primary key " + objectID + " failed with " + e.getMessage());
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
    }
    if (tUserLevel != null) {
        return tUserLevel.getBean();
    }
    return null;
}

From source file:com.aurel.track.fieldType.runtime.matchers.run.AccountingTimeMatcherRT.java

/**
 * Whether the value matches or not/*from  w w  w . ja v a  2 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;
    }
    AccountingTimeTO attributeValueAccountingTime = null;
    AccountingTimeTO matcherValueAccountingTime = null;
    try {
        attributeValueAccountingTime = (AccountingTimeTO) attributeValue;
    } catch (Exception e) {
        LOGGER.error("Converting the attribute value " + attributeValue + " of type "
                + attributeValue.getClass().getName() + " to AccountingTimeTO failed with " + e.getMessage());
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
        return false;
    }
    try {
        matcherValueAccountingTime = (AccountingTimeTO) matchValue;
    } catch (Exception e) {
        LOGGER.warn("Converting the matcher value " + matchValue + " of type " + matchValue.getClass().getName()
                + " to AccountingTimeTO failed with " + e.getMessage(), e);
        return false;
    }

    Double attributeValueDouble = attributeValueAccountingTime.getValue();
    Double matcherValueDouble = matcherValueAccountingTime.getValue();
    if (attributeValueDouble == null || matcherValueDouble == null) {
        return false;
    }
    Integer attributeValueUnit = attributeValueAccountingTime.getUnit();
    Integer matcherValueUnit = matcherValueAccountingTime.getUnit();
    if (attributeValueUnit == null) {
        attributeValueUnit = TIMEUNITS.HOURS;
    }
    if (matcherValueUnit == null) {
        matcherValueUnit = TIMEUNITS.HOURS;
    }
    if (!attributeValueUnit.equals(matcherValueUnit)) {
        if (attributeValueUnit.intValue() != TIME_UNIT.HOUR) {

            attributeValueDouble = AccountingBL.transformToTimeUnits(attributeValueDouble,
                    this.getHourPerWorkday(), attributeValueUnit, TIME_UNIT.HOUR).doubleValue();
        }
        if (matcherValueUnit.intValue() != TIME_UNIT.HOUR) {
            matcherValueDouble = AccountingBL.transformToTimeUnits(matcherValueDouble, this.getHourPerWorkday(),
                    matcherValueUnit, TIME_UNIT.HOUR).doubleValue();
        }
    }
    switch (relation) {
    case MatchRelations.EQUAL:
        return (Double.doubleToRawLongBits(attributeValueDouble.doubleValue())
                - Double.doubleToRawLongBits(matcherValueDouble.doubleValue()) == 0);
    case MatchRelations.NOT_EQUAL:
        return (Double.doubleToRawLongBits(attributeValueDouble.doubleValue())
                - Double.doubleToRawLongBits(matcherValueDouble.doubleValue()) != 0);
    case MatchRelations.GREATHER_THAN:
        return attributeValueDouble.doubleValue() > matcherValueDouble.doubleValue();
    case MatchRelations.GREATHER_THAN_EQUAL:
        return attributeValueDouble.doubleValue() >= matcherValueDouble.doubleValue();
    case MatchRelations.LESS_THAN:
        return attributeValueDouble.doubleValue() < matcherValueDouble.doubleValue();
    case MatchRelations.LESS_THAN_EQUAL:
        return attributeValueDouble.doubleValue() <= matcherValueDouble.doubleValue();
    default:
        return false;
    }
}

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

/**
 * Loads a priorityBean by primary key /*from w ww .  j a  v a 2 s .  co  m*/
 * @param objectID
 * @return
 */
@Override
public TPriorityBean loadByPrimaryKey(Integer objectID) {
    TPriority tPriority = null;
    try {
        tPriority = retrieveByPK(objectID);
    } catch (Exception e) {
        LOGGER.info("Loading the priority by primary key " + objectID + " failed with " + e.getMessage());
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
    }
    if (tPriority != null) {
        return tPriority.getBean();
    }
    return null;
}