List of usage examples for java.net URL toString
public String toString()
From source file:org.fcrepo.integration.auth.oauth.api.ContainerWrapper.java
public void start() throws Exception { final JAXBContext context = JAXBContext.newInstance(WebAppConfig.class); final Unmarshaller u = context.createUnmarshaller(); final WebAppConfig o = (WebAppConfig) u.unmarshal(getClass().getResource(this.configLocation)); final URI uri = URI.create("http://localhost:" + port + "/"); final Map<String, String> initParams = new HashMap<>(); server = GrizzlyWebContainerFactory.create(uri, initParams); // create a "root" web application final WebappContext wac = new WebappContext(o.displayName(), ""); for (final ContextParam p : o.contextParams()) { wac.addContextInitParameter(p.name(), p.value()); }/* www . j a v a 2 s . c o m*/ for (final Listener l : o.listeners) { wac.addListener(l.className()); } for (final Servlet s : o.servlets) { final ServletRegistration servlet = wac.addServlet(s.servletName(), s.servletClass()); final Collection<ServletMapping> mappings = o.servletMappings(s.servletName()); for (final ServletMapping sm : mappings) { servlet.addMapping(sm.urlPattern()); } for (final InitParam p : s.initParams()) { servlet.setInitParameter(p.name(), p.value()); } } for (final Filter f : o.filters) { final FilterRegistration filter = wac.addFilter(f.filterName(), f.filterClass()); final Collection<FilterMapping> mappings = o.filterMappings(f.filterName()); for (final FilterMapping sm : mappings) { final String urlPattern = sm.urlPattern(); final String servletName = sm.servletName(); if (urlPattern != null) { filter.addMappingForUrlPatterns(null, urlPattern); } else { filter.addMappingForServletNames(null, servletName); } } for (final InitParam p : f.initParams()) { filter.setInitParameter(p.name(), p.value()); } } wac.deploy(server); final URL webXml = this.getClass().getResource("/web.xml"); logger.error(webXml.toString()); logger.debug("started grizzly webserver endpoint at " + server.getHttpHandler().getName()); }
From source file:org.seedstack.w20.internal.W20BridgeIT.java
@Test @RunAsClient// w ww. j a va2s .c o m public void detected_fragments_are_resolved(@ArquillianResource URL baseUrl) { String response = given().auth().basic("ThePoltergeist", "bouh").expect().statusCode(200).when() .get(baseUrl.toString() + "seed-w20/application/configuration").getBody().asString(); assertThat(response).contains("\"" + baseUrl.getPath() + "seed-w20/seed-w20.w20.json\""); }
From source file:org.seedstack.w20.internal.W20BridgeIT.java
@Test @RunAsClient/* ww w .j a v a2 s . c o m*/ public void anonymous_fragment_is_preserved(@ArquillianResource URL baseUrl) { String response = given().auth().basic("ThePoltergeist", "bouh").expect().statusCode(200).when() .get(baseUrl.toString() + "seed-w20/application/configuration").getBody().asString(); assertThat(response).contains("\"\":{\"routes\":{\"/\":{\"templateUrl\":\"non-existent-template.html\"}}}"); }
From source file:org.n52.youngs.harvest.KvpCswSource.java
private String createRequest(long startPosition, long maxRecords) { StringBuilder recordsRequest = new StringBuilder(); URL url = getEndpoint(); recordsRequest.append(url);/*w w w . j a va 2 s.com*/ if (!url.toString().endsWith("?")) { recordsRequest.append("?"); } String fixedParameters = urlParameterJoiner.join(ImmutableMap.of("service", "CSW", "version", "2.0.2", "request", "GetRecords", "resultType", "results", "ElementSetName", "full")); recordsRequest.append(fixedParameters); String parameters = urlParameterJoiner.join(ImmutableMap.of("namespace", getNamespacesParameter(), "typeNames", getTypeNamesParameter(), "outputSchema", getOutputSchemaParameter(), "startPosition", startPosition, "maxRecords", maxRecords)); recordsRequest.append("&").append(parameters); return recordsRequest.toString(); }
From source file:de.felixschulze.acra.JsonSender.java
public void send(CrashReportData report) throws ReportSenderException { try {//w w w.java2 s . co m URL reportUrl; reportUrl = new URL(mFormUri.toString()); Log.d(LOG_TAG, "Connect to " + reportUrl.toString()); JSONObject json = createJSON(report); sendHttpPost(json.toString(), reportUrl, ACRA.getConfig().formUriBasicAuthLogin(), ACRA.getConfig().formUriBasicAuthPassword()); } catch (Exception e) { throw new ReportSenderException("Error while sending report to Http Post Form.", e); } }
From source file:org.openremote.android.console.util.AsyncGroupLoader.java
@Override public void run() { synchronized (this) { String server = AppSettingsModel.getSecuredServer(context); if (!TextUtils.isEmpty(server)) { HttpResponse response = null; try { URL url = new URL(server + "/rest/device/group"); HttpGet request = new HttpGet(url.toString()); HttpClient client = new DefaultHttpClient(); Scheme sch = new Scheme(url.getProtocol(), new SelfCertificateSSLSocketFactory(context), url.getPort());/* w w w . j av a 2s. com*/ client.getConnectionManager().getSchemeRegistry().register(sch); response = client.execute(request); } catch (ClientProtocolException e) { Log.e(LOG_CATEGORY + " run:", e.getMessage()); } catch (IOException e) { Log.e(LOG_CATEGORY + " run:", e.getMessage()); } String group = ""; if (response != null && response.getStatusLine().getStatusCode() == 200) { String tmp; try { BufferedReader in = new BufferedReader( new InputStreamReader(response.getEntity().getContent())); while ((tmp = in.readLine()) != null) { group += tmp; } } catch (IOException e) { Log.e(LOG_CATEGORY + " urlConnectionDidReceiveData:", e.getMessage()); } } AppSettingsModel.setGroup(context, group); } done = true; notify(); } }
From source file:com.samples.platform.service.common.GetServiceStatusOperation.java
/** * @param message/*from w ww .j a va2 s.c o m*/ * the {@link JAXBElement} containing a * {@link GetServiceStatusRequestType}. * @return the {@link JAXBElement} with a * {@link GetServiceStatusResponseType}. */ @InsightEndPoint @ServiceActivator public final JAXBElement<GetServiceStatusResponseType> getServiceStatus( final JAXBElement<GetServiceStatusRequestType> message) { this.logger.debug("+getServiceStatus"); GetServiceStatusResponseType response = this.of.createGetServiceStatusResponseType(); try { PropertyType p; ClassLoader cl; URL[] urls; ClassLoader sysCl = ClassLoader.getSystemClassLoader(); response.setStatus("Service is available"); /* System properties */ p = new PropertyType(); p.setName("System Properties"); response.getDetails().add(p); TreeSet<String> propertyNames = new TreeSet<String>(); propertyNames.addAll(System.getProperties().stringPropertyNames()); for (String propertyName : propertyNames) { p.getValue().add(new StringBuffer(64).append(propertyName).append("=") .append(System.getProperty(propertyName)).toString()); } /* Application properties. */ p = new PropertyType(); p.setName("Application loaded properties"); response.getDetails().add(p); propertyNames.clear(); propertyNames.addAll(this.properties.stringPropertyNames()); for (String propertyName : propertyNames) { p.getValue().add(new StringBuffer(64).append(propertyName).append("=") .append(this.properties.getProperty(propertyName)).toString()); } /* Current lass loader */ cl = this.getClass().getClassLoader(); p = new PropertyType(); p.setName("This ClassLoader"); response.getDetails().add(p); p.getValue().add(cl.getClass().getName()); if (URLClassLoader.class.isInstance(cl)) { urls = ((URLClassLoader) cl).getURLs(); p.getValue().add(new StringBuffer("Url: ").append(urls.length).toString()); for (URL url : urls) { p.getValue().add(url.toString()); } } cl = cl.getParent(); while (cl != sysCl) { p = new PropertyType(); p.setName("Parent Classloader"); response.getDetails().add(p); p.getValue().add(cl.getClass().getName()); if (URLClassLoader.class.isInstance(cl)) { urls = ((URLClassLoader) cl).getURLs(); p.getValue().add(new StringBuffer("Url: ").append(urls.length).toString()); for (URL url : urls) { p.getValue().add(url.toString()); } } cl = cl.getParent(); } /* System class loader */ cl = sysCl; p = new PropertyType(); p.setName("SystemClassLoader"); response.getDetails().add(p); p.getValue().add(cl.getClass().getName()); if (URLClassLoader.class.isInstance(cl)) { urls = ((URLClassLoader) cl).getURLs(); p.getValue().add(new StringBuffer("Url: ").append(urls.length).toString()); for (URL url : urls) { p.getValue().add(url.toString()); } } } catch (Throwable e) { this.logger.error(e.getMessage(), e); } finally { this.logger.debug("-getServiceStatus #{}, #f{}", response/* .get() */ != null ? 1 : 0, response.getFailure().size()); } return this.of.createGetServiceStatusResponse(response); }
From source file:com.iterranux.droolsjbpmCore.runtime.build.impl.KieModuleBuilder.java
/** * Simple Method to check if resource is duplicated in target/test-classes on classpath which happens during testing. * WARNING: This also excludes non test files if there path somehow contains '/target/test-classes/' which is unlikely. * * @param resourceURL/*from ww w .ja v a 2 s . c om*/ * @return Boolean */ protected Boolean isTestResource(URL resourceURL) { return resourceURL.toString().contains("/target/test-classes/"); }
From source file:com.iterranux.droolsjbpmCore.runtime.build.impl.KieModuleBuilder.java
/** * Simple Method to check if resource is folder. (Checks if last char of URL is /) * * @param resourceURL/*from w w w .j a v a 2 s .c om*/ * @return Boolean */ protected Boolean isFolder(URL resourceURL) { return resourceURL.toString().endsWith("/"); }
From source file:com.nominanuda.web.mvc.URLStreamer.java
private String determineContentType(URL url, URLConnection conn) { String ct = conn.getContentType(); if (ct == null || "content/unknown".equals(ct)) { ct = mimeHelper.guessContentTypeFromPath(url.toString()); //TODO add default charset if contenttype is textual }//from www . ja va2 s . co m if (ct == null) { ct = defaultContentType; } return ct; }