KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openbravo > erpCommon > utility > ServletSetPriority


1 /*
2  *************************************************************************
3  * The contents of this file are subject to the Openbravo Public License
4  * Version 1.0 (the "License"), being the Mozilla Public License
5  * Version 1.1 with a permitted attribution clause; you may not use this
6  * file except in compliance with the License. You may obtain a copy of
7  * the License at http://www.openbravo.com/legal/license.html
8  * Software distributed under the License is distributed on an "AS IS"
9  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
10  * License for the specific language governing rights and limitations
11  * under the License.
12  * The Original Code is Openbravo ERP.
13  * The Initial Developer of the Original Code is Openbravo SL
14  * All portions are Copyright (C) 2001-2006 Openbravo SL
15  * All Rights Reserved.
16  * Contributor(s): ______________________________________.
17  ************************************************************************
18 */

19 package org.openbravo.erpCommon.utility;
20
21 import java.io.PrintWriter JavaDoc;
22 import java.io.IOException JavaDoc;
23
24 import javax.servlet.*;
25 import javax.servlet.http.*;
26 import org.openbravo.base.secureApp.HttpSecureAppServlet;
27 import org.openbravo.base.secureApp.VariablesSecureApp;
28 import org.openbravo.xmlEngine.XmlDocument;
29 import org.openbravo.base.*;
30 import org.openbravo.erpCommon.businessUtility.WindowTabs;
31 import org.apache.log4j.Logger;
32
33 import org.apache.log4j.Level;
34
35 public class ServletSetPriority extends HttpSecureAppServlet {
36   
37
38   public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException JavaDoc, ServletException {
39     doPost(request,response);
40   }
41
42   public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException JavaDoc, ServletException {
43     VariablesSecureApp vars = new VariablesSecureApp(request);
44     String JavaDoc strCategory = request.getParameter("category");
45     String JavaDoc strPriority = request.getParameter("priority");
46     if (strCategory != null && strPriority != null) {
47       Logger category = Logger.getLogger(strCategory);
48       Level priority = Level.toLevel(strPriority);
49       category.setLevel(priority);
50     }
51     printPage(response, vars);
52   }
53
54   void printPage(HttpServletResponse response, VariablesSecureApp vars) throws IOException JavaDoc, ServletException {
55     if (log4j.isDebugEnabled()) log4j.debug("Output: Page");
56     response.setContentType("text/html; charset=UTF-8");
57     PrintWriter JavaDoc out = response.getWriter();
58     XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/utility/SetPriority").createXmlDocument();
59     ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "SetPriority", false, "", "", "",false, "utility", strReplaceWith, false, true);
60     toolbar.prepareSimpleToolBarTemplate();
61     xmlDocument.setParameter("toolbar", toolbar.toString());
62     xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n");
63     xmlDocument.setParameter("language", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";");
64     try {
65       WindowTabs tabs = new WindowTabs(this, vars, "org.openbravo.erpCommon.ad_forms.ShowSession");
66       xmlDocument.setParameter("theme", vars.getTheme());
67       NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "SetPriority.html", classInfo.id, classInfo.type, strReplaceWith, tabs.breadcrumb());
68       xmlDocument.setParameter("navigationBar", nav.toString());
69       LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "SetPriority.html", strReplaceWith);
70       xmlDocument.setParameter("leftTabs", lBar.manualTemplate());
71     } catch (Exception JavaDoc ex) {
72       throw new ServletException(ex);
73     }
74     {
75       OBError myMessage = vars.getMessage("SetPriority");
76       vars.removeMessage("SetPriority");
77       if (myMessage!=null) {
78         xmlDocument.setParameter("messageType", myMessage.getType());
79         xmlDocument.setParameter("messageTitle", myMessage.getTitle());
80         xmlDocument.setParameter("messageMessage", myMessage.getMessage());
81       }
82     }
83     xmlDocument.setData("structure1",CategoryData.getCategories());
84     out.println(xmlDocument.print());
85     out.close();
86   }
87
88   public String JavaDoc getServletInfo() {
89         return "Servlet that asign a priority to a Category";
90   }
91 }
92
Popular Tags