示例#1
0
void SWProcess::computerUpdated(IPropertyTree *computerNode, const char* oldName,
     const char* oldIp, const char* instanceXMLTagName)
{
   IPropertyTree *software = m_envHelper->getEnvTree()->queryPropTree("Software");
   Owned<IPropertyTreeIterator> compIter = software->getElements(m_processName);

   const char *instance = (instanceXMLTagName)? instanceXMLTagName: m_instanceElemName.str();

   synchronized block(mutex);
   ForEach (*compIter)
   {
      IPropertyTree *comp = &compIter->query();
      Owned<IPropertyTreeIterator> instanceIter = comp->getElements(instance);
      ForEach (*instanceIter)
      {
         IPropertyTree *instance = &instanceIter->query();
         if (instance->hasProp(XML_ATTR_NAME) && !stricmp(instance->queryProp(XML_ATTR_NAME), oldName))
         {
            if (stricmp(computerNode->queryProp(XML_ATTR_NAME), instance->queryProp(XML_ATTR_NAME)))
               instance->setProp(XML_ATTR_NAME, computerNode->queryProp(XML_ATTR_NAME));
            if (instance->hasProp(m_ipAttribute.str()) && stricmp(computerNode->queryProp(XML_ATTR_NETADDRESS), instance->queryProp(m_ipAttribute.str())))
               instance->setProp(m_ipAttribute.str(), computerNode->queryProp(XML_ATTR_NETADDRESS));
            if (instance->hasProp("@computer") && stricmp(computerNode->queryProp(XML_ATTR_NAME), instance->queryProp("@computer")))
               instance->setProp("@computer", computerNode->queryProp(XML_ATTR_NAME));
         }
         else if (instance->hasProp(m_ipAttribute.str()) && !stricmp(instance->queryProp(m_ipAttribute.str()), oldIp))
         {
            instance->setProp(m_ipAttribute.str(), computerNode->queryProp(XML_ATTR_NETADDRESS));
         }
      }
   }
}
示例#2
0
void SWProcess::addInstances(IPropertyTree *parent, IPropertyTree *params)
{
  IPropertyTree* pAttrs = params->queryPropTree("Attributes");
  if (!pAttrs)
     throw MakeStringException(CfgEnvErrorCode::InvalidParams, "Miss instance attributes input");

  const char * instanceXMLTagName = getInstanceXMLTagName(params->queryProp("@selector"));

  Owned<IPropertyTreeIterator> iter = pAttrs->getElements("Attribute");

  ForEach (*iter)
  {
     IPropertyTree *attr = &iter->query();
     const char* propName = attr->queryProp("@name");
     if (!stricmp(propName, "ip") || !stricmp(propName, "ipfile"))
     {
        bool isFile = false;
        if (!stricmp(propName, "ipfile")) isFile = true;

        StringArray ips;
        m_envHelper->processNodeAddress(attr->queryProp("@value"), ips, isFile);
        for ( unsigned i = 0; i < ips.ordinality() ; i++)
        {
           IPropertyTree * computerNode = addComputer(ips.item(i));
           addInstance(computerNode, parent, pAttrs, instanceXMLTagName);
        }
     }
  }
}
示例#3
0
IHqlExpression * XmlEclRepository::doLoadSymbol(IPropertyTree * repository, IAtom * modname, IAtom * attrname)
{
    StringBuffer s;
    IPropertyTree* module = repository->queryPropTree(s.append("./Module[@name=\"").append(*modname).append("\"]").str());
    if(!module)
    {
        if (logging())
            DBGLOG("No data for module %s",modname->getAtomNamePtr());
        return 0;
    }
    int access = module->getPropInt("@access",cs_full);

    s.clear().append("./Attribute[@name=\"").append(*attrname).append("\"]");
    Owned<IPropertyTreeIterator> it = module->getElements(s.str());
    for(it->first();it->isValid();it->next())
    {
        Owned<IHqlExpression> item = toNamedSymbol(&it->query(), *modname,access);
        CHqlNamedSymbol* cur = QUERYINTERFACE(item.get(), CHqlNamedSymbol);

        if(cur)
            return LINK(cur);
    }

    return 0;
}
示例#4
0
bool CLogThread::IsArray(IPropertyTree& tree)
{
// If the node have more than one children, and all have the same name,
// then it is an array.
    StringBuffer name, temp;
    Owned<IPropertyTreeIterator> itr =  tree.getElements("*");
    int count = 0;
    for (itr->first(); itr->isValid(); itr->next())
    {
        if (count==0)
            itr->query().getName(name);
        else
        {
            itr->query().getName(temp);
            if (stricmp(name,temp)!=0)
                return false;
            temp.clear();
        }
        count++;
    }

    //Loophole in code above if there is only 1 item in the array
    if(count==1)
    {
        if (name!=NULL && stricmp(name,"Item")==0)
            return true;
    }
    return count>1;
}
CWsMachineSoapBindingEx::CWsMachineSoapBindingEx(IPropertyTree* cfg, 
                                                 const char *bindname/*=NULL*/, 
                                                 const char *procname/*=NULL*/)
   :Cws_machineSoapBinding(cfg, bindname, procname)
{
    StringBuffer xpath;
    xpath.appendf("Software/EspProcess[@name=\"%s\"]", procname);
   IPropertyTree* pEspProcess = cfg->queryPropTree(xpath.str());

   if (pEspProcess)
   {
       xpath.clear().appendf("EspBinding[@name=\"%s\"]/@service", bindname);
      const char* service = pEspProcess->queryProp(xpath.str());

      if (service)
      {
          xpath.clear().appendf("EspService[@name=\"%s\"]/MachineInfo/Software/*", service);
         Owned<IPropertyTreeIterator> it = pEspProcess->getElements(xpath.str());
         ForEach(*it)
         {
            m_processTypes.append(it->query().queryName());
         }
         m_processTypes.sort(SortFunction);
      }
   }
}
示例#6
0
 void appendManifestSchemas(IPropertyTree &manifest, ILoadedDllEntry &loadedDll)
 {
     assertex(!finalized);
     Owned<IPropertyTreeIterator> iter = manifest.getElements("Resource[@type='RESULT_XSD']");
     ForEach(*iter)
     appendSchemaResource(iter->query(), loadedDll);
 }
void SWDirectories::modify(IPropertyTree *params)
{
  synchronized block(mutex);

  IPropertyTree * envTree = m_envHelper->getEnvTree();

  IPropertyTree * pAttrsTree = params->queryPropTree("Attributes");
  //Todo: if name attribute given in @selector
  //const char* selector = params->queryProp("@selector");
  const char* selectorKey = params->queryProp("@selector-key");

  if (selectorKey)
  {
      const char* dirPath = pAttrsTree->queryProp("Attribute[1]/@value");
      setCategoryAttributes(envTree, selectorKey, dirPath);
  }
  else
  {
    Owned<IPropertyTreeIterator> attrsIter = pAttrsTree->getElements("Attribute");
    ForEach(*attrsIter)
    {
      IPropertyTree* pAttrTree = &attrsIter->query();
      const char* dirName = pAttrTree->queryProp("@name");
      const char* dirPath = pAttrTree->queryProp("@value");
      setCategoryAttributes(envTree, dirName, dirPath);
    }
  }

  //query id
}
示例#8
0
void SWProcess::computerDeleted(const char* ipAddress, const char* computerName, const char *instanceXMLTagName)
{
   IPropertyTree * software = m_envHelper->getEnvTree()->queryPropTree(XML_TAG_SOFTWARE);
   Owned<IPropertyTreeIterator> compIter = software->getElements(m_processName);

   const char *instance = (instanceXMLTagName)? instanceXMLTagName: m_instanceElemName.str();

   synchronized block(mutex);
   ForEach (*compIter)
   {
      IPropertyTree * comp = &compIter->query();
      Owned<IPropertyTreeIterator> instanceIter = comp->getElements(instance);
      ForEach (*instanceIter)
      {
         IPropertyTree * instance = &instanceIter->query();
         if ((instance->hasProp(m_ipAttribute.str()) && stricmp(instance->queryProp(m_ipAttribute.str()), ipAddress)) ||
             (instance->hasProp("@computer") && stricmp(instance->queryProp("@computer"), computerName)))
            comp->removeTree(instance);
      }
   }
}
示例#9
0
void CLogThread::addLogInfo(IArrayOf<IEspLogInfo>& valueArray,IPropertyTree& logInfo)
{

    StringBuffer dataStr,nameStr,valueStr;
    Owned<IPropertyTreeIterator> itr =  logInfo.getElements("*");
    itr->first();
    while(itr->isValid())
    {
        IPropertyTree &node = itr->query();
        const char* name = node.queryName();
        if (getTreeFlattening()==true && node.hasChildren() == true)
        {

            if(IsArray(node)==true)
            {
                FlattenArray(valueArray,node,nameStr);
            }
            else
            {
                FlattenTree(valueArray,node,nameStr);
            }
        //  logElement.setName(node.queryName());
        //  dataStr.clear();
            /*toXML(&node,dataStr);
            //DOM temporary work about for the lack of XML decoding in esp arrays
            StringBuffer encodedData;
            JBASE64_Encode(dataStr.str(), dataStr.length() , encodedData);
            logElement.setData(encodedData.str());
        */

        }
        else if (getTreeFlattening()==false && node.hasChildren() == true)
        {
            IClientLogInfo& logElement = addLogInfoElement(valueArray);
            logElement.setName(node.queryName());
            dataStr.clear();
            toXML(&node,dataStr);
            //DOM temporary work about for the lack of XML decoding in esp arrays
            StringBuffer encodedData;
            JBASE64_Encode(dataStr.str(), dataStr.length() , encodedData);
            logElement.setData(encodedData.str());
        }
        else if (node.queryProp("") != 0 && ( strcmp(node.queryProp(""),"0") != 0 ))
        {
            IClientLogInfo& logElement = addLogInfoElement(valueArray);
            logElement.setName(node.queryName());
            logElement.setValue(node.queryProp(""));
        }
        itr->next();
    }

}
示例#10
0
static void appendClusterEndpoints(IPropertyTree& cluster,SocketEndpointArray &eps)
{
    SocketEndpoint ep;
    Owned<IPropertyTree> master = cluster.getPropTree("ThorMasterProcess");
    if (master)
        appendNodeEndpoint(*master,eps);
    Owned<IPropertyTreeIterator> nodes= cluster.getElements("ThorSlaveProcess");
    if (nodes&&nodes->first()) {
        do {
            appendNodeEndpoint(nodes->query(),eps);
        } while (nodes->next());
    }
}
示例#11
0
static bool recursiveCheckEmptyScope(IPropertyTree &ct)
{
    Owned<IPropertyTreeIterator> iter = ct.getElements("*");
    ForEach(*iter) {
        IPropertyTree &item = iter->query();
        const char *n = item.queryName();
        if (!n||(strcmp(n,queryDfsXmlBranchName(DXB_Scope))!=0))
            return false;
        if (!recursiveCheckEmptyScope(item))
            return false;
    }
    return true;
}
示例#12
0
void SWProcess::checkInstanceAttributes(IPropertyTree *instanceNode, IPropertyTree *parent)
{
   assert(instanceNode);
   if (portIsRequired() && !instanceNode->hasProp("@port"))
   {
      int port = getDefaultPort();
      if (!port)
         throw MakeStringException(CfgEnvErrorCode::InvalidParams, "Miss port attribute in instance");
      instanceNode->addPropInt("@port", port);
   }

   StringBuffer xpath;
   xpath.clear().appendf("xs:element/xs:complexType/xs:sequence/xs:element[@name=\"%s\"]",m_instanceElemName.str());
   IPropertyTree * instanceSchemaNode = m_pSchema->queryPropTree(xpath.str());
   if (!instanceSchemaNode) return;

   bool needDirProp = false;
   Owned<IPropertyTreeIterator> attrIter = instanceSchemaNode->getElements("xs:complexType/xs:attribute");
   ForEach(*attrIter)
   {
      IPropertyTree * attr = &attrIter->query();
      const char *attrName = attr->queryProp("@name");
      if (!stricmp(attrName, "directory"))
      {
         needDirProp = true;
         continue;
      }

      const char *defaultValue = attr->queryProp("@default");
      if (!defaultValue) continue;
      xpath.clear().appendf("@%s", attrName);
      if (instanceNode->hasProp(xpath.str())) continue;
      const char *use = attr->queryProp("@use");
      if (!use || !stricmp(use, "required")  || !stricmp(use, "optional"))
      {
         StringBuffer sbDefaultValue;
         sbDefaultValue.clear().append(defaultValue);
         sbDefaultValue.replaceString("\\", "\\\\");
         instanceNode->addProp(xpath.str(), sbDefaultValue.str());
       }
   }

   if (needDirProp && !instanceNode->hasProp("@directory"))
   {
      const IProperties *props = m_envHelper->getEnvConfigOptions().getProperties();
      StringBuffer sb;
      sb.clear().appendf("%s/%s",
         props->queryProp("runtime"), parent->queryProp(XML_ATTR_NAME));
      instanceNode->addProp("@directory", sb.str());
   }
}
示例#13
0
void CLogThread::deserializeLogInfo(IArrayOf<IEspLogInfo>& valueArray,IPropertyTree& logInfo)
{
    Owned<IPropertyTreeIterator> itr =  logInfo.getElements("LogInfo");
    itr->first();
    while(itr->isValid())
    {
        IPropertyTree &node = itr->query();
        IClientLogInfo& logElement = addLogInfoElement(valueArray);
        logElement.setName(node.queryProp("Name"));
        logElement.setValue(node.queryProp("Value"));
        logElement.setData(node.queryProp("Data"));
        itr->next();
    }
}
示例#14
0
void CBaseSecurityManager::init(const char *serviceName, IPropertyTree *config)
{
    if(config == NULL)
        return;
    
    m_config.set(config);

    m_permissionsCache.setCacheTimeout( 60 * config->getPropInt("@cacheTimeout", 5) );
    

    m_dbserver.appendf("%s",config->queryProp("@serverName"));
    m_dbuser.appendf("%s",config->queryProp("@systemUser"));
    if(config->hasProp("@ConnectionPoolSize"))
        m_poolsize = atoi(config->queryProp("@connectionPoolSize"));
    else
        m_poolsize = 2;

    StringBuffer encodedPass,encryptedPass;
    encodedPass.appendf("%s",config->queryProp("@systemPassword"));
    decrypt(m_dbpassword, encodedPass.str());

    m_dbpasswordEncoding = SecPwEnc_plain_text;

    StringBuffer strPasswordEncoding;
    const char* encodingType = config->queryProp("@encodePassword");
    if(encodingType && strcmp(encodingType,"MD5") == 0)
        m_dbpasswordEncoding=SecPwEnc_salt_md5;
    else if (encodingType && strcmp(encodingType,"Rijndael") == 0)
        m_dbpasswordEncoding=SecPwEnc_Rijndael;
    else if (encodingType && strcmp(encodingType,"Accurint MD5") == 0)
        m_dbpasswordEncoding = SecPwEnc_salt_accurint_md5;

    if(m_dbserver.length() == 0 || m_dbuser.length() == 0)
        throw MakeStringException(-1, "CBaseSecurityManager() - db server or user is missing");

    IPropertyTree* pNonRestrictedIPTree = config->queryBranch("SafeIPList");
    if(pNonRestrictedIPTree)
    {
        Owned<IPropertyTreeIterator> Itr = pNonRestrictedIPTree->getElements("ip");
        for(Itr->first();Itr->isValid();Itr->next())
        {
            IPropertyTree& tree = Itr->query();
            m_safeIPList[tree.queryProp("")]=true;
        }
    }

    m_enableIPRoaming = config->getPropBool("@enableIPRoaming");
    m_enableOTP = config->getPropBool("@enableOTP",false);
    m_passwordExpirationWarningDays = config->getPropInt(".//@passwordExpirationWarningDays", 10); //Default to 10 days
}
示例#15
0
bool getAllClusters(SocketEndpointArray &eps)
{
    Owned<IRemoteConnection> conn = querySDS().connect("/Environment/Software", myProcessSession(), RTM_LOCK_READ, SDS_CONNECT_TIMEOUT);
    if (!conn) 
        return false;
    IPropertyTree* root = conn->queryRoot();
    Owned<IPropertyTreeIterator> clusters= root->getElements("ThorCluster");
    if (clusters->first()) {
        do {
            IPropertyTree &cluster = clusters->query();
            if (!getCluster(cluster.queryProp("@name"),eps))
                ERRLOG("Cluster %s not found",cluster.queryProp("@name"));
        } while (clusters->next());
    }
    return eps.ordinality()!=0;
}
示例#16
0
void SWProcess::processNameChanged(const char* process, const char *newName, const char* oldName)
{
   StringBuffer xpath;
   xpath.clear().appendf("@%s", process);
   IPropertyTree * swTree = m_envHelper->getEnvTree()->queryPropTree("/Software");
   Owned<IPropertyTreeIterator> compIter =  swTree->getElements(m_envHelper->getXMLTagName(m_name.str()));
   synchronized block(mutex);
   ForEach(*compIter)
   {
      IPropertyTree * compTree = &compIter->query();
      if ((oldName != NULL) && strcmp(oldName, compTree->queryProp(xpath.str())))
         continue;

      if (compTree->queryProp(xpath.str()))
         compTree->setProp(xpath.str(), newName);
   }
}
示例#17
0
bool CLogThread::FlattenTree(IArrayOf<IEspLogInfo>& valueArray,IPropertyTree& tree,StringBuffer& RootName)
{
    StringBuffer Value,Name;
    if (tree.hasChildren() == true)
    {

        Owned<IPropertyTreeIterator> itr =  tree.getElements("*");
        itr->first();
        while(itr->isValid())
        {
            IPropertyTree &node = itr->query();
            if(RootName.length() > 0)
                Name.appendf("%s_",RootName.str());
            Name.appendf("%s",node.queryName());

            if (node.hasChildren() == true)
            {
                if(IsArray(node)==true)
                    FlattenArray(valueArray,node,Name);
                else
                    FlattenTree(valueArray,node,Name);
            }
            else
            {
                const char* _value = tree.queryProp(node.queryName());
                if(tree.hasProp(node.queryName())==true && _value!=0 && _value!='\0')
                {
                    Value.appendf("%s",tree.queryProp(node.queryName()));
                    IClientLogInfo& logElement = addLogInfoElement(valueArray);
                    logElement.setName(Name.str());
                    logElement.setValue(Value.str());
                    //DBGLOG("Add log element: %s, %s", Name.str(), Value.str());
                    Value.clear();
                }
            }
            Name.clear();
            itr->next();
        }

    }
    else
    {
        return false;
    }
    return true;
}
示例#18
0
bool XmlEclRepository::doLoadModule(IPropertyTree * repository, IHqlRemoteScope * rScope, IErrorReceiver *errs)
{
    IHqlScope * scope = rScope->queryScope();
    const char * scopeName = scope->queryName()->getAtomNamePtr();

    StringBuffer s;
    const char * modName = scope->queryFullName();
    IPropertyTree* module = repository->queryPropTree(s.append("./Module[@name=\"").append(modName).append("\"]").str());
    if(!module)
    {
        if (logging())
            DBGLOG("No data for module %s",scopeName);
        return false;
    }
    int access = module->getPropInt("@access",cs_full);

    if(module->queryProp("Text"))
    {
        const char * path = module->queryProp("@sourcePath");
        Owned<ISourcePath> sourcePath = createSourcePath(path ? path : modName);
        Owned<IFileContents> text = createFileContentsFromText(module->queryProp("Text"), sourcePath);
        rScope->setText(text);
    }
    else
    {
        StringBuffer buf("./Attribute");
        Owned<IPropertyTreeIterator> it = module->getElements(buf.str());
        if (it->first())
        {
            for(;it->isValid();it->next())
            {
                Owned<IHqlExpression> item = toNamedSymbol(&it->query(), *scope->queryName(), access);
                ((CHqlScope*)scope)->defineSymbol(LINK(item));
            }
        }
        else
        {
            if (logging())
                DBGLOG("No definitions were added for module %s", scopeName);
        }
    }
    return true;
}
示例#19
0
IConfigComp* SWProcess::getInstanceNetAddresses(StringArray& ipList, const char* clusterName)
{
  IPropertyTree * envTree = m_envHelper->getEnvTree();
  StringBuffer xpath;
  if (clusterName)
     xpath.clear().appendf(XML_TAG_SOFTWARE "/%s[@name=\"%s\"]", m_processName.str(), clusterName);
  else
     xpath.clear().appendf(XML_TAG_SOFTWARE "/%s[1]", m_processName.str());

  IPropertyTree *compTree = envTree->queryPropTree(xpath.str());

  Owned<IPropertyTreeIterator> iter = compTree->getElements(m_instanceElemName.str());
  ForEach (*iter)
  {
     IPropertyTree *instance = &iter->query();
     ipList.append(instance->queryProp("@netAddress"));

  }
  return (IConfigComp*)this;
}
示例#20
0
void SWProcess::modifyInstance(IPropertyTree *parent, IPropertyTree *params)
{
   IPropertyTree* pAttrs = params->queryPropTree("Attributes");
   if (!pAttrs)
      throw MakeStringException(CfgEnvErrorCode::InvalidParams, "Miss instance attributes input");

   const char * instanceXMLTagName = getInstanceXMLTagName(pAttrs->queryProp("@selector"));
   Owned<IPropertyTreeIterator> iter = pAttrs->getElements("Attribute");
   ForEach (*iter)
   {
      IPropertyTree *attr = &iter->query();
      const char* propName = attr->queryProp("@name");
      if (stricmp(propName, "ip"))
         continue;

      StringBuffer xpath;
      IPropertyTree *instanceToModify;
      const char* oldIp = attr->queryProp("@oldValue");
      if ((!oldIp || !(*oldIp)) && m_singleInstanceList.find(m_name.str()) == NotFound)
         throw MakeStringException(CfgEnvErrorCode::InvalidParams, "Miss instance  current ip to change");
      else if (oldIp && *oldIp)
      {
         xpath.clear().appendf("%s[%s=\"%s\"]", instanceXMLTagName, m_ipAttribute.str(), oldIp);
         instanceToModify = parent->queryPropTree(xpath.str());
      }
      else
      {
         xpath.clear().appendf("%s[1]", instanceXMLTagName);
         instanceToModify = parent->queryPropTree(xpath.str());
      }

      if (!instanceToModify)
         throw MakeStringException(CfgEnvErrorCode::InvalidParams, "Cannot find instance node to modify");

      IPropertyTree * computerNode = addComputer(attr->queryProp("@value"));
      instanceToModify->setProp("@computer", computerNode->queryProp(XML_ATTR_NAME));

      instanceToModify->setProp(m_ipAttribute.str(), computerNode->queryProp(XML_ATTR_NETADDRESS));
  }

}
示例#21
0
static void loadMachineMap()
{
    if (machinelist.ordinality())
        return;
    Owned<IRemoteConnection> conn = querySDS().connect("/Environment/Hardware", myProcessSession(), RTM_LOCK_READ, SDS_LOCK_TIMEOUT);
    if (!conn)
        return;
    IPropertyTree* root = conn->queryRoot();
    Owned<IPropertyTreeIterator> machines= root->getElements("Computer");
    if (machines->first()) {
        do {
            IPropertyTree &machine = machines->query();
            SocketEndpoint ep(machine.queryProp("@netAddress"));
            ep.port = getDaliServixPort();
            const char *name = machine.queryProp("@name");
            const char *state=machine.queryProp("@state");
            CMachineEntry *entry = new CMachineEntry(name,ep,!state||stricmp(state,"Available")==0);
            machinemap.setValue(name, entry);
            machinelist.append(*entry);
        } while (machines->next());
    }
}
void CWSESPControlEx::init(IPropertyTree *cfg, const char *process, const char *service)
{
    if(cfg == NULL)
        throw MakeStringException(-1, "Can't initialize CWSESPControlEx, cfg is NULL");

    espProcess.set(process);

    VStringBuffer xpath("Software/EspProcess[@name=\"%s\"]", process);
    IPropertyTree* espCFG = cfg->queryPropTree(xpath.str());
    if (!espCFG)
        throw MakeStringException(-1, "Can't find EspBinding for %s", process);

    Owned<IPropertyTreeIterator> it = espCFG->getElements("AuthDomains/AuthDomain");
    ForEach(*it)
    {
        IPropertyTree& authDomain = it->query();
        StringBuffer name = authDomain.queryProp("@domainName");
        if (name.isEmpty())
            name.set("default");
        sessionTimeoutMinutesMap.setValue(name.str(), authDomain.getPropInt("@sessionTimeoutMinutes", 0));
    }
}
示例#23
0
 void appendManifestSchemas(IPropertyTree &manifest, ILoadedDllEntry *dll)
 {
     if (flags & WWV_OMIT_SCHEMAS)
         return;
     assertex(!finalized);
     if (!dll)
         return;
     BoolHash uniqueResultNames;
     Owned<IPropertyTreeIterator> iter = manifest.getElements("Resource[@type='RESULT_XSD']");
     ForEach(*iter)
     {
         IPropertyTree& res = iter->query();
         const char* name = res.queryProp("@name");
         if (name && *name)
         {
             bool* found = uniqueResultNames.getValue(name);
             if (found && *found)
                 continue;
             uniqueResultNames.setValue(name, true);
         }
         appendSchemaResource(res, dll);
     }
 }
示例#24
0
bool CLogThread::FlattenArray(IArrayOf<IEspLogInfo>& valueArray,IPropertyTree& tree,StringBuffer& RootName)
{
    StringBuffer Value,Name;
    if (tree.hasChildren() == true)
    {
        Name.appendf("%s",tree.queryName());
        Owned<IPropertyTreeIterator> itrItem =  tree.getElements("./*");
        itrItem->first();
        while(itrItem->isValid()==true)
        {
            IPropertyTree &node = itrItem->query();
            if(Value.length()!=0)
                Value.append(",");
            Value.appendf("%s",node.queryProp(""));
            itrItem->next();
        }
        IClientLogInfo& logElement = addLogInfoElement(valueArray);
        logElement.setName(Name.str());
        logElement.setValue(Value.str());

    }
    return true;
}
//---------------------------------------------------------------------------
//  determineInstallFiles
//---------------------------------------------------------------------------
int CConfigGenEngine::determineInstallFiles(IPropertyTree& processNode, CInstallFiles& installFiles) const
{
    try
    {
        m_pCallback->printStatus(STATUS_NORMAL, NULL, NULL, NULL, 
            "Determining files to install for %s", processNode.queryProp("@name"));

        StringBuffer compListPath(CONFIGGEN_COMP_LIST);
        if (m_inDir.length())
            compListPath.clear().append(m_inDir).append(PATHSEPCHAR).append(CONFIGGEN_COMP_LIST);

        Owned<IPropertyTree> deployNode = createPTreeFromXMLFile(compListPath.str(), ipt_caseInsensitive);
        StringBuffer srcFilePath;
        srcFilePath.ensureCapacity(_MAX_PATH);
        const bool bFindStartable = &m_process == &processNode && m_startable == unknown;
        const bool bFindStoppable = &m_process == &processNode && m_stoppable == unknown;

        StringBuffer xpath;
        xpath.appendf("Component[@name=\"%s\"]",processNode.queryProp("@buildSet"));
        IPropertyTree* pComponent = deployNode->queryPropTree(xpath.str());

        if (!pComponent)
        {
            m_pCallback->printStatus(STATUS_NORMAL, NULL, NULL, NULL, 
                "Cannot find files to install for %s", processNode.queryProp("@buildSet"));
            return 0;
        }

        Owned<IPropertyTreeIterator> iter = pComponent->getElements("File");
        ForEach(*iter)
        {
            IPropertyTree* pFile = &iter->query();
            const char* name = pFile->queryProp("@name");

            if (!stricmp(name, "deploy_map.xml"))
                continue;

            if (bFindStartable && !strnicmp(name, "startup", sizeof("startup")-1))
                m_startable = yes;

            if (bFindStoppable && !strnicmp(name, "stop", sizeof("stop")-1))
                m_stoppable = yes;

            const char* method  = pFile->queryProp("@method");
            if (method && !stricmp(method, "schema"))
                continue;

            //if we are not deploying build files and method is copy then ignore this file
            if (!(m_deployFlags & DEFLAGS_BUILDFILES) && (!method || !stricmp(method, "copy")))
                continue;

            const char* srcPath = pFile->queryProp("@srcPath");
            const char* destPath= pFile->queryProp("@destPath");
            const char* destName= pFile->queryProp("@destName");
            bool bCacheable     = pFile->getPropBool("@cache", false);

            // Get source filespec
            if (srcPath && !strcmp(srcPath, "@temp"))
            {
                char tempfile[_MAX_PATH];
                getTempPath(tempfile, sizeof(tempfile), m_name);
                srcFilePath.clear().append(tempfile).append(name);
            }
            else
            {
                srcFilePath.clear().append(m_inDir);

        //adjust source paths
                if (srcPath && 0!=strcmp(srcPath, "."))
                {
                    if (!strncmp(srcPath, "..", 2) && (*(srcPath+2)=='/' || *(srcPath+2)=='\\'))
                    {
                        StringBuffer reldir(srcPath);
                        reldir.replace('/', '\\');

                        while (!strncmp(reldir.str(), "..\\", 3))
                        {
                            srcFilePath.setLength( srcFilePath.length() - 1 ); //remove last char PATHSEPCHAR
                            const char* tail = pathTail(srcFilePath.str());
                            srcFilePath.setLength( tail - srcFilePath.str() );
                            reldir.remove(0, 3);
                        }
                        srcFilePath.append(reldir).append(PATHSEPCHAR);
                    }
                    else
                        srcFilePath.append(srcPath).append(PATHSEPCHAR);
                }
                srcFilePath.append(name);
            }

            std::string sDestName;
            if (method && (!stricmp(method, "esp_service_module") || !stricmp(method, "esp_plugin")))
            {
                //if this is xsl transformation and we are not generating config files then ignore
                //
                if (!(m_deployFlags & DEFLAGS_CONFIGFILES) && !stricmp(method, "esp_service_module"))
                    continue;

                //if this file is an esp service module, encode name of service in the dest file name
                //so the esp deployment can figure out which service this file belongs to
                //
                const char* serviceName = processNode.queryProp("@name");

                //if destination name is specified then use it otherwise use <service-name>[index of module].xml
                sDestName = serviceName;
                if (destName)
                {
                    sDestName += '_';
                    sDestName += destName;
                }
                else
                {
                    int espServiceModules = m_envDepEngine.incrementEspModuleCount();
                    if (espServiceModules > 1)
                    {
                        char achNum[16];
                        itoa(espServiceModules, achNum, 10);

                        sDestName += achNum;
                    }
                    sDestName += ".xml";
                }
                //encode name of service herein - this is needed by and removed by CEspDeploymentEngine::processServiceModules()
                sDestName += '+';
                sDestName += processNode.queryProp("@name");//encode the name of service
            }
            else if (method && (!stricmp(method, "xsl") || !stricmp(method, "xslt")) && !(m_deployFlags & DEFLAGS_CONFIGFILES))
                continue;//ignore xsl transformations if we are not generating config files
            else
            {
                if (!method || !*method)
                    method = "copy";

                // Get destination filespec
                if (destName && *destName)
                {
                    //we now support attribute names within the destination file names like delimted by @ and + (optional)
                    //for e.g. segment_@attrib1+_file_@attrib2 would produce segment_attribval1_file_attrib2value
                    //+ not necessary if the attribute name ends with the word, for e.g. file_@attrib1
                    //for instnace, suite_@eclServer+.bat would expand to suite_myeclserver.bat
                    //if this process has an @eclServer with value "myeclserver"
                    //
                    if (strchr(destName, '@') || strchr(destName, '+'))
                    {
                        char* pszParts = strdup(destName);

                        char *saveptr;
                        const char* pszPart = strtok_r(pszParts, "+", &saveptr);
                        while (pszPart)
                        {
                            const char* p = pszPart;
                            if (*p)
                            {
                                if (strchr(p, '@'))//xpath for an attribute?
                                {
                                    // find name of attribute and replace it with its value
                                    const char* value = m_process.queryProp( p );
                                    if (value)
                                        sDestName.append(value);
                                }
                                else
                                    sDestName.append(p); //no attribute so copy verbatim
                            }
                            pszPart = strtok_r(NULL, "+", &saveptr);
                        }
                        free(pszParts);
                    }
                    else
                        sDestName = destName;


                    if (sDestName.empty())
                        throw MakeStringException(-1, "The destination file name '%s' for source file '%s' "
                        "translates to an empty string!", destName, name);
                }
            }

            StringBuffer destFilePath;
            destFilePath.ensureCapacity(_MAX_PATH);

            bool bTempFile = (destPath && !stricmp(destPath, "@temp")) ||
                !strnicmp(name, "@temp", 5); //@name starts with @temp or @tmp
            if (bTempFile)
            {
                if (sDestName.empty())//dest name not specified
                {
                    if (!strcmp(method, "copy"))
                        sDestName = name;
                    else
                    {
                        StringBuffer dir;
                        const char* pszFileName = splitDirTail(name, dir);
                        const char* pExt = findFileExtension(pszFileName);

                        if (pExt)
                            sDestName.append(pszFileName, pExt-pszFileName);
                        else
                            sDestName.append(pszFileName);

                        char index[16];
                        itoa(m_envDepEngine.incrementTempFileCount(), index, 10);
                        sDestName.append(index);

                        if (pExt)
                            sDestName.append(pExt);
                    }
                }
                destFilePath.append("@temp" PATHSEPSTR);
            }
            else
            {
                if (destPath && *destPath)
                {
                    destFilePath.append(destPath);
                    if (destPath[strlen(destPath)-1] != PATHSEPCHAR)
                        destFilePath.append(PATHSEPCHAR);
                }

                if (sDestName.empty())
                    sDestName = name;
            }

            if (!bTempFile)
                destFilePath.append(processNode.queryProp("@name")).append(PATHSEPCHAR);

            destFilePath.append(sDestName.c_str());

            //For oss, plugins to be handled globally, per Richard.
            //esp plugins also end with plugins.xml but they should be handled above.
            String destFilePathStr(destFilePath);
            String* tmpstr = destFilePathStr.toLowerCase();
            if (tmpstr->indexOf("plugins.xml") > 0)
            {
                delete tmpstr;
                createFakePlugins(destFilePath);
                continue;
            }

            delete tmpstr;

            //find all occurrences of this destination file in the map and resove any conflicts
            //like size mismatch etc.
            bool bAddToFileMap = installFiles.resolveConflicts(processNode, method, srcFilePath.str(), destFilePath.str(),
                m_name, m_curInstance, NULL);
            //resolve conflicts if method is not schema or exec
            if (0 != stricmp(method, "schema") && 0 != stricmp(method, "exec") && 0 != strnicmp(method, "del", 3)) 
            {
            }
            else if (!strnicmp(method, "del", 3))//treat files to be deleted as temp files - to be deleted AFTER we are done!
            {
                bTempFile = true;
                bAddToFileMap = false;
                m_envDepEngine.addTempFile(destFilePath.str());
            }


            if (bAddToFileMap)
            {
                if (bTempFile)
                    m_envDepEngine.addTempFile(destFilePath.str());

                //enable caching for files to be copied unless expressly asked not to do so
                //
                if (!bCacheable && !strcmp(method, "copy"))
                    bCacheable = pFile->getPropBool("@cache", true);

                installFiles.addInstallFile(method, srcFilePath.str(), destFilePath.str(), bCacheable, NULL);
            }
        }
    }
    catch (IException* e)
    {
        StringBuffer msg;
        e->errorMessage(msg);
        e->Release();
        throw MakeStringException(0, "Error creating file list for process %s: %s", m_name.get(), msg.str());
    }
    catch (...)
    {
        throw MakeErrnoException("Error creating file list for process %s", m_name.get());
    }

    m_pCallback->printStatus(STATUS_NORMAL, NULL, NULL, NULL, NULL);
    return installFiles.getInstallFileList().size();
}
示例#26
0
unsigned applyNodes(const char *grpip, ApplyMode mode, unsigned ver, bool isdali, bool quiet)
{
    SocketEndpointArray eps;
    if (isdali&&(stricmp(grpip,"all")==0)) {
        Owned<IRemoteConnection> conn = querySDS().connect("/Environment/Software", myProcessSession(), RTM_LOCK_READ, SDS_CONNECT_TIMEOUT);
        if (!conn) 
            return 0;
        IPropertyTree* root = conn->queryRoot();
        Owned<IPropertyTreeIterator> clusters= root->getElements("ThorCluster");
        unsigned ret = 0;
        if (clusters->first()) {
            do {
                IPropertyTree &cluster = clusters->query();
                ret += applyNodes(cluster.queryProp("@name"),mode,ver,true,quiet);
            } while (clusters->next());
        }
        return ret;
    }
    SocketEndpointArray result;
    StringAttrArray resultstr;
    if (!isdali||!getCluster(grpip,eps)) {
        SocketEndpoint ep(grpip);
        if (ep.isNull()) {
            ERRLOG("%s is not a group name or ip",grpip);
            return 0;
        }
        if (ep.port==0)
            ep.port = getDaliServixPort();
        eps.append(ep);
    }
    PointerIArrayOf<ISocket> sockets;
    unsigned to=10*1000;
    unsigned n=eps.ordinality();    // use approx log scale (timeout is long but only for failure situation)
    while (n>1) {
        n/=2;
        to+=10*1000;
    }
    if (!quiet&&(n>1))
        PROGLOG("Scanning %s...",grpip);
    multiConnect(eps,sockets,to);
    CriticalSection sect;
    class casyncfor: public CAsyncFor
    {
        SocketEndpointArray &eps;
        PointerIArrayOf<ISocket> &sockets;
        ApplyMode mode;
        unsigned ver;
        SocketEndpointArray &result;
        StringAttrArray &resultstr;
        CriticalSection &sect;
    public:
        casyncfor(ApplyMode _mode, unsigned _ver,SocketEndpointArray &_eps,PointerIArrayOf<ISocket> &_sockets,SocketEndpointArray &_result, StringAttrArray &_resultstr,CriticalSection &_sect) 
            : eps(_eps), sockets(_sockets), result(_result), resultstr(_resultstr), sect(_sect)
        { 
            mode = _mode;
            ver = _ver;
        }
        void Do(unsigned i)
        {
            ISocket *sock = sockets.item(i);
            StringBuffer epstr;
            SocketEndpoint ep = eps.item(i);
            ep.getUrlStr(epstr);
//          PROGLOG("T.1 %s %x",epstr.str(),(unsigned)sock);
            StringBuffer verstr;
            unsigned rver=0;
            if (sock) {
                rver = getRemoteVersion(sock, verstr);
                switch (mode) {
                case AMcheck:
                    if (rver!=0)
                        return;
                case AMver: {
                        CriticalBlock block(sect);
                        result.append(ep);
                        StringBuffer ln;
                        ln.append(rver).append(",\"").append(verstr).append('"');
                        resultstr.append(* new StringAttrItem(ln.str()));
                    }
                    return;
                case AMstopver:
                case AMcheckver: 
                case AMcheckvermajor: {
                    // compares versions up to the '-'
                        const char *rv = verstr.str();
                        const char *v = remoteServerVersionString();
                        if (mode!=AMcheckvermajor) {
                            while (*v&&(*v!='-')&&(*v==*rv)) {
                                v++;
                                rv++;
                            }
                        }
                        if ((*rv==*v)&&(rver==ver))
                            return;
                        while (*rv&&(*rv!='-'))
                            rv++;
                        verstr.setLength(rv-verstr.str());
                        if ((mode==AMcheckver)||(mode==AMcheckvermajor))
                            break;

                    }
                    // fall through
                case AMstop:
                    {
                        unsigned err = stopRemoteServer(sock);
                        if (err!=0) {
                            ERRLOG("Could not stop server on %s, %d returned",epstr.str(),err);
                            if (mode!=AMstopver)
                                return;     // even though failed to stop - still return code
                        }
                        else 
                            Sleep(1000); // let stop
                    }
                    break;
                default:
                    return;
                }
            }
            CriticalBlock block(sect);
            result.append(ep);
            if ((mode!=AMver)&&(mode!=AMcheckver)&&(mode!=AMcheckvermajor)&&(mode!=AMstopver))
                resultstr.append(* new StringAttrItem(""));
            else
                resultstr.append(* new StringAttrItem(verstr.str()));
        }
    } afor(mode,ver,eps,sockets,result,resultstr,sect);
    afor.For(eps.ordinality(), 10, false, true);
    if (result.ordinality()==0)
        return 0;
    switch (mode) {
    case AMstopver: 
    case AMcheckver: 
    case AMcheckvermajor: 
        if (!quiet) {
            StringBuffer epstr;
            ForEachItemIn(i,result) {
                result.item(i).getUrlStr(epstr.clear());
                StringAttrItem &attr = resultstr.item(i);
                if (attr.text.length()==0) 
                    ERRLOG("%s: %s not running DAFILESRV",grpip,epstr.str());
                else 
                    ERRLOG("%s: %s %s running DAFILESRV version %s",grpip,(mode==AMstopver)?"was":"is",epstr.str(),attr.text.get());
            }
            unsigned numok = eps.ordinality()-result.ordinality();
            if (mode==AMcheckvermajor)
                PROGLOG("%s: %d node%s running version %.1f of DAFILESRV",grpip,numok,(numok!=1)?"s":"",((double)FILESRV_VERSION)/10.0);
            else {
                StringBuffer vs;
                const char *v = remoteServerVersionString();
                while (*v&&(*v!='-'))
                    vs.append(*(v++));
                PROGLOG("%s: %d node%s running version %s of DAFILESRV",grpip,numok,(numok!=1)?"s":"",vs.str());
            }
        }
IPropertyTree* CFileSpraySoapBindingEx::createPTreeForXslt(double clientVersion, const char* method, const char* dfuwuid)
{
    Owned<IEnvironmentFactory> factory = getEnvironmentFactory(true);
    Owned<IConstEnvironment> constEnv = factory->openEnvironment();
    Owned<IPropertyTree> pEnvRoot = &constEnv->getPTree();
    IPropertyTree* pEnvSoftware = pEnvRoot->queryPropTree("Software");

    Owned<IPropertyTree> pRoot = createPTreeFromXMLString("<Environment/>");
    IPropertyTree* pSoftware = pRoot->addPropTree("Software", createPTree("Software"));

    if (pEnvSoftware)
    {
        StringBuffer dfuwuidSourcePartIP, wuxml;
        if(dfuwuid && *dfuwuid)
        {
            Owned<IDFUWorkUnitFactory> dfuwu_factory = getDFUWorkUnitFactory();
            Owned<IConstDFUWorkUnit> dfuwu = dfuwu_factory->openWorkUnit(dfuwuid, false);
            if(dfuwu)
            {   
                dfuwu->toXML(wuxml);

                Owned<IPropertyTree> wu = createPTreeFromXMLString(wuxml.str());
                if (wu)
                {
                    const char* ip = wu->queryProp("Source/Part/@node");
                    if (ip && *ip)
                        dfuwuidSourcePartIP.append(ip);
                }
            }
        }

        appendDropZones(clientVersion, constEnv, dfuwuidSourcePartIP.str(), pSoftware);

        //For Spray files on Thor Cluster, fetch all the group names for all the thor instances (and dedup them)
        BoolHash uniqueThorClusterGroupNames;
        Owned<IPropertyTreeIterator> it =pEnvSoftware->getElements("ThorCluster");
        ForEach(*it)
        {
            StringBuffer thorClusterGroupName;
            IPropertyTree& cluster = it->query();
            getClusterGroupName(cluster, thorClusterGroupName);
            if (!thorClusterGroupName.length())
                continue;
            bool* found = uniqueThorClusterGroupNames.getValue(thorClusterGroupName.str());
            if (found && *found)
                continue;

            uniqueThorClusterGroupNames.setValue(thorClusterGroupName.str(), true);
            IPropertyTree* newClusterTree = pSoftware->addPropTree("ThorCluster", &it->get());
            newClusterTree->setProp("@name", thorClusterGroupName.str()); //set group name into @name for spray target
        }

        it.setown(pEnvSoftware->getElements("EclAgentProcess"));
        ForEach(*it)
        {
            IPropertyTree &cluster = it->query();
            const char* name = cluster.queryProp("@name");
            if (!name||!*name)
                continue;
            
            unsigned ins = 0;
            Owned<IPropertyTreeIterator> insts = cluster.getElements("Instance");
            ForEach(*insts) 
            {
                const char *na = insts->query().queryProp("@netAddress");
                if (!na || !*na) 
                {
                    insts->query().setProp("@gname", name);
                    continue;
                }
                
                SocketEndpoint ep(na);
                if (ep.isNull())
                    continue;

                ins++;
                StringBuffer gname("hthor__");
                //StringBuffer gname;
                gname.append(name);
                if (ins>1)
                    gname.append('_').append(ins);

                insts->query().setProp("@gname", gname.str());

            }

            pSoftware->addPropTree("EclAgentProcess", &it->get());
        }

        if (stricmp(method, "CopyInput") == 0) //Limit for this method only
        {
            it.setown(pEnvSoftware->getElements("RoxieCluster"));
            ForEach(*it)
                pSoftware->addPropTree("RoxieCluster", &it->get());
        }

        if (wuxml.length() > 0)
            pSoftware->addPropTree("DfuWorkunit", createPTreeFromXMLString(wuxml.str()));
    }
    return pRoot.getClear();
}
示例#28
0
IPropertyTree* CFileSpraySoapBindingEx::createPTreeForXslt(const char* method, const char* dfuwuid)
{
    Owned<IEnvironmentFactory> factory = getEnvironmentFactory();
    Owned<IConstEnvironment> m_constEnv = factory->openEnvironment();
    Owned<IPropertyTree> pEnvRoot = &m_constEnv->getPTree();
    IPropertyTree* pEnvSoftware = pEnvRoot->queryPropTree("Software");

    Owned<IPropertyTree> pRoot = createPTreeFromXMLString("<Environment/>");
    IPropertyTree* pSoftware = pRoot->addPropTree("Software", createPTree("Software"));

    if (pEnvSoftware)
    {
        StringBuffer dfuwuidSourcePartIP, wuxml;
        if(dfuwuid && *dfuwuid)
        {
            Owned<IDFUWorkUnitFactory> dfuwu_factory = getDFUWorkUnitFactory();
            Owned<IConstDFUWorkUnit> dfuwu = dfuwu_factory->openWorkUnit(dfuwuid, false);
            if(dfuwu)
            {   
                dfuwu->toXML(wuxml);

                Owned<IPropertyTree> wu = createPTreeFromXMLString(wuxml.str());
                if (wu)
                {
                    const char* ip = wu->queryProp("Source/Part/@node");
                    if (ip && *ip)
                        dfuwuidSourcePartIP.append(ip);
                }
            }
        }

        Owned<IPropertyTreeIterator> it = pEnvSoftware->getElements("DropZone");
        ForEach(*it)
        {
            IPropertyTree* pDropZone = pSoftware->addPropTree("DropZone", &it->get());
            //get IP Address of the computer associated with this drop zone
            const char* pszComputer = it->query().queryProp("@computer");
            if (!strcmp(pszComputer, "."))
                pszComputer = "localhost";

            StringBuffer xpath;
            xpath.appendf("Hardware/Computer[@name='%s']/@netAddress", pszComputer);

            StringBuffer sNetAddr;
            const char* pszNetAddr = pEnvRoot->queryProp(xpath.str());
            if (strcmp(pszNetAddr, "."))
            {       
                sNetAddr.append(pszNetAddr);
            }
            else
            {
                StringBuffer ipStr;
                IpAddress ipaddr = queryHostIP();
                ipaddr.getIpText(ipStr);
                if (ipStr.length() > 0)
                {
#ifdef MACHINE_IP
                    sNetAddr.append(MACHINE_IP);
#else
                    sNetAddr.append(ipStr.str());
#endif
                }
            }
            pDropZone->addProp("@netAddress", sNetAddr.str());
            if ((dfuwuidSourcePartIP.length() > 0) && (sNetAddr.length() > 0))
            {
                IpAddress ip1(dfuwuidSourcePartIP.str()), ip2(sNetAddr.str());
                if (ip1.ipequals(ip2))              
                    pDropZone->addProp("@sourceNode", "1");
            }

            Owned<IConstMachineInfo> machine;
            if (strcmp(pszNetAddr, "."))
                machine.setown(m_constEnv->getMachineByAddress(sNetAddr.str()));
            else
            {
                machine.setown(m_constEnv->getMachineByAddress(pszNetAddr));
                if (!machine)
                    machine.setown(m_constEnv->getMachineByAddress(sNetAddr.str()));
            }

            if (machine)
            {
                //int os = machine->getOS();
                StringBuffer dir;
                pDropZone->getProp("@directory", dir);
                if (machine->getOS() == MachineOsLinux || machine->getOS() == MachineOsSolaris)
                {         
                    dir.replace('\\', '/');//replace all '\\' by '/'
                    pDropZone->setProp("@linux", "true");
                }
                else
                {       
                    dir.replace('/', '\\');
                    dir.replace('$', ':');
                }
                pDropZone->setProp("@directory", dir);
            }
        }

        //For Spray files on Thor Cluster, fetch all the group names for all the thor instances (and dedup them)
        BoolHash uniqueThorClusterGroupNames;
        it.setown(pEnvSoftware->getElements("ThorCluster"));
        ForEach(*it)
        {
            StringBuffer thorClusterGroupName;
            IPropertyTree& cluster = it->query();
            getClusterGroupName(cluster, thorClusterGroupName);
            if (!thorClusterGroupName.length())
                continue;
            bool* found = uniqueThorClusterGroupNames.getValue(thorClusterGroupName.str());
            if (found && *found)
                continue;

            uniqueThorClusterGroupNames.setValue(thorClusterGroupName.str(), true);
            IPropertyTree* newClusterTree = pSoftware->addPropTree("ThorCluster", &it->get());
            newClusterTree->setProp("@name", thorClusterGroupName.str()); //set group name into @name for spray target
        }

        it.setown(pEnvSoftware->getElements("EclAgentProcess"));
        ForEach(*it)
        {
            IPropertyTree &cluster = it->query();
            const char* name = cluster.queryProp("@name");
            if (!name||!*name)
                continue;
            
            unsigned ins = 0;
            Owned<IPropertyTreeIterator> insts = cluster.getElements("Instance");
            ForEach(*insts) 
            {
                const char *na = insts->query().queryProp("@netAddress");
                if (!na || !*na) 
                {
                    insts->query().setProp("@gname", name);
                    continue;
                }
                
                SocketEndpoint ep(na);
                if (ep.isNull())
                    continue;

                ins++;
                StringBuffer gname("hthor__");
                //StringBuffer gname;
                gname.append(name);
                if (ins>1)
                    gname.append('_').append(ins);

                insts->query().setProp("@gname", gname.str());

            }

            pSoftware->addPropTree("EclAgentProcess", &it->get());
        }

        if (stricmp(method, "CopyInput") == 0) //Limit for this method only
        {
            it.setown(pEnvSoftware->getElements("RoxieCluster"));
            ForEach(*it)
                pSoftware->addPropTree("RoxieCluster", &it->get());
        }

        if (wuxml.length() > 0)
            pSoftware->addPropTree("DfuWorkunit", createPTreeFromXMLString(wuxml.str()));
    }
    return pRoot.getClear();
}
示例#29
0
void MessageGenerator::genRoxieMessage(const char* templatemsg, StringBuffer& message)
{
    Owned<IPropertyTree> tmplat;
    StringBuffer root;

    if (templatemsg)
    {
        tmplat.setown(createPTreeFromXMLString(templatemsg));
        if(!tmplat.get())
            throw MakeStringException(-1, "can't generate property tree from input, please make sure it's valid xml.");
        root = tmplat->queryName();
        tmplat.setown(tmplat->getPropTree(VStringBuffer("//Results/Result")));
        if (!tmplat.get())
            throw MakeStringException(-1, "can't find Results/Result in input XML");
    }
    else 
        root = "Unknown"; // TODO: find out the root?

    message.appendf("<!-- <%s> --> %s", root.str(), LT);
    message.appendf(" <!-- <Results> --> %s", LT);
    message.appendf("  <Result>%s", LT);

    Owned<IPropertyTreeIterator> it = m_roxieSchemaRoot->getElements(VStringBuffer("XmlSchema"));
    for (it->first(); it->isValid(); it->next())
    {
        IPropertyTree* ds = &it->query();

        const char* name = ds->queryProp("@name");
        if (!name)
        {
            ERRLOG("XmlSchema without name");
            continue;
        }
        
        IPropertyTree* p = ds->queryBranch(VStringBuffer("%s:schema", xsdNs()));
        m_schemaTree.setown(LINK(p));
        IXmlSchema* xs = createXmlSchemaFromPTree(m_schemaTree);
        IXmlType* type = xs->queryElementType("Dataset");
        if (!type)
        {
            ERRLOG("Can not find type '%s'", name);
            continue;
        }
        // get the Row type
        type = type->queryFieldType(0);
        if (!type)
        {
            ERRLOG("The root element for %s is not an array", name);
            continue;
        }

        IPropertyTree* dsTmplat = tmplat.get() ? tmplat->queryPropTree(VStringBuffer("Dataset[@name='%s']",name)) : NULL;
        if (dsTmplat && dsTmplat->numChildren()>0)
        {
            message.appendf("    <Dataset name=\"%s\">%s", name, LT);
    
            Owned<IPropertyTreeIterator> row = dsTmplat->getElements("Row");
            for (row->first(); row->isValid(); row->next())
            {
                message.appendf("     <Row>%s", LT);
    
                StringStack parent;
                doType(parent,5,"Row",type, &row->query(), message);

                message.appendf("     </Row>%s", LT);
            }

            message.appendf("   </Dataset>%s", LT);
        }
        else if (m_genAllDatasets)
        {
            message.appendf("    <Dataset name=\"%s\">%s", name, LT);
            for (int i=0; i < m_items; i++)
            {
                message.appendf("     <Row>%s", LT);
                StringStack parent;
                doType(parent,6,"Row",type,message);
                message.appendf("     </Row>%s", LT);
            }
            if (m_ecl2esp)
                message.appendf("     <Row/>%s", LT);

            message.appendf("   </Dataset>%s", LT);
        }
    }

    message.appendf("  </Result>%s", LT);
    message.appendf(" <!-- </Results> --> %s", LT);
    message.appendf("<!-- </%s> --> %s", root.str(), LT);
}
void SWEspProcess::addBinding(IPropertyTree *parent, IPropertyTree * attrs)
{
   StringBuffer xpath;
   xpath.clear().append("Attribute[@name='name']/@value");
   const char * bindingName = attrs->queryProp(xpath);
   if (!bindingName || !(*bindingName))
         throw MakeStringException(CfgEnvErrorCode::InvalidParams, "Miss esp binding name in adding binding");

   xpath.clear().append("Attribute[@name='service']/@value");
   const char * serviceName = attrs->queryProp(xpath);
   if (!serviceName || !(*serviceName))
         throw MakeStringException(CfgEnvErrorCode::InvalidParams, "Miss esp service name in adding binding");

   IPropertyTree * envTree = m_envHelper->getEnvTree();
   xpath.clear().appendf(XML_TAG_SOFTWARE "/" XML_TAG_ESPSERVICE "[@name=\"%s\"]", serviceName);
   IPropertyTree * pEspService = envTree->queryPropTree(xpath.str());
   if (!pEspService)
   {
      const char* task="<Task category=\"Software\" component=\"esdl\" key=\"dynamicesdl\" operation=\"add\"/>";
      Owned<IPropertyTree> taskPT = createPTreeFromXMLString(task);
      ((SWEspService*)m_envHelper->getEnvSWComp("DynamicESDL"))->add(taskPT);
      pEspService = envTree->queryPropTree(xpath.str());
      assert(pEspService);
      // throw MakeStringException(CfgEnvErrorCode::InvalidParams, "Can't find EspService with name %s.", serviceName);
   }

   IPropertyTree *pBinding = createPTree(XML_TAG_ESPBINDING);
   if (attrs)
      updateNode(pBinding, attrs, NULL);

   // check attributes

   if (!(pBinding->queryProp(XML_ATTR_PROTOCOL)))
      pBinding->addProp(XML_ATTR_PROTOCOL, "http");
   const char* protocol = pBinding->queryProp(XML_ATTR_PROTOCOL);

   if (!stricmp(protocol, "https"))
      xpath.clear().append("Properties/@defaultSecurePort");
   else
      xpath.clear().append("Properties/@defaultPort");

   const char* defaultPort = pEspService->queryProp(xpath.str());
   const char* port = pBinding->queryProp(XML_ATTR_PORT);
   if (!port || !(*port))
   {
      pBinding->addProp(XML_ATTR_PORT, defaultPort);
   }
   const char* defaultForPort = pBinding->queryProp("@defaultForPort");
   if (!stricmp(defaultPort, pBinding->queryProp(XML_ATTR_PORT)))
   {
      if (!defaultForPort || !(*defaultForPort) || !defaultForPort)
         pBinding->setProp("@defaultForPort", "true");
   }
   else
   {
      if (!defaultForPort || !(*defaultForPort) || defaultForPort)
         pBinding->setProp("@defaultForPort", "true");
   }


   if (!(pBinding->queryProp("@defaultServiceVersion")))
      pBinding->addProp("@defaultServiceVersion", "");

   if (!(pBinding->queryProp("@resourcesBasedn")))
      pBinding->addProp("@resourcesBasedn", pEspService->queryProp("Properties/@defaultResourcesBasedn"));

   if (!(pBinding->queryProp(XML_ATTR_TYPE)))
      pBinding->addProp(XML_ATTR_TYPE, "");

   if (!(pBinding->queryProp("@workunitsBasedn")))
      pBinding->addProp("@workunitsBasedn", "ou=workunits,ou=ecl");

   if (!(pBinding->queryProp("@wsdlServiceAddress")))
      pBinding->addProp("@wsdlServiceAddress", "");

   // Add AuthenticateFeature
   Owned<IPropertyTreeIterator> afIter = pEspService->getElements("Properties/AuthenticateFeature");
   ForEach (*afIter)
   {
      pBinding->addPropTree("AuthenticateFeature", m_envHelper->clonePTree(&afIter->query()));
   }

   // Add Authenticate
   Owned<IPropertyTreeIterator> authIter = pEspService->getElements("Properties/Authenticate");
   ForEach (*authIter)
   {
      pBinding->addPropTree("Authenticate", m_envHelper->clonePTree(&authIter->query()));
   }

   parent->addPropTree(XML_TAG_ESPBINDING, pBinding);
}