1 19 package org.openbravo.erpCommon.ad_actionButton; 20 21 import org.openbravo.base.secureApp.LoginUtils; 22 import org.openbravo.xmlEngine.XmlDocument; 23 import org.openbravo.erpCommon.utility.Utility; 24 25 import org.openbravo.base.secureApp.HttpSecureAppServlet; 26 import org.openbravo.base.secureApp.VariablesSecureApp; 27 28 29 import java.io.*; 30 import javax.servlet.*; 31 import javax.servlet.http.*; 32 33 34 public class ClearSession extends HttpSecureAppServlet { 35 36 public void init (ServletConfig config) { 37 super.init(config); 38 boolHist = false; 39 } 40 41 public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException { 42 VariablesSecureApp vars = new VariablesSecureApp(request); 43 44 if (vars.commandIn("DEFAULT")) { 45 printPage(response, vars); 46 } else if (vars.commandIn("CLEAR")) { 47 clear(response, vars); 48 } else pageErrorPopUp(response); 49 } 50 51 void printPage(HttpServletResponse response, VariablesSecureApp vars) throws IOException, ServletException { 52 log4j.debug("Output: clear"); 53 XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_actionButton/ClearSession").createXmlDocument(); 54 response.setContentType("text/html; charset=UTF-8"); 55 PrintWriter out = response.getWriter(); 56 out.println(xmlDocument.print()); 57 out.close(); 58 } 59 60 void clear(HttpServletResponse response, VariablesSecureApp vars) throws IOException, ServletException { 61 log4j.debug("process"); 62 63 String strRol = vars.getSessionValue("role"); 64 String strClient = vars.getSessionValue("client"); 65 String strOrg = vars.getSessionValue("organization"); 66 String strWarehouse = vars.getSessionValue("warehouse"); 67 68 69 String user = vars.getSessionValue("#AD_User_ID"); 70 String role = vars.getSessionValue("#AD_Role_ID"); 71 String language = vars.getSessionValue("#AD_Language"); 72 String client = vars.getSessionValue("#AD_Client_ID"); 73 String organization = vars.getSessionValue("#AD_Org_ID"); 74 String userClient = vars.getSessionValue("#User_Client"); 75 String userOrganization = vars.getSessionValue("#User_Org"); 76 String warehouse = vars.getSessionValue("#M_Warehouse_ID"); 77 String dbSessionID = vars.getSessionValue("#AD_Session_ID"); 78 79 80 vars.clearSession(false); 81 82 vars.setSessionValue("#AD_User_ID",user); 83 vars.setSessionValue("#AD_Role_ID",role); 84 vars.setSessionValue("#AD_Language",language); 85 vars.setSessionValue("#AD_Client_ID",client); 86 vars.setSessionValue("#AD_Org_ID",organization); 87 vars.setSessionValue("#User_Client",userClient); 88 vars.setSessionValue("#User_Org",userOrganization); 89 vars.setSessionValue("#M_Warehouse_ID",warehouse); 90 vars.setSessionValue("#AD_Session_ID",dbSessionID); 91 92 vars.setSessionValue("role",strRol); 93 vars.setSessionValue("client",strClient); 94 vars.setSessionValue("strOrg",strOrg); 95 vars.setSessionValue("warehouse",strWarehouse); 96 97 if (log4j.isDebugEnabled()) log4j.debug("role:"+role 98 + ",client:"+client 99 + ",strOrg:"+organization 100 + ",warehouse:"+warehouse); 101 102 103 104 105 106 107 XmlDocument xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_actionButton/ClearSession").createXmlDocument(); 108 response.setContentType("text/html; charset=UTF-8"); 109 PrintWriter out = response.getWriter(); 110 111 String strMessage; 112 113 if (!LoginUtils.fillSessionArguments(this, vars, user , vars.getLanguage(), role, client, organization, warehouse)) 114 strMessage = Utility.messageBD(this, "ProcessFailed", vars.getLanguage()); 115 else 116 strMessage = Utility.messageBD(this, "Success", vars.getLanguage()); 117 118 xmlDocument.setParameter("message",strMessage.equals("")?"":"alert('" + strMessage + "');window.close();"); 119 out.println(xmlDocument.print()); 120 out.close(); 121 } 122 } 123 124 | Popular Tags |