KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openbravo > erpCommon > ad_process > ImportProductServlet


1 /*
2  ******************************************************************************
3  * The contents of this file are subject to the Compiere License Version 1.1
4  * ("License"); You may not use this file except in compliance with the License
5  * You may obtain a copy of the License at http://www.compiere.org/license.html
6  * Software distributed under the License is distributed on an "AS IS" basis,
7  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
8  * the specific language governing rights and limitations under the License.
9  * The Original Code is Compiere ERP & CRM Business Solution
10  * The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
11  * Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke, parts
12  * created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
13  * Contributor(s): Openbravo SL
14  * Contributions are Copyright (C) 2001-2006 Openbravo S.L.
15  ******************************************************************************
16 */

17 package org.openbravo.erpCommon.ad_process;
18
19 import org.openbravo.erpCommon.ad_actionButton.*;
20 import org.openbravo.erpCommon.utility.Utility;
21 import org.openbravo.utils.FormatUtilities;
22 import org.openbravo.base.secureApp.HttpSecureAppServlet;
23 import org.openbravo.base.secureApp.VariablesSecureApp;
24 import org.openbravo.xmlEngine.XmlDocument;
25 import java.io.*;
26 import javax.servlet.*;
27 import javax.servlet.http.*;
28
29
30 public class ImportProductServlet extends HttpSecureAppServlet {
31   
32
33   public void init (ServletConfig config) {
34     super.init(config);
35     boolHist = false;
36   }
37
38   public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException {
39     VariablesSecureApp vars = new VariablesSecureApp(request);
40
41     if (!Utility.hasProcessAccess(this, vars, "", "ImportProduct")) {
42       bdError(response, "AccessTableNoView", vars.getLanguage());
43       return;
44     }
45     String JavaDoc process = ImportData.processId(this, "ImportProduct");
46     if (vars.commandIn("DEFAULT")) {
47       String JavaDoc strTabId = vars.getGlobalVariable("inpTabId", "ImportProductServlet|tabId");
48       String JavaDoc strWindowId = vars.getGlobalVariable("inpwindowId", "ImportProductServlet|windowId");
49       String JavaDoc strDeleteOld = vars.getStringParameter("inpDeleteOld", "Y");
50       printPage(response, vars, process, strWindowId, strTabId, strDeleteOld);
51     } else if (vars.commandIn("SAVE")) {
52       String JavaDoc strDeleteOld = vars.getStringParameter("inpDeleteOld", "N");
53       String JavaDoc strTabId = vars.getRequestGlobalVariable("inpTabId", "ImportProductServlet|tabId");
54       String JavaDoc strWindowId = vars.getRequestGlobalVariable("inpwindowId", "ImportProductServlet|windowId");
55
56       ActionButtonDefaultData[] tab = ActionButtonDefaultData.windowName(this, strTabId);
57       String JavaDoc strWindowPath="";
58       String JavaDoc strTabName="";
59       if (tab!=null && tab.length!=0) {
60         strTabName = FormatUtilities.replace(tab[0].name);
61         if (tab[0].help.equals("Y")) strWindowPath="../utility/WindowTree_FS.html?inpTabId=" + strTabId;
62         else strWindowPath = "../" + FormatUtilities.replace(tab[0].description) + "/" + strTabName + "_Relation.html";
63       } else strWindowPath = strDefaultServlet;
64
65       ImportProduct pr = new ImportProduct(this, process, strDeleteOld.equals("Y"));
66       pr.startProcess(vars);
67       String JavaDoc strMessage = pr.getLog();
68       if (!strMessage.equals("")) vars.setSessionValue(strWindowId + "|" + strTabName + ".message", strMessage);
69       printPageClosePopUp(response, vars, strWindowPath);
70     } else pageErrorPopUp(response);
71   }
72
73
74 void printPage(HttpServletResponse response, VariablesSecureApp vars, String JavaDoc strProcessId, String JavaDoc strWindowId, String JavaDoc strTabId, String JavaDoc strDeleteOld) throws IOException, ServletException {
75       if (log4j.isDebugEnabled()) log4j.debug("Output: process ImportProductServlet");
76       ActionButtonDefaultData[] data = null;
77       String JavaDoc strHelp="", strDescription="";
78       if (vars.getLanguage().equals("en_US")) data = ActionButtonDefaultData.select(this, strProcessId);
79       else data = ActionButtonDefaultData.selectLanguage(this, vars.getLanguage(), strProcessId);
80       if (data!=null && data.length!=0) {
81         strDescription = data[0].description;
82         strHelp = data[0].help;
83       }
84       String JavaDoc[] discard = {""};
85       if (strHelp.equals("")) discard[0] = new String JavaDoc("helpDiscard");
86       XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_process/ImportProductServlet").createXmlDocument();
87       xmlDocument.setParameter("language", "LNG_POR_DEFECTO=\"" + vars.getLanguage() + "\";");
88       xmlDocument.setParameter("direction", "var baseDirection = \"" + strReplaceWith + "/\";\n");
89       xmlDocument.setParameter("question", Utility.messageBD(this, "StartProcess?", vars.getLanguage()));
90       xmlDocument.setParameter("description", strDescription);
91       xmlDocument.setParameter("help", strHelp);
92       xmlDocument.setParameter("windowId", strWindowId);
93       xmlDocument.setParameter("tabId", strTabId);
94       xmlDocument.setParameter("deleteOld", strDeleteOld);
95
96       response.setContentType("text/html; charset=UTF-8");
97       PrintWriter out = response.getWriter();
98       out.println(xmlDocument.print());
99       out.close();
100     }
101
102   public String JavaDoc getServletInfo() {
103     return "Servlet ImportProductServlet";
104   } // end of getServletInfo() method
105
}
106
107
Free Books   Free Magazines  
Popular Tags