List of usage examples for java.net URI getPath
public String getPath()
From source file:cross.datastructures.pipeline.ResultAwareCommandPipeline.java
/** * * @param cmd/* w ww . j a v a 2 s .c om*/ * @return */ protected String getFileHashKey(IFragmentCommand cmd) { URI fragmentCommandOutputDirectory = cmd.getWorkflow().getOutputDirectory(cmd).getAbsoluteFile().toURI(); URI relativeFile = FileTools.getRelativeUri( cmd.getWorkflow().getOutputDirectory().getAbsoluteFile().toURI(), fragmentCommandOutputDirectory); return cmd.getClass().getName() + "-" + relativeFile.getPath() + ".fileHash"; }
From source file:cross.datastructures.pipeline.ResultAwareCommandPipeline.java
/** * * @param cmd/*from w ww . j a va2 s .c o m*/ * @return */ protected String getParametersHashKey(IFragmentCommand cmd) { URI fragmentCommandOutputDirectory = cmd.getWorkflow().getOutputDirectory(cmd).getAbsoluteFile().toURI(); URI relativeFile = FileTools.getRelativeUri( cmd.getWorkflow().getOutputDirectory().getAbsoluteFile().toURI(), fragmentCommandOutputDirectory); return cmd.getClass().getName() + "-" + relativeFile.getPath() + ".parametersHash"; }
From source file:cat.calidos.morfeu.model.injection.URIToParsedModule.java
@Produces @Named("FetchedEffectiveContent") InputStream fetchedContentReady(@Named("FetchableContentURI") URI uri, @Named("FetchedRawContent") Producer<InputStream> rawContentProvider, @Named("FetchedTransformedContent") Producer<InputStream> transformedContentProvider) throws FetchingException { // if uri ends with yaml, we transform it from yaml to xml, otherwise we just fetch it raw, assuming xml String name = FilenameUtils.getName(uri.getPath()); try {/* w ww . ja v a 2 s .c o m*/ if (name.endsWith("yaml")) { return transformedContentProvider.get().get(); } else { return rawContentProvider.get().get(); } } catch (InterruptedException | ExecutionException e) { log.error("Could not complete executing fetch of '{}' ({}", uri, e); throw new FetchingException("Problem executing fetch '" + uri + "'", e); } }
From source file:it.infn.ct.futuregateway.apiserver.inframanager.SessionBuilder.java
/** * Read the proxy certificate from a remote location. * The location is retrieved from the parameters. * * @return A string representation of the proxy * @throws InfrastructureException If the proxy for the infrastructure * cannot be retrieved for problems with the parameters *//*from w w w .j a v a 2 s .c o m*/ protected final String readRemoteProxy() throws InfrastructureException { URL proxy; if (params.getProperty("proxyurl") == null && params.getProperty("etokenserverurl") == null) { throw new InfrastructureException( "No proxy location in " + "configuration parameters for " + infrastructure.getId()); } if (params.getProperty("proxyurl") != null) { try { proxy = new URL(params.getProperty("proxyurl")); } catch (MalformedURLException mue) { throw new InfrastructureException("URL for the proxy is not " + "valid, infrastructure " + infrastructure.getId() + " is not accessible"); } } else { try { URI etokenurl = new URI(params.getProperty("etokenserverurl")); StringBuilder queryURI = new StringBuilder(); StringBuilder pathURI = new StringBuilder(); String oldPath = etokenurl.getPath(); if (oldPath != null) { pathURI.append(oldPath); if (!oldPath.endsWith("/")) { pathURI.append('/'); } pathURI.append(params.getProperty("etokenid", "")); } else { pathURI.append('/').append(params.getProperty("etokenid", "")); } String oldQuery = etokenurl.getQuery(); if (oldQuery != null) { queryURI.append(oldQuery).append('&'); } queryURI.append("voms=").append(params.getProperty("vo", "")).append(':') .append(params.getProperty("voroles", "")).append('&'); queryURI.append("proxy-renewal=").append(params.getProperty("proxyrenewal", Defaults.PROXYRENEWAL)) .append('&'); queryURI.append("disable-voms-proxy=") .append(params.getProperty("disablevomsproxy", Defaults.DISABLEVOMSPROXY)).append('&'); queryURI.append("rfc-proxy=").append(params.getProperty("rfcproxy", Defaults.RFCPROXY)).append('&'); queryURI.append("cn-label="); if (user != null) { queryURI.append("eToken:").append(user); } etokenurl = new URI(etokenurl.getScheme(), etokenurl.getUserInfo(), etokenurl.getHost(), etokenurl.getPort(), pathURI.toString(), queryURI.toString(), etokenurl.getFragment()); proxy = etokenurl.toURL(); } catch (MalformedURLException | URISyntaxException use) { throw new InfrastructureException("etokenserverurl not " + "properly configured for infrastructure " + getInfrastructure().getId()); } } StringBuilder strProxy = new StringBuilder(); log.debug("Accessing the proxy " + proxy.toString()); try { String lnProxy; BufferedReader fileProxy = new BufferedReader(new InputStreamReader(proxy.openStream())); while ((lnProxy = fileProxy.readLine()) != null) { strProxy.append(lnProxy); strProxy.append("\n"); } } catch (IOException ioer) { log.error("Impossible to retrieve the remote proxy certificate from" + ": " + proxy.toString()); } log.debug("Proxy:\n\n" + strProxy.toString() + "\n\n"); return strProxy.toString(); }
From source file:eu.asterics.mw.services.TestResourceRegistry.java
@Test public void testSetAREBaseURI() throws URISyntaxException { //Test getting and relative to absolute testGetAREBaseURI();/*from w w w . j a va 2 s . co m*/ testRelativeToAbsoluteToRelative(); //change base URI String testURIString = "C:\\Program Files (x86)\\eclipse\\"; if (!OSUtils.isWindows()) { testURIString = "/var/log/"; } testURIString = FilenameUtils.normalize(testURIString); URI newURI; newURI = new File(testURIString).toURI(); System.out.println("Setting new AREBaseURI to <" + newURI.getPath() + ">"); URI oldURI = ResourceRegistry.getInstance().getAREBaseURI(); ResourceRegistry.getInstance().setAREBaseURI(newURI); //Test getting and relative to absolute again testGetAREBaseURI(); testRelativeToAbsoluteToRelative(); //Set old URI again to don't influence other tests. ResourceRegistry.getInstance().setAREBaseURI(oldURI); }
From source file:com.cloudera.livy.rsc.driver.RSCDriver.java
public File copyFileToLocal(File localCopyDir, String filePath, SparkContext sc) throws Exception { synchronized (jc) { if (!localCopyDir.isDirectory() && !localCopyDir.mkdir()) { throw new IOException("Failed to create directory to add pyFile"); }// w w w . ja va 2s . co m } URI uri = new URI(filePath); String name = uri.getFragment() != null ? uri.getFragment() : uri.getPath(); name = new File(name).getName(); File localCopy = new File(localCopyDir, name); if (localCopy.exists()) { throw new IOException(String.format("A file with name %s has " + "already been uploaded.", name)); } Configuration conf = sc.hadoopConfiguration(); FileSystem fs = FileSystem.get(uri, conf); fs.copyToLocalFile(new Path(uri), new Path(localCopy.toURI())); return localCopy; }
From source file:com.intuit.tank.proxy.Main.java
public void startHttpServer() throws IOException { InetSocketAddress addr = new InetSocketAddress(apiPort); HttpServer server = HttpServer.create(addr, 0); HttpHandler handler = new HttpHandler() { public void handle(HttpExchange exchange) throws IOException { String requestMethod = exchange.getRequestMethod(); URI requestURI = exchange.getRequestURI(); String msg = "unknown path"; if (requestMethod.equalsIgnoreCase("GET")) { // Thread t = null; if (requestURI.getPath().startsWith("/start")) { msg = "starting proxy on port " + port + " outputting to " + dumpFileName; // t = new Thread(new Runnable() { // @Override // public void run() { start();//from w w w .j a v a2 s.co m // } // }); } else if (requestURI.getPath().startsWith("/stop")) { msg = "stopping proxy and finalizing output in file " + dumpFileName; // t = new Thread(new Runnable() { // @Override // public void run() { stop(); // } // }); } else if (requestURI.getPath().startsWith("/quit")) { msg = "quitting proxy and finalizing output in file " + dumpFileName; // t = new Thread(new Runnable() { // @Override // public void run() { quit(); // } // }); } byte[] bytes = msg.getBytes(); Headers responseHeaders = exchange.getResponseHeaders(); responseHeaders.set("Content-Type", "text/plain"); exchange.sendResponseHeaders(200, bytes.length); OutputStream responseBody = exchange.getResponseBody(); responseBody.write(bytes); responseBody.close(); // if (t != null) { // t.start(); // } } } }; server.createContext("/", handler); server.setExecutor(Executors.newCachedThreadPool()); server.start(); System.out.println("Server is listening on port " + apiPort); }
From source file:edu.uw.sig.frames2owl.util.BatchFromIncludeConverter.java
private void runBatch() { // read general configuration parameters HierarchicalConfiguration conv = batchFromIncludeConfig.configurationAt("conv"); // run converter for primary String framesPath = conv.getString("frames-path"); String owlPath = conv.getString("owl-path"); String owlURI = conv.getString("owl-uri"); String configPath = conv.getString("conf-path"); //System.err.println("will create run using args: "+ framesPath+" "+owlPath+" "+owlURI); Converter mainConv = new Converter(framesPath, owlPath, owlURI, configPath); mainConv.run();//from w w w . jav a 2 s. co m // reuse frame2ProjectMap Map<FrameID, String> frame2ProjectMap = mainConv.getFrame2ProjectMap(); // get all of the included ont configs List<HierarchicalConfiguration> inclConfs = conv.configurationsAt("include"); Map<String, HierarchicalConfiguration> name2ConfMap = new HashMap<String, HierarchicalConfiguration>(); for (HierarchicalConfiguration inclConf : inclConfs) { String name = inclConf.getString("[@name]"); if (name == null || name.equals("")) { System.err.println("Include configuration with no name attribute"); continue; } name2ConfMap.put(name, inclConf); } // create and run converter for each included ont Collection<URI> includedProjURIs = mainConv.getIncludedProjects(); for (URI includedProjURI : includedProjURIs) { String ontName = getOntNameFromURI(includedProjURI); HierarchicalConfiguration include = name2ConfMap.get(ontName); if (include == null) { System.err.println("Included ontology with no corresponding batch config entry"); continue; } System.err.println(include); //TODO you are here! String includeFramesPath = includedProjURI.getPath(); String includeOwlPath = include.getString("owl-path"); String includeOwlURI = include.getString("owl-uri"); String includeConfigPath = include.getString("conf-path"); Converter importConv = new Converter(includeFramesPath, includeOwlPath, includeOwlURI, includeConfigPath, frame2ProjectMap); importConv.run(); } /* for(HierarchicalConfiguration conv : convs) { // get arguments for run // i.e. resource/cho.pprj results/test.owl http://si.uw.edu/ont/fma.owl String framesPath = conv.getString("frames-path"); String owlPath = conv.getString("owl-path"); String owlURI = conv.getString("owl-uri"); String configPath = conv.getString("conf-path"); //System.err.println("will create run using args: "+ framesPath+" "+owlPath+" "+owlURI); Converter currConv = new Converter(framesPath, owlPath, owlURI, configPath); currConv.run(); } */ }
From source file:com.offbytwo.jenkins.client.JenkinsHttpClient.java
/** * Create an unauthenticated Jenkins HTTP client * * @param uri// www . java2 s.co m * Location of the jenkins server (ex. http://localhost:8080) * @param client * Configured CloseableHttpClient to be used */ public JenkinsHttpClient(URI uri, CloseableHttpClient client) { this.context = uri.getPath(); if (!context.endsWith("/")) { context += "/"; } this.uri = uri; this.mapper = getDefaultMapper(); this.client = client; this.httpResponseValidator = new HttpResponseValidator(); // this.contentExtractor = new HttpResponseContentExtractor(); this.jenkinsVersion = null; LOGGER.debug("uri={}", uri.toString()); }
From source file:com.vp9.plugin.WebSocket.java
/** * Create the uri.//from www . j a v a2 s .c om * @param uriString * @return * @throws URISyntaxException */ private URI createURI(String uriString) throws URISyntaxException { URI uri = new URI(uriString); int port = uri.getPort(); if (port == -1) { if ("ws".equals(uri.getScheme())) { port = 80; } else if ("wss".equals(uri.getScheme())) { port = 443; } uri = URIUtils.createURI(uri.getScheme(), uri.getHost(), port, uri.getPath(), uri.getQuery(), uri.getFragment()); } return uri; }