use of org.ambraproject.wombat.util.BuildInfo in project wombat by PLOS.
the class BuildInfoDirective method getValue.
@Override
protected Object getValue(Environment env, Map params) throws TemplateException, IOException {
String component = params.get("component").toString();
BuildInfo info;
switch(component) {
case "webapp":
info = buildInfoService.getWebappBuildInfo();
break;
case "service":
info = buildInfoService.getServiceBuildInfo();
break;
default:
throw new TemplateModelException("component required");
}
final Object value;
if (info == null) {
value = null;
} else {
String field = params.get("field").toString();
switch(field) {
case "version":
value = info.getVersion();
break;
case "date":
value = info.getDate();
break;
case "user":
value = info.getUser();
break;
case "commitIdAbbrev":
value = info.getGitCommitIdAbbrev();
break;
case "enabledDevFeatures":
value = info.getEnabledDevFeatures();
break;
default:
throw new TemplateModelException("field required");
}
}
return (value != null) ? value : "?";
}
Aggregations