1 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 process = ImportData.processId(this, "ImportProduct"); 46 if (vars.commandIn("DEFAULT")) { 47 String strTabId = vars.getGlobalVariable("inpTabId", "ImportProductServlet|tabId"); 48 String strWindowId = vars.getGlobalVariable("inpwindowId", "ImportProductServlet|windowId"); 49 String strDeleteOld = vars.getStringParameter("inpDeleteOld", "Y"); 50 printPage(response, vars, process, strWindowId, strTabId, strDeleteOld); 51 } else if (vars.commandIn("SAVE")) { 52 String strDeleteOld = vars.getStringParameter("inpDeleteOld", "N"); 53 String strTabId = vars.getRequestGlobalVariable("inpTabId", "ImportProductServlet|tabId"); 54 String strWindowId = vars.getRequestGlobalVariable("inpwindowId", "ImportProductServlet|windowId"); 55 56 ActionButtonDefaultData[] tab = ActionButtonDefaultData.windowName(this, strTabId); 57 String strWindowPath=""; 58 String 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 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 strProcessId, String strWindowId, String strTabId, String strDeleteOld) throws IOException, ServletException { 75 if (log4j.isDebugEnabled()) log4j.debug("Output: process ImportProductServlet"); 76 ActionButtonDefaultData[] data = null; 77 String 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 [] discard = {""}; 85 if (strHelp.equals("")) discard[0] = new String ("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 getServletInfo() { 103 return "Servlet ImportProductServlet"; 104 } } 106 107
| Popular Tags
|