ApplicationUpdateStatusService.java

00001 /*
00002  * OpenMobileIS - a free Java(TM) Framework for mobile applications Java(TM)
00003  * Copyright (C) 2004-2009 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.bundle.update.terminal;
00027 
00028 import java.io.IOException;
00029 
00030 import javax.servlet.ServletException;
00031 import javax.servlet.http.HttpServletRequest;
00032 import javax.servlet.http.HttpServletResponse;
00033 
00034 import org.openmobileis.common.util.log.LogManager;
00035 import org.openmobileis.services.Service;
00036 import org.openmobileis.services.common.ServiceManager;
00037 
00042 public final class ApplicationUpdateStatusService extends Service {
00043         //int counter  = 0;
00047         public ApplicationUpdateStatusService() {
00048         }
00049 
00050         /* (non-Javadoc)
00051          * @see org.openmobileis.services.Service#getServiceUri()
00052          */
00053         public String getServiceUri() {
00054                 return ServiceManager.getManager().getServiceBaseURI() + "/updatesynchrostatus";
00055         }
00056 
00057         /* (non-Javadoc)
00058          * @see org.openmobileis.services.Service#run(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
00059          */
00060         public void run(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
00061                 String ret = "<ret>false</ret>";
00062                 if (!ApplicationUpdateJarUtil.updateStarted) ret = "<ret>true</ret>";
00063         //      if (counter++==10)ret = "<ret>true</ret>";
00064                 res.getWriter().write(ret);
00065                 res.setStatus(200);
00066                 res.setContentLength(ret.length());
00067                 LogManager.traceDebug(0, "ApplicationUpdateStatusService Called.");
00068         }
00069         
00070         /* 
00071          * 
00072          * Exemple of script to update HTML page when update is over. Doesn't work on Wince and windows mobile 5.0
00073          *
00074         <if updateappli>
00075         <script type="text/javascript" src="/openmisajax.js"></script>
00076         <script language="JavaScript">
00077 
00078         var t;
00079         function makerequest()
00080         {
00081                 try     {
00082                         OPENMISSendRequest('/services/updatesynchrostatus');
00083                         if (OPENMISstatus < 300)        {
00084                                 if (OPENMISresponse == '<ret>true</ret>') {
00085                                 //update message.               
00086                                         var mess = OpenMISgetElement('status');
00087                                         if(mess)        {
00088                                                 mess.innerHTML = "Mise &agrave; jour de l'application termin&eacute;e. Veuillez relancer une nouvelle synchronisation pour r&eacute;cup&eacute;rer les tours.";
00089                                         }
00090                                         if (t) clearTimeout(t);
00091                                         return;
00092                                 }
00093                         } else  {
00094                                         if (t) clearTimeout(t);
00095                                         return;
00096                         } 
00097     } catch (err)       {}
00098           t = setTimeout("makerequest()", 1000);
00099 }
00100 
00101 function testupdate()
00102 {
00103         OpenMIScreateAJAX();
00104         makerequest();
00105 }
00106         </script>
00107 </if>
00108 
00109          *
00110          */
00111 
00112 }

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