Ejemplo n.º 1
0
void LogicalGraphCreator::beginSubGraph(const char * label, bool nested)
{
    savedGraphId.append(subGraphId);
    if (!nested)
        saveSubGraphs();

    if ((subGraphs.ordinality() == 0) && rootSubGraph)
    {
        subGraphs.append(*LINK(rootSubGraph));
        subGraphId = rootGraphId;
        return;
    }

    subGraphId = ++seq;
    IPropertyTree * node = createPTree("node");
    node = curSubGraph()->addPropTree("node", node);
    node->setPropInt64("@id", subGraphId);

    IPropertyTree * graphAttr = node->addPropTree("att", createPTree("att"));
    IPropertyTree * subGraph = graphAttr->addPropTree("graph", createPTree("graph"));
    subGraphs.append(*LINK(subGraph));
    if (!rootSubGraph)
    {
        rootSubGraph.set(subGraph);
        rootGraphId = subGraphId;
    }
}
Ejemplo n.º 2
0
void CEspBinding::getNavigationData(IEspContext &context, IPropertyTree & data)
{
    IEspWsdlSections *wsdl = dynamic_cast<IEspWsdlSections *>(this);
    if (wsdl)
    {
        StringBuffer serviceName, params;
        wsdl->getServiceName(serviceName);
        if (!getUrlParams(context.queryRequestParameters(), params))
        {
            if (context.getClientVersion()>0)
                params.appendf("%cver_=%g", params.length()?'&':'?', context.getClientVersion());
        }

        StringBuffer encodedparams;
        if (params.length())
            encodeUtf8XML(params.str(), encodedparams, 0);

        if (params.length())
            params.setCharAt(0,'&'); //the entire params string will follow the initial param: "?form"

        VStringBuffer folderpath("Folder[@name='%s']", serviceName.str());

        IPropertyTree *folder = data.queryPropTree(folderpath.str());
        if(!folder)
        {
            folder=createPTree("Folder");
            folder->addProp("@name", serviceName.str());
            folder->addProp("@info", serviceName.str());
            folder->addProp("@urlParams", encodedparams);
            if (showSchemaLinks())
                folder->addProp("@showSchemaLinks", "true");
            folder->addPropBool("@isDynamicBinding", isDynamicBinding());
            folder->addPropBool("@isBound", isBound());
            data.addPropTree("Folder", folder);
        }

        MethodInfoArray methods;
        wsdl->getQualifiedNames(context, methods);
        ForEachItemIn(idx, methods)
        {
            CMethodInfo &method = methods.item(idx);
            IPropertyTree *link=createPTree("Link");
            link->addProp("@name", method.m_label.str());
            link->addProp("@info", method.m_label.str());
            StringBuffer path;
            path.appendf("../%s/%s?form%s", serviceName.str(), method.m_label.str(),params.str());
            link->addProp("@path", path.str());

            folder->addPropTree("Link", link);
        }
    }
Ejemplo n.º 3
0
unsigned SWBackupNode::add(IPropertyTree *params)
{
   unsigned rc = SWProcess::add(params);

   IPropertyTree * envTree = m_envHelper->getEnvTree();
   const char* key = params->queryProp("@key");
   StringBuffer xpath;
   xpath.clear().appendf(XML_TAG_SOFTWARE "/%s[@name=\"%s\"]", m_processName.str(), key);
   IPropertyTree * compTree = envTree->queryPropTree(xpath.str());
   assert(compTree);
   const char* selector = params->queryProp("@selector");
   if (selector && !stricmp("NodeGroup", selector))
   {
       IPropertyTree *nodeGroup = createPTree(selector);
       IPropertyTree* pAttrs = params->queryPropTree("Attributes");
       updateNode(nodeGroup, pAttrs, NULL);
       if (!nodeGroup->hasProp("@interval"))
       {
          xpath.clear().appendf("xs:element/xs:complexType/xs:sequence/xs:element[@name=\"NodeGroup\"]/xs:complexType/xs:attribute[@name=\"interval\"]/@default");
          const char *interval = m_pSchema->queryProp(xpath.str());
          if ( interval && *interval )
          {
              nodeGroup->addProp("@interval", interval);
          }
          else
          {
              throw MakeStringException(CfgEnvErrorCode::MissingRequiredParam,
                  "Missing required paramter \"interval\" and there is no default value.");
          }
       }
       compTree->addPropTree(selector, nodeGroup);
   }
   return rc;
}
IPropertyTree *getPkgSetRegistry(const char *process, bool readonly)
{
    Owned<IRemoteConnection> globalLock = querySDS().connect("/PackageSets/", myProcessSession(), RTM_LOCK_WRITE|RTM_CREATE_QUERY, SDS_LOCK_TIMEOUT);
    if (!globalLock)
        throw MakeStringException(PKG_DALI_LOOKUP_ERROR, "Unable to connect to PackageSet information in dali /PackageSets");
    IPropertyTree *pkgSets = globalLock->queryRoot();
    if (!pkgSets)
        throw MakeStringException(PKG_DALI_LOOKUP_ERROR, "Unable to open PackageSet information in dali /PackageSets");

    if (!process || !*process)
        process = "*";
    StringBuffer id;
    buildPkgSetId(id, process);

    //Only lock the branch for the target we're interested in.
    VStringBuffer xpath("/PackageSets/PackageSet[@id='%s']", id.str());
    Owned<IRemoteConnection> conn = querySDS().connect(xpath.str(), myProcessSession(), readonly ? RTM_LOCK_READ : RTM_LOCK_WRITE, SDS_LOCK_TIMEOUT);
    if (!conn)
    {
        if (readonly)
            return NULL;

        Owned<IPropertyTree> pkgSet = createPTree();
        pkgSet->setProp("@id", id.str());
        pkgSet->setProp("@process", process);
        pkgSets->addPropTree("PackageSet", pkgSet.getClear());
        globalLock->commit();

        conn.setown(querySDS().connect(xpath.str(), myProcessSession(), RTM_LOCK_WRITE, SDS_LOCK_TIMEOUT));
    }

    return (conn) ? conn->getRoot() : NULL;
}
Ejemplo n.º 5
0
void CEnvGen::addUpdateAttributesFromString(IPropertyTree *updateTree, const char *attrs)
{
   StringArray saAttrs;
   saAttrs.appendList(attrs, ATTR_SEP);
   //printf("attribute: %s\n",attrs);

   IPropertyTree *pAttrs = updateTree->addPropTree("Attributes", createPTree("Attributes"));
   for ( unsigned i = 0; i < saAttrs.ordinality() ; i++)
   {
     IPropertyTree *pAttr = pAttrs->addPropTree("Attribute", createPTree("Attribute"));

     StringArray keyValues;
     keyValues.appendList(saAttrs[i], "=");

     pAttr->addProp("@name", keyValues[0]);
     StringBuffer sbValue;
     sbValue.clear().appendf("%s", keyValues[1]);
     sbValue.replaceString("[equal]", "=");

     StringArray newOldValues;
     if (strcmp(keyValues[1], ""))
     {
        newOldValues.appendList(sbValue.str(), ATTR_V_SEP);
        pAttr->addProp("@value", newOldValues[0]);
        if (newOldValues.ordinality() > 1) pAttr->addProp("@oldValue", newOldValues[1]);
     }
     else
        pAttr->addProp("@value", "");
   }
}
    void doCreate(const char *partname, const char *xml, unsigned updateFlags, StringArray &filesNotFound)
    {
        createPart(partname, xml);

        if (pmExisting)
        {
            if (!checkFlag(PKGADD_MAP_REPLACE))
                throw MakeStringException(PKG_NAME_EXISTS, "PackageMap %s already exists, either delete it or specify overwrite", pmid.str());
        }

        cloneDfsInfo(updateFlags, filesNotFound);

        if (pmExisting)
            packageMaps->removeTree(pmExisting);

        Owned<IPropertyTree> pmTree = createPTree("PackageMap", ipt_ordered);
        pmTree->setProp("@id", pmid);
        pmTree->setPropBool("@multipart", true);
        pmTree->addPropTree("Part", pmPart.getClear());
        packageMaps->addPropTree("PackageMap", pmTree.getClear());

        VStringBuffer xpath("PackageMap[@id='%s'][@querySet='%s']", pmid.str(), target.get());
        Owned<IPropertyTree> pkgSet = getPkgSetRegistry(process, false);
        IPropertyTree *psEntry = pkgSet->queryPropTree(xpath);

        if (!psEntry)
        {
            psEntry = pkgSet->addPropTree("PackageMap", createPTree("PackageMap"));
            psEntry->setProp("@id", pmid);
            psEntry->setProp("@querySet", target);
        }
        makePackageActive(pkgSet, psEntry, target, checkFlag(PKGADD_MAP_ACTIVATE));
    }
Ejemplo n.º 7
0
static unsigned fn2(unsigned n, unsigned m, unsigned seed, unsigned depth, StringBuffer &parentname)
{
    if (!Rconn)
        return 0;
    if ((n+m+seed)%25==0) {
        Rconn->commit();
        Rconn->Release();
        Rconn = querySDS().connect("/DAREGRESS",myProcessSession(), 0, 1000000);
        if (!Rconn) {
            ERROR("Failed to connect to /DAREGRESS");
            return 0;
        }
    }
    IPropertyTree *parent = parentname.length()?Rconn->queryRoot()->queryPropTree(parentname.str()):Rconn->queryRoot();
    if (!parent) {
        ERROR1("Failed to connect to %s",parentname.str());
        Rconn->Release();
        Rconn = NULL;
        return 0;
    }
    __int64 val = parent->getPropInt64("val",0);
    parent->setPropInt64("val",n+val);
    val = parent->getPropInt64("@val",0);
    parent->setPropInt64("@val",m+val);
    val = parent->getPropInt64(NULL,0);
    parent->setPropInt64(NULL,seed+val);
    if (!seed)
        return m+n;
    if (n==m)
        return seed;
    if (depth>10)
        return seed+n+m;
    if (seed%7==n%7)
        return n;
    if (seed%7==m%7)
        return m;
    char name[64];
    unsigned v = seed;
    name[0] = 's';
    name[1] = 'u';
    name[2] = 'b';
    unsigned i = 3;
    while (v) {
        name[i++] = ('A'+v%26 );
        v /= 26;
    }
    name[i] = 0;
    unsigned l = parentname.length();
    if (parentname.length())
        parentname.append('/');
    parentname.append(name);
    IPropertyTree *child = parent->queryPropTree(name);
    if (!child) 
        child = parent->addPropTree(name, createPTree(name));
    unsigned ret = fn2(fn2(n,seed,seed*17+11,depth+1,parentname),fn2(seed,m,seed*11+17,depth+1,parentname),seed*19+7,depth+1,parentname);
    parentname.setLength(l);
    return ret;
}
    void convertExisting()
    {
        Linked<IPropertyTree> pmPart = pmExisting;
        const char *s = strstr(pmid.str(), "::");
        if (s)
            pmPart->addProp("@id", s+2);
        packageMaps->removeTree(pmExisting);

        Owned<IPropertyTree> pmTree = createPTree("PackageMap", ipt_ordered);
        pmTree->setProp("@id", pmid);
        pmTree->setPropBool("@multipart", true);
        pmTree->addPropTree("Part", pmPart.getClear());
        pmExisting = packageMaps->addPropTree("PackageMap", pmTree.getClear());
    }
void CLogContentFilter::addLogContentBranch(StringArray& branchNames, IPropertyTree* contentToLogBranch, IPropertyTree* updateLogRequestTree)
{
    IPropertyTree* pTree = updateLogRequestTree;
    unsigned numOfBranchNames = branchNames.length();
    unsigned i = 0;
    while (i < numOfBranchNames)
    {
        const char* branchName = branchNames.item(i);
        if (branchName && *branchName)
            pTree = ensurePTree(pTree, branchName);
        i++;
    }
    pTree->addPropTree(contentToLogBranch->queryName(), LINK(contentToLogBranch));
}
Ejemplo n.º 10
0
void ResourceManifest::addToArchive(IPropertyTree *archive)
{
    IPropertyTree *additionalFiles = ensurePTree(archive, "AdditionalFiles");

    //xsi namespace required for proper representaion after PTree::setPropBin()
    if (!additionalFiles->hasProp("@xmlns:xsi"))
        additionalFiles->setProp("@xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");

    Owned<IPropertyTreeIterator> resources = manifest->getElements("Resource[@resourcePath]");
    ForEach(*resources)
    {
        IPropertyTree &item = resources->query();
        const char *respath = item.queryProp("@resourcePath");

        VStringBuffer xpath("Resource[@resourcePath='%s']", respath);
        if (!additionalFiles->hasProp(xpath.str()))
        {
            IPropertyTree *resTree = additionalFiles->addPropTree("Resource", createPTree("Resource"));

            const char *filepath = item.queryProp("@originalFilename");
            resTree->setProp("@originalFilename", filepath);
            resTree->setProp("@resourcePath", respath);

            MemoryBuffer content;
            loadResource(filepath, content);
            resTree->setPropBin(NULL, content.length(), content.toByteArray());
        }
    }

    StringBuffer xml;
    toXML(manifest, xml);

    IPropertyTree *manifest = additionalFiles->addPropTree("Manifest", createPTree("Manifest", ipt_none));
    manifest->setProp("@originalFilename", absFilename.str());
    manifest->setProp(NULL, xml.str());
}
Ejemplo n.º 11
0
   //---------------------------------------------------------------------------
   //  addDirList
   //---------------------------------------------------------------------------
   IPropertyTree* addDirList(const char* comp, const char* path)
   {
      // Get or add Component node
      IPropertyTree* compNode = addComponent(comp);
      assertex(compNode);

      // Add new Directory node
      assertex(path);
      char ppath[_MAX_PATH];
      strcpy(ppath, path);
      removeTrailingPathSepChar(ppath);
      IPropertyTree* node = createPTree("Directory");
      node->addProp("@name", ppath);
      getDirList(ppath, node);
      return compNode->addPropTree("Directory", node);
   }
Ejemplo n.º 12
0
IPropertyTree *readOldIni()
{
    IPropertyTree *ret = createPTree("DFUSERVER", ipt_caseInsensitive);
    ret->setProp("@name","mydfuserver");
    ret->addPropTree("SSH",createPTree("SSH", ipt_caseInsensitive));
    Owned<IProperties> props = createProperties("dfuserver.ini", true);
    if (props) {
        XF(*ret,"@name",*props,"name");
        XF(*ret,"@daliservers",*props,"daliservers");
        XF(*ret,"@enableSNMP",*props,"enableSNMP");
        XF(*ret,"@enableSysLog",*props,"enableSysLog");
        XF(*ret,"@queue",*props,"queue");
        XF(*ret,"@monitorqueue",*props,"monitorqueue");
        XF(*ret,"@monitorinterval",*props,"monitorinterval");
        XF(*ret,"@transferBufferSize",*props,"transferBufferSize");
        XF(*ret,"@replicatequeue",*props,"replicatequeue");
        XF(*ret,"@log_dir",*props,"log_dir");
    }
    return ret;
}
Ejemplo n.º 13
0
void CEspBinding::getNavigationData(IEspContext &context, IPropertyTree & data)
{
    IEspWsdlSections *wsdl = dynamic_cast<IEspWsdlSections *>(this);
    if (wsdl)
    {
        StringBuffer serviceName, params;
        wsdl->getServiceName(serviceName);
        if (!getUrlParams(context.queryRequestParameters(), params))
        {
            if (context.getClientVersion()>0)
                params.appendf("&ver_=%g", context.getClientVersion());
        }
        if (params.length())
            params.setCharAt(0,'&');
        
        IPropertyTree *folder=createPTree("Folder");
        folder->addProp("@name", serviceName.str());
        folder->addProp("@info", serviceName.str());
        folder->addProp("@urlParams", params.str());
        if (showSchemaLinks())
            folder->addProp("@showSchemaLinks", "true");
        
        MethodInfoArray methods;
        wsdl->getQualifiedNames(context, methods);
        ForEachItemIn(idx, methods)
        {
            CMethodInfo &method = methods.item(idx);
            IPropertyTree *link=createPTree("Link");
            link->addProp("@name", method.m_label.str());
            link->addProp("@info", method.m_label.str());
            StringBuffer path;
            path.appendf("../%s/%s?form%s", serviceName.str(), method.m_label.str(),params.str());
            link->addProp("@path", path.str());

            folder->addPropTree("Link", link);
        }

        data.addPropTree("Folder", folder);
    }
Ejemplo n.º 14
0
void CEnvGen::addUpdateTaskFromFile(const char * inFile)
{
   Owned<IPropertyTree> inPTree;

   if ((String(inFile).toLowerCase())->endsWith(".json"))
   {
      StringBuffer sbFile;
      sbFile.loadFile(inFile);
      inPTree.setown(createPTreeFromJSONString(sbFile.str()));
   }
   else
   {
       inPTree.setown(createPTreeFromXMLFile(inFile));
   }

   // add Config attributies to params
   IPropertyTree *pCfg = m_params->queryPropTree("Config");
   assert(pCfg);
   Owned<IAttributeIterator> attrIter = inPTree->getAttributes();
   ForEach(*attrIter)
   {
      const char* propName = attrIter->queryName();
      if (!(*propName)) continue;
      pCfg->setProp(propName, attrIter->queryValue());

   }

   // add Tasks to params
   Owned<IPropertyTreeIterator> taskIter = inPTree->getElements("Task");
   ForEach(*taskIter)
   {
      IPropertyTree* task = &taskIter->query();
      StringBuffer sb;
      toXML(task, sb);
      pCfg->addPropTree("Task", createPTreeFromXMLString(sb.str()));

   }

}
    void addPart(const char *partname, const char *xml, unsigned updateFlags, StringArray &filesNotFound)
    {
        init();

        if (!pmExisting)
        {
            doCreate(partname, xml, updateFlags, filesNotFound);
            return;
        }

        createPart(partname, xml);

        VStringBuffer xpath("Part[@id='%s']", partname);
        IPropertyTree *existingPart = pmExisting->queryPropTree(xpath);
        if (existingPart && !checkFlag(PKGADD_SEG_REPLACE))
            throw MakeStringException(PKG_NAME_EXISTS, "Package Part %s already exists, remove, or specify 'delete previous'", partname);

        cloneDfsInfo(updateFlags, filesNotFound);

        if (existingPart)
            pmExisting->removeTree(existingPart);

        pmExisting->addPropTree("Part", pmPart.getClear());
    }
Ejemplo n.º 16
0
   //---------------------------------------------------------------------------
   //  addTask
   //---------------------------------------------------------------------------
   IPropertyTree* addTask(IDeployTask& task)
   {
      // Get or add Component node
      IPropertyTree* compNode = addComponent(task.getCompName());
      assertex(compNode);

      // Get Tasks node
      IPropertyTree* tasksNode = compNode->queryPropTree("Tasks");
      assertex(tasksNode);

      // Add new task
      IPropertyTree* node = createPTree("Task");
      node->addProp("@action", task.getCaption());
      node->addProp("@source", task.getFileSpec(DT_SOURCE));
      node->addProp("@target", task.getFileSpec(DT_TARGET));

      CDateTime modifiedTime;
      Owned<IFile> pTargetFile = createIFile(task.getFileSpec(DT_TARGET));
      
      if (pTargetFile->getTime(NULL, &modifiedTime, NULL))
      {
         StringBuffer timestamp;
         modifiedTime.getString(timestamp);
         offset_t filesize = pTargetFile->size();

         node->addProp("@date", timestamp.str());
         node->addPropInt64("@size", filesize);
      }

      if (task.getErrorCode())
      {
         node->addProp("@error", task.getErrorString());
         compNode->setProp("@error", "true");
      }
      return tasksNode->addPropTree("Task", node);
   }
Ejemplo n.º 17
0
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();
}
void addPackageMapInfo(const char *xml, StringArray &filesNotFound, const char *process, const char *target, const char *pmid, const char *packageSetName, const char *lookupDaliIp, const char *srcCluster, const char *prefix, bool activate, bool overWrite, IUserDescriptor* userdesc, bool allowForeignFiles, bool preloadAll)
{
    if (!xml || !*xml)
        throw MakeStringExceptionDirect(PKG_INFO_NOT_DEFINED, "PackageMap info not provided");

    if (srcCluster && *srcCluster)
    {
        if (!isProcessCluster(lookupDaliIp, srcCluster))
            throw MakeStringException(PKG_INVALID_CLUSTER_TYPE, "Process cluster %s not found on %s DALI", srcCluster, lookupDaliIp ? lookupDaliIp : "local");
    }

    Owned<IConstWUClusterInfo> clusterInfo = getTargetClusterInfo(target);
    if (!clusterInfo)
        throw MakeStringException(PKG_TARGET_NOT_DEFINED, "Could not find information about target cluster %s ", target);

    Owned<IPropertyTree> pmTree = createPTreeFromXMLString(xml);
    if (!pmTree)
        throw MakeStringExceptionDirect(PKG_INFO_NOT_DEFINED, "Invalid PackageMap info");

    StringBuffer lcPmid(pmid);
    pmid = lcPmid.toLowerCase().str();
    pmTree->setProp("@id", pmid);

    Owned<IPropertyTreeIterator> iter = pmTree->getElements("Package");
    ForEach(*iter)
    {
        IPropertyTree &item = iter->query();
        if (preloadAll)
            item.setPropBool("@preload", true);
        Owned<IPropertyTreeIterator> superFiles = item.getElements("SuperFile");
        ForEach(*superFiles)
        {
            IPropertyTree &superFile = superFiles->query();
            StringBuffer lc(superFile.queryProp("@id"));
            const char *id = lc.toLowerCase().str();
            if (*id == '~')
                id++;
            superFile.setProp("@id", id);

            Owned<IPropertyTreeIterator> subFiles = superFile.getElements("SubFile");
            ForEach(*subFiles)
            {
                IPropertyTree &subFile = subFiles->query();
                id = subFile.queryProp("@value");
                if (id && *id == '~')
                {
                    StringAttr value(id+1);
                    subFile.setProp("@value", value.get());
                }
            }
        }
    }

    VStringBuffer xpath("PackageMap[@id='%s']", pmid);
    Owned<IRemoteConnection> globalLock = querySDS().connect("/PackageMaps", myProcessSession(), RTM_LOCK_WRITE|RTM_CREATE_QUERY, SDS_LOCK_TIMEOUT);
    IPropertyTree *packageMaps = globalLock->queryRoot();
    IPropertyTree *pmExisting = packageMaps->queryPropTree(xpath);

    xpath.appendf("[@querySet='%s']", target);
    Owned<IPropertyTree> pkgSet = getPkgSetRegistry(process, false);
    IPropertyTree *psEntry = pkgSet->queryPropTree(xpath);

    if (!overWrite && (psEntry || pmExisting))
        throw MakeStringException(PKG_NAME_EXISTS, "Package name %s already exists, either delete it or specify overwrite", pmid);

    cloneFileInfoToDali(filesNotFound, pmTree, lookupDaliIp, clusterInfo, srcCluster, prefix, overWrite, userdesc, allowForeignFiles);

    if (pmExisting)
        packageMaps->removeTree(pmExisting);
    packageMaps->addPropTree("PackageMap", pmTree.getClear());

    if (!psEntry)
    {
        psEntry = pkgSet->addPropTree("PackageMap", createPTree("PackageMap"));
        psEntry->setProp("@id", pmid);
        psEntry->setProp("@querySet", target);
    }
    makePackageActive(pkgSet, psEntry, target, activate);
}
Ejemplo n.º 19
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();
}
Ejemplo n.º 20
0
void CEnvGen::createUpdateTask(const char* action, IPropertyTree * config, const char* param)
{
   if (!param || !(*param)) return;

   if (m_showInputOnly)
   {
      printf("Input as one line format: -%s %s\n", (m_actionAbbrMap.at(action)).c_str(), param);
   }

   StringArray items;
   items.appendList(param, ":");
   if (items.ordinality() < 2)
   {
      throw MakeStringException(CfgEnvErrorCode::InvalidParams,
         "Incorrect input format. At least two item expected: category:component.\n See usage for deail.");
   }

   IPropertyTree * updateTree =  createPTree("Task");
   config->addPropTree("Task", updateTree);

   updateTree->addProp("@operation", action);
   updateTree->addProp("@category", (m_envCategoryMap.at(items.item(0))).c_str());

   //have key and attributes
   StringArray compAndAttrs;
   compAndAttrs.appendList(items.item(1), "@");

   StringArray compAndTarget;
   compAndTarget.appendList(compAndAttrs[0], "%");
   if (!stricmp(action, "remove") && compAndTarget.ordinality() > 1 )
   {
      if (*(compAndTarget.item(1))) updateTree->addProp("@target", compAndTarget.item(1));
   }

   StringArray compAndKey;
   compAndKey.appendList(compAndTarget.item(0), "#");

   updateTree->addProp("@component", compAndKey.item(0));

   if (compAndKey.ordinality() > 1)
   {
      StringArray keyAndClone;
      keyAndClone.appendList(compAndKey.item(1), ATTR_V_SEP);
      updateTree->addProp("@key", keyAndClone.item(0));
      if (keyAndClone.ordinality() > 1)
         updateTree->addProp("@clone", keyAndClone.item(1));
   }

   if (compAndAttrs.ordinality() > 1)
   {
      addUpdateAttributesFromString(updateTree, compAndAttrs.item(1));
      return;
   }

   if (items.ordinality() == 2)
      return;

   int index = 2;

   // selector
   StringArray selectorAndAttrs;
   selectorAndAttrs.appendList(items.item(index), "@");

   StringArray selectorParts;
   selectorParts.appendList(selectorAndAttrs.item(0), "/");

   StringBuffer sbSelector;
   for ( unsigned i = 0; i < selectorParts.ordinality()-1 ; i++)
   {
       if (!sbSelector.isEmpty())
          sbSelector.append("/");
       sbSelector.append(selectorParts.item(i));
   }

   StringArray selectorAndKey;
   selectorAndKey.appendList(selectorParts.item(selectorParts.ordinality()-1), "#");
   if (!sbSelector.isEmpty())
      sbSelector.append("/");
   sbSelector.append(selectorAndKey.item(0));
   sbSelector.replace('#', '@');

   updateTree->addProp("@selector", sbSelector.str());
   if (selectorAndKey.ordinality() > 1)
      updateTree->addProp("@selector-key", selectorAndKey.item(1));

   if (selectorAndAttrs.ordinality() > 1)
   {
      addUpdateAttributesFromString(updateTree, selectorAndAttrs.item(1));
   }

   index++;
   if (items.ordinality() == index) return;

   // children nodes
   IPropertyTree *children = updateTree->addPropTree("Children", createPTree("Children"));
   for ( unsigned i = index; i < items.ordinality() ; i++)
   {
       IPropertyTree *child = children->addPropTree("Child", createPTree("Child"));
       StringArray nameAndAttrs;
       nameAndAttrs.appendList(items.item(i), "@");
       child->addProp("@name", nameAndAttrs.item(0));
       if (nameAndAttrs.ordinality() > 1)
          addUpdateAttributesFromString(child, nameAndAttrs.item(1));
   }

}
Ejemplo n.º 21
0
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);
}
Ejemplo n.º 22
0
void appendVariableParmInfo(IArrayOf<IPropertyTree> &parts, IResultSetFactory *resultSetFactory, IConstWUResult &var, unsigned hashWebserviceSeq=0)
{
    Owned<IResultSetMetaData> meta = resultSetFactory->createResultSetMeta(&var);
    StringAttr noinput;
    if (var.getResultFieldOpt("noinput", StringAttrAdaptor(noinput)).length() && strToBool(noinput.length(), noinput.get()))  //developer specified not to show field on form
        return;

    SCMStringBuffer varname;
    var.getResultName(varname);
    int seq = var.getResultSequence();

    WUResultFormat fmt = var.getResultFormat();

    SCMStringBuffer eclschema;
    var.getResultEclSchema(eclschema);

    StringBuffer width, height, fieldSeq, isPassword, select;
    var.getResultFieldOpt("fieldwidth", StringBufferAdaptor(width));
    var.getResultFieldOpt("fieldheight", StringBufferAdaptor(height));
    var.getResultFieldOpt("password", StringBufferAdaptor(isPassword));
    var.getResultFieldOpt("select", StringBufferAdaptor(select));
    if (hashWebserviceSeq)
        fieldSeq.append(hashWebserviceSeq);
    else
        var.getResultFieldOpt("sequence", StringBufferAdaptor(fieldSeq));

    SCMStringBuffer s;
    Owned<IPropertyTree> part = createPTree("part");
    if (!var.isResultScalar())
    {
        meta->getXmlSchema(s, false);
        part->setProp("@name", varname.str());
        part->setProp("@type", "tns:XmlDataset");
        if (fieldSeq.length())
            part->setProp("@sequence", fieldSeq);
    }
    else
    {
        meta->getColumnEclType(s, 0);
        DisplayType dt = meta->getColumnDisplayType(0);
        StringAttr ptype;
        switch (dt)
        {
        case TypeBoolean:
            ptype.set("xsd:boolean");
            break;
        case TypeInteger:
            ptype.set("xsd:integer");
            break;
        case TypeUnsignedInteger:
            ptype.set("xsd:integer");
            break;
        case TypeReal:
            ptype.set("xsd:real");
            break;
        case TypeSet:
            ptype.set("tns:EspStringArray");
            break;
        case TypeDataset:
        case TypeData:
            ptype.set("tns:XmlDataSet");
            break;
        case TypeUnicode:
        case TypeString:
            ptype.set("xsd:string");
            break;
        case TypeUnknown:
        case TypeBeginIfBlock:
        case TypeEndIfBlock:
        case TypeBeginRecord:
        default:
            ptype.set("xsd:string");
            break;
        }
        part->setProp("@name", varname.str());
        part->setProp("@type", ptype.str());
        if (width.length())
            part->setProp("@width", width);
        if (height.length())
            part->setProp("@height", height);
        if (fieldSeq.length())
            part->setProp("@sequence", fieldSeq);
        if (isPassword.length())
            part->setProp("@password", isPassword);
        if (select.length())
        {
            StringArray optionList;
            optionList.appendList(select, ",");
            IPropertyTree *selectTree = ensurePTree(part, "select");
            ForEachItemIn(i, optionList)
            {
                const char *value = optionList.item(i);
                bool selected = '*'==*value;
                if (selected)
                    value++;
                StringAttr name;
                const char *eq = strchr(value, '=');
                if (!eq)
                    name.set(value);
                else
                {
                    name.set(value, eq-value);
                    value = eq + 1;
                }
                Owned<IPropertyTree> optionTree = createPTree();
                optionTree->setProp("@name", name);
                optionTree->setProp("@value", value);
                if (selected)
                    optionTree->setPropBool("@selected", true);
                selectTree->addPropTree("option", optionTree.getClear());
            }
        }
    }