Refactoring of WANavigation and i,plementation of Service Status

This commit is contained in:
Ziver Koc 2015-07-24 15:15:38 +00:00
parent e201f9ce4c
commit b115a9cb4f
14 changed files with 101 additions and 91 deletions

View file

@ -48,21 +48,25 @@ public class ServicePage implements WAPage {
private static final String TMPL_FILE = "WebContent/page/ServicePage.tmpl";
private ArrayList<WAService> services;
private ArrayList<ServiceStatusPage> statuses;
private ServiceStatusPage rootStatusPage;
private ArrayList<ServiceStatusPage> statusPages;
public ServicePage(PluginManager pluginManager){
this.services = pluginManager.toArray(WAService.class);
this.statuses = new ArrayList<>();
this.rootStatusPage = new ServiceStatusPage(pluginManager);
this.statusPages = new ArrayList<>();
WANavigation nav = new WANavigation(NAVIGATION_NAME, this);
WANavigation nav = WANavigation.getRootNav(NAVIGATION_NAME);
nav.setResource(this);
for(WAService plugin : services) {
statuses.add(new ServiceStatusPage(plugin.getStatus()));
nav.addSubNav(new WANavigation(plugin.getName(), plugin));
for(WAServiceConfig conf : plugin.getConfigurations()){
statusPages.add(new ServiceStatusPage(plugin.getStatus()));
WANavigation serviceNav = nav.getSubNav(plugin.getName());
serviceNav.setResource(plugin);
for(WAServiceConfig conf : plugin.getConfigurations()){
//serviceNav.getSubNav(conf.getName()).setResource(conf);
}
}
WANavigation.addRootNav(nav);
}
@ -74,16 +78,20 @@ public class ServicePage implements WAPage {
Map<String, String> request) {
try {
int index = services.indexOf(context.getBreadcrumb().get(1).getResource());
if(index < 0)
return null;
WAService obj = services.get(index);
ServiceStatusPage statusPage = statuses.get(index);
Templator tmpl = new Templator(FileUtil.find(TMPL_FILE));
tmpl.set("service_status",
statusPage.htmlResponse(context, client_info, session, cookie, request).compile());
return tmpl;
int index = services.indexOf(context.getBreadcrumb().get(1).getResource());
if (index >= 0) {
WAService obj = services.get(index);
ServiceStatusPage statusPage = statusPages.get(index);
Templator tmpl = new Templator(FileUtil.find(TMPL_FILE));
tmpl.set("service_status",
statusPage.htmlResponse(context, client_info, session, cookie, request).compile());
return tmpl;
}
else{ // root page
return rootStatusPage.htmlResponse(context, client_info, session, cookie, request);
}
}catch (IOException e){
log.log(Level.SEVERE, null, e);