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:ke.co.tawi.babblesms.server.persistence.maskcode.MaskDAO.java

/**
 * @see ke.co.tawi.babblesms.server.persistence.maskcode.BabbleMaskDAO#get(java.lang.String)
 *//*from   w ww.  j  a  va2 s.c  o m*/
@Override
public Mask get(String uuid) {
    Mask mask = null;

    try (Connection conn = dbCredentials.getConnection();
            PreparedStatement pstmt = conn.prepareStatement("SELECT * FROM Mask WHERE Uuid = ?;");) {
        pstmt.setString(1, uuid);

        try (ResultSet rset = pstmt.executeQuery();) {
            if (rset.next()) {
                mask = beanProcessor.toBean(rset, Mask.class);
            }
        }

    } catch (SQLException e) {
        logger.error("SQL Exception when getting mask with uuid: " + uuid);
        logger.error(ExceptionUtils.getStackTrace(e));
    }

    return mask;
}

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

/**
 * @see ke.co.tawi.babblesms.server.persistence.contacts.BabblePhoneDAO#getPhone(java.lang.String)
 *//*w  ww. ja va  2s  .  co m*/
@Override
public Phone getPhone(String uuid) {
    Phone phone = null;

    try (Connection conn = dbCredentials.getConnection();
            PreparedStatement psmt = conn.prepareStatement("SELECT * FROM phone WHERE " + "uuid = ?;");) {

        psmt.setString(1, uuid);

        ResultSet rset = psmt.executeQuery();

        if (rset.next()) {
            phone = beanProcessor.toBean(rset, Phone.class);
        }

        rset.close();

    } catch (SQLException e) {
        logger.error("SQLException when getting phone with uuid: " + uuid);
        logger.error(ExceptionUtils.getStackTrace(e));
    }

    return phone;
}

From source file:jp.co.ipublishing.aeskit.alert.AlertService.java

/**
 * ???//from  w  w w.  j  av a  2  s  .  com
 */
private void fetchAlert() {
    mAlertManager.fetchAlert().subscribeOn(Schedulers.newThread()).subscribe(new Subscriber<Alert>() {
        @Override
        public void onCompleted() {
            // FIXME: Alert??????????
            downloadAlert();
        }

        @Override
        public void onError(Throwable e) {
            Log.e(TAG, ExceptionUtils.getStackTrace(e));

            // ????????
            // downloadLatestAlert??
            downloadAlert();
        }

        @Override
        public void onNext(Alert alert) {
            // post?
            EventBus.getDefault().post(new AlertUpdatedAlertEvent(alert));
        }
    });
}

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

/**
 * @see ke.co.tawi.babblesms.server.persistence.logs.BabbleContactGroupSentDAO#put(ke.co.tawi.babblesms.server.beans.log.contactGroupsent)
 *///from   w ww .j a  va  2 s  .  com
@Override
public boolean put(contactGroupsent cGroupsent) {
    boolean success = true;
    try (Connection conn = dbCredentials.getConnection();
            PreparedStatement pstmt = conn.prepareStatement(
                    "INSERT INTO contactgroupsent (sentcontactuuid, sentgroupuuid)" + "VALUES(?,?); ");) {
        pstmt.setString(1, cGroupsent.getSentContactUuid());
        pstmt.setString(2, cGroupsent.getSentGroupUuid());

        pstmt.execute();

    } catch (SQLException e) {
        logger.error("SQL Exception when trying to put " + cGroupsent);
        logger.error(ExceptionUtils.getStackTrace(e));
        //System.out.println(ExceptionUtils.getStackTrace(e));
        success = false;
    }

    return success;
}

From source file:de.micromata.mgc.common.test.ThreadedRunner.java

public void start(final RuntimeCallable caller) {
    startTime = System.currentTimeMillis();
    threads = new Thread[threadCount];
    for (int i = 0; i < threadCount; ++i) {
        final int intPrefix = i;
        threads[i] = new Thread(new Runnable() {

            @Override// ww w  . java  2s.c om
            public void run() {
                try {
                    for (int i = 0; i < loops; ++i) {
                        synchronized (ThreadedRunner.this) {
                            if (exeptions.length() > 0) {
                                break;
                            }
                        }
                        caller.call();
                    }
                } catch (Exception ex) {
                    synchronized (ThreadedRunner.this) {
                        exeptions.append("\n\nThread " + Thread.currentThread().getId() + " faield:\n")
                                .append(ExceptionUtils.getStackTrace(ex));
                    }
                }
            }

        });
    }
    for (Thread t : threads) {
        t.start();
    }
}

From source file:com.aurel.track.fieldType.fieldChange.config.ParentFieldChangeConfig.java

/**
 * Adds the field type specific json content to stringBuilder (without curly brackets)
 * @param stringBuilder//from  ww w  .j a v  a 2 s .com
 * @param value
 * @param dataSource
 * @param personBean
 * @param locale
 */
@Override
public void addSpecificJsonContent(StringBuilder stringBuilder, Object value, Object dataSource,
        TPersonBean personBean, Locale locale) {
    if (value != null) {
        Integer itemID = (Integer) value;
        TWorkItemBean workItemBean;
        try {
            workItemBean = ItemBL.loadWorkItem(itemID);
            if (workItemBean != null) {
                JSONUtility.appendStringValue(stringBuilder, "txtIssueNo", ItemBL.getItemNo(workItemBean));
                JSONUtility.appendStringValue(stringBuilder, "txtIssueTitle", workItemBean.getSynopsis());
            }
        } catch (ItemLoaderException e) {
            LOGGER.info("Loading the item " + itemID + " failed with " + e.getMessage());
            LOGGER.debug(ExceptionUtils.getStackTrace(e));
        }
        JSONUtility.appendIntegerValue(stringBuilder, JSONUtility.JSON_FIELDS.VALUE, itemID);
    }
}

From source file:ke.co.tawi.babblesms.server.persistence.utils.DateResetUtil.java

/**
 * Reset dates for Incoming SMS./*  w ww  . ja  va 2 s .c om*/
 * 
 * @param startDate A start date in the format yyyy-MM-dd HH:mm:ss
 * @param endDate An end date in the format yyyy-MM-dd HH:mm:ss
 */
public void resetIncomingDates(String startDate, String endDate) {

    SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // Example 2011-06-01 00:16:45" 
    List<String> uuids = new ArrayList<>();

    RandomDataGenerator generator = new RandomDataGenerator();

    // Get UUIDs of Incoming SMS are in the database
    try (Connection conn = dbCredentials.getConnection();
            PreparedStatement pstmt = conn.prepareStatement("SELECT uuid FROM incominglog;");) {
        ResultSet rset = pstmt.executeQuery();

        while (rset.next()) {
            uuids.add(rset.getString("uuid"));
        }

    } catch (SQLException e) {
        logger.error("SQLException when getting uuids of incominglog.");
        logger.error(ExceptionUtils.getStackTrace(e));
    }

    try (Connection conn = dbCredentials.getConnection();
            PreparedStatement pstmt = conn
                    .prepareStatement("UPDATE incominglog SET logTime=? " + "WHERE Uuid=?;");) {
        long start = dateFormatter.parse(startDate).getTime();
        long end = dateFormatter.parse(endDate).getTime();

        for (String uuid : uuids) {
            pstmt.setTimestamp(1, new Timestamp(generator.nextLong(start, end)));
            pstmt.setString(2, uuid);

            pstmt.executeUpdate();
        }

    } catch (SQLException e) {
        logger.error("SQLException when trying to reset dates of incomingLog.");
        logger.error(ExceptionUtils.getStackTrace(e));

    } catch (ParseException e) {
        logger.error("ParseException when trying to reset dates of incomingLog.");
        logger.error(ExceptionUtils.getStackTrace(e));
    }
}

From source file:ke.co.tawi.babblesms.server.persistence.network.NetworkDAO.java

/**
 * @see ke.co.tawi.babblesms.server.persistence.network.BabbleNetworkDAO#putNetwork(ke.co.tawi.babblesms.server.beans.network.Network)
 *//*from   w  w w.  ja v a2s. c  om*/
@Override
public boolean putNetwork(Network network) {
    boolean success = true;
    try (Connection conn = dbCredentials.getConnection();
            PreparedStatement pstmt = conn
                    .prepareStatement("INSERT INTO Network " + "(Uuid, Name, countryuuid) VALUES (?,?,?);");) {

        pstmt.setString(1, network.getUuid());
        pstmt.setString(2, network.getName());
        pstmt.setString(3, network.getCountryuuid());

        pstmt.execute();

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

    return success;
}

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

/**
 * Loads a roleBean by primaty key/*  ww  w .j  av a 2  s . c  om*/
 * @return 
 */
@Override
public TRoleBean loadByPrimaryKey(Integer objectID) {
    TRole tRole = null;
    try {
        tRole = retrieveByPK(objectID);
    } catch (Exception e) {
        LOGGER.warn("Loading of a role by primary key " + objectID + " failed with " + e.getMessage());
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
    }
    if (tRole != null) {
        return tRole.getBean();
    }
    return null;
}

From source file:jp.co.ipublishing.esnavi.impl.user.UserClient.java

@NonNull
@Override//from w  w w.  j a v  a  2s  .co m
public Observable<Void> registerNotificationKey(@NonNull final String key) {
    return Observable.create(new Observable.OnSubscribe<Void>() {
        @Override
        public void call(Subscriber<? super Void> subscriber) {
            // ?????????????????????
            final String latestKey = getRegistrationId(mContext);

            if (!key.equals(latestKey)) {
                try {
                    final ApiMethod apiMethod = mApi.registerNotificationKey();

                    final RequestBody formBody = new FormEncodingBuilder().add("gcmid", key).build();

                    final Request request = new Request.Builder().url(apiMethod.getUrl()).post(formBody)
                            .build();

                    mClient.newCall(request).execute();

                    storeRegistrationId(mContext, key);

                    subscriber.onNext(null);
                    subscriber.onCompleted();

                } catch (IOException e) {
                    Log.e(TAG, ExceptionUtils.getStackTrace(e));

                    subscriber.onError(e);
                }
            } else {
                subscriber.onNext(null);
                subscriber.onCompleted();
            }
        }
    });
}