List of usage examples for java.net URL getPath
public String getPath()
From source file:edu.wisc.nexus.auth.gidm.realms.GroupIdManagementIndexHtmlCustomizer.java
public GroupIdManagementIndexHtmlCustomizer() { final Properties props = loadProperties(); final String groupId = props.getProperty("groupId"); final String artifactId = props.getProperty("artifactId"); final String minifiedJs = props.getProperty("minifiedJs"); final StringBuilder scriptTagBuilder = new StringBuilder(); String version = getVersionFromJarFile("/META-INF/maven/" + groupId + "/" + artifactId + "/pom.properties"); if (version != null && version.endsWith("-SNAPSHOT")) { //Get around caching on snapshot dev version = Long.toString(System.currentTimeMillis()); //Search the classpath for scripts final ClassSpace classSpace = new URLClassSpace(this.getClass().getClassLoader()); for (final Enumeration<URL> entries = classSpace.findEntries("/static/gidm/js/", artifactId + "-*.js", true); entries.hasMoreElements();) { final URL script = entries.nextElement(); final String path = script.getPath(); final String file = path.substring(path.lastIndexOf('/') + 1); if (!file.equals(minifiedJs)) { addScript(scriptTagBuilder, version, file); }//from ww w . ja v a 2 s . c om } } else { addScript(scriptTagBuilder, version, minifiedJs); } this.scriptTag = scriptTagBuilder.toString(); }
From source file:com.openingdesign.qna.model.impl.QueryAndResponseImpl.java
public String getEtherpadId() { URL url; try {/*from w ww . j a v a 2 s.c o m*/ url = new URL(getUrl()); return url.getPath().replace("/", ""); } catch (MalformedURLException e) { e.printStackTrace(); return "???"; } }
From source file:blue.lapis.pore.launch.PoreBootstrap.java
@Inject public PoreBootstrap(Injector injector) { URL location = getClass().getProtectionDomain().getCodeSource().getLocation(); String path = location.getPath(); if (location.getProtocol().equals("jar")) { int pos = path.lastIndexOf('!'); if (pos >= 0) { path = path.substring(0, pos + 2); }/*from ww w . ja v a 2 s . com*/ } else { path = StringUtils.removeEnd(path, getClass().getName().replace('.', '/') + ".class"); } try { ClassLoader loader = new PoreClassLoader(getClass().getClassLoader(), new URL(location.getProtocol(), location.getHost(), location.getPort(), path)); Class<?> poreClass = Class.forName(IMPLEMENTATION_CLASS, true, loader); this.pore = (PoreEventManager) injector.getInstance(poreClass); } catch (ClassNotFoundException e) { throw new RuntimeException("Failed to load Pore implementation", e); } catch (MalformedURLException e) { throw new RuntimeException("Failed to load Pore implementation", e); } }
From source file:gemlite.core.internal.batch.BatchGenenator.java
/*** * GS_HOME/batchFile//*from w w w. ja v a2 s . com*/ */ private void initializeWorkPath() { if (LogUtil.getCoreLog().isDebugEnabled()) LogUtil.getCoreLog().debug("path initializing..."); String path = ServerConfigHelper.getConfig(ITEMS.GS_HOME); if (StringUtils.isEmpty(path)) { URL url = this.getClass().getResource("/"); path = url.getPath(); } if (!path.endsWith(File.separator)) path += File.separator; path += "batchFile" + File.separator; if (LogUtil.getCoreLog().isDebugEnabled()) LogUtil.getCoreLog().debug("path:" + path); File file = new File(path); if (!file.exists()) { file.mkdirs(); } batchFilePath = path; if (LogUtil.getCoreLog().isDebugEnabled()) LogUtil.getCoreLog().debug("path initialized"); }
From source file:com.comcast.cdn.traffic_control.traffic_router.core.request.HTTPRequest.java
public void applyUrl(final URL url) { setPath(url.getPath()); setQueryString(url.getQuery());/* w ww. ja v a2s . co m*/ setHostname(url.getHost()); setRequestedUrl(url.toString()); }
From source file:io.sloeber.core.managers.Manager.java
/** * convert a web url to a local file name. The local file name is the cache * of the web/* ww w . ja va 2s . co m*/ * * @param url * url of the file we want a local cache * @return the file that represents the file that is the local cache. the * file itself may not exists. If the url is malformed return null; * @throws MalformedURLException */ public static File getLocalFileName(String url) { URL packageUrl; try { packageUrl = new URL(url.trim()); } catch (MalformedURLException e) { Common.log(new Status(IStatus.ERROR, Activator.getId(), "Malformed url " + url, e)); //$NON-NLS-1$ return null; } String localFileName = Paths.get(packageUrl.getPath()).getFileName().toString(); Path packagePath = Paths .get(ConfigurationPreferences.getInstallationPath().append(localFileName).toString()); return packagePath.toFile(); }
From source file:edu.wisc.nexus.auth.rut.realm.RemoteUserTokenIndexHtmlCustomizer.java
public RemoteUserTokenIndexHtmlCustomizer() { final InputStream propStream = getClass().getResourceAsStream(PROP_FILE_NAME); if (propStream == null) { throw new IllegalStateException("Could not find " + PROP_FILE_NAME + " on classpath"); }/*from w w w .j a v a 2s.co m*/ final Properties props = new Properties(); try { props.load(propStream); } catch (IOException e) { throw new IllegalStateException("Could not load " + PROP_FILE_NAME + " from classpath", e); } finally { IOUtils.closeQuietly(propStream); } final String groupId = props.getProperty("groupId"); final String artifactId = props.getProperty("artifactId"); final String minifiedJs = props.getProperty("minifiedJs"); final StringBuilder scriptTagBuilder = new StringBuilder(); String version = getVersionFromJarFile("/META-INF/maven/" + groupId + "/" + artifactId + "/pom.properties"); if (version != null && version.endsWith("-SNAPSHOT")) { //Get around caching on snapshot dev version = Long.toString(System.currentTimeMillis()); //Search the classpath for scripts final ClassSpace classSpace = new URLClassSpace(this.getClass().getClassLoader()); for (final Enumeration<URL> entries = classSpace.findEntries("/static/js/", artifactId + "-*.js", true); entries.hasMoreElements();) { final URL script = entries.nextElement(); final String path = script.getPath(); final String file = path.substring(path.lastIndexOf('/') + 1); if (!file.equals(minifiedJs)) { addScript(scriptTagBuilder, version, file); } } } else { addScript(scriptTagBuilder, version, minifiedJs); } this.scriptTag = scriptTagBuilder.toString(); }
From source file:com.playonlinux.wine.WineInstallationTest.java
@Before public void getSystemProperties() throws Exception { URL url = this.getClass().getResource("."); this.wineInstallationToTest = new WineInstallation.Builder().withPath(new File(url.getPath())).build(); }
From source file:com.yfiton.oauth.receiver.GraphicalReceiver.java
private String getClasspath() { StringBuilder result = new StringBuilder(); for (URL url : ((URLClassLoader) Thread.currentThread().getContextClassLoader()).getURLs()) { result.append(new File(url.getPath())); result.append(File.pathSeparatorChar); }// w w w .ja v a 2s . c o m return result.toString(); }
From source file:io.fabric8.maven.core.handler.ProbeHandler.java
private HTTPGetAction getHTTPGetAction(String getUrl) { if (getUrl == null || !getUrl.subSequence(0, 4).toString().equalsIgnoreCase("http")) { return null; }//from w ww . j a v a 2s . co m try { URL url = new URL(getUrl); return new HTTPGetAction(url.getHost(), null /* headers */, url.getPath(), new IntOrString(url.getPort()), url.getProtocol()); } catch (MalformedURLException e) { throw new IllegalArgumentException("Invalid URL " + getUrl + " given for HTTP GET readiness check"); } }