⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stafhelpservice.cpp

📁 Software Testing Automation Framework (STAF)的开发代码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
        fServiceMap[upperService][errorNumber] = helpData;    }    else    {        STAFMutexSemLock lock(fMapSem);        if (fErrorMap.find(errorNumber) == fErrorMap.end())            return STAFServiceResult(kSTAFDoesNotExist, errorNumber);        if (fErrorMap[errorNumber].find(upperService) ==            fErrorMap[errorNumber].end())        {            return STAFServiceResult(kSTAFDoesNotExist, service);        }        fErrorMap[errorNumber].erase(upperService);        fServiceMap[upperService].erase(errorNumber);    }    return kSTAFOk;}STAFServiceResult STAFHelpService::handleList(    const STAFServiceRequest &requestInfo){    // Verify that the requesting machine/user has at least trust level 2    IVALIDATE_TRUST(2, "LIST");    // Parse the request    STAFCommandParseResultPtr parsedResult = fListParser.parse(        requestInfo.fRequest);     if (parsedResult->rc != kSTAFOk)    {        return STAFServiceResult(kSTAFInvalidRequestString,                                 parsedResult->errorBuffer);    }     DEFINE_VAR_POOL_LIST(varPoolList, varPoolListSize, requestInfo);    STAFString service = "INTERNAL";    STAFString errorBuffer;    STAFString result;    STAFRC_t rc = RESOLVE_OPTIONAL_STRING_OPTION("SERVICE", service);    if (rc != kSTAFOk) return STAFServiceResult(rc, errorBuffer);    STAFString upperService = service.toUpperCase();    STAFObjectPtr mc = STAFObject::createMarshallingContext();    STAFObjectPtr outputList = STAFObject::createList();        STAFMutexSemLock lock(fMapSem);    if (parsedResult->optionTimes("SERVICES") != 0)    {        // Create a marshalled list of strings containing the service names                HelpServiceMap::iterator iter;        for (iter = fServiceMap.begin(); iter != fServiceMap.end(); ++iter)        {            if (iter->first != "INTERNAL")                outputList->append(STAFString(iter->first));        }    }    else    {        if (fServiceMap.find(upperService) == fServiceMap.end())            return STAFServiceResult(kSTAFDoesNotExist, service);        // Create a marshalled list of maps containing the error information        mc->setMapClassDefinition(fErrorInfoClass->reference());                HelpErrorToInfoMap::iterator iter;        for (iter = fServiceMap[upperService].begin();             iter != fServiceMap[upperService].end(); ++iter)        {            STAFObjectPtr errorInfoMap = fErrorInfoClass->createInstance();            errorInfoMap->put("returnCode", STAFString(iter->first));            errorInfoMap->put("description", STAFString(iter->second.info));            outputList->append(errorInfoMap);        }        if (upperService == "INTERNAL")        {            STAFObjectPtr errorInfoMap = fErrorInfoClass->createInstance();            errorInfoMap->put("returnCode", STAFString("4000+"));            errorInfoMap->put(                "description", STAFString("Service specific errors"));            outputList->append(errorInfoMap);        }    }    mc->setRootObject(outputList);    return STAFServiceResult(kSTAFOk, mc->marshall());}STAFServiceResult STAFHelpService::handleError(    const STAFServiceRequest &requestInfo){    // Verify that the requesting machine/user has at least trust level 2    IVALIDATE_TRUST(2, "ERROR");    // Parse the request    STAFCommandParseResultPtr parsedResult =                              fErrorParser.parse(requestInfo.fRequest);     if (parsedResult->rc != kSTAFOk)    {        return STAFServiceResult(kSTAFInvalidRequestString,                                 parsedResult->errorBuffer);    }    DEFINE_VAR_POOL_LIST(varPoolList, varPoolListSize, requestInfo);    STAFString service;    STAFString errorBuffer;    unsigned int errorNumber;    STAFRC_t rc = RESOLVE_OPTIONAL_STRING_OPTION("SERVICE", service);    if (!rc) rc = RESOLVE_OPTIONAL_UINT_OPTION("ERROR", errorNumber);    if (rc) return STAFServiceResult(rc, errorBuffer);    STAFString upperService = service.toUpperCase();    STAFMutexSemLock lock(fMapSem);    if (service.length() != 0)    {        if (fServiceMap.find(upperService) == fServiceMap.end())            return STAFServiceResult(kSTAFDoesNotExist, service);        if (fServiceMap[upperService].find(errorNumber) ==            fServiceMap[upperService].end())        {            return STAFServiceResult(kSTAFDoesNotExist, errorNumber);        }    }    if (fErrorMap.find(errorNumber) == fErrorMap.end())        return STAFServiceResult(kSTAFDoesNotExist, errorNumber);    // Create a marshalled map containing help information for the error    STAFObjectPtr mc = STAFObject::createMarshallingContext();    STAFObjectPtr outputList = STAFObject::createList();        HelpServiceToInfoMap::iterator iter;        if ((upperService.length() != 0) || (errorNumber < 4000))    {        ServiceHelpData helpData;        if (upperService.length() == 0)            upperService = "INTERNAL";        helpData = fErrorMap[errorNumber][upperService];                STAFString info;        STAFString detail;        STAFRC_t rc = RESOLVE_STRING(helpData.info, info);        if (!rc) rc = RESOLVE_STRING(helpData.detail, detail);        if (rc) return STAFServiceResult(rc, errorBuffer);        // Create a marshalled map containing the error information        mc->setMapClassDefinition(fErrorDetailsClass->reference());        STAFObjectPtr errorMap = fErrorDetailsClass->createInstance();        errorMap->put("description", info);        errorMap->put("details", detail);        mc->setRootObject(errorMap);    }    else    {        mc->setMapClassDefinition(fServiceErrorClass->reference());        for(iter = fErrorMap[errorNumber].begin();            iter != fErrorMap[errorNumber].end(); ++iter)        {            STAFString info;            STAFString detail;            STAFRC_t rc = RESOLVE_STRING(iter->second.info, info);            if (!rc) rc = RESOLVE_STRING(iter->second.detail, detail);            if (rc) return STAFServiceResult(rc, errorBuffer);            // Create a marshalled list of maps contains the error information            STAFObjectPtr errorMap = fServiceErrorClass->createInstance();            errorMap->put("service", STAFString(iter->first));            errorMap->put("description", info);            errorMap->put("details", detail);            outputList->append(errorMap);        }        mc->setRootObject(outputList);    }    return STAFServiceResult(kSTAFOk, mc->marshall());}STAFServiceResult STAFHelpService::handleHelp(    const STAFServiceRequest &requestInfo){    // Verify that the requesting machine/user has at least trust level 1    IVALIDATE_TRUST(1, "HELP");    // Return the help text    STAFString result("HELP Service Help");    result += *gLineSeparatorPtr;    result += *gLineSeparatorPtr;    result += "REGISTER   SERVICE <Name> ERROR <Number> INFO <String> "              "DESCRIPTION <String>";     result += *gLineSeparatorPtr;    result += *gLineSeparatorPtr;    result += "UNREGISTER SERVICE <Name> ERROR <Number>";     result += *gLineSeparatorPtr;    result += *gLineSeparatorPtr;    result += "[SERVICE <Name>] ERROR <Number>";    result += *gLineSeparatorPtr;    result += *gLineSeparatorPtr;    result += "LIST SERVICES | [SERVICE <Name>] ERRORS";    result += *gLineSeparatorPtr;    result += *gLineSeparatorPtr;    result += "HELP";    result += *gLineSeparatorPtr;    return STAFServiceResult(kSTAFOk, result);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -