本文整理汇总了C++中XMLNode::NewChild方法的典型用法代码示例。如果您正苦于以下问题:C++ XMLNode::NewChild方法的具体用法?C++ XMLNode::NewChild怎么用?C++ XMLNode::NewChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLNode
的用法示例。
在下文中一共展示了XMLNode::NewChild方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: startJob
bool CREAMClient::startJob(const std::string& jobid) {
logger.msg(VERBOSE, "Creating and sending job start request");
action = "JobStart";
PayloadSOAP req(cream_ns);
XMLNode jobStartRequest = req.NewChild("types:" + action + "Request");
XMLNode xjobId = jobStartRequest.NewChild("types:jobId");
xjobId.NewChild("types:id") = jobid;
xjobId.NewChild("types:creamURL") = client->GetURL().str();
XMLNode response;
if (!process(req, response)) return false;
if (!response) {
logger.msg(VERBOSE, "Empty response");
return false;
}
if (!response["result"]["jobId"]["id"]) {
logger.msg(VERBOSE, "No job ID in response");
return false;
}
return true;
}
示例2: listTargetSystemFactories
bool UNICOREClient::listTargetSystemFactories(std::list< std::pair<URL, ServiceType> >& tsf) {
logger.msg(INFO, "Creating and sending an index service query");
PayloadSOAP req(unicore_ns);
XMLNode query = req.NewChild("rp:QueryResourceProperties");
XMLNode exp = query.NewChild("rp:QueryExpression");
exp.NewAttribute("Dialect") = "http://www.w3.org/TR/1999/REC-xpath-19991116";
exp = "//*";
PayloadSOAP *resp = NULL;
client->process("http://docs.oasis-open.org/wsrf/rpw-2"
"/QueryResourceProperties/QueryResourcePropertiesRequest",
&req, &resp);
if (resp == NULL) {
logger.msg(VERBOSE, "There was no SOAP response");
return false;
}
XMLNodeList memberServices = resp->Body().Path("QueryResourcePropertiesResponse/Entry/MemberServiceEPR");
for (XMLNodeList::iterator it = memberServices.begin(); it != memberServices.end(); it++) {
if (((std::string)(*it)["Metadata"]["InterfaceName"]).find("BESFactoryPortType") != std::string::npos) { // it.Metadata.InterfaceName should contain 'BESFactoryPortType'...
tsf.push_back(std::pair<URL, ServiceType>(URL((std::string)(*it)["Address"]), COMPUTING));
}
}
return true;
}
示例3: getJobDesc
bool CREAMClient::getJobDesc(const std::string& jobid, std::string& desc) {
logger.msg(VERBOSE, "Creating and sending a status request");
action = "JobInfo";
PayloadSOAP req(cream_ns);
XMLNode xjobId = req.NewChild("types:" + action + "Request").NewChild("types:jobId");
xjobId.NewChild("types:id") = jobid;
xjobId.NewChild("types:creamURL") = client->GetURL().str();
XMLNode response;
if (!process(req, response)) return false;
if (ISVALID(response["result"]["jobInfo"]["JDL"])) {
desc = (std::string)response["result"]["jobInfo"]["JDL"];
return true;
}
return false;
}
示例4: resume
bool CREAMClient::resume(const std::string& jobid) {
logger.msg(VERBOSE, "Creating and sending request to resume a job");
action = "JobResume";
PayloadSOAP req(cream_ns);
XMLNode xjobId = req.NewChild("types:" + action + "Request").NewChild("types:jobId");
xjobId.NewChild("types:id") = jobid;
xjobId.NewChild("types:creamURL") = client->GetURL().str();
XMLNode response;
if (!process(req, response)) return false;
if (!response) {
logger.msg(VERBOSE, "Empty response");
return false;
}
return true;
}
示例5: WriteBoost
//----------------------------------------------------------------------------
bool EngineLoop::WriteBoost()
{
XMLData data;
data.Create();
XMLNode boostNode = data.NewChild("boost");
boostNode.SetAttributeString("name", "boost");
XMLNode configNode = boostNode.NewChild("config");
XMLNode varNode_config = configNode.NewChild("var");
varNode_config.SetAttributeInt("width", (int)mBoostSize.Width);
varNode_config.SetAttributeInt("height", (int)mBoostSize.Height);
XMLNode playNode = boostNode.NewChild("play");
XMLNode varNode_play = playNode.NewChild("var");
varNode_play.SetAttributeString("projectname", mProjectName);
varNode_play.SetAttributeString("playlogicmode", GetPlayLogicModeStr());
return data.SaveFile("Data/boost.xml");
}
示例6: SaveConfig
//----------------------------------------------------------------------------
bool Project::SaveConfig(const std::string &filename)
{
// xml
XMLData data;
data.Create();
XMLNode projNode = data.NewChild("project");
// general
XMLNode generalNode = projNode.NewChild("general");
generalNode.SetAttributeString("name", GetName().c_str());
generalNode.SetAttributeString("screenorientation", _ToSOStr(mScreenOrientation));
generalNode.SetAttributeInt("width", (int)mSize.Width);
generalNode.SetAttributeInt("height", (int)mSize.Height);
std::string colorStr =
StringHelp::IntToString((int)(mBackgroundColor[0] * 255.0f)) + "," +
StringHelp::IntToString((int)(mBackgroundColor[1] * 255.0f)) + "," +
StringHelp::IntToString((int)(mBackgroundColor[2] * 255.0f)) + "," +
StringHelp::IntToString((int)(mBackgroundColor[3] * 255.0f));
generalNode.SetAttributeString("backcolor", colorStr);
std::string projColorStr =
StringHelp::IntToString((int)(mProjBackgroundColor[0] * 255.0f)) + "," +
StringHelp::IntToString((int)(mProjBackgroundColor[1] * 255.0f)) + "," +
StringHelp::IntToString((int)(mProjBackgroundColor[2] * 255.0f)) + "," +
StringHelp::IntToString((int)(mProjBackgroundColor[3] * 255.0f));
generalNode.SetAttributeString("projcolor", projColorStr);
// scene
XMLNode sceneNode = projNode.NewChild("scene");
sceneNode.SetAttributeString("filename", mSceneFilename.c_str());
// render setting
XMLNode renderNode = projNode.NewChild("render_setting");
// language
XMLNode languageNode = projNode.NewChild("language");
// publish
XMLNode publish = projNode.NewChild("publish");
// setting
XMLNode settingNode = projNode.NewChild("edit_setting");
settingNode.SetAttributeFloat("uicamerapercent", mEdit_UICameraPercent);
if (data.SaveFile(filename))
{
return true;
}
return false;
}
示例7: get_node
XMLNode get_node(XMLNode& parent,const char* name) {
XMLNode n = parent[name];
if(!n) n=parent.NewChild(name);
return n;
}
示例8: createDelegation
bool CREAMClient::createDelegation(const std::string& delegation_id,
const std::string& proxy) {
logger.msg(VERBOSE, "Creating delegation");
action = "getProxyReq";
PayloadSOAP req(cream_ns);
req.NewChild("deleg:" + action).NewChild("delegationID") = delegation_id;
XMLNode response;
if (!process(req, response, "http://www.gridsite.org/namespaces/delegation-2/")) return false;
std::string proxyRequestStr = (std::string)response["getProxyReqReturn"];
if (proxyRequestStr.empty()) {
logger.msg(VERBOSE, "Malformed response: missing getProxyReqReturn");
return false;
}
//Sign the proxy certificate
Credential signer(proxy, "", cadir, cafile);
std::string signedCert;
// TODO: Hardcoded time shift - VERY BAD approach
Time start_time = Time() - Period(300);
Time end_time = signer.GetEndTime();
if(end_time < start_time) {
logger.msg(VERBOSE, "Delegatable credentials expired: %s",end_time.str());
return false;
}
// CREAM is picky about end time of delegated credentials, so
// make sure it does not exceed end time of signer
Credential proxy_cred(start_time,end_time-start_time);
proxy_cred.InquireRequest(proxyRequestStr);
proxy_cred.SetProxyPolicy("gsi2", "", "", -1);
if (!(signer.SignRequest(&proxy_cred, signedCert))) {
logger.msg(VERBOSE, "Failed signing certificate request");
return false;
}
std::string signedOutputCert, signedOutputCertChain;
signer.OutputCertificate(signedOutputCert);
signer.OutputCertificateChain(signedOutputCertChain);
signedCert.append(signedOutputCert).append(signedOutputCertChain);
action = "putProxy";
req = PayloadSOAP(cream_ns);
XMLNode putProxyRequest = req.NewChild("deleg:" + action);
putProxyRequest.NewChild("delegationID") = delegation_id;
putProxyRequest.NewChild("proxy") = signedCert;
response = XMLNode();
if (!process(req, response, "http://www.gridsite.org/namespaces/delegation-2/"))
return false;
if (!response) {
logger.msg(VERBOSE, "Failed putting signed delegation certificate to service");
return false;
}
return true;
}
示例9: stat
bool CREAMClient::stat(const std::string& jobid, Job& job) {
logger.msg(VERBOSE, "Creating and sending a status request");
action = "JobInfo";
PayloadSOAP req(cream_ns);
XMLNode xjobId = req.NewChild("types:" + action + "Request").NewChild("types:jobId");
xjobId.NewChild("types:id") = jobid;
xjobId.NewChild("types:creamURL") = client->GetURL().str();
XMLNode response;
if (!process(req, response)) return false;
XMLNode jobInfoNode;
jobInfoNode = response["result"]["jobInfo"];
XMLNode lastStatusNode = jobInfoNode.Path("status").back();
if (lastStatusNode["name"]) {
job.State = JobStateCREAM((std::string)lastStatusNode["name"]);
}
if (lastStatusNode["failureReason"]) {
job.Error.push_back((std::string)lastStatusNode["failureReason"]);
}
if (!job.State) {
logger.msg(VERBOSE, "Unable to retrieve job status.");
return false;
}
if (ISVALID(jobInfoNode["jobId"]["id"])) {
job.IDFromEndpoint = (std::string)jobInfoNode["jobId"]["id"];
}
if (ISVALID(jobInfoNode["type"]))
job.Type = (std::string)jobInfoNode["type"];
if (ISVALID(jobInfoNode["JDL"])) {
job.JobDescription = "egee:jdl";
job.JobDescriptionDocument = (std::string)jobInfoNode["JDL"];
std::list<JobDescription> jds;
if (JobDescription::Parse(job.JobDescriptionDocument, jds) && !jds.empty()) {
if (!jds.front().Application.Input.empty())
job.StdIn = jds.front().Application.Input;
if (!jds.front().Application.Output.empty())
job.StdOut = jds.front().Application.Output;
if (!jds.front().Application.Error.empty())
job.StdErr = jds.front().Application.Error;
if (!jds.front().Resources.QueueName.empty()) {
job.Queue = jds.front().Resources.QueueName;
}
}
}
if (ISVALID(lastStatusNode["exitCode"]))
job.ExitCode = stringtoi((std::string)lastStatusNode["exitCode"]);
if (ISVALID(jobInfoNode["delegationProxyInfo"])) {
/* Format of delegationProxyInfo node.
[ isRFC="<true|false>";
valid from="<mon>/<date>/<yy> <hour>:<min> <AM|PM> (<timezone>)";
valid to="<mon>/<date>/<yy> <hour>:<min> <AM|PM> (<timezone>)";
holder DN="<DN>";
holder AC issuer="<DN>";
VO="<VO-name>";
AC issuer="<DN>";
VOMS attributes=<VOMS-Attributes>
]
*/
std::string delegationProxy = (std::string)jobInfoNode["delegationProxyInfo"];
std::size_t lBracketPos = delegationProxy.find('['), rBracketPos = delegationProxy.rfind(']');
if (lBracketPos != std::string::npos && rBracketPos != std::string::npos) {
delegationProxy = trim(delegationProxy.substr(lBracketPos, rBracketPos - lBracketPos));
}
std::list<std::string> tDelegInfo;
tokenize(delegationProxy, tDelegInfo, ";");
for (std::list<std::string>::iterator it = tDelegInfo.begin();
it != tDelegInfo.end(); ++it) {
std::list<std::string> keyValuePair;
tokenize(*it, keyValuePair, "=", "\"", "\"");
if (keyValuePair.size() != 2) continue;
if (lower(trim(keyValuePair.front())) == "holder dn") job.Owner = trim(keyValuePair.back(), " \"");
if (lower(trim(keyValuePair.front())) == "valid to") stringtoTime(trim(keyValuePair.back(), " \""), job.ProxyExpirationTime);
}
}
if (ISVALID(jobInfoNode["localUser"]))
job.LocalOwner = (std::string)jobInfoNode["localUser"];
if (ISVALID(jobInfoNode["lastCommand"])) {
int job_register_id_first = -1;
int job_register_id_last = -1;
int job_start_id_first = -1;
int job_start_id_last = -1;
int local_id = 0;
while (true) {
if (!jobInfoNode["lastCommand"][local_id])
break;
if ((std::string)jobInfoNode["lastCommand"][local_id]["name"] == "JOB_REGISTER") {
if (job_register_id_first == -1 && job_register_id_last == -1) {
job_register_id_first = local_id;
//.........这里部分代码省略.........
示例10: submit
bool UNICOREClient::submit(const JobDescription& jobdesc, XMLNode& id,
bool delegate) {
std::string faultstring;
logger.msg(INFO, "Creating and sending request");
// Create job request
/*
bes-factory:CreateActivity
bes-factory:ActivityDocument
jsdl:JobDefinition
*/
PayloadSOAP req(unicore_ns);
XMLNode op = req.NewChild("bes-factory:CreateActivity");
XMLNode act_doc = op.NewChild("bes-factory:ActivityDocument");
set_bes_factory_action(req, "CreateActivity");
WSAHeader(req).To(rurl.str());
//XMLNode proxyHeader = req.Header().NewChild("u6:Proxy");
if (true) {
std::string pem_str;
std::ifstream proxy_file(proxyPath.c_str()/*, ifstream::in*/);
std::getline<char>(proxy_file, pem_str, 0);
req.Header().NewChild("u6:Proxy") = pem_str;
//std::cout << "\n----\n" << "pem_str = " << pem_str << "\n----\n"; //debug code, remove!
}
//std::string jsdl_str;
//std::getline<char>(jsdl_file, jsdl_str, 0);
std::string jsdl_str;
if (!jobdesc.UnParse(jsdl_str, "nordugrid:jsdl")) {
logger.msg(INFO, "Unable to submit job. Job description is not valid in the %s format", "nordugrid:jsdl");
return false;
}
XMLNode jsdl_doc = act_doc.NewChild(XMLNode(jsdl_str));
//std::cout << "\n----\n" << jsdl_str << "\n----\n"; //Debug line to verify the activity document
jsdl_doc.Namespaces(unicore_ns); // Unify namespaces
PayloadSOAP *resp = NULL;
XMLNode ds =
act_doc["jsdl:JobDefinition"]["jsdl:JobDescription"]["jsdl:DataStaging"];
for (; (bool)ds; ds = ds[1]) {
// FilesystemName - ignore
// CreationFlag - ignore
// DeleteOnTermination - ignore
XMLNode source = ds["jsdl:Source"];
XMLNode target = ds["jsdl:Target"];
if ((bool)source) {
std::string s_name = ds["jsdl:FileName"];
if (!s_name.empty()) {
XMLNode x_url = source["jsdl:URI"];
std::string s_url = x_url;
if (s_url.empty())
s_url = "./" + s_name;
else {
URL u_url(s_url);
if (!u_url) {
if (s_url[0] != '/')
s_url = "./" + s_url;
}
else {
if (u_url.Protocol() == "file") {
s_url = u_url.Path();
if (s_url[0] != '/')
s_url = "./" + s_url;
}
else
s_url.resize(0);
}
}
if (!s_url.empty())
x_url.Destroy();
}
}
}
act_doc.GetXML(jsdl_str);
logger.msg(DEBUG, "Job description to be sent: %s", jsdl_str);
// Try to figure out which credentials are used
// TODO: Method used is unstable beacuse it assumes some predefined
// structure of configuration file. Maybe there should be some
// special methods of ClientTCP class introduced.
std::string deleg_cert;
std::string deleg_key;
if (delegate) {
client->Load(); // Make sure chain is ready
XMLNode tls_cfg = find_xml_node((client->GetConfig())["Chain"],
"Component", "name", "tls.client");
if (tls_cfg) {
deleg_cert = (std::string)(tls_cfg["ProxyPath"]);
if (deleg_cert.empty()) {
deleg_cert = (std::string)(tls_cfg["CertificatePath"]);
deleg_key = (std::string)(tls_cfg["KeyPath"]);
}
else
deleg_key = deleg_cert;
}
if (deleg_cert.empty() || deleg_key.empty()) {
logger.msg(ERROR, "Failed to find delegation credentials in "
"client configuration");
return false;
//.........这里部分代码省略.........
示例11: clean
bool UNICOREClient::clean(const std::string& jobid) {
std::string result, faultstring;
logger.msg(INFO, "Creating and sending request to terminate a job");
PayloadSOAP req(unicore_ns);
XMLNode op = req.NewChild("a-rex:ChangeActivityStatus");
XMLNode jobref = op.NewChild(XMLNode(jobid));
XMLNode jobstate = op.NewChild("a-rex:NewStatus");
jobstate.NewAttribute("bes-factory:state") = "Finished";
jobstate.NewChild("a-rex:state") = "Deleted";
// Send clean request
PayloadSOAP *resp = NULL;
if (client) {
MCC_Status status = client->process("", &req, &resp);
if (resp == NULL) {
logger.msg(VERBOSE, "There was no SOAP response");
return false;
}
}
else if (client_entry) {
Message reqmsg;
Message repmsg;
MessageAttributes attributes_req;
MessageAttributes attributes_rep;
MessageContext context;
reqmsg.Payload(&req);
reqmsg.Attributes(&attributes_req);
reqmsg.Context(&context);
repmsg.Attributes(&attributes_rep);
repmsg.Context(&context);
MCC_Status status = client_entry->process(reqmsg, repmsg);
if (!status) {
logger.msg(ERROR, "A job cleaning request failed");
return false;
}
logger.msg(INFO, "A job cleaning request succeed");
if (repmsg.Payload() == NULL) {
logger.msg(VERBOSE, "There was no response to a job cleaning request");
return false;
}
try {
resp = dynamic_cast<PayloadSOAP*>(repmsg.Payload());
} catch (std::exception&) {}
if (resp == NULL) {
logger.msg(ERROR, "The response of a job cleaning request was not "
"a SOAP message");
delete repmsg.Payload();
return false;
}
}
else {
logger.msg(ERROR, "There is no connection chain configured");
return false;
}
if (!((*resp)["ChangeActivityStatusResponse"])) {
delete resp;
XMLNode fs;
(*resp)["Fault"]["faultstring"].New(fs);
faultstring = (std::string)fs;
if (faultstring != "") {
logger.msg(ERROR, faultstring);
return false;
}
if (result != "true") {
logger.msg(ERROR, "Job termination failed");
return false;
}
}
delete resp;
return true;
}
示例12: Export
bool SOAPSecAttr::Export(SecAttrFormat format,XMLNode &val) const {
if(format == UNDEFINED) {
} else if(format == ARCAuth) {
NS ns;
ns["ra"]="http://www.nordugrid.org/schemas/request-arc";
val.Namespaces(ns); val.Name("ra:Request");
XMLNode item = val.NewChild("ra:RequestItem");
if(!object_.empty()) {
XMLNode object = item.NewChild("ra:Resource");
object=object_;
object.NewAttribute("Type")="string";
object.NewAttribute("AttributeId")="http://www.nordugrid.org/schemas/policy-arc/types/soap/endpoint";
};
if(!action_.empty()) {
XMLNode action = item.NewChild("ra:Action");
action=action_;
action.NewAttribute("Type")="string";
action.NewAttribute("AttributeId")="http://www.nordugrid.org/schemas/policy-arc/types/soap/operation";
};
if(!context_.empty()) {
XMLNode context = item.NewChild("ra:Context").NewChild("ra:ContextAttribute");
context=context_;
context.NewAttribute("Type")="string";
context.NewAttribute("AttributeId")="http://www.nordugrid.org/schemas/policy-arc/types/soap/namespace";
};
return true;
} else if(format == XACML) {
NS ns;
ns["ra"]="urn:oasis:names:tc:xacml:2.0:context:schema:os";
val.Namespaces(ns); val.Name("ra:Request");
if(!object_.empty()) {
XMLNode object = val.NewChild("ra:Resource");
XMLNode attr = object.NewChild("ra:Attribute");
attr.NewChild("ra:AttributeValue") = object_;
attr.NewAttribute("DataType")="xs:string";
attr.NewAttribute("AttributeId")="http://www.nordugrid.org/schemas/policy-arc/types/soap/endpoint";
};
if(!action_.empty()) {
XMLNode action = val.NewChild("ra:Action");
XMLNode attr = action.NewChild("ra:Attribute");
attr.NewChild("ra:AttributeValue") = action_;
attr.NewAttribute("DataType")="xs:string";
attr.NewAttribute("AttributeId")="http://www.nordugrid.org/schemas/policy-arc/types/soap/operation";
};
if(!context_.empty()) {
XMLNode context = val.NewChild("ra:Environment");
XMLNode attr = context.NewChild("ra:Attribute");
attr.NewChild("ra:AttributeValue") = context_;
attr.NewAttribute("DataType")="xs:string";
attr.NewAttribute("AttributeId")="http://www.nordugrid.org/schemas/policy-arc/types/soap/namespace";
};
return true;
} else {
};
return false;
}