public static String getRiverVersion() { String version = "Undefined"; try { String properties = Streams.copyToStringFromClasspath("/org/elasticsearch/river/mongodb/es-build.properties"); Properties props = new Properties(); props.load(new FastStringReader(properties)); String ver = props.getProperty("version", "undefined"); String hash = props.getProperty("hash", "undefined"); if (!"undefined".equals(hash)) { hash = hash.substring(0, 7); } String timestamp = "undefined"; String gitTimestampRaw = props.getProperty("timestamp"); if (gitTimestampRaw != null) { timestamp = ISODateTimeFormat.dateTimeNoMillis().withZone(DateTimeZone.UTC).print(Long.parseLong(gitTimestampRaw)); } version = String.format("version[%s] - hash[%s] - time[%s]", ver, hash, timestamp); } catch (Exception ex) { } return version; }
@Override public String toString() { try { if (klass != null) { InputStream inputStream = klass.getResourceAsStream(path); if (inputStream == null) { throw new FileNotFoundException("Resource [" + path + "] not found in classpath with class [" + klass.getName() + "]"); } return Streams.copyToString(new InputStreamReader(inputStream, "UTF-8")); } else { return Streams.copyToStringFromClasspath(classLoader, path); } } catch (IOException e) { throw new EsSetupRuntimeException(e); } } }
@Override public String toString() { try { if (klass != null) { InputStream inputStream = klass.getResourceAsStream(path); if (inputStream == null) { throw new FileNotFoundException("Resource [" + path + "] not found in classpath with class [" + klass.getName() + "]"); } return Streams.copyToString(new InputStreamReader(inputStream, "UTF-8")); } else { return Streams.copyToStringFromClasspath(classLoader, path); } } catch (IOException e) { throw new EsSetupRuntimeException(e); } } }