bool Cws_machineEx::onStartStopBegin( IEspContext &context, IEspStartStopBeginRequest &req, 
                                         IEspStartStopBeginResponse &resp)
{
    try
    {
        if (!context.validateFeatureAccess(EXEC_FEATURE_URL, SecAccess_Full, false))
            throw MakeStringException(ECLWATCH_EXECUTION_ACCESS_DENIED, "Permission denied.");

        StringBuffer addresses;
        StringArray& addresses0 = req.getAddresses();
        for(unsigned i = 0; i < addresses0.length(); i++)
        {
            StringBuffer addrStr;
            const char* address = addresses0.item(i);
            updatePathInAddress(address, addrStr);
            if (i > 0)
                addresses.appendf("|Addresses_i%d=%s", i+1, addrStr.str());
            else
                addresses.appendf("Addresses_i1=%s", addrStr.str());
        }

        resp.setAddresses(addresses);
        resp.setKey1(req.getKey1());
        resp.setKey2(req.getKey2());
        resp.setStop(req.getStop());
        double version = context.getClientVersion();
        if (version > 1.07)
        {
            resp.setAutoRefresh( req.getAutoRefresh() );
            resp.setMemThreshold(req.getMemThreshold());
            resp.setDiskThreshold(req.getDiskThreshold());
            resp.setCpuThreshold(req.getCpuThreshold());
            resp.setMemThresholdType(req.getMemThresholdType());
            resp.setDiskThresholdType(req.getDiskThresholdType());
        }
    }
    catch(IException* e)
    {   
        FORWARDEXCEPTION(context, e,  ECLWATCH_INTERNAL_ERROR);
    }
    return true;
}
    virtual void getNavigationData(IEspContext &context, IPropertyTree & data)
    {
        IPropertyTree *folder = ensureNavFolder(data, "Roxie Queries", NULL, NULL, false, 7);
        ensureNavLink(*folder, "Search Roxie Queries", "/WsRoxieQuery/RoxieQuerySearch", "Search Roxie Queries", NULL, NULL, 1);

        StringBuffer path = "/WsSMC/NotInCommunityEdition?form_";
        if (m_portalURL.length() > 0)
            path.appendf("&EEPortal=%s", m_portalURL.str());
        ensureNavLink(*folder, "Search Roxie Files",path.str(), "Search Roxie Files", NULL, NULL, 2);
        ensureNavLink(*folder, "View Roxie Files", path.str(), "View Roxie Files", NULL, NULL, 3);
    }
    CWsSMCSoapBindingEx(IPropertyTree* cfg, const char *bindname=NULL, const char *procname=NULL):CWsSMCSoapBinding(cfg, bindname, procname)
    {
        if (!procname || !*procname)
            return;

        StringBuffer xpath;
        xpath.appendf("Software/EspProcess[@name='%s']/@portalurl", procname);
        const char* portalURL = cfg->queryProp(xpath.str());
        if (portalURL && *portalURL)
            m_portalURL.append(portalURL);
    }
示例#4
0
    CouchbaseEmbedFunctionContext::CouchbaseEmbedFunctionContext(const IContextLogger &_logctx, const char *options, unsigned _flags)
    : logctx(_logctx), m_NextRow(), m_nextParam(0), m_numParams(0), m_scriptFlags(_flags)
    {
        cbQueryIterator = NULL;
        m_pCouchbaseClient = nullptr;
        m_pQuery = nullptr;
        m_pQcmd = nullptr;

        const char *server = "localhost";
        const char *user = "";
        const char *password = "";
        const char *bucketname = "default";
        unsigned port = 8093;
        bool useSSL = false;
        StringBuffer connectionOptions;

        StringArray inputOptions;
        inputOptions.appendList(options, ",");
        ForEachItemIn(idx, inputOptions)
        {
            const char *opt = inputOptions.item(idx);
            const char *val = strchr(opt, '=');
            if (val)
            {
                StringBuffer optName(val-opt, opt);
                val++;
                if (stricmp(optName, "server")==0)
                    server = val;   // Note that lifetime of val is adequate for this to be safe
                else if (stricmp(optName, "port")==0)
                    port = atoi(val);
                else if (stricmp(optName, "user")==0)
                    user = val;
                else if (stricmp(optName, "password")==0)
                    password = val;
                else if (stricmp(optName, "bucket")==0)
                    bucketname = val;
                else if (stricmp(optName, "useSSL")==0)
                    useSSL = clipStrToBool(val);

                //Connection String options
                else if (stricmp(optName,   "detailed_errcodes")==0
                        || stricmp(optName, "operation_timeout")==0
                        || stricmp(optName, "config_total_timeout")==0
                        || stricmp(optName, "http_poolsize")==0
                        || stricmp(optName, "detailed_errcodes")==0)
                    connectionOptions.appendf("%s%s=%s", connectionOptions.length() == 0 ? "?" : "&", optName.str(), val);
                else
                    failx("Unknown option %s", optName.str());
            }
        }

        m_oCBConnection.setown(new CouchbaseConnection(useSSL, server, port, bucketname, user, password, connectionOptions.str()));
        m_oCBConnection->connect();
    }
示例#5
0
IPropertyTree * SWProcess::addComputer(const char* ip)
{
   Hardware *hd = (Hardware*) m_envHelper->getEnvComp("hardware");
   StringBuffer sbTask;
   sbTask.clear().append("<Task operation=\"add\" category=\"hardware\" component=\"Computer\">");
   sbTask.appendf("<Attributes><Attribute name=\"ip\" value=\"%s\"/></Attributes></Task>", ip);

   Owned<IPropertyTree> params = createPTreeFromXMLString(sbTask.str());
   IPropertyTree * pComputer =  hd->addComputer(params);
   return pComputer;
}
bool deletePkgInfo(const char *name, const char *target, const char *process, bool globalScope)
{
    Owned<IRemoteConnection> pkgSetsConn = querySDS().connect("/PackageSets/", myProcessSession(), RTM_LOCK_WRITE, SDS_LOCK_TIMEOUT);
    if (!pkgSetsConn)
        throw MakeStringException(PKG_NONE_DEFINED, "No package sets defined");

    IPropertyTree* packageSets = pkgSetsConn->queryRoot();

    StringBuffer pkgSetId;
    buildPkgSetId(pkgSetId, process);
    VStringBuffer pkgSet_xpath("PackageSet[@id='%s']", pkgSetId.str());
    IPropertyTree *pkgSetRegistry = packageSets->queryPropTree(pkgSet_xpath.str());
    if (!pkgSetRegistry)
        throw MakeStringException(PKG_TARGET_NOT_DEFINED, "No package sets defined for %s", process);

    StringBuffer lcTarget(target);
    target = lcTarget.toLowerCase().str();

    StringBuffer lcName(name);
    name = lcName.toLowerCase().str();

    Owned<IPropertyTree> mapEntry;
    StringBuffer xpath;
    if (!globalScope)
    {
        xpath.appendf("PackageMap[@id='%s::%s'][@querySet='%s']", target, name, target);
        mapEntry.setown(pkgSetRegistry->getPropTree(xpath.str()));
    }
    if (!mapEntry)
    {
        xpath.clear().appendf("PackageMap[@id='%s'][@querySet='%s']", name, target);
        mapEntry.setown(pkgSetRegistry->getPropTree(xpath.str()));
        if (!mapEntry)
            throw MakeStringException(PKG_DELETE_NOT_FOUND, "Unable to delete %s - information not found", lcName.str());
    }
    StringAttr pmid(mapEntry->queryProp("@id"));
    pkgSetRegistry->removeTree(mapEntry);

    xpath.clear().appendf("PackageSet/PackageMap[@id='%s']", pmid.get());
    if (!packageSets->hasProp(xpath))
    {
        Owned<IRemoteConnection> pkgMapsConn = querySDS().connect("/PackageMaps/", myProcessSession(), RTM_LOCK_WRITE, SDS_LOCK_TIMEOUT);
        if (!pkgMapsConn)
            throw MakeStringException(PKG_DALI_LOOKUP_ERROR, "Unable to retrieve PackageMaps information from dali [/PackageMaps]");
        IPropertyTree *pkgMaps = pkgMapsConn->queryRoot();
        if (!pkgMaps)
            throw MakeStringException(PKG_DALI_LOOKUP_ERROR, "Unable to retrieve PackageMaps information from dali [/PackageMaps]");
        IPropertyTree *mapTree = pkgMaps->queryPropTree(xpath.clear().appendf("PackageMap[@id='%s']", pmid.get()).str());
        if (mapTree)
            pkgMaps->removeTree(mapTree);
    }
    return true;
}
示例#7
0
void CSchemaMapManager::addMapOfXSDXPathToElement(const char* pXPath, CElement *pElement)
{
    assert (pElement != nullptr);
    assert(pXPath != nullptr && *pXPath != 0);

    if (pElement != nullptr && pXPath != nullptr && *pXPath != 0)
    {
        StringBuffer strFullXPath;
        strFullXPath.appendf("%s-%s",pElement->getConstSchemaNode()->getXSDXPath(), pXPath);
        m_pXSDToElementPtrsMap->setValue(strFullXPath.str(), pElement);
    }
}
示例#8
0
void CEnvGen::createUpdateNodeTask(const char* action, IPropertyTree * config, const char* param)
{
    StringBuffer sbParam;
    StringArray parts;
    parts.appendList(param, ":");

    String part1(parts.item(0));
    if (part1.startsWith("spark"))
    {
        sbParam.clear().append("pg:buildset#sparkthor");
        createUpdateTask(action, config, sbParam.str());
    }

    if (part1.startsWith("thor"))
    {
       for ( unsigned i = 1; i < parts.ordinality() ; i++)
       {
          sbParam.clear().append("sw:");
          StringBuffer sbPart1(part1.str());
          sbPart1.append(":instance-").appendf("%s",parts.item(i));
          sbParam.appendf("%s", sbPart1.str());
          createUpdateTask(action, config, sbParam.str());
       }
    }
    else
    {
       if (part1.startsWith("computer"))
           sbParam.append("hd:").appendf("%s", part1.str());

       else
       {
          sbParam.clear().append("sw:");
          StringBuffer sbPart1(part1.str());
          sbPart1.replaceString("@", ":instance@");
          sbParam.appendf("%s", sbPart1.str());
       }
       createUpdateTask(action, config, sbParam.str());
    }

}
void SplitRecord(const char*  strLine, StringBuffer& GUID, StringBuffer& Cache)
{
    if(strLine==NULL || *strLine=='\0')
        return;

    while(*strLine && *strLine != '\t' && *strLine != '\0')
    {
        GUID.append(*strLine);
        strLine++;
    }
    strLine++;
    Cache.appendf("%s",strLine);
}
示例#10
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);
        }
    }
示例#11
0
const byte * HelperDll::getResource(unsigned id) const
{
#ifdef _WIN32
    HINSTANCE dllHandle = so.getInstanceHandle();
    HRSRC hrsrc = FindResource(dllHandle, MAKEINTRESOURCE(id), "BIGSTRING");
    if (hrsrc)
        return (const byte *) LoadResource(dllHandle, hrsrc);
    return NULL;
#else
    StringBuffer resourceName;
    resourceName.appendf("BIGSTRING_%d_txt_start", id);
    return (const byte *) getEntry(resourceName.str());
#endif
}
示例#12
0
bool ResourceManager::getDuplicateResourceId(const char *srctype, const char *respath, const char *filepath, int &id)
{
    StringBuffer xpath;
    if (respath && *respath)
        xpath.appendf("Resource[@resourcePath='%s']", respath);
    else
        xpath.appendf("Resource[@originalFilename='%s']", filepath);
    Owned<IPropertyTreeIterator> iter = manifest->getElements(xpath.str());
    ForEach (*iter)
    {
        IPropertyTree &item = iter->query();
        if (item.hasProp("@id"))
        {
            const char *type = item.queryProp("@type");
            if (type && strieq(type, srctype))
            {
                id=item.getPropInt("@id");
                return true;
            }
        }
    }
    return false;
}
示例#13
0
IPropertyTree *CEspBinding::ensureNavMenu(IPropertyTree &root, const char *name)
{
    StringBuffer xpath;
    xpath.appendf("Menu[@name=\"%s\"]", name);

    IPropertyTree *ret = root.queryPropTree(xpath.str());
    if (!ret)
    {
        ret=createPTree("Menu");
        ret->addProp("@name", name);
        root.addPropTree("Menu", ret);
    }
    return ret;
}
bool LogicFileWrapper::doDeleteFile(const char* logicalName,const char *cluster, StringBuffer& returnStr, IUserDescriptor* udesc)
{
    CDfsLogicalFileName lfn;
    lfn.set(logicalName);
    StringBuffer cname;
    lfn.getCluster(cname);
    if (0 == cname.length()) // if has no cluster, use supplied cluster
        lfn.setCluster(cluster);
    lfn.get(cname.clear(), false, true); // get file@cluster form;

    try
    {
        IDistributedFileDirectory &fdir = queryDistributedFileDirectory();
        {
            Owned<IDistributedFile> df = fdir.lookup(cname.str(), udesc, true) ;
            if(!df)
            {
                returnStr.appendf("<Message><Value>File %s not found</Value></Message>", cname.str());
                return false;
            }
        }

        fdir.removeEntry(cname.str(), udesc, NULL, REMOVE_FILE_SDS_CONNECT_TIMEOUT, true);
        returnStr.appendf("<Message><Value>Deleted File %s</Value></Message>", cname.str());
        DBGLOG("%s", returnStr.str());
        return true;
    }
    catch (IException *e)
    {
        StringBuffer errorMsg;
        e->errorMessage(returnStr);
        e->Release();
        PROGLOG("%s", errorMsg.str());
        returnStr.appendf("<Message><Value>Failed to delete File %s, error: %s</Value></Message>", cname.str(), errorMsg.str());
    }
    return false;
}
示例#15
0
bool CConfigHelper::isInBuildSet(const char* comp_process_name, const char* comp_name) const
{
  StringBuffer xpath;

  xpath.appendf("./%s/%s/%s[%s=\"%s\"][%s=\"%s\"]", XML_TAG_PROGRAMS, XML_TAG_BUILD, XML_TAG_BUILDSET, XML_ATTR_PROCESS_NAME, comp_process_name, XML_ATTR_NAME, comp_name);

  if (strcmp(XML_TAG_DIRECTORIES,comp_name) != 0 && m_pDefBldSet->hasProp(xpath.str()) == false)
  {
     return false;
  }
  else
  {
     return true;
  }
}
示例#16
0
void CJHTreeNode::dump()
{
    for (unsigned int i=0; i<getNumKeys(); i++)
    {
        unsigned char *dst = (unsigned char *) alloca(keyLen+50);
        getValueAt(i,(char *) dst);
        offset_t pos = getFPosAt(i);

        StringBuffer nodeval;
        for (unsigned j = 0; j < keyLen; j++)
            nodeval.appendf("%02x", dst[j] & 0xff);
        DBGLOG("keyVal %d [%" I64F "d] = %s", i, pos, nodeval.str());
    }
    DBGLOG("==========");
}
示例#17
0
void CEnvGen::createUpdateBindingTask(const char* action, IPropertyTree * config, const char* param)
{
    StringArray bindingAndAttrs;
    bindingAndAttrs.appendList(param, "@");
    StringArray espAndBinding;
    espAndBinding.appendList(bindingAndAttrs.item(0), ":");
    if (bindingAndAttrs.ordinality() != 2)
    {
       if (!stricmp(action, "modify") && (espAndBinding.ordinality() != 2))
          throw MakeStringException(CfgEnvErrorCode::InvalidParams,
             "\"-mod-binding\" should have format: <esp name>:<binding name>@attr1=<value>^attr2=value>");
       else if (!stricmp(action, "add"))
          throw MakeStringException(CfgEnvErrorCode::InvalidParams,
             "\"-add-binding\" should have format: <esp name>@name=<value>^service=<value>");
    }

    if (!stricmp(action, "remove") && (espAndBinding.ordinality() != 2))
        throw MakeStringException(CfgEnvErrorCode::InvalidParams,
           "\"-rmv-binding\" should have format: <esp name>:<binding name>");

    StringBuffer sbParam;
    sbParam.appendf("sw:esp#%s:EspBinding", espAndBinding.item(0));

    if ((espAndBinding.ordinality() == 2) && *(espAndBinding.item(1)))
    {
       if (stricmp(action, "remove"))
          sbParam.appendf("#%s", espAndBinding.item(1));
       else
          sbParam.appendf("@name=%s", espAndBinding.item(1));
    }

    if (stricmp(action, "remove"))
       sbParam.appendf("@%s", bindingAndAttrs.item(1));

    createUpdateTask(action, config, sbParam.str());
}
示例#18
0
IPropertyTree *CEspBinding::ensureNavMenuItem(IPropertyTree &root, const char *name, const char *tooltip, const char *action)
{
    StringBuffer xpath;
    xpath.appendf("MenuItem[@name=\"%s\"]", name);
    IPropertyTree *ret = root.queryPropTree(xpath.str());
    if (!ret)
    {
        ret=createPTree("MenuItem");
        ret->addProp("@name", name);
        ret->addProp("@tooltip", tooltip);
        ret->addProp("@action", action);
        root.addPropTree("MenuItem", ret);
    }
    return ret;
}
示例#19
0
CXRefNode::CXRefNode(const char* NodeName, IRemoteConnection *_conn)
{
    //DBGLOG("CXRefNode::CXRefNode(const char* NodeName)");

    m_bChanged = false;
    m_conn.set(_conn);

    StringBuffer xpath;
    xpath.appendf("Cluster[@name=\"%s\"]", NodeName);

    IPropertyTree* cluster_ptree = m_conn->queryRoot()->queryPropTree(xpath.str());
    m_XRefTree.set(cluster_ptree);
    m_XRefTree->getProp("@name",m_origName);
    //DBGLOG("returning from CXRefNode::CXRefNode(const char* NodeName)");

}
示例#20
0
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;
}
bool CLogContentFilter::readLogFilters(IPropertyTree* cfg, unsigned groupID)
{
    Owned<CESPLogContentGroupFilters> espLogContentGroupFilters = new CESPLogContentGroupFilters((ESPLogContentGroup) groupID);
    StringBuffer xpath;
    if (groupID != ESPLCGAll)
        xpath.appendf("Filters/Filter[@type='%s']", espLogContentGroupNames[groupID]);
    else
        xpath.append("Filters/Filter");
    Owned<IPropertyTreeIterator> filters = cfg->getElements(xpath.str());
    ForEach(*filters)
    {
        IPropertyTree &filter = filters->query();
        StringBuffer value = filter.queryProp("@value");
        if (!value.length())
            continue;

        //clean "//"
        unsigned idx = value.length()-1;
        while (idx)
        {
            if ((value.charAt(idx-1) == '/') && (value.charAt(idx) == '/'))
                value.remove(idx, 1);
            idx--;
        }

        //clean "/*" at the end
        while ((value.length() > 1) && (value.charAt(value.length()-2) == '/') && (value.charAt(value.length()-1) == '*'))
            value.setLength(value.length() - 2);

        if (value.length() && !streq(value.str(), "*") && !streq(value.str(), "/") && !streq(value.str(), "*/"))
        {
            espLogContentGroupFilters->addFilter(value.str());
        }
        else
        {
            espLogContentGroupFilters->clearFilters();
            break;
        }
    }

    bool hasFilter = espLogContentGroupFilters->getFilterCount() > 0;
    if (hasFilter)
        groupFilters.append(*espLogContentGroupFilters.getClear());
    return hasFilter;
}
    virtual void getNavigationData(IEspContext &context, IPropertyTree & data)
    {
        bool isFF = false;
        StringBuffer browserUserAgent;
        context.getUseragent(browserUserAgent);
        if ((browserUserAgent.length() > 0) && strstr(browserUserAgent.str(), "Firefox"))
            isFF = true;

        IPropertyTree *folder = ensureNavFolder(data, "My Account", "My Account");
        StringBuffer path = "/WsSMC/NotInCommunityEdition?form_";
        if (m_portalURL.length() > 0)
            path.appendf("&EEPortal=%s", m_portalURL.str());

        ensureNavLink(*folder, "Change Password", path.str(), "Change Password");
        if (!isFF)
            ensureNavLink(*folder, "Relogin", path.str(), "Relogin");
        ensureNavLink(*folder, "Who Am I", path.str(), "WhoAmI");
    }
示例#23
0
void CJHVarTreeNode::dump()
{
    for (unsigned int i=0; i<getNumKeys(); i++)
    {
        const void * p = recArray[i];
        unsigned reclen = ((KEYRECSIZE_T *) p)[-1];
        _WINREV(reclen);
        unsigned char *dst = (unsigned char *) alloca(reclen);
        getValueAt(i,(char *) dst);
        offset_t pos = getFPosAt(i);

        StringBuffer nodeval;
        for (unsigned j = 0; j < reclen; j++)
            nodeval.appendf("%02x", dst[j] & 0xff);
        DBGLOG("keyVal %d [%" I64F "d] = %s", i, pos, nodeval.str());
    }
    DBGLOG("==========");
}
示例#24
0
int CXslTransform::transform(StringBuffer &target)
{
    if(!m_ParsedSource)
        throw MakeStringException(1, "[XML source not set]");
    else if(!m_xslsource)
        throw MakeStringException(2, "[XSL stylesheet not set]");


    XalanCompiledStylesheet* pCompiledStylesheet = NULL;
    pCompiledStylesheet = m_xslsource->getStylesheet();

    if (!pCompiledStylesheet)
    {
        DBGLOG("[failed to compile XSLT stylesheet]");
        throw MakeStringException(2, "[failed to compile XSLT stylesheet]");
    }

    int rc=0;
    m_sMessages.clear();
    try
    {
        XalanStringBufferOutputHandler output(target);
        rc = m_XalanTransformer.transform(*m_ParsedSource, pCompiledStylesheet,
            (void*)&output, (XalanOutputHandlerType)output.callback, (XalanFlushHandlerType)0);
    }
    catch(...)
    {
        StringBuffer estr("[Exception running XSLT stylesheet]");
        estr.appendf("[%s]", m_XalanTransformer.getLastError());
        DBGLOG("%s", estr.str());
        throw MakeStringException(2, "%s", estr.str());
    }

    if (rc < 0)
    {
        StringBuffer estr;
        estr.appendf("[%s]", m_XalanTransformer.getLastError());
        DBGLOG("%s", estr.str());
        throw MakeStringException(2, "%s", estr.str());
    }

    return rc;
}
示例#25
0
ESP_FACTORY IEspRpcBinding * esp_binding_factory(const char *name, const char* type, IPropertyTree *cfg, const char *process)
{
    if (strcmp(type, "ws_eclSoapBinding")==0)
    {
        StringBuffer xpath;
        xpath.appendf("Software/EspProcess[@name=\"%s\"]", process);
        Owned<IPropertyTree> bcfg = cfg->getPropTree(xpath.str());
        const char* cfgFile = cfg->queryProp("@config");
        if (cfgFile)
            bcfg->addProp("@config", cfgFile);
        return new CWsEclBinding(bcfg.get(), name, process);
    }
    else
    {
        throw MakeStringException(-1, "Unknown binding type %s", type);
    }

    return NULL;
}
示例#26
0
IXRefNode * CXRefNodeManager::getXRefNode(const char* NodeName)
{
    //DBGLOG("Node Name %s:",NodeName);

    StringBuffer xpath;
    xpath.appendf("Cluster[@name=\"%s\"]", NodeName);
    //if not exists, add DFU/XREF/ClusterName branch to SDS
    //not linked
    Owned<IRemoteConnection> conn = querySDS().connect("/DFU/XREF",myProcessSession(),RTM_CREATE_QUERY|RTM_NONE ,INFINITE);
    IPropertyTree* cluster_ptree = conn->queryRoot()->queryPropTree(xpath.str());
    conn->commit();
    if (cluster_ptree==0)
    {
        DBGLOG("Cluster[@name=%s] can't be found under /DFU/XREF", NodeName);
        return 0 ;
    }
    return new CXRefNode(NodeName,conn);

}
示例#27
0
    virtual void append(IMultiException& me)
    {
        synchronized block(m_mutex);

        IArrayOf<IException>& exceptions = me.getArray();
        const char* source = me.source();
        ForEachItemIn(i, exceptions)
        {
            IException& e = exceptions.item(i);
            if (source && *source)
            {
                StringBuffer msg;
                msg.appendf("[%s] ",source);
                e.errorMessage(msg);
                array_.append(*MakeStringExceptionDirect(e.errorAudience(), e.errorCode(), msg));
            }
            else
                array_.append(*LINK(&e));
        }
示例#28
0
    static void buildJsonAppendValue(IXmlType* type, StringBuffer& out, const char* tag, const char *value, unsigned flags)
    {
        JSONField_Category ct = xsdTypeToJSONFieldCategory(type->queryName());

        if (ct==JSONField_Present && (!value || !*value))
            return;

        if (tag && *tag)
            out.appendf("\"%s\": ", tag);
        StringBuffer sample;
        if ((!value || !*value) && (flags & REQSF_SAMPLE_DATA))
        {
            type->getSampleValue(sample, NULL);
            value = sample.str();
        }

        if (value)
        {
            switch (ct)
            {
            case JSONField_String:
                appendJSONValue(out, NULL, value);
                break;
            case JSONField_Integer:
                appendJSONNumericString(out, value, false);
                break;
            case JSONField_Real:
                appendJSONNumericString(out, value, true);
                break;
            case JSONField_Boolean:
                if (strieq(value, "default"))
                    out.append("null");
                else
                    appendJSONValue(out, NULL, strToBool(value));
                break;
            case JSONField_Present:
                appendJSONValue(out, NULL, true);
                break;
            }
        }
        else
            out.append("null");
    }
void CEclDirectEx::init(IPropertyTree *cfg, const char *process, const char *service)
{
    StringBuffer xpath;
    xpath.appendf("Software/EspProcess[@name=\"%s\"]/EspService[@name=\"%s\"]", process, service);
    Owned<IPropertyTree> srvcfg = cfg->getPropTree(xpath.str());

    if (!srvcfg)
    {
        IERRLOG("EclDirect: Configuration Error: unable to load configuration");
        throw MakeStringException(-1, "EclDirect: Configuration Error: unable to load configuration");
    }

    srvcfg->getProp("ClusterName", defaultCluster);

    defaultWait = srvcfg->getPropInt("WuTimeout", 60000);
    deleteWorkunits = cfg->getPropBool("DeleteWorkUnits", false);

    refreshValidClusters();
}
示例#30
0
int CXslTransform::transform(ISocket* targetSocket)
{
    if(!m_ParsedSource)
        throw MakeStringException(1, "[XML source not set for XSLT[");
    else if(!m_xslsource)
        throw MakeStringException(2, "[XSL stylesheet not set]");

    XalanCompiledStylesheet* pCompiledStylesheet = NULL;
    pCompiledStylesheet = m_xslsource->getStylesheet();

    if (!pCompiledStylesheet)
    {
        DBGLOG("[failed to compile XSLT stylesheet]");
        throw MakeStringException(2, "[failed to compile XSLT stylesheet]");
    }

    int rc=0;
    m_sMessages.clear();
    try
    {
        m_resultTarget = new XSLTResultTarget();
        Owned<ISocketOutputStream> stream = createSocketOutputStream(targetSocket);
        m_resultTarget->setCharacterStream(stream->getWriter());
        rc = m_XalanTransformer.transform(*m_ParsedSource, pCompiledStylesheet, *m_resultTarget);
    }
    catch(...)
    {
        StringBuffer estr("[Exception running XSLT stylesheet]");
        estr.appendf("[%s]", m_XalanTransformer.getLastError());
        DBGLOG("%s", estr.str());
        throw MakeStringException(2, "%s", estr.str());
    }
    if (rc < 0)
    {
        StringBuffer estr;
        estr.appendf("[%s]", m_XalanTransformer.getLastError());
        DBGLOG("%s", estr.str());
        throw MakeStringException(2, "%s", estr.str());
    }

    return rc;
}