use of com.peterphi.std.io.PropertyFile in project stdlib by petergeneric.
the class TomcatService method getTomcatsAndPorts.
public Map<File, Integer> getTomcatsAndPorts() {
final Map<File, Integer> map = new HashMap<>();
for (File domain : tomcatRoot.listFiles(new TomcatDomainFilenameFilter())) {
try {
PropertyFile props = new PropertyFile(new File(domain, "tomcat.properties"));
final int port = props.get("tomcat.port", -1);
final String path = props.get("tomcat.webapp.folder");
final File webappFolder = new File(path);
if (port <= 0)
throw new IllegalArgumentException("No port specified!");
else if (!webappFolder.exists())
throw new IllegalArgumentException("No valid webapp folder specified: does not exist: " + webappFolder);
map.put(webappFolder, port);
} catch (Exception e) {
throw new RuntimeException("Error reading tomcat.properties for " + domain, e);
}
}
return map;
}
Aggregations