private URL toURL(Servlet servlet) { try { return servlet.getBaseURI().toURL(); } catch (Exception e) { throw new RuntimeException("Could not convert Servlet to URL, " + servlet, e); } }
private URL toURL(Servlet servlet) { try { return servlet.getBaseURI().toURL(); } catch (Exception e) { throw new RuntimeException("Could not convert Servlet to URL, " + servlet, e); } }
private URL locateCommandEventBusURI(HTTPContext context) { List<Servlet> contextServlets = context.getServlets(); if (contextServlets == null) { throw new IllegalArgumentException("Could not determine URI for WarpFilter in context " + context + ". There are no Servlets in context."); } Set<String> contextRoots = new HashSet<String>(); for (Servlet servlet : contextServlets) { contextRoots.add(servlet.getContextRoot()); } if (contextRoots.size() == 1) { try { URI baseURI = context.getServlets().get(0).getBaseURI(); return new URL("http", baseURI.getHost(), baseURI.getPort(), baseURI.getPath()); } catch (MalformedURLException e) { throw new RuntimeException("Could not convert Servlet to URI, " + context.getServlets().get(0), e); } } else { try { return new URL("http", context.getHost(), context.getPort(), "/"); } catch (MalformedURLException e) { throw new RuntimeException("Could not convert HTTPContext to URI, " + context, e); } } } }
private URL locateCommandEventBusURI(HTTPContext context) { List<Servlet> contextServlets = context.getServlets(); if (contextServlets == null) { throw new IllegalArgumentException("Could not determine URI for WarpFilter in context " + context + ". There are no Servlets in context."); } Set<String> contextRoots = new HashSet<String>(); for (Servlet servlet : contextServlets) { contextRoots.add(servlet.getContextRoot()); } if (contextRoots.size() == 1) { try { URI baseURI = context.getServlets().get(0).getBaseURI(); return new URL("http", baseURI.getHost(), baseURI.getPort(), baseURI.getPath()); } catch (MalformedURLException e) { throw new RuntimeException("Could not convert Servlet to URI, " + context.getServlets().get(0), e); } } else { try { return new URL("http", context.getHost(), context.getPort(), "/"); } catch (MalformedURLException e) { throw new RuntimeException("Could not convert HTTPContext to URI, " + context, e); } } } }
URI baseURI = context.getServlets().get(0).getBaseURI(); String path = baseURI.getPath(); if (path.endsWith("/")) {
protected URI getBaseURL() { HTTPContext context = metaDataInst.get().getContext(HTTPContext.class); if (allInSameContext(context.getServlets())) { return context.getServlets().get(0).getBaseURI(); } throw new IllegalStateException("No baseURL found in HTTPContext"); }
private URI locateAuthURI(ProtocolMetaData data) { Collection<HTTPContext> contexts = data.getContexts(HTTPContext.class); if(contexts == null || contexts.size() == 0 || contexts.size() > 1) { throw new RuntimeException("Could not determine auth URL: " + contexts); } HTTPContext context = contexts.iterator().next(); return URI.create(context.getServlets().get(0).getBaseURI()+ "auth"); }
protected URI getBaseURI(Method method) throws Exception { ProtocolDefinition definition = registry.get().getProtocol(ProtocolDescription.DEFAULT); ModulesProtocolConfiguration configuration = (ModulesProtocolConfiguration) definition.createProtocolConfiguration(); HTTPContext context = ModulesApi.findHTTPContext(configuration, protocolMetaData, method); return context.getServlets().get(0).getBaseURI(); }
@Test public void testGetBaseURIForTestContext() { final String actualBaseUri = servletWithParent.getBaseURI().toString(); assertEquals(TEST_CONTEXT_ROOT_BASE_URI, actualBaseUri); }
@Test public void testGetBaseURIForTestContext() { final String actualBaseUri = servletWithParent.getBaseURI().toString(); assertEquals(TEST_CONTEXT_ROOT_BASE_URI, actualBaseUri); }
/** * ARQ-554 */ @Test public void testGetBaseURIForRootContext() { final String actualBaseUri = rootContextServletWithParent.getBaseURI().toString(); assertEquals(ROOT_CONTEXT_ROOT_BASE_URI, actualBaseUri); }
/** * ARQ-554 */ @Test public void testGetBaseURIForRootContext() { final String actualBaseUri = rootContextServletWithParent.getBaseURI().toString(); assertEquals(ROOT_CONTEXT_ROOT_BASE_URI, actualBaseUri); }