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.dbase.Migrate500To502.java

/**
 * Add inline linked link type/*from ww  w  .j a va  2s.c  o  m*/
 */
static void addInlineLinkedLinkType() {
    List<TLinkTypeBean> inlinelinkTypeBeans = LinkTypeBL
            .loadByLinkType(InlineLinkType.getInstance().getPluginID(), null);
    if (inlinelinkTypeBeans == null || inlinelinkTypeBeans.isEmpty()) {
        TLinkTypeBean linkTypeBean = LinkTypeBL.loadByPrimaryKey(13);
        if (linkTypeBean == null) {
            LOGGER.info("Add 'inline linked' link type with fixed ID");
            Connection cono = null;
            try {
                cono = InitDatabase.getConnection();
                Statement ostmt = cono.createStatement();
                cono.setAutoCommit(false);
                String inlineLinkTypeStmt = addInlineLinkTypeStmt(13, "is inline linked in",
                        "the filtered items are inline linked to", LINK_DIRECTION.RIGHT_TO_LEFT,
                        InlineLinkType.class.getName(), "0123456789");
                ostmt.executeUpdate(inlineLinkTypeStmt);
                cono.commit();
                cono.setAutoCommit(true);
            } catch (Exception e) {
                LOGGER.debug(ExceptionUtils.getStackTrace(e));
            } finally {
                try {
                    if (cono != null) {
                        cono.close();
                    }
                } catch (Exception e) {
                    LOGGER.info("Closing the connection failed with " + e.getMessage());
                    LOGGER.debug(ExceptionUtils.getStackTrace(e));
                }
            }
        } else {
            LOGGER.info("Add 'inline linked' link type at end");
            UpgradeDatabase.addLinkType("is inline linked in", "the filtered items are inline linked to",
                    LINK_DIRECTION.RIGHT_TO_LEFT, InlineLinkType.class.getName());
        }
    }
}

From source file:com.aurel.track.dbase.Migrate411To412.java

public static void addTaskIsMilestone() {
    TFieldBean taskIsMilestoneFieldBean = FieldBL.loadByPrimaryKey(SystemFields.INTEGER_TASK_IS_MILESTONE);
    if (taskIsMilestoneFieldBean == null) {
        LOGGER.info("Adding task is milestone field");
        Connection cono = null;/*from  w  w  w. ja v a2s.c om*/
        try {
            cono = InitDatabase.getConnection();
            Statement ostmt = cono.createStatement();
            cono.setAutoCommit(false);
            ostmt.executeUpdate(addField(SystemFields.INTEGER_TASK_IS_MILESTONE, "TaskIsMilestone",
                    "com.aurel.track.fieldType.types.system.check.SystemTaskIsMilestone"));
            ostmt.executeUpdate(addFieldConfig(SystemFields.INTEGER_TASK_IS_MILESTONE,
                    SystemFields.INTEGER_TASK_IS_MILESTONE, "Task is milestone", "Is milestone"));
            cono.commit();
            cono.setAutoCommit(true);
        } catch (Exception e) {
            LOGGER.debug(ExceptionUtils.getStackTrace(e));
        } finally {
            try {
                if (cono != null) {
                    cono.close();
                }
            } catch (Exception e) {
                LOGGER.debug(ExceptionUtils.getStackTrace(e));
            }
        }
    }
}

From source file:com.chiorichan.factory.parsers.IncludesParser.java

@Override
public String resolveMethod(String... args) throws Exception {
    if (args.length > 2)
        Log.get(factory).warning("EvalFactory: include() method only accepts one argument, ignored.");

    // TODO Prevent infinite loops!
    ScriptingResult result = factory//from   w w w  .jav  a 2  s  . c o  m
            .eval(ScriptingContext.fromAuto(context.site(), args[1]).request(context.request()));

    if (result.hasNonIgnorableExceptions())
        ExceptionReport.throwExceptions(result.getExceptions());
    else if (result.hasIgnorableExceptions()) {
        StringBuilder sb = new StringBuilder();
        for (ScriptingException e : result.getExceptions())
            sb.append(ExceptionUtils.getStackTrace(e) + "\n");
        return sb.toString();
    }

    return result.getString();
}

From source file:it.infn.mw.iam.core.web.IamErrorController.java

@RequestMapping(PATH)
public ModelAndView error(HttpServletRequest request) {

    ModelAndView errorPage = new ModelAndView(IAM_ERROR_VIEW);

    HttpStatus status = HttpStatus.valueOf(getErrorCode(request));

    errorPage.addObject("errorMessage", String.format("%d. %s", status.value(), status.getReasonPhrase()));

    Exception exception = getRequestException(request);

    if (exception != null) {
        errorPage.addObject("exceptionMessage", exception.getMessage());
        errorPage.addObject("exceptionStackTrace", ExceptionUtils.getStackTrace(exception).trim());
    }/*w ww  .  jav  a  2  s.co  m*/
    return errorPage;
}

From source file:com.aurel.track.util.emailHandling.SyncStore.java

public synchronized static boolean connect(Store _store, String _protocol, String _host, int _port,
        String _user, String _password) {
    ConnectionPoint cp = getConnPoint(_store, _protocol, _host, _port, _user, _password);
    boolean connected = false;
    try {/*from www  . j a v  a2s . co  m*/
        Store store = cp.getStore();
        if (!store.isConnected()) {
            cp.getStore().connect(_host, _port, _user, _password);
        }
        ++cp.connectionCount;
        LOGGER.debug("Connecting store: connectionCount = " + cp.connectionCount);
        connected = true;
    } catch (Exception e) {
        connected = false;
        if (LogThrottle.isReady("Syncstore1", 240)) {
            LOGGER.warn("Could not connect..." + e.getMessage());
        }
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
    }
    return connected;
}

From source file:com.google.refine.model.medadata.MetadataFactory.java

/**
 * Build an empty data package metadata, then populate the fields from the Project Metadata
 * @param project//www  .j a  va  2s.c  o m
 * @return
 */
public static DataPackageMetadata buildDataPackageMetadata(Project project) {
    DataPackageMetadata dpm = buildDataPackageMetadata();
    ProjectMetadata pmd = project.getMetadata();
    Package pkg = dpm.getPackage();
    Resource resource = SchemaExtension.createResource(project.getMetadata().getName(), project.columnModel);
    try {
        pkg.addResource(resource);

        putValue(pkg, Package.JSON_KEY_NAME, pmd.getName());
        putValue(pkg, PackageExtension.JSON_KEY_LAST_UPDATED,
                ParsingUtilities.localDateToString(pmd.getModified()));
        putValue(pkg, PackageExtension.JSON_KEY_DESCRIPTION, pmd.getDescription());
        putValue(pkg, PackageExtension.JSON_KEY_TITLE, pmd.getTitle());
        putValue(pkg, PackageExtension.JSON_KEY_HOMEPAGE, pmd.getHomepage());
        putValue(pkg, PackageExtension.JSON_KEY_IMAGE, pmd.getImage());
        putValue(pkg, PackageExtension.JSON_KEY_LICENSE, pmd.getLicense());

        pkg.removeProperty(PackageExtension.JSON_KEY_KEYWORKS);
        pkg.addProperty(PackageExtension.JSON_KEY_KEYWORKS, JSONUtilities.arrayToJSONArray(pmd.getTags()));
    } catch (ValidationException | IOException | DataPackageException e) {
        logger.error(ExceptionUtils.getStackTrace(e));
    }

    return dpm;
}

From source file:cz.muni.fi.editor.webapp.controllers.ExceptionHandlingController.java

@ExceptionHandler(AccessDeniedException.class)
public String handlePermission(AccessDeniedException ex, Model model) {
    String stackTrace = ExceptionUtils.getStackTrace(ex);
    model.addAttribute("errorMessage", stackTrace);

    return "error";
}

From source file:ch.jamiete.hilda.music.MusicLogFormat.java

@Override
public final String format(final LogRecord record) {
    String log = "";

    log += this.sdf.format(new Date(record.getMillis()));
    log += " [" + record.getLevel().getLocalizedName().toUpperCase() + ']';

    if (record.getSourceClassName() != null) {
        final String[] split = record.getSourceClassName().split("\\.");
        log += " [" + split[(split.length == 1) ? 0 : (split.length - 1)] + ']';
    }//from  w w w  .ja v a  2 s  .  c o  m

    if (record.getSourceMethodName() != null) {
        log += " (" + record.getSourceMethodName() + ')';
    }

    log += ' ' + record.getMessage();

    if (record.getThrown() != null) {
        /*log += "\n" + record.getThrown().getMessage();
                
        for (StackTraceElement element : record.getThrown().getStackTrace()) {
        log += "\n" + element.toString();
        }*/
        log += '\n' + ExceptionUtils.getStackTrace(record.getThrown());
    }

    log += System.getProperty("line.separator");

    return log;
}

From source file:com.aurel.track.fieldType.runtime.bl.CustomSelectUtil.java

public static Integer[] getSelectedOptionsFromStringArr(Object attributeValue) {
    Integer[] integerOptionIDs = null;
    String[] stringOptionIDs = null;
    if (attributeValue != null) {
        try {//  ww w . j  a  va  2  s.c  o  m
            stringOptionIDs = (String[]) attributeValue;
        } catch (Exception e) {
            LOGGER.warn("The type of the attributeValue source is " + attributeValue.getClass().getName()
                    + ". Casting it to String[] failed with " + e.getMessage());
            LOGGER.debug(ExceptionUtils.getStackTrace(e));
        }
        if (stringOptionIDs != null) {
            integerOptionIDs = new Integer[stringOptionIDs.length];
            for (int i = 0; i < stringOptionIDs.length; i++) {
                if ("".equals(stringOptionIDs[i])) {
                    //probably list was empty and no real value was submitted just an empty string 
                    integerOptionIDs[i] = null;
                    break;
                } else {
                    integerOptionIDs[i] = new Integer(stringOptionIDs[i]);
                }
            }
            //clean the null values
            integerOptionIDs = getNotNullValues(integerOptionIDs);
        }
    }
    return integerOptionIDs;
}

From source file:com.arrow.acs.Loggable.java

public void logError(String method, Throwable throwable) {
    logger.error(formatLog(method, ExceptionUtils.getStackTrace(throwable)));
}