IDEMPIERE-460 Integrate and migrate 3e services. Fixed lookup. Refactoring and cleanup.

This commit is contained in:
Heng Sin Low 2013-02-19 21:25:15 +08:00
parent eac774fb67
commit e436719065
18 changed files with 1667 additions and 1280 deletions

View File

@ -13,5 +13,10 @@ import org.idempiere.adInterface.x10.CompositeResponsesDocument;
@SOAPBinding(style=Style.RPC,use=Use.LITERAL,parameterStyle=ParameterStyle.WRAPPED) @SOAPBinding(style=Style.RPC,use=Use.LITERAL,parameterStyle=ParameterStyle.WRAPPED)
public interface CompositeService { public interface CompositeService {
/**
*
* @param reqs
* @return CompositeResponsesDocument
*/
public CompositeResponsesDocument compositeOperation(CompositeRequestDocument reqs); public CompositeResponsesDocument compositeOperation(CompositeRequestDocument reqs);
} }

View File

@ -14,7 +14,7 @@
package com.trekglobal.ws; package com.trekglobal.ws;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Properties; import java.util.logging.Level;
import javax.jws.WebService; import javax.jws.WebService;
@ -26,8 +26,6 @@ import org.idempiere.adInterface.x10.CompositeRequestDocument;
import org.idempiere.adInterface.x10.CompositeResponse; import org.idempiere.adInterface.x10.CompositeResponse;
import org.idempiere.adInterface.x10.CompositeResponses; import org.idempiere.adInterface.x10.CompositeResponses;
import org.idempiere.adInterface.x10.CompositeResponsesDocument; import org.idempiere.adInterface.x10.CompositeResponsesDocument;
import org.idempiere.adInterface.x10.DataField;
import org.idempiere.adInterface.x10.ModelCRUD;
import org.idempiere.adInterface.x10.ModelCRUDRequest; import org.idempiere.adInterface.x10.ModelCRUDRequest;
import org.idempiere.adInterface.x10.ModelCRUDRequestDocument; import org.idempiere.adInterface.x10.ModelCRUDRequestDocument;
import org.idempiere.adInterface.x10.ModelRunProcessRequest; import org.idempiere.adInterface.x10.ModelRunProcessRequest;
@ -41,7 +39,6 @@ import org.idempiere.adInterface.x10.RunProcessResponseDocument;
import org.idempiere.adInterface.x10.StandardResponse; import org.idempiere.adInterface.x10.StandardResponse;
import org.idempiere.adInterface.x10.StandardResponseDocument; import org.idempiere.adInterface.x10.StandardResponseDocument;
import org.idempiere.adInterface.x10.WindowTabDataDocument; import org.idempiere.adInterface.x10.WindowTabDataDocument;
import org.idempiere.adinterface.CompiereService;
import org.idempiere.adinterface.ModelADServiceImpl; import org.idempiere.adinterface.ModelADServiceImpl;
import org.idempiere.webservices.AbstractService; import org.idempiere.webservices.AbstractService;
@ -59,60 +56,71 @@ public class CompositeServiceImpl extends AbstractService implements CompositeSe
private static String webServiceName = new String("CompositeInterface"); private static String webServiceName = new String("CompositeInterface");
public CompositeServiceImpl() { public CompositeServiceImpl() {
if (log.isLoggable(Level.INFO))
log.info("Creating session object BiziInterface"); log.info("Creating session object compositeInterface");
} }
/**
* @see CompositeService#compositeOperation(CompositeRequestDocument)
*/
@Override
public CompositeResponsesDocument compositeOperation(CompositeRequestDocument reqs) { public CompositeResponsesDocument compositeOperation(CompositeRequestDocument reqs) {
boolean connected = getCompiereService().isConnected();
CompiereService m_cs = getCompiereService();
try {
CompositeResponsesDocument ret = CompositeResponsesDocument.Factory.newInstance(); if (!connected)
CompositeResponses resps = ret.addNewCompositeResponses(); getCompiereService().connect();
CompositeRequest req = reqs.getCompositeRequest(); CompositeResponsesDocument ret = CompositeResponsesDocument.Factory.newInstance();
String serviceType = req.getServiceType(); CompositeResponses resps = ret.addNewCompositeResponses();
ADLoginRequest reqlogin = req.getADLoginRequest(); CompositeRequest req = reqs.getCompositeRequest();
String err = login(reqlogin, webServiceName, "composite", serviceType); String serviceType = req.getServiceType();
if (err != null && err.length() > 0) {
CompositeResponse resp = resps.addNewCompositeResponse(); ADLoginRequest reqlogin = req.getADLoginRequest();
StandardResponse stdResp = resp.addNewStandardResponse(); String err = login(reqlogin, webServiceName, "composite", serviceType);
stdResp.setError(err); if (err != null && err.length() > 0) {
stdResp.setIsError(true); CompositeResponse resp = resps.addNewCompositeResponse();
return ret; StandardResponse stdResp = resp.addNewStandardResponse();
} stdResp.setError(err);
stdResp.setIsError(true);
ModelADServiceImpl modelADService = new ModelADServiceImpl(ctx); return ret;
String trxName = m_cs.getM_trx_name();
trxName = Trx.createTrxName("ws_biziInterface");
Trx trx = Trx.get(trxName, true);
modelADService.setLocalTrxName(trxName);
Operations operationsArr[] = req.getOperationsArray();
for (Operations operations : operationsArr) {
Operation operationArr[] = operations.getOperationArray();
if (operationArr.length > 0) {
CompositeResponse compResp = resps.addNewCompositeResponse();
ArrayList<StandardResponse> respAggregator = new ArrayList<StandardResponse>();
boolean isSuccess = performOperations(trx, operationArr, modelADService, compResp, respAggregator, reqlogin);
// Committing after each operation set
if (isSuccess) {
commitTrx(trx, compResp, respAggregator, "Cannot commit at end of process", false);
}
} }
ModelADServiceImpl modelADService = new ModelADServiceImpl(ctx);
String trxName = Trx.createTrxName(webServiceName);
Trx trx = Trx.get(trxName, true);
try {
modelADService.setLocalTrxName(trxName);
Operations operationsArr[] = req.getOperationsArray();
for (Operations operations : operationsArr) {
Operation operationArr[] = operations.getOperationArray();
if (operationArr.length > 0) {
CompositeResponse compResp = resps.addNewCompositeResponse();
ArrayList<StandardResponse> respAggregator = new ArrayList<StandardResponse>();
boolean isSuccess = performOperations(trx, operationArr, modelADService, compResp, respAggregator, reqlogin);
// Committing after each operation set
if (isSuccess) {
commitTrx(trx, compResp, respAggregator, "Cannot commit at end of process", false);
}
}
}
} finally {
trx.close();
}
return ret;
} finally {
if (!connected)
getCompiereService().disconnect();
} }
trx.close();
return ret;
} }
/** /**
@ -260,6 +268,12 @@ public class CompositeServiceImpl extends AbstractService implements CompositeSe
return wrapperDoc; return wrapperDoc;
} }
/**
*
* @param ctx
* @param crud
*/
/*
public void resolveContextCRUD(Properties ctx, ModelCRUD crud) { public void resolveContextCRUD(Properties ctx, ModelCRUD crud) {
DataField fields[] = crud.getDataRow().getFieldArray(); DataField fields[] = crud.getDataRow().getFieldArray();
for (DataField field : fields) { for (DataField field : fields) {
@ -271,7 +285,7 @@ public class CompositeServiceImpl extends AbstractService implements CompositeSe
field.setVal(val); field.setVal(val);
} }
} }
} }*/
/** /**
* Rollback and set error on response * Rollback and set error on response

View File

@ -46,6 +46,6 @@ public class CompiereDataSourceFactory
if(ri.getReportViewID() > 0) if(ri.getReportViewID() > 0)
return new ReportViewDataSource(ctx, pi, params); return new ReportViewDataSource(ctx, pi, params);
return new DBDataSource(ctx, ri, params); return new DBDataSource(ctx, ri, params);
} }
} }

View File

@ -76,7 +76,7 @@ public class ReportViewDataSource extends compiereDataSource
public Object getFieldValue(JRField field) throws JRException public Object getFieldValue(JRField field) throws JRException
{ {
PrintDataElement pde = (PrintDataElement)m_printData.getNode(field.getName()); PrintDataElement pde = (PrintDataElement)m_printData.getNode(field.getName());
if(pde == null || pde.isNull()) if(pde == null || pde.isNull())
return null; return null;
if(pde.isDate()) if(pde.isDate())

View File

@ -1,44 +0,0 @@
/**
* reportServer for JasperReport.
* Copyright (C) 2004 Peter Shen.
* Shanghai, China.
* Email: zpshen@gmail.com
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Contributor: Marco LOMBARDO, Compilo subAdministrator.
* lombardo@mayking.com, mar9000@gmail.com
* Italy.
**/
package net.sf.compilo.data;
/**
* @author Peter Shen
* @version $Id: sqlProcessor.java,v 1.1 2005/07/15 10:29:40 pshen Exp $
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Generation - Code and Comments
*/
public class sqlProcessor
{
/**
*
*/
public sqlProcessor()
{
super();
// TODO Auto-generated constructor stub
}
}

View File

@ -40,7 +40,7 @@ public class FileFilter implements FilenameFilter
public FileFilter(String reportStart, File directory, String[] extension) public FileFilter(String reportStart, File directory, String[] extension)
{ {
this.reportStart = reportStart; this.reportStart = reportStart;
this.directory = directory; this.directory = directory;
this.extension = extension; this.extension = extension;
} }

View File

@ -150,10 +150,6 @@ public class ReportInfo
JasperReport res = null; JasperReport res = null;
try try
{ {
String compiere_home = (String)System.getProperty("COMPIERE_HOME");
// compiere_home = "C:/compiere/acompiere2/";
//log.info( "compiere_home = "+compiere_home);
System.setProperty("jasper.reports.compile.class.path", compiere_home+"/lib/reporttools.jar;"+compiere_home+"/lib/Compiere.jar");
JasperCompileManager.compileReportToFile( reportFile.getAbsolutePath(), jasperFile.getAbsolutePath()); JasperCompileManager.compileReportToFile( reportFile.getAbsolutePath(), jasperFile.getAbsolutePath());
jasperFile.setLastModified( reportFile.lastModified()); jasperFile.setLastModified( reportFile.lastModified());
res = (JasperReport)JRLoader.loadObjectFromFile(jasperFile.getAbsolutePath()); res = (JasperReport)JRLoader.loadObjectFromFile(jasperFile.getAbsolutePath());
@ -235,49 +231,6 @@ public class ReportInfo
} }
log.info("Get ReportDefinition-" + this.toString()); log.info("Get ReportDefinition-" + this.toString());
} }
/*
private void getResource()
{
// Resources
File[] resources =
reportInfo.getReportFile().getParentFile().listFiles(
new FileFilter( jasperName, reportInfo.getReportFile().getParentFile(), ".properties"));
File resFile = null;
// try baseName + "_" + language
for( int i=0; i<resources.length; i++)
{
if ( resources[i].getName().equals( jasperName+currLang.getLocale().getLanguage()+".properties"))
{
resFile=resources[i];
break;
}
}
if (resFile==null)
{
// try baseName only
for( int i=0; i<resources.length; i++)
{
if ( resources[i].getName().equals( jasperName+".properties"))
{
resFile=resources[i];
break;
}
}
}
if (resFile!=null)
{
try
{
PropertyResourceBundle res = new PropertyResourceBundle( new FileInputStream(resFile));
m_Param.put("RESOURCE", res);
}
catch (IOException e)
{}
}
}
*/
protected boolean isDirty() protected boolean isDirty()
{ {

View File

@ -62,7 +62,7 @@ public class ReportPool
} }
*/ */
ReportInfo reportinfo; ReportInfo reportinfo;
reportinfo = loadReport(AD_Process_ID); reportinfo = loadReport(AD_Process_ID);
return reportinfo; return reportinfo;
} }

View File

@ -41,6 +41,7 @@ import org.compiere.process.ProcessInfo;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.DB; import org.compiere.util.DB;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.compiere.util.Ini;
import org.compiere.util.Language; import org.compiere.util.Language;
/** /**
@ -52,17 +53,12 @@ import org.compiere.util.Language;
*/ */
public class ReportProcessor public class ReportProcessor
{ {
public static final String REPORT_PATH__fix = "c:/compiere/compiere-all/reports";
public static File REPORT_HOME = null; public static File REPORT_HOME = null;
private static CLogger log = CLogger.getCLogger(ReportProcessor.class); private static CLogger log = CLogger.getCLogger(ReportProcessor.class);
static static
{ {
String reportPath = REPORT_PATH__fix;// "c:/compiere/compiere-all/reports";//System.getProperty("REPORT_HOME"); String reportPath = Ini.getAdempiereHome();
if (reportPath == null || reportPath.length() == 0)
reportPath = System.getProperty("COMPIERE_HOME")+ System.getProperty("file.separator")+ "reports";
//System.setProperty("jasper.reports.compiler.class", "net.sf.jasperreports.engine.design.JRCompiler");
String classpath = Thread.currentThread().getContextClassLoader().getResource("net/sf/jasperreports/engine").toString(); String classpath = Thread.currentThread().getContextClassLoader().getResource("net/sf/jasperreports/engine").toString();
System.setProperty("jasper.reports.compile.temp", reportPath); System.setProperty("jasper.reports.compile.temp", reportPath);
System.setProperty("jasper.reports.compile.class.path", classpath.split("file:/")[1].split("!")[0]); System.setProperty("jasper.reports.compile.class.path", classpath.split("file:/")[1].split("!")[0]);
@ -101,25 +97,21 @@ public class ReportProcessor
addProcessParameters( m_AD_PInstance_ID, m_Param); addProcessParameters( m_AD_PInstance_ID, m_Param);
m_Param.put("RECORD_ID", new Integer( m_Record_ID)); m_Param.put("RECORD_ID", new Integer( m_Record_ID));
// Marco LOMBARDO: REPORT_HOME used to express subreports path. // Marco LOMBARDO: REPORT_HOME used to express subreports path.
m_Param.put("REPORT_HOME", REPORT_PATH__fix ); //System.getProperty("REPORT_HOME")); m_Param.put("REPORT_HOME", REPORT_HOME);
// End Marco LOMBARDO. // End Marco LOMBARDO.
Language currLang = Env.getLanguage(Env.getCtx()); Language currLang = Env.getLanguage(Env.getCtx());
m_Param.put("CURRENT_LANG", currLang.getAD_Language()); m_Param.put("CURRENT_LANG", currLang.getAD_Language());
java.sql.Connection conn = DB.getConnectionRO(); java.sql.Connection conn = DB.getConnectionRO();
m_Param.put("REPORT_CONNECTION", conn ); //DB_CONN m_Param.put("REPORT_CONNECTION", conn ); //DB_CONN
m_Param.put("DB_CONN", conn ); m_Param.put("DB_CONN", conn );
System.out.println( "REPORT_CONNECTION = "+conn.toString() );
log.saveError("REPORT_CONNECTION = "+conn.toString(), "");
//System.out.println( "REPORT_HOME = "+System.getProperty("REPORT_HOME") );
// fill report // fill report
compiereDataSource ds = null;
try try
{ {
compiereDataSource ds = CompiereDataSourceFactory.createDataSource(m_ctx, reportInfo, m_pi, m_Param); ds = CompiereDataSourceFactory.createDataSource(m_ctx, reportInfo, m_pi, m_Param);
//compiereDataSource ds = new compiereDataSource (m_ctx, reportInfo.getJasperReport());
m_jasperPrint = JasperFillManager.fillReport( reportInfo.getJasperReport(), m_Param, ds); m_jasperPrint = JasperFillManager.fillReport( reportInfo.getJasperReport(), m_Param, ds);
ds.close();
log.finest("ReportProcessor.fillReport"); log.finest("ReportProcessor.fillReport");
} }
@ -132,6 +124,11 @@ public class ReportProcessor
{ {
e.printStackTrace(); e.printStackTrace();
} }
finally
{
if (ds != null)
ds.close();
}
} }
else else
System.out.println("Error:" + reportInfo.getErrorMsg()); System.out.println("Error:" + reportInfo.getErrorMsg());

View File

@ -1,3 +1,14 @@
/******************************************************************************
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
*****************************************************************************/
package org.idempiere.adinterface; package org.idempiere.adinterface;
import org.compiere.model.Lookup; import org.compiere.model.Lookup;
@ -18,7 +29,13 @@ public class ADLookup {
protected static CLogger log = CLogger.getCLogger(ADLookup.class); protected static CLogger log = CLogger.getCLogger(ADLookup.class);
/**
* @param lvs
* @param lookup
* @param isMandatory
* @param isReadOnly
* @param isShortList
*/
public static void fillLookupValues( LookupValues lvs, Lookup lookup, boolean isMandatory, boolean isReadOnly, boolean isShortList) // IDEMPIERE 90 public static void fillLookupValues( LookupValues lvs, Lookup lookup, boolean isMandatory, boolean isReadOnly, boolean isShortList) // IDEMPIERE 90
{ {

View File

@ -1,3 +1,14 @@
/******************************************************************************
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
*****************************************************************************/
package org.idempiere.adinterface; package org.idempiere.adinterface;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
@ -18,6 +29,11 @@ import org.compiere.util.KeyNamePair;
import org.compiere.util.Language; import org.compiere.util.Language;
import org.compiere.util.Login; import org.compiere.util.Login;
/**
* @author deepak
* @author hengsin
*
*/
public class CompiereService { public class CompiereService {
private static CLogger log = CLogger.getCLogger(CompiereService.class); private static CLogger log = CLogger.getCLogger(CompiereService.class);
@ -25,17 +41,16 @@ public class CompiereService {
public final static String datePattern = "dd-MM-yyyy"; public final static String datePattern = "dd-MM-yyyy";
private Properties m_ctx; private Properties m_ctx;
private String m_trx_name;
private int m_AD_Client_ID; private int m_AD_Client_ID;
private int m_AD_Org_ID; private int m_AD_Org_ID;
private int m_AD_User_ID; private int m_AD_User_ID;
private int m_AD_Role_ID; private int m_AD_Role_ID;
private int m_AD_Warehouse_ID; private int m_M_Warehouse_ID;
private String m_Lang; private String m_locale;
private String m_User; private String m_userName;
private boolean LoggedIn = false; private boolean m_loggedin = false;
/** Localized Date format */ /** Localized Date format */
@ -66,83 +81,109 @@ public class CompiereService {
/** Localized Quantity format */ /** Localized Quantity format */
public DecimalFormat modelQuantityFormat = null; public DecimalFormat modelQuantityFormat = null;
private Language m_lang; private Language m_language;
public final String dateFormatOnlyForCtx = "yyyy-MM-dd"; public final String dateFormatOnlyForCtx = "yyyy-MM-dd";
private boolean m_connected;
public int getM_AD_Client_ID() { /**
*
* @return AD_Client_ID of current request
*/
public int getAD_Client_ID() {
return m_AD_Client_ID; return m_AD_Client_ID;
} }
public void setM_AD_Client_ID(int client_ID) { /**
m_AD_Client_ID = client_ID; *
} * @return AD_Org_ID of current request
*/
public int getM_AD_Org_ID() { public int getAD_Org_ID() {
return m_AD_Org_ID; return m_AD_Org_ID;
} }
public void setM_AD_Org_ID(int org_ID) { /**
m_AD_Org_ID = org_ID; *
} * @return context of current request
*/
public Properties getM_ctx() { public Properties getCtx() {
return m_ctx; return m_ctx;
} }
public void setM_ctx(Properties m_ctx) { /**
this.m_ctx = m_ctx; * default constructor
} */
public String getM_trx_name() {
return m_trx_name;
}
public void setM_trx_name(String m_trx_name) {
this.m_trx_name = m_trx_name;
}
public CompiereService() public CompiereService()
{ {
m_trx_name= null; //Trx.createTrxName(); m_loggedin = false;
m_ctx = new Properties(); m_connected = false;
LoggedIn = false;
} }
/**
* setup request
*/
public void connect() public void connect()
{ {
CompiereUtil.initWeb(); if (!m_connected)
{
ServerContext.setCurrentInstance(m_ctx); CompiereUtil.initWeb();
Env.setContext( m_ctx, "#AD_Language", "en_US" );
m_lang = Language.getLanguage("en_US"); m_ctx = new Properties();
m_connected = true;
// These variables are needed for ADClient.exe
Language m_lang2 = Language.getLanguage("pl_PL"); ServerContext.setCurrentInstance(m_ctx);
Env.setContext( m_ctx, "#AD_Language", "en_US" );
m_language = Language.getLanguage("en_US");
dateFormat = new SimpleDateFormat( datePattern );
dateTimeFormat = new SimpleDateFormat( datePattern ); // These variables are needed for ADClient.exe
Language m_lang2 = Language.getLanguage("pl_PL");
amountFormat = DisplayType.getNumberFormat(DisplayType.Amount, m_lang2);
integerFormat = DisplayType.getNumberFormat(DisplayType.Integer, m_lang2);
numberFormat = DisplayType.getNumberFormat(DisplayType.Number, m_lang2); dateFormat = new SimpleDateFormat( datePattern );
quantityFormat = DisplayType.getNumberFormat(DisplayType.Quantity, m_lang2); dateTimeFormat = new SimpleDateFormat( datePattern );
amountFormat = DisplayType.getNumberFormat(DisplayType.Amount, m_lang2);
integerFormat = DisplayType.getNumberFormat(DisplayType.Integer, m_lang2);
numberFormat = DisplayType.getNumberFormat(DisplayType.Number, m_lang2);
quantityFormat = DisplayType.getNumberFormat(DisplayType.Quantity, m_lang2);
}
} }
public Language getM_lang() { /**
return m_lang; * cleanup request
*/
public void disconnect()
{
if (m_connected)
{
ServerContext.dispose();
m_ctx = null;
m_loggedin = false;
m_connected = false;
}
}
/**
* @return true if started
*/
public boolean isConnected()
{
return m_connected;
} }
public void setM_lang(Language m_lang) { /**
this.m_lang = m_lang; * @return Language of current request
*/
public Language getLanguage() {
return m_language;
} }
/**
* @return true if already logged in
*/
public boolean isLoggedIn() { public boolean isLoggedIn() {
return LoggedIn; return m_loggedin;
} }
/** /**
@ -170,14 +211,16 @@ public class CompiereService {
+ " AND (o.AD_Client_ID = 0 OR o.AD_Client_ID=c.AD_Client_ID)" + " AND (o.AD_Client_ID = 0 OR o.AD_Client_ID=c.AD_Client_ID)"
+ " AND c.AD_Client_ID IN (SELECT AD_Client_ID FROM AD_Role_OrgAccess ca WHERE ca.AD_Role_ID=ur.AD_Role_ID)" + " AND c.AD_Client_ID IN (SELECT AD_Client_ID FROM AD_Role_OrgAccess ca WHERE ca.AD_Role_ID=ur.AD_Role_ID)"
+ " AND o.AD_Org_ID IN (SELECT AD_Org_ID FROM AD_Role_OrgAccess ca WHERE ca.AD_Role_ID=ur.AD_Role_ID)"; + " AND o.AD_Org_ID IN (SELECT AD_Org_ID FROM AD_Role_OrgAccess ca WHERE ca.AD_Role_ID=ur.AD_Role_ID)";
PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, AD_User_ID); pstmt.setInt(1, AD_User_ID);
pstmt.setInt(2, AD_Client_ID); pstmt.setInt(2, AD_Client_ID);
pstmt.setInt(3, AD_Org_ID); pstmt.setInt(3, AD_Org_ID);
pstmt.setInt(4, AD_Role_ID); pstmt.setInt(4, AD_Role_ID);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
loginInfo = rs.getString(1); loginInfo = rs.getString(1);
rs.close(); rs.close();
@ -185,7 +228,9 @@ public class CompiereService {
} }
catch (SQLException e) catch (SQLException e)
{ {
// log.log(Level.SEVERE, "checkLogin", e); e.printStackTrace();
} finally {
DB.close(rs, pstmt);
} }
// not verified // not verified
@ -202,16 +247,23 @@ public class CompiereService {
String printer = null; String printer = null;
Login login = new Login(ctx); Login login = new Login(ctx);
login.loadPreferences(org, wh, date, printer); login.loadPreferences(org, wh, date, printer);
// Don't Show Acct/Trl Tabs on HTML UI
Env.setContext(ctx, "#ShowAcct", "N");
Env.setContext(ctx, "#ShowTrl", "N");
// //
return loginInfo; return loginInfo;
} // checkLogin } // checkLogin
public boolean login( int AD_User_ID, int AD_Role_ID, int AD_Client_ID, int AD_Org_ID, int AD_Warehouse_ID, String Lang ) { /**
LoggedIn = false; *
String loginInfo = checkLogin (getM_ctx(), AD_User_ID, AD_Role_ID, AD_Client_ID, AD_Org_ID, AD_Warehouse_ID ); * @param AD_User_ID
* @param AD_Role_ID
* @param AD_Client_ID
* @param AD_Org_ID
* @param M_Warehouse_ID
* @param Lang
* @return true if login is successful
*/
public boolean login( int AD_User_ID, int AD_Role_ID, int AD_Client_ID, int AD_Org_ID, int M_Warehouse_ID, String Lang ) {
m_loggedin = false;
String loginInfo = checkLogin (getCtx(), AD_User_ID, AD_Role_ID, AD_Client_ID, AD_Org_ID, M_Warehouse_ID );
if (loginInfo == null) if (loginInfo == null)
return false; return false;
@ -219,75 +271,74 @@ public class CompiereService {
m_AD_Org_ID = AD_Org_ID; m_AD_Org_ID = AD_Org_ID;
m_AD_User_ID = AD_User_ID; m_AD_User_ID = AD_User_ID;
m_AD_Role_ID = AD_Role_ID; m_AD_Role_ID = AD_Role_ID;
m_AD_Warehouse_ID = AD_Warehouse_ID; m_M_Warehouse_ID = M_Warehouse_ID;
m_Lang = Lang; m_locale = Lang;
m_User = MUser.getNameOfUser(m_AD_User_ID); m_userName = MUser.getNameOfUser(m_AD_User_ID);
Env.setContext( m_ctx, "#AD_Language", Lang); Env.setContext( m_ctx, "#AD_Language", Lang);
m_lang = Language.getLanguage(Lang); m_language = Language.getLanguage(Lang);
Env.verifyLanguage( getM_ctx(), m_lang ); Env.verifyLanguage( getCtx(), m_language );
modelDateFormat = new SimpleDateFormat( datePattern ); modelDateFormat = new SimpleDateFormat( datePattern );
modelDateTimeFormat = new SimpleDateFormat( datePattern ); modelDateTimeFormat = new SimpleDateFormat( datePattern );
modelAmountFormat = DisplayType.getNumberFormat(DisplayType.Amount, m_lang); modelAmountFormat = DisplayType.getNumberFormat(DisplayType.Amount, m_language);
modelIntegerFormat = DisplayType.getNumberFormat(DisplayType.Integer, m_lang); modelIntegerFormat = DisplayType.getNumberFormat(DisplayType.Integer, m_language);
modelNumberFormat = DisplayType.getNumberFormat(DisplayType.Number, m_lang); modelNumberFormat = DisplayType.getNumberFormat(DisplayType.Number, m_language);
modelQuantityFormat = DisplayType.getNumberFormat(DisplayType.Quantity, m_lang); modelQuantityFormat = DisplayType.getNumberFormat(DisplayType.Quantity, m_language);
// Set Date // Set Date
Timestamp ts = new Timestamp(System.currentTimeMillis()); Timestamp ts = new Timestamp(System.currentTimeMillis());
SimpleDateFormat dateFormat4Timestamp = new SimpleDateFormat( dateFormatOnlyForCtx ); SimpleDateFormat dateFormat4Timestamp = new SimpleDateFormat( dateFormatOnlyForCtx );
Env.setContext( getM_ctx(), "#Date", dateFormat4Timestamp.format(ts)+" 00:00:00" ); // JDBC format Env.setContext( getCtx(), "#Date", dateFormat4Timestamp.format(ts)+" 00:00:00" ); // JDBC format
log.info(" #Date = "+ Env.getContextAsDate( getM_ctx(), "#Date")); log.info(" #Date = "+ Env.getContextAsDate( getCtx(), "#Date"));
Env.setContext( getM_ctx(), "#M_Warehouse_ID", AD_Warehouse_ID ); Env.setContext( getCtx(), "#M_Warehouse_ID", M_Warehouse_ID );
Env.setContext(m_ctx, Env.LANGUAGE, m_lang.getAD_Language()); Env.setContext(m_ctx, Env.LANGUAGE, m_language.getAD_Language());
//Env.setContext( getM_ctx(), "#AD_Language", Lang );
LoggedIn = true; m_loggedin = true;
return true; return true;
} }
public void setM_AD_User_ID(int m_AD_User_ID) { /**
this.m_AD_User_ID = m_AD_User_ID; *
} * @return AD_User_ID of current request
*/
public int getM_AD_User_ID() { public int getAD_User_ID() {
return m_AD_User_ID; return m_AD_User_ID;
} }
public void setM_AD_Role_ID(int m_AD_Role_ID) { /**
this.m_AD_Role_ID = m_AD_Role_ID; *
} * @return AD_Role_ID of current request
*/
public int getM_AD_Role_ID() { public int getAD_Role_ID() {
return m_AD_Role_ID; return m_AD_Role_ID;
} }
public void setM_Lang(String m_Lang) { /**
this.m_Lang = m_Lang; *
* @return locale code of current request
*/
public String getLocale() {
return m_locale;
} }
public String getM_Lang() { /**
return m_Lang; *
* @return M_Warehouse_ID of current request
*/
public int getM_Warehouse_ID() {
return m_M_Warehouse_ID;
} }
public void setM_AD_Warehouse_ID(int m_AD_Warehouse_ID) { /**
this.m_AD_Warehouse_ID = m_AD_Warehouse_ID; *
} * @return logged in user name of current request
*/
public int getM_AD_Warehouse_ID() { public String getUserName() {
return m_AD_Warehouse_ID; return m_userName;
}
public void setUser(String m_User) {
this.m_User = m_User;
}
public String getUser() {
return m_User;
} }
} }

View File

@ -1,12 +1,20 @@
/******************************************************************************
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
*****************************************************************************/
package org.idempiere.adinterface; package org.idempiere.adinterface;
import java.util.Properties;
import java.util.logging.Level; import java.util.logging.Level;
import org.compiere.Adempiere; import org.compiere.Adempiere;
import org.compiere.model.MClient;
import org.compiere.model.MSystem;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
@ -15,7 +23,9 @@ public class CompiereUtil {
private static CLogger log = CLogger.getCLogger(CompiereUtil.class); private static CLogger log = CLogger.getCLogger(CompiereUtil.class);
private static boolean s_initOK = false; private static boolean s_initOK = false;
/**
* @return startup idempiere environment if needed
*/
public static boolean initWeb() public static boolean initWeb()
{ {
if (s_initOK) if (s_initOK)
@ -23,16 +33,8 @@ public class CompiereUtil {
return true; return true;
} }
// TODO:
// Load Environment Variables (serverApps/src/web/WEB-INF/web.xml)
try try
{ {
//CLogMgt.setLevel(Level.OFF);
/* ADEMPIERE/COMPIERE */
//s_initOK = Compiere.startup(false);
s_initOK = Adempiere.startup(false); s_initOK = Adempiere.startup(false);
} }
catch (Exception ex) catch (Exception ex)
@ -42,16 +44,6 @@ public class CompiereUtil {
if (!s_initOK) if (!s_initOK)
return false; return false;
// Logging now initiated
//
Properties ctx = new Properties();
@SuppressWarnings("unused")
MClient client = MClient.get(ctx, 0);
@SuppressWarnings("unused")
MSystem system = MSystem.get(ctx);
return s_initOK; return s_initOK;
} }
} }

View File

@ -66,10 +66,10 @@ public class Process {
MProcess process = null; MProcess process = null;
if (AD_Menu_ID>0 && AD_Process_ID==0 ) if (AD_Menu_ID>0 && AD_Process_ID==0 )
process = MProcess.getFromMenu( cs.getM_ctx(), AD_Menu_ID); process = MProcess.getFromMenu( cs.getCtx(), AD_Menu_ID);
else else
if (AD_Menu_ID==0 && AD_Process_ID>0 ) if (AD_Menu_ID==0 && AD_Process_ID>0 )
process = new MProcess( cs.getM_ctx(), AD_Process_ID, null); process = new MProcess( cs.getCtx(), AD_Process_ID, null);
if (process != null) if (process != null)
{ {
@ -101,7 +101,7 @@ public class Process {
if (para.getDefaultValue().indexOf( "@#Date@")>=0) { if (para.getDefaultValue().indexOf( "@#Date@")>=0) {
//Object t = Env.getContextAsDate( cs.getM_ctx(), "#Date" ); //Object t = Env.getContextAsDate( cs.getM_ctx(), "#Date" );
//String t = Env.getContext( cs.getM_ctx(), "#Date" ); //String t = Env.getContext( cs.getM_ctx(), "#Date" );
String t= cs.dateFormat.format( Env.getContextAsDate( cs.getM_ctx(), "#Date") ); String t= cs.dateFormat.format( Env.getContextAsDate( cs.getCtx(), "#Date") );
p.setDefaultValue( t ); //cs.dateFormat.format( t )); p.setDefaultValue( t ); //cs.dateFormat.format( t ));
} }
@ -125,7 +125,7 @@ public class Process {
if (para.getDefaultValue2().indexOf( "@#Date@")>=0) { if (para.getDefaultValue2().indexOf( "@#Date@")>=0) {
//Object t = Env.getContextAsDate( cs.getM_ctx(), "#Date" ); //Object t = Env.getContextAsDate( cs.getM_ctx(), "#Date" );
//String t = Env.getContext( cs.getM_ctx(), "#Date" ); //String t = Env.getContext( cs.getM_ctx(), "#Date" );
String t= cs.dateFormat.format( Env.getContextAsDate( cs.getM_ctx(), "#Date") ); String t= cs.dateFormat.format( Env.getContextAsDate( cs.getCtx(), "#Date") );
p.setDefaultValue2( t ); //cs.dateFormat.format( t ) ); p.setDefaultValue2( t ); //cs.dateFormat.format( t ) );
} }
} }
@ -165,7 +165,7 @@ public class Process {
int m_record_id = rp.getADRecordID(); int m_record_id = rp.getADRecordID();
//WebSessionCtx wsc = WebSessionCtx.get (request); //WebSessionCtx wsc = WebSessionCtx.get (request);
MProcess process = MProcess.get (m_cs.getM_ctx() , AD_Process_ID); MProcess process = MProcess.get (m_cs.getCtx() , AD_Process_ID);
// need to check if Role can access // need to check if Role can access
if (process == null) if (process == null)
{ {
@ -183,13 +183,13 @@ public class Process {
// Requirements // Requirements
// - the process must be a workflow document // - the process must be a workflow document
if (process.getAD_Workflow_ID() > 0) { if (process.getAD_Workflow_ID() > 0) {
MWorkflow wf = MWorkflow.get(m_cs.getM_ctx(), process.getAD_Workflow_ID()); MWorkflow wf = MWorkflow.get(m_cs.getCtx(), process.getAD_Workflow_ID());
if (wf.getWorkflowType().equals(MWorkflow.WORKFLOWTYPE_DocumentProcess)) { if (wf.getWorkflowType().equals(MWorkflow.WORKFLOWTYPE_DocumentProcess)) {
// - get the table associated with the workflow document // - get the table associated with the workflow document
// - set DocAction in such table // - set DocAction in such table
// get the PO for the tablename and record ID // get the PO for the tablename and record ID
MTable table = MTable.get(m_cs.getM_ctx(), wf.getAD_Table_ID()); MTable table = MTable.get(m_cs.getCtx(), wf.getAD_Table_ID());
if (table != null) { if (table != null) {
PO po = table.getPO(m_record_id, null); PO po = table.getPO(m_record_id, null);
if (po != null) { if (po != null) {
@ -222,8 +222,8 @@ public class Process {
} }
// //
ProcessInfo pi = new ProcessInfo (process.getName(), process.getAD_Process_ID()); ProcessInfo pi = new ProcessInfo (process.getName(), process.getAD_Process_ID());
pi.setAD_User_ID(Env.getAD_User_ID(m_cs.getM_ctx())); pi.setAD_User_ID(Env.getAD_User_ID(m_cs.getCtx()));
pi.setAD_Client_ID(Env.getAD_Client_ID(m_cs.getM_ctx())); pi.setAD_Client_ID(Env.getAD_Client_ID(m_cs.getCtx()));
pi.setAD_PInstance_ID(pInstance.getAD_PInstance_ID()); pi.setAD_PInstance_ID(pInstance.getAD_PInstance_ID());
if (m_record_id >0) if (m_record_id >0)
pi.setRecord_ID( m_record_id ); pi.setRecord_ID( m_record_id );
@ -332,7 +332,7 @@ public class Process {
if (pf.isTableBased()) if (pf.isTableBased())
{ {
CharArrayWriter wr = new CharArrayWriter(); CharArrayWriter wr = new CharArrayWriter();
ok = ReportEngineEx.createEXCEL_HTML_wr( re, m_cs.getM_ctx(), wr, false, re.getPrintFormat().getLanguage() ); ok = ReportEngineEx.createEXCEL_HTML_wr( re, m_cs.getCtx(), wr, false, re.getPrintFormat().getLanguage() );
file_type ="xls"; file_type ="xls";
String data = wr.toString(); String data = wr.toString();
if (data!=null) if (data!=null)
@ -351,7 +351,7 @@ public class Process {
} }
else else
{ {
JasperPrint jp = getJasperReportPrint( m_cs.getM_ctx(), pi); JasperPrint jp = getJasperReportPrint( m_cs.getCtx(), pi);
//file = File.createTempFile("WProcess", ".pdf"); //file = File.createTempFile("WProcess", ".pdf");
ByteArrayOutputStream wr = new ByteArrayOutputStream(); ByteArrayOutputStream wr = new ByteArrayOutputStream();
net.sf.jasperreports.engine.JasperExportManager.exportReportToPdfStream(jp, wr); net.sf.jasperreports.engine.JasperExportManager.exportReportToPdfStream(jp, wr);
@ -368,7 +368,7 @@ public class Process {
//file.getAbsolutePath() //file.getAbsolutePath()
// Marker that Process is OK // Marker that Process is OK
m_cs.getM_ctx().put("AD_PInstance_ID=" + pInstance.getAD_PInstance_ID(), "ok"); m_cs.getCtx().put("AD_PInstance_ID=" + pInstance.getAD_PInstance_ID(), "ok");
} }
else else
{ {

View File

@ -25,7 +25,6 @@ import java.util.Properties;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.xml.namespace.QName; import javax.xml.namespace.QName;
import javax.xml.ws.WebServiceContext; import javax.xml.ws.WebServiceContext;
import javax.xml.ws.handler.MessageContext; import javax.xml.ws.handler.MessageContext;
@ -64,6 +63,7 @@ import org.idempiere.adinterface.CompiereService;
*/ */
public class AbstractService { public class AbstractService {
private static final String COMPIERE_SERVICE = "CompiereService";
@Resource @Resource
protected WebServiceContext ctx; protected WebServiceContext ctx;
@ -79,16 +79,16 @@ public class AbstractService {
CompiereService m_cs = getCompiereService(); CompiereService m_cs = getCompiereService();
if (m_cs.isLoggedIn() && m_cs.getM_AD_Client_ID() == loginRequest.getClientID() && loginRequest.getClientID() == Env.getAD_Client_ID(Env.getCtx()) if (m_cs.isLoggedIn() && m_cs.getAD_Client_ID() == loginRequest.getClientID() && loginRequest.getClientID() == Env.getAD_Client_ID(Env.getCtx())
&& m_cs.getM_AD_Org_ID() == loginRequest.getOrgID() && m_cs.getM_AD_Role_ID() == loginRequest.getRoleID() && m_cs.getAD_Org_ID() == loginRequest.getOrgID() && m_cs.getAD_Role_ID() == loginRequest.getRoleID()
&& m_cs.getM_AD_Warehouse_ID() == loginRequest.getWarehouseID() && loginRequest.getUser().equals(m_cs.getUser())) && m_cs.getM_Warehouse_ID() == loginRequest.getWarehouseID() && loginRequest.getUser().equals(m_cs.getUserName()))
return authenticate(webService, method, serviceType, m_cs); // already logged with same data return authenticate(webService, method, serviceType, m_cs); // already logged with same data
String ret =invokeLoginValidator(loginRequest, m_cs.getM_ctx(), null, IWSValidator.TIMING_BEFORE_LOGIN); String ret =invokeLoginValidator(loginRequest, m_cs.getCtx(), null, IWSValidator.TIMING_BEFORE_LOGIN);
if(ret!=null && ret.length()>0) if(ret!=null && ret.length()>0)
return ret; return ret;
Login login = new Login(m_cs.getM_ctx()); Login login = new Login(m_cs.getCtx());
KeyNamePair[] roles = login.getRoles(loginRequest.getUser(), loginRequest.getPass()); KeyNamePair[] roles = login.getRoles(loginRequest.getUser(), loginRequest.getPass());
if (roles != null) { if (roles != null) {
boolean okrole = false; boolean okrole = false;
@ -112,7 +112,7 @@ public class AbstractService {
if (!okclient) if (!okclient)
return "Error logging in - client not allowed for this role"; return "Error logging in - client not allowed for this role";
m_cs.getM_ctx().setProperty("#AD_Client_ID", "" + loginRequest.getClientID()); m_cs.getCtx().setProperty("#AD_Client_ID", "" + loginRequest.getClientID());
KeyNamePair[] orgs = login.getOrgs(new KeyNamePair(loginRequest.getRoleID(), "")); KeyNamePair[] orgs = login.getOrgs(new KeyNamePair(loginRequest.getRoleID(), ""));
@ -146,7 +146,7 @@ public class AbstractService {
if (error != null && error.length() > 0) if (error != null && error.length() > 0)
return error; return error;
int AD_User_ID = Env.getAD_User_ID(m_cs.getM_ctx()); int AD_User_ID = Env.getAD_User_ID(m_cs.getCtx());
if (!m_cs.login(AD_User_ID, loginRequest.getRoleID(), loginRequest.getClientID(), loginRequest.getOrgID(), loginRequest.getWarehouseID(), loginRequest.getLang())) if (!m_cs.login(AD_User_ID, loginRequest.getRoleID(), loginRequest.getClientID(), loginRequest.getOrgID(), loginRequest.getWarehouseID(), loginRequest.getLang()))
@ -158,7 +158,7 @@ public class AbstractService {
return "Error logging in - no roles or user/pwd invalid for user " + loginRequest.getUser(); return "Error logging in - no roles or user/pwd invalid for user " + loginRequest.getUser();
} }
ret =invokeLoginValidator(loginRequest, m_cs.getM_ctx(), null, IWSValidator.TIMING_AFTER_LOGIN); ret =invokeLoginValidator(loginRequest, m_cs.getCtx(), null, IWSValidator.TIMING_AFTER_LOGIN);
if(ret!=null && ret.length()>0) if(ret!=null && ret.length()>0)
return ret; return ret;
@ -177,7 +177,7 @@ public class AbstractService {
HttpServletRequest req = (HttpServletRequest) ctx.getMessageContext().get(MessageContext.SERVLET_REQUEST); HttpServletRequest req = (HttpServletRequest) ctx.getMessageContext().get(MessageContext.SERVLET_REQUEST);
MWebService m_webservice = MWebService.get(m_cs.getM_ctx(), webServiceValue); MWebService m_webservice = MWebService.get(m_cs.getCtx(), webServiceValue);
if (m_webservice == null || !m_webservice.isActive()) if (m_webservice == null || !m_webservice.isActive())
return "Web Service " + webServiceValue + " not registered"; return "Web Service " + webServiceValue + " not registered";
@ -192,13 +192,13 @@ public class AbstractService {
ResultSet rs = null; ResultSet rs = null;
try { try {
pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, m_cs.getM_AD_Client_ID()); pstmt.setInt(1, m_cs.getAD_Client_ID());
pstmt.setInt(2, m_webservice.getWS_WebService_ID()); pstmt.setInt(2, m_webservice.getWS_WebService_ID());
pstmt.setInt(3, m_webservicemethod.getWS_WebServiceMethod_ID()); pstmt.setInt(3, m_webservicemethod.getWS_WebServiceMethod_ID());
pstmt.setString(4, serviceTypeValue); pstmt.setString(4, serviceTypeValue);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
m_webservicetype = new MWebServiceType(m_cs.getM_ctx(), rs, null); m_webservicetype = new MWebServiceType(m_cs.getCtx(), rs, null);
} catch (Exception e) { } catch (Exception e) {
throw new IdempiereServiceFault(e.getClass().toString() + " " + e.getMessage() + " sql=" + sql, e.getCause(), new QName( throw new IdempiereServiceFault(e.getClass().toString() + " " + e.getMessage() + " sql=" + sql, e.getCause(), new QName(
"authenticate")); "authenticate"));
@ -213,7 +213,7 @@ public class AbstractService {
req.setAttribute("MWebServiceType", m_webservicetype); req.setAttribute("MWebServiceType", m_webservicetype);
String ret=invokeLoginValidator(null, m_cs.getM_ctx(), m_webservicetype, IWSValidator.TIMING_ON_AUTHORIZATION); String ret=invokeLoginValidator(null, m_cs.getCtx(), m_webservicetype, IWSValidator.TIMING_ON_AUTHORIZATION);
if(ret!=null && ret.length()>0) if(ret!=null && ret.length()>0)
return ret; return ret;
@ -240,16 +240,14 @@ public class AbstractService {
/** /**
* *
* @return Compiere Service object for current session * @return Compiere Service object for current request
*/ */
protected CompiereService getCompiereService() { protected CompiereService getCompiereService() {
HttpServletRequest req = (HttpServletRequest) ctx.getMessageContext().get(MessageContext.SERVLET_REQUEST); HttpServletRequest req = (HttpServletRequest) ctx.getMessageContext().get(MessageContext.SERVLET_REQUEST);
HttpSession session = req.getSession(); CompiereService m_cs = (CompiereService) req.getAttribute(COMPIERE_SERVICE);
CompiereService m_cs = (CompiereService) session.getAttribute("CompiereServiceBean");
if (m_cs == null) { if (m_cs == null) {
m_cs = new CompiereService(); m_cs = new CompiereService();
m_cs.connect(); req.setAttribute(COMPIERE_SERVICE, m_cs);
session.setAttribute("CompiereServiceBean", m_cs);
} }
return m_cs; return m_cs;
} }
@ -394,10 +392,10 @@ public class AbstractService {
if (indDot == -1) { if (indDot == -1) {
if (varName.charAt(0) == '#') { if (varName.charAt(0) == '#') {
varName = varName.substring(1); varName = varName.substring(1);
val = getCompiereService().getM_ctx().getProperty(varName); val = getCompiereService().getCtx().getProperty(varName);
} else { } else {
// If there is no table name, then it should be // If there is no table name, then it should be
// premitive data type // primitive data type
if (po != null && poInfo.getColumnIndex(varName)!=-1) if (po != null && poInfo.getColumnIndex(varName)!=-1)
val = po.get_Value(varName); val = po.get_Value(varName);

View File

@ -1,3 +1,16 @@
/******************************************************************************
* Copyright (C) 2012 Trek Global *
* Product: iDempiere ERP & CRM Smart Business Solution *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
*****************************************************************************/
package org.idempiere.webservices; package org.idempiere.webservices;
import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleActivator;

View File

@ -1,3 +1,16 @@
/******************************************************************************
* Copyright (C) 2012 Trek Global *
* Product: iDempiere ERP & CRM Smart Business Solution *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
*****************************************************************************/
package org.idempiere.webservices; package org.idempiere.webservices;
import java.util.Map; import java.util.Map;
@ -10,6 +23,11 @@ import org.idempiere.webservices.fault.IdempiereServiceFault;
import org.idempiere.adInterface.x10.ADLoginRequest; import org.idempiere.adInterface.x10.ADLoginRequest;
import org.idempiere.adInterface.x10.DataField; import org.idempiere.adInterface.x10.DataField;
/**
*
* @author deepak
*
*/
public interface IWSValidator { public interface IWSValidator {
public static final int TIMING_BEFORE_PARSE=1; public static final int TIMING_BEFORE_PARSE=1;
public static final int TIMING_AFTER_PARSE=2; public static final int TIMING_AFTER_PARSE=2;
@ -23,6 +41,25 @@ public interface IWSValidator {
public static final int TIMING_BEFORE_PROCESS=8; public static final int TIMING_BEFORE_PROCESS=8;
public static final int TIMING_AFTER_PROCESS=9; public static final int TIMING_AFTER_PROCESS=9;
/**
*
* @param po
* @param m_webserviceType
* @param fields
* @param time
* @param trxName
* @param requestCtx
* @throws IdempiereServiceFault
*/
public void validate(PO po,MWebServiceType m_webserviceType,DataField[] fields,int time,String trxName,Map<String, Object> requestCtx) throws IdempiereServiceFault; public void validate(PO po,MWebServiceType m_webserviceType,DataField[] fields,int time,String trxName,Map<String, Object> requestCtx) throws IdempiereServiceFault;
/**
*
* @param loginRequest
* @param ctx
* @param m_webserviceType
* @param time
* @throws IdempiereServiceFault
*/
public void login(ADLoginRequest loginRequest,Properties ctx,MWebServiceType m_webserviceType,int time) throws IdempiereServiceFault; public void login(ADLoginRequest loginRequest,Properties ctx,MWebServiceType m_webserviceType,int time) throws IdempiereServiceFault;
} }

View File

@ -1,3 +1,16 @@
/******************************************************************************
* Copyright (C) 2012 Trek Global *
* Product: iDempiere ERP & CRM Smart Business Solution *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
*****************************************************************************/
package org.idempiere.webservices.fault; package org.idempiere.webservices.fault;
import javax.xml.namespace.QName; import javax.xml.namespace.QName;