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.linkedin.pinot.core.block.query.IntermediateResultsBlock.java

public IntermediateResultsBlock(Exception e) {
    if (_processingExceptions == null) {
        _processingExceptions = new ArrayList<ProcessingException>();
    }//from   w  w w. j  a  v  a  2s  . com
    ProcessingException exception = QueryException.QUERY_EXECUTION_ERROR.deepCopy();
    exception.setMessage(ExceptionUtils.getStackTrace(e));
    _processingExceptions.add(exception);
}

From source file:com.aurel.track.struts2.interceptor.AuthenticationItemNavigator.java

/**
 * Standard authentication procedure including extra checking: If the user 
 * is CLIENT user and not from Teamgeist then item navigator is disabled. 
 *   Client user will be redirected to cockpits. 
 *   In case of a CLIENT user from Teamgeist the procedure is allowed
 * /*from w ww .  j  a  v a 2 s  .co  m*/
 */
@Override
public String intercept(ActionInvocation actionInvocation) throws Exception {
    //get the actual request
    HttpServletRequest request = ServletActionContext.getRequest();
    HttpServletResponse response = ServletActionContext.getResponse();
    //force the creation of a new session if it does not exist yet
    request.getSession();
    Map<String, Object> session = actionInvocation.getInvocationContext().getSession();
    //if session is new set the newly created session map into the Action context
    //(instead of null). Otherwise the SessionAware interface sets the wrong session object
    //which does not contain the session attributes (user, etc.)
    if (session == null || session.isEmpty()) {
        session = new SessionMap(ServletActionContext.getRequest());
        ActionContext.getContext().setSession(session);
    }
    TPersonBean personBean = (TPersonBean) session.get(Constants.USER_KEY);
    if (personBean == null && ApplicationBean.getInstance().getSiteBean() != null) {
        if (!BypassLoginHelper.loginAsGuest(request, session)) {
            boolean fromAjax = false;
            try {
                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(request, session);
            return "logon";//TODO rename to Action.LOGIN;
        }
    } else {
        if (personBean.getUserLevel().intValue() == USERLEVEL.CLIENT.intValue()
                && !MobileBL.isMobileApp(session)) {
            LOGGER.debug("Client user tries to access item navigator. Will be redirected to cockpits!");
            return "cockpit";
        }
    }
    return actionInvocation.invoke();
}

From source file:ke.co.tawi.babblesms.server.persistence.contacts.ContactGroupDAO.java

/**
 * @see ke.co.tawi.babblesms.server.persistence.contacts.BabbleContactGroupDAO#putContact(ke.co.tawi.babblesms.server.beans.contact.Contact, ke.co.tawi.babblesms.server.beans.contact.Group)
 * /* ww  w .  j  ava  2 s. c  om*/
 * @return <code>true if the relationship can be established.</code>, <code> false otherwise</code>
 */
@Override
public boolean putContact(Contact contact, Group group) {
    boolean success = true;

    try (Connection conn = dbCredentials.getConnection();
            PreparedStatement pstmt = conn.prepareStatement("INSERT INTO ContactGroup "
                    + "(Uuid, contactuuid, groupuuid, accountuuid) VALUES (?,?,?,?);");) {
        pstmt.setString(1, UUID.randomUUID().toString());
        pstmt.setString(2, contact.getUuid());
        pstmt.setString(3, group.getUuid());
        pstmt.setString(4, contact.getAccountUuid());

        pstmt.execute();

    } catch (SQLException e) {
        logger.error("SQL Exception when trying to put " + contact + " into " + group);
        logger.error(ExceptionUtils.getStackTrace(e));
        success = false;
    }

    return success;
}

From source file:com.gatf.executor.executor.SingleTestCaseExecutor.java

public List<TestCaseReport> executeDirectTestCase(TestCase testCase,
        TestCaseExecutorUtil testCaseExecutorUtil) {

    TestCaseReport testCaseReport = new TestCaseReport();
    testCaseReport.setTestCase(testCase);
    testCaseReport.setNumberOfRuns(1);/* w ww  .ja v a  2s .c  o m*/

    ListenableFuture<TestCaseReport> report = testCaseExecutorUtil.executeTestCase(testCase, testCaseReport);
    try {
        testCaseReport = report.get();
    } catch (Exception e) {
        testCaseReport.setStatus(TestStatus.Failed.status);
        testCaseReport.setError(e.getMessage());
        testCaseReport.setErrorText(ExceptionUtils.getStackTrace(e));
        e.printStackTrace();
    }

    List<TestCaseReport> lst = new ArrayList<TestCaseReport>();
    lst.add(testCaseReport);
    return lst;
}

From source file:jp.co.ipublishing.esnavi.impl.shelter.ShelterClient.java

@NonNull
@Override// w w w  . jav  a2 s  .  co  m
public Observable<ShelterNumberOfPeople> downloadNumberOfPeople() {
    return Observable.create(new Observable.OnSubscribe<ShelterNumberOfPeople>() {
        @Override
        public void call(Subscriber<? super ShelterNumberOfPeople> subscriber) {
            final ApiMethod apiMethod = mApi.downloadNumberOfPeople();

            try {
                final Request request = new Request.Builder().url(apiMethod.getUrl()).get().build();

                final Response response = mClient.newCall(request).execute();
                final String result = response.body().string();

                final ShelterNumberOfPeople numbers = ShelterFactory.createNumberOfPeople(result);

                subscriber.onNext(numbers);
                subscriber.onCompleted();
            } catch (IOException | JSONException | ParseException e) {
                Log.e(TAG, ExceptionUtils.getStackTrace(e));

                subscriber.onError(e);
            }
        }
    });
}

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

/**
 * Loads the field by primary key//w w w  . j a va2s  .co m
 * @param objectID
 * @return
 */
@Override
public TFieldBean loadByPrimaryKey(Integer objectID) {
    TField tField = null;
    try {
        tField = retrieveByPK(objectID);
    } catch (Exception e) {
        LOGGER.info("Loading of a field by primary key " + objectID + " failed with " + e.getMessage());
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
    }
    if (tField != null) {
        return tField.getBean();
    }
    return null;
}

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

/**
 * Stop the database server/*from  w ww  .  ja v  a2s .  co  m*/
 */
public static void stopDbServer() {

    System.setProperty("derby.drda.startNetworkServer", "true");
    databaseIsInitialized = false;
    if (dbServer == null) {
        try {
            dbServer = new NetworkServerControl(InetAddress.getByName("localhost"), 15270, user, password);
        } catch (Exception e) {
            LOGGER.error(ExceptionUtils.getStackTrace(e));
        }
    }
    try {
        Torque.shutdown();
        dbServer.shutdown();
    } catch (Exception e) {
        if (!e.getMessage().contains("Connection refused")) {
            LOGGER.info("Derby server shutdown failed. Ignoring this, but you should check! " + e.getMessage());
            LOGGER.debug("Stack trace: ", e);
        }
    }
}

From source file:com.aurel.track.screen.dashboard.template.DashboardTemplateAction.java

public String copyAsTemplateDashboard() {
    TDashboardScreenBean dashboardScreenBean = null;
    TPersonBean user = (TPersonBean) session.get(Constants.USER_KEY);
    if (projectID != null) {
        dashboardScreenBean = DashboardScreenDesignBL.getInstance().loadByProject(user.getObjectID(), projectID,
                entityType);//from  w w w .j a va2s  .  c o  m
    } else {
        dashboardScreenBean = DashboardScreenDesignBL.getInstance().loadByPerson(user);
    }

    StringBuilder sb = new StringBuilder();
    sb.append("{");
    JSONUtility.appendBooleanValue(sb, JSONUtility.JSON_FIELDS.SUCCESS, true);
    JSONUtility.appendJSONValue(sb, JSONUtility.JSON_FIELDS.DATA,
            ScreenDesignBL.getInstance().encodeJSONScreenTO(dashboardScreenBean), true);
    sb.append("}");
    try {
        JSONUtility.prepareServletResponseJSON(ServletActionContext.getResponse());
        PrintWriter out = ServletActionContext.getResponse().getWriter();
        out.println(sb);
    } catch (IOException e) {
        LOGGER.error(ExceptionUtils.getStackTrace(e));
    }
    return null;
}

From source file:ke.co.tawi.babblesms.server.persistence.logs.OutgoingGroupLogDAO.java

/**
 * @see ke.co.tawi.babblesms.server.persistence.logs.BabbleOutgoingGroupLogDAO#putOutgoingGrouplog(ke.co.tawi.babblesms.server.beans.log.OutgoingGrouplog)
 *///from w  w w  . j a  v a2  s. c om
@Override
public boolean put(OutgoingGrouplog log) {
    boolean success = true;
    try (Connection conn = dbCredentials.getConnection();
            PreparedStatement pstmt = conn
                    .prepareStatement("INSERT INTO OutgoinggroupLog (Uuid, origin, networkuuid,"
                            + "destination, message, sender, messagestatusuuid, logTime) "
                            + "VALUES (?,?,?,?,?,?,?,?);");) {

        pstmt.setString(1, log.getUuid());
        pstmt.setString(2, log.getOrigin());
        pstmt.setString(3, log.getNetworkUuid());
        pstmt.setString(4, log.getDestination());
        pstmt.setString(5, log.getMessage());
        pstmt.setString(6, log.getSender());
        pstmt.setString(7, log.getMessagestatusuuid());
        pstmt.setTimestamp(8, new Timestamp(log.getLogTime().getTime()));

        pstmt.execute();

    } catch (SQLException e) {
        logger.error("SQL Exception when trying to put: " + log);
        logger.error(ExceptionUtils.getStackTrace(e));
        success = false;

    }
    return success;

}

From source file:gt.org.ms.api.global.GlobalExceptionHandler.java

protected ResponseEntity handleException(BaseException ex) {
    List<ValidationError> errors;
    if (ex instanceof ValidationException) {
        errors = ((ValidationException) ex).getErrors();
    } else {/*from   www.j  a v  a 2  s .c om*/
        errors = Arrays.asList(new ValidationError("internal_error",
                ExceptionUtils.getStackTrace(ex.getCause() != null ? ex.getCause() : ex)));
    }
    StringBuffer sb = new StringBuffer("<div style='color:#b72222; font-weight: bold'>")
            .append("Listado errores:</div><ol>");
    for (ValidationError e : errors) {
        sb = sb.append("<li style='color: #b72222;'>").append(e.getPath()).append(e.getMessage())
                .append("</li>");
    }
    sb.append("</ol>");
    HttpHeaders responseHeaders = new HttpHeaders();
    responseHeaders.setContentType(MediaType.TEXT_HTML);

    return new ResponseEntity<String>(sb.toString(), responseHeaders, ex.getHttpStatus());
}