List of usage examples for java.net URISyntaxException printStackTrace
public void printStackTrace()
From source file:com.github.tomakehurst.wiremock.common.UniqueFilenameGenerator.java
public static String generateIdFromUrl(final String prefix, final String id, final String url) { URIBuilder urlbuild = null;/*w w w . j av a2 s .c o m*/ try { urlbuild = new URIBuilder(url); urlbuild = urlbuild.removeQuery(); return getRandomId(prefix, id, new URI(urlbuild.toString())); } catch (URISyntaxException e) { e.printStackTrace(); } return null; }
From source file:demo.config.ApplicationContextLoader.java
public static ApplicationContextLoader getInstance() { if (instance == null) { try {/* w ww. j ava2s . c o m*/ instance = new ApplicationContextLoader(); } catch (URISyntaxException e) { e.printStackTrace(); return null; } } return instance; }
From source file:com.almende.arum.RESTApplication.java
/** * Inits the.//from w w w .j a v a 2s. c o m */ public static void init() { Servlet servlet = new org.apache.wink.server.internal.servlet.RestServlet(); ObjectNode params = JOM.createObjectNode(); ArrayNode initParams = JOM.createArrayNode(); ObjectNode param = JOM.createObjectNode(); param.put("key", "javax.ws.rs.Application"); param.put("value", RESTApplication.class.getName()); initParams.add(param); params.set("initParams", initParams); JettyLauncher launcher = new JettyLauncher(); try { launcher.add(servlet, new URI("/rs/"), params); launcher.addFilter("com.thetransactioncompany.cors.CORSFilter", "/*"); } catch (URISyntaxException e) { e.printStackTrace(); } }
From source file:Main.java
public static URI getURIAttribute(Element el, String attr, URI defaultValue) { if (el.hasAttribute(attr)) { try {//from ww w . j a v a2 s . c om return new URI(el.getAttribute(attr)); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return defaultValue; }
From source file:Main.java
/** * Unmask the URI and return it//w w w . java 2 s . c om */ public static Uri unmaskLink(Uri uri, int i) { String s = null; List pathSegments; if (MASK_HOSTS_SEG[i] == null) { // The host always masks, no need to determine if it's the right segment s = uri.getQueryParameter(MASK_HOSTS_PAR[i]); } else { // Only a certain segment is used to mask URLs. Determine if this is it. pathSegments = uri.getPathSegments(); if (pathSegments == null) return uri; // If it is, unmask the URL. if (pathSegments.size() > 0 && MASK_HOSTS_SEG[i].equals(pathSegments.get(0))) s = uri.getQueryParameter(MASK_HOSTS_PAR[i]); } if (s == null) return uri; // Resolve link if it's relative try { if (!new URI(s).isAbsolute()) s = new URI(uri.toString()).resolve(s).toString(); } catch (URISyntaxException e) { e.printStackTrace(); } try { return Uri.parse(URLDecoder.decode(s, "UTF-8")); } catch (UnsupportedEncodingException e) { e.printStackTrace(); return uri; } }
From source file:cognition.pipeline.Main.java
private static String getCurrentFolder() { CodeSource codeSource = Main.class.getProtectionDomain().getCodeSource(); File jarFile;// ww w.j a v a2s. com try { jarFile = new File(codeSource.getLocation().toURI().getPath()); } catch (URISyntaxException e) { e.printStackTrace(); return ""; } return jarFile.getParentFile().getPath(); }
From source file:org.mrgeo.utils.FileUtils.java
public static String resolveURI(final String path) { try {/*from w w w . ja va 2 s . c o m*/ URI uri = new URI(path); if (uri.getScheme() == null) { String fragment = uri.getFragment(); URI part = new File(uri.getPath()).toURI(); uri = new URI(part.getScheme(), part.getPath(), fragment); } return uri.toString(); } catch (URISyntaxException e) { e.printStackTrace(); } return path; }
From source file:com.jaspersoft.studio.server.util.HttpUtils31.java
public static void setupProxy(HttpClient c, URL arg2, HostConfiguration config) { IProxyService proxyService = getProxyService(); if (proxyService == null) return;// www. jav a 2 s .c om IProxyData[] proxyDataForHost; try { proxyDataForHost = proxyService.select(arg2.toURI()); for (IProxyData data : proxyDataForHost) { if (data.isRequiresAuthentication()) { String userId = data.getUserId(); Credentials proxyCred = new UsernamePasswordCredentials(userId, data.getPassword()); // if the username is in the form "user\domain" // then use NTCredentials instead. int domainIndex = userId.indexOf("\\"); if (domainIndex > 0) { String domain = userId.substring(0, domainIndex); if (userId.length() > domainIndex + 1) { String user = userId.substring(domainIndex + 1); proxyCred = new NTCredentials(user, data.getPassword(), data.getHost(), domain); } } c.getState().setProxyCredentials(AuthScope.ANY, proxyCred); } config.setProxy(data.getHost(), data.getPort()); } // Close the service and close the service tracker proxyService = null; } catch (URISyntaxException e) { e.printStackTrace(); } }
From source file:MondrianService.java
private static String getSettingsPath() { try {//from ww w .ja v a2s . c om // Get current location jar path String jar = MondrianService.class.getProtectionDomain().getCodeSource().getLocation().toURI() .getPath(); // Get jar parent folder String path = new File(jar).getParentFile().getAbsolutePath(); // Return path to settings file return path; } catch (URISyntaxException ex) { ex.printStackTrace(); return null; } }
From source file:jp.go.nict.langrid.management.logic.service.HttpClientUtil.java
/** * //w ww .j av a 2 s .c om * */ public static HttpClient createHttpClientWithHostConfig(URL url) { HttpClient client = new HttpClient(); int port = url.getPort(); if (port == -1) { port = url.getDefaultPort(); if (port == -1) { port = 80; } } if ((url.getProtocol().equalsIgnoreCase("https")) && (sslSocketFactory != null)) { Protocol https = new Protocol("https", (ProtocolSocketFactory) new SSLSocketFactorySSLProtocolSocketFactory(sslSocketFactory), port); client.getHostConfiguration().setHost(url.getHost(), url.getPort(), https); } else { Protocol http = new Protocol("http", new SocketFactoryProtocolSocketFactory(SocketFactory.getDefault()), port); client.getHostConfiguration().setHost(url.getHost(), url.getPort(), http); } try { List<Proxy> proxies = ProxySelector.getDefault().select(url.toURI()); for (Proxy p : proxies) { if (p.equals(Proxy.NO_PROXY)) continue; if (!p.type().equals(Proxy.Type.HTTP)) continue; InetSocketAddress addr = (InetSocketAddress) p.address(); client.getHostConfiguration().setProxy(addr.getHostName(), addr.getPort()); break; } } catch (URISyntaxException e) { e.printStackTrace(); } return client; }