use of org.compiere.interfaces.Server in project adempiere by adempiere.
the class ProcessCtl method startProcess.
// startWorkflow
/**************************************************************************
* Start Java Process Class.
* instanciate the class implementing the interface ProcessCall.
* The class can be a Server/Client class (when in Package
* org adempiere.process or org.compiere.model) or a client only class
* (e.g. in org.compiere.report)
*
* @return true if success
*/
private boolean startProcess() {
log.fine(processInstance.toString());
boolean started = false;
//hengsin, bug [ 1633995 ]
boolean clientOnly = false;
if (!processInstance.getClassName().toLowerCase().startsWith(MRule.SCRIPT_PREFIX)) {
try {
Class<?> processClass = Class.forName(processInstance.getClassName());
if (ClientProcess.class.isAssignableFrom(processClass))
clientOnly = true;
} catch (Exception e) {
}
}
if (isServerProcess && !clientOnly) {
Server server = CConnection.get().getServer();
try {
if (server != null) {
// See ServerBean
processInstance = server.process(Env.getRemoteCallCtx(Env.getCtx()), processInstance);
log.finest("server => " + processInstance);
started = true;
}
} catch (UndeclaredThrowableException ex) {
Throwable cause = ex.getCause();
if (cause != null) {
if (cause instanceof InvalidClassException)
log.log(Level.SEVERE, "Version Server <> Client: " + cause.toString() + " - " + processInstance, ex);
else
log.log(Level.SEVERE, "AppsServer error(1b): " + cause.toString() + " - " + processInstance, ex);
} else
log.log(Level.SEVERE, " AppsServer error(1) - " + processInstance, ex);
started = false;
} catch (Exception ex) {
Throwable cause = ex.getCause();
if (cause == null)
cause = ex;
log.log(Level.SEVERE, "AppsServer error - " + processInstance, cause);
started = false;
}
}
// Run locally
if (!started && (!isServerProcess || clientOnly)) {
if (processInstance.getClassName().toLowerCase().startsWith(MRule.SCRIPT_PREFIX)) {
return ProcessUtil.startScriptProcess(Env.getCtx(), processInstance, m_trx);
} else {
if (processInstance.isManagedTransaction())
return ProcessUtil.startJavaProcess(Env.getCtx(), processInstance, m_trx);
else
return ProcessUtil.startJavaProcess(Env.getCtx(), processInstance, m_trx, processInstance.isManagedTransaction());
}
}
return !processInstance.isError();
}
use of org.compiere.interfaces.Server in project adempiere by adempiere.
the class ProcessCtl method startWorkflow.
// unlock
/**************************************************************************
* Start Workflow.
*
* @param AD_Workflow_ID workflow
* @return true if started
*/
private boolean startWorkflow(int AD_Workflow_ID) {
log.fine(AD_Workflow_ID + " - " + processInstance);
boolean started = false;
if (isServerProcess) {
Server server = CConnection.get().getServer();
try {
if (server != null) {
// See ServerBean
processInstance = server.workflow(Env.getRemoteCallCtx(Env.getCtx()), processInstance, AD_Workflow_ID);
log.finest("server => " + processInstance);
started = true;
}
} catch (Exception ex) {
log.log(Level.SEVERE, "AppsServer error", ex);
started = false;
}
}
// Run locally
if (!started && !isServerProcess) {
if (m_trx != null)
processInstance.setTransactionName(m_trx.getTrxName());
MWFProcess wfProcess = ProcessUtil.startWorkFlow(Env.getCtx(), processInstance, AD_Workflow_ID);
started = wfProcess != null;
}
return started;
}
use of org.compiere.interfaces.Server in project adempiere by adempiere.
the class MStore method createEMail.
// beforeSave
/************
* Create EMail from Request User
* @param to recipient
* @param subject sunject
* @param message nessage
* @return EMail
*/
public EMail createEMail(String to, String subject, String message) {
if (to == null || to.length() == 0) {
log.warning("No To");
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, from, to, subject, message);
// Authorizetion
if (client.isSmtpAuthorization()) {
if (getWStoreEMail() != null && getWStoreUser() != null && getWStoreUserPW() != null)
email.createAuthenticator(getWStoreUser(), getWStoreUserPW());
else
email.createAuthenticator(client.getRequestUser(), client.getRequestUserPW());
}
// Bcc
email.addBcc(from);
//
return email;
}
use of org.compiere.interfaces.Server in project adempiere by adempiere.
the class ServerProcessCtl method startDBProcess.
// startProcess
/**************************************************************************
* Start Database Process
* @param ProcedureName PL/SQL procedure name
* @return true if success
*/
protected boolean startDBProcess(String ProcedureName) {
// execute on this thread/connection
log.fine(ProcedureName + "(" + processInfo.getAD_PInstance_ID() + ")");
boolean started = false;
String trxName = trx != null ? trx.getTrxName() : null;
if (isServerProcess) {
Server server = CConnection.get().getServer();
try {
if (server != null) {
// See ServerBean
processInfo = server.dbProcess(processInfo, ProcedureName);
log.finest("server => " + processInfo);
started = true;
}
} catch (UndeclaredThrowableException ex) {
Throwable cause = ex.getCause();
if (cause != null) {
if (cause instanceof InvalidClassException)
log.log(Level.SEVERE, "Version Server <> Client: " + cause.toString() + " - " + processInfo, ex);
else
log.log(Level.SEVERE, "AppsServer error(1b): " + cause.toString() + " - " + processInfo, ex);
} else {
log.log(Level.SEVERE, " AppsServer error(1) - " + processInfo, ex);
cause = ex;
}
processInfo.setSummary(Msg.getMsg(Env.getCtx(), "ProcessRunError") + " " + cause.getLocalizedMessage());
processInfo.setError(true);
return false;
} catch (Exception ex) {
Throwable cause = ex.getCause();
if (cause == null)
cause = ex;
log.log(Level.SEVERE, "AppsServer error - " + processInfo, cause);
processInfo.setSummary(Msg.getMsg(Env.getCtx(), "ProcessRunError") + " " + cause.getLocalizedMessage());
processInfo.setError(true);
return false;
}
}
//try locally
if (!started) {
if (processInfo.isManagedTransaction())
return ProcessUtil.startDatabaseProcedure(processInfo, ProcedureName, trx);
else
return ProcessUtil.startDatabaseProcedure(processInfo, ProcedureName, trx, processInfo.isManagedTransaction());
}
return true;
}
use of org.compiere.interfaces.Server in project adempiere by adempiere.
the class ServerProcessCtl method startWorkflow.
// run
/**************************************************************************
* Start Workflow.
*
* @param AD_Workflow_ID workflow
* @return true if started
*/
protected boolean startWorkflow(int AD_Workflow_ID) {
log.fine(AD_Workflow_ID + " - " + processInfo);
boolean started = false;
if (isServerProcess) {
Server server = CConnection.get().getServer();
try {
if (server != null) {
// See ServerBean
processInfo = server.workflow(Env.getRemoteCallCtx(Env.getCtx()), processInfo, AD_Workflow_ID);
log.finest("server => " + processInfo);
started = true;
}
} catch (Exception ex) {
log.log(Level.SEVERE, "AppsServer error", ex);
started = false;
}
}
// Run locally
if (!started && !isServerProcess) {
if (trx != null)
processInfo.setTransactionName(trx.getTrxName());
MWFProcess wfProcess = ProcessUtil.startWorkFlow(Env.getCtx(), processInfo, AD_Workflow_ID);
started = wfProcess != null;
}
return started;
}
Aggregations