@Override protected Map<String, String> exposeConfiguration() { final Map<String, String> properties = new LinkedHashMap<String, String>(super.exposeConfiguration()); properties.put("DELEGATE", repo.toString()); return properties; }
@Override public void isValid() { if (repo instanceof BaseRepository) { ((BaseRepository)repo).isValid(); } }
@Test public void testGetStatus() throws Exception { Response response = auxRepo.getStatus(); assertEquals(Status.OK.getStatusCode(), response.getStatus()); assertTrue(response.getEntity().toString().startsWith("OK")); backendRepo.close(); response = auxRepo.getStatus(); assertEquals(Status.SERVICE_UNAVAILABLE.getStatusCode(), response.getStatus()); assertFalse(response.getEntity().toString().startsWith("OK")); }
@Override protected Map<String, String> exposeConfiguration() { final Map<String, String> properties = new LinkedHashMap<String, String>(super.exposeConfiguration()); properties.put("DELEGATE", repo.toString()); return properties; }
@Override public void isValid() { if (repo instanceof BaseRepository) { ((BaseRepository)repo).isValid(); } }
@Override public String toString() { final StringBuilder builder = new StringBuilder().append(super.toString()); final Map<String, String> properties = exposeConfiguration(); if (properties != null) { for (Map.Entry<String, String> entry : properties.entrySet()) { builder.append("\n\t").append(entry.getKey()).append("\t: ").append(entry.getValue()); } } return builder.toString(); }
@GET @Path("/status") public Response getStatus() { Status status = Status.OK; String text = "OK"; if (repo instanceof BaseRepository) { try { ((BaseRepository)repo).isValid(); } catch (IllegalStateException e) { status = Status.SERVICE_UNAVAILABLE; text = e.getMessage(); } } else { text = "N/A"; } return Response.status(status).entity(text + " : " + repo.getClass()).build(); }
@Override public String toString() { final StringBuilder builder = new StringBuilder().append(super.toString()); final Map<String, String> properties = exposeConfiguration(); if (properties != null) { for (Map.Entry<String, String> entry : properties.entrySet()) { builder.append("\n\t").append(entry.getKey()).append("\t: ").append(entry.getValue()); } } return builder.toString(); }
@GET @Path("/status") public Response getStatus() { Status status = Status.OK; String text = "OK"; if (repo instanceof BaseRepository) { try { ((BaseRepository)repo).isValid(); } catch (IllegalStateException e) { status = Status.SERVICE_UNAVAILABLE; text = e.getMessage(); } } else { text = "N/A"; } return Response.status(status).entity(text + " : " + repo.getClass()).build(); }
@Override protected Map<String, String> exposeConfiguration() { final Map<String, String> properties = new LinkedHashMap<String, String>(super.exposeConfiguration()); properties.put(Config.CLIENT_SERVER_URL, webResource.getURI().toString()); return properties; }
@Override protected Map<String, String> exposeConfiguration() { final Map<String, String> properties = new LinkedHashMap<String, String>(super.exposeConfiguration()); properties.put(Config.CLIENT_SERVER_URL, webResource.getURI().toString()); return properties; }