本文整理汇总了C++中IEspContext类的典型用法代码示例。如果您正苦于以下问题:C++ IEspContext类的具体用法?C++ IEspContext怎么用?C++ IEspContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IEspContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onAddPackage
bool CWsPackageProcessEx::onAddPackage(IEspContext &context, IEspAddPackageRequest &req, IEspAddPackageResponse &resp)
{
resp.updateStatus().setCode(0);
StringAttr target(req.getTarget());
StringAttr name(req.getPackageMap());
if (target.isEmpty())
throw MakeStringExceptionDirect(PKG_MISSING_PARAM, "Target cluster parameter required");
if (name.isEmpty())
throw MakeStringExceptionDirect(PKG_MISSING_PARAM, "PackageMap name parameter required");
DBGLOG("%s adding packagemap %s to target %s", context.queryUserId(), name.str(), target.str());
StringBuffer pmid;
if (!req.getGlobalScope())
pmid.append(target).append("::");
pmid.append(name.get());
bool activate = req.getActivate();
unsigned updateFlags = 0;
if (req.getOverWrite())
updateFlags |= (DALI_UPDATEF_PACKAGEMAP | DALI_UPDATEF_REPLACE_FILE | DALI_UPDATEF_CLONE_FROM | DALI_UPDATEF_SUPERFILES);
if (req.getReplacePackageMap())
updateFlags |= DALI_UPDATEF_PACKAGEMAP;
if (req.getUpdateCloneFrom())
updateFlags |= DALI_UPDATEF_CLONE_FROM;
if (req.getUpdateSuperFiles())
updateFlags |= DALI_UPDATEF_SUPERFILES;
if (req.getAppendCluster())
updateFlags |= DALI_UPDATEF_APPEND_CLUSTER;
StringAttr processName(req.getProcess());
Owned<IUserDescriptor> userdesc;
const char *user = context.queryUserId();
const char *password = context.queryPassword();
if (user && *user && *password && *password)
{
userdesc.setown(createUserDescriptor());
userdesc->set(user, password);
}
StringBuffer srcCluster;
StringBuffer daliip;
StringBuffer prefix;
splitDerivedDfsLocation(req.getDaliIp(), srcCluster, daliip, prefix, req.getSourceProcess(), req.getSourceProcess(), NULL, NULL);
StringBuffer pkgSetId;
buildPkgSetId(pkgSetId, processName.get());
StringArray filesNotFound;
addPackageMapInfo(updateFlags, req.getInfo(), filesNotFound, processName, target, pmid, pkgSetId, daliip, srcCluster, prefix, activate, userdesc, req.getAllowForeignFiles(), req.getPreloadAllPackages());
resp.setFilesNotFound(filesNotFound);
StringBuffer msg;
msg.append("Successfully loaded ").append(name.get());
resp.updateStatus().setDescription(msg.str());
return true;
}
示例2: onAddPackage
bool CWsPackageProcessEx::onAddPackage(IEspContext &context, IEspAddPackageRequest &req, IEspAddPackageResponse &resp)
{
PackageMapUpdater updater;
updater.setFlag(PKGADD_MAP_CREATE);
updater.setFlag(PKGADD_MAP_ACTIVATE, req.getActivate());
updater.setFlag(PKGADD_MAP_REPLACE, req.getOverWrite());
updater.setFlag(PKGADD_ALLOW_FOREIGN, req.getAllowForeignFiles());
updater.setFlag(PKGADD_PRELOAD_ALL, req.getPreloadAllPackages());
updater.setPMID(req.getTarget(), req.getPackageMap(), req.getGlobalScope());
updater.setProcess(req.getProcess());
updater.setUser(context.queryUserId(), context.queryPassword());
updater.setDerivedDfsLocation(req.getDaliIp(), req.getSourceProcess());
unsigned updateFlags = 0;
if (req.getOverWrite())
updateFlags |= (DALI_UPDATEF_PACKAGEMAP | DALI_UPDATEF_REPLACE_FILE | DALI_UPDATEF_CLONE_FROM | DALI_UPDATEF_SUPERFILES);
if (req.getReplacePackageMap())
updateFlags |= DALI_UPDATEF_PACKAGEMAP;
if (req.getUpdateCloneFrom())
updateFlags |= DALI_UPDATEF_CLONE_FROM;
if (req.getUpdateSuperFiles())
updateFlags |= DALI_UPDATEF_SUPERFILES;
if (req.getAppendCluster())
updateFlags |= DALI_UPDATEF_APPEND_CLUSTER;
StringArray filesNotFound;
updater.create(req.getPackageMap(), req.getInfo(), updateFlags, filesNotFound);
resp.setFilesNotFound(filesNotFound);
resp.updateStatus().setCode(0);
resp.updateStatus().setDescription(StringBuffer("Successfully loaded ").append(req.getPackageMap()));
return true;
}
示例3: onSetLogging
bool CWSESPControlEx::onSetLogging(IEspContext& context, IEspSetLoggingRequest& req, IEspSetLoggingResponse& resp)
{
try
{
#ifdef _USE_OPENLDAP
CLdapSecManager* secmgr = dynamic_cast<CLdapSecManager*>(context.querySecManager());
if(secmgr && !secmgr->isSuperUser(context.queryUser()))
{
context.setAuthStatus(AUTH_STATUS_NOACCESS);
throw MakeStringException(ECLWATCH_SUPER_USER_ACCESS_DENIED, "Failed to change log settings. Permission denied.");
}
#endif
if (!m_container)
throw MakeStringException(ECLWATCH_INTERNAL_ERROR, "Failed to access container.");
if (!req.getLoggingLevel_isNull())
m_container->setLogLevel(req.getLoggingLevel());
if (!req.getLogRequests_isNull())
m_container->setLogRequests(req.getLogRequests());
if (!req.getLogResponses_isNull())
m_container->setLogResponses(req.getLogResponses());
resp.setStatus(0);
resp.setMessage("Logging settings are updated.");
}
catch(IException* e)
{
FORWARDEXCEPTION(context, e, ECLWATCH_INTERNAL_ERROR);
}
return true;
}
示例4: onCleanSession
bool CWSESPControlEx::onCleanSession(IEspContext& context, IEspCleanSessionRequest& req, IEspCleanSessionResponse& resp)
{
try
{
#ifdef _USE_OPENLDAP
CLdapSecManager* secmgr = dynamic_cast<CLdapSecManager*>(context.querySecManager());
if(secmgr && !secmgr->isSuperUser(context.queryUser()))
{
context.setAuthStatus(AUTH_STATUS_NOACCESS);
throw MakeStringException(ECLWATCH_SUPER_USER_ACCESS_DENIED, "Failed to clean session. Permission denied.");
}
#endif
StringBuffer id, userID, fromIP;
bool allSessions = req.getAllSessions();
if (!allSessions)
{
id.set(req.getID());
userID.set(req.getUserID());
fromIP.set(req.getFromIP());
if ((id.trim().isEmpty()) && (userID.trim().isEmpty()) && (fromIP.trim().isEmpty()))
throw MakeStringException(ECLWATCH_INVALID_INPUT, "ID, userID or FromIP has to be specified.");
}
cleanSessions(allSessions, id.str(), userID.str(), fromIP.str());
resp.setStatus(0);
resp.setMessage("Session is cleaned.");
}
catch(IException* e)
{
FORWARDEXCEPTION(context, e, ECLWATCH_INTERNAL_ERROR);
}
return true;
}
示例5: queueLog
bool CLogThread::queueLog(IEspContext & context,const char* serviceName, const char* request, const char* response)
{
IProperties* pProperties = context.queryRequestParameters();
StringBuffer UserID, UserRealm, UserReference, peer;
if(pProperties != NULL && pProperties->hasProp("userid_"))
UserID.appendf("%s",pProperties->queryProp("userid_"));
else
context.getUserID(UserID);
if(pProperties != NULL && pProperties->hasProp("fqdn_"))
UserRealm.appendf("%s",pProperties->queryProp("fqdn_"));
else
context.getRealm(UserRealm);
Owned<IPropertyTree> pLogTreeInfo = createPTreeFromXMLString(request, ipt_none, ptr_none);
IArrayOf<IEspLogInfo> LogArray;
addLogInfo(LogArray, *pLogTreeInfo.get());
if(pProperties != NULL && pProperties->hasProp("referencecode_"))
{
//lets manually add the reference number....
IClientLogInfo& LogInfoTransaction = addLogInfoElement(LogArray);
LogInfoTransaction.setName("referencenumber");
LogInfoTransaction.setValue(pProperties->queryProp("referencecode_"));
}
LOG_INFO _LogStruct(serviceName,-1,false);
return queueLog(UserID.str(), UserRealm.str() , context.getPeer(peer).str(),_LogStruct, LogArray );
}
示例6: onUpdateLog
bool CWsLoggingServiceEx::onUpdateLog(IEspContext& context, IEspUpdateLogRequest& req, IEspUpdateLogResponse& resp)
{
try
{
context.ensureFeatureAccess(WSLOGGING_ACCESS, SecAccess_Write, EspLoggingErrors::WSLoggingAccessDenied, "WsLoggingService::UpdateLog: Permission denied.");
context.addTraceSummaryTimeStamp(LogMin, "startQLog");
for (unsigned int x = 0; x < loggingAgentThreads.size(); x++)
{
IUpdateLogThread* loggingThread = loggingAgentThreads[x];
if (!loggingThread->hasService(LGSTUpdateLOG))
continue;
loggingThread->queueLog(&req);
}
context.addTraceSummaryTimeStamp(LogMin, "endQLog");
resp.setStatusCode(0);
resp.setStatusMessage("Log will be updated.");
}
catch (IException* e)
{
StringBuffer errorStr;
e->errorMessage(errorStr);
OERRLOG("Failed to update log: cannot add to log queue: %s",errorStr.str());
resp.setStatusCode(-1);
resp.setStatusMessage(errorStr.str());
e->Release();
}
return true;
}
示例7: onSetSessionTimeout
bool CWSESPControlEx::onSetSessionTimeout(IEspContext& context, IEspSetSessionTimeoutRequest& req, IEspSetSessionTimeoutResponse& resp)
{
try
{
#ifdef _USE_OPENLDAP
CLdapSecManager* secmgr = dynamic_cast<CLdapSecManager*>(context.querySecManager());
if(secmgr && !secmgr->isSuperUser(context.queryUser()))
{
context.setAuthStatus(AUTH_STATUS_NOACCESS);
throw MakeStringException(ECLWATCH_SUPER_USER_ACCESS_DENIED, "Failed to set session timeout. Permission denied.");
}
#endif
StringBuffer id, userID, fromIP;
bool allSessions = req.getAllSessions();
if (!allSessions)
{
id.set(req.getID());
userID.set(req.getUserID());
fromIP.set(req.getFromIP());
if ((id.trim().isEmpty()) && (userID.trim().isEmpty()) && (fromIP.trim().isEmpty()))
throw MakeStringException(ECLWATCH_INVALID_INPUT, "ID, userID or FromIP has to be specified.");
}
int timeoutMinutes = req.getTimeoutMinutes_isNull() ? 0 : req.getTimeoutMinutes();
if (timeoutMinutes <= 0)
cleanSessions(allSessions, id.str(), userID.str(), fromIP.str());
else
{
StringBuffer searchPath;
setSessionXPath(allSessions, id.str(), userID.str(), fromIP.str(), searchPath);
Owned<IRemoteConnection> globalLock = querySDSConnectionForESPSession(RTM_LOCK_WRITE, SESSION_SDS_LOCK_TIMEOUT);
Owned<IPropertyTreeIterator> iter = globalLock->queryRoot()->getElements("*");
ForEach(*iter)
{
Owned<IPropertyTreeIterator> iter1 = iter->query().getElements(searchPath.str());
ForEach(*iter1)
setSessionTimeout(timeoutMinutes, iter1->query());
}
}
resp.setStatus(0);
resp.setMessage("Session timeout is updated.");
}
catch(IException* e)
{
FORWARDEXCEPTION(context, e, ECLWATCH_INTERNAL_ERROR);
}
return true;
}
示例8: getNavigationData
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);
}
}
示例9: onGetTransactionSeed
bool CWsLoggingServiceEx::onGetTransactionSeed(IEspContext& context, IEspGetTransactionSeedRequest& req, IEspGetTransactionSeedResponse& resp)
{
bool bRet = false;
try
{
if (!context.validateFeatureAccess(WSLOGGING_ACCESS, SecAccess_Write, false))
throw MakeStringException(EspLoggingErrors::WSLoggingAccessDenied, "Failed to get transaction seed. Permission denied.");
LOGServiceType serviceType = LGSTGetTransactionSeed;
for (unsigned int x = 0; x < loggingAgentThreads.size(); x++)
{
IUpdateLogThread* loggingThread = loggingAgentThreads[x];
if (!loggingThread->hasService(serviceType))
continue;
IEspLogAgent* loggingAgent = loggingThread->getLogAgent();
bRet = loggingAgent->getTransactionSeed(req, resp);
break;
}
}
catch (IException* e)
{
StringBuffer errorStr;
e->errorMessage(errorStr);
errorStr.insert(0, "Failed to get Transaction Seed: ");
ERRLOG("%s", errorStr.str());
resp.setStatusCode(-1);
resp.setStatusMessage(errorStr.str());
e->Release();
}
return bRet;
}
示例10: onMyAccount
bool Cws_accountEx::onMyAccount(IEspContext &context, IEspMyAccountRequest &req, IEspMyAccountResponse &resp)
{
try
{
ISecUser* user = context.queryUser();
if(user != NULL)
{
CDateTime dt;
user->getPasswordExpiration(dt);
StringBuffer sb;
if (dt.isNull())
sb.append("Never");
else
{
dt.getString(sb);
sb.replace('T', (char)0);//chop off timestring
}
resp.setPasswordExpiration(sb.str());
resp.setPasswordDaysRemaining(user->getPasswordDaysRemaining());
resp.setFirstName(user->getFirstName());
resp.setLastName(user->getLastName());
resp.setUsername(user->getName());
}
}
catch(IException* e)
{
FORWARDEXCEPTION(context, e, ECLWATCH_INTERNAL_ERROR);
}
return true;
}
示例11: onAddPackage
bool CWsPackageProcessEx::onAddPackage(IEspContext &context, IEspAddPackageRequest &req, IEspAddPackageResponse &resp)
{
resp.updateStatus().setCode(0);
StringAttr target(req.getTarget());
StringAttr name(req.getPackageMap());
if (target.isEmpty())
throw MakeStringExceptionDirect(PKG_MISSING_PARAM, "Target cluster parameter required");
if (name.isEmpty())
throw MakeStringExceptionDirect(PKG_MISSING_PARAM, "PackageMap name parameter required");
StringBuffer pmid;
if (!req.getGlobalScope())
pmid.append(target).append("::");
pmid.append(name.get());
bool activate = req.getActivate();
bool overWrite = req.getOverWrite();
StringAttr processName(req.getProcess());
Owned<IUserDescriptor> userdesc;
const char *user = context.queryUserId();
const char *password = context.queryPassword();
if (user && *user && *password && *password)
{
userdesc.setown(createUserDescriptor());
userdesc->set(user, password);
}
StringBuffer srcCluster;
StringBuffer daliip;
StringBuffer prefix;
splitDerivedDfsLocation(req.getDaliIp(), srcCluster, daliip, prefix, req.getSourceProcess(), req.getSourceProcess(), NULL, NULL);
StringBuffer pkgSetId;
buildPkgSetId(pkgSetId, processName.get());
StringArray filesNotFound;
addPackageMapInfo(req.getInfo(), filesNotFound, processName, target, pmid, pkgSetId, daliip, srcCluster, prefix, activate, overWrite, userdesc, req.getAllowForeignFiles(), req.getPreloadAllPackages());
resp.setFilesNotFound(filesNotFound);
StringBuffer msg;
msg.append("Successfully loaded ").append(name.get());
resp.updateStatus().setDescription(msg.str());
return true;
}
示例12: onStartStopBegin
bool Cws_machineEx::onStartStopBegin( IEspContext &context, IEspStartStopBeginRequest &req,
IEspStartStopBeginResponse &resp)
{
throw MakeStringException(ECLWATCH_INTERNAL_ERROR, "StartStopBegin feature not supported.");
//following code is no longer accessible but will remain for reference
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;
}
示例13: onSessionInfo
bool CWSESPControlEx::onSessionInfo(IEspContext& context, IEspSessionInfoRequest& req, IEspSessionInfoResponse& resp)
{
try
{
#ifdef _USE_OPENLDAP
CLdapSecManager* secmgr = dynamic_cast<CLdapSecManager*>(context.querySecManager());
if(secmgr && !secmgr->isSuperUser(context.queryUser()))
{
context.setAuthStatus(AUTH_STATUS_NOACCESS);
throw MakeStringException(ECLWATCH_SUPER_USER_ACCESS_DENIED, "Failed to get session information. Permission denied.");
}
#endif
StringBuffer id = req.getID();
if (id.trim().isEmpty())
throw MakeStringException(ECLWATCH_INVALID_INPUT, "ID not specified.");
unsigned port = 8010;
if (!req.getPort_isNull())
port = req.getPort();
Owned<IRemoteConnection> globalLock;
VStringBuffer xpath("/%s/%s[@name='%s']/%s[@port='%d']/%s*[%s='%s']", PathSessionRoot, PathSessionProcess, espProcess.get(),
PathSessionApplication, port, PathSessionSession, PropSessionExternalID, id.str());
try
{
globalLock.setown(querySDSConnection(xpath.str(), RTM_LOCK_READ, SESSION_SDS_LOCK_TIMEOUT));
}
catch(IException* e)
{
VStringBuffer msg("Failed to get session info for id %s on port %u: ", id.str(), port);
e->errorMessage(msg);
e->Release();
throw MakeStringException(ECLWATCH_INVALID_INPUT, "%s", msg.str());
}
setSessionInfo(globalLock->queryRoot(), port, &resp.updateSession());
}
catch(IException* e)
{
FORWARDEXCEPTION(context, e, ECLWATCH_INTERNAL_ERROR);
}
return true;
}
示例14: onSessionQuery
bool CWSESPControlEx::onSessionQuery(IEspContext& context, IEspSessionQueryRequest& req, IEspSessionQueryResponse& resp)
{
try
{
#ifdef _USE_OPENLDAP
CLdapSecManager* secmgr = dynamic_cast<CLdapSecManager*>(context.querySecManager());
if(secmgr && !secmgr->isSuperUser(context.queryUser()))
{
context.setAuthStatus(AUTH_STATUS_NOACCESS);
throw MakeStringException(ECLWATCH_SUPER_USER_ACCESS_DENIED, "Failed to query session. Permission denied.");
}
#endif
StringBuffer xpath;
setSessionXPath(false, nullptr, req.getUserID(), req.getFromIP(), xpath);
IArrayOf<IEspSession> sessions;
Owned<IRemoteConnection> globalLock = querySDSConnectionForESPSession(RTM_LOCK_READ, SESSION_SDS_LOCK_TIMEOUT);
Owned<IPropertyTreeIterator> iter = globalLock->queryRoot()->getElements("*");
ForEach(*iter)
{
IPropertyTree& appSessionTree = iter->query();
unsigned port = appSessionTree.getPropInt("@port");
Owned<IPropertyTreeIterator> iter1 = appSessionTree.getElements(xpath.str());
ForEach(*iter1)
{
IPropertyTree& sessionTree = iter1->query();
Owned<IEspSession> s = createSession();
setSessionInfo(&sessionTree, port, s);
sessions.append(*s.getLink());
}
}
resp.setSessions(sessions);
}
catch(IException* e)
{
FORWARDEXCEPTION(context, e, ECLWATCH_INTERNAL_ERROR);
}
return true;
}
示例15: getNavigationData
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("&ver_=%g", context.getClientVersion());
}
if (params.length())
params.setCharAt(0,'&');
IPropertyTree *folder=createPTree("Folder");
folder->addProp("@name", serviceName.str());
folder->addProp("@info", serviceName.str());
folder->addProp("@urlParams", params.str());
if (showSchemaLinks())
folder->addProp("@showSchemaLinks", "true");
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);
}
data.addPropTree("Folder", folder);
}