List of usage examples for java.net URL getPath
public String getPath()
From source file:fr.sanofi.fcl4transmart.controllers.listeners.rnaSeqData.RnaSeqLoadAnnotationListener.java
@Override protected String getJobPath() throws Exception { URL jobUrl = new URL("platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/load_rnaseq_annotation.kjb"); jobUrl = FileLocator.toFileURL(jobUrl); String jobPath = jobUrl.getPath(); jobUrl = new URL("platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/i2b2_rna_seq_annotation.ktr"); jobUrl = FileLocator.toFileURL(jobUrl); jobUrl = new URL( "platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/load_rna_annotation_to_de_gpl_info.ktr"); jobUrl = FileLocator.toFileURL(jobUrl); jobUrl = new URL( "platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/load_all_rnaseq_annotation_to_lt.ktr"); jobUrl = FileLocator.toFileURL(jobUrl); jobUrl = new URL("platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/cz_end_audit.ktr"); jobUrl = FileLocator.toFileURL(jobUrl); jobUrl = new URL("platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/cz_start_audit.ktr"); jobUrl = FileLocator.toFileURL(jobUrl); jobUrl = new URL("platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/cz_write_audit.ktr"); jobUrl = FileLocator.toFileURL(jobUrl); return jobPath; }
From source file:com.predic8.membrane.core.interceptor.WSDLInterceptor.java
private String getCompletePath(URL url) { if (url.getQuery() == null) return url.getPath(); return url.getPath() + "?" + url.getQuery(); }
From source file:fr.sanofi.fcl4transmart.controllers.listeners.proteomicsData.ProteomicsLoadAnnotationListener.java
@Override protected String getJobPath() throws Exception { URL jobUrl = new URL("platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/load_proteomics_annotation.kjb"); jobUrl = FileLocator.toFileURL(jobUrl); String jobPath = jobUrl.getPath(); jobUrl = new URL( "platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/load_proteomics_annotation_to_de_gpl_info.ktr"); jobUrl = FileLocator.toFileURL(jobUrl); jobUrl = new URL( "platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/load_proteomics_annotation_to_lt.ktr"); jobUrl = FileLocator.toFileURL(jobUrl); jobUrl = new URL( "platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/run_i2b2_load_proteomics_annot_deapp.ktr"); jobUrl = FileLocator.toFileURL(jobUrl); jobUrl = new URL("platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/cz_end_audit.ktr"); jobUrl = FileLocator.toFileURL(jobUrl); jobUrl = new URL("platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/cz_start_audit.ktr"); jobUrl = FileLocator.toFileURL(jobUrl); jobUrl = new URL("platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/cz_write_audit.ktr"); jobUrl = FileLocator.toFileURL(jobUrl); return jobPath; }
From source file:com.sun.socialsite.web.listeners.ContextListener.java
/** * Responds to context initialization event by processing context * parameters for easy access by the rest of the application. *//*from w w w . j a v a 2 s .co m*/ public void contextInitialized(ServletContextEvent sce) { log.info("SocialSite Initializing ... "); // Keep a reference to ServletContext object servletContext = sce.getServletContext(); // Set a "context.realpath" property, allowing others to find our filesystem basedir Config.setProperty("context.realpath", sce.getServletContext().getRealPath("/")); try { URL baseUrl = new URL(Config.getProperty("socialsite.base.url")); Config.setProperty("context.contextpath", baseUrl.getPath()); log.debug("Config[context.contextpath]=" + Config.getProperty("context.contextpath")); } catch (MalformedURLException ex) { String msg = String.format("Could not decode socialsite.base.url[%s]", Config.getProperty("socialsite.base.url")); log.error(msg, ex); } // Log system information (if enabled) // TODO: move this down to DEBUG level if (log.isInfoEnabled()) { logClassLoaderInfo(ClassLoader.getSystemClassLoader(), "systemClassLoader"); logClassLoaderInfo(Thread.currentThread().getContextClassLoader(), "contextClassLoader"); } // Set a "context.contextpath" property, allowing others to find our webapp base // Now prepare the core services of the app so we can bootstrap try { Startup.prepare(); } catch (StartupException ex) { log.fatal("SocialSite startup failed during app preparation", ex); return; } // If preparation failed or is incomplete then we are done if (!Startup.isPrepared()) { log.info("SocialSite startup requires interaction from user to continue"); return; } try { Factory.bootstrap(); Factory.getSocialSite().initialize(); } catch (BootstrapException ex) { log.fatal("Factory bootstrap failed", ex); } catch (SocialSiteException ex) { log.fatal("Factory initialization failed", ex); } log.info("SocialSite Initialization Complete"); }
From source file:io.stallion.tools.ExportToHtml.java
@Override public void execute(ServeCommandOptions options) throws Exception { Log.info("EXECUTE EXPORT ACTION!!"); String exportFolder = Settings.instance().getTargetFolder() + "/export-" + DateUtils.formatNow("yyyy-MM-dd-HH-mm-ss"); File export = new File(exportFolder); if (!export.exists()) { export.mkdirs();/* w w w .j a va2 s. com*/ } FileUtils.copyDirectory(new File(Settings.instance().getTargetFolder() + "/assets"), new File(exportFolder + "/st-assets")); Set<String> assets = new HashSet<>(); Set<String> allUrlPaths = new HashSet<>(); for (SiteMapItem item : SiteMapController.instance().getAllItems()) { String uri = item.getPermalink(); Log.info("URI {0}", uri); if (!uri.contains("://")) { uri = "http://localhost" + uri; } URL url = new URL(uri); allUrlPaths.add(url.getPath()); } allUrlPaths.addAll(ExporterRegistry.instance().exportAll()); for (String path : allUrlPaths) { Log.info("Export page {0}", path); MockRequest request = new MockRequest(path, "GET"); MockResponse response = new MockResponse(); RequestHandler.instance().handleStallionRequest(request, response); response.getContent(); if (!path.contains(".")) { if (!path.endsWith("/")) { path += "/"; } path += "index.html"; } File file = new File(exportFolder + path); File folder = new File(file.getParent()); if (!folder.isDirectory()) { folder.mkdirs(); } String html = response.getContent(); html = html.replace(Settings.instance().getSiteUrl(), ""); FileUtils.write(file, html, UTF8); assets.addAll(findAssetsInHtml(response.getContent())); } for (String src : assets) { Log.info("Asset src: {0}", src); MockRequest request = new MockRequest(src, "GET"); MockResponse response = new MockResponse(); RequestHandler.instance().handleStallionRequest(request, response); int min = 300; if (response.getContent().length() < 300) { min = response.getContent().length(); } URL url = new URL("http://localhost" + src); File file = new File(exportFolder + url.getPath()); File folder = new File(file.getParent()); if (!folder.isDirectory()) { folder.mkdirs(); } if (url.getPath().endsWith(".js") || url.getPath().endsWith(".css")) { FileUtils.write(file, response.getContent(), UTF8); } else { //ByteArrayOutputStream bos = new ByteArrayOutputStream(); //response.getOutputStream() //bos.writeTo(response.getOutputStream()); //bos.close(); //FileUtils.writeByteArrayToFile(file, response.getContent().getBytes()); } } }
From source file:es.gva.cit.catalog.protocols.HTTPGetProtocol.java
/** * //from ww w. j ava 2 s.c o m * * * @return * @param url * @param object * @param firstRecord */ public Collection doQuery(URL url, Object object, int firstRecord) { NameValuePair[] parameters = (NameValuePair[]) object; File file = null; String sUrl = "http://" + url.getHost() + ":" + url.getPort() + url.getPath(); sUrl = sUrl + createURLParams(parameters); try { file = Utilities.downloadFile(new URL(sUrl), "catalog-", null); } catch (Exception e) { return null; } Collection col = new java.util.ArrayList(); col.add(XMLTree.xmlToTree(file)); return col; }
From source file:com.dangdang.ddframe.job.security.WwwAuthFilter.java
@Override public void init(final FilterConfig filterConfig) throws ServletException { Properties props = new Properties(); URL classLoaderURL = Thread.currentThread().getContextClassLoader().getResource(""); if (null != classLoaderURL) { String configFilePath = Joiner.on(FILE_SEPARATOR).join(classLoaderURL.getPath(), "conf", "auth.properties"); try {/*from w w w.j a v a 2 s .co m*/ props.load(new FileInputStream(configFilePath)); } catch (final IOException ex) { log.warn("Cannot found auth config file, use default auth config."); } } rootUsername = props.getProperty("root.username", ROOT_DEFAULT_USERNAME); rootPassword = props.getProperty("root.password", ROOT_DEFAULT_PASSWORD); guestUsername = props.getProperty("guest.username", GUEST_DEFAULT_USERNAME); guestPassword = props.getProperty("guest.password", GUEST_DEFAULT_PASSWORD); }
From source file:com.google.enterprise.connector.sharepoint.wsclient.mock.XmlClientFactory.java
/** * Returns a {@link MockItem} that has the specified Url. * * @param itemUrl The Url to lookup//from w w w . j a va 2s . co m * @param username The user requesting access * @return a {@link MockItem} if found; null otherwise * @throws AxisFault when the user is not authorized */ public MockItem getItemFromUrl(final String itemUrl, String username) throws AxisFault { if (!root.hasPermission(username)) { throw new AxisFault(SPConstants.UNAUTHORIZED); } String path; try { final URL url = new URL(itemUrl); path = StringUtils.strip(url.getPath(), "/ "); } catch (MalformedURLException e) { path = ""; } MockItem item = root; for (String part : path.split("/")) { item = item.getChildByName(part); if (null == item) { break; } if (!item.hasPermission(username)) { throw new AxisFault(SPConstants.UNAUTHORIZED); } } return item; }
From source file:com.gatf.executor.report.ReportHandler.java
public static void doFinalLoadTestReport(String prefix, TestSuiteStats testSuiteStats, AcceptanceTestContext acontext, List<String> nodes, List<String> nodeurls, List<LoadTestResource> loadTestResources) { GatfExecutorConfig config = acontext.getGatfExecutorConfig(); VelocityContext context = new VelocityContext(); try {//from w w w .j a v a 2s. co m String reportingJson = new ObjectMapper().writeValueAsString(testSuiteStats); context.put("suiteStats", reportingJson); if (nodes == null) { reportingJson = new ObjectMapper().writeValueAsString(loadTestResources); context.put("loadTestResources", reportingJson); } else { context.put("loadTestResources", "{}"); context.put("nodes", nodes); context.put("nodeurls", nodeurls); } } catch (Exception e) { e.printStackTrace(); } try { File basePath = null; if (config.getOutFilesBasePath() != null) basePath = new File(config.getOutFilesBasePath()); else { URL url = Thread.currentThread().getContextClassLoader().getResource("."); basePath = new File(url.getPath()); } File resource = new File(basePath, config.getOutFilesDir()); VelocityEngine engine = new VelocityEngine(); engine.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath"); engine.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName()); engine.init(); StringWriter writer = new StringWriter(); engine.mergeTemplate("/gatf-templates/index-load.vm", context, writer); if (prefix == null) prefix = ""; BufferedWriter fwriter = new BufferedWriter(new FileWriter( new File(resource.getAbsolutePath() + SystemUtils.FILE_SEPARATOR + prefix + "index.html"))); fwriter.write(writer.toString()); fwriter.close(); //if(distributedTestStatus!=null) { //distributedTestStatus.getReportFileContent().put(prefix + "index.html", writer.toString()); } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.clican.pluto.orm.dynamic.impl.ClassLoaderUtilImpl.java
private void populateJars(Set<String> jars, ClassLoader loader) { if (!(loader instanceof URLClassLoader)) { if (log.isDebugEnabled()) { log.debug("The ClassLoader[" + loader.getClass().getName() + "] is ignored"); }/* w w w. j a va 2 s . c o m*/ } else { URLClassLoader urlClassLoader = (URLClassLoader) loader; for (URL url : urlClassLoader.getURLs()) { jars.add(url.getPath()); } } if (loader == ClassLoader.getSystemClassLoader()) { return; } else { populateJars(jars, loader.getParent()); } }