List of usage examples for java.net URISyntaxException getMessage
public String getMessage()
From source file:com.lin.web.service.impl.GAEClientConnection.java
@Override public void sendRequestHeader(HttpRequest request) throws HttpException, IOException { try {/*from w ww . java 2 s .c om*/ HttpHost host = route.getTargetHost(); URI uri = new URI(host.getSchemeName() + "://" + host.getHostName() + ((host.getPort() == -1) ? "" : (":" + host.getPort())) + request.getRequestLine().getUri()); this.request = new HTTPRequest(uri.toURL(), HTTPMethod.valueOf(request.getRequestLine().getMethod()), FetchOptions.Builder.disallowTruncate().doNotFollowRedirects()); } catch (URISyntaxException ex) { throw new IOException("Malformed request URI: " + ex.getMessage(), ex); } catch (IllegalArgumentException ex) { throw new IOException("Unsupported HTTP method: " + ex.getMessage(), ex); } // System.err.println("SEND: " + this.request.getMethod() + " " + this.request.getURL()); for (Header h : request.getAllHeaders()) { // System.err.println("SEND: " + h.getName() + ": " + h.getValue()); this.request.addHeader(new HTTPHeader(h.getName(), h.getValue())); } }
From source file:ru.algorithmist.jquant.infr.GAEClientConnection.java
@Override public void sendRequestHeader(HttpRequest request) throws HttpException, IOException { try {/*w ww . j ava 2s . c om*/ HttpHost host = route.getTargetHost(); URI uri = new URI(host.getSchemeName() + "://" + host.getHostName() + ((host.getPort() == -1) ? "" : (":" + host.getPort())) + request.getRequestLine().getUri()); this.request = new HTTPRequest(uri.toURL(), HTTPMethod.valueOf(request.getRequestLine().getMethod()), FetchOptions.Builder.disallowTruncate().doNotFollowRedirects()); } catch (URISyntaxException ex) { throw new IOException("Malformed request URI: " + ex.getMessage(), ex); } catch (IllegalArgumentException ex) { throw new IOException("Unsupported HTTP method: " + ex.getMessage(), ex); } for (Header h : request.getAllHeaders()) { this.request.addHeader(new HTTPHeader(h.getName(), h.getValue())); } }
From source file:it.geosolutions.geobatch.imagemosaic.GeoBatchBaseTest.java
/** * Load a resource from the resource/ directory (either main/ or test/). *///w w w . j ava 2 s.c om protected File loadFile(String name) { try { URL url = this.getClass().getClassLoader().getResource(name); if (url == null) { throw new IllegalArgumentException("Cant get file '" + name + "'"); } File file = new File(url.toURI()); return file; } catch (URISyntaxException e) { LOGGER.error("Can't load file " + name + ": " + e.getMessage(), e); return null; } }
From source file:org.yaoha.ApiConnector.java
public HttpResponse createNewChangeset() throws ClientProtocolException, IOException, OAuthMessageSignerException, OAuthExpectationFailedException, OAuthCommunicationException { URI uri = null;/* w w w .ja v a 2 s.c om*/ try { uri = new URI("http", apiUrl, "/api/0.6/changeset/create", null, null); } catch (URISyntaxException e) { Log.e(ApiConnector.class.getSimpleName(), "Creating new changeset failed:"); Log.e(ApiConnector.class.getSimpleName(), e.getMessage()); } HttpPut request = new HttpPut(uri); request.setHeader(userAgentHeader); String requestString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<osm>" + "<changeset>" + "<tag k=\"created_by\" v=\"YAOHA\"/>" + "<tag k=\"comment\" v=\"Updating opening hours\"/>" + "</changeset>" + "</osm>"; HttpEntity entity = new StringEntity(requestString, HTTP.UTF_8); request.setEntity(entity); consumer.sign(request); return client.execute(request); }
From source file:ph.com.globe.connect.Sms.java
/** * Build request url./* w w w . j a va2 s. c o m*/ * * @param url target url * @return String * @throws ApiException api exception */ protected String buildUrl(String url) throws ApiException { // try parsing url try { // build url url = String.format(url, this.senderAddress); // initialize url builder URIBuilder builder = new URIBuilder(url); // set access token parameter builder.setParameter("access_token", this.accessToken); // build the url url = builder.build().toString(); return url; } catch (URISyntaxException e) { // throw exception throw new ApiException(e.getMessage()); } }
From source file:eu.peppol.jdbc.OxalisDataSourceFactoryDbcpImplTest.java
private ConnectionFactory createConnectionFactory(boolean profileSql) throws MalformedURLException, ClassNotFoundException, InstantiationException, IllegalAccessException, SQLException { String jdbcDriverClassPath = globalConfiguration.getJdbcDriverClassPath(); URL url = new URL(jdbcDriverClassPath); try {// w ww. j a v a 2 s . c om File file = new File(url.toURI()); if (!file.exists()) { throw new IllegalStateException("JDBC driver class path not found: " + file); } } catch (URISyntaxException e) { throw new IllegalStateException( "Unable to convert URL " + url.toExternalForm() + " into URI: " + e.getMessage(), e); } URLClassLoader urlClassLoader = new URLClassLoader(new URL[] { url }, Thread.currentThread().getContextClassLoader()); String jdbcDriverClassName = globalConfiguration.getJdbcDriverClassName(); String connectURI = globalConfiguration.getJdbcConnectionURI(); // + "?initialTimeout=2"; String userName = globalConfiguration.getJdbcUsername(); String password = globalConfiguration.getJdbcPassword(); Class<?> aClass = null; try { aClass = Class.forName(jdbcDriverClassName, true, urlClassLoader); } catch (ClassNotFoundException e) { throw new IllegalStateException("Unable to locate class " + jdbcDriverClassName + " in class path '" + jdbcDriverClassPath + "'"); } Driver driver = (Driver) aClass.newInstance(); assertTrue(driver.acceptsURL(connectURI)); Properties properties = new Properties(); properties.put("user", userName); properties.put("password", password); if (profileSql) { properties.put("profileSQL", "true"); // MySQL debug option } return new DriverConnectionFactory(driver, connectURI, properties); }
From source file:org.yamj.common.model.YamjInfo.java
/** * Create the URL to the web server based on the core IP address and port * * @param additionalPath/* ww w . j a v a 2s. c om*/ * @return The generated URL */ private String buildBaseUrl(String additionalPath) { try { StringBuilder path = new StringBuilder("/"); path.append(FilenameUtils.normalize(additionalPath, true)); if (!path.toString().endsWith("/")) { path.append("/"); } URI uri = new URI("http", null, coreIp, corePort, path.toString(), null, null); return uri.toString(); } catch (URISyntaxException ex) { LOG.warn("Failed to encode base URL: {}", ex.getMessage()); return ""; } }
From source file:nl.mpi.lamus.filesystem.implementation.LamusWorkspaceFileHandler.java
/** * @see WorkspaceFileHandler#getFilesInOrphanDirectory(nl.mpi.lamus.workspace.model.Workspace) *///w w w.ja v a 2s .co m @Override public Collection<File> getFilesInOrphanDirectory(Workspace workspace) { File orphansDirectory; try { orphansDirectory = archiveFileLocationProvider .getOrphansDirectory(workspace.getTopNodeArchiveURL().toURI()); } catch (URISyntaxException ex) { logger.warn("Problem while trying to get the location of the orphans directory: " + ex.getMessage()); return new ArrayList<>(); } Collection<File> allFiles = new ArrayList<>(); if (orphansDirectory.exists()) { logger.debug("Listing files for orphans directory: " + orphansDirectory.getAbsolutePath()); allFiles = FileUtils.listFiles(orphansDirectory, null, true); } Collection<File> fileAvailableForWorkspace = new ArrayList<>(); for (File currentFile : allFiles) { try { if (currentFile.isFile()) { workspaceAccessChecker.ensureNodeIsNotLocked(currentFile.toURI()); //for metadata files: create a copy in the workspace and operate that copy so the original is kept intact if (currentFile.getName().endsWith(".cmdi")) { try { currentFile = copyOrphanFileToWorkspace(currentFile, workspace); } catch (URISyntaxException e) { logger.warn("Problem while trying to copy files into the workspace orphans directory: " + e.getMessage()); return new ArrayList<>(); } } fileAvailableForWorkspace.add(currentFile); } } catch (NodeAccessException ex) { //do nothing, let the loop continue } } return fileAvailableForWorkspace; }
From source file:org.jasig.portlet.proxy.service.proxy.document.URLRewritingFilter.java
protected void updateUrls(final Document document, final IContentResponse proxyResponse, final Map<String, Set<String>> elementSet, final RenderRequest request, final RenderResponse response, boolean action) { // attempt to retrieve the list of rewritten URLs from the session final PortletSession session = request.getPortletSession(); ConcurrentMap<String, String> rewrittenUrls; synchronized (PortletUtils.getSessionMutex(session)) { rewrittenUrls = (ConcurrentMap<String, String>) session.getAttribute(REWRITTEN_URLS_KEY); // if the rewritten URLs list doesn't exist yet, create it if (rewrittenUrls == null) { rewrittenUrls = new ConcurrentHashMap<String, String>(); session.setAttribute(REWRITTEN_URLS_KEY, rewrittenUrls); }/*from w w w. ja v a 2 s. c om*/ } // get the list of configured whitelist regexes final PortletPreferences preferences = request.getPreferences(); final String[] whitelistRegexes = preferences.getValues("whitelistRegexes", new String[] {}); // If we're proxying a remote website (as opposed to a local file system // resources, we'll need to transform any relative URLs. To do this, // we first compute the base and relative URLs for the page. String baseUrl = null; String relativeUrl = null; try { baseUrl = getBaseServerUrl(proxyResponse.getProxiedLocation()); relativeUrl = getRelativePathUrl(proxyResponse.getProxiedLocation()); LOG.trace("Computed base url {} and relative url {} for proxied url {}", baseUrl, relativeUrl, proxyResponse.getProxiedLocation()); } catch (URISyntaxException e) { LOG.error(e.getMessage(), e); } for (final Map.Entry<String, Set<String>> elementEntry : elementSet.entrySet()) { for (final String attributeName : elementEntry.getValue()) { // get a list of elements for this element type and iterate through // them, updating the relevant URL attribute final Elements elements = document.getElementsByTag(elementEntry.getKey()); for (Element element : elements) { String attributeUrl = element.attr(attributeName); LOG.trace("Considering element {} with URL attribute {} of value {}", element, attributeName, attributeUrl); // don't adjust or filter javascript url targets if (StringUtils.isNotBlank(attributeUrl) && !attributeUrl.startsWith(JAVASCRIPT_PREFIX) && !attributeUrl.startsWith(JAVASCRIPT_PREFIX.toLowerCase())) { // if we're proxying a remote website, adjust any // relative URLs into absolute URLs if (baseUrl != null) { // (1) do not prefix absolute URLs if (attributeUrl.contains("://") || attributeUrl.startsWith("//")) { // do nothing... } // (2) if the URL is relative to the server base, // prepend the base URL else if (attributeUrl.startsWith("/")) { attributeUrl = baseUrl.concat(attributeUrl); } // (3) otherwise use the full relative path else { attributeUrl = relativeUrl.concat(attributeUrl); } } // if this URL matches our whitelist regex, rewrite it // to pass through this portlet for (String regex : whitelistRegexes) { if (StringUtils.isNotBlank(regex)) { final Pattern pattern = Pattern.compile(regex); // TODO share compiled regexes if (pattern.matcher(attributeUrl).find()) { // record that we've rewritten this URL rewrittenUrls.put(attributeUrl, attributeUrl); // TODO: the value in the rewritten URLs map needs to // be a resource URL. we also want to key URLs by a short // string rather than the full URL if (elementEntry.getKey().equals("form")) { // the form action needs to be set to POST to // properly pass through our portlet boolean isPost = "POST".equalsIgnoreCase(element.attr("method")); if (!isPost) { element.attr("method", "POST"); } attributeUrl = createFormUrl(response, isPost, attributeUrl); } else if (action) { attributeUrl = createActionUrl(response, attributeUrl); } else { attributeUrl = createResourceUrl(response, attributeUrl); } } } } } element.attr(attributeName, attributeUrl.replace("&", "&")); } } } }
From source file:com.lsb.inomet.Inomet.java
protected void datuak_irakurri() { //Funtzio honekin Asynctask-a marchan jartzen dugu datuak irakurtzeko final captureData task = new captureData(); try {/*w w w .java 2 s . com*/ if (primera_vez) task.execute(new URI("http://10.123.5.43 "), null, null); else { task.execute(new URI("http://" + direccionWeb), null, null); } } catch (URISyntaxException e) { Toast.makeText(this, "Direccin " + direccionWeb + " incorrecta.", Toast.LENGTH_LONG).show(); Log.d(TAG, e.getMessage()); } }