SynchroJournalDisplayService.java

00001 /*
00002  * OpenMobileIS - a free Java(TM) Framework for mobile applications Java(TM)
00003  * Copyright (C) 2004-2006 Philippe Delrieu
00004  * All rights reserved.
00005  * Contact: pdelrieu@openmobileis.org
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
00020  * USA
00021  *
00022  *  Author : Philippe Delrieu
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     // initialize tables at the launching
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     //manage application restart.
00089     if (status == Status.STATUS_OK_RESTART_APPLICATION) {
00090       templateData.put("updateappli", new SimpleScalar(true));
00091     }
00092     
00093     //manage application and open MobileIS version
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 }

Generated on Mon Jan 11 21:19:17 2010 for OpenMobileIS by  doxygen 1.5.4