private static URI removeAuthority(URI uri) { try { uri = new URI( uri.getScheme(), "", uri.getPath(), uri.getQuery(), uri.getFragment() ); } catch (URISyntaxException e) { throw new IllegalArgumentException(e.getLocalizedMessage()); } return uri; }
public List<PluginInterface> findPluginsByFolder( URL folder ) { String path = folder.getPath(); try { path = folder.toURI().normalize().getPath(); } catch ( URISyntaxException e ) { log.logError( e.getLocalizedMessage(), e ); } if ( path.endsWith( "/" ) ) { path = path.substring( 0, path.length() - 1 ); } List<PluginInterface> result = new ArrayList<PluginInterface>(); lock.readLock().lock(); try { for ( Set<PluginInterface> typeInterfaces : pluginMap.values() ) { for ( PluginInterface plugin : typeInterfaces ) { URL pluginFolder = plugin.getPluginDirectory(); try { if ( pluginFolder != null && pluginFolder.toURI().normalize().getPath().startsWith( path ) ) { result.add( plugin ); } } catch ( URISyntaxException e ) { log.logError( e.getLocalizedMessage(), e ); } } } } finally { lock.readLock().unlock(); } return result; }
LOGGER.error("URISyntaxException: " + e.getLocalizedMessage()); System.exit(1); } catch ( Exception e ) {
nameURL = new URI(url); } catch (URISyntaxException e) { String msg = e.getLocalizedMessage(); if (msg != null) System.err.println(msg);
String msg = use.getLocalizedMessage(); if (msg != null) { out.write(DataHelper.getASCII("<p>\n"));
public URI getSchemaLocationAsURI() { try { return new URI(schemaLocation); } catch (URISyntaxException e) { // shouldn't happen throw new IllegalArgumentException("Invalid URI: " + schemaLocation + ". Cause: " + e.getLocalizedMessage()); } }
private static URI removeAuthority(URI uri) { try { uri = new URI( uri.getScheme(), "", uri.getPath(), uri.getQuery(), uri.getFragment() ); } catch (URISyntaxException e) { throw new IllegalArgumentException(e.getLocalizedMessage()); } return uri; }
private static URI removeAuthority(URI uri) { try { uri = new URI( uri.getScheme(), "", uri.getPath(), uri.getQuery(), uri.getFragment() ); } catch (URISyntaxException e) { throw new IllegalArgumentException(e.getLocalizedMessage()); } return uri; }
private static URI removeAuthority(URI uri) { try { uri = new URI( uri.getScheme(), "", uri.getPath(), uri.getQuery(), uri.getFragment() ); } catch (URISyntaxException e) { throw new IllegalArgumentException(e.getLocalizedMessage()); } return uri; }
private static URI removeAuthority(URI uri) { try { uri = new URI( uri.getScheme(), "", uri.getPath(), uri.getQuery(), uri.getFragment() ); } catch (URISyntaxException e) { throw new IllegalArgumentException(e.getLocalizedMessage()); } return uri; }
URISyntaxException errorURISyntax(String hostName, URISyntaxException e) { error(errormsyntax, hostName, e.getLocalizedMessage()); return e; }
public void setUrlList(List<String> urlList) { this.m_urlList = urlList; Iterator<String> itr = urlList.iterator(); String uriStr = ""; while(itr.hasNext()) { URI uri; try { uriStr = itr.next(); uri = new URI(uriStr); m_uriList.add(uri); } catch (NoSuchElementException e) { LOGGER.error( "Failed to create URI for" + uriStr + " : " + e.getLocalizedMessage()); } catch (URISyntaxException e) { LOGGER.error( "Failed to create URI for" + uriStr + " : " + e.getLocalizedMessage()); } } } }
public void setSchemaLocation(String schemaLocation) { // if (schemaLocation != null) { // first check if schemaLocation is a valid URI try { new URI(schemaLocation); } catch (URISyntaxException e) { throw new IllegalArgumentException("Invalid URI: " + schemaLocation + ". Cause: " + e.getLocalizedMessage()); } this.schemaLocation = (String)modifyIfNeeded(this.schemaLocation, schemaLocation); } }
@Override public IResourceReference restore(final IResourceReference resourceReference) throws IOException { try { if (!ResourceReferenceUtilities.isFileSystemResource(resourceReference)) { throw new IOException("Unsupported resource"); //$NON-NLS-1$ } final File file = ResourceReferenceUtilities.getFile(resourceReference); final File backup = new File(file.getPath() + "~"); //$NON-NLS-1$ if (backup.exists()) { Files.copy(backup.toPath(), file.toPath(), StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.ATOMIC_MOVE); if (!file.exists()) { throw new IOException("Coudn't restore file " + file); //$NON-NLS-1$ } return new ResourceReferenceFactory().create(backup); } return null; } catch (final URISyntaxException exception) { throw new IOException(exception.getLocalizedMessage(), exception); } } }
@Override public URI convert(final URL url) { try { final URI converted = this.converter.convert(url); logger.log(ILevel.DEBUG, MessageFormat.format("url {0} uri {1}", url, converted)); //$NON-NLS-1$ return converted; } catch (final URISyntaxException exception) { logger.log(ILevel.DEBUG, exception.getLocalizedMessage(), exception); return null; } } }, sysloader.getURLs(), URI.class);
@Override public URI convert(final URL url) { try { final URI converted = this.converter.convert(url); logger.log(ILevel.DEBUG, MessageFormat.format("url {0} uri {1}", url, converted)); //$NON-NLS-1$ return converted; } catch (final URISyntaxException exception) { logger.log(ILevel.DEBUG, exception.getLocalizedMessage(), exception); return null; } } }, sysloader.getURLs(), URI.class);
@Override public Boolean visitUrlResource(final UrlResourceReference urlResourceReference) { try { final URI uri = urlToUriConverter.convert(urlResourceReference.getUrl()); return Boolean.valueOf(UriUtilities.isFileUri(uri)); } catch (final URISyntaxException exception) { logger.log(ILevel.WARNING, exception.getLocalizedMessage()); return Boolean.FALSE; } }
@Override public Boolean visitUrlResource(final UrlResourceReference urlResourceReference) { try { final URI uri = urlToUriConverter.convert(urlResourceReference.getUrl()); return Boolean.valueOf(UriUtilities.isFileUri(uri)); } catch (final URISyntaxException exception) { logger.log(ILevel.WARNING, exception.getLocalizedMessage()); return Boolean.FALSE; } }
static SocketAddress detectProxy(VpnProfile vp) { // Construct a new url with https as protocol try { URL url = new URL(String.format("https://%s:%s", vp.mServerName, vp.mServerPort)); Proxy proxy = getFirstProxy(url); if (proxy == null) return null; SocketAddress addr = proxy.address(); if (addr instanceof InetSocketAddress) { return addr; } } catch (MalformedURLException e) { VpnStatus.logError(R.string.getproxy_error, e.getLocalizedMessage()); } catch (URISyntaxException e) { VpnStatus.logError(R.string.getproxy_error, e.getLocalizedMessage()); } return null; }
private URIish getCloneURI(String content) { URIish finalURI; try { finalURI = new URIish(content.trim()); if (Protocol.FILE.handles(finalURI) || Protocol.GIT.handles(finalURI) || Protocol.HTTP.handles(finalURI) || Protocol.HTTPS.handles(finalURI) || Protocol.SSH.handles(finalURI)) return finalURI; else return null; } catch (URISyntaxException e) { Activator.handleError(e.getLocalizedMessage(), e, true); return null; } } }