Migrated Server and Status client interface to equinox extension.
This commit is contained in:
parent
3c1f8d98fb
commit
59de85428c
|
@ -29,6 +29,7 @@ Export-Package: com.akunagroup.uk.postcode,
|
|||
org.compiere.dbPort,
|
||||
org.compiere.impexp,
|
||||
org.compiere.interfaces,
|
||||
org.compiere.interfaces.impl,
|
||||
org.compiere.model,
|
||||
org.compiere.print,
|
||||
org.compiere.print.layout,
|
||||
|
@ -46,5 +47,7 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
|||
Eclipse-ExtensibleAPI: true
|
||||
Import-Package: net.sf.cglib.proxy,
|
||||
org.eclipse.core.runtime;version="3.4.0",
|
||||
org.osgi.framework
|
||||
org.osgi.framework,
|
||||
org.restlet.representation,
|
||||
org.restlet.util
|
||||
|
||||
|
|
|
@ -7,5 +7,7 @@
|
|||
<extension-point id="org.adempiere.base.Process" name="Process" schema="schema/org.adempiere.base.Process.exsd"/>
|
||||
<extension-point id="org.adempiere.base.ModelValidator" name="Model Validator" schema="schema/org.adempiere.base.ModelValidator.exsd"/>
|
||||
<extension-point id="org.compiere.db.AdempiereDatabase" name="Adempiere Database Interface" schema="schema/org.compiere.db.AdempiereDatabase.exsd"/>
|
||||
<extension-point id="org.compiere.interfaces.Server" name="Server Interface" schema="schema/org.compiere.interfaces.Server.exsd"/>
|
||||
<extension-point id="org.compiere.interfaces.Status" name="Status interface" schema="schema/org.compiere.interfaces.Status.exsd"/>
|
||||
|
||||
</plugin>
|
||||
|
|
|
@ -0,0 +1,102 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<!-- Schema file written by PDE -->
|
||||
<schema targetNamespace="org.adempiere.base" xmlns="http://www.w3.org/2001/XMLSchema">
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.schema plugin="org.adempiere.base" id="org.compiere.interfaces.Server" name="Server Interface"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
[Enter description of this extension point.]
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<element name="extension">
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.element />
|
||||
</appinfo>
|
||||
</annotation>
|
||||
<complexType>
|
||||
<choice>
|
||||
<element ref="interface"/>
|
||||
</choice>
|
||||
<attribute name="point" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="id" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="name" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
<appinfo>
|
||||
<meta.attribute translatable="true"/>
|
||||
</appinfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="interface">
|
||||
<complexType>
|
||||
<attribute name="class" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
<appinfo>
|
||||
<meta.attribute kind="java" basedOn=":org.compiere.interfaces.Server"/>
|
||||
</appinfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.section type="since"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
[Enter the first release in which this extension point appears.]
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.section type="examples"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
[Enter extension point usage example here.]
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.section type="apiinfo"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
[Enter API information here.]
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.section type="implementation"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
[Enter information about supplied implementation of this extension point.]
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
|
||||
</schema>
|
|
@ -0,0 +1,102 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<!-- Schema file written by PDE -->
|
||||
<schema targetNamespace="org.adempiere.base" xmlns="http://www.w3.org/2001/XMLSchema">
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.schema plugin="org.adempiere.base" id="org.compiere.interfaces.Status" name="Status interface"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
[Enter description of this extension point.]
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<element name="extension">
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.element />
|
||||
</appinfo>
|
||||
</annotation>
|
||||
<complexType>
|
||||
<choice>
|
||||
<element ref="interface"/>
|
||||
</choice>
|
||||
<attribute name="point" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="id" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="name" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
<appinfo>
|
||||
<meta.attribute translatable="true"/>
|
||||
</appinfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="interface">
|
||||
<complexType>
|
||||
<attribute name="class" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
<appinfo>
|
||||
<meta.attribute kind="java" basedOn=":org.compiere.interfaces.Status"/>
|
||||
</appinfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.section type="since"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
[Enter the first release in which this extension point appears.]
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.section type="examples"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
[Enter extension point usage example here.]
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.section type="apiinfo"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
[Enter API information here.]
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.section type="implementation"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
[Enter information about supplied implementation of this extension point.]
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
|
||||
</schema>
|
|
@ -0,0 +1,59 @@
|
|||
/******************************************************************************
|
||||
* Copyright (C) 2010 Low Heng Sin All Rights Reserved. *
|
||||
* 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.io.ObjectInputStream;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.util.CLogger;
|
||||
import org.restlet.representation.InputRepresentation;
|
||||
import org.restlet.representation.ObjectRepresentation;
|
||||
import org.restlet.representation.Representation;
|
||||
import org.restlet.util.WrapperRepresentation;
|
||||
|
||||
/**
|
||||
* Utility method for restlet support.
|
||||
* @author hengsin
|
||||
*
|
||||
*/
|
||||
public class RestletUtil {
|
||||
|
||||
public final static CLogger log = CLogger.getCLogger(RestletUtil.class);
|
||||
|
||||
/**
|
||||
* Convert response or request representation to java object.
|
||||
* @param entity
|
||||
* @return T
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T toObject(Representation entity) {
|
||||
try {
|
||||
if (entity instanceof WrapperRepresentation) {
|
||||
entity = ((WrapperRepresentation)entity).getWrappedRepresentation();
|
||||
}
|
||||
if (entity instanceof ObjectRepresentation<?>) {
|
||||
ObjectRepresentation<?> or = (ObjectRepresentation<?>) entity;
|
||||
return (T) or.getObject();
|
||||
} else if (entity instanceof InputRepresentation) {
|
||||
InputRepresentation ir = (InputRepresentation) entity;
|
||||
ObjectInputStream ois = new ObjectInputStream(ir.getStream());
|
||||
return (T) ois.readObject();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.log(Level.SEVERE, e.getLocalizedMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -26,11 +26,11 @@ import javax.naming.InitialContext;
|
|||
import javax.sql.DataSource;
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
import org.adempiere.base.Service;
|
||||
import org.compiere.Adempiere;
|
||||
import org.compiere.interfaces.Server;
|
||||
import org.compiere.interfaces.Status;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Ini;
|
||||
import org.compiere.util.ValueNamePair;
|
||||
|
||||
|
@ -72,9 +72,6 @@ public class CConnection implements Serializable, Cloneable
|
|||
@Deprecated
|
||||
public static final String PROFILE_WAN = "W";
|
||||
|
||||
/** System property flag to embed server bean in process **/
|
||||
public final static String SERVER_EMBEDDED = "org.adempiere.server.embedded";
|
||||
|
||||
/**
|
||||
* Get/Set default client/server Connection
|
||||
* @return Connection Descriptor
|
||||
|
@ -98,7 +95,7 @@ public class CConnection implements Serializable, Cloneable
|
|||
{
|
||||
//hengsin, zero setup for webstart client
|
||||
CConnection cc = null;
|
||||
if (apps_host != null && Adempiere.isWebStartClient() && !CConnection.isServerEmbedded())
|
||||
if (apps_host != null && Adempiere.isWebStartClient())
|
||||
{
|
||||
cc = new CConnection(apps_host);
|
||||
cc.setConnectionProfile(CConnection.PROFILE_LAN);
|
||||
|
@ -238,8 +235,10 @@ public class CConnection implements Serializable, Cloneable
|
|||
private Server m_server = null;
|
||||
/** DB Info */
|
||||
private String m_dbInfo = null;
|
||||
|
||||
private final static String SECURITY_PRINCIPAL = "org.adempiere.security.principal";
|
||||
private int m_webPort;
|
||||
private int m_sslPort;
|
||||
private boolean m_queryAppsServer;
|
||||
private SecurityPrincipal securityPrincipal;
|
||||
|
||||
/*************************************************************************
|
||||
* Get Name
|
||||
|
@ -262,7 +261,7 @@ public class CConnection implements Serializable, Cloneable
|
|||
/**
|
||||
* Set Name
|
||||
*/
|
||||
protected void setName ()
|
||||
public void setName ()
|
||||
{
|
||||
m_name = toString ();
|
||||
} // setName
|
||||
|
@ -288,6 +287,78 @@ public class CConnection implements Serializable, Cloneable
|
|||
m_okApps = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return web port
|
||||
*/
|
||||
public int getWebPort()
|
||||
{
|
||||
return m_webPort;
|
||||
}
|
||||
|
||||
/**
|
||||
* set web port
|
||||
* @param webPort
|
||||
*/
|
||||
public void setWebPort(int webPort)
|
||||
{
|
||||
m_webPort = webPort;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Web Port
|
||||
* @param webPortString web port as String
|
||||
*/
|
||||
public void setWebPort (String webPortString)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (webPortString == null || webPortString.length() == 0)
|
||||
;
|
||||
else
|
||||
setWebPort (Integer.parseInt (webPortString));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.severe(e.toString ());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ssl port
|
||||
*/
|
||||
public int getSSLPort()
|
||||
{
|
||||
return m_sslPort;
|
||||
}
|
||||
|
||||
/**
|
||||
* set ssl port
|
||||
* @param sslPort
|
||||
*/
|
||||
public void setSSLPort(int sslPort)
|
||||
{
|
||||
m_sslPort = sslPort;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set SSL Port
|
||||
* @param sslPortString web port as String
|
||||
*/
|
||||
public void setSSLPort (String sslPortString)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (sslPortString == null || sslPortString.length() == 0)
|
||||
;
|
||||
else
|
||||
setSSLPort (Integer.parseInt (sslPortString));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.severe(e.toString ());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Is Application Server OK
|
||||
* @param tryContactAgain try to contact again
|
||||
|
@ -295,6 +366,26 @@ public class CConnection implements Serializable, Cloneable
|
|||
*/
|
||||
public boolean isAppsServerOK (boolean tryContactAgain)
|
||||
{
|
||||
if (!tryContactAgain && m_queryAppsServer)
|
||||
return m_okApps;
|
||||
|
||||
if (getAppServerCredential() == null)
|
||||
{
|
||||
m_okApps = false;
|
||||
return m_okApps;
|
||||
}
|
||||
|
||||
m_queryAppsServer = true;
|
||||
|
||||
try
|
||||
{
|
||||
Status status = Service.locate(Status.class);
|
||||
m_version = status.getDateVersion();
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
m_okApps = false;
|
||||
}
|
||||
return m_okApps;
|
||||
} // isAppsOK
|
||||
|
||||
|
@ -304,6 +395,7 @@ public class CConnection implements Serializable, Cloneable
|
|||
*/
|
||||
public synchronized Exception testAppsServer ()
|
||||
{
|
||||
m_appsException = null;
|
||||
queryAppsServerInfo();
|
||||
return getAppsServerException ();
|
||||
} // testAppsServer
|
||||
|
@ -314,6 +406,10 @@ public class CConnection implements Serializable, Cloneable
|
|||
*/
|
||||
public Server getServer()
|
||||
{
|
||||
if (m_server == null)
|
||||
{
|
||||
m_server = Service.locate(Server.class);
|
||||
}
|
||||
return m_server;
|
||||
} // getServer
|
||||
|
||||
|
@ -957,23 +1053,35 @@ public class CConnection implements Serializable, Cloneable
|
|||
public String toStringLong ()
|
||||
{
|
||||
StringBuffer sb = new StringBuffer ("CConnection[");
|
||||
sb.append ("name=").append (m_name)
|
||||
.append (",AppsHost=").append (m_apps_host)
|
||||
.append (",type=").append (m_type)
|
||||
.append (",DBhost=").append (m_db_host)
|
||||
sb.append ("name=").append (escape(m_name))
|
||||
.append (",AppsHost=").append (escape(m_apps_host))
|
||||
.append (",WebPort=").append (m_webPort)
|
||||
.append (",SSLPort=").append (m_sslPort)
|
||||
.append (",type=").append (escape(m_type))
|
||||
.append (",DBhost=").append (escape(m_db_host))
|
||||
.append (",DBport=").append (m_db_port)
|
||||
.append (",DBname=").append (m_db_name)
|
||||
.append (",DBname=").append (escape(m_db_name))
|
||||
.append (",BQ=").append (m_bequeath)
|
||||
.append (",FW=").append (m_firewall)
|
||||
.append (",FWhost=").append (m_fw_host)
|
||||
.append (",FWhost=").append (escape(m_fw_host))
|
||||
.append (",FWport=").append (m_fw_port)
|
||||
.append (",UID=").append (m_db_uid)
|
||||
.append (",PWD=").append (m_db_pwd)
|
||||
.append (",UID=").append (escape(m_db_uid))
|
||||
.append (",PWD=").append (escape(m_db_pwd))
|
||||
.append("]");
|
||||
; // the format is read by setAttributes
|
||||
sb.append ("]");
|
||||
return sb.toString ();
|
||||
} // toStringLong
|
||||
|
||||
private String escape(String value) {
|
||||
if (value == null)
|
||||
return null;
|
||||
|
||||
// use html like escape sequence to escape = and ,
|
||||
value = value.replace("=", "&eq;");
|
||||
value = value.replace(",", ",");
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Attributes from String (pares toStringLong())
|
||||
* @param attributes attributes
|
||||
|
@ -982,22 +1090,70 @@ public class CConnection implements Serializable, Cloneable
|
|||
{
|
||||
try
|
||||
{
|
||||
setName (attributes.substring (attributes.indexOf ("name=") + 5, attributes.indexOf (",AppsHost=")));
|
||||
setAppsHost (attributes.substring (attributes.indexOf ("AppsHost=") + 9, attributes.indexOf (",type=")));
|
||||
//
|
||||
setType (attributes.substring (attributes.indexOf ("type=")+5, attributes.indexOf (",DBhost=")));
|
||||
setDbHost (attributes.substring (attributes.indexOf ("DBhost=") + 7, attributes.indexOf (",DBport=")));
|
||||
setDbPort (attributes.substring (attributes.indexOf ("DBport=") + 7, attributes.indexOf (",DBname=")));
|
||||
setDbName (attributes.substring (attributes.indexOf ("DBname=") + 7, attributes.indexOf (",BQ=")));
|
||||
//
|
||||
setBequeath (attributes.substring (attributes.indexOf ("BQ=") + 3, attributes.indexOf (",FW=")));
|
||||
setViaFirewall (attributes.substring (attributes.indexOf ("FW=") + 3, attributes.indexOf (",FWhost=")));
|
||||
setFwHost (attributes.substring (attributes.indexOf ("FWhost=") + 7, attributes.indexOf (",FWport=")));
|
||||
setFwPort (attributes.substring (attributes.indexOf ("FWport=") + 7, attributes.indexOf (",UID=")));
|
||||
//
|
||||
setDbUid (attributes.substring (attributes.indexOf ("UID=") + 4, attributes.indexOf (",PWD=")));
|
||||
setDbPwd (attributes.substring (attributes.indexOf ("PWD=") + 4, attributes.indexOf ("]")));
|
||||
//
|
||||
attributes = attributes.substring(attributes.indexOf("[")+1, attributes.length() - 1);
|
||||
String[] pairs= attributes.split("[,]");
|
||||
for(String pair : pairs)
|
||||
{
|
||||
String[] pairComponents = pair.split("[=]");
|
||||
String key = pairComponents[0];
|
||||
String value = unescape(pairComponents[1]);
|
||||
if ("name".equalsIgnoreCase(key))
|
||||
{
|
||||
setName(value);
|
||||
}
|
||||
else if ("AppsHost".equalsIgnoreCase(key))
|
||||
{
|
||||
setAppsHost(value);
|
||||
}
|
||||
else if ("type".equalsIgnoreCase(key))
|
||||
{
|
||||
setType(value);
|
||||
}
|
||||
else if ("DBhost".equalsIgnoreCase(key))
|
||||
{
|
||||
setDbHost(value);
|
||||
}
|
||||
else if ("DBport".equalsIgnoreCase(key))
|
||||
{
|
||||
setDbPort(value);
|
||||
}
|
||||
else if ("DbName".equalsIgnoreCase(key))
|
||||
{
|
||||
setDbName(value);
|
||||
}
|
||||
else if ("BQ".equalsIgnoreCase(key))
|
||||
{
|
||||
setBequeath(value);
|
||||
}
|
||||
else if ("FW".equalsIgnoreCase(key))
|
||||
{
|
||||
setViaFirewall(value);
|
||||
}
|
||||
else if ("FWhost".equalsIgnoreCase(key))
|
||||
{
|
||||
setFwHost(value);
|
||||
}
|
||||
else if ("FWport".equalsIgnoreCase(key))
|
||||
{
|
||||
setFwPort(value);
|
||||
}
|
||||
else if ("UID".equalsIgnoreCase(key))
|
||||
{
|
||||
setDbUid(value);
|
||||
}
|
||||
else if ("PWD".equalsIgnoreCase(key))
|
||||
{
|
||||
setDbPwd(value);
|
||||
}
|
||||
else if ("WebPort".equalsIgnoreCase(key))
|
||||
{
|
||||
setWebPort(value);
|
||||
}
|
||||
else if ("SSLPort".equalsIgnoreCase(key))
|
||||
{
|
||||
setSSLPort(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -1005,6 +1161,12 @@ public class CConnection implements Serializable, Cloneable
|
|||
}
|
||||
} // setAttributes
|
||||
|
||||
private String unescape(String value) {
|
||||
value = value.replace("&eq;", "=");
|
||||
value = value.replace(",", ",");
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Equals
|
||||
* @param o object
|
||||
|
@ -1105,37 +1267,6 @@ public class CConnection implements Serializable, Cloneable
|
|||
return "";
|
||||
} // getConnectionURL
|
||||
|
||||
/**
|
||||
* Get Server Connection - do close
|
||||
* @param autoCommit true if autocommit connection
|
||||
* @param trxLevel Connection transaction level
|
||||
* @return Connection
|
||||
*/
|
||||
public Connection getServerConnection (boolean autoCommit, int trxLevel)
|
||||
{
|
||||
Connection conn = null;
|
||||
// Server Connection
|
||||
if (m_ds != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
conn = m_ds.getConnection ();
|
||||
conn.setAutoCommit (autoCommit);
|
||||
conn.setTransactionIsolation (trxLevel);
|
||||
m_okDB = true;
|
||||
}
|
||||
catch (SQLException ex)
|
||||
{
|
||||
m_dbException = ex;
|
||||
log.log(Level.SEVERE, "", ex);
|
||||
}
|
||||
}
|
||||
|
||||
// Server
|
||||
return conn;
|
||||
} // getServerConnection
|
||||
|
||||
|
||||
/**
|
||||
* Create Connection - no not close.
|
||||
* Sets m_dbException
|
||||
|
@ -1261,6 +1392,22 @@ public class CConnection implements Serializable, Cloneable
|
|||
*/
|
||||
private boolean queryAppsServerInfo ()
|
||||
{
|
||||
m_okApps = false;
|
||||
m_queryAppsServer = true;
|
||||
|
||||
if (getAppsHost().equalsIgnoreCase("MyAppsServer")) {
|
||||
log.warning (getAppsHost() + " ignored");
|
||||
return m_okApps; // false
|
||||
}
|
||||
|
||||
Status status = Service.locate(Status.class);
|
||||
try {
|
||||
updateInfoFromServer(status);
|
||||
m_okApps = true;
|
||||
} catch (Exception e) {
|
||||
m_appsException = e;
|
||||
}
|
||||
|
||||
return m_okApps;
|
||||
} // setAppsServerInfo
|
||||
|
||||
|
@ -1293,7 +1440,7 @@ public class CConnection implements Serializable, Cloneable
|
|||
//
|
||||
setFwHost (svr.getFwHost ());
|
||||
setFwPort (svr.getFwPort ());
|
||||
if (getFwHost ().length () == 0)
|
||||
if (getFwHost() == null || getFwHost().length () == 0)
|
||||
setViaFirewall (false);
|
||||
m_version = svr.getDateVersion ();
|
||||
log.config("Server=" + getDbHost() + ", DB=" + getDbName());
|
||||
|
@ -1353,21 +1500,18 @@ public class CConnection implements Serializable, Cloneable
|
|||
return "<?" + transactionIsolation + "?>";
|
||||
} // getTransactionIsolationInfo
|
||||
|
||||
/**
|
||||
* @return true if server is embedded in process
|
||||
*/
|
||||
public static boolean isServerEmbedded() {
|
||||
return "true".equalsIgnoreCase(System.getProperty(SERVER_EMBEDDED));
|
||||
}
|
||||
|
||||
public void setAppServerCredential(String principal, String credential)
|
||||
public void setAppServerCredential(String identity, char[] secret)
|
||||
{
|
||||
SecurityPrincipal sp = new SecurityPrincipal();
|
||||
sp.principal = principal;
|
||||
sp.credential = credential;
|
||||
Env.getCtx().put(SECURITY_PRINCIPAL, sp);
|
||||
securityPrincipal = new SecurityPrincipal();
|
||||
securityPrincipal.identity = identity;
|
||||
securityPrincipal.secret= secret;
|
||||
m_server = null;
|
||||
}
|
||||
|
||||
public SecurityPrincipal getAppServerCredential()
|
||||
{
|
||||
return securityPrincipal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
|
|
|
@ -19,11 +19,11 @@ import java.io.Serializable;
|
|||
* @author Low Heng Sin
|
||||
*
|
||||
*/
|
||||
class SecurityPrincipal implements Serializable {
|
||||
public class SecurityPrincipal implements Serializable {
|
||||
/**
|
||||
*
|
||||
* generated serial version id
|
||||
*/
|
||||
private static final long serialVersionUID = -4703480025159571932L;
|
||||
String principal;
|
||||
String credential;
|
||||
private static final long serialVersionUID = -6924078376448056295L;
|
||||
public String identity;
|
||||
public char[] secret;
|
||||
}
|
||||
|
|
|
@ -11,10 +11,6 @@ import org.compiere.util.EMail;
|
|||
*/
|
||||
public interface Server
|
||||
{
|
||||
public final static String JNDI_NAME = "adempiere/Server";
|
||||
|
||||
public final static String EJB_NAME = "adempiereServer";
|
||||
|
||||
/**
|
||||
* Post Immediate
|
||||
* @param ctx Client Context
|
||||
|
@ -22,10 +18,9 @@ public interface Server
|
|||
* @param AD_Table_ID Table ID of Document
|
||||
* @param Record_ID Record ID of this document
|
||||
* @param force force posting
|
||||
* @param trxName ignore, retained for backward compatibility
|
||||
* @return null, if success or error message */
|
||||
public String postImmediate( Properties ctx, int AD_Client_ID, int AD_Table_ID,
|
||||
int Record_ID, boolean force, String trxName);
|
||||
int Record_ID, boolean force);
|
||||
|
||||
/**
|
||||
* Process Remote
|
||||
|
@ -43,50 +38,32 @@ public interface Server
|
|||
public ProcessInfo workflow( Properties ctx, ProcessInfo pi, int AD_Workflow_ID );
|
||||
|
||||
/**
|
||||
* Create EMail from Server (Request User)
|
||||
* Send EMail from Server
|
||||
* @param ctx Context
|
||||
* @param AD_Client_ID client
|
||||
* @param to recipient email address
|
||||
* @param subject subject
|
||||
* @param message message
|
||||
* @return EMail */
|
||||
public EMail createEMail( Properties ctx, int AD_Client_ID, String to,
|
||||
String subject, String message );
|
||||
* @param email
|
||||
* @return message return from email server */
|
||||
public String sendEMail( Properties ctx, EMail email);
|
||||
|
||||
/**
|
||||
* Create EMail from Server (Request User)
|
||||
* @param ctx Context
|
||||
* @param AD_Client_ID client
|
||||
* @param AD_User_ID user to send email from
|
||||
* @param to recipient email address
|
||||
* @param subject subject
|
||||
* @param message message
|
||||
* @return EMail */
|
||||
public EMail createEMail( Properties ctx, int AD_Client_ID, int AD_User_ID,
|
||||
String to, String subject, String message );
|
||||
|
||||
/**
|
||||
* Execute task on server
|
||||
* @param ctx Context
|
||||
* @param AD_Task_ID task
|
||||
* @return execution trace */
|
||||
public String executeTask( int AD_Task_ID );
|
||||
public String executeTask( Properties ctx, int AD_Task_ID );
|
||||
|
||||
/**
|
||||
* Cash Reset
|
||||
* @param ctx Context
|
||||
* @param tableName table name
|
||||
* @param Record_ID record or 0 for all
|
||||
* @return number of records reset */
|
||||
public int cacheReset( String tableName,int Record_ID );
|
||||
|
||||
/**
|
||||
* Describes the instance and its content for debugging purpose
|
||||
* @return Debugging information about the instance and its content */
|
||||
public String getStatus( );
|
||||
public int cacheReset( Properties ctx, String tableName,int Record_ID );
|
||||
|
||||
/**
|
||||
* Execute db proces on server
|
||||
* @param ctx Context
|
||||
* @param processInfo
|
||||
* @param procedureName
|
||||
* @return ProcessInfo */
|
||||
public ProcessInfo dbProcess( ProcessInfo processInfo, String procedureName );
|
||||
public ProcessInfo dbProcess( Properties ctx, ProcessInfo processInfo, String procedureName );
|
||||
}
|
||||
|
|
|
@ -5,10 +5,6 @@ package org.compiere.interfaces;
|
|||
*/
|
||||
public interface Status
|
||||
{
|
||||
public final static String JNDI_NAME="adempiere/Status";
|
||||
|
||||
public final static String EJB_NAME="adempiereStatus";
|
||||
|
||||
/**
|
||||
* Get Version (Date)
|
||||
* @return version e.g. 2002-09-02 */
|
||||
|
@ -63,19 +59,4 @@ public interface Status
|
|||
* Get Connection Manager Port
|
||||
* @return Connection Manager Port */
|
||||
public int getFwPort( );
|
||||
|
||||
/**
|
||||
* Get Version Count
|
||||
* @return number of version inquiries */
|
||||
public int getVersionCount( );
|
||||
|
||||
/**
|
||||
* Get Database Count
|
||||
* @return number of database inquiries */
|
||||
public int getDatabaseCount( );
|
||||
|
||||
/**
|
||||
* Describes the instance and its content for debugging purpose
|
||||
* @return Debugging information about the instance and its content */
|
||||
public String getStatus( );
|
||||
}
|
||||
|
|
|
@ -0,0 +1,140 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* 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. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.interfaces.impl;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.adempiere.util.ProcessUtil;
|
||||
import org.compiere.acct.Doc;
|
||||
import org.compiere.interfaces.Server;
|
||||
import org.compiere.model.MAcctSchema;
|
||||
import org.compiere.model.MTask;
|
||||
import org.compiere.process.ProcessInfo;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.CacheMgt;
|
||||
import org.compiere.util.EMail;
|
||||
import org.compiere.util.Env;
|
||||
|
||||
/**
|
||||
* Adempiere Server Bean.
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: ServerBean.java,v 1.3 2006/07/30 00:53:33 jjanke Exp $
|
||||
* @author Low Heng Sin
|
||||
* - Added remote transaction management
|
||||
* - Added support to run db process remotely on server
|
||||
*
|
||||
* @author Teo Sarca, SC ARHIPAC SERVICE SRL - BF [ 1757523 ]
|
||||
*/
|
||||
public class ServerBean implements Server
|
||||
{
|
||||
/** Logger */
|
||||
private static CLogger log = CLogger.getCLogger(ServerBean.class);
|
||||
//
|
||||
/**
|
||||
* Post Immediate
|
||||
*
|
||||
* @param ctx Client Context
|
||||
* @param AD_Client_ID Client ID of Document
|
||||
* @param AD_Table_ID Table ID of Document
|
||||
* @param Record_ID Record ID of this document
|
||||
* @param force force posting
|
||||
* @return null, if success or error message
|
||||
*/
|
||||
public String postImmediate (Properties ctx,
|
||||
int AD_Client_ID, int AD_Table_ID, int Record_ID, boolean force)
|
||||
{
|
||||
log.info ("Table=" + AD_Table_ID + ", Record=" + Record_ID);
|
||||
|
||||
MAcctSchema[] ass = MAcctSchema.getClientAcctSchema(ctx, AD_Client_ID);
|
||||
return Doc.postImmediate(ass, AD_Table_ID, Record_ID, force, null);
|
||||
} // postImmediate
|
||||
|
||||
/*************************************************************************
|
||||
* Process Remote
|
||||
*
|
||||
* @param ctx Context
|
||||
* @param pi Process Info
|
||||
* @return resulting Process Info
|
||||
*/
|
||||
public ProcessInfo process (Properties ctx, ProcessInfo pi)
|
||||
{
|
||||
// Start Process
|
||||
ProcessUtil.startJavaProcess(ctx, pi, null);
|
||||
return pi;
|
||||
} // process
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* Run Workflow (and wait) on Server
|
||||
*
|
||||
* @param ctx Context
|
||||
* @param pi Process Info
|
||||
* @param AD_Workflow_ID id
|
||||
* @return process info
|
||||
*/
|
||||
public ProcessInfo workflow (Properties ctx, ProcessInfo pi, int AD_Workflow_ID)
|
||||
{
|
||||
log.info ("AD_Workflow_ID=" + AD_Workflow_ID);
|
||||
ProcessUtil.startWorkFlow(ctx, pi, AD_Workflow_ID);
|
||||
return pi;
|
||||
} // workflow
|
||||
|
||||
/**
|
||||
* Execute task on server
|
||||
* @param ctx Context
|
||||
* @param AD_Task_ID task
|
||||
* @return execution trace
|
||||
*/
|
||||
public String executeTask (Properties ctx, int AD_Task_ID)
|
||||
{
|
||||
MTask task = new MTask (Env.getCtx(), AD_Task_ID, null); // Server Context
|
||||
return task.execute();
|
||||
} // executeTask
|
||||
|
||||
|
||||
/**
|
||||
* Cash Reset
|
||||
* @param ctx Context
|
||||
* @param tableName table name
|
||||
* @param Record_ID record or 0 for all
|
||||
* @return number of records reset
|
||||
*/
|
||||
public int cacheReset (Properties ctx, String tableName, int Record_ID)
|
||||
{
|
||||
log.config(tableName + " - " + Record_ID);
|
||||
return CacheMgt.get().reset(tableName, Record_ID);
|
||||
} // cacheReset
|
||||
|
||||
/**
|
||||
* Execute db proces on server
|
||||
* @param ctx Context
|
||||
* @param processInfo
|
||||
* @param procedureName
|
||||
* @return ProcessInfo
|
||||
*/
|
||||
public ProcessInfo dbProcess(Properties ctx, ProcessInfo processInfo, String procedureName)
|
||||
{
|
||||
ProcessUtil.startDatabaseProcedure(processInfo, procedureName, null);
|
||||
return processInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String sendEMail(Properties ctx, EMail email) {
|
||||
return email.send();
|
||||
}
|
||||
} // ServerBean
|
|
@ -0,0 +1,142 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* 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. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.interfaces.impl;
|
||||
|
||||
import org.compiere.Adempiere;
|
||||
import org.compiere.db.CConnection;
|
||||
import org.compiere.interfaces.Status;
|
||||
import org.compiere.util.CLogger;
|
||||
|
||||
|
||||
/**
|
||||
* Adempiere Status Bean
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: StatusBean.java,v 1.3 2006/07/30 00:53:33 jjanke Exp $
|
||||
*/
|
||||
public class StatusBean implements Status
|
||||
{
|
||||
private static final String ALLOW_CLIENT_QUERY_DB_PWD = "adempiere.client.getDBPwd";
|
||||
|
||||
/** Logging */
|
||||
@SuppressWarnings("unused")
|
||||
private static CLogger log = CLogger.getCLogger(StatusBean.class);
|
||||
|
||||
/**
|
||||
* Get Version (Date)
|
||||
* @return version e.g. 2002-09-02
|
||||
*/
|
||||
public String getDateVersion()
|
||||
{
|
||||
return Adempiere.DATE_VERSION;
|
||||
} // getDateVersion
|
||||
|
||||
/**
|
||||
* Get Main Version
|
||||
* @return main version - e.g. Version 2.4.3b
|
||||
*/
|
||||
public String getMainVersion()
|
||||
{
|
||||
return Adempiere.MAIN_VERSION;
|
||||
} // getMainVersion
|
||||
|
||||
/**
|
||||
* Get Database Type
|
||||
* @return Database Type
|
||||
*/
|
||||
public String getDbType()
|
||||
{
|
||||
return CConnection.get().getType();
|
||||
} // getDbType
|
||||
|
||||
/**
|
||||
* Get Database Host
|
||||
* @return Database Host Name
|
||||
*/
|
||||
public String getDbHost()
|
||||
{
|
||||
return CConnection.get().getDbHost();
|
||||
} // getDbHost
|
||||
|
||||
/**
|
||||
* Get Database Port
|
||||
* @return Database Port
|
||||
*/
|
||||
public int getDbPort()
|
||||
{
|
||||
return CConnection.get().getDbPort();
|
||||
} // getDbPort
|
||||
|
||||
/**
|
||||
* Get Database SID
|
||||
* @return Database SID
|
||||
*/
|
||||
public String getDbName()
|
||||
{
|
||||
return CConnection.get().getDbName();
|
||||
} // getDbSID
|
||||
|
||||
/**
|
||||
* Get Database URL
|
||||
* @return Database URL
|
||||
*/
|
||||
public String getConnectionURL()
|
||||
{
|
||||
return CConnection.get().getConnectionURL();
|
||||
} // getConnectionURL
|
||||
|
||||
/**
|
||||
* Get Database UID
|
||||
* @return Database User Name
|
||||
*/
|
||||
public String getDbUid()
|
||||
{
|
||||
return CConnection.get().getDbUid();
|
||||
} // getDbUID
|
||||
|
||||
/**
|
||||
* Get Database PWD
|
||||
* @return Database User Password
|
||||
*/
|
||||
public String getDbPwd()
|
||||
{
|
||||
String f = System.getProperty(ALLOW_CLIENT_QUERY_DB_PWD);
|
||||
if ("false".equalsIgnoreCase(f))
|
||||
return "";
|
||||
|
||||
return CConnection.get().getDbPwd();
|
||||
} // getDbPWD
|
||||
|
||||
/**
|
||||
* Get Connection Manager Host
|
||||
* @return Connection Manager Host
|
||||
*/
|
||||
public String getFwHost()
|
||||
{
|
||||
return CConnection.get().getFwHost();
|
||||
} // getCMHost
|
||||
|
||||
/**
|
||||
* Get Connection Manager Port
|
||||
* @return Connection Manager Port
|
||||
*/
|
||||
public int getFwPort()
|
||||
{
|
||||
return CConnection.get().getFwPort();
|
||||
} // getCMPort
|
||||
|
||||
} // StatusBean
|
|
@ -32,13 +32,11 @@ import java.util.logging.Level;
|
|||
import javax.mail.internet.InternetAddress;
|
||||
|
||||
import org.compiere.db.CConnection;
|
||||
import org.compiere.interfaces.Server;
|
||||
import org.compiere.util.CCache;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.EMail;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Ini;
|
||||
import org.compiere.util.Language;
|
||||
|
||||
/**
|
||||
|
@ -106,6 +104,7 @@ public class MClient extends X_AD_Client
|
|||
} // get
|
||||
|
||||
/** Static Logger */
|
||||
@SuppressWarnings("unused")
|
||||
private static CLogger s_log = CLogger.getCLogger (MClient.class);
|
||||
/** Cache */
|
||||
private static CCache<Integer,MClient> s_cache = new CCache<Integer,MClient>("AD_Client", 3);
|
||||
|
@ -479,7 +478,15 @@ public class MClient extends X_AD_Client
|
|||
return "Could not create EMail: " + getName();
|
||||
try
|
||||
{
|
||||
String msg = email.send();
|
||||
String msg = null;
|
||||
if (isServerEMail())
|
||||
{
|
||||
msg = CConnection.get().getServer().sendEMail(Env.getRemoteCallCtx(Env.getCtx()), email);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = email.send();
|
||||
}
|
||||
if (EMail.SENT_OK.equals (msg))
|
||||
{
|
||||
log.info("Sent Test EMail to " + getRequestEMail());
|
||||
|
@ -599,7 +606,15 @@ public class MClient extends X_AD_Client
|
|||
email.addAttachment(attachment);
|
||||
try
|
||||
{
|
||||
String msg = email.send();
|
||||
String msg = null;
|
||||
if (isServerEMail())
|
||||
{
|
||||
msg = CConnection.get().getServer().sendEMail(Env.getRemoteCallCtx(Env.getCtx()), email);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = email.send();
|
||||
}
|
||||
if (EMail.SENT_OK.equals (msg))
|
||||
{
|
||||
log.info("Sent EMail " + subject + " to " + to);
|
||||
|
@ -676,7 +691,15 @@ public class MClient extends X_AD_Client
|
|||
*/
|
||||
public boolean sendEmailNow(MUser from, MUser to, EMail email)
|
||||
{
|
||||
String msg = email.send();
|
||||
String msg = null;
|
||||
if (isServerEMail())
|
||||
{
|
||||
msg = CConnection.get().getServer().sendEMail(Env.getRemoteCallCtx(Env.getCtx()), email);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = email.send();
|
||||
}
|
||||
//
|
||||
X_AD_UserMail um = new X_AD_UserMail(getCtx(), 0, null);
|
||||
um.setClientOrg(this);
|
||||
|
@ -749,29 +772,7 @@ public class MClient extends X_AD_Client
|
|||
return null;
|
||||
}
|
||||
//
|
||||
EMail email = null;
|
||||
if (isServerEMail() && Ini.isClient())
|
||||
{
|
||||
Server server = CConnection.get().getServer();
|
||||
try
|
||||
{
|
||||
if (server != null)
|
||||
{ // See ServerBean
|
||||
if (html && message != null)
|
||||
message = EMail.HTML_MAIL_MARKER + message;
|
||||
email = server.createEMail(Env.getRemoteCallCtx(getCtx()), getAD_Client_ID(),
|
||||
to, subject, message);
|
||||
}
|
||||
else
|
||||
log.log(Level.WARNING, "No AppsServer");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.log(Level.SEVERE, getName() + " - AppsServer error", ex);
|
||||
}
|
||||
}
|
||||
if (email == null)
|
||||
email = new EMail (this,
|
||||
EMail email = new EMail (this,
|
||||
getRequestEMail(), to,
|
||||
subject, message, html);
|
||||
if (isSmtpAuthorization())
|
||||
|
@ -861,30 +862,7 @@ public class MClient extends X_AD_Client
|
|||
return null;
|
||||
}
|
||||
//
|
||||
EMail email = null;
|
||||
if (isServerEMail() && Ini.isClient())
|
||||
{
|
||||
Server server = CConnection.get().getServer();
|
||||
try
|
||||
{
|
||||
if (server != null)
|
||||
{ // See ServerBean
|
||||
if (html && message != null)
|
||||
message = EMail.HTML_MAIL_MARKER + message;
|
||||
email = server.createEMail(Env.getRemoteCallCtx(getCtx()), getAD_Client_ID(),
|
||||
from.getAD_User_ID(),
|
||||
to, subject, message);
|
||||
}
|
||||
else
|
||||
log.log(Level.WARNING, "No AppsServer");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.log(Level.SEVERE, getName() + " - AppsServer error", ex);
|
||||
}
|
||||
}
|
||||
if (email == null)
|
||||
email = new EMail (this,
|
||||
EMail email = new EMail (this,
|
||||
from.getEMail(),
|
||||
to,
|
||||
subject,
|
||||
|
|
|
@ -24,14 +24,11 @@ import java.util.Iterator;
|
|||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.db.CConnection;
|
||||
import org.compiere.interfaces.Server;
|
||||
import org.compiere.util.CCache;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.EMail;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Ini;
|
||||
import org.compiere.util.Msg;
|
||||
|
||||
/**
|
||||
|
@ -74,7 +71,7 @@ public class MStore extends X_W_Store
|
|||
public static MStore get (Properties ctx, String contextPath)
|
||||
{
|
||||
MStore wstore = null;
|
||||
Iterator it = s_cache.values().iterator();
|
||||
Iterator<?> it = s_cache.values().iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
wstore = (MStore)it.next();
|
||||
|
@ -204,7 +201,7 @@ public class MStore extends X_W_Store
|
|||
s_log.info("");
|
||||
try
|
||||
{
|
||||
Collection cc = s_cache.values();
|
||||
Collection<?> cc = s_cache.values();
|
||||
Object[] oo = cc.toArray();
|
||||
for (int i = 0; i < oo.length; i++)
|
||||
s_log.info(i + ": " + oo[i]);
|
||||
|
@ -353,31 +350,11 @@ public class MStore extends X_W_Store
|
|||
return null;
|
||||
}
|
||||
//
|
||||
EMail email = null;
|
||||
MClient client = MClient.get(getCtx(), getAD_Client_ID());
|
||||
if (client.isServerEMail() && Ini.isClient())
|
||||
{
|
||||
Server server = CConnection.get().getServer();
|
||||
try
|
||||
{
|
||||
if (server != null)
|
||||
{ // See ServerBean
|
||||
email = server.createEMail(Env.getRemoteCallCtx(getCtx()), getAD_Client_ID(),
|
||||
to, subject, message);
|
||||
}
|
||||
else
|
||||
log.log(Level.WARNING, "No AppsServer");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.log(Level.SEVERE, getName() + " - AppsServer error", ex);
|
||||
}
|
||||
}
|
||||
String from = getWStoreEMail();
|
||||
if (from == null || from.length() == 0)
|
||||
from = client.getRequestEMail();
|
||||
if (email == null)
|
||||
email = new EMail (client,
|
||||
EMail email = new EMail (client,
|
||||
from, to,
|
||||
subject, message);
|
||||
// Authorizetion
|
||||
|
|
|
@ -141,7 +141,6 @@ public class ServerProcessCtl implements Runnable {
|
|||
int AD_ReportView_ID = 0;
|
||||
int AD_Workflow_ID = 0;
|
||||
boolean IsReport = false;
|
||||
boolean isPrintPreview = m_pi.isPrintPreview();
|
||||
|
||||
//
|
||||
String sql = "SELECT p.Name, p.ProcedureName,p.ClassName, p.AD_Process_ID," // 1..4
|
||||
|
@ -428,7 +427,6 @@ public class ServerProcessCtl implements Runnable {
|
|||
// execute on this thread/connection
|
||||
log.fine(ProcedureName + "(" + m_pi.getAD_PInstance_ID() + ")");
|
||||
boolean started = false;
|
||||
String trxName = m_trx != null ? m_trx.getTrxName() : null;
|
||||
if (m_IsServerProcess)
|
||||
{
|
||||
Server server = CConnection.get().getServer();
|
||||
|
@ -436,7 +434,7 @@ public class ServerProcessCtl implements Runnable {
|
|||
{
|
||||
if (server != null)
|
||||
{ // See ServerBean
|
||||
m_pi = server.dbProcess(m_pi, ProcedureName);
|
||||
m_pi = server.dbProcess(Env.getRemoteCallCtx(Env.getCtx()), m_pi, ProcedureName);
|
||||
log.finest("server => " + m_pi);
|
||||
started = true;
|
||||
}
|
||||
|
|
|
@ -1,191 +0,0 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* 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. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.util;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Hashtable;
|
||||
|
||||
import javax.naming.InitialContext;
|
||||
import javax.naming.NamingEnumeration;
|
||||
|
||||
import org.compiere.interfaces.Status;
|
||||
|
||||
/**
|
||||
* Apps Server Connection Test
|
||||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: ConnectTest.java,v 1.2 2006/07/30 00:54:35 jjanke Exp $
|
||||
*/
|
||||
public class ConnectTest
|
||||
{
|
||||
/**
|
||||
* Connection Test Constructor
|
||||
* @param serverName server name or IP
|
||||
*/
|
||||
public ConnectTest (String serverName)
|
||||
{
|
||||
System.out.println("ConnectTest: " + serverName);
|
||||
System.out.println();
|
||||
//
|
||||
Hashtable<String,String> env = new Hashtable<String,String>();
|
||||
env.put(InitialContext.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
|
||||
env.put(InitialContext.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
|
||||
env.put(InitialContext.PROVIDER_URL, serverName);
|
||||
// env.put(InitialContext.SECURITY_PROTOCOL, ""); // "ssl"
|
||||
// env.put(InitialContext.SECURITY_AUTHENTICATION, "none"); // "none", "simple", "strong"
|
||||
// env.put(InitialContext.SECURITY_PRINCIPAL, "");
|
||||
// env.put(InitialContext.SECURITY_CREDENTIALS, "");
|
||||
|
||||
// Get Context
|
||||
System.out.println ("Creating context ...");
|
||||
System.out.println (" " + env);
|
||||
InitialContext context = null;
|
||||
try
|
||||
{
|
||||
context = new InitialContext(env);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.err.println("ERROR: Could not create context: " + e);
|
||||
return;
|
||||
}
|
||||
|
||||
testJNP (serverName, context);
|
||||
testEJB (serverName, context);
|
||||
|
||||
} // ConnectTest
|
||||
|
||||
/**
|
||||
* Test JNP
|
||||
* @param serverName server name
|
||||
* @param context context
|
||||
*/
|
||||
private void testJNP (String serverName, InitialContext context)
|
||||
{
|
||||
// Connect to MBean
|
||||
System.out.println();
|
||||
System.out.println ("Connecting to MBean ...");
|
||||
/**
|
||||
try
|
||||
{
|
||||
String connectorName = "jmx:" + serverName + ":rmi";
|
||||
RMIAdaptor server = (RMIAdaptor) context.lookup (connectorName);
|
||||
System.out.println("- have Server");
|
||||
System.out.println("- Default Domain=" + server.getDefaultDomain());
|
||||
System.out.println("- MBeanCount = " + server.getMBeanCount());
|
||||
|
||||
// ObjectName serviceName = new ObjectName ("Adempiere:service=AdempiereCtrl");
|
||||
// System.out.println("- " + serviceName + " is registered=" + server.isRegistered(serviceName));
|
||||
|
||||
// System.out.println(" - AdempiereSummary= "
|
||||
// + server.getAttribute(serviceName, "AdempiereSummary"));
|
||||
|
||||
Object[] params = {};
|
||||
String[] signature = {};
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.err.println("ERROR: Could not contact MBean: " + e);
|
||||
return;
|
||||
}
|
||||
**/
|
||||
|
||||
// List Context
|
||||
System.out.println();
|
||||
System.out.println(" Examining context ....");
|
||||
try
|
||||
{
|
||||
System.out.println(" Namespace=" + context.getNameInNamespace());
|
||||
System.out.println(" Environment=" + context.getEnvironment());
|
||||
System.out.println(" Context '/':");
|
||||
NamingEnumeration ne = context.list("/");
|
||||
while (ne.hasMore())
|
||||
System.out.println(" - " + ne.nextElement());
|
||||
//
|
||||
System.out.println(" Context 'ejb':");
|
||||
ne = context.list("ejb");
|
||||
while (ne.hasMore())
|
||||
System.out.println(" - " + ne.nextElement());
|
||||
//
|
||||
System.out.println(" Context 'ejb/adempiere':");
|
||||
ne = context.list("ejb/adempiere");
|
||||
while (ne.hasMore())
|
||||
System.out.println(" - " + ne.nextElement());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.err.println("ERROR: Could not examine context: " + e);
|
||||
return;
|
||||
}
|
||||
} // testJNP
|
||||
|
||||
/**
|
||||
* Test EJB
|
||||
* @param serverName server name
|
||||
* @param context context
|
||||
*/
|
||||
private void testEJB (String serverName, InitialContext context)
|
||||
{
|
||||
System.out.println();
|
||||
System.out.println ("Connecting to EJB server ...");
|
||||
try
|
||||
{
|
||||
System.out.println(" Name=" + Status.JNDI_NAME);
|
||||
Status sta = (Status)context.lookup (Status.JNDI_NAME);
|
||||
System.out.println(" .. bean created");
|
||||
System.out.println(" ServerVersion=" + sta.getMainVersion() + " " + sta.getDateVersion());
|
||||
System.out.println(" .. bean removed");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.err.println("ERROR: Could not connect: " + e);
|
||||
return;
|
||||
}
|
||||
|
||||
System.out.println();
|
||||
System.out.println("SUCCESS !!");
|
||||
} // testEJB
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* Start Method
|
||||
* @param args serverName
|
||||
*/
|
||||
public static void main(String[] args)
|
||||
{
|
||||
String serverName = null;
|
||||
if (args.length > 0)
|
||||
serverName = args[0];
|
||||
if (serverName == null || serverName.length() == 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
serverName = InetAddress.getLocalHost().getHostName();
|
||||
}
|
||||
catch (UnknownHostException ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Start
|
||||
ConnectTest ct = new ConnectTest (serverName);
|
||||
} // main
|
||||
|
||||
} // ConnectionTest
|
|
@ -19,6 +19,7 @@ package org.compiere.util;
|
|||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
@ -170,7 +171,7 @@ public final class EMail implements Serializable
|
|||
/** SMTP enable start TLS */
|
||||
// @TODO - make tls configurable - private boolean m_smtpStarttlsEnable = false;
|
||||
/** Attachments */
|
||||
private ArrayList<Object> m_attachments;
|
||||
private ArrayList<DataSource> m_attachments;
|
||||
/** UserName and Password */
|
||||
private EMailAuthenticator m_auth = null;
|
||||
/** Message */
|
||||
|
@ -406,7 +407,7 @@ public final class EMail implements Serializable
|
|||
return;
|
||||
try
|
||||
{
|
||||
Enumeration e = m_msg.getAllHeaderLines ();
|
||||
Enumeration<?> e = m_msg.getAllHeaderLines ();
|
||||
while (e.hasMoreElements ())
|
||||
log.fine("- " + e.nextElement ());
|
||||
}
|
||||
|
@ -785,8 +786,8 @@ public final class EMail implements Serializable
|
|||
if (file == null)
|
||||
return;
|
||||
if (m_attachments == null)
|
||||
m_attachments = new ArrayList<Object>();
|
||||
m_attachments.add(file);
|
||||
m_attachments = new ArrayList<DataSource>();
|
||||
m_attachments.add(new FileDataSource(file));
|
||||
} // addAttachment
|
||||
|
||||
/**
|
||||
|
@ -811,8 +812,12 @@ public final class EMail implements Serializable
|
|||
if (url == null)
|
||||
return;
|
||||
if (m_attachments == null)
|
||||
m_attachments = new ArrayList<Object>();
|
||||
m_attachments.add(url);
|
||||
m_attachments = new ArrayList<DataSource>();
|
||||
try {
|
||||
m_attachments.add(new URLDataSource(url.toURL()));
|
||||
} catch (MalformedURLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
} // addAttachment
|
||||
|
||||
/**
|
||||
|
@ -837,7 +842,7 @@ public final class EMail implements Serializable
|
|||
if (dataSource == null)
|
||||
return;
|
||||
if (m_attachments == null)
|
||||
m_attachments = new ArrayList<Object>();
|
||||
m_attachments = new ArrayList<DataSource>();
|
||||
m_attachments.add(dataSource);
|
||||
} // addAttachment
|
||||
|
||||
|
|
|
@ -1534,11 +1534,14 @@ public final class Env
|
|||
Set<Object> keys = ctx.keySet();
|
||||
for (Object key : keys)
|
||||
{
|
||||
String s = key.toString();
|
||||
if (s.startsWith("#") || s.startsWith("$"))
|
||||
{
|
||||
p.put(key, ctx.get(key));
|
||||
}
|
||||
if(!(key instanceof String))
|
||||
continue;
|
||||
|
||||
Object value = ctx.get(key);
|
||||
if (!(value instanceof String))
|
||||
continue;
|
||||
|
||||
p.put(key, value);
|
||||
}
|
||||
|
||||
return p;
|
||||
|
|
|
@ -242,8 +242,6 @@ public class Login
|
|||
|
||||
// Authentification
|
||||
boolean authenticated = false;
|
||||
if (Ini.isClient())
|
||||
CConnection.get().setAppServerCredential(app_user, app_pwd);
|
||||
MSystem system = MSystem.get(m_ctx);
|
||||
if (system == null)
|
||||
throw new IllegalStateException("No System Info");
|
||||
|
|
Loading…
Reference in New Issue