private String getWebUrl(String containerPath) throws Exception { if (curator.get().checkExists().forPath(containerPath) != null) { byte[] bytes = ZkPath.loadURL(curator.get(), containerPath); String text = new String(bytes); // NOTE this is a bit naughty, we should probably be doing // Jackson parsing here; but we only need 1 String and // this avoids the jackson runtime dependency - its just a bit brittle // only finding http endpoints and all String prefix = "\"services\":[\""; int idx = text.indexOf(prefix); String answer = text; if (idx > 0) { int startIndex = idx + prefix.length(); int endIdx = text.indexOf("\"]", startIndex); if (endIdx > 0) { answer = text.substring(startIndex, endIdx); if (answer.length() > 0) { // lets expand any variables answer = ZooKeeperUtils.getSubstitutedData(curator.get(), answer); return answer; } } } } return null; }
protected void expandPropertyResolvers(ServiceDTO dto) throws URISyntaxException { List<String> services = dto.getServices(); List<String> newList = new ArrayList<String>(services.size()); for (String service : services) { String expanded = ZooKeeperUtils.getSubstitutedData(curator, service); newList.add(expanded); } dto.setServices(newList); }