Example usage for java.lang Exception toString

List of usage examples for java.lang Exception toString

Introduction

In this page you can find the example usage for java.lang Exception toString.

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:org.sana.android.net.ssl.SimpleSSLProtocolSocketFactory.java

private static SSLContext createEasySSLContext() throws ClientProtocolException {
    try {/* w  ww.  ja va 2 s  .  c o  m*/
        SSLContext context = SSLContext.getInstance("TLS");
        context.init(null, new TrustManager[] { new X509TrustManager() {
            public java.security.cert.X509Certificate[] getAcceptedIssuers() {
                return null;
            }

            public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) {
            }

            public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) {
            }
        } }, null);
        return context;
    } catch (Exception e) {
        //LOG.error(e.getMessage(), e);
        throw new ClientProtocolException(e.toString());
    }
}

From source file:cz.incad.kramerius.virtualcollections.VirtualCollectionsManager.java

public static VirtualCollection doVC(String pid, FedoraAccess fedoraAccess, ArrayList<String> languages) {
    try {// ww  w.j  a  v  a  2  s  . c o  m
        String xPathStr;
        XPathFactory factory = XPathFactory.newInstance();
        XPath xpath = factory.newXPath();
        XPathExpression expr;

        ArrayList<String> langs = new ArrayList<String>();
        if (languages == null || languages.isEmpty()) {
            String[] ls = KConfiguration.getInstance().getPropertyList("interface.languages");
            for (int i = 0; i < ls.length; i++) {
                String lang = ls[++i];
                langs.add(lang);
            }
        } else {
            langs = new ArrayList<String>(languages);
        }
        String name = "";
        boolean canLeave = true;
        fedoraAccess.getDC(pid);
        Document doc = fedoraAccess.getDC(pid);
        xPathStr = "//dc:title/text()";
        expr = xpath.compile(xPathStr);
        Node node = (Node) expr.evaluate(doc, XPathConstants.NODE);
        if (node != null) {
            name = StringEscapeUtils.escapeXml(node.getNodeValue());
        }

        xPathStr = "//dc:type/text()";
        expr = xpath.compile(xPathStr);
        node = (Node) expr.evaluate(doc, XPathConstants.NODE);
        if (node != null) {
            canLeave = Boolean.parseBoolean(StringEscapeUtils.escapeXml(node.getNodeValue()));
        }
        VirtualCollection vc = new VirtualCollection(name, pid, canLeave);

        for (String lang : langs) {
            String dsName = TEXT_DS_PREFIX + lang;
            String value = IOUtils.readAsString(fedoraAccess.getDataStream(pid, dsName),
                    Charset.forName("UTF8"), true);
            vc.addDescription(lang, value);
        }
        return vc;
    } catch (Exception vcex) {
        logger.log(Level.WARNING, "Could not get virtual collection for  " + pid + ": " + vcex.toString());
        return null;
    }
}

From source file:net.doubledoordev.backend.webserver_old.methods.Post.java

/**
 * Entry point//from w w w .j  a  v a2s  .co  m
 */
public static void handlePost(HashMap<String, Object> dataObject, NanoHTTPD.HTTPSession session) {
    Map<String, String> map = session.getParms();
    String split[] = session.getUri().substring(1).split("/");
    switch (split[0]) // 0 => type id
    {
    case "login":
        handleLogin(dataObject, session, map);
        break;
    case "register":
        handleRegister(dataObject, session, map);
        break;
    case "newserver":
        try {
            handleNewServer(dataObject, session, map);
        } catch (Exception e) {
            e.printStackTrace();
            dataObject.put("message", e.toString());
        }
        break;
    case "servers":
        Settings.getServerByName(split[1]).setPropertiesAsText(map.get("serverProperties"));
        break;
    }
}

From source file:com.tethrnet.manage.db.SystemStatusDB.java

/**
 * returns all key placement statuses/*ww  w  . j  av a 2 s .  c  o  m*/
 * @param userId user id
 */
public static List<HostSystem> getAllSystemStatus(Long userId) {

    List<HostSystem> hostSystemList = new ArrayList<HostSystem>();
    Connection con = null;
    try {
        con = DBUtils.getConn();
        hostSystemList = getAllSystemStatus(con, userId);

    } catch (Exception e) {
        log.error(e.toString(), e);
    }
    DBUtils.closeConn(con);
    return hostSystemList;

}

From source file:com.ephesoft.dcma.batch.service.EphesoftSSLProtocolSocketFactory.java

private static SSLContext createEasySSLContext() {
    try {// w w w . ja  v a 2 s  . co  m
        final SSLContext context = SSLContext.getInstance("SSL");
        context.init(new KeyManager[0], new TrustManager[] { new DefaultTrustManager() }, new SecureRandom());
        return context;
    } catch (final Exception exception) {
        LOGGER.error(exception.getMessage(), exception);
        throw new HttpClientError(exception.toString());
    }
}

From source file:com.keybox.manage.db.ProfileDB.java

/**
 * method to do order by based on the sorted set object for profiles
 * @return list of profiles/*www  .j  av a  2s  . co  m*/
 */
public static SortedSet getProfileSet(SortedSet sortedSet) {

    ArrayList<Profile> profileList = new ArrayList<>();

    String orderBy = "";
    if (sortedSet.getOrderByField() != null && !sortedSet.getOrderByField().trim().equals("")) {
        orderBy = " order by " + sortedSet.getOrderByField() + " " + sortedSet.getOrderByDirection();
    }
    String sql = "select distinct p.* from  profiles p ";
    if (StringUtils.isNotEmpty(sortedSet.getFilterMap().get(FILTER_BY_SYSTEM))) {
        sql = sql + ", system_map m, system s where m.profile_id = p.id and m.system_id = s.id"
                + " and (lower(s.display_nm) like ? or lower(s.host) like ?)";
    } else if (StringUtils.isNotEmpty(sortedSet.getFilterMap().get(FILTER_BY_USER))) {
        sql = sql + ", user_map m, users u where m.profile_id = p.id and m.user_id = u.id"
                + " and (lower(u.first_nm) like ? or lower(u.last_nm) like ?"
                + " or lower(u.email) like ? or lower(u.username) like ?)";
    }
    sql = sql + orderBy;

    Connection con = null;
    try {
        con = DBUtils.getConn();
        PreparedStatement stmt = con.prepareStatement(sql);
        if (StringUtils.isNotEmpty(sortedSet.getFilterMap().get(FILTER_BY_SYSTEM))) {
            stmt.setString(1, "%" + sortedSet.getFilterMap().get(FILTER_BY_SYSTEM).toLowerCase() + "%");
            stmt.setString(2, "%" + sortedSet.getFilterMap().get(FILTER_BY_SYSTEM).toLowerCase() + "%");
        } else if (StringUtils.isNotEmpty(sortedSet.getFilterMap().get(FILTER_BY_USER))) {
            stmt.setString(1, "%" + sortedSet.getFilterMap().get(FILTER_BY_USER).toLowerCase() + "%");
            stmt.setString(2, "%" + sortedSet.getFilterMap().get(FILTER_BY_USER).toLowerCase() + "%");
            stmt.setString(3, "%" + sortedSet.getFilterMap().get(FILTER_BY_USER).toLowerCase() + "%");
            stmt.setString(4, "%" + sortedSet.getFilterMap().get(FILTER_BY_USER).toLowerCase() + "%");
        }
        ResultSet rs = stmt.executeQuery();

        while (rs.next()) {
            Profile profile = new Profile();
            profile.setId(rs.getLong("id"));
            profile.setNm(rs.getString("nm"));
            profile.setDesc(rs.getString("desc"));
            profileList.add(profile);

        }
        DBUtils.closeRs(rs);
        DBUtils.closeStmt(stmt);

    } catch (Exception e) {
        log.error(e.toString(), e);
    } finally {
        DBUtils.closeConn(con);
    }

    sortedSet.setItemList(profileList);
    return sortedSet;
}

From source file:com.keybox.manage.db.SystemStatusDB.java

/**
 * deletes all records from status table for user
 *
 * @param con DB connection object//from   w  ww.  ja v  a 2s. co m
 * @param userId user id
 */
private static void deleteAllSystemStatus(Connection con, Long userId) {

    try {

        PreparedStatement stmt = con.prepareStatement("delete from status where user_id=?");
        stmt.setLong(1, userId);
        stmt.execute();
        DBUtils.closeStmt(stmt);

    } catch (Exception e) {
        log.error(e.toString(), e);
    }

}

From source file:com.keybox.manage.db.SystemStatusDB.java

/**
 * updates the status table to keep track of key placement status
 *
 * @param hostSystem systems for authorized_keys replacement
 * @param userId user id//w  w  w  .j a v  a 2s .com
 */
public static void updateSystemStatus(HostSystem hostSystem, Long userId) {

    Connection con = null;
    try {
        con = DBUtils.getConn();

        updateSystemStatus(con, hostSystem, userId);

    } catch (Exception e) {
        log.error(e.toString(), e);
    }
    DBUtils.closeConn(con);

}

From source file:com.keybox.manage.db.SystemStatusDB.java

/**
 * returns all key placement statuses/*from   w w  w. ja v  a  2s  . c  om*/
 * @param userId user id
 */
public static List<HostSystem> getAllSystemStatus(Long userId) {

    List<HostSystem> hostSystemList = new ArrayList<>();
    Connection con = null;
    try {
        con = DBUtils.getConn();
        hostSystemList = getAllSystemStatus(con, userId);

    } catch (Exception e) {
        log.error(e.toString(), e);
    }
    DBUtils.closeConn(con);
    return hostSystemList;

}

From source file:com.keybox.manage.db.SystemStatusDB.java

/**
 * updates the status table to keep track of key placement status
 *
 * @param con                DB connection
 * @param hostSystem systems for authorized_keys replacement
 * @param userId user id/*  www .  ja v a  2  s.  co  m*/
 */
public static void updateSystemStatus(Connection con, HostSystem hostSystem, Long userId) {

    try {

        PreparedStatement stmt = con.prepareStatement("update status set status_cd=? where id=? and user_id=?");
        stmt.setString(1, hostSystem.getStatusCd());
        stmt.setLong(2, hostSystem.getId());
        stmt.setLong(3, userId);
        stmt.execute();
        DBUtils.closeStmt(stmt);

    } catch (Exception e) {
        log.error(e.toString(), e);
    }

}