void ResourceManager::addWebServiceInfo(IPropertyTree *wsinfo) { //convert legacy web service info to the new resource format if (wsinfo) { if (wsinfo->hasProp("SOAP")) ensureManifestInfo()->addProp("WS-PARAMS", wsinfo->queryProp("SOAP")); if (wsinfo->hasProp("HELP")) { const char *content = wsinfo->queryProp("HELP"); addCompress("HELP", strlen(content)+1, content); } if (wsinfo->hasProp("INFO")) { const char *content = wsinfo->queryProp("INFO"); addCompress("INFO", strlen(content)+1, content); } if (wsinfo->hasProp("OTX")) { const char *content = wsinfo->queryProp("OTX"); addCompress("HYPER-LINK", strlen(content)+1, content); } if (wsinfo->hasProp("HTML")) { const char *content = wsinfo->queryProp("HTML"); Owned<IPropertyTree> manifestEntry = createPTree("Resource"); manifestEntry->setProp("@name", "Custom Form"); addCompress("XSLT", strlen(content)+1, content, manifestEntry); IPropertyTree *view = ensurePTree(ensureManifestInfo(), "Views/XSLT/FORM"); view->setProp("@resource", "Custom Form"); } if (wsinfo->hasProp("HTMLD")) { const char *content = wsinfo->queryProp("HTMLD"); Owned<IPropertyTree> manifestEntry = createPTree("Resource"); manifestEntry->setProp("@name", "Custom HTML"); addCompress("HTML", strlen(content)+1, content, manifestEntry); IPropertyTree *view = ensurePTree(ensureManifestInfo(), "Views/HTML/FORM"); view->setProp("@resource", "Custom HTML"); } if (wsinfo->hasProp("RESULT")) { const char *content = wsinfo->queryProp("RESULT"); Owned<IPropertyTree> manifestEntry = createPTree("Resource"); manifestEntry->setProp("@name", "Results"); addCompress("XSLT", strlen(content)+1, content, manifestEntry); IPropertyTree *view = ensurePTree(ensureManifestInfo(), "Views/XSLT/RESULTS"); view->setProp("@resource", "Results"); } if (wsinfo->hasProp("ERROR")) { const char *content = wsinfo->queryProp("ERROR"); Owned<IPropertyTree> manifestEntry = createPTree("Resource"); manifestEntry->setProp("@name", "Error"); addCompress("XSLT", strlen(content)+1, content, manifestEntry); IPropertyTree *view = ensurePTree(ensureManifestInfo(), "Views/XSLT/ERROR"); view->setProp("@resource", "Error"); } } }
IPropertyTree *CEspBinding::ensureNavLink(IPropertyTree &folder, const char *name, const char *path, const char *tooltip, const char *menuname, const char *navPath, unsigned relPosition, bool force) { StringBuffer xpath; xpath.appendf("Link[@name=\"%s\"]", name); bool addNew = true; IPropertyTree *ret = folder.queryPropTree(xpath.str()); if (ret) { bool forced = ret->getPropBool("@force"); if (forced || !force) return ret; addNew = false; } if (addNew) ret=createPTree("Link"); ret->setProp("@name", name); ret->setProp("@tooltip", tooltip); ret->setProp("@path", path); ret->setProp("@menu", menuname); ret->setProp("@navPath", navPath); ret->setPropInt("@relPosition", relPosition); ret->setPropBool("@force", force); if (addNew) folder.addPropTree("Link", ret); return ret; }
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)); } } } }
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)); }
ForEachChild(i, record) { IHqlExpression * cur = record->queryChild(i); switch (cur->getOperator()) { case no_record: //MORE: If this is a public symbol it should be expanded, otherwise it will be elsewhere. expandRecordSymbolsMeta(metaTree, cur); break; case no_field: { IPropertyTree * field = metaTree->addPropTree("Field"); field->setProp("@name", str(cur->queryId())); StringBuffer ecltype; cur->queryType()->getECLType(ecltype); field->setProp("@type", ecltype); break; } case no_ifblock: { IPropertyTree * block = metaTree->addPropTree("IfBlock"); expandRecordSymbolsMeta(block, cur->queryChild(1)); break; } case no_attr: case no_attr_link: case no_attr_expr: { IPropertyTree * attr = metaTree->addPropTree("Attr"); attr->setProp("@name", str(cur->queryName())); break; } } }
void updateManifestResourcePaths(IPropertyTree &resource, const char *dir) { StringBuffer filepath; makeAbsolutePath(resource.queryProp("@filename"), dir, filepath); resource.setProp("@originalFilename", filepath.str()); StringBuffer respath; makePathUniversal(filepath.str(), respath); resource.setProp("@resourcePath", respath.str()); }
bool CWsDfuXRefEx::onDFUXRefList(IEspContext &context, IEspDFUXRefListRequest &req, IEspDFUXRefListResponse &resp) { try { if (!context.validateFeatureAccess(FEATURE_URL, SecAccess_Read, false)) throw MakeStringException(ECLWATCH_DFU_XREF_ACCESS_DENIED, "Failed to access Xref. Permission denied."); StringBuffer username; context.getUserID(username); DBGLOG("CWsDfuXRefEx::onDFUXRefList User=%s",username.str()); //Firstly we need to get a list of the available Thor Cluster.... IArrayOf<IEspTpCluster> clusters; CTpWrapper _topology; _topology.getClusterProcessList(eqThorCluster,clusters,false,true); ///_topology.getClusterList(eqRoxieCluster,clusters,false,true); Owned<IPropertyTree> pXRefNodeTree = createPTree("XRefNodes"); //DBGLOG("CWsDfuXRefEx::onDFUXRefList1\n"); for (unsigned x=0;x<=clusters.ordinality();x++) { IPropertyTree* XRefTreeNode = pXRefNodeTree->addPropTree("XRefNode", createPTree(ipt_caseInsensitive)); IEspTpCluster* cluster = x<clusters.ordinality()?&clusters.item(x):NULL; const char *clustername = cluster?cluster->getName():"SuperFiles"; XRefTreeNode->setProp("Name",clustername); //create the node if it doesn;t exist Owned<IXRefNode> xRefNode = XRefNodeManager->getXRefNode(clustername); if (xRefNode == 0) { XRefTreeNode->setProp("Modified",""); XRefTreeNode->setProp("Status","Not Run"); } else { StringBuffer buf; XRefTreeNode->setProp("Modified",xRefNode->getLastModified(buf).str()); buf.clear(); XRefTreeNode->setProp("Status",xRefNode->getStatus(buf).str()); } } StringBuffer buf; resp.setDFUXRefListResult(toXML(pXRefNodeTree, buf).str()); } catch(IException* e) { FORWARDEXCEPTION(context, e, ECLWATCH_INTERNAL_ERROR); } return true; }
virtual void done() { StringBuffer scopedName; OwnedRoxieString outputName(helper->getOutputName()); queryThorFileManager().addScope(container.queryJob(), outputName, scopedName); Owned<IWorkUnit> wu = &container.queryJob().queryWorkUnit().lock(); Owned<IWUResult> r = wu->updateResultBySequence(helper->getSequence()); r->setResultStatus(ResultStatusCalculated); r->setResultLogicalName(scopedName.str()); r.clear(); wu.clear(); IPropertyTree &patchProps = patchDesc->queryProperties(); if (0 != (helper->getFlags() & KDPexpires)) setExpiryTime(patchProps, helper->getExpiryDays()); IPropertyTree &originalProps = originalDesc->queryProperties();; if (originalProps.queryProp("ECL")) patchProps.setProp("ECL", originalProps.queryProp("ECL")); if (originalProps.getPropBool("@local")) patchProps.setPropBool("@local", true); container.queryTempHandler()->registerFile(outputName, container.queryOwner().queryGraphId(), 0, false, WUFileStandard, &clusters); Owned<IDistributedFile> patchFile; // set part sizes etc queryThorFileManager().publish(container.queryJob(), outputName, false, *patchDesc, &patchFile, 0, false); try { // set file size if (patchFile) { __int64 fs = patchFile->getFileSize(true,false); if (fs!=-1) patchFile->queryAttributes().setPropInt64("@size",fs); } } catch (IException *e) { EXCLOG(e,"keydiff setting file size"); e->Release(); } // Add a new 'Patch' description to the secondary key. DistributedFilePropertyLock lock(newIndexFile); IPropertyTree &fileProps = lock.queryAttributes(); StringBuffer path("Patch[@name=\""); path.append(scopedName.str()).append("\"]"); IPropertyTree *patch = fileProps.queryPropTree(path.str()); if (!patch) patch = fileProps.addPropTree("Patch", createPTree()); patch->setProp("@name", scopedName.str()); unsigned checkSum; if (patchFile->getFileCheckSum(checkSum)) patch->setPropInt64("@checkSum", checkSum); IPropertyTree *index = patch->setPropTree("Index", createPTree()); index->setProp("@name", originalIndexFile->queryLogicalName()); if (originalIndexFile->getFileCheckSum(checkSum)) index->setPropInt64("@checkSum", checkSum); originalIndexFile->setAccessed(); newIndexFile->setAccessed(); }
virtual void getNavigationData(IEspContext &context, IPropertyTree & data) { data.setProp("@appName", "EclWatch"); data.setProp("@start_page", "/WsSMC/Activity"); IPropertyTree *folder = ensureNavFolder(data, "Clusters", NULL, NULL, false, 1); ensureNavLink(*folder, "Activity", "/WsSMC/Activity", "Display Activity on all target clusters in an environment", NULL, NULL, 1); ensureNavLink(*folder, "Scheduler", "/WsWorkunits/WUShowScheduled", "Access the ECL Scheduler to view and manage scheduled workunits or events", NULL, NULL, 2); IPropertyTree *folderTools = ensureNavFolder(data, "Resources", NULL, NULL, false, 8); ensureNavLink(*folderTools, "Browse", "/WsSMC/BrowseResources", "Browse a list of resources available for download, such as the ECL IDE, documentation, examples, etc. These are only available if optional packages are installed on the ESP Server.", NULL, NULL, 1); }
//For every ECLWatchVisible dropzones, read: dropZoneName, directory, and, if available, computer. //For every Servers/Server in ECLWatchVisible dropzones, read: directory, // server name, and hostname(or IP). Create dropzone("@name", "@directory", "@computer", // "@netAddress", "@linux", "@sourceNode") tree into pSoftware. void CFileSpraySoapBindingEx::appendDropZones(double clientVersion, IConstEnvironment* env, const char* dfuwuidSourcePartIP, IPropertyTree* softwareTree) { Owned<IConstDropZoneInfoIterator> dropZoneItr = env->getDropZoneIterator(); ForEach(*dropZoneItr) { IConstDropZoneInfo& dropZoneInfo = dropZoneItr->query(); if (!dropZoneInfo.isECLWatchVisible()) //This code is used by ECLWatch. So, skip the DZs not for ECLWatch. continue; SCMStringBuffer dropZoneName, directory, computerName; dropZoneInfo.getName(dropZoneName); dropZoneInfo.getDirectory(directory); if (!dropZoneName.length() || !directory.length()) continue; bool isLinux = getPathSepChar(directory.str()) == '/' ? true : false; Owned<IConstDropZoneServerInfoIterator> dropZoneServerItr = dropZoneInfo.getServers(); ForEach(*dropZoneServerItr) { IConstDropZoneServerInfo& dropZoneServer = dropZoneServerItr->query(); StringBuffer name, server, networkAddress; dropZoneServer.getName(name); dropZoneServer.getServer(server); if (name.isEmpty() || server.isEmpty()) continue; IPropertyTree* dropZone = softwareTree->addPropTree("DropZone", createPTree()); dropZone->setProp("@name", dropZoneName.str()); dropZone->setProp("@computer", name.str()); dropZone->setProp("@directory", directory.str()); if (isLinux) dropZone->setProp("@linux", "true"); IpAddress ipAddr; ipAddr.ipset(server.str()); ipAddr.getIpText(networkAddress); if (!ipAddr.isNull()) { dropZone->addProp("@netAddress", networkAddress); if (!isEmptyString(dfuwuidSourcePartIP)) { IpAddress ip(dfuwuidSourcePartIP); if (ip.ipequals(ipAddr)) dropZone->addProp("@sourceNode", "1"); } } } } }
void WebServicesExtractor::getAttributeText(StringBuffer & text, const char* attributeName) { const char * dot = strrchr(attributeName, '.'); if(!dot || !dot[1]) throw MakeStringException(3, "Please specify both module and attribute"); OwnedHqlExpr symbol = getResolveAttributeFullPath(attributeName, LSFpublic, lookupCtx); if (!symbol || !hasNamedSymbol(symbol) || !symbol->hasText()) { StringBuffer txt; txt.append("Could not read attribute: ").append(attributeName); DBGLOG("%s", txt.str()); throw MakeStringException(ERR_NO_ATTRIBUTE_TEXT, "%s", txt.str()); } symbol->getTextBuf(text); /* MORE: It would be preferable if this was better integrated with hqlgram2.cpp. It's a reasonable stopgap */ if (archive) { StringAttr moduleName(attributeName, dot-attributeName); IPropertyTree * moduleTree = queryEnsureArchiveModule(archive, moduleName, NULL); IPropertyTree * attrTree = queryArchiveAttribute(moduleTree, dot+1); if (!attrTree) { attrTree = createArchiveAttribute(moduleTree, dot+1); const char * p = text.str(); if (0 == strncmp(p, UTF8_BOM,3)) p += 3; attrTree->setProp("", p); } } }
bool ResourceManifest::loadInclude(IPropertyTree &include, const char *dir) { const char *filename = include.queryProp("@filename"); StringBuffer includePath; makeAbsolutePath(filename, dir, includePath); VStringBuffer xpath("Include[@originalFilename='%s']", includePath.str()); if (manifest->hasProp(xpath.str())) return false; include.setProp("@originalFilename", includePath.str()); StringBuffer includeDir; splitDirTail(includePath, includeDir); Owned<IPropertyTree> manifestInclude = createPTreeFromXMLFile(includePath.str()); Owned<IPropertyTreeIterator> it = manifestInclude->getElements("*"); ForEach(*it) { IPropertyTree &item = it->query(); if (streq(item.queryName(), "Resource")) updateResourcePaths(item, includeDir.str()); else if (streq(item.queryName(), "Include")) { if (!loadInclude(item, includeDir.str())) continue; } manifest->addPropTree(item.queryName(), LINK(&item)); } return true; }
IPropertyTree *CEspBinding::addNavException(IPropertyTree &folder, const char *message/*=NULL*/, int code/*=0*/, const char *source/*=NULL*/) { IPropertyTree *ret = folder.addPropTree("Exception", createPTree()); ret->addProp("@message", message ? message : "Unknown exception"); ret->setPropInt("@code", code); ret->setProp("@source", source); return ret; }
extern WORKUNIT_API void setAttributeValue(IPropertyTree & tgt, WuAttr kind, const char * value) { const WuAttrInfo & info = attrInfo[kind-WANone]; const char * path = info.graphPath; if (path[0] == '@') tgt.setProp(path, value); else addGraphAttribute(&tgt, info.childPath)->setProp("@value", value); }
void addComplexGraphEdge(IPropertyTree * graph, unsigned __int64 sourceGraph, unsigned __int64 targetGraph, unsigned __int64 sourceActivity, unsigned __int64 targetActivity, unsigned outputIndex, IAtom * kind, const char * label) { StringBuffer idText; IPropertyTree *edge = createPTree(); edge->setProp("@id", idText.clear().append(sourceGraph).append('_').append(targetGraph).append("_").append(outputIndex).str()); edge->setPropInt64("@target", sourceGraph); edge->setPropInt64("@source", targetGraph); if (label) edge->setProp("@label", label); if (outputIndex) addGraphAttributeInt(edge, "_sourceIndex", outputIndex); if (kind == dependencyAtom) addGraphAttributeBool(edge, "_dependsOn", true); addGraphAttributeInt(edge, "_sourceActivity", sourceActivity); addGraphAttributeInt(edge, "_targetActivity", targetActivity); graph->addPropTree("edge", edge); }
IPropertyTree * addIntraGraphEdge(IPropertyTree * subGraph, unsigned __int64 source, unsigned __int64 target, unsigned outputIndex) { IPropertyTree *edge = createPTree(); edge->setPropInt64("@target", target); edge->setPropInt64("@source", source); StringBuffer s; edge->setProp("@id", s.append(source).append('_').append(outputIndex).str()); return subGraph->addPropTree("edge", edge); }
void ResourceManager::addManifestInclude(IPropertyTree &include, const char *dir) { StringBuffer includePath; makeAbsolutePath(include.queryProp("@filename"), dir, includePath); VStringBuffer xpath("Include[@originalFilename='%s']", includePath.str()); if (manifest->hasProp(xpath.str())) return; include.setProp("@originalFilename", includePath.str()); manifest->addPropTree("Include", LINK(&include)); addManifestFile(includePath.str()); }
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)); } }
IPropertyTree * addInterGraphEdge(IPropertyTree * graph, unsigned __int64 sourceGraph, unsigned __int64 targetGraph, unsigned __int64 sourceActivity, unsigned __int64 targetActivity, unsigned outputIndex) { StringBuffer idText; IPropertyTree *edge = createPTree(); edge->setProp("@id", idText.clear().append(sourceGraph).append('_').append(targetGraph).append("_").append(outputIndex).str()); edge->setPropInt64("@target", sourceGraph); edge->setPropInt64("@source", targetGraph); addGraphAttributeInt(edge, "_sourceActivity", sourceActivity); addGraphAttributeInt(edge, "_targetActivity", targetActivity); return graph->addPropTree("edge", edge); }
bool setValue(LPCSTR newValue) // returns true if value actually updated { ASSERT(!isBinary()); ASSERT(connection != NULL); if(connection->lockWrite()) { pTree->setProp(name, newValue); connection->unlockWrite(); return true; } return false; }
void addSimpleGraphEdge(IPropertyTree * subGraph, unsigned __int64 source, unsigned __int64 target, unsigned outputIndex, unsigned inputIndex, IAtom * kind, const char * label, bool nWay) { IPropertyTree *edge = createPTree(); edge->setPropInt64("@target", target); edge->setPropInt64("@source", source); if (outputIndex != 0) addGraphAttributeInt(edge, "_sourceIndex", outputIndex); if (inputIndex != 0) addGraphAttributeInt(edge, "_targetIndex", inputIndex); if (label) edge->setProp("@label", label); if (kind == dependencyAtom) addGraphAttributeBool(edge, "_dependsOn", true); if (nWay) edge->setPropBool("@nWay", true); StringBuffer s; edge->setProp("@id", s.append(source).append('_').append(outputIndex).str()); subGraph->addPropTree("edge", edge); }
bool doSingleSwapNode(const char *oldip,const char *newip,unsigned nodenum,IPropertyTree *info,const char *timechecked) { if (doSwap(oldip,newip)) { if (info) { StringBuffer times(timechecked); if (times.length()==0) { CDateTime dt; dt.setNow(); dt.getString(times); } // TBD tie up with bad node in auto? IPropertyTree *swap = info->addPropTree("Swap",createPTree("Swap")); swap->setProp("@inNetAddress",newip); swap->setProp("@outNetAddress",oldip); swap->setProp("@time",times.str()); if (UINT_MAX != nodenum) swap->setPropInt("@rank",nodenum-1); } return true; } return false; }
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()); }
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); } }
IPropertyTree *CEspBinding::ensureNavDynFolder(IPropertyTree &root, const char *name, const char *tooltip, const char *params, const char *menuname) { StringBuffer xpath; xpath.appendf("DynamicFolder[@name=\"%s\"]", name); IPropertyTree *ret = root.queryPropTree(xpath.str()); if (!ret) { ret=createPTree("DynamicFolder"); ret->addProp("@name", name); ret->addProp("@tooltip", tooltip); ret->addProp("@params", params); ret->setProp("@menu", menuname); root.addPropTree("DynamicFolder", ret); } return ret; }
virtual void getNavigationData(IEspContext &context, IPropertyTree & data) { if (!batchWatchFeaturesOnly) { IPropertyTree *folder = ensureNavFolder(data, "ECL", "Run Ecl code and review Ecl workunits", NULL, false, 2); ensureNavLink(*folder, "Search Workunits", "/WsWorkunits/WUQuery?form_", "Search Workunits", NULL, NULL, 1); ensureNavLink(*folder, "Browse Workunits", "/WsWorkunits/WUQuery", "Browse Workunits", NULL, NULL, 2); ensureNavLink(*folder, "ECL Playground", "/esp/files/stub.htm?Widget=ECLPlaygroundWidget", "ECL Editor, Executor, Graph and Result Viewer", NULL, NULL, 4); IPropertyTree *folderQueryset = ensureNavFolder(data, "Queries", NULL, NULL, false, 3); ensureNavLink(*folderQueryset, "Browse", "/WsWorkunits/WUQuerySets", "Browse Published Queries"); IPropertyTree *folderTP = CEspBinding::ensureNavFolder(data, "Tech Preview", "Technical Preview"); IPropertyTree *eclWatchTP = CEspBinding::ensureNavLink(*folderTP, "ECL Watch", "/esp/files/stub.htm?Widget=HPCCPlatformWidget", "ECL Watch", NULL, NULL, 1); eclWatchTP->setProp("@target", "_blank"); } }
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; }
IPropertyTree *CEspBinding::ensureNavFolder(IPropertyTree &root, const char *name, const char *tooltip, const char *menuname, bool sort, unsigned relPosition) { StringBuffer xpath; xpath.appendf("Folder[@name=\"%s\"]", name); IPropertyTree *ret = root.queryPropTree(xpath.str()); if (!ret) { ret=createPTree("Folder"); ret->addProp("@name", name); ret->addProp("@tooltip", tooltip); ret->setProp("@menu", menuname); if (sort) ret->addPropBool("@sort", true); ret->addPropInt("@relPosition", relPosition); root.addPropTree("Folder", ret); } return ret; }
void doStuff() { Owned<IRemoteConnection> conn = querySDS().connect("/Orbit", myProcessSession(), RTM_LOCK_WRITE|RTM_CREATE_QUERY, DALI_TIMEOUT); IPropertyTree *root = conn->queryRoot(); StringBuffer s; if (root->getProp("TestBranch1",s)) { printf("TestBranch1: read %s\n",s.str()); } else { // save as string printf("TestBranch1: set (as string)\n",s.str()); root->setProp("TestBranch1",MyTestXML); } MemoryBuffer m; if (root->getPropBin("TestBranch2",m)) { m.append((byte)0); // add a NULL to returned data const char *str = m.toByteArray(); printf("TestBranch2: read %s\n",str); } else { // save as raw binary printf("TestBranch2: set (as blob)\n",s.str()); root->setPropBin("TestBranch2",strlen(MyTestXML),MyTestXML); // include NULL } IPropertyTree *br3 = root->queryPropTree("TestBranch3"); if (br3) { printf("read TestBranch3 as tree\n"); printf("Hello = %s\n",br3->queryProp("Hello")); int n = br3->getPropInt("Bye/@num"); // update printf("Bye num = %d\n",n); br3->setPropInt("Bye/@num",n+1); } else { // save as tree printf("TestBranch3: set (as tree)\n",s.str()); br3 = createPTreeFromXMLString(MyTestXML); // parses and creates object tree root->setPropTree("TestBranch3", br3); } }
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())); } }