| Return Type | Function name | Arguments |
|---|---|---|
| hzEcode | hdsSphere::ReadSphere | (hzXmlNode*,) |
Declared in file: hzDissemino.h
Defined in file : hdsConfig.cpp
Function Logic:
Function body:
hzEcode hdsSphere::ReadSphere (hzXmlNode* pRoot)
{
_hzfunc("hdsSphere::ReadSphere") ;
hzDocXml X ;
hzXmlNode* pN ;
hdsApp* pApp ;
hzAttrset ai ;
hzDomain domain ;
hzDomain subdom ;
hzString name ;
hzString baseDir ;
hzString rootFile ;
hzString cookieBase ;
hzString pvtKey ;
hzString cert ;
hzString certCA ;
uint32_t nA ;
uint32_t portSTD ;
uint32_t portSSL ;
uint32_t bOpFlags ;
hzEcode rc = E_OK ;
InitJS_Events() ;
if (!pRoot->NameEQ("sphereCfg"))
{ m_pLog->Log("Expected root tag of <sphereCfg>. Tag <%s> disallowed\n", pRoot->txtName()) ; return E_SYNTAX ; }
/*
** ** Get sphere parameters
** */
for (ai = pRoot ; ai.Valid() ; ai.Advance())
{
if (ai.NameEQ("name")) m_Name = ai.Value() ;
else if (ai.NameEQ("basedir")) m_Basedir = ai.Value() ;
else if (ai.NameEQ("logroot")) m_Logroot = ai.Value() ;
else if (ai.NameEQ("sslPvtKey")) m_dfltSSL_PvtKey = ai.Value() ;
else if (ai.NameEQ("sslCert")) m_dfltSSL_Cert = ai.Value() ;
else if (ai.NameEQ("sslCertCA")) m_dfltSSL_CertCA = ai.Value() ;
else if (ai.NameEQ("portSTD")) m_nCommonPortSTD = ai.Value() ? atoi(ai.Value()) : 0;
else if (ai.NameEQ("portSSL")) m_nCommonPortSSL = ai.Value() ? atoi(ai.Value()) : 0;
else
{
m_pLog->Log("File %s Line %d <sphereCfg> tag: Expect name|basedir|sslPvtKey|sslCert|sslCertCA|portSTD|portSSL only. Invalid param (%s=%s)\n",
pRoot->Fname(), pRoot->Line(), ai.Name(), ai.Value()) ;
rc = E_SYNTAX ;
}
}
if ((m_dfltSSL_PvtKey || m_dfltSSL_Cert || m_dfltSSL_CertCA) && !(m_dfltSSL_PvtKey && m_dfltSSL_Cert && m_dfltSSL_CertCA))
{ rc = E_SYNTAX ; m_pLog->Log("File %s Line %d <sphereCfg> Must set NONE or ALL SSL params\n", pRoot->Fname(), pRoot->Line()) ; }
if (rc != E_OK)
return rc ;
/*
** ** Get initial parameters for each application
** */
for (pN = pRoot->GetFirstChild() ; rc == E_OK && pN ; pN = pN->Sibling())
{
if (!pN->NameEQ("webapp"))
{ rc = E_SYNTAX ; m_pLog->Log("File %s Line %d. Expected <webapp> tag, not <%s>\n", pN->Fname(), pN->Line(), pN->txtName()) ; break ; }
bOpFlags = portSTD = portSSL = 0;
for (ai = pN ; ai.Valid() ; ai.Advance())
{
if (ai.NameEQ("name")) name = ai.Value() ;
else if (ai.NameEQ("domain")) domain = ai.Value() ;
else if (ai.NameEQ("subdom")) subdom = ai.Value() ;
else if (ai.NameEQ("basedir")) baseDir = ai.Value() ;
else if (ai.NameEQ("rootfile")) rootFile = ai.Value() ;
else if (ai.NameEQ("robot")) bOpFlags |= ai.ValEQ("true") ? DS_APP_ROBOT : 0;
else if (ai.NameEQ("index")) bOpFlags |= ai.ValEQ("true") ? DS_APP_SITEINDEX : 0;
else if (ai.NameEQ("login")) bOpFlags |= ai.ValEQ("true") ? DS_APP_SUBSCRIBERS : 0;
else if (ai.NameEQ("sslPvtKey")) pvtKey = ai.Value() ;
else if (ai.NameEQ("sslCert")) cert = ai.Value() ;
else if (ai.NameEQ("sslCertCA")) certCA = ai.Value() ;
else if (ai.NameEQ("portSTD")) portSTD = ai.Value() ? atoi(ai.Value()) : 0;
else if (ai.NameEQ("portSSL")) portSSL = ai.Value() ? atoi(ai.Value()) : 0;
else
{
m_pLog->Log("File %s Line %d <webapp> tag: Expect name|domain|basedir|rootfile|index|portSTD|portSSL only. Invalid param (%s=%s)\n",
pRoot->Fname(), pRoot->Line(), ai.Name(), ai.Value()) ;
rc = E_SYNTAX ;
}
}
if (portSTD)
{
if (portSTD > 0xffff)
{ rc = E_SYNTAX ; m_pLog->Log("File %s Line %d <webapp> HTTP port illegal (%u)\n", pRoot->Fname(), pRoot->Line(), portSTD) ; }
}
else
{
if (!m_nCommonPortSTD)
{ rc = E_SYNTAX ; m_pLog->Log("File %s Line %d <webapp> No HTTP port set in the Sphere or the APP\n", pRoot->Fname(), pRoot->Line()) ; }
}
if (portSSL)
{
if (portSSL > 0xffff)
{ rc = E_SYNTAX ; m_pLog->Log("File %s Line %d <webapp> HTTP port illegal (%u)\n", pRoot->Fname(), pRoot->Line(), portSTD) ; }
}
else
{
if (!m_nCommonPortSSL)
{ rc = E_SYNTAX ; m_pLog->Log("File %s Line %d <webapp> No HTTP port set in the Sphere or the APP\n", pRoot->Fname(), pRoot->Line()) ; }
}
if (rc != E_OK)
break ;
rc = _hzGlobal_Dissemino->AddApplication(domain, baseDir, rootFile, pvtKey, cert, certCA, portSTD, portSSL, bOpFlags) ;
if (rc == E_OK)
m_pLog->Log("Added webapp %s %s %s\n", *domain, *baseDir, *rootFile) ;
else
m_pLog->Log("Failed to ADD webapp %s %s %s\n", *domain, *baseDir, *rootFile) ;
if (subdom)
{
rc = _hzGlobal_Dissemino->AddApplication(subdom, baseDir, rootFile, pvtKey, cert, certCA, portSTD, portSSL, bOpFlags) ;
if (rc == E_OK)
m_pLog->Log("Added webapp %s %s %s\n", *subdom, *baseDir, *rootFile) ;
else
m_pLog->Log("Failed to ADD webapp %s %s %s\n", *subdom, *baseDir, *rootFile) ;
}
}
for (nA = 1; rc == E_OK && nA <&eq; _hzGlobal_Dissemino->Count() ; nA++)
{
pApp = _hzGlobal_Dissemino->GetApplication(nA) ;
if (pApp->m_nPortSTD || pApp->m_nPortSSL)
{
pApp->m_OpFlags |= DS_APP_BYPROXY ;
m_pLog->Log("Webapp %s:- Hosted by proxy\n", *pApp->m_Appname) ;
continue ;
}
pApp->m_ADP.InitStandard(pApp->m_Appname) ;
if (pApp->m_OpFlags & DS_APP_SITEINDEX)
pApp->m_ADP.InitSiteIndex("../data") ;
pApp->SetStdTypeValidations() ;
m_pLog->Log("Webapp %s:- Standard Types created\n", *pApp->m_Appname) ;
rc = pApp->ReadWebappCfg() ;
if (rc == E_OK)
{
pApp->SetupMasterMenu() ;
m_pLog->Log("Webapp %s:- Data Model Editing initialized\n", *pApp->m_Domain) ;
rc = pApp->CheckProject() ;
}
}
return rc ;
}