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 TypeFunction nameArguments
hzEcodehdsApp::ReadMicroservice(hzXmlNode*,)

Declared in file: hzDissemino.h
Defined in file : hdsConfig.cpp

Function Logic:

0:START 1:unknown 2:Return hzerr(E_ARGUMENT,No root supplied) 3:unknown 4:Return hzerr(E_CONFIG,Expected root tag of . Found <%s>,pRoot->txtName()) 5:items 6:unknown 7:unknown 8:m_Appname 9:ai.NameEQ(sslPvtKey) 10:m_SSL_PvtKey 11:ai.NameEQ(sslCert) 12:m_SSL_Cert 13:ai.NameEQ(sslCertCA) 14:m_SSL_CertCA 15:ai.NameEQ(configs) 16:m_Configdir 17:ai.NameEQ(datadir) 18:m_Datadir 19:ai.NameEQ(loghits) 20:m_AllHits 21:ai.NameEQ(portSTD) 22:items 23:ai.NameEQ(portSSL) 24:items 25:rc items 26:unknown 27:Return rc 28:unknown 29:Return hzerr(E_NOINIT,No Project/Application name) 30:rc 31:unknown 32:Return hzerr(rc,Resource Initialization Failed) 33:unknown 34:unknown 35:rc 36:pN->NameEQ(class) 37:rc 38:pN->NameEQ(repos) 39:rc 40:rc items 41:unknown 42:Return rc 43:rc 44:unknown 45:items 46:Return E_WRITEFAIL 47:items 48:Return rc

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 ;
}