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:jp.co.ipublishing.aeskit.alert.AlertService.java

/**
 * ???//from  ww w  .  j  a va  2 s  . com
 * ?????????AlertUpdateEvent????
 * ?????????
 */
private void downloadAlert() {
    mAlertManager.downloadAlert().subscribe(new Subscriber<Alert>() {
        @Override
        public void onCompleted() {
            // Nothing to do
        }

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

            EventBus.getDefault().post(new AlertFailedDownloadAlertEvent(e));
        }

        @Override
        public void onNext(Alert alert) {
            // addAlert??
            // ????AlertUpdateLatestEvent??
            mAlertManager.storeAlert(alert).subscribe(new Subscriber<Alert>() {
                @Override
                public void onCompleted() {
                    // Nothing to do
                }

                @Override
                public void onError(Throwable e) {
                    Log.e(TAG, ExceptionUtils.getStackTrace(e));
                    EventBus.getDefault().post(new AlertFailedStoreAlertEvent(e));
                }

                @Override
                public void onNext(Alert alert) {
                    if (alert != null) {
                        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#getUsingSentGroup(java.lang.String)
 *///from   ww w.  ja va 2 s  .c om
@Override
public List<contactGroupsent> getUsingSentGroup(String SentGroupUuid) {
    List<contactGroupsent> GrpsentList = new ArrayList<>();
    try (Connection conn = dbCredentials.getConnection();
            PreparedStatement pstmt = conn
                    .prepareStatement("SELECT * FROM contactgroupsent WHERE sentgroupuuid=?;");) {
        pstmt.setString(1, SentGroupUuid);
        try (ResultSet rset = pstmt.executeQuery();) {
            GrpsentList = beanProcessor.toBeanList(rset, contactGroupsent.class);
        }

    } catch (SQLException e) {
        logger.error("SQL Exception when trying to List associated with " + SentGroupUuid);
        logger.error(ExceptionUtils.getStackTrace(e));
    }

    return GrpsentList;
}

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

public static void addReportTemplates() {
    URL urlSrc;//w ww .j a v  a  2  s.c  o  m
    File srcDir = null;
    //first try to get the template dir through class.getResource(path)
    urlSrc = PluginUtils.class.getResource("/resources/reportTemplates");
    urlSrc = PluginUtils.createValidFileURL(urlSrc);
    if (urlSrc != null) {
        LOGGER.info("Retrieving report templates from " + urlSrc.toString());
        srcDir = new File(urlSrc.getPath());
        Long uuid = new Date().getTime();
        File tmpDir = new File(
                System.getProperty("java.io.tmpdir") + File.separator + "TrackTmp" + uuid.toString());
        if (!tmpDir.isDirectory()) {
            tmpDir.mkdir();
        }
        tmpDir.deleteOnExit();

        File[] files = srcDir.listFiles(new InitReportTemplateBL.Filter());
        if (files == null || files.length == 0) {
            LOGGER.error("Problem unzipping report template: No files.");
            return;
        }
        for (int index = 0; index < files.length; index++) {
            ZipFile zipFile = null;
            try {
                String sname = files[index].getName();
                String oid = sname.substring(sname.length() - 6, sname.length() - 4);
                zipFile = new ZipFile(files[index], ZipFile.OPEN_READ);
                LOGGER.debug("Extracting template from " + files[index].getName());
                unzipFileIntoDirectory(zipFile, tmpDir);

                File descriptor = new File(tmpDir, "description.xml");
                InputStream in = new FileInputStream(descriptor);
                //parse using builder to get DOM representation of the XML file
                Map<String, Object> desc = ReportBL.getTemplateDescription(in);

                String rname = "The name";
                String description = "The description";
                String expfmt = (String) desc.get("format");

                Map<String, String> localizedStuff = (Map<String, String>) desc
                        .get("locale_" + Locale.getDefault().getLanguage());
                if (localizedStuff != null) {
                    rname = localizedStuff.get("listing");
                    description = localizedStuff.get("description");
                } else {
                    localizedStuff = (Map<String, String>) desc.get("locale_en");
                    rname = localizedStuff.get("listing");
                    description = localizedStuff.get("description");
                }

                addReportTemplateToDatabase(new Integer(oid), rname, expfmt, description);

            } catch (IOException e) {
                LOGGER.error("Problem unzipping report template " + files[index].getName());
                LOGGER.debug(ExceptionUtils.getStackTrace(e));
            }
        }
    }
}

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

public static void saveParameters(TDashboardFieldBean field, Connection con) {
    Integer fieldID = field.getObjectID();
    List oldParams = getByDashboardField(fieldID, con);
    if (oldParams == null) {//in order to avoid nullPointerException
        oldParams = new ArrayList();
    }/*from  www. j  av  a2 s .co  m*/
    Map params = field.getParametres();
    if (params == null) {
        for (int i = 0; i < oldParams.size(); i++) {
            TDashboardParameter o = (TDashboardParameter) oldParams.get(i);
            try {
                doDelete(SimpleKey.keyFor(o.getObjectID()), con);
            } catch (TorqueException e) {
                LOGGER.debug(ExceptionUtils.getStackTrace(e));
            }
        }
        return;
    }
    Iterator it = params.keySet().iterator();
    while (it.hasNext()) {
        String param = (String) it.next();
        boolean found = false;
        for (int i = 0; i < oldParams.size(); i++) {
            TDashboardParameter o = (TDashboardParameter) oldParams.get(i);
            if (o.getName().equals(param)) {
                o.setParamValue((String) params.get(param));
                found = true;
                try {
                    o.save(con);
                } catch (TorqueException e) {
                    LOGGER.debug(ExceptionUtils.getStackTrace(e));
                }
                oldParams.remove(o);
                break;
            }
        }
        if (found == false) {
            TDashboardParameter o = new TDashboardParameter();
            o.setName(param);
            o.setParamValue((String) params.get(param));
            try {
                o.setDashboardField(field.getObjectID());
            } catch (TorqueException e) {
                LOGGER.debug(ExceptionUtils.getStackTrace(e)); //To change body of catch statement use File | Settings | File Templates.
            }
            try {
                o.save(con);
            } catch (TorqueException e) {
                LOGGER.debug(ExceptionUtils.getStackTrace(e));
            }
        }
    }
    //remove old parameters (if exists)
    for (int i = 0; i < oldParams.size(); i++) {
        TDashboardParameter o = (TDashboardParameter) oldParams.get(i);
        try {
            doDelete(SimpleKey.keyFor(o.getObjectID()), con);
        } catch (TorqueException e) {
            LOGGER.debug(ExceptionUtils.getStackTrace(e));
        }
    }
}

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

/**
* @see ke.co.tawi.babblesms.server.persistence.contacts.BabbleContactDAO#getContactByName(Account, java.lang.String)
*///from w  w  w .j  ava 2s  .co  m
@Override
public List<Contact> getContactByName(Account account, String name) {
    List<Contact> list = new ArrayList<>();

    try (Connection conn = dbCredentials.getConnection();
            PreparedStatement pstmt = conn
                    .prepareStatement("SELECT * FROM Contact WHERE accountuuid = ? " + "AND name ILIKE ?;");) {
        pstmt.setString(1, account.getUuid());
        pstmt.setString(2, "%" + name + "%");

        ResultSet rset = pstmt.executeQuery();

        list = beanProcessor.toBeanList(rset, Contact.class);

        rset.close();

    } catch (SQLException e) {
        logger.error("SQLException when getting contacts of " + account + " and name '" + name + "'");
        logger.error(ExceptionUtils.getStackTrace(e));
    }

    Collections.sort(list);
    return list;
}

From source file:jp.co.ipublishing.esnavi.impl.alert.AlertStore.java

/**
 * ??//from   ww w.j  ava  2 s.  com
 *
 * @param alert 
 */
private void storeLatestAlert(@NonNull Alert alert) {
    try {
        final String string = Base64.encodeObject(alert);
        getPreferences(mContext).edit().putString(KEY_LATEST_ALERT, string).commit();
    } catch (IOException e) {
        Log.e(TAG, ExceptionUtils.getStackTrace(e));
    }
}

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

/**
 * Loads the FieldChangeBeans by itemID and fields changed since
 * @param itemID//from  w  w w.j ava  2  s. com
 * @param fieldIDs
 * @param since
 * @return
 */
@Override
public List<TFieldChangeBean> loadByItemAndFieldsSince(Integer itemID, List<Integer> fieldIDs, Date since) {
    if (fieldIDs != null && !fieldIDs.isEmpty() && itemID != null) {
        Criteria criteria = new Criteria();
        criteria.addIn(FIELDKEY, fieldIDs);
        criteria.addJoin(THistoryTransactionPeer.OBJECTID, HISTORYTRANSACTION);
        criteria.add(THistoryTransactionPeer.WORKITEM, itemID);
        criteria.add(THistoryTransactionPeer.LASTEDIT, since, Criteria.GREATER_THAN);
        criteria.addDescendingOrderByColumn(THistoryTransactionPeer.LASTEDIT);
        try {
            return convertTorqueListToBeanList(doSelect(criteria));
        } catch (TorqueException e) {
            LOGGER.error("Loading the fieldChangeBeans by itemID  " + itemID + " for  fieldIDs " + fieldIDs
                    + " since " + since + " failed with " + e.getMessage());
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug(ExceptionUtils.getStackTrace(e));
            }
        }
    }
    return null;
}

From source file:ke.co.tawi.babblesms.server.persistence.maskcode.ShortcodeDAO.java

/**
    * @see ke.co.tawi.babblesms.server.persistence.maskcode.BabbleShortcodeDAO#put(ke.co.tawi.babblesms.server.beans.maskcode.Shortcode)
  *//*from www.  j ava  2 s .  c o m*/
@Override
public boolean put(Shortcode shortcode) {
    boolean success = true;

    try (Connection conn = dbCredentials.getConnection();
            PreparedStatement pstmt = conn.prepareStatement("INSERT INTO Shortcode (Uuid, codenumber,"
                    + "accountuuid, networkuuid) VALUES (?,?,?,?);");) {
        pstmt.setString(1, shortcode.getUuid());
        pstmt.setString(2, shortcode.getCodenumber());
        pstmt.setString(3, shortcode.getAccountuuid());
        pstmt.setString(4, shortcode.getNetworkuuid());

        pstmt.execute();

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

    return success;
}

From source file:com.aurel.track.screen.action.AbstractFieldAction.java

/**
 * Obtain the properties for a field/*ww  w .jav  a2 s. c o  m*/
 * -load the screen field
 * @return
 */
public String properties() {
    field = getAbstractFieldDesignBL().loadField(componentID);
    fieldType = getType(field);
    String s = getAbstractFieldDesignBL().encodeJSON_FieldProperies(field, fieldType);
    try {
        JSONUtility.prepareServletResponseJSON(ServletActionContext.getResponse());
        PrintWriter out = ServletActionContext.getResponse().getWriter();
        out.println(s);
    } catch (IOException e) {
        LOGGER.error(ExceptionUtils.getStackTrace(e));
    }
    return null;
}

From source file:com.aurel.track.admin.customize.treeConfig.screen.ScreenAssignmentAction.java

/**
 * Export the selected screens into an xml file
 * @return//  w w w  .j a v a2  s.com
 */
public String export() {
    List<Integer> screenIDList = GeneralUtils.createIntegerListFromString(selectedScreenIDs);
    String fileName = ScreenExporter.getExportFileName(screenIDList);
    DownloadUtil.prepareResponse(ServletActionContext.getRequest(), servletResponse, fileName, "text/xml");
    OutputStream outputStream = null;
    try {
        outputStream = servletResponse.getOutputStream();
        ScreenExporter screenExporter = new ScreenExporter(true);
        List<EntityContext> entityContextList = screenExporter.exportScreens(screenIDList);
        String screenXmlExport = EntityExporter.export2(entityContextList);
        outputStream.write(screenXmlExport.getBytes());
        outputStream.flush();
        outputStream.close();
        return null;
    } catch (EntityExporterException e) {
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
    } catch (IOException e) {
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
    }
    return "";
}