bool CLoggingManager::getTransactionID(StringAttrMapping* transFields, StringBuffer& transactionID, StringBuffer& status)
{
    if (!initialized)
        throw MakeStringException(-1,"LoggingManager not initialized");

    try
    {
        for (unsigned int x = 0; x < loggingAgentThreads.size(); x++)
        {
            IUpdateLogThread* loggingThread = loggingAgentThreads[x];
            if (!loggingThread->hasService(LGSTGetTransactionID))
                continue;

            IEspLogAgent* loggingAgent = loggingThread->getLogAgent();
            loggingAgent->getTransactionID(transFields, transactionID);
            if (!transactionID.isEmpty())
                ESPLOG(LogMax, "Got TransactionID '%s'", transactionID.str());
            return true;
        }
    }
    catch (IException* e)
    {
        e->errorMessage(status);
        e->Release();
    }

    return false;
}
void CWSESPControlEx::init(IPropertyTree *cfg, const char *process, const char *service)
{
    if(cfg == NULL)
        throw MakeStringException(-1, "Can't initialize CWSESPControlEx, cfg is NULL");

    espProcess.set(process);

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

    Owned<IPropertyTreeIterator> it = espCFG->getElements("AuthDomains/AuthDomain");
    ForEach(*it)
    {
        IPropertyTree& authDomain = it->query();
        StringBuffer name = authDomain.queryProp("@domainName");
        if (name.isEmpty())
            name.set("default");
        sessionTimeoutMinutesMap.setValue(name.str(), authDomain.getPropInt("@sessionTimeoutMinutes", 0));
    }
}
예제 #3
0
*/

#include "catch/catch.hpp"

#include "../str.h"
#include "../strbuf.h"

using namespace herschel;


TEST_CASE("StringBuffer basic", "[string][string-buffer]")
{
  StringBuffer buf("hello world");
  REQUIRE(buf.toString() == String("hello world"));
  REQUIRE(buf.length() == 11);
  REQUIRE(!buf.isEmpty());
}


TEST_CASE("StringBuffer compare", "[string][string-buffer]")
{
  StringBuffer buf2(String("hello world"));
  REQUIRE(buf2.toString() == String("hello world"));

  StringBuffer buf3(buf2);
  REQUIRE(buf3.toString() == String("hello world"));
}


TEST_CASE("StringBuffer append string", "[string][string-buffer]")
{
예제 #4
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));
   }

}