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:cn.ieclipse.pay.wxpay.OrderInfoUtil.java

public static Map<String, String> parseJsonResponse(String content) {
    try {/*  www .  j  a  v  a  2  s .c om*/
        JSONObject object = new JSONObject(content);
        Map<String, String> map = new HashMap<>();
        Iterator<String> keys = object.keys();
        if (keys != null) {
            while (keys.hasNext()) {
                String key = keys.next();
                map.put(key, object.getString(key));
            }
        }
        return map;
    } catch (Exception e) {
        if (Wxpay.DEBUG) {
            Wxpay.log("json???" + e.toString());
        }
    }
    return null;
}

From source file:com.ctrip.infosec.rule.resource.Crypto.java

public static String decrypt(String complexText) {
    init();// w w w  .ja v a2s  .  c o  m
    beforeInvoke("Crypto.decrypt");
    String txt = null;
    try {
        if (PROD.equals(env)) {
            txt = cryptoGraphyProd.decrypt(complexText);
        } else {
            txt = cryptoGraphyDev.decrypt(complexText);
        }
    } catch (Exception ex) {
        fault("Crypto.decrypt");
        logger.warn(Contexts.getLogPrefix() + "decrypt fault. complexText=" + complexText, ex);
        TraceLogger.traceLog(": complexText=" + complexText + ", EXCEPTION: " + ex.toString());
    } finally {
        afterInvoke("Crypto.decrypt");
    }
    return txt;
}

From source file:edu.umass.cs.msocket.gns.GnsIntegration.java

/**
 * Return the GUID of the given alias/*ww  w  . j av  a 2 s  . c o  m*/
 * throws UnknownHostException, so that it is similar to
 * exception thrown on DNS failure
 * @param alias
 * @param gnsCredentials
 * @return
 * @throws UnknownHostException
 */
public synchronized static String getGUIDOfAlias(String alias, GnsCredentials gnsCredentials)
        throws UnknownHostException {
    try {
        if (gnsCredentials == null) {
            long gnsCredStart = System.currentTimeMillis();
            gnsCredentials = GnsCredentials.getDefaultCredentials();
            long gnsCredEnd = System.currentTimeMillis();
            log.debug("gnsCredentials time" + (gnsCredEnd - gnsCredStart));
        }

        UniversalGnsClient gnsClient = gnsCredentials.getGnsClient();

        long checkConnStart = System.currentTimeMillis();
        gnsClient.checkConnectivity();
        long checkConnEnd = System.currentTimeMillis();
        log.debug("checkConnectivity time" + (checkConnEnd - checkConnStart));

        long guidLookupStart = System.currentTimeMillis();
        String guidAlias = gnsClient.lookupGuid(alias);
        long guidLookupEnd = System.currentTimeMillis();
        log.debug("lookupGuid time" + (guidLookupEnd - guidLookupStart));

        return guidAlias;
    } catch (Exception ex) {
        throw new UnknownHostException(ex.toString());
    }

}

From source file:edu.usc.polar.OpenNLP.java

public static void ApacheOpenNLP(String doc, String args[]) {
    try {/* www.ja va 2 s  .c om*/
        String text;
        AutoDetectParser parser = new AutoDetectParser();
        BodyContentHandler handler = new BodyContentHandler();
        Metadata metadata = new Metadata();

        InputStream stream = new FileInputStream(doc);

        //   System.out.println(stream.toString());
        parser.parse(stream, handler, metadata);
        // return handler.toString();
        text = handler.toString();
        String metaValue = metadata.toString();
        System.out.println("Desc:: " + metadata.get("description"));

        String[] example = new String[1];
        example[0] = text;
        String name = doc.replace("C:\\Users\\Snehal\\Documents\\TREC-Data\\Data", "polar.usc.edu");
        Map<String, Set<String>> list = tikaOpenNLP(text);
        System.out.println(combineSets(list));
        JSONObject jsonObj = new JSONObject();
        jsonObj.put("DOI", name);
        jsonObj.put("metadata", metaValue.replaceAll("\\s\\s+|\n|\t", " "));
        JSONArray tempArray = new JSONArray();
        JSONObject tempObj = new JSONObject();
        for (Map.Entry<String, Set<String>> entry : list.entrySet()) {
            System.out.println("\"" + entry.getKey() + "/" + ":\"" + entry.getValue() + "\"");
            tempObj.put(entry.getKey(), entry.getValue());
            //          String jsonOut="{ DOI:"+name+"  ,"
            //                + ""+item.first() + "\": \"" + text.substring(item.second(), item.third()).replaceAll("\\s\\s+|\n|\t"," ")+"\""
            //                + "\"metadata\":\""+metaValue+"\""
            //                + "}";
            // System.out.println(jsonOut);
            //     tempObj.put(item.first(),text.substring(item.second(), item.third()).replaceAll("\\s\\s+|\n|\t"," "));
        }
        tempArray.add(tempObj);
        jsonObj.put("NER", tempArray);
        jsonArray.add(jsonObj);

        // System.out.println("---");

    } catch (Exception e) {
        System.out.println("ERROR : OpenNLP" + "|File Name"
                + doc.replaceAll("C:\\Users\\Snehal\\Documents\\TREC-Data", "") + " direct" + e.toString());
    }
}

From source file:de.itomig.itoplib.GetItopJSON.java

/**
 * request data from itop server in json format
 * //www .  j a va2s. com
 * @param operation
 * @param itopClass
 * @param key
 * @param output_fields
 * @return
 */
public static String postJsonToItopServer(String operation, String itopClass, String key,
        String output_fields) {
    AndroidHttpClient client = AndroidHttpClient.newInstance("Android");
    String result = "";

    try {
        HttpPost request = new HttpPost();
        String url = ItopConfig.getItopUrl();

        String req = url + "/webservices/rest.php?version=1.0";
        if (debug)
            Log.i(TAG, "req.=" + req);
        request.setURI(new URI(req));

        ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>();
        postParameters.add(ItopConfig.getItopUserNameValuePair());
        postParameters.add(ItopConfig.getItopPwdNameValuePair());

        JSONObject jsd = new JSONObject();
        jsd.put("operation", operation);
        jsd.put("class", itopClass);
        jsd.put("key", key);
        jsd.put("output_fields", output_fields);

        postParameters.add(new BasicNameValuePair("json_data", jsd.toString()));
        UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(postParameters);
        request.setEntity(formEntity);

        // request.addHeader(HTTP.CONTENT_TYPE, "application/json");
        HttpResponse response = client.execute(request);
        String status = response.getStatusLine().toString();
        if (debug)
            Log.i(TAG, "status: " + status);

        if (status.contains("200") && status.contains("OK")) {

            // request worked fine, retrieved some data
            InputStream instream = response.getEntity().getContent();
            result = convertStreamToString(instream);
            Log.d(TAG, "result is: " + result);
        } else // some error in http response
        {
            Log.e(TAG, "Get data - http-ERROR: " + status);
            result = "ERROR: http status " + status;
        }

    } catch (Exception e) {
        // Toast does not work in background task
        Log.e(TAG, "Get data -  " + e.toString());
        result = "ERROR: " + e.toString();
    } finally {
        client.close(); // needs to be done for androidhttpclient
        if (debug)
            Log.i(TAG, "...finally.. get data finished");
    }
    return result;

}

From source file:com.greenline.guahao.biz.manager.payment.util.AlipayCore.java

/**
 * ?????????//w w  w. ja v  a 2 s .c  o  m
 * 
 * @param params ??
 * @return ?
 */
public static boolean verifyNotify(Map<String, String> params) throws Exception {

    // ???????
    String responseTxt = "true";
    try {
        // XML?notify_data??notify_id
        Document document = DocumentHelper.parseText(params.get("notify_data"));
        String notify_id = document.selectSingleNode("//notify/notify_id").getText();
        responseTxt = verifyResponse(notify_id);
    } catch (Exception e) {
        responseTxt = e.toString();
    }

    // ????
    String sign = "";
    if (params.get("sign") != null) {
        sign = params.get("sign");
    }
    boolean isSign = getSignVeryfy(params, sign, false);

    if (isSign && "true".equals(responseTxt)) {
        return true;
    } else {
        return false;
    }
}

From source file:com.jaspersoft.ireport.jasperserver.ws.IReportSSLSocketFactory.java

private static SSLContext createIRSSLContext() {

    try {// w  ww.  j a v a2s .  co  m

        SSLContext context = SSLContext.getInstance("SSL");

        context.init(null, new TrustManager[] { new IReportTrustManager() }, null);

        return context;

    } catch (Exception ex) {

        ex.printStackTrace();

        throw new HttpClientError(ex.toString());

    }

}

From source file:ffx.utilities.StringUtils.java

/**
 * Returns the file name of a temporary copy of <code>input</code> content.
 *
 * @param input a {@link java.io.InputStream} object.
 * @param name a {@link java.lang.String} object.
 * @param suffix a {@link java.lang.String} object.
 * @return a {@link java.lang.String} object.
 * @throws java.io.IOException if any.// www . j  a  v a 2s.  c  o m
 */
public static String copyInputStreamToTmpFile(final InputStream input, String name, final String suffix)
        throws IOException {
    File tmpFile = null;
    try {
        name = "ffx." + name + ".";
        tmpFile = File.createTempFile(name, suffix);
    } catch (Exception e) {
        System.out.println(" Could not extract a Force Field X library.");
        System.err.println(e.toString());
        System.exit(-1);
    }

    tmpFile.deleteOnExit();
    OutputStream output = null;
    try {
        output = new BufferedOutputStream(new FileOutputStream(tmpFile));
        byte[] buffer = new byte[8192];
        int size;
        while ((size = input.read(buffer)) != -1) {
            output.write(buffer, 0, size);
        }
    } finally {
        if (input != null) {
            input.close();
        }
        if (output != null) {
            output.close();
        }
    }

    return tmpFile.toString();
}

From source file:cn.ieclipse.pay.wxpay.OrderInfoUtil.java

/**
 * <xml>/*from  www.  j  a  v a 2s .c  om*/
 * <return_code><![CDATA[SUCCESS]]></return_code>
 * <return_msg><![CDATA[OK]]></return_msg>
 * <appid><![CDATA[wx2421b1c4370ec43b]]></appid>
 * <mch_id><![CDATA[10000100]]></mch_id>
 * <nonce_str><![CDATA[IITRi8Iabbblz1Jc]]></nonce_str>
 * <sign><![CDATA[7921E432F65EB8ED0CE9755F0E86D72F]]></sign>
 * <result_code><![CDATA[SUCCESS]]></result_code>
 * <prepay_id><![CDATA[wx201411101639507cbf6ffd8b0779950874]]></prepay_id>
 * <trade_type><![CDATA[APP]]></trade_type>
 * </xml>
 * ??xml
 *
 * @param content ?xml
 *
 * @return ?map
 */
public static Map<String, String> parseXmlResponse(String content) {
    try {
        Map<String, String> xml = new HashMap<>();
        XmlPullParser parser = Xml.newPullParser();
        parser.setInput(new StringReader(content));
        int event = parser.getEventType();
        while (event != XmlPullParser.END_DOCUMENT) {

            String nodeName = parser.getName();
            switch (event) {
            case XmlPullParser.START_DOCUMENT:
                break;
            case XmlPullParser.START_TAG:
                if ("xml".equals(nodeName) == false) {
                    // 
                    xml.put(nodeName, parser.nextText());
                }
                break;
            case XmlPullParser.END_TAG:
                break;
            }
            event = parser.next();
        }
        return xml;
    } catch (Exception e) {
        if (Wxpay.DEBUG) {
            Wxpay.log("xml???" + e.toString());
        }
    }
    return null;
}

From source file:gdt.data.entity.BaseHandler.java

/**
 * Execute an action/* www . j av  a2  s  .  c  o  m*/
 *  @param entigrator instance of  the Entigrator class
 *  @param locator$ the arguments string.
 * @return response string.
 */

public static String execute(Entigrator entigrator, String locator$) {
    try {
        Properties locator = Locator.toProperties(locator$);
        String handlerClass$ = locator.getProperty(HANDLER_CLASS);
        String method$ = locator.getProperty(HANDLER_METHOD);
        Class<?> cls = Class.forName(handlerClass$);
        Object obj = cls.newInstance();
        // System.out.println("ConsoleHandler:execute:context="+handlerClass$);
        Method method = cls.getDeclaredMethod(method$, Entigrator.class, String.class);
        return (String) method.invoke(obj, entigrator, locator$);
    } catch (Exception e) {
        Logger.getLogger(BaseHandler.class.getName()).severe(e.toString());
        return Locator.append(locator$, FacetHandler.METHOD_STATUS, FacetHandler.METHOD_STATUS_FAILED);
    }

}