From ed47ed7118449604c23ab0438b6f45a67b285869 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Mon, 11 Mar 2013 09:40:29 -0500 Subject: [PATCH 1/3] IDEMPIERE-716 #resolve can't use new role when "User Level" of the role is "system" --- org.adempiere.base/src/org/compiere/util/Login.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/util/Login.java b/org.adempiere.base/src/org/compiere/util/Login.java index 5d7a18abad..3be1f18c96 100644 --- a/org.adempiere.base/src/org/compiere/util/Login.java +++ b/org.adempiere.base/src/org/compiere/util/Login.java @@ -842,9 +842,6 @@ public class Login String retValue = ""; int AD_Client_ID = Env.getContextAsInt(m_ctx, "#AD_Client_ID"); int AD_Org_ID = org.getKey(); - @SuppressWarnings("unused") - int AD_User_ID = Env.getContextAsInt(m_ctx, "#AD_User_ID"); - int AD_Role_ID = Env.getContextAsInt(m_ctx, "#AD_Role_ID"); // Other Settings Env.setContext(m_ctx, "#YYYY", "Y"); From 722537e0f58fc442852b4cd32aa6e749f6950108 Mon Sep 17 00:00:00 2001 From: Juliana Corredor Date: Mon, 11 Mar 2013 16:39:58 -0500 Subject: [PATCH 2/3] IDEMPIERE-645 Fitnesse Recorder --- .../idempiere/fitrecorder/FitRecorder.java | 309 +++++++++++------- 1 file changed, 184 insertions(+), 125 deletions(-) diff --git a/org.idempiere.fitrecorder/src/org/idempiere/fitrecorder/FitRecorder.java b/org.idempiere.fitrecorder/src/org/idempiere/fitrecorder/FitRecorder.java index d254a6f497..4f4f581ca8 100644 --- a/org.idempiere.fitrecorder/src/org/idempiere/fitrecorder/FitRecorder.java +++ b/org.idempiere.fitrecorder/src/org/idempiere/fitrecorder/FitRecorder.java @@ -16,9 +16,12 @@ *****************************************************************************/ package org.idempiere.fitrecorder; +import groovy.swing.factory.WidgetFactory; + import java.io.BufferedWriter; import java.io.File; import java.io.FileOutputStream; +import java.io.IOException; import java.io.OutputStreamWriter; import java.io.Writer; import java.math.BigDecimal; @@ -28,14 +31,18 @@ import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.logging.Level; +import org.codehaus.groovy.control.messages.Message; import org.compiere.model.MClient; import org.compiere.model.MColumn; import org.compiere.model.MPInstance; import org.compiere.model.MPInstancePara; import org.compiere.model.MProcess; import org.compiere.model.MProcessPara; +import org.compiere.model.MSearchDefinition; +import org.compiere.model.MSession; import org.compiere.model.MSysConfig; import org.compiere.model.MTable; import org.compiere.model.MUser; @@ -47,11 +54,13 @@ import org.compiere.util.CLogger; import org.compiere.util.DB; import org.compiere.util.DisplayType; import org.compiere.util.Env; +import org.compiere.util.Ini; public class FitRecorder implements ModelValidator { - private static FileOutputStream tempFile = null; - private static Writer writer; + private static FileOutputStream FileOr = null; + private static Writer writer; + private HashMap files; /** Logger */ private static CLogger log = CLogger.getCLogger(FitRecorder.class); @@ -103,14 +112,10 @@ public class FitRecorder implements ModelValidator { @Override public void initialize(ModelValidationEngine engine, MClient client) { - SimpleDateFormat format = new SimpleDateFormat ("yyyyMMddHHmmss"); - String dateTimeText = format.format(new Timestamp(System.currentTimeMillis())); + files=new HashMap(); try { - File fileNameOr = File.createTempFile("fit_test_" + dateTimeText + "_", ".txt"); - tempFile = new FileOutputStream(fileNameOr, true); - writer = new BufferedWriter(new OutputStreamWriter(tempFile, "UTF8")); - + String sql = "SELECT ta.TableName" +" FROM AD_Table ta" +" WHERE ta.IsActive='Y'" @@ -164,53 +169,6 @@ public class FitRecorder implements ModelValidator { @Override public String login(int AD_Org_ID, int AD_Role_ID, int AD_User_ID) { - try { - - writer.append("\n"); - writer.append("\n"); - writer.append("LOGIN"); - writer.append("\n"); - writer.append("!"); - writer.append("|Login|"); - writer.append("\n"); - MUser user = MUser.get(Env.getCtx(), AD_User_ID); - writer.append("|User|"); - if (MSysConfig.getBooleanValue(MSysConfig.USE_EMAIL_FOR_LOGIN, false)) - writer.append(user.getEMail() + "|"); - else - if (user.getLDAPUser() != null) - writer.append(user.getLDAPUser() + "|"); - else - writer.append(user.getName() + "|"); - writer.append("\n"); - writer.append("|Password|"); - writer.append(user.getPassword() + "|"); - writer.append("\n"); - writer.append("|AD_Client_ID|"); - MClient client = MClient.get(Env.getCtx(), Env.getContextAsInt(Env.getCtx(), "#AD_Client_ID")); - writer.append("@Ref=AD_Client[Name='" + client.getName() + "'].AD_Client_ID|"); - writer.append("\n"); - writer.append("|AD_Org_ID|"); - String orgName = DB.getSQLValueString(null, "SELECT Name FROM AD_Org WHERE AD_Org_ID=?", AD_Org_ID); - writer.append("@Ref=AD_Org[Name='" + orgName + "'].AD_Org_ID|"); - writer.append("\n"); - writer.append("|AD_Role_ID|"); - writer.append("@Ref=AD_Role[Name='" + Env.getContext(Env.getCtx(), "#AD_Role_Name") + "'].AD_Role_ID|"); - writer.append("\n"); - int warehouseid = Env.getContextAsInt(Env.getCtx(), Env.M_WAREHOUSE_ID); - if (warehouseid > 0) { - MWarehouse warehouse = MWarehouse.get(Env.getCtx(), warehouseid); - writer.append("|M_Warehouse_ID|"); - writer.append("@Ref=M_Warehouse[Name='" + warehouse.getName() + "'].M_Warehouse_ID|"); - writer.append("\n"); - } - writer.append("|*Login*|"); - writer.append("\n"); - writer.flush(); - - } catch (Exception e) { - return e.getLocalizedMessage(); - } return null; } @@ -219,6 +177,10 @@ public class FitRecorder implements ModelValidator { try { if (type == TYPE_AFTER_NEW ) { + + if(po instanceof MSession){ + loginFixture(po); + } if (dontLogTables.contains(po.get_TableName().toUpperCase())) return null; @@ -230,15 +192,15 @@ public class FitRecorder implements ModelValidator { if (po.get_TrxName().startsWith("WFP_")) return null; - writer.append("\n"); - writer.append("\n"); - writer.append("CREATE RECORD"); - writer.append("\n"); - writer.append("!"); - writer.append("|Create Record||"); - writer.append("\n"); - writer.append("|*Table*|"); - writer.append(po.get_TableName() + "|"); + writeFile("\n"); + writeFile("\n"); + writeFile("CREATE RECORD"); + writeFile("\n"); + writeFile("!"); + writeFile("|Create Record||"); + writeFile("\n"); + writeFile("|*Table*|"); + writeFile(po.get_TableName() + "|"); MTable table = MTable.get(Env.getCtx(),po.get_Table_ID()); for(MColumn column : table.getColumns(false)) { @@ -260,19 +222,18 @@ public class FitRecorder implements ModelValidator { String value = po.get_ValueAsString(colName); if (value != null && value.length() > 0) { - writer.append("\n"); - writer.append("|" + colName + "|"); + writeFile("\n"); + writeFile("|" + colName + "|"); if (DisplayType.isLookup(column.getAD_Reference_ID()) && DisplayType.List != column.getAD_Reference_ID()) { - writer.append(resolveValue(po, table, column) + "|"); + writeFile(resolveValue(po, table, column) + "|"); } else { - writer.append(value +"|"); + writeFile(value +"|"); } } } - writer.append("\n"); - writer.append("|*Save*|"); - writer.append("\n"); - writer.flush(); + writeFile("\n"); + writeFile("|*Save*|"); + writeFile("\n"); } @@ -281,15 +242,15 @@ public class FitRecorder implements ModelValidator { MProcess pro = MProcess.get(Env.getCtx(), po.get_ValueAsInt("AD_Process_ID")); MPInstance pint = (MPInstance)po; - writer.append("\n"); - writer.append("\n"); - writer.append("RUN PROCESS"); - writer.append("\n"); - writer.append("!"); - writer.append("|Run Process|"); - writer.append("\n"); - writer.append("|*ProcessValue*|"); - writer.append(pro.getValue() + "|"); + writeFile("\n"); + writeFile("\n"); + writeFile("RUN PROCESS"); + writeFile("\n"); + writeFile("!"); + writeFile("|Run Process|"); + writeFile("\n"); + writeFile("|*ProcessValue*|"); + writeFile(pro.getValue() + "|"); MPInstancePara[] iparas = pint.getParameters(); for (MProcessPara para : pro.getParameters()) { MPInstancePara ipara = null; @@ -327,23 +288,34 @@ public class FitRecorder implements ModelValidator { valueTo = ipara.getP_String_To(); } if (value != null) { - writer.append("\n"); - writer.append("|" + para.getColumnName() + "|"); - writer.append(value + "|"); + writeFile("\n"); + writeFile("|" + para.getColumnName() + "|"); + writeFile(value + "|"); } if (para.isRange() && valueTo != null) { - writer.append("\n"); - writer.append("|" + para.getColumnName() + "_2|"); - writer.append(valueTo + "|"); + writeFile("\n"); + writeFile("|" + para.getColumnName() + "_2|"); + writeFile(valueTo + "|"); } } - writer.append("\n"); - writer.append("|*Run*|"); - writer.append("\n"); - writer.flush(); + writeFile("\n"); + writeFile("|*Run*|"); + writeFile("\n"); } } + + if (po instanceof MSession){ + if (type == TYPE_AFTER_CHANGE) { + MSession session =(MSession) po; + if(session.isProcessed()){ + String msg=closefile(); + if (msg != null){ + return msg; + } + } + } + } }catch (Exception e) { return e.getLocalizedMessage(); } @@ -435,47 +407,46 @@ public class FitRecorder implements ModelValidator { if (timing == TIMING_BEFORE_POST) action = "PO"; - writer.append("\n"); - writer.append("\n"); + writeFile("\n"); + writeFile("\n"); if (action.equals("CO")) { // run process String processValue = DB.getSQLValueString(po.get_TrxName(), "SELECT p.Value FROM AD_Process p JOIN AD_Workflow w ON (p.AD_Workflow_ID=w.AD_Workflow_ID) WHERE w.AD_Table_ID=?", po.get_Table_ID()); - writer.append("RUN PROCESS"); - writer.append("\n"); - writer.append("!"); - writer.append("|Run Process|"); - writer.append("\n"); - writer.append("|*ProcessValue*|"); - writer.append(processValue + "|"); - writer.append("\n"); - writer.append("|*RecordID*|"); - writer.append(resolveValueDoc(po.get_ID(), po.get_TableName()) + "|"); - writer.append("\n"); - writer.append("|*DocAction*|"); - writer.append(action + "|"); - writer.append("\n"); - writer.append("|*Run*|"); + writeFile("RUN PROCESS"); + writeFile("\n"); + writeFile("!"); + writeFile("|Run Process|"); + writeFile("\n"); + writeFile("|*ProcessValue*|"); + writeFile(processValue + "|"); + writeFile("\n"); + writeFile("|*RecordID*|"); + writeFile(resolveValueDoc(po.get_ID(), po.get_TableName()) + "|"); + writeFile("\n"); + writeFile("|*DocAction*|"); + writeFile(action + "|"); + writeFile("\n"); + writeFile("|*Run*|"); } else { // set doc action - writer.append("SET DOC ACTION"); - writer.append("\n"); - writer.append("!"); - writer.append("|Set DocAction|"); - writer.append("\n"); - writer.append("|*Table*|"); - writer.append(po.get_TableName() + "|"); - writer.append("\n"); - writer.append("|" + po.get_TableName() + "_ID|"); - writer.append(resolveValueDoc(po.get_ID(), po.get_TableName()) + "|"); - writer.append("\n"); - writer.append("|DocAction|"); - writer.append(action + "|"); - writer.append("\n"); - writer.append("|*Save*|"); + writeFile("SET DOC ACTION"); + writeFile("\n"); + writeFile("!"); + writeFile("|Set DocAction|"); + writeFile("\n"); + writeFile("|*Table*|"); + writeFile(po.get_TableName() + "|"); + writeFile("\n"); + writeFile("|" + po.get_TableName() + "_ID|"); + writeFile(resolveValueDoc(po.get_ID(), po.get_TableName()) + "|"); + writeFile("\n"); + writeFile("|DocAction|"); + writeFile(action + "|"); + writeFile("\n"); + writeFile("|*Save*|"); } - writer.append("\n"); - writer.flush(); + writeFile("\n"); } } catch (Exception e) { if (log.isLoggable(Level.INFO)) log.info(e.getLocalizedMessage()); @@ -514,4 +485,92 @@ public class FitRecorder implements ModelValidator { return value; } + + public String loginFixture(PO po){ + String msg=null; + String preference = Env.getPreference(Env.getCtx(), 0, "FitRecorder", false); + if (preference.equals("Y")) { + int Session_ID = po.get_ID(); + int User_ID = Env.getContextAsInt(Env.getCtx(), "#AD_User_ID"); + int AD_Org_ID = Env.getContextAsInt(Env.getCtx(), "#AD_Org_ID"); + MUser user = new MUser(Env.getCtx(), User_ID, null); + String name = Ini.getAdempiereHome() + "/log/fit_test_" + Session_ID+ user.getName() + ".txt"; + File fileNameOr; + try { + fileNameOr = new File(name); + FileOr = new FileOutputStream(fileNameOr, true); + writer = new BufferedWriter(new OutputStreamWriter(FileOr, + "UTF8")); + files.put(Session_ID, writer); + writer.append("\n"); + writer.append("\n"); + writer.append("LOGIN"); + writer.append("\n"); + writer.append("!"); + writer.append("|Login|"); + writer.append("\n"); + writer.append("|User|"); + if (MSysConfig.getBooleanValue(MSysConfig.USE_EMAIL_FOR_LOGIN, + false)) + writer.append(user.getEMail() + "|"); + else if (user.getLDAPUser() != null) + writer.append(user.getLDAPUser() + "|"); + else + writer.append(user.getName() + "|"); + writer.append("\n"); + writer.append("|Password|"); + writer.append(" |"); + writer.append("\n"); + writer.append("|AD_Client_ID|"); + MClient client = MClient.get(Env.getCtx(),Env.getContextAsInt(Env.getCtx(), "#AD_Client_ID")); + writer.append("@Ref=AD_Client[Name='" + client.getName() + "'].AD_Client_ID|"); + writer.append("\n"); + writer.append("|AD_Org_ID|"); + String orgName = DB.getSQLValueString(null,"SELECT Name FROM AD_Org WHERE AD_Org_ID=?", AD_Org_ID); + writer.append("@Ref=AD_Org[Name='" + orgName + "'].AD_Org_ID|"); + writer.append("\n"); + writer.append("|AD_Role_ID|"); + writer.append("@Ref=AD_Role[Name='"+ Env.getContext(Env.getCtx(), "#AD_Role_Name")+ "'].AD_Role_ID|"); + writer.append("\n"); + int warehouseid = Env.getContextAsInt(Env.getCtx(),Env.M_WAREHOUSE_ID); + if (warehouseid > 0) { + MWarehouse warehouse = MWarehouse.get(Env.getCtx(),warehouseid); + writer.append("|M_Warehouse_ID|"); + writer.append("@Ref=M_Warehouse[Name='" + warehouse.getName()+ "'].M_Warehouse_ID|"); + writer.append("\n"); + } + writer.append("|*Login*|"); + writer.append("\n"); + files.put(Session_ID, writer); + } catch (Exception e) { + return e.getLocalizedMessage(); + } + } + return msg; + } + + public void writeFile(String msg){ + int Session_ID=Env.getContextAsInt(Env.getCtx(), "#AD_Session_ID"); + Writer writerOr=(Writer) files.get(Session_ID); + try{ + writerOr.append(msg); + writerOr.flush(); + + }catch (Exception e) { + + } + } + + public String closefile(){ + String msg=null; + int Session_ID=Env.getContextAsInt(Env.getCtx(), "#AD_Session_ID"); + Writer writerOr=(Writer) files.get(Session_ID); + try { + writerOr.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + return e.getLocalizedMessage(); + } + return msg; + } } From 9243e6453de9df0cfc09eac36b151ea572a5242c Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Mon, 11 Mar 2013 17:44:16 -0500 Subject: [PATCH 3/3] IDEMPIERE-645 Fitnesse Recorder / peer review --- .../idempiere/fitrecorder/FitRecorder.java | 144 ++++++++---------- 1 file changed, 64 insertions(+), 80 deletions(-) diff --git a/org.idempiere.fitrecorder/src/org/idempiere/fitrecorder/FitRecorder.java b/org.idempiere.fitrecorder/src/org/idempiere/fitrecorder/FitRecorder.java index 4f4f581ca8..1de13aa38a 100644 --- a/org.idempiere.fitrecorder/src/org/idempiere/fitrecorder/FitRecorder.java +++ b/org.idempiere.fitrecorder/src/org/idempiere/fitrecorder/FitRecorder.java @@ -16,8 +16,6 @@ *****************************************************************************/ package org.idempiere.fitrecorder; -import groovy.swing.factory.WidgetFactory; - import java.io.BufferedWriter; import java.io.File; import java.io.FileOutputStream; @@ -27,21 +25,17 @@ import java.io.Writer; import java.math.BigDecimal; import java.sql.PreparedStatement; import java.sql.ResultSet; -import java.sql.Timestamp; -import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.logging.Level; -import org.codehaus.groovy.control.messages.Message; import org.compiere.model.MClient; import org.compiere.model.MColumn; import org.compiere.model.MPInstance; import org.compiere.model.MPInstancePara; import org.compiere.model.MProcess; import org.compiere.model.MProcessPara; -import org.compiere.model.MSearchDefinition; import org.compiere.model.MSession; import org.compiere.model.MSysConfig; import org.compiere.model.MTable; @@ -58,9 +52,7 @@ import org.compiere.util.Ini; public class FitRecorder implements ModelValidator { - private static FileOutputStream FileOr = null; - private static Writer writer; - private HashMap files; + private HashMap writersPerSession; /** Logger */ private static CLogger log = CLogger.getCLogger(FitRecorder.class); @@ -112,7 +104,7 @@ public class FitRecorder implements ModelValidator { @Override public void initialize(ModelValidationEngine engine, MClient client) { - files=new HashMap(); + writersPerSession=new HashMap(); try { @@ -178,7 +170,7 @@ public class FitRecorder implements ModelValidator { try { if (type == TYPE_AFTER_NEW ) { - if(po instanceof MSession){ + if (po instanceof MSession) { loginFixture(po); } if (dontLogTables.contains(po.get_TableName().toUpperCase())) @@ -305,18 +297,15 @@ public class FitRecorder implements ModelValidator { } } - if (po instanceof MSession){ + if (po instanceof MSession) { if (type == TYPE_AFTER_CHANGE) { - MSession session =(MSession) po; - if(session.isProcessed()){ - String msg=closefile(); - if (msg != null){ - return msg; - } + MSession session = (MSession) po; + if (session.isProcessed()) { + closefile(); } } } - }catch (Exception e) { + } catch (Exception e) { return e.getLocalizedMessage(); } return null; @@ -490,58 +479,56 @@ public class FitRecorder implements ModelValidator { String msg=null; String preference = Env.getPreference(Env.getCtx(), 0, "FitRecorder", false); if (preference.equals("Y")) { - int Session_ID = po.get_ID(); - int User_ID = Env.getContextAsInt(Env.getCtx(), "#AD_User_ID"); - int AD_Org_ID = Env.getContextAsInt(Env.getCtx(), "#AD_Org_ID"); - MUser user = new MUser(Env.getCtx(), User_ID, null); - String name = Ini.getAdempiereHome() + "/log/fit_test_" + Session_ID+ user.getName() + ".txt"; - File fileNameOr; + int session_ID = po.get_ID(); + int user_ID = Env.getContextAsInt(Env.getCtx(), "#AD_User_ID"); + int org_ID = Env.getContextAsInt(Env.getCtx(), "#AD_Org_ID"); + MUser user = new MUser(Env.getCtx(), user_ID, null); + String name = Ini.getAdempiereHome() + "/log/fit_test_" + session_ID+ user.getName() + ".txt"; try { - fileNameOr = new File(name); - FileOr = new FileOutputStream(fileNameOr, true); - writer = new BufferedWriter(new OutputStreamWriter(FileOr, - "UTF8")); - files.put(Session_ID, writer); - writer.append("\n"); - writer.append("\n"); - writer.append("LOGIN"); - writer.append("\n"); - writer.append("!"); - writer.append("|Login|"); - writer.append("\n"); - writer.append("|User|"); + File file = new File(name); + FileOutputStream fos = new FileOutputStream(file, true); + Writer writer = new BufferedWriter(new OutputStreamWriter(fos, "UTF8")); + Env.setContext(Env.getCtx(), "#AD_Session_ID", session_ID); + writersPerSession.put(session_ID, writer); + writeFile("\n"); + writeFile("\n"); + writeFile("LOGIN"); + writeFile("\n"); + writeFile("!"); + writeFile("|Login|"); + writeFile("\n"); + writeFile("|User|"); if (MSysConfig.getBooleanValue(MSysConfig.USE_EMAIL_FOR_LOGIN, false)) - writer.append(user.getEMail() + "|"); + writeFile(user.getEMail() + "|"); else if (user.getLDAPUser() != null) - writer.append(user.getLDAPUser() + "|"); + writeFile(user.getLDAPUser() + "|"); else - writer.append(user.getName() + "|"); - writer.append("\n"); - writer.append("|Password|"); - writer.append(" |"); - writer.append("\n"); - writer.append("|AD_Client_ID|"); + writeFile(user.getName() + "|"); + writeFile("\n"); + writeFile("|Password|"); + writeFile(" |"); + writeFile("\n"); + writeFile("|AD_Client_ID|"); MClient client = MClient.get(Env.getCtx(),Env.getContextAsInt(Env.getCtx(), "#AD_Client_ID")); - writer.append("@Ref=AD_Client[Name='" + client.getName() + "'].AD_Client_ID|"); - writer.append("\n"); - writer.append("|AD_Org_ID|"); - String orgName = DB.getSQLValueString(null,"SELECT Name FROM AD_Org WHERE AD_Org_ID=?", AD_Org_ID); - writer.append("@Ref=AD_Org[Name='" + orgName + "'].AD_Org_ID|"); - writer.append("\n"); - writer.append("|AD_Role_ID|"); - writer.append("@Ref=AD_Role[Name='"+ Env.getContext(Env.getCtx(), "#AD_Role_Name")+ "'].AD_Role_ID|"); - writer.append("\n"); + writeFile("@Ref=AD_Client[Name='" + client.getName() + "'].AD_Client_ID|"); + writeFile("\n"); + writeFile("|AD_Org_ID|"); + String orgName = DB.getSQLValueString(null,"SELECT Name FROM AD_Org WHERE AD_Org_ID=?", org_ID); + writeFile("@Ref=AD_Org[Name='" + orgName + "'].AD_Org_ID|"); + writeFile("\n"); + writeFile("|AD_Role_ID|"); + writeFile("@Ref=AD_Role[Name='"+ Env.getContext(Env.getCtx(), "#AD_Role_Name")+ "'].AD_Role_ID|"); + writeFile("\n"); int warehouseid = Env.getContextAsInt(Env.getCtx(),Env.M_WAREHOUSE_ID); if (warehouseid > 0) { MWarehouse warehouse = MWarehouse.get(Env.getCtx(),warehouseid); - writer.append("|M_Warehouse_ID|"); - writer.append("@Ref=M_Warehouse[Name='" + warehouse.getName()+ "'].M_Warehouse_ID|"); - writer.append("\n"); + writeFile("|M_Warehouse_ID|"); + writeFile("@Ref=M_Warehouse[Name='" + warehouse.getName()+ "'].M_Warehouse_ID|"); + writeFile("\n"); } - writer.append("|*Login*|"); - writer.append("\n"); - files.put(Session_ID, writer); + writeFile("|*Login*|"); + writeFile("\n"); } catch (Exception e) { return e.getLocalizedMessage(); } @@ -550,27 +537,24 @@ public class FitRecorder implements ModelValidator { } public void writeFile(String msg){ - int Session_ID=Env.getContextAsInt(Env.getCtx(), "#AD_Session_ID"); - Writer writerOr=(Writer) files.get(Session_ID); - try{ - writerOr.append(msg); - writerOr.flush(); - - }catch (Exception e) { - - } + int session_ID=Env.getContextAsInt(Env.getCtx(), "#AD_Session_ID"); + Writer writer = (Writer) writersPerSession.get(session_ID); + if (writer != null) { + try{ + writer.append(msg); + writer.flush(); + } catch (Exception e) {} + } } - public String closefile(){ - String msg=null; + public void closefile(){ int Session_ID=Env.getContextAsInt(Env.getCtx(), "#AD_Session_ID"); - Writer writerOr=(Writer) files.get(Session_ID); - try { - writerOr.close(); - } catch (IOException e) { - // TODO Auto-generated catch block - return e.getLocalizedMessage(); - } - return msg; + Writer writer = (Writer) writersPerSession.get(Session_ID); + if (writer != null) { + try { + writer.close(); + writersPerSession.remove(Session_ID); + } catch (IOException e) {} + } } }