IDEMPIERE-1606 initial client testing > email improvements
This commit is contained in:
parent
aea4e1017a
commit
fbdb0e0efe
|
@ -0,0 +1,14 @@
|
||||||
|
SET SQLBLANKLINES ON
|
||||||
|
SET DEFINE OFF
|
||||||
|
|
||||||
|
-- Feb 11, 2014 2:29:31 AM ICT
|
||||||
|
-- IDEMPIERE-1606:initial client testing > email improvements
|
||||||
|
INSERT INTO AD_Process_Para (IsRange,AD_Process_Para_ID,AD_Process_Para_UU,AD_Reference_ID,IsMandatory,EntityType,Name,ColumnName,FieldLength,IsCentrallyMaintained,SeqNo,DefaultValue,IsActive,UpdatedBy,Updated,CreatedBy,Created,AD_Org_ID,IsEncrypted,AD_Client_ID,AD_Process_ID) VALUES ('N',200074,'a9304d73-8f35-487a-a020-fd24c98bb9db',10,'N','D','Administrative User Email','AdminUserEmail',60,'N',45,NULL,'Y',100,TO_DATE('2014-02-11 02:29:30','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2014-02-11 02:29:30','YYYY-MM-DD HH24:MI:SS'),0,'N',0,53161)
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Feb 11, 2014 2:32:28 AM ICT
|
||||||
|
INSERT INTO AD_Process_Para (IsRange,AD_Process_Para_ID,AD_Process_Para_UU,AD_Reference_ID,IsMandatory,EntityType,Name,ColumnName,FieldLength,IsCentrallyMaintained,SeqNo,DefaultValue,IsActive,UpdatedBy,Updated,CreatedBy,Created,AD_Org_ID,IsEncrypted,AD_Client_ID,AD_Process_ID) VALUES ('N',200075,'422bd18a-9354-4bb6-9fcd-9c7be9985f9a',10,'N','D','Normal User Email','NormalUserEmail',60,'N',55,NULL,'Y',100,TO_DATE('2014-02-11 02:32:28','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2014-02-11 02:32:28','YYYY-MM-DD HH24:MI:SS'),0,'N',0,53161)
|
||||||
|
;
|
||||||
|
|
||||||
|
SELECT register_migration_script('201402111604-IDEMPIERE-1606.sql') FROM dual
|
||||||
|
;
|
|
@ -0,0 +1,11 @@
|
||||||
|
-- Feb 11, 2014 2:29:31 AM ICT
|
||||||
|
-- IDEMPIERE-1606:initial client testing > email improvements
|
||||||
|
INSERT INTO AD_Process_Para (IsRange,AD_Process_Para_ID,AD_Process_Para_UU,AD_Reference_ID,IsMandatory,EntityType,Name,ColumnName,FieldLength,IsCentrallyMaintained,SeqNo,DefaultValue,IsActive,UpdatedBy,Updated,CreatedBy,Created,AD_Org_ID,IsEncrypted,AD_Client_ID,AD_Process_ID) VALUES ('N',200074,'a9304d73-8f35-487a-a020-fd24c98bb9db',10,'N','D','Administrative User Email','AdminUserEmail',60,'N',45,NULL,'Y',100,TO_TIMESTAMP('2014-02-11 02:29:30','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2014-02-11 02:29:30','YYYY-MM-DD HH24:MI:SS'),0,'N',0,53161)
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Feb 11, 2014 2:32:28 AM ICT
|
||||||
|
INSERT INTO AD_Process_Para (IsRange,AD_Process_Para_ID,AD_Process_Para_UU,AD_Reference_ID,IsMandatory,EntityType,Name,ColumnName,FieldLength,IsCentrallyMaintained,SeqNo,DefaultValue,IsActive,UpdatedBy,Updated,CreatedBy,Created,AD_Org_ID,IsEncrypted,AD_Client_ID,AD_Process_ID) VALUES ('N',200075,'422bd18a-9354-4bb6-9fcd-9c7be9985f9a',10,'N','D','Normal User Email','NormalUserEmail',60,'N',55,NULL,'Y',100,TO_TIMESTAMP('2014-02-11 02:32:28','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2014-02-11 02:32:28','YYYY-MM-DD HH24:MI:SS'),0,'N',0,53161)
|
||||||
|
;
|
||||||
|
|
||||||
|
SELECT register_migration_script('201402111604-IDEMPIERE-1606.sql') FROM dual
|
||||||
|
;
|
|
@ -36,12 +36,15 @@ import org.adempiere.exceptions.AdempiereException;
|
||||||
import org.compiere.model.MCity;
|
import org.compiere.model.MCity;
|
||||||
import org.compiere.model.MCurrency;
|
import org.compiere.model.MCurrency;
|
||||||
import org.compiere.model.MSetup;
|
import org.compiere.model.MSetup;
|
||||||
|
import org.compiere.model.MSysConfig;
|
||||||
import org.compiere.print.PrintUtil;
|
import org.compiere.print.PrintUtil;
|
||||||
import org.compiere.process.ProcessInfoParameter;
|
import org.compiere.process.ProcessInfoParameter;
|
||||||
import org.compiere.process.SvrProcess;
|
import org.compiere.process.SvrProcess;
|
||||||
import org.compiere.util.DB;
|
import org.compiere.util.DB;
|
||||||
|
import org.compiere.util.EMail;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.compiere.util.KeyNamePair;
|
import org.compiere.util.KeyNamePair;
|
||||||
|
import org.compiere.util.Util;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process to create a new client (tenant)
|
* Process to create a new client (tenant)
|
||||||
|
@ -76,6 +79,8 @@ public class InitialClientSetup extends SvrProcess
|
||||||
private boolean p_IsUseCampaignDimension = false;
|
private boolean p_IsUseCampaignDimension = false;
|
||||||
private boolean p_IsUseSalesRegionDimension = false;
|
private boolean p_IsUseSalesRegionDimension = false;
|
||||||
private String p_CoAFile = null;
|
private String p_CoAFile = null;
|
||||||
|
private String p_AdminUserEmail = null;
|
||||||
|
private String p_NormalUserEmail = null;
|
||||||
|
|
||||||
/** WindowNo for this process */
|
/** WindowNo for this process */
|
||||||
public static final int WINDOW_THIS_PROCESS = 9999;
|
public static final int WINDOW_THIS_PROCESS = 9999;
|
||||||
|
@ -137,6 +142,10 @@ public class InitialClientSetup extends SvrProcess
|
||||||
p_EMail = (String) para[i].getParameter();
|
p_EMail = (String) para[i].getParameter();
|
||||||
else if (name.equals("TaxID"))
|
else if (name.equals("TaxID"))
|
||||||
p_TaxID = (String) para[i].getParameter();
|
p_TaxID = (String) para[i].getParameter();
|
||||||
|
else if (name.equals("AdminUserEmail"))
|
||||||
|
p_AdminUserEmail = (String) para[i].getParameter();
|
||||||
|
else if (name.equals("NormalUserEmail"))
|
||||||
|
p_NormalUserEmail = (String) para[i].getParameter();
|
||||||
else
|
else
|
||||||
log.log(Level.SEVERE, "Unknown Parameter: " + name);
|
log.log(Level.SEVERE, "Unknown Parameter: " + name);
|
||||||
}
|
}
|
||||||
|
@ -205,6 +214,17 @@ public class InitialClientSetup extends SvrProcess
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate existence and read permissions on CoA file
|
// Validate existence and read permissions on CoA file
|
||||||
|
boolean email_login = MSysConfig.getBooleanValue(MSysConfig.USE_EMAIL_FOR_LOGIN, false);
|
||||||
|
if (email_login) {
|
||||||
|
if (Util.isEmpty(p_AdminUserEmail))
|
||||||
|
throw new AdempiereException("AdminUserEmail is required");
|
||||||
|
if (! EMail.validate(p_AdminUserEmail))
|
||||||
|
throw new AdempiereException("AdminUserEmail " + p_AdminUserEmail + " is incorrect");
|
||||||
|
if (Util.isEmpty(p_NormalUserEmail))
|
||||||
|
throw new AdempiereException("NormalUserEmail is required");
|
||||||
|
if (! EMail.validate(p_NormalUserEmail))
|
||||||
|
throw new AdempiereException("NormalUserEmail " + p_NormalUserEmail + " is incorrect");
|
||||||
|
}
|
||||||
File coaFile = new File(p_CoAFile);
|
File coaFile = new File(p_CoAFile);
|
||||||
if (!coaFile.exists())
|
if (!coaFile.exists())
|
||||||
throw new AdempiereException("CoaFile " + p_CoAFile + " does not exist");
|
throw new AdempiereException("CoaFile " + p_CoAFile + " does not exist");
|
||||||
|
@ -219,7 +239,7 @@ public class InitialClientSetup extends SvrProcess
|
||||||
MSetup ms = new MSetup(Env.getCtx(), WINDOW_THIS_PROCESS);
|
MSetup ms = new MSetup(Env.getCtx(), WINDOW_THIS_PROCESS);
|
||||||
|
|
||||||
if (! ms.createClient(p_ClientName, p_OrgValue, p_OrgName, p_AdminUserName, p_NormalUserName
|
if (! ms.createClient(p_ClientName, p_OrgValue, p_OrgName, p_AdminUserName, p_NormalUserName
|
||||||
, p_Phone, p_Phone2, p_Fax, p_EMail, p_TaxID)) {
|
, p_Phone, p_Phone2, p_Fax, p_EMail, p_TaxID, p_AdminUserEmail, p_NormalUserEmail)) {
|
||||||
ms.rollback();
|
ms.rollback();
|
||||||
throw new AdempiereException("Create client failed");
|
throw new AdempiereException("Create client failed");
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import java.sql.SQLException;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import org.adempiere.exceptions.AdempiereException;
|
||||||
import org.adempiere.util.ProcessUtil;
|
import org.adempiere.util.ProcessUtil;
|
||||||
import org.compiere.process.ProcessInfo;
|
import org.compiere.process.ProcessInfo;
|
||||||
import org.compiere.process.ProcessInfoParameter;
|
import org.compiere.process.ProcessInfoParameter;
|
||||||
|
@ -108,7 +109,8 @@ public final class MSetup
|
||||||
* @return true if created
|
* @return true if created
|
||||||
*/
|
*/
|
||||||
public boolean createClient (String clientName, String orgValue, String orgName,
|
public boolean createClient (String clientName, String orgValue, String orgName,
|
||||||
String userClient, String userOrg, String phone, String phone2, String fax, String eMail, String taxID)
|
String userClient, String userOrg, String phone, String phone2, String fax, String eMail, String taxID,
|
||||||
|
String adminEmail, String userEmail)
|
||||||
{
|
{
|
||||||
log.info(clientName);
|
log.info(clientName);
|
||||||
m_trx.start();
|
m_trx.start();
|
||||||
|
@ -276,19 +278,22 @@ public final class MSetup
|
||||||
* - Client
|
* - Client
|
||||||
* - Org
|
* - Org
|
||||||
*/
|
*/
|
||||||
|
MUser clientAdminUser = new MUser(m_ctx, 0, m_trx.getTrxName());
|
||||||
|
|
||||||
name = userClient;
|
name = userClient;
|
||||||
if (name == null || name.length() == 0)
|
if (name == null || name.length() == 0)
|
||||||
name = m_clientName + "Client";
|
name = m_clientName + "Client";
|
||||||
AD_User_ID = getNextID(AD_Client_ID, "AD_User");
|
|
||||||
AD_User_Name = name;
|
clientAdminUser.setPassword(name);
|
||||||
name = DB.TO_STRING(name);
|
clientAdminUser.setDescription(name);
|
||||||
sql = "INSERT INTO AD_User(" + m_stdColumns + ",AD_User_ID,"
|
clientAdminUser.setName(name);
|
||||||
+ "Name,Description,Password)"
|
clientAdminUser.setAD_Client_ID(AD_Client_ID);
|
||||||
+ " VALUES (" + m_stdValues + "," + AD_User_ID + ","
|
clientAdminUser.setAD_Org_ID(0);
|
||||||
+ name + "," + name + "," + name + ")";
|
clientAdminUser.setEMail(adminEmail);
|
||||||
no = DB.executeUpdate(sql, m_trx.getTrxName());
|
|
||||||
if (no != 1)
|
try {
|
||||||
{
|
clientAdminUser.saveEx();
|
||||||
|
} catch (AdempiereException ex) {
|
||||||
String err = "Admin User NOT inserted - " + AD_User_Name;
|
String err = "Admin User NOT inserted - " + AD_User_Name;
|
||||||
log.log(Level.SEVERE, err);
|
log.log(Level.SEVERE, err);
|
||||||
m_info.append(err);
|
m_info.append(err);
|
||||||
|
@ -296,22 +301,33 @@ public final class MSetup
|
||||||
m_trx.close();
|
m_trx.close();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AD_User_ID = clientAdminUser.getAD_User_ID();
|
||||||
|
AD_User_Name = name;
|
||||||
|
|
||||||
// Info
|
// Info
|
||||||
m_info.append(Msg.translate(m_lang, "AD_User_ID")).append("=").append(AD_User_Name).append("/").append(AD_User_Name).append("\n");
|
m_info.append(Msg.translate(m_lang, "AD_User_ID")).append("=").append(AD_User_Name).append("/").append(AD_User_Name).append("\n");
|
||||||
|
|
||||||
|
MUser clientUser = new MUser(m_ctx, 0, m_trx.getTrxName());
|
||||||
|
|
||||||
|
name = userClient;
|
||||||
|
if (name == null || name.length() == 0)
|
||||||
|
name = m_clientName + "Client";
|
||||||
|
|
||||||
name = userOrg;
|
name = userOrg;
|
||||||
if (name == null || name.length() == 0)
|
if (name == null || name.length() == 0)
|
||||||
name = m_clientName + "Org";
|
name = m_clientName + "Org";
|
||||||
AD_User_U_ID = getNextID(AD_Client_ID, "AD_User");
|
|
||||||
AD_User_U_Name = name;
|
clientUser.setPassword(name);
|
||||||
name = DB.TO_STRING(name);
|
clientUser.setDescription(name);
|
||||||
sql = "INSERT INTO AD_User(" + m_stdColumns + ",AD_User_ID,"
|
clientUser.setName(name);
|
||||||
+ "Name,Description,Password)"
|
clientUser.setAD_Client_ID(AD_Client_ID);
|
||||||
+ " VALUES (" + m_stdValues + "," + AD_User_U_ID + ","
|
clientUser.setAD_Org_ID(0);
|
||||||
+ name + "," + name + "," + name + ")";
|
clientUser.setEMail(userEmail);
|
||||||
no = DB.executeUpdate(sql, m_trx.getTrxName());
|
|
||||||
if (no != 1)
|
try {
|
||||||
{
|
clientUser.saveEx();
|
||||||
|
} catch (AdempiereException ex) {
|
||||||
String err = "Org User NOT inserted - " + AD_User_U_Name;
|
String err = "Org User NOT inserted - " + AD_User_U_Name;
|
||||||
log.log(Level.SEVERE, err);
|
log.log(Level.SEVERE, err);
|
||||||
m_info.append(err);
|
m_info.append(err);
|
||||||
|
@ -319,6 +335,9 @@ public final class MSetup
|
||||||
m_trx.close();
|
m_trx.close();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AD_User_U_ID = clientUser.getAD_User_ID();
|
||||||
|
AD_User_U_Name = name;
|
||||||
// Info
|
// Info
|
||||||
m_info.append(Msg.translate(m_lang, "AD_User_ID")).append("=").append(AD_User_U_Name).append("/").append(AD_User_U_Name).append("\n");
|
m_info.append(Msg.translate(m_lang, "AD_User_ID")).append("=").append(AD_User_U_Name).append("/").append(AD_User_U_Name).append("\n");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue