List of usage examples for java.lang Exception toString
public String toString()
From source file:com.intuit.tank.harness.functions.FunctionHandler.java
/** * Is the string a valid function/*from ww w . j ava 2 s . c o m*/ * * @param function * The function string to evaluate * @return TRUE if that is an actual function; FALSE otherwise */ static public boolean validFunction(String function) { try { String[] values = getValues(function); if (values[0].equalsIgnoreCase(ValidationUtil.functionIdentifier)) { if (values[1].equalsIgnoreCase("date")) return DateFunctions.isValid(values); else if (values[1].equalsIgnoreCase("monetary")) return MonetaryFunctions.isValid(values); else if (values[1].equalsIgnoreCase("numeric")) return NumericFunctions.isValid(values); else if (values[1].equalsIgnoreCase("generic")) return GenericFunctions.isValid(values); else if (values[1].equalsIgnoreCase("string")) return StringFunctions.isValid(values); else if (values[1].equalsIgnoreCase("datatype")) return DataTypeFunctions.isValid(values); else if (values[1].equalsIgnoreCase("tax")) return TaxFunctions.isValid(values); else return false; } else return false; } catch (Exception ex) { logger.error(LogUtil.getLogMessage(ex.toString()), ex); return false; } }
From source file:com.intuit.tank.harness.functions.FunctionHandler.java
/** * Execute a function//from ww w . j av a 2 s .c om * * @param function * The function string to execute * @return The response value from the function */ static public String executeFunction(String function, Variables variables, String addtlString) { try { if (!FunctionHandler.validFunction(function)) return null; String[] values = getValues(function); substituteVariables(values, variables); if (values[1].equalsIgnoreCase("date")) return DateFunctions.executeFunction(values); else if (values[1].equalsIgnoreCase("monetary")) return MonetaryFunctions.executeFunction(values); else if (values[1].equalsIgnoreCase("numeric")) return NumericFunctions.executeFunction(values, variables); else if (values[1].equalsIgnoreCase("string")) return StringFunctions.executeFunction(values, variables, addtlString); else if (values[1].equalsIgnoreCase("generic")) return GenericFunctions.executeFunction(values, variables); else if (values[1].equalsIgnoreCase("datatype")) return DataTypeFunctions.executeFunction(values); else if (values[1].equalsIgnoreCase("tax")) return TaxFunctions.executeFunction(values, variables); return null; } catch (Exception ex) { logger.error(LogUtil.getLogMessage(ex.toString()), ex); return null; } }
From source file:com.sittinglittleduck.DirBuster.EasySSLProtocolSocketFactory.java
private static SSLContext createEasySSLContext() { try {// ww w .ja v a 2 s .co m SSLContext context = SSLContext.getInstance("SSL"); context.init(null, new TrustManager[] { new EasyX509TrustManager(null) }, null); return context; } catch (Exception e) { // LOG.error(e.getMessage(), e); throw new HttpClientError(e.toString()); } }
From source file:com.facebook.internal.AppEventsLoggerUtility.java
public static JSONObject getJSONObjectForGraphAPICall(GraphAPIActivityType activityType, AttributionIdentifiers attributionIdentifiers, String anonymousAppDeviceGUID, boolean limitEventUsage, Context context) throws JSONException { JSONObject publishParams = new JSONObject(); publishParams.put("event", API_ACTIVITY_TYPE_TO_STRING.get(activityType)); Utility.setAppEventAttributionParameters(publishParams, attributionIdentifiers, anonymousAppDeviceGUID, limitEventUsage);//from w w w . j av a2 s . c om // The code to get all the Extended info is safe but just in case we can wrap the // whole call in its own try/catch block since some of the things it does might // cause unexpected exceptions on rooted/funky devices: try { Utility.setAppEventExtendedDeviceInfoParameters(publishParams, context); } catch (Exception e) { // Swallow but log Logger.log(LoggingBehavior.APP_EVENTS, "AppEvents", "Fetching extended device info parameters failed: '%s'", e.toString()); } publishParams.put("application_package_name", context.getPackageName()); return publishParams; }
From source file:com.yahoo.storm.yarn.TestIntegration.java
@AfterClass public static void tearDown() { try {/* www . ja v a 2s. c om*/ //shutdown Storm Cluster List<String> cmd = java.util.Arrays.asList(STORM_YARN_CMD, "shutdown", storm_conf_file.toString(), "--appId", appId); execute(cmd); sleep(1000); } catch (Exception ex) { LOG.info(ex.toString()); } //shutdown Zookeeper server if (zkServer != null) { zkServer.stop(); zkServer = null; } //shutdown YARN cluster if (yarnCluster != null) { LOG.info("shutdown MiniYarn cluster"); yarnCluster.stop(); yarnCluster = null; } sleep(1000); //remove configuration file testConf.cleanup(); }
From source file:com.alibaba.antx.config.resource.http.EasySSLProtocolSocketFactory.java
private static SSLContext createEasySSLContext() { try {//from w w w . j a va 2s . c om SSLContext context = SSLContext.getInstance("SSL"); context.init(null, new TrustManager[] { new EasyX509TrustManager(null) }, null); return context; } catch (Exception e) { LOG.error(e.getMessage(), e); throw new HttpClientError(e.toString()); } }
From source file:com.pfarrell.crypto.HmacUtil.java
/** * calculate the sha of the argument, return hex encoded value * @param message to hash/*from w w w . ja va2 s. c om*/ * @return hexified result */ public static String sha(byte[] message) { Preconditions.checkNotNull(message); byte[] gas = null; try { MessageDigest digest = MessageDigest.getInstance("SHA-256"); digest.update(message); gas = digest.digest(); } catch (Exception e) { System.out.println("WebUtils.sha256 - caught exception: " + e.toString()); } return hexify(gas); }
From source file:org.elegosproject.romupdater.DownloadManager.java
public static boolean sendAnonymousData() { String link = "http://www.elegosproject.org/android/upload.php"; String data;/*from w ww . jav a2 s .co m*/ SharedData shared = SharedData.getInstance(); String romName = shared.getRepositoryROMName(); String romVersion = shared.getDownloadVersion(); String romPhone = shared.getRepositoryModel(); String romRepository = shared.getRepositoryUrl(); if (romName.equals("") || romVersion.equals("") || romPhone.equals("") || romRepository.equals("")) { Log.e(TAG, "Internal error - missing system variables."); return false; } if (!checkHttpFile(link)) return false; try { data = URLEncoder.encode("phone", "UTF-8") + "=" + URLEncoder.encode(romPhone, "UTF-8"); data += "&" + URLEncoder.encode("rom_name", "UTF-8") + "=" + URLEncoder.encode(romName, "UTF-8"); data += "&" + URLEncoder.encode("rom_version", "UTF-8") + "=" + URLEncoder.encode(romVersion, "UTF-8"); data += "&" + URLEncoder.encode("rom_repository", "UTF-8") + "=" + URLEncoder.encode(romRepository, "UTF-8"); HttpParams httpParameters = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(httpParameters, 3000); URL url = new URL(link); url.openConnection(); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("POST"); conn.setRequestProperty("User-Agent", "ROMUpdater"); conn.setDoOutput(true); PrintWriter out = new PrintWriter(conn.getOutputStream()); out.println(data); out.close(); int status = Integer.parseInt(conn.getHeaderField("ROMUpdater-status")); if (status == 1) return true; Log.e(TAG, "It was impossible to send data to the stastistics server (" + conn.getHeaderField("ROMUpdater-error") + ")."); return false; } catch (Exception e) { Log.e(TAG, "It was impossible to send data to the stastistics server."); Log.e(TAG, "Error: " + e.toString()); return false; } }
From source file:com.microsoft.azure.servicebus.samples.queueswithproxy.QueuesWithProxy.java
public static int runApp(String[] args, Function<String, Integer> run) { try {//from w ww. ja v a 2 s . c om String connectionString; String proxyHostName; String proxyPortString; int proxyPort; // Add command line options and create parser Options options = new Options(); options.addOption(new Option("c", true, "Connection string")); options.addOption(new Option("n", true, "Proxy hostname")); options.addOption(new Option("p", true, "Proxy port")); CommandLineParser clp = new DefaultParser(); CommandLine cl = clp.parse(options, args); // Pull variables from command line options or environment variables connectionString = getOptionOrEnv(cl, "c", SB_SAMPLES_CONNECTIONSTRING); proxyHostName = getOptionOrEnv(cl, "n", SB_SAMPLES_PROXY_HOSTNAME); proxyPortString = getOptionOrEnv(cl, "p", SB_SAMPLES_PROXY_PORT); // Check for bad input if (StringUtil.isNullOrEmpty(connectionString) || StringUtil.isNullOrEmpty(proxyHostName) || StringUtil.isNullOrEmpty(proxyPortString)) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("run jar with", "", options, "", true); return 2; } if (!NumberUtils.isCreatable(proxyPortString)) { System.err.println("Please provide a numerical value for the port"); } proxyPort = Integer.parseInt(proxyPortString); // ProxySelector set up for an HTTP proxy final ProxySelector systemDefaultSelector = ProxySelector.getDefault(); ProxySelector.setDefault(new ProxySelector() { @Override public List<Proxy> select(URI uri) { if (uri != null && uri.getHost() != null && uri.getHost().equalsIgnoreCase(proxyHostName)) { List<Proxy> proxies = new LinkedList<>(); proxies.add(new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHostName, proxyPort))); return proxies; } return systemDefaultSelector.select(uri); } @Override public void connectFailed(URI uri, SocketAddress sa, IOException ioe) { if (uri == null || sa == null || ioe == null) { throw new IllegalArgumentException("Arguments can't be null."); } systemDefaultSelector.connectFailed(uri, sa, ioe); } }); return run.apply(connectionString); } catch (Exception e) { System.out.printf("%s", e.toString()); return 3; } }
From source file:com.mid.util.ssl.EasySSLProtocolSocketFactory.java
private static SSLContext createEasySSLContext() { try {// w w w .j a v a 2 s .c om SSLContext context = SSLContext.getInstance("SSL"); context.init(null, new TrustManager[] { new EasyX509TrustManager() }, null); return context; } catch (Exception e) { LOG.error(e.getMessage(), e); throw new HttpClientError(e.toString()); } }