remove application server dependency
This commit is contained in:
parent
389d0c94a2
commit
e4d11cfc8f
|
@ -24,7 +24,6 @@ Bundle-ClassPath: base.jar,
|
|||
lib/commons-collections-3.1.jar,
|
||||
lib/activemq-core-5.0.0.jar
|
||||
Export-Package: org.adempiere.apps.graph,
|
||||
org.adempiere.as,
|
||||
org.adempiere.base,
|
||||
org.adempiere.exceptions,
|
||||
org.adempiere.impexp,
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
source.base.jar = src/,build/
|
||||
source.base.jar = src/
|
||||
bin.includes = META-INF/,\
|
||||
base.jar,\
|
||||
plugin.xml
|
||||
jars.extra.classpath = platform:/plugin/org.adempiere.tools/lib/activation.jar,\
|
||||
platform:/plugin/org.adempiere.tools/lib/activemq-core-5.0.0.jar,\
|
||||
jars.extra.classpath = 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-contrib-1.0b1.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/iText-2.1.7.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/jfreechart-1.0.11.jar,\
|
||||
platform:/plugin/org.adempiere.tools/lib/jcommon-1.0.16.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/jnlp.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/mail.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/ojdbc14.jar,\
|
||||
platform:/plugin/org.adempiere.tools/lib/ojdbc6.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/script-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/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/wizard.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/xml-apis.jar
|
||||
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
|
@ -17,27 +17,19 @@
|
|||
package org.compiere.db;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.rmi.RMISecurityManager;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DatabaseMetaData;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Hashtable;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import javax.naming.CommunicationException;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
import javax.naming.NamingException;
|
||||
import javax.sql.DataSource;
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
import org.adempiere.as.ASFactory;
|
||||
import org.adempiere.util.EmbeddedServerProxy;
|
||||
import org.compiere.Adempiere;
|
||||
import org.compiere.interfaces.Server;
|
||||
import org.compiere.interfaces.Status;
|
||||
import org.compiere.util.CLogMgt;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Ini;
|
||||
|
@ -53,7 +45,7 @@ import org.compiere.util.ValueNamePair;
|
|||
public class CConnection implements Serializable, Cloneable
|
||||
{
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -7893119456331485444L;
|
||||
/** Connection */
|
||||
|
@ -81,11 +73,6 @@ public class CConnection implements Serializable, Cloneable
|
|||
@Deprecated
|
||||
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 **/
|
||||
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.setConnectionProfile(CConnection.PROFILE_LAN);
|
||||
cc.setAppsPort(ASFactory.getApplicationServer().getDefaultNamingServicePort());
|
||||
if (cc.testAppsServer() == null)
|
||||
{
|
||||
s_cc = cc;
|
||||
|
@ -210,7 +196,7 @@ public class CConnection implements Serializable, Cloneable
|
|||
/** Application Host */
|
||||
private String m_apps_host = "MyAppsServer";
|
||||
/** Application Port */
|
||||
private int m_apps_port = ASFactory.getApplicationServer().getDefaultNamingServicePort();
|
||||
private int m_apps_port = 0;
|
||||
|
||||
/** Database Type */
|
||||
private String m_type = "";
|
||||
|
@ -222,9 +208,6 @@ public class CConnection implements Serializable, Cloneable
|
|||
/** Database name */
|
||||
private String m_db_name = "MyDBName";
|
||||
|
||||
/** Connection Profile */
|
||||
private String m_connectionProfile = PROFILE_LAN;
|
||||
|
||||
/** In Memory connection */
|
||||
private boolean m_bequeath = false;
|
||||
|
||||
|
@ -264,9 +247,6 @@ public class CConnection implements Serializable, Cloneable
|
|||
/** DB Info */
|
||||
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";
|
||||
|
||||
/*************************************************************************
|
||||
|
@ -314,7 +294,6 @@ public class CConnection implements Serializable, Cloneable
|
|||
m_apps_host = apps_host;
|
||||
m_name = toString ();
|
||||
m_okApps = false;
|
||||
m_queryAppsServer = false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -334,7 +313,6 @@ public class CConnection implements Serializable, Cloneable
|
|||
{
|
||||
m_apps_port = apps_port;
|
||||
m_okApps = false;
|
||||
m_queryAppsServer = false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -363,49 +341,6 @@ public class CConnection implements Serializable, Cloneable
|
|||
*/
|
||||
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;
|
||||
} // isAppsOK
|
||||
|
||||
|
@ -425,32 +360,6 @@ public class CConnection implements Serializable, Cloneable
|
|||
*/
|
||||
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;
|
||||
} // 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
|
||||
* @param useCache if true, use existing cache
|
||||
|
@ -1407,58 +1313,9 @@ public class CConnection implements Serializable, Cloneable
|
|||
*/
|
||||
public InitialContext getInitialContext (boolean useCache)
|
||||
{
|
||||
if (useCache && m_iContext != 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;
|
||||
return null;
|
||||
} // 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.
|
||||
* update okApps
|
||||
|
@ -1466,49 +1323,6 @@ public class CConnection implements Serializable, Cloneable
|
|||
*/
|
||||
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;
|
||||
} // setAppsServerInfo
|
||||
|
||||
|
@ -1614,8 +1428,6 @@ public class CConnection implements Serializable, Cloneable
|
|||
sp.principal = principal;
|
||||
sp.credential = credential;
|
||||
Env.getCtx().put(SECURITY_PRINCIPAL, sp);
|
||||
m_iContext = null;
|
||||
m_env = null;
|
||||
m_server = null;
|
||||
}
|
||||
|
||||
|
@ -1629,26 +1441,6 @@ public class CConnection implements Serializable, Cloneable
|
|||
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
|
||||
* @param args ignored
|
||||
|
|
|
@ -46,7 +46,7 @@ import org.compiere.util.Language;
|
|||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: MClient.java,v 1.2 2006/07/30 00:58:37 jjanke Exp $
|
||||
*
|
||||
*
|
||||
* @author Carlos Ruiz - globalqss
|
||||
* integrate bug fix reported by Teo Sarca
|
||||
* [ 1619085 ] Client setup creates duplicate trees
|
||||
|
@ -56,7 +56,7 @@ import org.compiere.util.Language;
|
|||
public class MClient extends X_AD_Client
|
||||
{
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -6482473737885701403L;
|
||||
|
||||
|
@ -110,7 +110,7 @@ public class MClient extends X_AD_Client
|
|||
/** Cache */
|
||||
private static CCache<Integer,MClient> s_cache = new CCache<Integer,MClient>("AD_Client", 3);
|
||||
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* Standard Constructor
|
||||
* @param ctx context
|
||||
|
@ -130,7 +130,7 @@ public class MClient extends X_AD_Client
|
|||
// setName (null);
|
||||
setAD_Org_ID(0);
|
||||
setIsMultiLingualDocument (false);
|
||||
setIsSmtpAuthorization (false);
|
||||
setIsSmtpAuthorization (false);
|
||||
setIsUseBetaFunctions (true);
|
||||
setIsServerEMail(false);
|
||||
setAD_Language(Language.getBaseAD_Language());
|
||||
|
@ -246,8 +246,8 @@ public class MClient extends X_AD_Client
|
|||
}
|
||||
return m_language;
|
||||
} // getLanguage
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Set AD_Language
|
||||
* @param AD_Language new language
|
||||
|
@ -257,7 +257,7 @@ public class MClient extends X_AD_Client
|
|||
m_language = null;
|
||||
super.setAD_Language (AD_Language);
|
||||
} // setAD_Language
|
||||
|
||||
|
||||
/**
|
||||
* Get AD_Language
|
||||
* @return Language
|
||||
|
@ -281,8 +281,8 @@ public class MClient extends X_AD_Client
|
|||
return lang.getLocale();
|
||||
return Locale.getDefault();
|
||||
} // getLocale
|
||||
|
||||
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* Create Trees and Setup Client Info
|
||||
* @param language language
|
||||
|
@ -390,7 +390,7 @@ public class MClient extends X_AD_Client
|
|||
|
||||
// Create ClientInfo
|
||||
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_Campaign_ID, AD_Tree_Activity_ID, get_TrxName());
|
||||
success = clientInfo.save();
|
||||
|
@ -398,7 +398,7 @@ public class MClient extends X_AD_Client
|
|||
} // 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
|
||||
*/
|
||||
public int getSetup_AD_Tree_Account_ID()
|
||||
|
@ -415,8 +415,8 @@ public class MClient extends X_AD_Client
|
|||
String aa = getAutoArchive();
|
||||
return aa != null && !aa.equals(AUTOARCHIVE_None);
|
||||
} // isAutoArchive
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Update Trl Tables automatically?
|
||||
* @param TableName table name
|
||||
|
@ -433,7 +433,7 @@ public class MClient extends X_AD_Client
|
|||
return false;
|
||||
return true;
|
||||
} // isMultiLingualDocument
|
||||
|
||||
|
||||
/**
|
||||
* Get Primary Accounting Schema
|
||||
* @return Acct Schema or null
|
||||
|
@ -450,7 +450,7 @@ public class MClient extends X_AD_Client
|
|||
}
|
||||
return null;
|
||||
} // getMClientInfo
|
||||
|
||||
|
||||
/**
|
||||
* Save
|
||||
* @return true if saved
|
||||
|
@ -461,8 +461,8 @@ public class MClient extends X_AD_Client
|
|||
return saveUpdate();
|
||||
return super.save ();
|
||||
} // save
|
||||
|
||||
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* Test EMail
|
||||
* @return OK or error
|
||||
|
@ -473,7 +473,7 @@ public class MClient extends X_AD_Client
|
|||
return "No Request EMail for " + getName();
|
||||
//
|
||||
EMail email = createEMail (getRequestEMail(),
|
||||
"Adempiere EMail Test",
|
||||
"Adempiere EMail Test",
|
||||
"Adempiere EMail Test: " + toString());
|
||||
if (email == null)
|
||||
return "Could not create EMail: " + getName();
|
||||
|
@ -500,7 +500,7 @@ public class MClient extends X_AD_Client
|
|||
return ex.getLocalizedMessage();
|
||||
}
|
||||
} // testEMail
|
||||
|
||||
|
||||
/**
|
||||
* Send EMail from Request User - with trace
|
||||
* @param AD_User_ID recipient
|
||||
|
@ -509,7 +509,7 @@ public class MClient extends X_AD_Client
|
|||
* @param attachment optional attachment
|
||||
* @return true if sent
|
||||
*/
|
||||
public boolean sendEMail (int AD_User_ID,
|
||||
public boolean sendEMail (int AD_User_ID,
|
||||
String subject, String message, File attachment)
|
||||
{
|
||||
Collection<File> attachments = new ArrayList<File>();
|
||||
|
@ -517,7 +517,7 @@ public class MClient extends X_AD_Client
|
|||
attachments.add(attachment);
|
||||
return sendEMailAttachments(AD_User_ID, subject, message, attachments);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send EMail from Request User - with trace
|
||||
* @param AD_User_ID recipient
|
||||
|
@ -526,12 +526,12 @@ public class MClient extends X_AD_Client
|
|||
* @param attachment optional collection of attachments
|
||||
* @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)
|
||||
{
|
||||
return sendEMailAttachments(AD_User_ID, subject, message, attachments, false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send EMail from Request User - with trace
|
||||
* @param AD_User_ID recipient
|
||||
|
@ -541,11 +541,11 @@ public class MClient extends X_AD_Client
|
|||
* @param html
|
||||
* @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)
|
||||
{
|
||||
MUser to = MUser.get(getCtx(), AD_User_ID);
|
||||
String toEMail = to.getEMail();
|
||||
String toEMail = to.getEMail();
|
||||
if (toEMail == null || toEMail.length() == 0)
|
||||
{
|
||||
log.warning("No EMail for recipient: " + to);
|
||||
|
@ -565,7 +565,7 @@ public class MClient extends X_AD_Client
|
|||
return false;
|
||||
}
|
||||
} // sendEMail
|
||||
|
||||
|
||||
/**
|
||||
* Send EMail from Request User - no trace
|
||||
* @param to recipient email address
|
||||
|
@ -574,12 +574,12 @@ public class MClient extends X_AD_Client
|
|||
* @param attachment optional attachment
|
||||
* @return true if sent
|
||||
*/
|
||||
public boolean sendEMail (String to,
|
||||
public boolean sendEMail (String to,
|
||||
String subject, String message, File attachment)
|
||||
{
|
||||
return sendEMail(to, subject, message, attachment, false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send EMail from Request User - no trace
|
||||
* @param to recipient email address
|
||||
|
@ -589,7 +589,7 @@ public class MClient extends X_AD_Client
|
|||
* @param html
|
||||
* @return true if sent
|
||||
*/
|
||||
public boolean sendEMail (String to,
|
||||
public boolean sendEMail (String to,
|
||||
String subject, String message, File attachment, boolean html)
|
||||
{
|
||||
EMail email = createEMail(to, subject, message, html);
|
||||
|
@ -607,7 +607,7 @@ public class MClient extends X_AD_Client
|
|||
}
|
||||
else
|
||||
{
|
||||
log.warning("Could NOT Send Email: " + subject
|
||||
log.warning("Could NOT Send Email: " + subject
|
||||
+ " to " + to + ": " + msg
|
||||
+ " (" + getName() + ")");
|
||||
return false;
|
||||
|
@ -629,12 +629,12 @@ public class MClient extends X_AD_Client
|
|||
* @param attachment optional attachment
|
||||
* @return true if sent
|
||||
*/
|
||||
public boolean sendEMail (MUser from, MUser to,
|
||||
public boolean sendEMail (MUser from, MUser to,
|
||||
String subject, String message, File attachment)
|
||||
{
|
||||
return sendEMail(from, to, subject, message, attachment, false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send EMail from User
|
||||
* @param from sender
|
||||
|
@ -645,13 +645,13 @@ public class MClient extends X_AD_Client
|
|||
* @param isHtml
|
||||
* @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)
|
||||
{
|
||||
EMail email = createEMail(from, to, subject, message, isHtml);
|
||||
if (email == null)
|
||||
return false;
|
||||
|
||||
|
||||
if (attachment != null)
|
||||
email.addAttachment(attachment);
|
||||
InternetAddress emailFrom = email.getFrom();
|
||||
|
@ -696,11 +696,11 @@ public class MClient extends X_AD_Client
|
|||
if (email.isSentOK())
|
||||
{
|
||||
if (from != null)
|
||||
log.info("Sent Email: " + email.getSubject()
|
||||
log.info("Sent Email: " + email.getSubject()
|
||||
+ " from " + from.getEMail()
|
||||
+ " to " + to.getEMail());
|
||||
else
|
||||
log.info("Sent Email: " + email.getSubject()
|
||||
log.info("Sent Email: " + email.getSubject()
|
||||
+ " to " + to.getEMail());
|
||||
return true;
|
||||
}
|
||||
|
@ -726,12 +726,12 @@ public class MClient extends X_AD_Client
|
|||
* @param message nessage
|
||||
* @return EMail
|
||||
*/
|
||||
public EMail createEMail (String to,
|
||||
public EMail createEMail (String to,
|
||||
String subject, String message)
|
||||
{
|
||||
return createEMail(to, subject, message, false);
|
||||
}
|
||||
|
||||
|
||||
/************
|
||||
* Create EMail from Request User
|
||||
* @param to recipient
|
||||
|
@ -740,7 +740,7 @@ public class MClient extends X_AD_Client
|
|||
* @param html
|
||||
* @return EMail
|
||||
*/
|
||||
public EMail createEMail (String to,
|
||||
public EMail createEMail (String to,
|
||||
String subject, String message, boolean html)
|
||||
{
|
||||
if (to == null || to.length() == 0)
|
||||
|
@ -759,11 +759,11 @@ public class MClient extends X_AD_Client
|
|||
{ // See ServerBean
|
||||
if (html && message != null)
|
||||
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);
|
||||
}
|
||||
else
|
||||
log.log(Level.WARNING, "No AppsServer");
|
||||
log.log(Level.WARNING, "No AppsServer");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -787,12 +787,12 @@ public class MClient extends X_AD_Client
|
|||
* @param message nessage
|
||||
* @return EMail
|
||||
*/
|
||||
public EMail createEMail (MUser from, MUser to,
|
||||
public EMail createEMail (MUser from, MUser to,
|
||||
String subject, String message)
|
||||
{
|
||||
return createEMail(from, to, subject, message, false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create EMail from User
|
||||
* @param from optional sender
|
||||
|
@ -802,7 +802,7 @@ public class MClient extends X_AD_Client
|
|||
* @param html
|
||||
* @return EMail
|
||||
*/
|
||||
public EMail createEMail (MUser from, MUser to,
|
||||
public EMail createEMail (MUser from, MUser to,
|
||||
String subject, String message, boolean html)
|
||||
{
|
||||
if (to == null)
|
||||
|
@ -817,7 +817,7 @@ public class MClient extends X_AD_Client
|
|||
}
|
||||
return createEMail (from, to.getEMail(), subject, message, html);
|
||||
} // createEMail
|
||||
|
||||
|
||||
/**
|
||||
* Create EMail from User
|
||||
* @param from optional sender
|
||||
|
@ -826,12 +826,12 @@ public class MClient extends X_AD_Client
|
|||
* @param message nessage
|
||||
* @return EMail
|
||||
*/
|
||||
public EMail createEMail (MUser from, String to,
|
||||
public EMail createEMail (MUser from, String to,
|
||||
String subject, String message)
|
||||
{
|
||||
return createEMail(from, to, subject, message, false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create EMail from User
|
||||
* @param from optional sender
|
||||
|
@ -841,7 +841,7 @@ public class MClient extends X_AD_Client
|
|||
* @param html
|
||||
* @return EMail
|
||||
*/
|
||||
public EMail createEMail (MUser from, String to,
|
||||
public EMail createEMail (MUser from, String to,
|
||||
String subject, String message, boolean html)
|
||||
{
|
||||
if (to == null || to.length() == 0)
|
||||
|
@ -853,7 +853,7 @@ public class MClient extends X_AD_Client
|
|||
if (from == null)
|
||||
return createEMail (to, subject, message, html);
|
||||
// No From details - Error
|
||||
if (from.getEMail() == null
|
||||
if (from.getEMail() == null
|
||||
|| from.getEMailUser() == null
|
||||
|| (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);
|
||||
}
|
||||
else
|
||||
log.log(Level.WARNING, "No AppsServer");
|
||||
log.log(Level.WARNING, "No AppsServer");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -885,9 +885,9 @@ public class MClient extends X_AD_Client
|
|||
}
|
||||
if (email == null)
|
||||
email = new EMail (this,
|
||||
from.getEMail(),
|
||||
from.getEMail(),
|
||||
to,
|
||||
subject,
|
||||
subject,
|
||||
message, html);
|
||||
if (isSmtpAuthorization())
|
||||
email.createAuthenticator (from.getEMailUser(), from.getEMailUserPW());
|
||||
|
@ -900,7 +900,7 @@ public class MClient extends X_AD_Client
|
|||
* D - Disabled (default)
|
||||
* Q - Queue (enabled to post by hand - queue documents for posterior processing)
|
||||
* I - Immediate (immediate post - allow complete on errors)
|
||||
*
|
||||
*
|
||||
* @return boolean representing if client accounting is enabled and it's on a client
|
||||
*/
|
||||
private static final String CLIENT_ACCOUNTING_DISABLED = "D";
|
||||
|
@ -909,21 +909,21 @@ public class MClient extends X_AD_Client
|
|||
|
||||
public static boolean isClientAccounting() {
|
||||
String ca = MSysConfig.getValue("CLIENT_ACCOUNTING",
|
||||
CLIENT_ACCOUNTING_DISABLED, // default
|
||||
CLIENT_ACCOUNTING_QUEUE, // default
|
||||
Env.getAD_Client_ID(Env.getCtx()));
|
||||
return (ca.equalsIgnoreCase(CLIENT_ACCOUNTING_IMMEDIATE) || ca.equalsIgnoreCase(CLIENT_ACCOUNTING_QUEUE));
|
||||
}
|
||||
|
||||
public static boolean isClientAccountingQueue() {
|
||||
String ca = MSysConfig.getValue("CLIENT_ACCOUNTING",
|
||||
CLIENT_ACCOUNTING_DISABLED, // default
|
||||
CLIENT_ACCOUNTING_QUEUE, // default
|
||||
Env.getAD_Client_ID(Env.getCtx()));
|
||||
return ca.equalsIgnoreCase(CLIENT_ACCOUNTING_QUEUE);
|
||||
}
|
||||
|
||||
public static boolean isClientAccountingImmediate() {
|
||||
String ca = MSysConfig.getValue("CLIENT_ACCOUNTING",
|
||||
CLIENT_ACCOUNTING_DISABLED, // default
|
||||
CLIENT_ACCOUNTING_QUEUE, // default
|
||||
Env.getAD_Client_ID(Env.getCtx()));
|
||||
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()
|
||||
+ " AND ce.IsActive = 'Y' "
|
||||
+ " AND ce.AD_Field_ID IS NOT NULL "
|
||||
+ " AND ce.ASP_Status = 'H')"
|
||||
+ " AND ce.ASP_Status = 'H')"
|
||||
+ " ORDER BY AD_Field_ID";
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
|
|
|
@ -55,8 +55,8 @@ import org.eevolution.model.I_PP_Order;
|
|||
|
||||
/**
|
||||
* Document Action Engine
|
||||
*
|
||||
* @author Jorg Janke
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @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
|
||||
* @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);
|
||||
} // DocActionEngine
|
||||
|
||||
|
||||
/**
|
||||
* Doc Engine
|
||||
* @param po document
|
||||
|
@ -92,10 +92,10 @@ public class DocumentEngine implements DocAction
|
|||
private String m_message = null;
|
||||
/** Actual Doc Action */
|
||||
private String m_action = null;
|
||||
|
||||
|
||||
/** Logger */
|
||||
private static CLogger log = CLogger.getCLogger(DocumentEngine.class);
|
||||
|
||||
|
||||
/**
|
||||
* Get Doc Status
|
||||
* @return document status
|
||||
|
@ -122,7 +122,7 @@ public class DocumentEngine implements DocAction
|
|||
{
|
||||
return STATUS_Drafted.equals(m_status);
|
||||
} // isDrafted
|
||||
|
||||
|
||||
/**
|
||||
* Document is Invalid
|
||||
* @return true if Invalid
|
||||
|
@ -131,7 +131,7 @@ public class DocumentEngine implements DocAction
|
|||
{
|
||||
return STATUS_Invalid.equals(m_status);
|
||||
} // isInvalid
|
||||
|
||||
|
||||
/**
|
||||
* Document is In Progress
|
||||
* @return true if In Progress
|
||||
|
@ -140,7 +140,7 @@ public class DocumentEngine implements DocAction
|
|||
{
|
||||
return STATUS_InProgress.equals(m_status);
|
||||
} // isInProgress
|
||||
|
||||
|
||||
/**
|
||||
* Document is Approved
|
||||
* @return true if Approved
|
||||
|
@ -149,7 +149,7 @@ public class DocumentEngine implements DocAction
|
|||
{
|
||||
return STATUS_Approved.equals(m_status);
|
||||
} // isApproved
|
||||
|
||||
|
||||
/**
|
||||
* Document is Not Approved
|
||||
* @return true if Not Approved
|
||||
|
@ -158,7 +158,7 @@ public class DocumentEngine implements DocAction
|
|||
{
|
||||
return STATUS_NotApproved.equals(m_status);
|
||||
} // isNotApproved
|
||||
|
||||
|
||||
/**
|
||||
* Document is Waiting Payment or Confirmation
|
||||
* @return true if Waiting Payment
|
||||
|
@ -168,7 +168,7 @@ public class DocumentEngine implements DocAction
|
|||
return STATUS_WaitingPayment.equals(m_status)
|
||||
|| STATUS_WaitingConfirmation.equals(m_status);
|
||||
} // isWaitingPayment
|
||||
|
||||
|
||||
/**
|
||||
* Document is Completed
|
||||
* @return true if Completed
|
||||
|
@ -177,7 +177,7 @@ public class DocumentEngine implements DocAction
|
|||
{
|
||||
return STATUS_Completed.equals(m_status);
|
||||
} // isCompleted
|
||||
|
||||
|
||||
/**
|
||||
* Document is Reversed
|
||||
* @return true if Reversed
|
||||
|
@ -186,7 +186,7 @@ public class DocumentEngine implements DocAction
|
|||
{
|
||||
return STATUS_Reversed.equals(m_status);
|
||||
} // isReversed
|
||||
|
||||
|
||||
/**
|
||||
* Document is Closed
|
||||
* @return true if Closed
|
||||
|
@ -195,7 +195,7 @@ public class DocumentEngine implements DocAction
|
|||
{
|
||||
return STATUS_Closed.equals(m_status);
|
||||
} // isClosed
|
||||
|
||||
|
||||
/**
|
||||
* Document is Voided
|
||||
* @return true if Voided
|
||||
|
@ -204,23 +204,23 @@ public class DocumentEngine implements DocAction
|
|||
{
|
||||
return STATUS_Voided.equals(m_status);
|
||||
} // isVoided
|
||||
|
||||
|
||||
/**
|
||||
* Document Status is Unknown
|
||||
* @return true if unknown
|
||||
*/
|
||||
public boolean isUnknown()
|
||||
{
|
||||
return STATUS_Unknown.equals(m_status) ||
|
||||
return STATUS_Unknown.equals(m_status) ||
|
||||
!(isDrafted() || isInvalid() || isInProgress() || isNotApproved()
|
||||
|| isApproved() || isWaiting() || isCompleted()
|
||||
|| isReversed() || isClosed() || isVoided() );
|
||||
} // isUnknown
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @param processAction document action based on workflow
|
||||
* @param docAction document action based on document
|
||||
|
@ -231,7 +231,7 @@ public class DocumentEngine implements DocAction
|
|||
m_message = null;
|
||||
m_action = null;
|
||||
// Std User Workflows - see MWFNodeNext.isValidFor
|
||||
|
||||
|
||||
if (isValidAction(processAction)) // WF Selection first
|
||||
m_action = processAction;
|
||||
//
|
||||
|
@ -243,11 +243,11 @@ public class DocumentEngine implements DocAction
|
|||
{
|
||||
if (m_document != null)
|
||||
m_document.get_Logger().info ("**** No Action (Prc=" + processAction + "/Doc=" + docAction + ") " + m_document);
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalStateException("Status=" + getDocStatus()
|
||||
throw new IllegalStateException("Status=" + getDocStatus()
|
||||
+ " - Invalid Actions: Process=" + processAction + ", Doc=" + docAction);
|
||||
}
|
||||
if (m_document != null)
|
||||
|
@ -257,7 +257,7 @@ public class DocumentEngine implements DocAction
|
|||
m_document.get_Logger().fine("**** Action=" + m_action + " - Success=" + success);
|
||||
return success;
|
||||
} // process
|
||||
|
||||
|
||||
/**
|
||||
* Process actual document - do not call directly.
|
||||
* Calls the individual actions which call the document action
|
||||
|
@ -312,12 +312,12 @@ public class DocumentEngine implements DocAction
|
|||
docafter.save();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (STATUS_Completed.equals(status) && MClient.isClientAccountingImmediate())
|
||||
{
|
||||
m_document.save();
|
||||
postIt();
|
||||
|
||||
|
||||
if (m_document instanceof PO && docsPostProcess.size() > 0) {
|
||||
for (PO docafter : docsPostProcess) {
|
||||
@SuppressWarnings("unused")
|
||||
|
@ -344,11 +344,11 @@ public class DocumentEngine implements DocAction
|
|||
//
|
||||
return false;
|
||||
} // processDocument
|
||||
|
||||
|
||||
/**
|
||||
* Unlock Document.
|
||||
* Status: Drafted
|
||||
* @return true if success
|
||||
* @return true if success
|
||||
* @see org.compiere.process.DocAction#unlockIt()
|
||||
*/
|
||||
public boolean unlockIt()
|
||||
|
@ -368,11 +368,11 @@ public class DocumentEngine implements DocAction
|
|||
m_status = STATUS_Drafted;
|
||||
return true;
|
||||
} // unlockIt
|
||||
|
||||
|
||||
/**
|
||||
* Invalidate Document.
|
||||
* Status: Invalid
|
||||
* @return true if success
|
||||
* @return true if success
|
||||
* @see org.compiere.process.DocAction#invalidateIt()
|
||||
*/
|
||||
public boolean invalidateIt()
|
||||
|
@ -392,11 +392,11 @@ public class DocumentEngine implements DocAction
|
|||
m_status = STATUS_Invalid;
|
||||
return true;
|
||||
} // invalidateIt
|
||||
|
||||
|
||||
/**
|
||||
* Process Document.
|
||||
* 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()
|
||||
*/
|
||||
public String prepareIt()
|
||||
|
@ -414,7 +414,7 @@ public class DocumentEngine implements DocAction
|
|||
/**
|
||||
* Approve Document.
|
||||
* Status: Approved
|
||||
* @return true if success
|
||||
* @return true if success
|
||||
* @see org.compiere.process.DocAction#approveIt()
|
||||
*/
|
||||
public boolean approveIt()
|
||||
|
@ -434,11 +434,11 @@ public class DocumentEngine implements DocAction
|
|||
m_status = STATUS_Approved;
|
||||
return true;
|
||||
} // approveIt
|
||||
|
||||
|
||||
/**
|
||||
* Reject Approval.
|
||||
* Status: Not Approved
|
||||
* @return true if success
|
||||
* @return true if success
|
||||
* @see org.compiere.process.DocAction#rejectIt()
|
||||
*/
|
||||
public boolean rejectIt()
|
||||
|
@ -458,7 +458,7 @@ public class DocumentEngine implements DocAction
|
|||
m_status = STATUS_NotApproved;
|
||||
return true;
|
||||
} // rejectIt
|
||||
|
||||
|
||||
/**
|
||||
* Complete Document.
|
||||
* Status is set by process
|
||||
|
@ -476,26 +476,26 @@ public class DocumentEngine implements DocAction
|
|||
}
|
||||
return m_status;
|
||||
} // completeIt
|
||||
|
||||
|
||||
/**
|
||||
* Post Document
|
||||
* Does not change status
|
||||
* @return true if success
|
||||
* @return true if success
|
||||
*/
|
||||
public boolean postIt()
|
||||
{
|
||||
if (!isValidAction(ACTION_Post)
|
||||
if (!isValidAction(ACTION_Post)
|
||||
|| m_document == null)
|
||||
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());
|
||||
return (error == null);
|
||||
} // postIt
|
||||
|
||||
|
||||
/**
|
||||
* Void Document.
|
||||
* Status: Voided
|
||||
* @return true if success
|
||||
* @return true if success
|
||||
* @see org.compiere.process.DocAction#voidIt()
|
||||
*/
|
||||
public boolean voidIt()
|
||||
|
@ -515,11 +515,11 @@ public class DocumentEngine implements DocAction
|
|||
m_status = STATUS_Voided;
|
||||
return true;
|
||||
} // voidIt
|
||||
|
||||
|
||||
/**
|
||||
* Close Document.
|
||||
* Status: Closed
|
||||
* @return true if success
|
||||
* @return true if success
|
||||
* @see org.compiere.process.DocAction#closeIt()
|
||||
*/
|
||||
public boolean closeIt()
|
||||
|
@ -542,11 +542,11 @@ public class DocumentEngine implements DocAction
|
|||
m_status = STATUS_Closed;
|
||||
return true;
|
||||
} // closeIt
|
||||
|
||||
|
||||
/**
|
||||
* Reverse Correct Document.
|
||||
* Status: Reversed
|
||||
* @return true if success
|
||||
* @return true if success
|
||||
* @see org.compiere.process.DocAction#reverseCorrectIt()
|
||||
*/
|
||||
public boolean reverseCorrectIt()
|
||||
|
@ -566,11 +566,11 @@ public class DocumentEngine implements DocAction
|
|||
m_status = STATUS_Reversed;
|
||||
return true;
|
||||
} // reverseCorrectIt
|
||||
|
||||
|
||||
/**
|
||||
* Reverse Accrual Document.
|
||||
* Status: Reversed
|
||||
* @return true if success
|
||||
* @return true if success
|
||||
* @see org.compiere.process.DocAction#reverseAccrualIt()
|
||||
*/
|
||||
public boolean reverseAccrualIt()
|
||||
|
@ -590,11 +590,11 @@ public class DocumentEngine implements DocAction
|
|||
m_status = STATUS_Reversed;
|
||||
return true;
|
||||
} // reverseAccrualIt
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Re-activate Document.
|
||||
* Status: In Progress
|
||||
* @return true if success
|
||||
* @return true if success
|
||||
* @see org.compiere.process.DocAction#reActivateIt()
|
||||
*/
|
||||
public boolean reActivateIt()
|
||||
|
@ -615,7 +615,7 @@ public class DocumentEngine implements DocAction
|
|||
return true;
|
||||
} // reActivateIt
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Set Document Status to new Status
|
||||
* @param newStatus new status
|
||||
|
@ -625,7 +625,7 @@ public class DocumentEngine implements DocAction
|
|||
m_status = newStatus;
|
||||
} // setStatus
|
||||
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* Get Action Options based on current Status
|
||||
* @return array of actions
|
||||
|
@ -633,37 +633,37 @@ public class DocumentEngine implements DocAction
|
|||
public String[] getActionOptions()
|
||||
{
|
||||
if (isInvalid())
|
||||
return new String[] {ACTION_Prepare, ACTION_Invalidate,
|
||||
return new String[] {ACTION_Prepare, ACTION_Invalidate,
|
||||
ACTION_Unlock, ACTION_Void};
|
||||
|
||||
if (isDrafted())
|
||||
return new String[] {ACTION_Prepare, ACTION_Invalidate, ACTION_Complete,
|
||||
return new String[] {ACTION_Prepare, ACTION_Invalidate, ACTION_Complete,
|
||||
ACTION_Unlock, ACTION_Void};
|
||||
|
||||
|
||||
if (isInProgress() || isApproved())
|
||||
return new String[] {ACTION_Complete, ACTION_WaitComplete,
|
||||
ACTION_Approve, ACTION_Reject,
|
||||
return new String[] {ACTION_Complete, ACTION_WaitComplete,
|
||||
ACTION_Approve, ACTION_Reject,
|
||||
ACTION_Unlock, ACTION_Void, ACTION_Prepare};
|
||||
|
||||
|
||||
if (isNotApproved())
|
||||
return new String[] {ACTION_Reject, ACTION_Prepare,
|
||||
return new String[] {ACTION_Reject, ACTION_Prepare,
|
||||
ACTION_Unlock, ACTION_Void};
|
||||
|
||||
|
||||
if (isWaiting())
|
||||
return new String[] {ACTION_Complete, ACTION_WaitComplete,
|
||||
ACTION_ReActivate, ACTION_Void, ACTION_Close};
|
||||
|
||||
|
||||
if (isCompleted())
|
||||
return new String[] {ACTION_Close, ACTION_ReActivate,
|
||||
ACTION_Reverse_Accrual, ACTION_Reverse_Correct,
|
||||
return new String[] {ACTION_Close, ACTION_ReActivate,
|
||||
ACTION_Reverse_Accrual, ACTION_Reverse_Correct,
|
||||
ACTION_Post, ACTION_Void};
|
||||
|
||||
|
||||
if (isClosed())
|
||||
return new String[] {ACTION_Post, ACTION_ReOpen};
|
||||
|
||||
|
||||
if (isReversed() || isVoided())
|
||||
return new String[] {ACTION_Post};
|
||||
|
||||
|
||||
return new String[] {};
|
||||
} // getActionOptions
|
||||
|
||||
|
@ -691,7 +691,7 @@ public class DocumentEngine implements DocAction
|
|||
{
|
||||
return m_message;
|
||||
} // getProcessMsg
|
||||
|
||||
|
||||
/**
|
||||
* Get Process Message
|
||||
* @param msg clear text error message
|
||||
|
@ -700,11 +700,11 @@ public class DocumentEngine implements DocAction
|
|||
{
|
||||
m_message = msg;
|
||||
} // setProcessMsg
|
||||
|
||||
|
||||
|
||||
|
||||
/** 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
|
||||
* @return throw exception
|
||||
|
@ -713,7 +713,7 @@ public class DocumentEngine implements DocAction
|
|||
{
|
||||
throw new IllegalStateException(EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Document No
|
||||
* @return throw exception
|
||||
|
@ -740,7 +740,7 @@ public class DocumentEngine implements DocAction
|
|||
{
|
||||
throw new IllegalStateException(EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Document Currency
|
||||
* @return throw exception
|
||||
|
@ -776,7 +776,7 @@ public class DocumentEngine implements DocAction
|
|||
{
|
||||
throw new IllegalStateException(EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Doc Action
|
||||
* @return Document Action
|
||||
|
@ -794,7 +794,7 @@ public class DocumentEngine implements DocAction
|
|||
{
|
||||
throw new IllegalStateException(EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Context
|
||||
* @return context
|
||||
|
@ -816,7 +816,7 @@ public class DocumentEngine implements DocAction
|
|||
return m_document.get_ID();
|
||||
throw new IllegalStateException(EXCEPTION_MSG);
|
||||
} // get_ID
|
||||
|
||||
|
||||
/**
|
||||
* Get AD_Table_ID
|
||||
* @return AD_Table_ID
|
||||
|
@ -827,7 +827,7 @@ public class DocumentEngine implements DocAction
|
|||
return m_document.get_Table_ID();
|
||||
throw new IllegalStateException(EXCEPTION_MSG);
|
||||
} // get_Table_ID
|
||||
|
||||
|
||||
/**
|
||||
* Get Logger
|
||||
* @return logger
|
||||
|
@ -856,9 +856,9 @@ public class DocumentEngine implements DocAction
|
|||
{
|
||||
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.
|
||||
* @param docStatus
|
||||
* @param processing
|
||||
|
@ -869,16 +869,16 @@ public class DocumentEngine implements DocAction
|
|||
* @param 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)
|
||||
{
|
||||
if (options == null)
|
||||
throw new IllegalArgumentException("Option array parameter is null");
|
||||
if (docAction == null)
|
||||
throw new IllegalArgumentException("Doc action array parameter is null");
|
||||
|
||||
|
||||
int index = 0;
|
||||
|
||||
|
||||
// Locked
|
||||
if (processing != null)
|
||||
{
|
||||
|
@ -923,8 +923,8 @@ public class DocumentEngine implements DocAction
|
|||
options[index++] = DocumentEngine.ACTION_Prepare;
|
||||
}
|
||||
// Closed, Voided, REversed .. CL/VO/RE
|
||||
else if (docStatus.equals(DocumentEngine.STATUS_Closed)
|
||||
|| docStatus.equals(DocumentEngine.STATUS_Voided)
|
||||
else if (docStatus.equals(DocumentEngine.STATUS_Closed)
|
||||
|| docStatus.equals(DocumentEngine.STATUS_Voided)
|
||||
|| docStatus.equals(DocumentEngine.STATUS_Reversed))
|
||||
return 0;
|
||||
|
||||
|
@ -1132,7 +1132,7 @@ public class DocumentEngine implements DocAction
|
|||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fill Vector with DocAction Ref_List(135) values
|
||||
* @param v_value
|
||||
|
@ -1142,13 +1142,13 @@ public class DocumentEngine implements DocAction
|
|||
public static void readReferenceList(ArrayList<String> v_value, ArrayList<String> v_name,
|
||||
ArrayList<String> v_description)
|
||||
{
|
||||
if (v_value == null)
|
||||
if (v_value == null)
|
||||
throw new IllegalArgumentException("v_value parameter is null");
|
||||
if (v_name == null)
|
||||
throw new IllegalArgumentException("v_name parameter is null");
|
||||
if (v_description == null)
|
||||
throw new IllegalArgumentException("v_description parameter is null");
|
||||
|
||||
|
||||
String sql;
|
||||
if (Env.isBaseLanguage(Env.getCtx(), "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) {
|
||||
return MRole.get(Env.getCtx(), roleId).checkActionAccess(clientId, docTypeId, options, maxIndex);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Post Immediate
|
||||
*
|
||||
|
@ -1210,48 +1210,18 @@ public class DocumentEngine implements DocAction
|
|||
* @param trxName ignore, retained for backward compatibility
|
||||
* @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)
|
||||
{
|
||||
// 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)
|
||||
return null;
|
||||
|
||||
|
||||
String error = null;
|
||||
if (MClient.isClientAccounting()) {
|
||||
log.info ("Table=" + AD_Table_ID + ", Record=" + Record_ID);
|
||||
MAcctSchema[] ass = MAcctSchema.getClientAcctSchema(ctx, AD_Client_ID);
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
log.info ("Table=" + AD_Table_ID + ", Record=" + Record_ID);
|
||||
MAcctSchema[] ass = MAcctSchema.getClientAcctSchema(ctx, AD_Client_ID);
|
||||
error = Doc.postImmediate(ass, AD_Table_ID, Record_ID, force, trxName);
|
||||
return error;
|
||||
} // postImmediate
|
||||
|
||||
|
||||
} // DocumentEnine
|
||||
|
|
Loading…
Reference in New Issue