List of usage examples for java.net URISyntaxException getMessage
public String getMessage()
From source file:ph.com.globe.connect.Payment.java
/** * Build request url./*from www . j av a 2s.co m*/ * * @param url target url * @param appId app id * @param appSecret app secret * @return String * @throws ApiException api exception */ protected String buildUrl(String url, String appId, String appSecret) throws ApiException { // try parsing url try { // initialize url builder URIBuilder builder = new URIBuilder(url); // set app id parameter builder.setParameter("app_id", appId); // set app secret parameter builder.setParameter("app_secret", appSecret); // build the url url = builder.build().toString(); return url; } catch (URISyntaxException e) { // throw exception throw new ApiException(e.getMessage()); } }
From source file:com.epimorphics.lda.renderers.common.EldaURL.java
/** * Construct an Elda page URL by parsing the given string as a URI * @param url String denoting the page URL * @exception EldaException if the given string is not a legal URI *///from w w w . j a v a 2s. c o m public EldaURL(String url) { try { uri = new URI(url); } catch (URISyntaxException e) { throw new EldaException("Failed to parse Elda page URL", e.getMessage(), EldaException.SERVER_ERROR, e); } }
From source file:org.couchpotato.CouchPotato.java
public URL fileCache(String filename) throws MalformedURLException { // WOW this sucks i hope this works for both windows and linux try {// ww w.j a v a 2s .c o m filename = filename.replace("\\", "/"); if (filename.startsWith("/") == false) { filename = "/" + filename; } return this.getUri("file.cache" + filename, null).toURL(); } catch (URISyntaxException e) { throw new MalformedURLException(e.getMessage()); } }
From source file:de.netsat.orekit.util.ZipJarCrawler.java
/** Build a zip crawler for an archive file in classpath. * @param classLoader class loader to use to retrieve the resources * @param resource name of the zip file to browse * @exception OrekitException if resource name is malformed *//*from w w w.j a va 2 s . c o m*/ public ZipJarCrawler(final ClassLoader classLoader, final String resource) throws OrekitException { try { this.file = null; this.resource = resource; this.classLoader = classLoader; this.url = null; this.name = classLoader.getResource(resource).toURI().toString(); } catch (URISyntaxException use) { throw new OrekitException(use, LocalizedFormats.SIMPLE_MESSAGE, use.getMessage()); } }
From source file:de.netsat.orekit.util.ZipJarCrawler.java
/** Build a zip crawler for an archive file on network. * @param url URL of the zip file on network * @exception OrekitException if url syntax is malformed *//* www .j a v a 2 s .com*/ public ZipJarCrawler(final URL url) throws OrekitException { try { this.file = null; this.resource = null; this.classLoader = null; this.url = url; this.name = url.toURI().toString(); } catch (URISyntaxException use) { throw new OrekitException(use, LocalizedFormats.SIMPLE_MESSAGE, use.getMessage()); } }
From source file:com.epimorphics.lda.renderers.common.EldaURL.java
/** * Generate a URL that has the same structure as this URL, except for the given parameters. * @param parameters Parameters of the new URL object, as a map * @return A new URL object/*from www .j a v a 2 s . c om*/ */ protected EldaURL generateURL(Map<String, URLParameterValue> parameters) { try { URI u = new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), uri.getPort(), uri.getPath(), queryString(parameters), uri.getFragment()); return new EldaURL(u); } catch (URISyntaxException e) { throw new EldaException("Failed to generate new EldaURL", e.getMessage(), EldaException.SERVER_ERROR, e); } }
From source file:io.uploader.drive.drive.largefile.GDriveUpload.java
protected String uploadFile(boolean update) throws IOException { Preconditions.checkState(update == (fileId != null)); DriveResumableUpload upload = null;// w w w .java 2 s . co m BasicFileAttributes attr = null; File fstatus = null; try { String googleLocation; String filestatus = tmpFilePath; attr = io.uploader.drive.util.FileUtils.getFileAttr(Paths.get(filename)); fstatus = new File(filestatus); if (fstatus.exists()) { BufferedReader in = new BufferedReader(new FileReader(filestatus)); md5 = in.readLine(); googleLocation = in.readLine(); in.close(); if (update) { upload = new DriveResumableUpload(config.getHttpProxySettings(), new DriveAuth(config), googleLocation, fileId, mimeType, filename, attr.size(), progressCallback); } else { upload = new DriveResumableUpload(config.getHttpProxySettings(), new DriveAuth(config), googleLocation, title, description, parentId, mimeType, filename, attr.size(), progressCallback); } } else { if (md5 == null) { FileInputStream fis = new FileInputStream(new File(filename)); md5 = org.apache.commons.codec.digest.DigestUtils.md5Hex(fis); logger.info("md5: " + md5); fis.close(); } // Completely new upload. location: null if (update) { upload = new DriveResumableUpload(config.getHttpProxySettings(), new DriveAuth(config), null, fileId, mimeType, filename, attr.size(), progressCallback); } else { upload = new DriveResumableUpload(config.getHttpProxySettings(), new DriveAuth(config), null, title, description, parentId, mimeType, filename, attr.size(), progressCallback); } // Write location and md5 to file for later resume BufferedWriter out = new BufferedWriter(new FileWriter(filestatus)); out.write(md5 + "\n" + upload.getLocation() + "\n"); out.close(); } } catch (URISyntaxException e) { logger.error("Error occurred while uploading files", e); throw new RuntimeException("Error occurred while uploading files " + e.getMessage()); } try { String ret = uploadFile(upload, attr); if (fstatus != null && fstatus.exists()) { fstatus.delete(); } return ret; } catch (TransferException e) { if (e.isNotResumable()) { if (fstatus != null && fstatus.exists()) { fstatus.delete(); } } throw new IOException(e.getMessage()); } }
From source file:org.couchpotato.CouchPotato.java
private <T> T command(String command, String arguments, Type type) throws MalformedURLException, IOException, SocketTimeoutException { try {//from w ww . j a v a2 s . c o m URI uri = this.getUri(command, arguments); // this WILL throw a EOFexception if it gets a HTTP 301 response because it wont follow it // so ALL URLS MUST BE PERFECT!!!! HttpURLConnection server = (HttpURLConnection) uri.toURL().openConnection(); // TODO going to try and not use this and see if everything works out // if ( uri.getScheme().compareTo("https") == 0 ) { // server = (HttpsURLConnection)uri.toURL().openConnection(); // } else { // server = (HttpURLConnection)uri.toURL().openConnection(); // } server.setConnectTimeout(SOCKET_TIMEOUT); Reader reader = new BufferedReader(new InputStreamReader(server.getInputStream())); // TypeToken cannot figure out T so instead it must be supplied GsonBuilder build = new GsonBuilder(); build.registerTypeAdapter(JsonBoolean.class, new JsonBooleanDeserializer()); T response; if (type == MovieListJson.class) { response = (T) build.create().fromJson(reader, _NewAPI_MovieListJson.class).toOld(); } else { response = build.create().fromJson(reader, type); } return response; } catch (URISyntaxException e) { throw new MalformedURLException(e.getMessage()); } }
From source file:com.orange.clara.cloud.servicedbdumper.dbdumper.DatabaseRefManager.java
private String extractUriFromCloudServiceKey(CloudServiceKey cloudServiceKey) throws DatabaseExtractionException { CloudService cloudService = cloudServiceKey.getService(); logger.debug("Service found: " + cloudService.getMeta() + " with label: " + cloudService.getLabel()); Map<String, Object> credentials = cloudServiceKey.getCredentials(); DatabaseType databaseType = this.extractDatabaseType(cloudService); if (databaseType == null) { throw new DatabaseExtractionException( "Database type cannot be extracted '" + cloudService.getName() + "'"); }//from w ww. jav a 2s. c o m String host = this.extractHostFromCredentials(credentials); if (host.isEmpty()) { throw new DatabaseExtractionException( "Hostname cannot be extracted from service '" + cloudService.getName() + "'"); } String databaseName = "/" + this.extractDatabaseNameFromCredentials(credentials); String username = this.extractUsernameFromCredentials(credentials); String password = this.extractPasswordFromCredentials(credentials); String portString = this.extractPortFromCredentials(credentials); int port = databaseType.getDefaultPort(); if (!portString.isEmpty()) { port = Integer.parseInt(portString); } String userInfo = ""; if (!username.isEmpty() && !password.isEmpty()) { userInfo = username + ":" + password; } if (!password.isEmpty() && username.isEmpty()) { userInfo = password; } try { URI generatedUri = new URI(databaseType.name().toLowerCase(), userInfo, host, port, databaseName, null, null); return generatedUri.toString(); } catch (URISyntaxException e) { throw new DatabaseExtractionException("Database cannot be extracted from service '" + cloudService.getName() + "' - Error: " + e.getMessage(), e); } }