Main Page | Packages | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

ServletTools.java

00001 /*
00002  * OpenMobileIS - a free Java(TM) Framework for mobile applications Java(TM)
00003  * Copyright (C) 2004-2005 Philippe Delrieu
00004  * All rights reserved.
00005  * Contact: openmobileis@e-care.fr
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  *  Modifications :
00025  *  2004 Creation P.Delrieu
00026  *  2004 Modified by Romain Beaugrand
00027  * 
00028  */
00029 
00030 package org.openmobileis.services.common;
00031 
00032 import javax.servlet.http.HttpServletResponse;
00033 
00034 import org.openmobileis.embedded.webserver.templates.*;
00035 import freemarker.template.*;
00036 import org.openmobileis.common.util.log.*;
00037 
00055 public class ServletTools {
00056 
00057 /*
00058 * Send a openmobileis error page
00059 *
00060 */
00061 public static void sendErrorPage (String serviceName, String message, String url, HttpServletResponse res) {
00062   try {
00063                 res.setContentType("text/html .html");
00064     TemplateModelRoot root = TemplateManager.getManager().getTemplateModelRoot();
00065     root.put("messageDonnees", new SimpleScalar(message));
00066     root.put("serviceName", new SimpleScalar(serviceName));
00067     root.put("url", new SimpleScalar(url));
00068     TemplateManager.getManager().sendResponse ("openmischannel"+java.io.File.separator+"erreurmessage.htm", root, res);
00069     } catch (TemplateNotFoundException ex)  {
00070       try {
00071         org.openmobileis.common.intl.IntlResourceManager resourceManager = org.openmobileis.common.intl.IntlResourceManager.getManager();
00072         String title = resourceManager.getLocalizedProperty("ServletTools.ErrorExec");
00073         res.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, title);
00074       } catch (Exception exi)  {
00075       }
00076       LogManager.traceAlert(LogServices.WEBSERVICE, "Error Template not found name erreurSaisie ");
00077       LogManager.traceAlert(LogServices.WEBSERVICE, ex);
00078     } catch (Exception ex) {
00079       try {
00080         org.openmobileis.common.intl.IntlResourceManager resourceManager = org.openmobileis.common.intl.IntlResourceManager.getManager();
00081         String title = resourceManager.getLocalizedProperty("ServletTools.ErrorExec");
00082         res.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, title);
00083       } catch (Exception exi)  {
00084       }
00085       LogManager.traceAlert(LogServices.WEBSERVICE, "Error during execution of Service"+serviceName);
00086       LogManager.traceAlert(LogServices.WEBSERVICE, ex);
00087     }
00088 }
00089 
00090   /*
00091   * Send a openmobileis error page
00092   *
00093   */
00094   public static void sendConfirmationPage (String serviceName, String message, String url, HttpServletResponse res) {
00095     try {
00096       TemplateModelRoot root = TemplateManager.getManager().getTemplateModelRoot();
00097       root.put("messageDonnees", new SimpleScalar(message));
00098       root.put("serviceName", new SimpleScalar(serviceName));
00099       root.put("url", new SimpleScalar(url));
00100       TemplateManager.getManager().sendResponse ("openmischannel"+java.io.File.separator+"confirmationmessage.htm", root, res);
00101     } catch (TemplateNotFoundException ex)  {
00102       try {
00103         org.openmobileis.common.intl.IntlResourceManager resourceManager = org.openmobileis.common.intl.IntlResourceManager.getManager();
00104         String title = resourceManager.getLocalizedProperty("ServletTools.ErrorExec");
00105         res.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, title);
00106       } catch (Exception exi)  {
00107       }
00108       LogManager.traceAlert(LogServices.WEBSERVICE, "Error Template not found name confirmation ");
00109       LogManager.traceAlert(LogServices.WEBSERVICE, ex);
00110     } catch (Exception ex) {
00111       try {
00112       org.openmobileis.common.intl.IntlResourceManager resourceManager = org.openmobileis.common.intl.IntlResourceManager.getManager();
00113       String title = resourceManager.getLocalizedProperty("ServletTools.ErrorExec");
00114       res.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, title);
00115       } catch (Exception exi)  {
00116       }
00117       LogManager.traceAlert(LogServices.WEBSERVICE, "Error during execution of Service"+serviceName);
00118       LogManager.traceAlert(LogServices.WEBSERVICE, ex);
00119     }
00120 }
00121 }

Generated on Wed Dec 14 21:05:35 2005 for OpenMobileIS by  doxygen 1.4.4