public boolean outputError(Uri uri, GadgetException e) throws IOException { println(formatError("outputError", e, uri)); return e.getHttpStatusCode() == HttpResponse.SC_INTERNAL_SERVER_ERROR; }
public boolean outputError(Uri uri, GadgetException e) throws IOException { print(formatError(e, uri)); return e.getHttpStatusCode() == HttpResponse.SC_INTERNAL_SERVER_ERROR; }
public boolean outputError(Uri uri, GadgetException e) throws IOException { print(formatError(e, uri)); return e.getHttpStatusCode() == HttpResponse.SC_INTERNAL_SERVER_ERROR; }
public void rewrite(Gadget gadget, MutableContent content) throws RewritingException { Map<String, Feature> directFeatures = gadget.getViewFeatures(); Feature feature = directFeatures.get(TEMPLATES_FEATURE_NAME); if (feature == null && directFeatures.containsKey(OSML_FEATURE_NAME)) { feature = directFeatures.get(OSML_FEATURE_NAME); } if (feature != null && isServerTemplatingEnabled(feature)) { try { rewriteImpl(gadget, feature, content); } catch (GadgetException ge) { throw new RewritingException(ge, ge.getHttpStatusCode()); } } }
protected final FeatureRegistry getFeatureRegistry(JsUri jsUri) throws JsException { try { return featureRegistryProvider.get(jsUri.getRepository()); } catch (GadgetException e) { throw new JsException(e.getHttpStatusCode(), e.getMessage()); } }
/** * @return An HttpResponse object wrapping the given GadgetException. */ public static HttpResponse errorResponse(GadgetException e) { return new HttpResponseBuilder().setHttpStatusCode(e.getHttpStatusCode()) .setResponseString(e.getMessage() != null ? e.getMessage() : "").create(); }
/** * @return An HttpResponse object wrapping the given GadgetException. */ public static HttpResponse errorResponse(GadgetException e) { return new HttpResponseBuilder().setHttpStatusCode(e.getHttpStatusCode()) .setResponseString(e.getMessage() != null ? e.getMessage() : "").create(); }
/** * @return An HttpResponse object wrapping the given GadgetException. */ public static HttpResponse errorResponse(GadgetException e) { return new HttpResponseBuilder().setHttpStatusCode(e.getHttpStatusCode()) .setHeader("Content-Type", "text/plain") .setResponseString(e.getMessage() != null ? e.getMessage() : "").create(); }
@Test public void testHttpBadPort() throws Exception { Uri uri = Uri.parse("http://a:b/"); HttpRequest request = new HttpRequest(uri); try { fetcher.fetch(request); fail("Expected GadgetException"); } catch (GadgetException e) { assertEquals(400, e.getHttpStatusCode()); assertTrue(e.getMessage().contains("Bad port number in request")); } }
@Test public void testHttpBadUrl() throws Exception { Uri uri = Uri.parse("host/data"); HttpRequest request = new HttpRequest(uri); try { fetcher.fetch(request); fail("Expected GadgetException"); } catch (GadgetException e) { assertEquals(400, e.getHttpStatusCode()); assertTrue(e.getMessage().contains("Missing domain name for request")); } }
@Test public void testHttpBadHost() throws Exception { Uri uri = Uri.parse("http://a:b:c/"); HttpRequest request = new HttpRequest(uri); try { fetcher.fetch(request); fail("Expected GadgetException"); } catch (GadgetException e) { assertEquals(400, e.getHttpStatusCode()); assertTrue(e.getMessage().contains("Bad host name in request")); } }
@Test public void testHttpBadPort() throws Exception { Uri uri = Uri.parse("http://a:b/"); HttpRequest request = new HttpRequest(uri); try { fetcher.fetch(request); fail("Expected GadgetException"); } catch (GadgetException e) { assertEquals(400, e.getHttpStatusCode()); assertTrue(e.getMessage().contains("Bad port number in request")); } }
@Test public void testHttpNoSchema() throws Exception { Uri uri = Uri.parse("//host/data"); HttpRequest request = new HttpRequest(uri); try { fetcher.fetch(request); fail("Expected GadgetException"); } catch (GadgetException e) { assertEquals(400, e.getHttpStatusCode()); assertTrue(e.getMessage().contains("Missing schema for request")); } }
@Test public void testHttpBadHost() throws Exception { Uri uri = Uri.parse("http://a:b:c/"); HttpRequest request = new HttpRequest(uri); try { fetcher.fetch(request); fail("Expected GadgetException"); } catch (GadgetException e) { assertEquals(400, e.getHttpStatusCode()); assertTrue(e.getMessage().contains("Bad host name in request")); } }
@Test public void testHttpNoSchema() throws Exception { Uri uri = Uri.parse("//host/data"); HttpRequest request = new HttpRequest(uri); try { fetcher.fetch(request); fail("Expected GadgetException"); } catch (GadgetException e) { assertEquals(400, e.getHttpStatusCode()); assertTrue(e.getMessage().contains("Missing schema for request")); } }
@Test public void testHttpBadHost() throws Exception { Uri uri = Uri.parse("http://a:b:c/"); HttpRequest request = new HttpRequest(uri); try { fetcher.fetch(request); fail("Expected GadgetException"); } catch (GadgetException e) { assertEquals(400, e.getHttpStatusCode()); assertTrue(e.getMessage().contains("Bad host name in request")); } }
@Test public void testHttpBadUrl() throws Exception { Uri uri = Uri.parse("host/data"); HttpRequest request = new HttpRequest(uri); try { fetcher.fetch(request); fail("Expected GadgetException"); } catch (GadgetException e) { assertEquals(400, e.getHttpStatusCode()); assertTrue(e.getMessage().contains("Missing domain name for request")); } }
@Test public void testHttpBadPort() throws Exception { Uri uri = Uri.parse("http://a:b/"); HttpRequest request = new HttpRequest(uri); try { fetcher.fetch(request); fail("Expected GadgetException"); } catch (GadgetException e) { assertEquals(400, e.getHttpStatusCode()); assertTrue(e.getMessage().contains("Bad port number in request")); } }
@Test public void testHttpBadUrl() throws Exception { Uri uri = Uri.parse("host/data"); HttpRequest request = new HttpRequest(uri); try { fetcher.fetch(request); fail("Expected GadgetException"); } catch (GadgetException e) { assertEquals(400, e.getHttpStatusCode()); assertTrue(e.getMessage().contains("Missing domain name for request")); } }
@Test public void testHttpNoSchema() throws Exception { Uri uri = Uri.parse("//host/data"); HttpRequest request = new HttpRequest(uri); try { fetcher.fetch(request); fail("Expected GadgetException"); } catch (GadgetException e) { assertEquals(400, e.getHttpStatusCode()); assertTrue(e.getMessage().contains("Missing schema for request")); } }