Example #1
0
/*
<FIELD NAME='STATUS' VALUE=''> </FIELD>STATUS/LOCK/CLOSE
*/
int __fastcall ASEditSvr::exeRestfulCommand(WideString asOperation,WideString asParams,WideString &asResult)
{
  PCPtr<PCXML> lParam(new PCXML(asParams));
  PCPtr<PCXML> lResult(new PCXML("<DATASETS/>"));
  String lsID,lsAction,lsField,lsValue;
  _di_IXMLNode lParentNode;
  //<ACTION>DEFAULT</ACTION>
  lParentNode = lParam->SubNode["ACTION"];
  if(lParentNode)
	lsAction = BLNODETEXT(lParentNode).Trim();
  if(lsAction.IsEmpty()) lsAction = "DEFAULT";
   Action = lsAction;
  lParentNode = lParam->SubNode["PARAM"];
  if(lParentNode)
	 lsID = BLNODETEXT(lParentNode).Trim();
  if((!BLSAMESTR(asOperation,"add")) && lsID.IsEmpty()) throw Exception("必须提供ID参数");
  if(BLSAMESTR(asOperation,"add")){
	  Retrieve("-1");
	  lParentNode = lParam->SubNode["DATASETS"];
	  fromXML(lParentNode,true);
	  Save();
	  lParentNode = lResult->SubNode[""];
	  BLNODEATTSET(lParentNode,"ERI",ERI);
	  toXML(lParentNode);
  }
  else if(BLSAMESTR(asOperation,"get")){
	  Retrieve(lsID);
	  lParentNode = lResult->SubNode[""];
	  BLNODEATTSET(lParentNode,"ERI",ERI);
	  toXML(lParentNode);
  }
  else if(BLSAMESTR(asOperation,"set")){
	  Retrieve(lsID);
	  lParentNode = lParam->SubNode["DATASETS"];
	  fromXML(lParentNode,false,true);
	  Save();
	  lParentNode = lResult->SubNode[""];
	  BLNODEATTSET(lParentNode,"ERI",ERI);
	  toXML(lParentNode);
  }
  else
	 throw Exception("错误操作命令" + asOperation);
  asResult = lResult->XML->Text;
  return 1;
}
Example #2
0
File: var.cpp Project: Aspenka/SSD
void Var::exportToXml(QString path)
{
	QFile file(path);
	if(file.open(QIODevice::WriteOnly))
    {
        file.write(toXML().toUtf8());
        file.close();
    }
}
Example #3
0
 void appendXML(IPropertyTree *xml, const char *tag=NULL)
 {
     assertex(!finalized);
     if (tag)
         buffer.append('<').append(tag).append('>');
     if (xml)
         toXML(xml, buffer);
     if (tag)
         buffer.append("</").append(tag).append('>');
 }
Example #4
0
CPackageNode::CPackageNode(IPropertyTree *p)
{
    if (p)
        node.set(p);
    else
        node.setown(createPTree("HpccPackages"));
    StringBuffer xml;
    toXML(node, xml, 0, XML_SortTags);
    hash = rtlHash64Data(xml.length(), xml.str(), 9994410);
}
Example #5
0
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;
}
Example #6
0
std::string VisualizationNode::toXML(const std::string &basePath, int tabs)
{
	std::string fnV = getFilename();
	/*if (!fnV.empty())
	{
		//if (!basePath.empty())
		//	BaseIO::makeRelativePath(basePath,fnV);
	}*/
	boost::filesystem::path fn(fnV);
	return toXML(basePath,fn.filename().string(),tabs);
}
Example #7
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();
    }

}
Example #8
0
void ResourceManager::finalize()
{
    if (!finalized)
    {
        if (manifest)
        {
            StringBuffer content;
            toXML(manifest, content);
            addCompress("MANIFEST", content.length()+1, content.str(), NULL, MANIFEST_BASE, false);
        }
        finalized=true;
    }
}
Example #9
0
const StringBuffer &CEspApplicationPort::getDynNavData(IEspContext &context, IProperties *params, StringBuffer &content,
                                                       StringBuffer &contentType, bool& bVolatile)
{
    Owned<IPropertyTree> navtree=createPTree("EspDynNavData");
    bVolatile = false;
    int count = getBindingCount();
    for (int idx = 0; idx<count; idx++)
        bindings[idx]->queryBinding()->getDynNavData(context, params, *navtree.get());

    if (!bVolatile)
        bVolatile = navtree->getPropBool("@volatile", false);
    contentType.clear().append(HTTP_TYPE_APPLICATION_XML_UTF8);
    return toXML(navtree.get(), content.clear());
}
Example #10
0
		void set_uid(int val)
		{
			setUID(val);

			// NOTIFY MY ID TO SLAVES
			sendData(std::make_shared<protocol::Invoke>("set_master_uid", val));

			// NOTIFY MY UID TO MASTER
			// Call Master::SlaveSystem::construct()
			auto xml = toXML();
			{
				xml->clear();
				xml->setTag("system");
			}
			getParent()->sendData(std::make_shared<protocol::Invoke>("construct", xml));
		};
Example #11
0
    std::string CollisionModel::toXML(const std::string& basePath, int tabs)
    {
        std::string collisionFilename;

        if (visualization)
        {
            collisionFilename = visualization->getFilename();
        }
        else if (modelVisualization)
        {
            collisionFilename = modelVisualization->getFilename();
        }

        boost::filesystem::path fn(collisionFilename);
        return toXML(basePath, fn.string(), tabs);

    }
Example #12
0
void CXRefNode::deserializeMessages(IPropertyTree& inTree)
{
    if(!m_messages.get())
    {
        IPropertyTree* messagesBranch = m_XRefTree->queryPropTree("Messages");
        if(messagesBranch == 0)
        {
            messagesBranch = m_XRefTree->addPropTree("Messages",createPTree());
            commit();
        }
        StringBuffer tmpbuf;
        m_messages.set(messagesBranch);
    }
    StringBuffer datastr;
    toXML(&inTree,datastr);
    m_messages->setPropBin("data",datastr.length(),(void*)datastr.toCharArray());
}
Example #13
0
void checkFile(IChecker *checker,IDistributedFile *file)
{
    StringBuffer tmp;
    checker->add("queryLogicalName",file->queryLogicalName());
    unsigned np = file->numParts();
    checker->add("numParts",np);
    checker->add("queryDefaultDir",file->queryDefaultDir());
    if (np>1)
        checker->add("queryPartMask",file->queryPartMask());
    checker->add("queryProperties()",toXML(&file->queryAttributes(),tmp.clear()).str());
    CDateTime dt;
    if (file->getModificationTime(dt))
        dt.getString(tmp.clear());
    else
        tmp.clear().append("nodatetime");

    // Owned<IFileDescriptor> desc = getFileDescriptor();
    // checkFileDescriptor(checker,desc);

    //virtual bool existsPhysicalPartFiles(unsigned short port) = 0;                // returns true if physical patrs all exist (on primary OR secondary)

    //Owned<IPropertyTree> tree = getTreeCopy();
    //checker->add("queryProperties()",toXML(tree,tmp.clear()).str());

    checker->add("getFileSize",file->getFileSize(false,false));
    bool blocked;
    checker->add("isCompressed",file->isCompressed(&blocked)?1:0);
    checker->add("blocked",blocked?1:0);
    unsigned csum;
    if (file->getFileCheckSum(csum)&&!blocked) 
        checker->add("getFileCheckSum",csum);
    else
        checker->add("getFileCheckSum","nochecksum");
    checker->add("isSubFile",file->isSubFile()?1:0);
    StringBuffer clustname;
    checker->add("queryClusterName(0)",file->getClusterName(0,clustname).str());
    for (unsigned i=0;i<np;i++) {
        Owned<IDistributedFilePart> part = file->getPart(i);
        if (part)
            checkFilePart(checker,part,blocked);
    }
        
}
    virtual int processCMD()
    {
        loadServiceDef();

        StringBuffer xml("<esdl>");
        Owned<IEsdlDefObjectIterator> structs = cmdHelper.esdlDef->getDependencies( optService.get(), optMethod.get(), ESDLOPTLIST_DELIMITER, 0, nullptr, 0 );
        cmdHelper.defHelper->toXML(*structs, xml, 0, NULL, 0);
        xml.append("</esdl>");

        Owned<IPropertyTree> depTree = createPTreeFromXMLString(xml, ipt_ordered);
        removeEclHidden(depTree);
        toXML(depTree, xml.clear());

        StringBuffer monTemplate;
        createMonitoringTemplate(monTemplate, depTree, optMethod);

        VStringBuffer templatefile("monitor_template_%s.xml", optMethod.str());
        saveAsFile(".", templatefile, monTemplate);
        return 0;
    }
Example #15
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()));

   }

}
Example #16
0
// Create an Invoke message for the standalone Gnash
std::string
ExternalInterface::makeInvoke (const std::string &method,
                               const std::vector<as_value> &args)
{
    std::stringstream ss;
    std::vector<as_value>::const_iterator it;

    ss << "<invoke name=\"" << method << "\" returntype=\"xml\">";
    ss << "<arguments>";
    for (it=args.begin(); it != args.end(); ++it) {
        // Should we avoid re-serializing the same object ?
        ss << toXML(*it);
    }
    
    ss << "</arguments>";
    ss << "</invoke>";

    // Add a CR on the end so the output is more readable on the other
    // end. XL should be ignoring the CR anyway.
    ss << std::endl;
    
    return ss.str();
}
//---------------------------------------------------------------------------
// copyInstallFiles
//---------------------------------------------------------------------------
void CDaliDeploymentEngine::copyInstallFiles(IPropertyTree& instanceNode, const char* destPath)
{
    const char* computer = instanceNode.queryProp("@computer");
   if ((m_deployFlags & DEFLAGS_CONFIGFILES) && computer && *computer)
   {
      // Create dalisds.xml is not already exists
      StringBuffer hostRoot(getHostRoot(computer, NULL));

      const char* dir = m_process.queryProp("@dataPath");
      if (!dir || !*dir)
         dir = instanceNode.queryProp("@directory");

      if (dir)
      {
         if (isPathSepChar(*dir))
            dir++;
         StringBuffer sDir( dir );
         sDir.replace(':', '$');
         sDir.replace('/', '\\');
         sDir.insert(0, hostRoot.str());

         if (!checkFileExists( sDir.str() ))
         {
            Owned<IPropertyTree> tree = &m_environment.getPTree();
            StringBuffer xml("<SDS>");
            toXML(tree, xml);
            xml.append("</SDS>");

            sDir.append( "\\dalisds.xml" );
            writeFile(sDir.str(), xml.str());
         }
      }
   }
   // Copy install files to deploy subdir
   CDeploymentEngine::copyInstallFiles(instanceNode, destPath);
}
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());
}
 StringBuffer &toStr(StringBuffer &s)
 {
     Owned<IPropertyTree> t = getTree();
     return toXML(t, s);
 }
Example #20
0
void CEspApplicationPort::buildNavTreeXML(IPropertyTree* navtree, StringBuffer& xmlBuf, bool insideFolder)
{
    if (!navtree)
        return;

    //Find out the menu items which do not request a specific position
    //Also find out the maximum position being requested
    unsigned positionMax = 0;
    StringArray itemsGroup1;
    Owned<IPropertyTreeIterator> items = navtree->getElements("*");
    ForEach(*items)
    {
        IPropertyTree &item = items->query();
        unsigned position = (unsigned) item.getPropInt("@relPosition", 0);
        if (position > positionMax)
        {
            positionMax = position;
        }
        else if (position < 1)
        {//if the item does not request a position, add it to the 'itemsGroup1'.
            StringBuffer itemXML;
            if (!insideFolder)
                buildNavTreeXML(&item, itemXML, true);
            else
                toXML(&item, itemXML);

            itemsGroup1.append(itemXML);
        }
    }

    xmlBuf.appendf("<%s", navtree->queryName());
    Owned<IAttributeIterator> attrs = navtree->getAttributes();
    ForEach(*attrs)
    {
        const char *attrname = attrs->queryName()+1;
        const char *attrvaluee = attrs->queryValue();
        if (attrname && *attrname && attrvaluee && *attrvaluee)
            xmlBuf.appendf(" %s=\"%s\"", attrname, attrvaluee);
    }
    xmlBuf.append(">\n");

    unsigned positionInGroup1 = 0;
    unsigned itemCountInGroup1 = itemsGroup1.length();

    //append the menu items based on the position requested
    unsigned position = 1;
    while (position <= positionMax)
    {
        bool foundOne = false;

        //process the item(s) which asks for this position
        StringBuffer xPath;
        xPath.appendf("*[@relPosition=%d]", position);
        Owned<IPropertyTreeIterator> items1 = navtree->getElements(xPath.str());
        ForEach(*items1)
        {
            IPropertyTree &item = items1->query();

            StringBuffer itemXML;
            if (!insideFolder)
                buildNavTreeXML(&item, itemXML, true);
            else
                toXML(&item, itemXML);
            xmlBuf.append(itemXML.str());

            foundOne = true;
        }

        //If no one asks for this position, pick one from the itemsGroup1
        if (!foundOne && (positionInGroup1 < itemCountInGroup1))
        {
            StringBuffer itemXML = itemsGroup1.item(positionInGroup1);
            xmlBuf.append(itemXML.str());
            positionInGroup1++;
        }

        position++;
    }

    //Check any item left inside the itemsGroup1 and append it into the xml
    while (positionInGroup1 < itemCountInGroup1)
    {
        StringBuffer itemXML = itemsGroup1.item(positionInGroup1);
        xmlBuf.append(itemXML.str());
        positionInGroup1++;
    }

    xmlBuf.appendf("</%s>\n", navtree->queryName());
}
Example #21
0
    void processMessage(CMessageBuffer &mb)
    {
        ICoven &coven=queryCoven();
        MemoryBuffer params;
        params.swapWith(mb);
        int fn;
        params.read(fn);
        switch (fn) {
        case MDR_GET_VALUE: {
                StringAttr id;
                StringBuffer buf;
                params.read(id);
                if (0 == stricmp(id,"threads")) {
                    mb.append(getThreadList(buf).str());
                }
                else if (0 == stricmp(id, "mpqueue")) {
                    mb.append(getReceiveQueueDetails(buf).str());
                }
                else if (0 == stricmp(id, "locks")) {
                    mb.append(querySDS().getLocks(buf).str());
                }
                else if (0 == stricmp(id, "sdsstats")) {
                    mb.append(querySDS().getUsageStats(buf).str());
                }
                else if (0 == stricmp(id, "connections")) {
                    mb.append(querySDS().getConnections(buf).str());
                }
                else if (0 == stricmp(id, "sdssubscribers")) {
                    mb.append(querySDS().getSubscribers(buf).str());
                }
                else if (0 == stricmp(id, "clients")) {
                    mb.append(querySessionManager().getClientProcessList(buf).str());
                }
                else if (0 == stricmp(id, "subscriptions")) {
                    mb.append(getSubscriptionList(buf).str());
                }
                else if (0 == stricmp(id, "mpverify")) {
                    queryWorldCommunicator().verifyAll(buf);
                    mb.append(buf.str());
                }
                else if (0 == stricmp(id, "extconsistency")) {
                    mb.append(querySDS().getExternalReport(buf).str());
                }
                else if (0 == stricmp(id, "build")) {
                    mb.append("$Id: dadiags.cpp 62376 2011-02-04 21:59:58Z sort $");
                }
                else if (0 == stricmp(id, "sdsfetch")) {
                    StringAttr branchpath;
                    params.read(branchpath);
                    Linked<IPropertyTree> sroot = querySDSServer().lockStoreRead();
                    try { sroot->queryPropTree(branchpath)->serialize(mb); }
                    catch (...) { querySDSServer().unlockStoreRead(); throw; }
                    querySDSServer().unlockStoreRead();
                }
                else if (0 == stricmp(id, "perf")) {
                    getSystemTraceInfo(buf,PerfMonStandard);
                    mb.append(buf.str());
                }
                else if (0 == stricmp(id, "sdssize")) {
                    StringAttr branchpath;
                    params.read(branchpath);
                    Linked<IPropertyTree> sroot = querySDSServer().lockStoreRead();
                    StringBuffer sbuf;
                    try { 
                        toXML(sroot->queryPropTree(branchpath),sbuf); 
                        DBGLOG("sdssize '%s' = %d",branchpath.get(),sbuf.length());
                    }
                    catch (...) { 
                        querySDSServer().unlockStoreRead(); 
                        throw; 
                    }
                    querySDSServer().unlockStoreRead();
                    mb.append(sbuf.length());
                }
                else if (0 == stricmp(id, "disconnect")) {
                    StringAttr client;
                    params.read(client);
                    SocketEndpoint ep(client);
                    PROGLOG("Dalidiag request to close client connection: %s", client.get());
                    Owned<INode> node = createINode(ep);
                    queryCoven().disconnect(node);
                }
                else if (0 == stricmp(id, "unlock")) {
                    __int64 connectionId;
                    bool disconnect;
                    params.read(connectionId);
                    params.read(disconnect);
                    PROGLOG("Dalidiag request to unlock connection id: %" I64F "x", connectionId);
                    StringBuffer connectionInfo;
                    bool success = querySDSServer().unlock(connectionId, disconnect, connectionInfo);
                    mb.append(success);
                    if (success)
                        mb.append(connectionInfo);
                }
                else if (0 == stricmp(id, "save")) {
                    PROGLOG("Dalidiag requests SDS save");
                    querySDSServer().saveRequest();
                }
                else if (0 == stricmp(id, "settracetransactions")) {
                    PROGLOG("Dalidiag requests Trace Transactions");
                    if(traceAllTransactions(true))
                        mb.append("OK - no change");
                    else
                        mb.append("OK - transaction tracing enabled");
                }
                else if (0 == stricmp(id, "cleartracetransactions")) {
                    PROGLOG("Dalidiag requests Trace Transactions stopped");
                    if(traceAllTransactions(false))
                        mb.append("OK - transaction tracing disabled");
                    else
                        mb.append("OK - no change");
                }
                else if (0 == stricmp(id, "setldapflags")) {
                    unsigned f;
                    params.read(f);
                    PROGLOG("Dalidiag requests setldapflags %d",f);
                    querySessionManager().setLDAPflags(f);

                }
                else if (0 == stricmp(id, "getldapflags")) {
                    unsigned f=querySessionManager().getLDAPflags();;
                    mb.append(f);
                }
                else if (0 == stricmp(id, "setsdsdebug")) {
                    PROGLOG("Dalidiag setsdsdebug");
                    unsigned p;
                    params.read(p);
                    StringArray arr;
                    while (p--)
                    {
                        StringAttr s;
                        params.read(s);
                        arr.append(s);
                    }
                    StringBuffer reply;
                    bool success = querySDSServer().setSDSDebug(arr, reply);
                    mb.append(success).append(reply);
                }
                else
                    mb.append(StringBuffer("UNKNOWN OPTION: ").append(id).str());
            }
            break;
        }
        coven.reply(mb);            
    }   
Example #22
0
void Trajectory::print() const
{
	std::string s = toXML(0);
	VR_INFO << s << endl;
}
Example #23
0
StringBuffer& CXRefNode::getXRefData(StringBuffer & str)
{
    return toXML(&getDataTree(),str);
}
Example #24
0
unsigned WebServicesExtractor::getVersion()
{
    StringBuffer info;
    toXML(root, info);
    return crc32(info.str(), info.length(), 0);
}
Example #25
0
std::string Message::toXML() const
{
  std::string str;
  return toXML( str );
}
void CwsstoreEx::init(IPropertyTree *_cfg, const char *_process, const char *_service)
{
   if(_cfg == nullptr)
        throw MakeStringException(-1, "CwsstoreEx::init: Empty configuration provided.");

#ifdef _DEBUG
    StringBuffer thexml;
    toXML(_cfg, thexml,0,0);
    fprintf(stderr, "%s", thexml.str());
#endif

    StringBuffer xpath;
    xpath.appendf("Software/EspProcess[@name=\"%s\"]/EspService[@name=\"%s\"]", _process, _service);
    m_serviceConfig.setown(_cfg->getPropTree(xpath.str()));

    if(!m_serviceConfig)
        throw MakeStringException(-1, "CwsstoreEx::init: Config not found for service %s/%s",_process, _service);

    IPropertyTree * storeProviderTree = m_serviceConfig->queryPropTree("StoreProvider[1]");

    if (storeProviderTree == nullptr)
         throw MakeStringException(-1, "CwsstoreEx::init: Store provider configuration not found for service %s/%s",_process, _service);

    const char * providerLibraryName = storeProviderTree->queryProp("@lib");
    if (!providerLibraryName || !*providerLibraryName)
        throw MakeStringException(-1, "CwsstoreEx::init: Must provide store provider library name for service %s/%s",_process, _service);

    const char * providerInstanceName = storeProviderTree->queryProp("@name");
    const char * providerFactoryMethod = storeProviderTree->queryProp("@factoryMethod");

    m_storeProvider.setown(loadStoreProvider(providerInstanceName, providerLibraryName, (providerFactoryMethod && *providerFactoryMethod) ? providerFactoryMethod : DEFAULT_ESP_STORE_FACTORY_METHOD));
    if (!m_storeProvider)
        throw MakeStringException(-1, "CwsstoreEx::init: Couldn't instantiate storeprovider lib: '%s' method: '%s'",providerLibraryName, (providerFactoryMethod && *providerFactoryMethod) ? providerFactoryMethod : DEFAULT_ESP_STORE_FACTORY_METHOD);

    m_storeProvider->init(providerInstanceName, "type", storeProviderTree);

    if (!m_isDetachedFromDali)
    {
        ESPLOG(LogMin, "CwsstoreEx: Ensuring configured stores are created:");
        Owned<IPropertyTreeIterator> iter = m_serviceConfig->getElements("Stores/Store");

        StringBuffer owner;
        owner.setf("%s/%s", _process, _service);

        m_defaultStore.clear();

        ForEach(*iter)
        {
            StringBuffer id;
            StringBuffer type;
            StringBuffer description;
            bool isDefault = false;

            iter->query().getProp("@name", id);
            iter->query().getProp("@type", type);
            iter->query().getProp("@description", description);
            isDefault = iter->query().getPropBool("@default", false);

            ESPLOG(LogMin, "CwsstoreEx: Creating Store: '%s'%s", id.str(), isDefault ? " - as Default" : "");
            m_storeProvider->createStore(type.str(), id.str(), description.str(), new CSecureUser(owner.str(), nullptr));
            if (isDefault)
            {
                if (!m_defaultStore.isEmpty())
                   throw MakeStringException(-1, "ws_store init(): Multiple stores erroneously configured as default store!");

                m_defaultStore.set(id.str());
            }
        }
    }
Example #27
0
 std::string VisualizationNode::toXML(const std::string& basePath, int tabs)
 {
     std::string visualizationFilename = getFilename();
     boost::filesystem::path fn(visualizationFilename);
     return toXML(basePath, fn.string(), tabs);
 }
Example #28
0
int doSendQuery(const char * ip, unsigned port, const char * base)
{
    Owned<ISocket> socket;
    Owned<ISecureSocketContext> secureContext;
    __int64 starttime, endtime;
    StringBuffer ipstr;
    try
    {
        if (strcmp(ip, ".")==0)
            ip = GetCachedHostName();
        else
        {
            const char *dash = strchr(ip, '-');
            if (dash && isdigit(dash[1]) && dash>ip && isdigit(dash[-1]))
            {
                if (persistConnections)
                    UNIMPLEMENTED;
                const char *startrange = dash-1;
                while (isdigit(startrange[-1]))
                    startrange--;
                char *endptr;
                unsigned firstnum = atoi(startrange);
                unsigned lastnum = strtol(dash+1, &endptr, 10);
                if (lastnum > firstnum)
                {
                    static unsigned counter;
                    static CriticalSection counterCrit;
                    CriticalBlock b(counterCrit);
                    ipstr.append(startrange - ip, ip).append((counter++ % (lastnum+1-firstnum)) + firstnum).append(endptr);
                    ip = ipstr.str();
                    printf("Sending to %s\n", ip);
                }
            }
        }
        starttime= get_cycles_now();
        if (persistConnections)
        {
            if (!persistSocket)
            {
                SocketEndpoint ep(ip,port);
                persistSocket.setown(ISocket::connect_timeout(ep, 1000));
                if (useSSL)
                {
#ifdef _USE_OPENSSL
                    if (!persistSecureContext)
                        persistSecureContext.setown(createSecureSocketContext(ClientSocket));
                    persistSSock.setown(persistSecureContext->createSecureSocket(persistSocket.getClear()));
                    persistSSock->secure_connect();
                    persistSocket.setown(persistSSock.getClear());
#else
                    throw MakeStringException(-1, "OpenSSL disabled in build");
#endif
                }
            }
            socket = persistSocket;
        }
        else
        {
            SocketEndpoint ep(ip,port);
            socket.setown(ISocket::connect_timeout(ep, 100000));
            if (useSSL)
            {
#ifdef _USE_OPENSSL
                secureContext.setown(createSecureSocketContext(ClientSocket));
                Owned<ISecureSocket> ssock = secureContext->createSecureSocket(socket.getClear());
                ssock->secure_connect();
                socket.setown(ssock.getClear());
#else
                throw MakeStringException(1, "OpenSSL disabled in build");
#endif
            }
        }
    }
    catch(IException * e)
    {
        pexception("failed to connect to server", e);
        return 1;
    }

    StringBuffer fullQuery;
    bool useHTTP = forceHTTP || strstr(base, "<soap:Envelope") != NULL;
    if (useHTTP)
    {
        StringBuffer newQuery;
        Owned<IPTree> p = createPTreeFromXMLString(base, ipt_none, ptr_none);
        const char *queryName = p->queryName();
        if ((stricmp(queryName, "envelope") != 0) && (stricmp(queryName, "envelope") != 0))
        {
            if (queryNameOverride.length())
                queryName = queryNameOverride;
            newQuery.appendf("<Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><Body><%sRequest>", queryName);
            Owned<IPTreeIterator> elements = p->getElements("./*");
            ForEach(*elements)
            {
                IPTree &elem = elements->query();
                toXML(&elem, newQuery, 0, XML_SingleQuoteAttributeValues);
            }
            newQuery.appendf("</%sRequest></Body></Envelope>", queryName);
            base = newQuery.str();
        }
        // note - don't support queryname override unless original query is xml
        fullQuery.appendf("POST /doc HTTP/1.0\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: %d\r\n\r\n", (int) strlen(base)).append(base);
    }
    else
    {
        if (sendToSocket)
 StringBuffer &getPartContent(const char *partname, StringBuffer &content)
 {
     init();
     return toXML(ensurePart(partname), content);
 }
Example #30
0
bool CEnvGen::process()
{
   if (m_showInputOnly)
   {
      if (m_displayFormat == XML_Format)
      {
         StringBuffer cfgXML;
         toXML(m_params, cfgXML.clear());
         printf("Input as XML format:\n");
         printf("%s\n\n",cfgXML.str());
      }
      else if (m_displayFormat == JSON_Format)
      {
         StringBuffer cfgJSON;
         toJSON(m_params, cfgJSON.clear());
         printf("Input as JSON format:\n");
         printf("%s\n\n",cfgJSON.str());
      }
      else
         printf("Unknown display format: %d \n\n", m_displayFormat);

      return true;
   }

   IPropertyTree* config = m_params->queryPropTree("Config");
   const char* mode = config->queryProp("@mode");
   if (!stricmp(mode, "create") )
      m_iConfigEnv->create(config);
   else
      m_iConfigEnv->runUpdateTasks(config);


   // blindly set attribute with xpath
   if (m_arrXPaths.length() > 0)
   {
      unsigned nCount = 0;
      while (nCount < m_arrXPaths.length())
      {
         m_iConfigEnv->setAttribute( m_arrXPaths.item(nCount).str(),
                                     m_arrAttrib.item(nCount).str(),
                                     m_arrValues.item(nCount).str()
                                 );
         nCount++;
      }
   }


   // blindly add content with xpath
   if (m_arrContentXPaths.length() > 0)
   {
      unsigned nCount = 0;
      while (nCount < m_arrContentXPaths.length())
      {
         int format = (!stricmp(m_arrContentFormats.item(nCount), "json")) ? JSON_Format : XML_Format;
         m_iConfigEnv->addContent( m_arrContentXPaths.item(nCount),
                                   m_arrContents.item(nCount), format);
         nCount++;
      }
   }

   StringBuffer out;
   m_iConfigEnv->getContent(NULL, out, XML_SortTags | XML_Format);

   Owned<IFile> pFile;
   const char* envFile = config->queryProp("@env-out");

   //printf("output envxml to file %s\n", envFile);

   pFile.setown(createIFile(envFile));

   Owned<IFileIO> pFileIO;
   pFileIO.setown(pFile->open(IFOcreaterw));
   pFileIO->write(0, out.length(), out.str());

   //printf("%s", out.str());

   if (!m_iConfigEnv->isEnvironmentValid(out))
   {
      fprintf(stderr, "The result environment.xml is invalid.\n");
      return false;
   }

   return true;
}