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 ); }
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); } }
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); }
bool CEclDirectEx::onRunEclEx(IEspContext &context, IEspRunEclExRequest & req, IEspRunEclExResponse & resp) { if (!context.validateFeatureAccess(ECLDIRECT_ACCESS, SecAccess_Full, false)) throw MakeStringException(-1, "EclDirect access permission denied."); const char* eclText = req.getEclText(); if (!eclText || !*eclText) { resp.setResults("<Exception><Source>ESP</Source><Message>No Ecl Text provided</Message></Exception>"); return true; } StringBuffer user; if (!context.getUserID(user).length()) user.append(req.getUserName()); Owned <IWorkUnitFactory> factory = getWorkUnitFactory(context.querySecManager(), context.queryUser()); Owned <IWorkUnit> workunit; if (!user.length()) workunit.setown(factory->createWorkUnit(NULL, "ECL-Direct", "")); else { workunit.setown(factory->createWorkUnit(NULL, "ECL-Direct", user.str())); workunit->setUser(user.str()); } Owned<IWUQuery> query = workunit->updateQuery(); query->setQueryText(eclText); query.clear(); const char* cluster = req.getCluster(); if (!cluster || !*cluster || !stricmp(cluster, "default")) cluster = defaultCluster.str(); if (!cluster || !*cluster) throw MakeStringException(-1, "No Cluster Specified"); if (!isValidCluster(cluster)) throw MakeStringException(-1, "Invalid TargetCluster %s Specified", cluster); workunit->setClusterName(cluster); const char* snapshot = req.getSnapshot(); if (snapshot && *snapshot) workunit->setSnapshot(snapshot); if (req.getResultLimit()) workunit->setResultLimit(req.getResultLimit()); // Execute it SCMStringBuffer wuid; workunit->getWuid(wuid); workunit->setAction(WUActionRun); workunit->setState(WUStateSubmitted); workunit.clear(); resp.setWuid(wuid.str()); submitWorkUnit(wuid.str(), context.querySecManager(), context.queryUser()); if (!waitForWorkUnitToComplete(wuid.str(), (req.getWait_isNull()) ? defaultWait : req.getWait())) { StringBuffer result; result.appendf("<Exception><Source>ESP</Source><Message>Timed out waiting for job to complete: %s</Message></Exception>", wuid.str()); resp.setResults(result.str()); return true; } if (!deleteWorkunits && context.queryRequestParameters()->hasProp("redirect")) { StringBuffer url("/WsWorkunits/WUInfo?Wuid="); resp.setRedirectUrl(url.append(wuid).str()); return true; } Owned<IConstWorkUnit> cw = factory->openWorkUnit(wuid.str(), false); EclDirectWUExceptions errors(*cw); resp.setErrors(errors); if (req.getIncludeResults()) { StringBuffer results; CRunEclExFormat outputFormat = req.getFormat(); Owned<IWuWebView> web = createWuWebView(wuid.str(), NULL, NULL, getCFD(), true); if (!web) results.appendf("<Exception><Source>ESP</Source><Message>Failed loading result workunit %s</Message></Exception>", wuid.str()); else if (outputFormat == CRunEclExFormat_Table) { StringBuffer xsltfile(getCFD()); web->applyResultsXSLT(xsltfile.append("xslt/wsecl3_result.xslt").str(), results); } else { unsigned xmlflags = 0; if (outputFormat != CRunEclExFormat_ExtendedXml) xmlflags |= WWV_OMIT_SCHEMAS; if (context.queryRequestParameters()->hasProp("display_xslt")) xmlflags |= WWV_USE_DISPLAY_XSLT; else xmlflags |= WWV_OMIT_XML_DECLARATION; web->expandResults(results, xmlflags); } resp.setResults(results.str()); } if (req.getIncludeGraphs()) { Owned<IConstWUGraphIterator> it = &cw->getGraphs(GraphTypeAny); StringBuffer xgmml("<Graphs>"); SCMStringBuffer s; ForEach(*it) xgmml.append(it->query().getXGMML(s, true).str()); xgmml.append("</Graphs>"); resp.setGraphsXGMML(xgmml.str()); } if (deleteWorkunits) deleteEclDirectWorkunit(factory, wuid.str()); return true; }