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 ); }
StringBuffer& CLogThread::serializeRequest(IEspContext& context,IInterface& logInfo, StringBuffer& returnStr) { IRpcSerializable* rpcreq = dynamic_cast<IRpcSerializable*>(&logInfo); if(rpcreq==NULL) throw MakeStringException(500,"Issue serializing log information"); // We want to serialize anything here for logging purpose: e.g., internal user fields: CompanyId // rpcreq->serialize(&context,returnStr, "LogData"); // rpcreq->serialize(NULL,returnStr, "LogData"); //BUG#26047 //logInfo function parameter is instance of the incoming request object of the service. //instance objects of context and request are dependent upon the protocol binding. //Request parameters are relevent for HTTP protocol but are not relevent for protocolX. //Since request parameters pointer is not initilized in processing protocolX request it remains NULL //and causing this crash. IProperties* params = context.queryRequestParameters(); if(params!=NULL) { bool notInternal = !params->hasProp("internal"); if (notInternal) params->setProp("internal","1"); rpcreq->serialize(&context,returnStr, "LogData"); if (notInternal) params->removeProp("internal"); }else{ rpcreq->serialize(NULL,returnStr, "LogData"); } return returnStr; }
bool CXmlScope::_getValue(const char* x, StringBuffer &ret) { if (locals && locals->hasProp(x)) { locals->getProp(x, ret); return true; } return root->getProp(x,ret); };
/* return false if the name is already defined. */ bool CXmlScope::declareValue(const char *name) { if (locals && locals->hasProp(name)) return false; if (!locals) locals = createProperties(true); locals->setProp(name, ""); return true; };
int CFileSpraySoapBindingEx::onGetInstantQuery(IEspContext &context, CHttpRequest* request, CHttpResponse* response, const char *service, const char *method) { bool permission = true; bool bDownloadFile = false; bool bProcess; StringBuffer sourceLogicalFile; StringBuffer methodbuf; StringBuffer submethod; StringBuffer xsltFileName(getCFD()); xsltFileName.append("smc_xslt/"); if (stricmp(method, "SprayFixedInput")==0) { if (!context.validateFeatureAccess(FILE_SPRAY_URL, SecAccess_Write, false)) permission = false; bProcess = true; xsltFileName.append("fs_sprayForm.xslt"); methodbuf.append("SprayFixed"); } else if(stricmp(method, "SprayVariableInput")==0) { if (!context.validateFeatureAccess(FILE_SPRAY_URL, SecAccess_Write, false)) permission = false; bProcess = true; xsltFileName.append("fs_sprayForm.xslt"); methodbuf.append("SprayVariable"); request->getParameter("submethod", submethod); } else if (stricmp(method, "DesprayInput")==0) { if (!context.validateFeatureAccess(FILE_DESPRAY_URL, SecAccess_Write, false)) permission = false; request->getParameter("sourceLogicalName", sourceLogicalFile); xsltFileName.append("fs_desprayCopyForm.xslt"); methodbuf.append("Despray"); bProcess = true; } else if (stricmp(method, "CopyInput") == 0) { if (!context.validateFeatureAccess(FILE_SPRAY_URL, SecAccess_Write, false)) permission = false; request->getParameter("sourceLogicalName", sourceLogicalFile); xsltFileName.append("fs_desprayCopyForm.xslt"); methodbuf.append("Copy"); bProcess = true; } else if (stricmp(method, "RenameInput") == 0) { if (!context.validateFeatureAccess(FILE_SPRAY_URL, SecAccess_Write, false)) permission = false; request->getParameter("sourceLogicalName", sourceLogicalFile); xsltFileName.append("fs_renameForm.xslt"); methodbuf.append("Rename"); bProcess = true; } else if (stricmp(method, "DownloadFile") == 0) { if (!context.validateFeatureAccess(FILE_SPRAY_URL, SecAccess_Full, false)) permission = false; downloadFile(context, request, response); bDownloadFile = true; bProcess = true; } else bProcess = false; if (bProcess) { if (bDownloadFile) return 0; StringBuffer xml; Owned<IProperties> params(createProperties()); if (!permission) { params->setProp("@method", methodbuf.str()); xml.append("<Environment><ErrorMessage>Permission denied.</ErrorMessage></Environment>"); } else { if(submethod.length() > 0) params->setProp("@submethod", submethod.str()); params->setProp("@method", methodbuf.str()); if (*sourceLogicalFile.str()) { params->setProp("@sourceLogicalName", sourceLogicalFile.str()); Owned<IUserDescriptor> userdesc; StringBuffer username; context.getUserID(username); if(username.length() > 0) { const char* passwd = context.queryPassword(); userdesc.setown(createUserDescriptor()); userdesc->set(username.str(), passwd); try { if (stricmp(method, "CopyInput") == 0) { Owned<IDistributedFile> df = queryDistributedFileDirectory().lookup(sourceLogicalFile.str(), userdesc.get()); if(!df) { throw MakeStringException(ECLWATCH_FILE_NOT_EXIST,"Could not find file %s.",sourceLogicalFile.str()); } const char *kind = df->queryAttributes().queryProp("@kind"); if (kind && strcmp(kind,"key")==0) { params->setProp("@compressflag", 0); } else if(df->isCompressed()) { params->setProp("@compressflag", 2); } else { params->setProp("@compressflag", 1); } } } catch (IException *E) { Owned<IXslProcessor> xslp = getXslProcessor(); if (!xslp) throw E; Owned<IMultiException> me = MakeMultiException(); me->append(*E); response->handleExceptions(xslp, me, "FileSpray", method, StringBuffer(getCFD()).append("./smc_xslt/exceptions.xslt").str()); return 0; } } } else { params->setProp("@compressflag", 1); } StringBuffer wuid; request->getParameter("wuid", wuid); Owned<IPropertyTree> pTree = createPTreeForXslt(method, wuid.str()); toXML(pTree, xml, false); } IProperties* requestparams = request->queryParameters(); if(requestparams && requestparams->hasProp("rawxml_")) { response->setContent(xml.str()); response->setContentType(HTTP_TYPE_APPLICATION_XML); } else{ StringBuffer htmlbuf; xsltTransform(xml.str(), xsltFileName.str(), params, htmlbuf); response->setContent(htmlbuf.str()); response->setContentType(HTTP_TYPE_TEXT_HTML_UTF8); } response->send(); return 0; } else return CFileSpraySoapBinding::onGetInstantQuery(context, request, response, service, method); }