bool finalizeOptions(IProperties *globals) { if (optInput.length()) { const char *in = optInput.get(); while (*in && isspace(*in)) in++; if (*in!='<') { StringBuffer content; content.loadFile(in); optInput.set(content.str()); } } if (optESDLDefID.isEmpty()) throw MakeStringException( 0, "ESDL definition ID must be provided!" ); if (optESDLService.isEmpty()) throw MakeStringException( 0, "ESDL service definition name must be provided!" ); if(optTargetESPProcName.isEmpty()) throw MakeStringException( 0, "Name of Target ESP process must be provided!" ); if (optPortOrName.isEmpty()) throw MakeStringException( 0, "Either the target ESP service port of name must be provided!" ); else { const char * portorname = optPortOrName.get(); isdigit(*portorname) ? optTargetPort.set(portorname) : optService.set(portorname); } return EsdlPublishCmdCommon::finalizeOptions(globals); }
CMailInfo(char const * _to, char const * _subject, char const * _mailServer, unsigned _port, char const * _sender, StringArray *_warnings) : subject(_subject), mailServer(_mailServer), port(_port), sender(_sender), lastAction("process initialization"), inlen(0) { warnings = _warnings; CSMTPValidator validator; if(strlen(senderHeader) + sender.length() > 998) throw MakeStringException(0, "email sender address too long: %" I64F "u characters", static_cast<__uint64>(sender.length())); validator.validateAddress(sender.get(), "email sender address"); getRecipients(validator, _to); if(strlen(toHeader) + to.length() > 998) throw MakeStringException(0, "Email recipient address list too long: %u characters", to.length()); if(strlen(subjectHeader) + subject.length() > 998) throw MakeStringException(0, "Email subject too long: %" I64F "u characters", static_cast<__uint64>(subject.length())); validator.validateValue(subject.get(), "email subject"); }
void CLibXmlValidator::validate() { if (!xmlFile.length() && !xml.length()) throw MakeStringException(XMLERR_MissingSource, "Source XML not provided"); if (!xsdFile.length() && !xsd.length()) throw MakeStringException(XMLERR_MissingSource, "XML Schema not provided"); xmlParserInputBufferPtr input; if (xmlFile.length()) input = xmlParserInputBufferCreateFilename(xmlFile.get(), XML_CHAR_ENCODING_NONE); else input = xmlParserInputBufferCreateMem(xml.str(), xml.length()+1, XML_CHAR_ENCODING_NONE); if (!input) throw MakeStringException(XMLERR_InvalidXml, "Failed to create XML input stream"); xmlSchemaParserCtxtPtr xsdParser; if (xsdFile.length()) xsdParser = xmlSchemaNewParserCtxt(xsdFile.get()); else xsdParser = xmlSchemaNewMemParserCtxt(xsd.str(), xsd.length()); if (!xsdParser) throw MakeStringException(XMLERR_InvalidXsd, "Failed to load XML Schema"); xmlSchemaSetParserErrors(xsdParser, libxmlXsdErrorMsgHandler, libxmlXsdErrorMsgHandler, this); xmlSchemaPtr schema = xmlSchemaParse(xsdParser); xmlSchemaFreeParserCtxt(xsdParser); if (!schema) throw MakeStringException(XMLERR_InvalidXsd, "XSD schema parsing failed"); xmlSchemaValidCtxtPtr validator = xmlSchemaNewValidCtxt(schema); xmlSchemaSetValidErrors(validator, libxmlXsdErrorMsgHandler, libxmlXsdErrorMsgHandler, this); int ret = xmlSchemaValidateStream(validator, input, XML_CHAR_ENCODING_NONE, emptySAXHandler, (void *)this); if (ret != 0) { ensureExceptions()->append(*MakeStringException(XMLERR_XsdValidationFailed, "XML validation failed")); throw exceptions.getClear(); } xmlSchemaFreeValidCtxt(validator); }
bool finalizeOptions(IProperties *globals) { if (optInput.length()) { const char *in = optInput.get(); while (*in && isspace(*in)) in++; if (*in!='<') { StringBuffer content; content.loadFile(in); optInput.set(content.str()); } } if (optESDLDefID.isEmpty()) throw MakeStringException( 0, "ESDL definition ID must be provided!" ); if (optESDLService.isEmpty()) throw MakeStringException( 0, "ESDL service definition name must be provided!" ); if(optTargetESPProcName.isEmpty()) throw MakeStringException( 0, "Name of Target ESP process must be provided!" ); if (optPortOrName.isEmpty()) throw MakeStringException( 0, "Either the target ESP service port of name must be provided!" ); else { const char * portorname = optPortOrName.get(); isdigit(*portorname) ? optTargetPort.set(portorname) : optService.set(portorname); } if (optWSProcAddress.isEmpty()) throw MakeStringException( 0, "Server address of ESDL process server must be provided" ); if (optWSProcPort.isEmpty()) throw MakeStringException( 0, "Port on which ESDL process is listening must be provided" ); return true; }
bool send(INode *node,unsigned timeout) { unsigned retries = 3; loop { try { CMessageBuffer mb; serialize(mb); if (queryWorldCommunicator().sendRecv(mb,node,MPTAG_SASHA_REQUEST,timeout?timeout:12*60*60*1000)) { // could take a long time! clearIds(); clearResults(); if (action==SCA_WORKUNIT_SERVICES_GET) { mb.swapWith(wusbuf); } else { unsigned n=0; unsigned i; if (mb.length()-mb.getPos()>=sizeof(unsigned)) { mb.read(n); for (i=0;i<n;i++) { StringAttr s; mb.read(s); addId(s.get()); } if (mb.length()-mb.getPos()>=sizeof(unsigned)+sizeof(bool)) { mb.read(resultoverflow); mb.read(n); for (i=0;i<n;i++) { StringAttr res; mb.read(res); size32_t reslen = res.length(); results.append(*new StringAttrItem(res,reslen)); resultsize += reslen; } if (mb.length()-mb.getPos()>=sizeof(unsigned)) { mb.read(numdts); free(dts); dts = NULL; if (numdts) { dts = (CDateTime *)calloc(numdts,sizeof(CDateTime)); for (i=0;i<numdts;i++) dts[i].deserialize(mb); } } } } } return true; } else break; } catch (IException *e) { if ((--retries==0)||(action==SCA_STOP)) throw; EXCLOG(e,"CSashaCommand send"); ::Release(e); } try { // shouldn't really be necessary but make sure socket really closed queryWorldCommunicator().disconnect(node); } catch (IException *e) { EXCLOG(e,"CSashaCommand disconnect"); ::Release(e); } }; return false; }
CThorNodeGroup(const char* _groupName, unsigned _nodeCount, bool _replicateOutputs) : groupName(_groupName), nodeCount(_nodeCount), replicateOutputs(_replicateOutputs) { keyhash = hashnc((const byte *)groupName.get(),groupName.length(),0); timeCached = msTick(); }
int doSendQuery(const char * ip, unsigned port, const char * base) { Owned<ISocket> socket; Owned<ISecureSocketContext> secureContext; __int64 starttime, endtime; StringBuffer ipstr; try { if (strcmp(ip, ".")==0) ip = GetCachedHostName(); else { const char *dash = strchr(ip, '-'); if (dash && isdigit(dash[1]) && dash>ip && isdigit(dash[-1])) { if (persistConnections) UNIMPLEMENTED; const char *startrange = dash-1; while (isdigit(startrange[-1])) startrange--; char *endptr; unsigned firstnum = atoi(startrange); unsigned lastnum = strtol(dash+1, &endptr, 10); if (lastnum > firstnum) { static unsigned counter; static CriticalSection counterCrit; CriticalBlock b(counterCrit); ipstr.append(startrange - ip, ip).append((counter++ % (lastnum+1-firstnum)) + firstnum).append(endptr); ip = ipstr.str(); printf("Sending to %s\n", ip); } } } starttime= get_cycles_now(); if (persistConnections) { if (!persistSocket) { SocketEndpoint ep(ip,port); persistSocket.setown(ISocket::connect_timeout(ep, 1000)); if (useSSL) { #ifdef _USE_OPENSSL if (!persistSecureContext) persistSecureContext.setown(createSecureSocketContext(ClientSocket)); persistSSock.setown(persistSecureContext->createSecureSocket(persistSocket.getClear())); persistSSock->secure_connect(); persistSocket.setown(persistSSock.getClear()); #else throw MakeStringException(-1, "OpenSSL disabled in build"); #endif } } socket = persistSocket; } else { SocketEndpoint ep(ip,port); socket.setown(ISocket::connect_timeout(ep, 100000)); if (useSSL) { #ifdef _USE_OPENSSL secureContext.setown(createSecureSocketContext(ClientSocket)); Owned<ISecureSocket> ssock = secureContext->createSecureSocket(socket.getClear()); ssock->secure_connect(); socket.setown(ssock.getClear()); #else throw MakeStringException(1, "OpenSSL disabled in build"); #endif } } } catch(IException * e) { pexception("failed to connect to server", e); return 1; } StringBuffer fullQuery; bool useHTTP = forceHTTP || strstr(base, "<soap:Envelope") != NULL; if (useHTTP) { StringBuffer newQuery; Owned<IPTree> p = createPTreeFromXMLString(base, ipt_none, ptr_none); const char *queryName = p->queryName(); if ((stricmp(queryName, "envelope") != 0) && (stricmp(queryName, "envelope") != 0)) { if (queryNameOverride.length()) queryName = queryNameOverride; newQuery.appendf("<Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><Body><%sRequest>", queryName); Owned<IPTreeIterator> elements = p->getElements("./*"); ForEach(*elements) { IPTree &elem = elements->query(); toXML(&elem, newQuery, 0, XML_SingleQuoteAttributeValues); } newQuery.appendf("</%sRequest></Body></Envelope>", queryName); base = newQuery.str(); } // note - don't support queryname override unless original query is xml fullQuery.appendf("POST /doc HTTP/1.0\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: %d\r\n\r\n", (int) strlen(base)).append(base); } else { if (sendToSocket)
int xsdNsLength() { return m_xsdNamespace.length(); }
void appendVariableParmInfo(IArrayOf<IPropertyTree> &parts, IResultSetFactory *resultSetFactory, IConstWUResult &var, unsigned hashWebserviceSeq=0) { Owned<IResultSetMetaData> meta = resultSetFactory->createResultSetMeta(&var); StringAttr noinput; if (var.getResultFieldOpt("noinput", StringAttrAdaptor(noinput)).length() && strToBool(noinput.length(), noinput.get())) //developer specified not to show field on form return; SCMStringBuffer varname; var.getResultName(varname); int seq = var.getResultSequence(); WUResultFormat fmt = var.getResultFormat(); SCMStringBuffer eclschema; var.getResultEclSchema(eclschema); StringBuffer width, height, fieldSeq, isPassword, select; var.getResultFieldOpt("fieldwidth", StringBufferAdaptor(width)); var.getResultFieldOpt("fieldheight", StringBufferAdaptor(height)); var.getResultFieldOpt("password", StringBufferAdaptor(isPassword)); var.getResultFieldOpt("select", StringBufferAdaptor(select)); if (hashWebserviceSeq) fieldSeq.append(hashWebserviceSeq); else var.getResultFieldOpt("sequence", StringBufferAdaptor(fieldSeq)); SCMStringBuffer s; Owned<IPropertyTree> part = createPTree("part"); if (!var.isResultScalar()) { meta->getXmlSchema(s, false); part->setProp("@name", varname.str()); part->setProp("@type", "tns:XmlDataset"); if (fieldSeq.length()) part->setProp("@sequence", fieldSeq); } else { meta->getColumnEclType(s, 0); DisplayType dt = meta->getColumnDisplayType(0); StringAttr ptype; switch (dt) { case TypeBoolean: ptype.set("xsd:boolean"); break; case TypeInteger: ptype.set("xsd:integer"); break; case TypeUnsignedInteger: ptype.set("xsd:integer"); break; case TypeReal: ptype.set("xsd:real"); break; case TypeSet: ptype.set("tns:EspStringArray"); break; case TypeDataset: case TypeData: ptype.set("tns:XmlDataSet"); break; case TypeUnicode: case TypeString: ptype.set("xsd:string"); break; case TypeUnknown: case TypeBeginIfBlock: case TypeEndIfBlock: case TypeBeginRecord: default: ptype.set("xsd:string"); break; } part->setProp("@name", varname.str()); part->setProp("@type", ptype.str()); if (width.length()) part->setProp("@width", width); if (height.length()) part->setProp("@height", height); if (fieldSeq.length()) part->setProp("@sequence", fieldSeq); if (isPassword.length()) part->setProp("@password", isPassword); if (select.length()) { StringArray optionList; optionList.appendList(select, ","); IPropertyTree *selectTree = ensurePTree(part, "select"); ForEachItemIn(i, optionList) { const char *value = optionList.item(i); bool selected = '*'==*value; if (selected) value++; StringAttr name; const char *eq = strchr(value, '='); if (!eq) name.set(value); else { name.set(value, eq-value); value = eq + 1; } Owned<IPropertyTree> optionTree = createPTree(); optionTree->setProp("@name", name); optionTree->setProp("@value", value); if (selected) optionTree->setPropBool("@selected", true); selectTree->addPropTree("option", optionTree.getClear()); } } }