Process configs for a single repository microservice. Microservices rest on hdsApp which is designed to accommodate Dissemino webapps. With microservices however, the configs are limited to specifying the data model. There are no pages or articles, and no forms or form handlers. Arguments: None
| Return Type | Function name | Arguments |
|---|---|---|
| hzEcode | hdsApp::ReadMicroservice | (hzXmlNode*,) |
Declared in file: hzDissemino.h
Defined in file : hdsConfig.cpp
Function Logic:
Function body:
hzEcode hdsApp::ReadMicroservice (hzXmlNode* pRoot)
{
// Category: Microservice Configuration
//
// Process configs for a single repository microservice.
//
// Microservices rest on hdsApp which is designed to accommodate Dissemino webapps. With microservices however, the configs are limited to specifying the data model. There are
// no pages or articles, and no forms or form handlers.
//
// Arguments: None
//
// Returns: E_ARGUMENT If no XML node is supplied
// E_CONFIG If there are errors in the XML config
// E_OK Config read successful
_hzfunc("hdsApp::ReadMicroservice") ;
hzDocXml X ; // The config document
hzChain Z ; // For robot.txt etc
hzAttrset ai ; // XML node attribute iterator
hzXmlNode* pN ; // Current node
hzPair p ; // Misc name/value pair
hzString S ; // Intermeadiate string
hzEcode rc = E_OK ; // Return code
// Check root tag
if (!pRoot)
return hzerr(E_ARGUMENT, "No root supplied") ;
if (!pRoot->NameEQ("microService"))
return hzerr(E_CONFIG, "Expected root tag of <microService>. Found <%s>", pRoot->txtName()) ;
// { m_pLog->Log("Expected root tag of <microService>. Tag <%s> disallowed\n", pRoot->txtName()) ; return E_CONFIG ; }
m_pLog->Log("Obtained project's XML root %s\n", pRoot->txtName()) ;
// Get microservice params
for (ai = pRoot ; ai.Valid() ; ai.Advance())
{
if (ai.NameEQ("name")) m_Appname = ai.Value() ;
else if (ai.NameEQ("sslPvtKey")) m_SSL_PvtKey = ai.Value() ;
else if (ai.NameEQ("sslCert")) m_SSL_Cert = ai.Value() ;
else if (ai.NameEQ("sslCertCA")) m_SSL_CertCA = ai.Value() ;
else if (ai.NameEQ("configs")) m_Configdir = ai.Value() ;
else if (ai.NameEQ("datadir")) m_Datadir = ai.Value() ;
else if (ai.NameEQ("loghits")) m_AllHits = ai.Value() ;
else if (ai.NameEQ("portSTD")) m_nPortSTD = ai.Value() ? atoi(ai.Value()) : 0;
else if (ai.NameEQ("portSSL")) m_nPortSSL = ai.Value() ? atoi(ai.Value()) : 0;
else
{
rc = E_CONFIG ;
m_pLog->Log("File %s Line %d <webappCfg> tag: Invalid param (%s=%s)\n", pRoot->Fname(), pRoot->Line(), ai.Name(), ai.Value()) ;
}
}
if (rc != E_OK)
return rc ;
if (!m_Appname)
return hzerr(E_NOINIT, "No Project/Application name") ;
// Set up the subscriber class and repository
// if (m_OpFlags & DS_APP_SUBSCRIBERS)
// {
// rc = m_ADP.InitSubscribers(m_Datadir) ;
// if (rc != E_OK)
// { m_pLog->Log("The subscriber cache is not found in the ADP\n") ; return E_NOINIT ; }
// }
// Set up the app resources database
rc = InitResources() ;
if (rc != E_OK)
return hzerr(rc, "Resource Initialization Failed") ;
// m_Images = m_Docroot + "/img" ;
// Read in XML
for (pN = pRoot->GetFirstChild() ; rc == E_OK && pN ; pN = pN->Sibling())
{
if (pN->NameEQ("enum")) rc = _readDataEnum(pN) ;
else if (pN->NameEQ("class")) rc = _readClass(pN) ;
else if (pN->NameEQ("repos")) rc = _readRepos(pN) ;
else
{
rc = E_CONFIG ;
m_pLog->Log("File %s Line %d tag <%s> unexpected. Only enum, class and repos are allowed\n", pN->Fname(), pN->Line(), pN->txtName()) ;
}
}
if (rc != E_OK)
return rc ;
// Assert the data directory
rc = AssertDir(m_Datadir, 0777);
if (rc != E_OK)
{ m_pLog->Log("Cannot assert data directory %s\n", *m_Datadir) ; return E_WRITEFAIL ; }
/*
** if (chdir(*m_Docroot) < 0)
** {
** m_pLog->Log("Cannot CD to docroot [%s]\n", *m_Docroot) ;
** rc = E_NOINIT ;
** }
** else
** m_pLog->Log("Now operating in docroot [%s]\n", *m_Docroot) ;
** */
m_pLog->Log("Status=%s\n", Err2Txt(rc)) ;
return rc ;
}