remove application server dependency

This commit is contained in:
Heng Sin Low 2010-07-08 05:30:45 +08:00
parent 389d0c94a2
commit e4d11cfc8f
8 changed files with 158 additions and 547 deletions

View File

@ -24,7 +24,6 @@ Bundle-ClassPath: base.jar,
lib/commons-collections-3.1.jar, lib/commons-collections-3.1.jar,
lib/activemq-core-5.0.0.jar lib/activemq-core-5.0.0.jar
Export-Package: org.adempiere.apps.graph, Export-Package: org.adempiere.apps.graph,
org.adempiere.as,
org.adempiere.base, org.adempiere.base,
org.adempiere.exceptions, org.adempiere.exceptions,
org.adempiere.impexp, org.adempiere.impexp,

View File

@ -1,9 +1,8 @@
source.base.jar = src/,build/ source.base.jar = src/
bin.includes = META-INF/,\ bin.includes = META-INF/,\
base.jar,\ base.jar,\
plugin.xml plugin.xml
jars.extra.classpath = platform:/plugin/org.adempiere.tools/lib/activation.jar,\ jars.extra.classpath = platform:/plugin/org.adempiere.tools/lib/activemq-core-5.0.0.jar,\
platform:/plugin/org.adempiere.tools/lib/activemq-core-5.0.0.jar,\
platform:/plugin/org.adempiere.tools/lib/ant-commons-net.jar,\ platform:/plugin/org.adempiere.tools/lib/ant-commons-net.jar,\
platform:/plugin/org.adempiere.tools/lib/ant-contrib-1.0b1.jar,\ platform:/plugin/org.adempiere.tools/lib/ant-contrib-1.0b1.jar,\
platform:/plugin/org.adempiere.tools/lib/ant-launcher.jar,\ platform:/plugin/org.adempiere.tools/lib/ant-launcher.jar,\
@ -22,8 +21,8 @@ jars.extra.classpath = platform:/plugin/org.adempiere.tools/lib/activation.jar,\
platform:/plugin/org.adempiere.tools/lib/groovy-engine.jar,\ platform:/plugin/org.adempiere.tools/lib/groovy-engine.jar,\
platform:/plugin/org.adempiere.tools/lib/iText-2.1.7.jar,\ platform:/plugin/org.adempiere.tools/lib/iText-2.1.7.jar,\
platform:/plugin/org.adempiere.tools/lib/javaee.jar,\ platform:/plugin/org.adempiere.tools/lib/javaee.jar,\
platform:/plugin/org.adempiere.tools/lib/jcommon-1.0.14.jar,\ platform:/plugin/org.adempiere.tools/lib/jcommon-1.0.16.jar,\
platform:/plugin/org.adempiere.tools/lib/jfreechart-1.0.11.jar,\ platform:/plugin/org.adempiere.tools/lib/jfreechart-1.0.13.jar,\
platform:/plugin/org.adempiere.tools/lib/jgraph.jar,\ platform:/plugin/org.adempiere.tools/lib/jgraph.jar,\
platform:/plugin/org.adempiere.tools/lib/jnlp.jar,\ platform:/plugin/org.adempiere.tools/lib/jnlp.jar,\
platform:/plugin/org.adempiere.tools/lib/jpayment.jar,\ platform:/plugin/org.adempiere.tools/lib/jpayment.jar,\
@ -38,17 +37,15 @@ jars.extra.classpath = platform:/plugin/org.adempiere.tools/lib/activation.jar,\
platform:/plugin/org.adempiere.tools/lib/looks-2.0.4.jar,\ platform:/plugin/org.adempiere.tools/lib/looks-2.0.4.jar,\
platform:/plugin/org.adempiere.tools/lib/mail.jar,\ platform:/plugin/org.adempiere.tools/lib/mail.jar,\
platform:/plugin/org.adempiere.tools/lib/miglayout-3.7.1-swing.jar,\ platform:/plugin/org.adempiere.tools/lib/miglayout-3.7.1-swing.jar,\
platform:/plugin/org.adempiere.tools/lib/ocrs12.jar,\ platform:/plugin/org.adempiere.tools/lib/ojdbc6.jar,\
platform:/plugin/org.adempiere.tools/lib/ojdbc14.jar,\
platform:/plugin/org.adempiere.tools/lib/poi-3.0.1-FINAL-20070705.jar,\ platform:/plugin/org.adempiere.tools/lib/poi-3.0.1-FINAL-20070705.jar,\
platform:/plugin/org.adempiere.tools/lib/postgresql.jar,\ platform:/plugin/org.adempiere.tools/lib/postgresql.jar,\
platform:/plugin/org.adempiere.tools/lib/script-api.jar,\ platform:/plugin/org.adempiere.tools/lib/script-api.jar,\
platform:/plugin/org.adempiere.tools/lib/servlet-api.jar,\ platform:/plugin/org.adempiere.tools/lib/servlet-api.jar,\
platform:/plugin/org.adempiere.tools/lib/standard.jar,\ platform:/plugin/org.adempiere.tools/lib/standard.jar,\
platform:/plugin/org.adempiere.tools/lib/swingx-0.9.0.jar,\ platform:/plugin/org.adempiere.tools/lib/swingx-1.6.jar,\
platform:/plugin/org.adempiere.tools/lib/Verisign.jar,\ platform:/plugin/org.adempiere.tools/lib/Verisign.jar,\
platform:/plugin/org.adempiere.tools/lib/wizard.jar,\ platform:/plugin/org.adempiere.tools/lib/wizard.jar,\
platform:/plugin/org.adempiere.tools/lib/xercesImpl.jar,\ platform:/plugin/org.adempiere.tools/lib/xercesImpl.jar,\
platform:/plugin/org.adempiere.tools/lib/xjavadoc-1.1.jar,\ platform:/plugin/org.adempiere.tools/lib/xjavadoc-1.1.jar,\
platform:/plugin/org.adempiere.tools/lib/xml-apis.jar platform:/plugin/org.adempiere.tools/lib/xml-apis.jar

View File

@ -1,59 +0,0 @@
/******************************************************************************
* Copyright (C) 2008 Low Heng Sin *
* 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.adempiere.as;
import java.util.Hashtable;
import org.adempiere.base.Service;
/**
*
* @author Low Heng Sin
*
*/
public class ASFactory {
public final static String JBOSS = "JBoss";
public final static String GLASS_FISH = "GlassFish";
public final static String[] AS_Names = new String[] {
JBOSS, GLASS_FISH
};
private static IApplicationServer applicationServer;
static {
applicationServer = Service.locate(IApplicationServer.class);
if (applicationServer == null) {
applicationServer = new IApplicationServer() {
public int getDefaultNamingServicePort() {
return 0;
}
public Hashtable<String, String> getInitialContextEnvironment(
String AppsHost, int AppsPort, String principal,
String credential) {
return new Hashtable<String, String>();
}
};
}
}
/**
* @return IApplicationServer
*/
public static IApplicationServer getApplicationServer() {
return applicationServer;
}
}

View File

@ -1,39 +0,0 @@
/******************************************************************************
* Copyright (C) 2008 Low Heng Sin *
* 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.adempiere.as;
import java.util.Hashtable;
import org.adempiere.base.IService;
/**
*
* @author Low Heng Sin
*
*/
public interface IApplicationServer extends IService {
/**
* @param AppsHost
* @param AppsPort
* @param principal
* @param credential
* @return Environment to construct initial context
*/
public Hashtable<String, String> getInitialContextEnvironment (String AppsHost, int AppsPort, String principal,
String credential);
/**
* @return default naming service port
*/
public int getDefaultNamingServicePort();
}

View File

@ -1,49 +0,0 @@
/******************************************************************************
* Copyright (C) 2009 Low Heng Sin *
* Copyright (C) 2009 Idalica Corporation *
* 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.adempiere.util;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import org.compiere.interfaces.Server;
/**
*
* @author hengsin
*
*/
public class EmbeddedServerProxy implements InvocationHandler {
private Server server = null;
public EmbeddedServerProxy() {
ClassLoader loader = null;
loader = Thread.currentThread().getContextClassLoader();
if (loader == null)
loader = this.getClass().getClassLoader();
try {
Class<?> clazz = loader.loadClass("org.compiere.session.ServerBean");
server = (Server) clazz.newInstance();
} catch (Exception e) {
throw new IllegalStateException("Failed to load org.compiere.session.ServerBean.", e);
}
}
public Object invoke(Object proxy, Method method, Object[] args)
throws Throwable {
Method m = Server.class.getMethod(method.getName(), method.getParameterTypes());
return m.invoke(server, args);
}
}

View File

@ -17,27 +17,19 @@
package org.compiere.db; package org.compiere.db;
import java.io.Serializable; import java.io.Serializable;
import java.lang.reflect.Proxy;
import java.rmi.RMISecurityManager;
import java.sql.Connection; import java.sql.Connection;
import java.sql.DatabaseMetaData; import java.sql.DatabaseMetaData;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.logging.Level; import java.util.logging.Level;
import javax.naming.CommunicationException;
import javax.naming.Context;
import javax.naming.InitialContext; import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource; import javax.sql.DataSource;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import org.adempiere.as.ASFactory;
import org.adempiere.util.EmbeddedServerProxy;
import org.compiere.Adempiere; import org.compiere.Adempiere;
import org.compiere.interfaces.Server; import org.compiere.interfaces.Server;
import org.compiere.interfaces.Status; import org.compiere.interfaces.Status;
import org.compiere.util.CLogMgt;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.compiere.util.Ini; import org.compiere.util.Ini;
@ -53,7 +45,7 @@ import org.compiere.util.ValueNamePair;
public class CConnection implements Serializable, Cloneable public class CConnection implements Serializable, Cloneable
{ {
/** /**
* *
*/ */
private static final long serialVersionUID = -7893119456331485444L; private static final long serialVersionUID = -7893119456331485444L;
/** Connection */ /** Connection */
@ -81,11 +73,6 @@ public class CConnection implements Serializable, Cloneable
@Deprecated @Deprecated
public static final String PROFILE_WAN = "W"; public static final String PROFILE_WAN = "W";
private final static String COMPONENT_NS = "java:comp/env";
/** Prefer component namespace when running at server **/
private boolean useComponentNamespace = !Ini.isClient();
/** System property flag to embed server bean in process **/ /** System property flag to embed server bean in process **/
public final static String SERVER_EMBEDDED = "org.adempiere.server.embedded"; public final static String SERVER_EMBEDDED = "org.adempiere.server.embedded";
@ -116,7 +103,6 @@ public class CConnection implements Serializable, Cloneable
{ {
cc = new CConnection(apps_host); cc = new CConnection(apps_host);
cc.setConnectionProfile(CConnection.PROFILE_LAN); cc.setConnectionProfile(CConnection.PROFILE_LAN);
cc.setAppsPort(ASFactory.getApplicationServer().getDefaultNamingServicePort());
if (cc.testAppsServer() == null) if (cc.testAppsServer() == null)
{ {
s_cc = cc; s_cc = cc;
@ -210,7 +196,7 @@ public class CConnection implements Serializable, Cloneable
/** Application Host */ /** Application Host */
private String m_apps_host = "MyAppsServer"; private String m_apps_host = "MyAppsServer";
/** Application Port */ /** Application Port */
private int m_apps_port = ASFactory.getApplicationServer().getDefaultNamingServicePort(); private int m_apps_port = 0;
/** Database Type */ /** Database Type */
private String m_type = ""; private String m_type = "";
@ -222,9 +208,6 @@ public class CConnection implements Serializable, Cloneable
/** Database name */ /** Database name */
private String m_db_name = "MyDBName"; private String m_db_name = "MyDBName";
/** Connection Profile */
private String m_connectionProfile = PROFILE_LAN;
/** In Memory connection */ /** In Memory connection */
private boolean m_bequeath = false; private boolean m_bequeath = false;
@ -264,9 +247,6 @@ public class CConnection implements Serializable, Cloneable
/** DB Info */ /** DB Info */
private String m_dbInfo = null; private String m_dbInfo = null;
/** Had application server been query **/
private boolean m_queryAppsServer = false;
private final static String SECURITY_PRINCIPAL = "org.adempiere.security.principal"; private final static String SECURITY_PRINCIPAL = "org.adempiere.security.principal";
/************************************************************************* /*************************************************************************
@ -314,7 +294,6 @@ public class CConnection implements Serializable, Cloneable
m_apps_host = apps_host; m_apps_host = apps_host;
m_name = toString (); m_name = toString ();
m_okApps = false; m_okApps = false;
m_queryAppsServer = false;
} }
/** /**
@ -334,7 +313,6 @@ public class CConnection implements Serializable, Cloneable
{ {
m_apps_port = apps_port; m_apps_port = apps_port;
m_okApps = false; m_okApps = false;
m_queryAppsServer = false;
} }
/** /**
@ -363,49 +341,6 @@ public class CConnection implements Serializable, Cloneable
*/ */
public boolean isAppsServerOK (boolean tryContactAgain) public boolean isAppsServerOK (boolean tryContactAgain)
{ {
if (isServerEmbedded())
return true;
if (Ini.isClient() && !tryContactAgain && m_queryAppsServer)
return m_okApps;
// Carlos Ruiz - globalqss - speed up when jnp://MyAppsServer:1099 is set
if (getAppsHost().equalsIgnoreCase("MyAppsServer")) {
log.warning (getAppsHost() + " ignored");
return false;
}
m_queryAppsServer = true;
// Contact it
try
{
Status status = (Status)lookup (Status.JNDI_NAME);
m_version = status.getDateVersion ();
m_okApps = true;
}
catch (Exception ce)
{
m_okApps = false;
String connect = (String)m_env.get(Context.PROVIDER_URL);
if (connect == null || connect.trim().length() == 0)
connect = getAppsHost() + ":" + getAppsPort();
log.warning (connect
+ "\n - " + ce.toString ()
+ "\n - " + m_env);
ce.printStackTrace();
}
catch (Throwable t)
{
m_okApps = false;
String connect = (String)m_env.get(Context.PROVIDER_URL);
if (connect == null || connect.trim().length() == 0)
connect = getAppsHost() + ":" + getAppsPort();
log.warning (connect
+ "\n - " + t.toString ()
+ "\n - " + m_env);
t.printStackTrace();
}
return m_okApps; return m_okApps;
} // isAppsOK } // isAppsOK
@ -425,32 +360,6 @@ public class CConnection implements Serializable, Cloneable
*/ */
public Server getServer() public Server getServer()
{ {
//only cache ServerHome for client
if (m_server == null || !Ini.isClient())
{
if (isServerEmbedded())
{
m_server = (Server)Proxy.newProxyInstance(Server.class.getClassLoader(),
new Class[]{Server.class}, new EmbeddedServerProxy());
return m_server;
}
try
{
Server server = (Server)lookup (Server.JNDI_NAME);
if (server != null)
if (Ini.isClient())
m_server = server;
else
return server;
}
catch (Exception ex)
{
log.log(Level.SEVERE, "", ex);
m_iContext = null;
throw new RuntimeException(ex);
}
}
return m_server; return m_server;
} // getServer } // getServer
@ -1397,9 +1306,6 @@ public class CConnection implements Serializable, Cloneable
/*************************************************************************/ /*************************************************************************/
private InitialContext m_iContext = null;
private Hashtable m_env = null;
/** /**
* Get Application Server Initial Context * Get Application Server Initial Context
* @param useCache if true, use existing cache * @param useCache if true, use existing cache
@ -1407,58 +1313,9 @@ public class CConnection implements Serializable, Cloneable
*/ */
public InitialContext getInitialContext (boolean useCache) public InitialContext getInitialContext (boolean useCache)
{ {
if (useCache && m_iContext != null) return null;
return m_iContext;
// Set Environment
if (m_env == null || !useCache)
{
SecurityPrincipal sp = (SecurityPrincipal) Env.getCtx().get(SECURITY_PRINCIPAL);
String principal = sp != null ? sp.principal : null;
String credential = sp != null ? sp.credential : null;
m_env = getInitialEnvironment(getAppsHost(), getAppsPort(), false,
principal, credential);
}
String connect = (String)m_env.get(Context.PROVIDER_URL);
Env.setContext(Env.getCtx(), Context.PROVIDER_URL, connect);
// Get Context
m_iContext = null;
try
{
m_iContext = new InitialContext (m_env);
}
catch (Exception ex)
{
m_okApps = false;
m_appsException = ex;
if (connect == null)
connect = (String)m_env.get(Context.PROVIDER_URL);
log.severe(connect
+ "\n - " + ex.toString ()
+ "\n - " + m_env);
if (CLogMgt.isLevelFinest())
ex.printStackTrace();
}
return m_iContext;
} // getInitialContext } // getInitialContext
/**
* Get Initial Environment
* @param AppsHost host
* @param AppsPort port
* @param RMIoverHTTP ignore, retained for backward compatibility
* @param principal
* @param credential
* @return environment
*/
private Hashtable getInitialEnvironment (String AppsHost, int AppsPort,
boolean RMIoverHTTP, String principal, String credential)
{
return ASFactory.getApplicationServer()
.getInitialContextEnvironment(AppsHost, AppsPort, principal, credential);
} // getInitialEnvironment
/** /**
* Query Application Server Status. * Query Application Server Status.
* update okApps * update okApps
@ -1466,49 +1323,6 @@ public class CConnection implements Serializable, Cloneable
*/ */
private boolean queryAppsServerInfo () private boolean queryAppsServerInfo ()
{ {
log.finer(getAppsHost());
long start = System.currentTimeMillis();
m_okApps = false;
m_queryAppsServer = true;
m_appsException = null;
// Carlos Ruiz - globalqss - speed up when jnp://MyAppsServer:1099 is set
if (getAppsHost().equalsIgnoreCase("MyAppsServer")) {
log.warning (getAppsHost() + " ignored");
return m_okApps; // false
}
try
{
Status status = (Status)lookup (Status.JNDI_NAME);
//
updateInfoFromServer(status);
//
m_okApps = true;
}
catch (CommunicationException ce) // not a "real" error
{
m_appsException = ce;
String connect = (String)m_env.get(Context.PROVIDER_URL);
if (connect == null || connect.trim().length() == 0)
connect = getAppsHost() + ":" + getAppsPort();
log.warning (connect
+ "\n - " + ce.toString ()
+ "\n - " + m_env);
ce.printStackTrace();
}
catch (Exception e)
{
m_appsException = e;
String connect = (String)m_env.get(Context.PROVIDER_URL);
if (connect == null || connect.trim().length() == 0)
connect = getAppsHost() + ":" + getAppsPort();
log.warning (connect
+ "\n - " + e.toString ()
+ "\n - " + m_env);
e.printStackTrace();
}
log.fine("Success=" + m_okApps + " - " + (System.currentTimeMillis()-start) + "ms");
return m_okApps; return m_okApps;
} // setAppsServerInfo } // setAppsServerInfo
@ -1614,8 +1428,6 @@ public class CConnection implements Serializable, Cloneable
sp.principal = principal; sp.principal = principal;
sp.credential = credential; sp.credential = credential;
Env.getCtx().put(SECURITY_PRINCIPAL, sp); Env.getCtx().put(SECURITY_PRINCIPAL, sp);
m_iContext = null;
m_env = null;
m_server = null; m_server = null;
} }
@ -1629,26 +1441,6 @@ public class CConnection implements Serializable, Cloneable
return c; return c;
} }
private Object lookup(String jndiName) throws NamingException {
InitialContext ctx = getInitialContext(Ini.isClient());
if (useComponentNamespace)
{
try
{
return ctx.lookup(COMPONENT_NS + "/" + jndiName);
}
catch (Exception e)
{
log.warning("Component name space not available - " + e.getLocalizedMessage());
//not available
useComponentNamespace = false;
}
}
//global jndi lookup
return ctx.lookup(jndiName);
}
/************************************************************************** /**************************************************************************
* Testing * Testing
* @param args ignored * @param args ignored

View File

@ -46,7 +46,7 @@ import org.compiere.util.Language;
* *
* @author Jorg Janke * @author Jorg Janke
* @version $Id: MClient.java,v 1.2 2006/07/30 00:58:37 jjanke Exp $ * @version $Id: MClient.java,v 1.2 2006/07/30 00:58:37 jjanke Exp $
* *
* @author Carlos Ruiz - globalqss * @author Carlos Ruiz - globalqss
* integrate bug fix reported by Teo Sarca * integrate bug fix reported by Teo Sarca
* [ 1619085 ] Client setup creates duplicate trees * [ 1619085 ] Client setup creates duplicate trees
@ -56,7 +56,7 @@ import org.compiere.util.Language;
public class MClient extends X_AD_Client public class MClient extends X_AD_Client
{ {
/** /**
* *
*/ */
private static final long serialVersionUID = -6482473737885701403L; private static final long serialVersionUID = -6482473737885701403L;
@ -110,7 +110,7 @@ public class MClient extends X_AD_Client
/** Cache */ /** Cache */
private static CCache<Integer,MClient> s_cache = new CCache<Integer,MClient>("AD_Client", 3); private static CCache<Integer,MClient> s_cache = new CCache<Integer,MClient>("AD_Client", 3);
/************************************************************************** /**************************************************************************
* Standard Constructor * Standard Constructor
* @param ctx context * @param ctx context
@ -130,7 +130,7 @@ public class MClient extends X_AD_Client
// setName (null); // setName (null);
setAD_Org_ID(0); setAD_Org_ID(0);
setIsMultiLingualDocument (false); setIsMultiLingualDocument (false);
setIsSmtpAuthorization (false); setIsSmtpAuthorization (false);
setIsUseBetaFunctions (true); setIsUseBetaFunctions (true);
setIsServerEMail(false); setIsServerEMail(false);
setAD_Language(Language.getBaseAD_Language()); setAD_Language(Language.getBaseAD_Language());
@ -246,8 +246,8 @@ public class MClient extends X_AD_Client
} }
return m_language; return m_language;
} // getLanguage } // getLanguage
/** /**
* Set AD_Language * Set AD_Language
* @param AD_Language new language * @param AD_Language new language
@ -257,7 +257,7 @@ public class MClient extends X_AD_Client
m_language = null; m_language = null;
super.setAD_Language (AD_Language); super.setAD_Language (AD_Language);
} // setAD_Language } // setAD_Language
/** /**
* Get AD_Language * Get AD_Language
* @return Language * @return Language
@ -281,8 +281,8 @@ public class MClient extends X_AD_Client
return lang.getLocale(); return lang.getLocale();
return Locale.getDefault(); return Locale.getDefault();
} // getLocale } // getLocale
/************************************************************************** /**************************************************************************
* Create Trees and Setup Client Info * Create Trees and Setup Client Info
* @param language language * @param language language
@ -390,7 +390,7 @@ public class MClient extends X_AD_Client
// Create ClientInfo // Create ClientInfo
MClientInfo clientInfo = new MClientInfo (this, MClientInfo clientInfo = new MClientInfo (this,
AD_Tree_Org_ID, AD_Tree_BPartner_ID, AD_Tree_Project_ID, AD_Tree_Org_ID, AD_Tree_BPartner_ID, AD_Tree_Project_ID,
AD_Tree_SalesRegion_ID, AD_Tree_Product_ID, AD_Tree_SalesRegion_ID, AD_Tree_Product_ID,
AD_Tree_Campaign_ID, AD_Tree_Activity_ID, get_TrxName()); AD_Tree_Campaign_ID, AD_Tree_Activity_ID, get_TrxName());
success = clientInfo.save(); success = clientInfo.save();
@ -398,7 +398,7 @@ public class MClient extends X_AD_Client
} // createTrees } // createTrees
/** /**
* Get AD_Tree_Account_ID created in setup client info * Get AD_Tree_Account_ID created in setup client info
* @return Account Tree ID * @return Account Tree ID
*/ */
public int getSetup_AD_Tree_Account_ID() public int getSetup_AD_Tree_Account_ID()
@ -415,8 +415,8 @@ public class MClient extends X_AD_Client
String aa = getAutoArchive(); String aa = getAutoArchive();
return aa != null && !aa.equals(AUTOARCHIVE_None); return aa != null && !aa.equals(AUTOARCHIVE_None);
} // isAutoArchive } // isAutoArchive
/** /**
* Update Trl Tables automatically? * Update Trl Tables automatically?
* @param TableName table name * @param TableName table name
@ -433,7 +433,7 @@ public class MClient extends X_AD_Client
return false; return false;
return true; return true;
} // isMultiLingualDocument } // isMultiLingualDocument
/** /**
* Get Primary Accounting Schema * Get Primary Accounting Schema
* @return Acct Schema or null * @return Acct Schema or null
@ -450,7 +450,7 @@ public class MClient extends X_AD_Client
} }
return null; return null;
} // getMClientInfo } // getMClientInfo
/** /**
* Save * Save
* @return true if saved * @return true if saved
@ -461,8 +461,8 @@ public class MClient extends X_AD_Client
return saveUpdate(); return saveUpdate();
return super.save (); return super.save ();
} // save } // save
/************************************************************************** /**************************************************************************
* Test EMail * Test EMail
* @return OK or error * @return OK or error
@ -473,7 +473,7 @@ public class MClient extends X_AD_Client
return "No Request EMail for " + getName(); return "No Request EMail for " + getName();
// //
EMail email = createEMail (getRequestEMail(), EMail email = createEMail (getRequestEMail(),
"Adempiere EMail Test", "Adempiere EMail Test",
"Adempiere EMail Test: " + toString()); "Adempiere EMail Test: " + toString());
if (email == null) if (email == null)
return "Could not create EMail: " + getName(); return "Could not create EMail: " + getName();
@ -500,7 +500,7 @@ public class MClient extends X_AD_Client
return ex.getLocalizedMessage(); return ex.getLocalizedMessage();
} }
} // testEMail } // testEMail
/** /**
* Send EMail from Request User - with trace * Send EMail from Request User - with trace
* @param AD_User_ID recipient * @param AD_User_ID recipient
@ -509,7 +509,7 @@ public class MClient extends X_AD_Client
* @param attachment optional attachment * @param attachment optional attachment
* @return true if sent * @return true if sent
*/ */
public boolean sendEMail (int AD_User_ID, public boolean sendEMail (int AD_User_ID,
String subject, String message, File attachment) String subject, String message, File attachment)
{ {
Collection<File> attachments = new ArrayList<File>(); Collection<File> attachments = new ArrayList<File>();
@ -517,7 +517,7 @@ public class MClient extends X_AD_Client
attachments.add(attachment); attachments.add(attachment);
return sendEMailAttachments(AD_User_ID, subject, message, attachments); return sendEMailAttachments(AD_User_ID, subject, message, attachments);
} }
/** /**
* Send EMail from Request User - with trace * Send EMail from Request User - with trace
* @param AD_User_ID recipient * @param AD_User_ID recipient
@ -526,12 +526,12 @@ public class MClient extends X_AD_Client
* @param attachment optional collection of attachments * @param attachment optional collection of attachments
* @return true if sent * @return true if sent
*/ */
public boolean sendEMailAttachments (int AD_User_ID, public boolean sendEMailAttachments (int AD_User_ID,
String subject, String message, Collection<File> attachments) String subject, String message, Collection<File> attachments)
{ {
return sendEMailAttachments(AD_User_ID, subject, message, attachments, false); return sendEMailAttachments(AD_User_ID, subject, message, attachments, false);
} }
/** /**
* Send EMail from Request User - with trace * Send EMail from Request User - with trace
* @param AD_User_ID recipient * @param AD_User_ID recipient
@ -541,11 +541,11 @@ public class MClient extends X_AD_Client
* @param html * @param html
* @return true if sent * @return true if sent
*/ */
public boolean sendEMailAttachments (int AD_User_ID, public boolean sendEMailAttachments (int AD_User_ID,
String subject, String message, Collection<File> attachments, boolean html) String subject, String message, Collection<File> attachments, boolean html)
{ {
MUser to = MUser.get(getCtx(), AD_User_ID); MUser to = MUser.get(getCtx(), AD_User_ID);
String toEMail = to.getEMail(); String toEMail = to.getEMail();
if (toEMail == null || toEMail.length() == 0) if (toEMail == null || toEMail.length() == 0)
{ {
log.warning("No EMail for recipient: " + to); log.warning("No EMail for recipient: " + to);
@ -565,7 +565,7 @@ public class MClient extends X_AD_Client
return false; return false;
} }
} // sendEMail } // sendEMail
/** /**
* Send EMail from Request User - no trace * Send EMail from Request User - no trace
* @param to recipient email address * @param to recipient email address
@ -574,12 +574,12 @@ public class MClient extends X_AD_Client
* @param attachment optional attachment * @param attachment optional attachment
* @return true if sent * @return true if sent
*/ */
public boolean sendEMail (String to, public boolean sendEMail (String to,
String subject, String message, File attachment) String subject, String message, File attachment)
{ {
return sendEMail(to, subject, message, attachment, false); return sendEMail(to, subject, message, attachment, false);
} }
/** /**
* Send EMail from Request User - no trace * Send EMail from Request User - no trace
* @param to recipient email address * @param to recipient email address
@ -589,7 +589,7 @@ public class MClient extends X_AD_Client
* @param html * @param html
* @return true if sent * @return true if sent
*/ */
public boolean sendEMail (String to, public boolean sendEMail (String to,
String subject, String message, File attachment, boolean html) String subject, String message, File attachment, boolean html)
{ {
EMail email = createEMail(to, subject, message, html); EMail email = createEMail(to, subject, message, html);
@ -607,7 +607,7 @@ public class MClient extends X_AD_Client
} }
else else
{ {
log.warning("Could NOT Send Email: " + subject log.warning("Could NOT Send Email: " + subject
+ " to " + to + ": " + msg + " to " + to + ": " + msg
+ " (" + getName() + ")"); + " (" + getName() + ")");
return false; return false;
@ -629,12 +629,12 @@ public class MClient extends X_AD_Client
* @param attachment optional attachment * @param attachment optional attachment
* @return true if sent * @return true if sent
*/ */
public boolean sendEMail (MUser from, MUser to, public boolean sendEMail (MUser from, MUser to,
String subject, String message, File attachment) String subject, String message, File attachment)
{ {
return sendEMail(from, to, subject, message, attachment, false); return sendEMail(from, to, subject, message, attachment, false);
} }
/** /**
* Send EMail from User * Send EMail from User
* @param from sender * @param from sender
@ -645,13 +645,13 @@ public class MClient extends X_AD_Client
* @param isHtml * @param isHtml
* @return true if sent * @return true if sent
*/ */
public boolean sendEMail (MUser from, MUser to, public boolean sendEMail (MUser from, MUser to,
String subject, String message, File attachment, boolean isHtml) String subject, String message, File attachment, boolean isHtml)
{ {
EMail email = createEMail(from, to, subject, message, isHtml); EMail email = createEMail(from, to, subject, message, isHtml);
if (email == null) if (email == null)
return false; return false;
if (attachment != null) if (attachment != null)
email.addAttachment(attachment); email.addAttachment(attachment);
InternetAddress emailFrom = email.getFrom(); InternetAddress emailFrom = email.getFrom();
@ -696,11 +696,11 @@ public class MClient extends X_AD_Client
if (email.isSentOK()) if (email.isSentOK())
{ {
if (from != null) if (from != null)
log.info("Sent Email: " + email.getSubject() log.info("Sent Email: " + email.getSubject()
+ " from " + from.getEMail() + " from " + from.getEMail()
+ " to " + to.getEMail()); + " to " + to.getEMail());
else else
log.info("Sent Email: " + email.getSubject() log.info("Sent Email: " + email.getSubject()
+ " to " + to.getEMail()); + " to " + to.getEMail());
return true; return true;
} }
@ -726,12 +726,12 @@ public class MClient extends X_AD_Client
* @param message nessage * @param message nessage
* @return EMail * @return EMail
*/ */
public EMail createEMail (String to, public EMail createEMail (String to,
String subject, String message) String subject, String message)
{ {
return createEMail(to, subject, message, false); return createEMail(to, subject, message, false);
} }
/************ /************
* Create EMail from Request User * Create EMail from Request User
* @param to recipient * @param to recipient
@ -740,7 +740,7 @@ public class MClient extends X_AD_Client
* @param html * @param html
* @return EMail * @return EMail
*/ */
public EMail createEMail (String to, public EMail createEMail (String to,
String subject, String message, boolean html) String subject, String message, boolean html)
{ {
if (to == null || to.length() == 0) if (to == null || to.length() == 0)
@ -759,11 +759,11 @@ public class MClient extends X_AD_Client
{ // See ServerBean { // See ServerBean
if (html && message != null) if (html && message != null)
message = EMail.HTML_MAIL_MARKER + message; message = EMail.HTML_MAIL_MARKER + message;
email = server.createEMail(Env.getRemoteCallCtx(getCtx()), getAD_Client_ID(), email = server.createEMail(Env.getRemoteCallCtx(getCtx()), getAD_Client_ID(),
to, subject, message); to, subject, message);
} }
else else
log.log(Level.WARNING, "No AppsServer"); log.log(Level.WARNING, "No AppsServer");
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -787,12 +787,12 @@ public class MClient extends X_AD_Client
* @param message nessage * @param message nessage
* @return EMail * @return EMail
*/ */
public EMail createEMail (MUser from, MUser to, public EMail createEMail (MUser from, MUser to,
String subject, String message) String subject, String message)
{ {
return createEMail(from, to, subject, message, false); return createEMail(from, to, subject, message, false);
} }
/** /**
* Create EMail from User * Create EMail from User
* @param from optional sender * @param from optional sender
@ -802,7 +802,7 @@ public class MClient extends X_AD_Client
* @param html * @param html
* @return EMail * @return EMail
*/ */
public EMail createEMail (MUser from, MUser to, public EMail createEMail (MUser from, MUser to,
String subject, String message, boolean html) String subject, String message, boolean html)
{ {
if (to == null) if (to == null)
@ -817,7 +817,7 @@ public class MClient extends X_AD_Client
} }
return createEMail (from, to.getEMail(), subject, message, html); return createEMail (from, to.getEMail(), subject, message, html);
} // createEMail } // createEMail
/** /**
* Create EMail from User * Create EMail from User
* @param from optional sender * @param from optional sender
@ -826,12 +826,12 @@ public class MClient extends X_AD_Client
* @param message nessage * @param message nessage
* @return EMail * @return EMail
*/ */
public EMail createEMail (MUser from, String to, public EMail createEMail (MUser from, String to,
String subject, String message) String subject, String message)
{ {
return createEMail(from, to, subject, message, false); return createEMail(from, to, subject, message, false);
} }
/** /**
* Create EMail from User * Create EMail from User
* @param from optional sender * @param from optional sender
@ -841,7 +841,7 @@ public class MClient extends X_AD_Client
* @param html * @param html
* @return EMail * @return EMail
*/ */
public EMail createEMail (MUser from, String to, public EMail createEMail (MUser from, String to,
String subject, String message, boolean html) String subject, String message, boolean html)
{ {
if (to == null || to.length() == 0) if (to == null || to.length() == 0)
@ -853,7 +853,7 @@ public class MClient extends X_AD_Client
if (from == null) if (from == null)
return createEMail (to, subject, message, html); return createEMail (to, subject, message, html);
// No From details - Error // No From details - Error
if (from.getEMail() == null if (from.getEMail() == null
|| from.getEMailUser() == null || from.getEMailUser() == null
|| (isSmtpAuthorization() && from.getEMailUserPW() == null) ) // is SMTP authorization and password is null - teo_sarca [ 1723309 ] || (isSmtpAuthorization() && from.getEMailUserPW() == null) ) // is SMTP authorization and password is null - teo_sarca [ 1723309 ]
{ {
@ -876,7 +876,7 @@ public class MClient extends X_AD_Client
to, subject, message); to, subject, message);
} }
else else
log.log(Level.WARNING, "No AppsServer"); log.log(Level.WARNING, "No AppsServer");
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -885,9 +885,9 @@ public class MClient extends X_AD_Client
} }
if (email == null) if (email == null)
email = new EMail (this, email = new EMail (this,
from.getEMail(), from.getEMail(),
to, to,
subject, subject,
message, html); message, html);
if (isSmtpAuthorization()) if (isSmtpAuthorization())
email.createAuthenticator (from.getEMailUser(), from.getEMailUserPW()); email.createAuthenticator (from.getEMailUser(), from.getEMailUserPW());
@ -900,7 +900,7 @@ public class MClient extends X_AD_Client
* D - Disabled (default) * D - Disabled (default)
* Q - Queue (enabled to post by hand - queue documents for posterior processing) * Q - Queue (enabled to post by hand - queue documents for posterior processing)
* I - Immediate (immediate post - allow complete on errors) * I - Immediate (immediate post - allow complete on errors)
* *
* @return boolean representing if client accounting is enabled and it's on a client * @return boolean representing if client accounting is enabled and it's on a client
*/ */
private static final String CLIENT_ACCOUNTING_DISABLED = "D"; private static final String CLIENT_ACCOUNTING_DISABLED = "D";
@ -909,21 +909,21 @@ public class MClient extends X_AD_Client
public static boolean isClientAccounting() { public static boolean isClientAccounting() {
String ca = MSysConfig.getValue("CLIENT_ACCOUNTING", String ca = MSysConfig.getValue("CLIENT_ACCOUNTING",
CLIENT_ACCOUNTING_DISABLED, // default CLIENT_ACCOUNTING_QUEUE, // default
Env.getAD_Client_ID(Env.getCtx())); Env.getAD_Client_ID(Env.getCtx()));
return (ca.equalsIgnoreCase(CLIENT_ACCOUNTING_IMMEDIATE) || ca.equalsIgnoreCase(CLIENT_ACCOUNTING_QUEUE)); return (ca.equalsIgnoreCase(CLIENT_ACCOUNTING_IMMEDIATE) || ca.equalsIgnoreCase(CLIENT_ACCOUNTING_QUEUE));
} }
public static boolean isClientAccountingQueue() { public static boolean isClientAccountingQueue() {
String ca = MSysConfig.getValue("CLIENT_ACCOUNTING", String ca = MSysConfig.getValue("CLIENT_ACCOUNTING",
CLIENT_ACCOUNTING_DISABLED, // default CLIENT_ACCOUNTING_QUEUE, // default
Env.getAD_Client_ID(Env.getCtx())); Env.getAD_Client_ID(Env.getCtx()));
return ca.equalsIgnoreCase(CLIENT_ACCOUNTING_QUEUE); return ca.equalsIgnoreCase(CLIENT_ACCOUNTING_QUEUE);
} }
public static boolean isClientAccountingImmediate() { public static boolean isClientAccountingImmediate() {
String ca = MSysConfig.getValue("CLIENT_ACCOUNTING", String ca = MSysConfig.getValue("CLIENT_ACCOUNTING",
CLIENT_ACCOUNTING_DISABLED, // default CLIENT_ACCOUNTING_QUEUE, // default
Env.getAD_Client_ID(Env.getCtx())); Env.getAD_Client_ID(Env.getCtx()));
return ca.equalsIgnoreCase(CLIENT_ACCOUNTING_IMMEDIATE); return ca.equalsIgnoreCase(CLIENT_ACCOUNTING_IMMEDIATE);
} }
@ -991,7 +991,7 @@ public class MClient extends X_AD_Client
+ " WHERE ce.AD_Client_ID = " + getAD_Client_ID() + " WHERE ce.AD_Client_ID = " + getAD_Client_ID()
+ " AND ce.IsActive = 'Y' " + " AND ce.IsActive = 'Y' "
+ " AND ce.AD_Field_ID IS NOT NULL " + " AND ce.AD_Field_ID IS NOT NULL "
+ " AND ce.ASP_Status = 'H')" + " AND ce.ASP_Status = 'H')"
+ " ORDER BY AD_Field_ID"; + " ORDER BY AD_Field_ID";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;

View File

@ -55,8 +55,8 @@ import org.eevolution.model.I_PP_Order;
/** /**
* Document Action Engine * Document Action Engine
* *
* @author Jorg Janke * @author Jorg Janke
* @author Karsten Thiemann FR [ 1782412 ] * @author Karsten Thiemann FR [ 1782412 ]
* @author victor.perez@e-evolution.com www.e-evolution.com FR [ 1866214 ] http://sourceforge.net/tracker/index.php?func=detail&aid=1866214&group_id=176962&atid=879335 * @author victor.perez@e-evolution.com www.e-evolution.com FR [ 1866214 ] http://sourceforge.net/tracker/index.php?func=detail&aid=1866214&group_id=176962&atid=879335
* @version $Id: DocumentEngine.java,v 1.2 2006/07/30 00:54:44 jjanke Exp $ * @version $Id: DocumentEngine.java,v 1.2 2006/07/30 00:54:44 jjanke Exp $
@ -71,7 +71,7 @@ public class DocumentEngine implements DocAction
{ {
this (po, STATUS_Drafted); this (po, STATUS_Drafted);
} // DocActionEngine } // DocActionEngine
/** /**
* Doc Engine * Doc Engine
* @param po document * @param po document
@ -92,10 +92,10 @@ public class DocumentEngine implements DocAction
private String m_message = null; private String m_message = null;
/** Actual Doc Action */ /** Actual Doc Action */
private String m_action = null; private String m_action = null;
/** Logger */ /** Logger */
private static CLogger log = CLogger.getCLogger(DocumentEngine.class); private static CLogger log = CLogger.getCLogger(DocumentEngine.class);
/** /**
* Get Doc Status * Get Doc Status
* @return document status * @return document status
@ -122,7 +122,7 @@ public class DocumentEngine implements DocAction
{ {
return STATUS_Drafted.equals(m_status); return STATUS_Drafted.equals(m_status);
} // isDrafted } // isDrafted
/** /**
* Document is Invalid * Document is Invalid
* @return true if Invalid * @return true if Invalid
@ -131,7 +131,7 @@ public class DocumentEngine implements DocAction
{ {
return STATUS_Invalid.equals(m_status); return STATUS_Invalid.equals(m_status);
} // isInvalid } // isInvalid
/** /**
* Document is In Progress * Document is In Progress
* @return true if In Progress * @return true if In Progress
@ -140,7 +140,7 @@ public class DocumentEngine implements DocAction
{ {
return STATUS_InProgress.equals(m_status); return STATUS_InProgress.equals(m_status);
} // isInProgress } // isInProgress
/** /**
* Document is Approved * Document is Approved
* @return true if Approved * @return true if Approved
@ -149,7 +149,7 @@ public class DocumentEngine implements DocAction
{ {
return STATUS_Approved.equals(m_status); return STATUS_Approved.equals(m_status);
} // isApproved } // isApproved
/** /**
* Document is Not Approved * Document is Not Approved
* @return true if Not Approved * @return true if Not Approved
@ -158,7 +158,7 @@ public class DocumentEngine implements DocAction
{ {
return STATUS_NotApproved.equals(m_status); return STATUS_NotApproved.equals(m_status);
} // isNotApproved } // isNotApproved
/** /**
* Document is Waiting Payment or Confirmation * Document is Waiting Payment or Confirmation
* @return true if Waiting Payment * @return true if Waiting Payment
@ -168,7 +168,7 @@ public class DocumentEngine implements DocAction
return STATUS_WaitingPayment.equals(m_status) return STATUS_WaitingPayment.equals(m_status)
|| STATUS_WaitingConfirmation.equals(m_status); || STATUS_WaitingConfirmation.equals(m_status);
} // isWaitingPayment } // isWaitingPayment
/** /**
* Document is Completed * Document is Completed
* @return true if Completed * @return true if Completed
@ -177,7 +177,7 @@ public class DocumentEngine implements DocAction
{ {
return STATUS_Completed.equals(m_status); return STATUS_Completed.equals(m_status);
} // isCompleted } // isCompleted
/** /**
* Document is Reversed * Document is Reversed
* @return true if Reversed * @return true if Reversed
@ -186,7 +186,7 @@ public class DocumentEngine implements DocAction
{ {
return STATUS_Reversed.equals(m_status); return STATUS_Reversed.equals(m_status);
} // isReversed } // isReversed
/** /**
* Document is Closed * Document is Closed
* @return true if Closed * @return true if Closed
@ -195,7 +195,7 @@ public class DocumentEngine implements DocAction
{ {
return STATUS_Closed.equals(m_status); return STATUS_Closed.equals(m_status);
} // isClosed } // isClosed
/** /**
* Document is Voided * Document is Voided
* @return true if Voided * @return true if Voided
@ -204,23 +204,23 @@ public class DocumentEngine implements DocAction
{ {
return STATUS_Voided.equals(m_status); return STATUS_Voided.equals(m_status);
} // isVoided } // isVoided
/** /**
* Document Status is Unknown * Document Status is Unknown
* @return true if unknown * @return true if unknown
*/ */
public boolean isUnknown() public boolean isUnknown()
{ {
return STATUS_Unknown.equals(m_status) || return STATUS_Unknown.equals(m_status) ||
!(isDrafted() || isInvalid() || isInProgress() || isNotApproved() !(isDrafted() || isInvalid() || isInProgress() || isNotApproved()
|| isApproved() || isWaiting() || isCompleted() || isApproved() || isWaiting() || isCompleted()
|| isReversed() || isClosed() || isVoided() ); || isReversed() || isClosed() || isVoided() );
} // isUnknown } // isUnknown
/** /**
* Process actual document. * Process actual document.
* Checks if user (document) action is valid and then process action * Checks if user (document) action is valid and then process action
* Calls the individual actions which call the document action * Calls the individual actions which call the document action
* @param processAction document action based on workflow * @param processAction document action based on workflow
* @param docAction document action based on document * @param docAction document action based on document
@ -231,7 +231,7 @@ public class DocumentEngine implements DocAction
m_message = null; m_message = null;
m_action = null; m_action = null;
// Std User Workflows - see MWFNodeNext.isValidFor // Std User Workflows - see MWFNodeNext.isValidFor
if (isValidAction(processAction)) // WF Selection first if (isValidAction(processAction)) // WF Selection first
m_action = processAction; m_action = processAction;
// //
@ -243,11 +243,11 @@ public class DocumentEngine implements DocAction
{ {
if (m_document != null) if (m_document != null)
m_document.get_Logger().info ("**** No Action (Prc=" + processAction + "/Doc=" + docAction + ") " + m_document); m_document.get_Logger().info ("**** No Action (Prc=" + processAction + "/Doc=" + docAction + ") " + m_document);
return true; return true;
} }
else else
{ {
throw new IllegalStateException("Status=" + getDocStatus() throw new IllegalStateException("Status=" + getDocStatus()
+ " - Invalid Actions: Process=" + processAction + ", Doc=" + docAction); + " - Invalid Actions: Process=" + processAction + ", Doc=" + docAction);
} }
if (m_document != null) if (m_document != null)
@ -257,7 +257,7 @@ public class DocumentEngine implements DocAction
m_document.get_Logger().fine("**** Action=" + m_action + " - Success=" + success); m_document.get_Logger().fine("**** Action=" + m_action + " - Success=" + success);
return success; return success;
} // process } // process
/** /**
* Process actual document - do not call directly. * Process actual document - do not call directly.
* Calls the individual actions which call the document action * Calls the individual actions which call the document action
@ -312,12 +312,12 @@ public class DocumentEngine implements DocAction
docafter.save(); docafter.save();
} }
} }
if (STATUS_Completed.equals(status) && MClient.isClientAccountingImmediate()) if (STATUS_Completed.equals(status) && MClient.isClientAccountingImmediate())
{ {
m_document.save(); m_document.save();
postIt(); postIt();
if (m_document instanceof PO && docsPostProcess.size() > 0) { if (m_document instanceof PO && docsPostProcess.size() > 0) {
for (PO docafter : docsPostProcess) { for (PO docafter : docsPostProcess) {
@SuppressWarnings("unused") @SuppressWarnings("unused")
@ -344,11 +344,11 @@ public class DocumentEngine implements DocAction
// //
return false; return false;
} // processDocument } // processDocument
/** /**
* Unlock Document. * Unlock Document.
* Status: Drafted * Status: Drafted
* @return true if success * @return true if success
* @see org.compiere.process.DocAction#unlockIt() * @see org.compiere.process.DocAction#unlockIt()
*/ */
public boolean unlockIt() public boolean unlockIt()
@ -368,11 +368,11 @@ public class DocumentEngine implements DocAction
m_status = STATUS_Drafted; m_status = STATUS_Drafted;
return true; return true;
} // unlockIt } // unlockIt
/** /**
* Invalidate Document. * Invalidate Document.
* Status: Invalid * Status: Invalid
* @return true if success * @return true if success
* @see org.compiere.process.DocAction#invalidateIt() * @see org.compiere.process.DocAction#invalidateIt()
*/ */
public boolean invalidateIt() public boolean invalidateIt()
@ -392,11 +392,11 @@ public class DocumentEngine implements DocAction
m_status = STATUS_Invalid; m_status = STATUS_Invalid;
return true; return true;
} // invalidateIt } // invalidateIt
/** /**
* Process Document. * Process Document.
* Status is set by process * Status is set by process
* @return new status (In Progress or Invalid) * @return new status (In Progress or Invalid)
* @see org.compiere.process.DocAction#prepareIt() * @see org.compiere.process.DocAction#prepareIt()
*/ */
public String prepareIt() public String prepareIt()
@ -414,7 +414,7 @@ public class DocumentEngine implements DocAction
/** /**
* Approve Document. * Approve Document.
* Status: Approved * Status: Approved
* @return true if success * @return true if success
* @see org.compiere.process.DocAction#approveIt() * @see org.compiere.process.DocAction#approveIt()
*/ */
public boolean approveIt() public boolean approveIt()
@ -434,11 +434,11 @@ public class DocumentEngine implements DocAction
m_status = STATUS_Approved; m_status = STATUS_Approved;
return true; return true;
} // approveIt } // approveIt
/** /**
* Reject Approval. * Reject Approval.
* Status: Not Approved * Status: Not Approved
* @return true if success * @return true if success
* @see org.compiere.process.DocAction#rejectIt() * @see org.compiere.process.DocAction#rejectIt()
*/ */
public boolean rejectIt() public boolean rejectIt()
@ -458,7 +458,7 @@ public class DocumentEngine implements DocAction
m_status = STATUS_NotApproved; m_status = STATUS_NotApproved;
return true; return true;
} // rejectIt } // rejectIt
/** /**
* Complete Document. * Complete Document.
* Status is set by process * Status is set by process
@ -476,26 +476,26 @@ public class DocumentEngine implements DocAction
} }
return m_status; return m_status;
} // completeIt } // completeIt
/** /**
* Post Document * Post Document
* Does not change status * Does not change status
* @return true if success * @return true if success
*/ */
public boolean postIt() public boolean postIt()
{ {
if (!isValidAction(ACTION_Post) if (!isValidAction(ACTION_Post)
|| m_document == null) || m_document == null)
return false; return false;
String error = DocumentEngine.postImmediate(Env.getCtx(), m_document.getAD_Client_ID(), m_document.get_Table_ID(), m_document.get_ID(), true, m_document.get_TrxName()); String error = DocumentEngine.postImmediate(Env.getCtx(), m_document.getAD_Client_ID(), m_document.get_Table_ID(), m_document.get_ID(), true, m_document.get_TrxName());
return (error == null); return (error == null);
} // postIt } // postIt
/** /**
* Void Document. * Void Document.
* Status: Voided * Status: Voided
* @return true if success * @return true if success
* @see org.compiere.process.DocAction#voidIt() * @see org.compiere.process.DocAction#voidIt()
*/ */
public boolean voidIt() public boolean voidIt()
@ -515,11 +515,11 @@ public class DocumentEngine implements DocAction
m_status = STATUS_Voided; m_status = STATUS_Voided;
return true; return true;
} // voidIt } // voidIt
/** /**
* Close Document. * Close Document.
* Status: Closed * Status: Closed
* @return true if success * @return true if success
* @see org.compiere.process.DocAction#closeIt() * @see org.compiere.process.DocAction#closeIt()
*/ */
public boolean closeIt() public boolean closeIt()
@ -542,11 +542,11 @@ public class DocumentEngine implements DocAction
m_status = STATUS_Closed; m_status = STATUS_Closed;
return true; return true;
} // closeIt } // closeIt
/** /**
* Reverse Correct Document. * Reverse Correct Document.
* Status: Reversed * Status: Reversed
* @return true if success * @return true if success
* @see org.compiere.process.DocAction#reverseCorrectIt() * @see org.compiere.process.DocAction#reverseCorrectIt()
*/ */
public boolean reverseCorrectIt() public boolean reverseCorrectIt()
@ -566,11 +566,11 @@ public class DocumentEngine implements DocAction
m_status = STATUS_Reversed; m_status = STATUS_Reversed;
return true; return true;
} // reverseCorrectIt } // reverseCorrectIt
/** /**
* Reverse Accrual Document. * Reverse Accrual Document.
* Status: Reversed * Status: Reversed
* @return true if success * @return true if success
* @see org.compiere.process.DocAction#reverseAccrualIt() * @see org.compiere.process.DocAction#reverseAccrualIt()
*/ */
public boolean reverseAccrualIt() public boolean reverseAccrualIt()
@ -590,11 +590,11 @@ public class DocumentEngine implements DocAction
m_status = STATUS_Reversed; m_status = STATUS_Reversed;
return true; return true;
} // reverseAccrualIt } // reverseAccrualIt
/** /**
* Re-activate Document. * Re-activate Document.
* Status: In Progress * Status: In Progress
* @return true if success * @return true if success
* @see org.compiere.process.DocAction#reActivateIt() * @see org.compiere.process.DocAction#reActivateIt()
*/ */
public boolean reActivateIt() public boolean reActivateIt()
@ -615,7 +615,7 @@ public class DocumentEngine implements DocAction
return true; return true;
} // reActivateIt } // reActivateIt
/** /**
* Set Document Status to new Status * Set Document Status to new Status
* @param newStatus new status * @param newStatus new status
@ -625,7 +625,7 @@ public class DocumentEngine implements DocAction
m_status = newStatus; m_status = newStatus;
} // setStatus } // setStatus
/************************************************************************** /**************************************************************************
* Get Action Options based on current Status * Get Action Options based on current Status
* @return array of actions * @return array of actions
@ -633,37 +633,37 @@ public class DocumentEngine implements DocAction
public String[] getActionOptions() public String[] getActionOptions()
{ {
if (isInvalid()) if (isInvalid())
return new String[] {ACTION_Prepare, ACTION_Invalidate, return new String[] {ACTION_Prepare, ACTION_Invalidate,
ACTION_Unlock, ACTION_Void}; ACTION_Unlock, ACTION_Void};
if (isDrafted()) if (isDrafted())
return new String[] {ACTION_Prepare, ACTION_Invalidate, ACTION_Complete, return new String[] {ACTION_Prepare, ACTION_Invalidate, ACTION_Complete,
ACTION_Unlock, ACTION_Void}; ACTION_Unlock, ACTION_Void};
if (isInProgress() || isApproved()) if (isInProgress() || isApproved())
return new String[] {ACTION_Complete, ACTION_WaitComplete, return new String[] {ACTION_Complete, ACTION_WaitComplete,
ACTION_Approve, ACTION_Reject, ACTION_Approve, ACTION_Reject,
ACTION_Unlock, ACTION_Void, ACTION_Prepare}; ACTION_Unlock, ACTION_Void, ACTION_Prepare};
if (isNotApproved()) if (isNotApproved())
return new String[] {ACTION_Reject, ACTION_Prepare, return new String[] {ACTION_Reject, ACTION_Prepare,
ACTION_Unlock, ACTION_Void}; ACTION_Unlock, ACTION_Void};
if (isWaiting()) if (isWaiting())
return new String[] {ACTION_Complete, ACTION_WaitComplete, return new String[] {ACTION_Complete, ACTION_WaitComplete,
ACTION_ReActivate, ACTION_Void, ACTION_Close}; ACTION_ReActivate, ACTION_Void, ACTION_Close};
if (isCompleted()) if (isCompleted())
return new String[] {ACTION_Close, ACTION_ReActivate, return new String[] {ACTION_Close, ACTION_ReActivate,
ACTION_Reverse_Accrual, ACTION_Reverse_Correct, ACTION_Reverse_Accrual, ACTION_Reverse_Correct,
ACTION_Post, ACTION_Void}; ACTION_Post, ACTION_Void};
if (isClosed()) if (isClosed())
return new String[] {ACTION_Post, ACTION_ReOpen}; return new String[] {ACTION_Post, ACTION_ReOpen};
if (isReversed() || isVoided()) if (isReversed() || isVoided())
return new String[] {ACTION_Post}; return new String[] {ACTION_Post};
return new String[] {}; return new String[] {};
} // getActionOptions } // getActionOptions
@ -691,7 +691,7 @@ public class DocumentEngine implements DocAction
{ {
return m_message; return m_message;
} // getProcessMsg } // getProcessMsg
/** /**
* Get Process Message * Get Process Message
* @param msg clear text error message * @param msg clear text error message
@ -700,11 +700,11 @@ public class DocumentEngine implements DocAction
{ {
m_message = msg; m_message = msg;
} // setProcessMsg } // setProcessMsg
/** Document Exception Message */ /** Document Exception Message */
private static String EXCEPTION_MSG = "Document Engine is no Document"; private static String EXCEPTION_MSG = "Document Engine is no Document";
/************************************************************************* /*************************************************************************
* Get Summary * Get Summary
* @return throw exception * @return throw exception
@ -713,7 +713,7 @@ public class DocumentEngine implements DocAction
{ {
throw new IllegalStateException(EXCEPTION_MSG); throw new IllegalStateException(EXCEPTION_MSG);
} }
/** /**
* Get Document No * Get Document No
* @return throw exception * @return throw exception
@ -740,7 +740,7 @@ public class DocumentEngine implements DocAction
{ {
throw new IllegalStateException(EXCEPTION_MSG); throw new IllegalStateException(EXCEPTION_MSG);
} }
/** /**
* Get Document Currency * Get Document Currency
* @return throw exception * @return throw exception
@ -776,7 +776,7 @@ public class DocumentEngine implements DocAction
{ {
throw new IllegalStateException(EXCEPTION_MSG); throw new IllegalStateException(EXCEPTION_MSG);
} }
/** /**
* Get Doc Action * Get Doc Action
* @return Document Action * @return Document Action
@ -794,7 +794,7 @@ public class DocumentEngine implements DocAction
{ {
throw new IllegalStateException(EXCEPTION_MSG); throw new IllegalStateException(EXCEPTION_MSG);
} }
/** /**
* Get Context * Get Context
* @return context * @return context
@ -816,7 +816,7 @@ public class DocumentEngine implements DocAction
return m_document.get_ID(); return m_document.get_ID();
throw new IllegalStateException(EXCEPTION_MSG); throw new IllegalStateException(EXCEPTION_MSG);
} // get_ID } // get_ID
/** /**
* Get AD_Table_ID * Get AD_Table_ID
* @return AD_Table_ID * @return AD_Table_ID
@ -827,7 +827,7 @@ public class DocumentEngine implements DocAction
return m_document.get_Table_ID(); return m_document.get_Table_ID();
throw new IllegalStateException(EXCEPTION_MSG); throw new IllegalStateException(EXCEPTION_MSG);
} // get_Table_ID } // get_Table_ID
/** /**
* Get Logger * Get Logger
* @return logger * @return logger
@ -856,9 +856,9 @@ public class DocumentEngine implements DocAction
{ {
return null; return null;
} }
/** /**
* Get list of valid document action into the options array parameter. * Get list of valid document action into the options array parameter.
* Set default document action into the docAction array parameter. * Set default document action into the docAction array parameter.
* @param docStatus * @param docStatus
* @param processing * @param processing
@ -869,16 +869,16 @@ public class DocumentEngine implements DocAction
* @param options * @param options
* @return Number of valid options * @return Number of valid options
*/ */
public static int getValidActions(String docStatus, Object processing, public static int getValidActions(String docStatus, Object processing,
String orderType, String isSOTrx, int AD_Table_ID, String[] docAction, String[] options) String orderType, String isSOTrx, int AD_Table_ID, String[] docAction, String[] options)
{ {
if (options == null) if (options == null)
throw new IllegalArgumentException("Option array parameter is null"); throw new IllegalArgumentException("Option array parameter is null");
if (docAction == null) if (docAction == null)
throw new IllegalArgumentException("Doc action array parameter is null"); throw new IllegalArgumentException("Doc action array parameter is null");
int index = 0; int index = 0;
// Locked // Locked
if (processing != null) if (processing != null)
{ {
@ -923,8 +923,8 @@ public class DocumentEngine implements DocAction
options[index++] = DocumentEngine.ACTION_Prepare; options[index++] = DocumentEngine.ACTION_Prepare;
} }
// Closed, Voided, REversed .. CL/VO/RE // Closed, Voided, REversed .. CL/VO/RE
else if (docStatus.equals(DocumentEngine.STATUS_Closed) else if (docStatus.equals(DocumentEngine.STATUS_Closed)
|| docStatus.equals(DocumentEngine.STATUS_Voided) || docStatus.equals(DocumentEngine.STATUS_Voided)
|| docStatus.equals(DocumentEngine.STATUS_Reversed)) || docStatus.equals(DocumentEngine.STATUS_Reversed))
return 0; return 0;
@ -1132,7 +1132,7 @@ public class DocumentEngine implements DocAction
} }
return index; return index;
} }
/** /**
* Fill Vector with DocAction Ref_List(135) values * Fill Vector with DocAction Ref_List(135) values
* @param v_value * @param v_value
@ -1142,13 +1142,13 @@ public class DocumentEngine implements DocAction
public static void readReferenceList(ArrayList<String> v_value, ArrayList<String> v_name, public static void readReferenceList(ArrayList<String> v_value, ArrayList<String> v_name,
ArrayList<String> v_description) ArrayList<String> v_description)
{ {
if (v_value == null) if (v_value == null)
throw new IllegalArgumentException("v_value parameter is null"); throw new IllegalArgumentException("v_value parameter is null");
if (v_name == null) if (v_name == null)
throw new IllegalArgumentException("v_name parameter is null"); throw new IllegalArgumentException("v_name parameter is null");
if (v_description == null) if (v_description == null)
throw new IllegalArgumentException("v_description parameter is null"); throw new IllegalArgumentException("v_description parameter is null");
String sql; String sql;
if (Env.isBaseLanguage(Env.getCtx(), "AD_Ref_List")) if (Env.isBaseLanguage(Env.getCtx(), "AD_Ref_List"))
sql = "SELECT Value, Name, Description FROM AD_Ref_List " sql = "SELECT Value, Name, Description FROM AD_Ref_List "
@ -1198,7 +1198,7 @@ public class DocumentEngine implements DocAction
public static int checkActionAccess(int clientId, int roleId, int docTypeId, String[] options, int maxIndex) { public static int checkActionAccess(int clientId, int roleId, int docTypeId, String[] options, int maxIndex) {
return MRole.get(Env.getCtx(), roleId).checkActionAccess(clientId, docTypeId, options, maxIndex); return MRole.get(Env.getCtx(), roleId).checkActionAccess(clientId, docTypeId, options, maxIndex);
} }
/** /**
* Post Immediate * Post Immediate
* *
@ -1210,48 +1210,18 @@ public class DocumentEngine implements DocAction
* @param trxName ignore, retained for backward compatibility * @param trxName ignore, retained for backward compatibility
* @return null, if success or error message * @return null, if success or error message
*/ */
public static String postImmediate (Properties ctx, public static String postImmediate (Properties ctx,
int AD_Client_ID, int AD_Table_ID, int Record_ID, boolean force, String trxName) int AD_Client_ID, int AD_Table_ID, int Record_ID, boolean force, String trxName)
{ {
// Ensure the table has Posted column / i.e. GL_JournalBatch can be completed but not posted // Ensure the table has Posted column / i.e. GL_JournalBatch can be completed but not posted
if (MColumn.getColumn_ID(MTable.getTableName(ctx, AD_Table_ID), "Posted") <= 0) if (MColumn.getColumn_ID(MTable.getTableName(ctx, AD_Table_ID), "Posted") <= 0)
return null; return null;
String error = null; String error = null;
if (MClient.isClientAccounting()) { log.info ("Table=" + AD_Table_ID + ", Record=" + Record_ID);
log.info ("Table=" + AD_Table_ID + ", Record=" + Record_ID); MAcctSchema[] ass = MAcctSchema.getClientAcctSchema(ctx, AD_Client_ID);
MAcctSchema[] ass = MAcctSchema.getClientAcctSchema(ctx, AD_Client_ID); error = Doc.postImmediate(ass, AD_Table_ID, Record_ID, force, trxName);
error = Doc.postImmediate(ass, AD_Table_ID, Record_ID, force, trxName);
return error;
}
// try to get from Server when enabled
if (CConnection.get().isAppsServerOK(true))
{
log.config("trying server");
try
{
Server server = CConnection.get().getServer();
if (server != null)
{
Properties p = Env.getRemoteCallCtx(Env.getCtx());
error = server.postImmediate(p, AD_Client_ID,
AD_Table_ID, Record_ID, force, null); // don't pass transaction to server
log.config("from Server: " + error== null ? "OK" : error);
}
else
{
error = "NoAppsServer";
}
}
catch (Exception e)
{
log.log(Level.WARNING, "(RE)", e);
error = e.getMessage();
}
}
return error; return error;
} // postImmediate } // postImmediate
} // DocumentEnine } // DocumentEnine