00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 package org.openmobileis.synchro.openmsp.client.services;
00027
00028 import freemarker.template.*;
00029
00030 import java.io.IOException;
00031
00032 import org.openmobileis.common.context.ApplicationContext;
00033 import org.openmobileis.common.context.ApplicationContextManager;
00034 import org.openmobileis.common.util.collection.Array;
00035 import org.openmobileis.services.TemplateService;
00036 import org.openmobileis.services.common.ServiceManager;
00037 import org.openmobileis.services.navigation.NavigationBarService;
00038 import org.openmobileis.synchro.journal.JournalEntry;
00039 import org.openmobileis.synchro.journal.JournalLogRenderer;
00040 import org.openmobileis.synchro.journal.JournalManager;
00041 import org.openmobileis.synchro.openmsp.client.OpenMSPSynchroManager;
00042 import org.openmobileis.synchro.openmsp.protocol.Status;
00043
00044 import javax.servlet.ServletException;
00045 import javax.servlet.http.HttpServletRequest;
00046 import javax.servlet.http.HttpServletResponse;
00047
00059 public class SynchroJournalDisplayService extends TemplateService implements NavigationBarService {
00060
00061 private static final String templatePath="openmischannel"+java.io.File.separator+"journalsynchro.htm";
00062
00063 public SynchroJournalDisplayService() {
00064
00065 JournalManager.getManager();
00066 }
00067
00068 public String runTemplate(HttpServletRequest req, HttpServletResponse res, TemplateModelRoot templateData) throws ServletException, IOException {
00069 int status = OpenMSPSynchroManager.getManager().getGlobalSynchroStatut();
00070
00071 String syncMessage = JournalManager.getManager().getErrorMessageForSynchroStatus(status);
00072 templateData.put("syncstatus", new SimpleScalar(syncMessage));
00073
00074 Array list = JournalManager.getManager().getRendererList();
00075 SimpleList templatelist = new SimpleList();
00076 JournalLogRenderer renderer;
00077 int size = list.size();
00078 for (int i=0; i<size; i++) {
00079 renderer = (JournalLogRenderer)list.get(i);
00080 String syncName = renderer.getSyncName();
00081 JournalEntry[] entryList = JournalManager.getManager().getAllJournalEntryForService(syncName);
00082 if (entryList.length > 0) {
00083 renderer.render(templatelist, entryList);
00084 }
00085 }
00086 templateData.put("serviceLogList", templatelist);
00087
00088
00089 if (status == Status.STATUS_OK_RESTART_APPLICATION) {
00090 templateData.put("updateappli", new SimpleScalar(true));
00091 }
00092
00093
00094 ApplicationContext appContext = ApplicationContextManager.getManager().getApplicationContext();
00095 templateData.put("appversion", new SimpleScalar(appContext.getApplicationVersion()));
00096 templateData.put("openmisfwkversion", new SimpleScalar(appContext.getOpenMISFWKVersion()));
00097
00098
00099 return templatePath;
00100 }
00101
00102 public String getNavigationBarLabel(HttpServletRequest req) {
00103 return "Journal de Synchro";
00104 }
00105
00106 public boolean displayFormExitMessage() {
00107 return false;
00108 }
00109
00110 public boolean displayRecursive() {
00111 return false;
00112 }
00113
00114 public String getServiceUri() {
00115 return ServiceManager.getManager().getServiceBaseURI()+"/synchro/journal";
00116 }
00117 }