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; }
bool DelegationMultiSecAttr::Export(SecAttrFormat format,XMLNode &val) const { if(attrs_.size() == 0) return true; if(attrs_.size() == 1) return (*attrs_.begin())->Export(format,val); if(!MultiSecAttr::Export(format,val)) return false; val.Name("Policies"); return true; }
XMLNode * XMLNode::AddChild(const string &name) { XMLNode *child = new XMLNode(); child->Name() = name; children.push_back(child); return child; }
bool CheckComputingService(XMLNode result) { if(result.Namespace() != GLUE2_NAMESPACE) { logger.msg(ERROR,"Query returned unexpected element: %s:%s",result.Namespace(),result.Name()); return false; }; if(result.Name() != "ComputingService") { logger.msg(ERROR,"Query returned unexpected element: %s:%s",result.Namespace(),result.Name()); return false; }; std::string errstr; std::string glue2_schema = ArcLocation::GetDataDir()+G_DIR_SEPARATOR_S+"schema"+G_DIR_SEPARATOR_S+"GLUE2.xsd"; if(!result.Validate(glue2_schema,errstr)) { logger.msg(ERROR,"Element validation according to GLUE2 schema failed: %s",errstr); return false; }; return true; }
//---------------------------------------------------------------------- StatementData OutputChannelNodeProcessor::ProcessAsRoot( XMLParser& parser, XMLNode* node ) { std::string statement; m_shaderGenerator->EnableOuputChannel( m_lightingModelComp ); XMLNode* child = node->FirstChildElement(); if( child != nullptr ) { for( ; child != nullptr; child = child->NextSiblingElement() ) { std::string name = child->Name(); if( name.compare( "Input" ) == 0 ) { StatementData statementData; statementData = ProcessInputNode( parser, child ); if( statementData.outputType == m_outputType || ( m_outputType == VT_VECTOR_4 && statementData.outputType == VT_TEXTURE_SAMPLE_2D ) ) { statement = m_outputVariable + " = " + statementData.statement + ";"; } else { m_shaderGenerator->AddLogMessage( "Incorrect data type: \'%s\' provided for output channel %s", color::RED, GetVariableTypeAsString( statementData.outputType ).c_str(), m_name.c_str() ); m_shaderGenerator->EnableCompilerErrorFlag(); } } else { StatementNodeProcessor* processor = m_shaderGenerator->GetStatementNodeProcessor( name ); if( processor != nullptr ) { statement = m_outputVariable + " = " + processor->ProcessAsChild( parser, child ).statement + ";"; } else { //Invalid node processor m_shaderGenerator->AddLogMessage( "Invalid node as child statement for %s output channel: %s", color::RED, name.c_str(), m_name.c_str() ); m_shaderGenerator->EnableCompilerErrorFlag(); } } } } else { //Invalid Diffuse statement no input :( m_shaderGenerator->AddLogMessage( "Invalid %s channel statement. No input provided", color::RED, m_name.c_str() ); m_shaderGenerator->EnableCompilerErrorFlag(); } StatementData shaderVariable; shaderVariable.statement = statement; shaderVariable.outputType = VT_VECTOR_4; return shaderVariable; }
std::map<std::string, Status*> Status::GetAllStatusses() { if (s_allStatusses.size() == 0) { IImageManager* imageManager = PlatformSpecific::GetImageManager(); //otherwise open status XML file typedef vector<XMLNode*>::const_iterator SI; vector<XMLNode*> statusNodes = BmeClient::GetPreferences()->GetIconPrefs()->GetStatusNodes(); for (SI s = statusNodes.begin(); s != statusNodes.end(); ++s) { XMLNode* statusNode = *s; if (statusNode->Name() == "status") { vector<XMLNode*> children = statusNode->Children(); Status* status = new Status(); for (SI c = children.begin(); c != children.end(); ++c) { XMLNode* statusChild = *c; if (statusChild->Name() == "icon") { std::string iconPath = statusChild->StringValue(); IPath* iconFullPath = PlatformSpecific::GetPathManager()->GetIconPrefsPath()->Append(iconPath); Image* statusIcon = imageManager->GetImageFromFile(iconFullPath->ToString()); status->AddIcon(statusIcon); delete iconFullPath; } else if (statusChild->Name() == "message") { status->SetStatusName(statusChild->StringValue()); } else if (statusChild->Name() == "protocol") { status->SetAbbreviation(statusChild->StringValue()); } else if (statusChild->Name() == "visible") { bool userChoice = atoi(statusChild->StringValue().c_str()); status->SetUserChoice(userChoice); } else if (statusChild->Name() == "color") { } } s_allStatusses[status->GetAbbreviation()] = (status); } } delete imageManager; } return s_allStatusses; }
XMLNode* resource_to_xmb_msg(const StringResource& res) { // the msg element vector<XMLAttribute> attrs; string name = res.pos.file; name += ":"; name += res.TypedID(); attrs.push_back(XMLAttribute("", "name", name)); attrs.push_back(XMLAttribute("", "desc", strip_newlines(res.comment))); attrs.push_back(XMLAttribute(XMLNS_XMLNS, "space", "preserve")); XMLNode* msg = XMLNode::NewElement(res.pos, "", "msg", attrs, XMLNode::EXACT); // the contents are in xliff/html, convert it to xliff int err = 0; XMLNode* value = res.value; string tag = value->Name(); int phID = 0; for (vector<XMLNode*>::const_iterator it=value->Children().begin(); it!=value->Children().end(); it++) { err |= convert_html_to_xliff(*it, tag, msg, &phID); } if (err != 0) { return NULL; } // and then convert that to xmb for (vector<XMLNode*>::iterator it=msg->EditChildren().begin(); it!=msg->EditChildren().end(); it++) { err |= convert_xliff_to_ph(*it, &phID); } if (err == 0) { return msg; } else { return NULL; } }
//---------------------------------------------------------------------- StatementData VariableNodeProcessor::ProcessAsRoot( XMLParser& parser, XMLNode* node ) { std::string variableName; std::string variableValue; std::string variableType; if( parser.validateXMLAttributes( node, "name,type", "" ) ) { variableName = parser.getXMLAttributeAsString( node, "name", "" ); variableType = parser.getXMLAttributeAsString( node, "type", "" ); std::string variableData = parser.getXMLElementPCDataAsString( node ); if( variableType.compare( "Texture2D" ) == 0 ) { m_shaderGenerator->AddLogMessage( "Cannot declare textures as variables", color::RED ); m_shaderGenerator->EnableCompilerErrorFlag(); } else { XMLNode* child = node->FirstChildElement(); if( child != nullptr ) { for( ; child != nullptr; child = child->NextSiblingElement() ) { std::string name = child->Name(); if( name.compare( "Input" ) == 0 ) { StatementData statementData; statementData = ProcessInputNode( parser, child ); if( statementData.outputType != VT_COUNT ) { if( statementData.outputType == VT_TEXTURE_SAMPLE_2D ) { m_shaderGenerator->AddLogMessage( "Cannot declare a variable of type Texture2D", color::RED ); } else { variableValue = statementData.statement; } } else { variableValue = "0"; variableType = "Real"; } } else { StatementNodeProcessor* processor = m_shaderGenerator->GetStatementNodeProcessor( name ); if( processor != nullptr ) { variableValue = processor->ProcessAsChild( parser, child ).statement; } else { //Invalid node processor m_shaderGenerator->AddLogMessage( "Invalid child node: %s for variable: %s", color::RED, name.c_str(), variableName.c_str() ); m_shaderGenerator->EnableCompilerErrorFlag(); } } } } else { std::vector< std::string > variableDataList; stringTokenizer( variableData, variableDataList, "," ); if( ValidListOfVariables( variableDataList ) ) variableValue = GetVariableConstructionFromType( GetVariableTypeFromString( variableType ), StripDollarSignsFromCommaSeperatedVariables( variableData ) ); else { for( unsigned int i = 0; i < variableDataList.size(); ++i ) { if( variableDataList[i][0] == '$' ) variableDataList[i] = variableDataList[i].substr( 1, variableDataList[i].npos ); else if( !ValidRealNumber( variableDataList[i] ) ) { m_shaderGenerator->AddLogMessage( "Syntax error in variable declaration in variable name usage: %s. Missing \'$\'?", color::RED, variableData.c_str() ); m_shaderGenerator->EnableCompilerErrorFlag(); } } if( !m_shaderGenerator->WasCompilerError() && ValidListOfVariables( variableDataList ) ) { variableValue = StripDollarSignsFromListOfVariables( variableDataList ); } else { m_shaderGenerator->AddLogMessage( "Invalid data entered for variable declaration: Variable name: %s Data: %s", color::RED, variableName.c_str(), variableData.c_str() ); m_shaderGenerator->EnableCompilerErrorFlag(); } } } } } if( variableName.size() > 0 ) m_shaderGenerator->AddVariable( variableType, variableName, variableValue, ( m_name.compare( "Constant" ) == 0 ) ); return StatementData( "", VT_COUNT ); }
void MSNP12ContactListProtocol::HandleMessage(ProtocolMessage* message) { std::string command = message->CommandType(); //CHANGED IN MSNP11!!!! if (command == NotificationMessages::K_SYNCHRONISE_LIST) { std::string firstTimeStamp = message->GetParam(0); std::string secondTimeStamp = message->GetParam(1); if (firstTimeStamp != secondTimeStamp) { //we should update our contactlist std::string numContacts = message->GetParam(2); m_numContacts = atoi(numContacts.c_str()); std::string numGroups = message->GetParam(3); m_numGroups = atoi(numGroups.c_str()); } else { //if we don't have to synchronise the list and are using the cached contact list instead //be sure to set the m_contactsAdded and m_groupsAdded to the number of contacts and groups //available. In that way the initial status message will always be sent, and always after //the syn message m_contactsAdded = m_numContacts; m_groupsAdded = m_numGroups; } } else if (command == NotificationMessages::K_CONTACT_LIST_MSG) { Contact *newContact = new Contact(); for (int i = 0; i < message->ParamCount(); i++) { std::string temp = message->GetParam(i); if (temp.find("N=") != std::string::npos) { temp = temp.substr(2); newContact->SetPassport(temp); } else if (temp.find("F=") != std::string::npos) { temp = temp.substr(2); std::string friendlyName = temp; friendlyName = Common::decodeURL(friendlyName); newContact->SetFriendlyName(friendlyName); } else if (temp.find("C=") != std::string::npos) { temp = temp.substr(2); newContact->SetGUID(temp); } else if (i == 4) { //only in this order!!! //parse groupID's std::string groupId; int32_t startIndex = 0; size_t commaIndex = std::string::npos; do { commaIndex = temp.find(",",startIndex); if (commaIndex != std::string::npos) { //get one of the groupID's groupId = temp.substr(startIndex, commaIndex-startIndex); //add group to grouplist of contact newContact->AddGroup(groupId); cout << "GroupID 1= " << groupId << endl; groupId = ""; //start searching at position past the previous found comma startIndex = commaIndex + 1; } else { //get one of the groupID's //temp.CopyInto(groupID,0, temp.CountChars()); groupId = temp; //add group to grouplist of contact newContact->AddGroup(groupId); cout << "GroupID 2= " << groupId << endl; groupId = ""; break; } } while (commaIndex <= temp.size()); } else { int32_t partOfLists = atoi(temp.c_str()); newContact->SetPartOfLists(partOfLists); } } //set initial status for the contact to offline newContact->SetStatus(Status::GetStatusForAbbreviation(Statusses::K_OFFLINE)); //inform the contact list that a new contact has been found m_contactListProtocolDelegate->ContactFound(newContact); m_contactsAdded++; //see if we're done synchronizing the lists if (m_contactsAdded == m_numContacts) { m_contactListProtocolDelegate->SyncListEnded(); this->ProtocolDelegate()->SyncListEnded(); } } else if (command == NotificationMessages::K_GROUP_LIST_MSG) { std::string groupName = message->GetParam(0); std::string groupId = message->GetParam(1); m_contactListProtocolDelegate->GroupFound(groupId, groupName); m_groupsAdded++; } else if ( (command == NotificationMessages::K_PRINCIPAL_INITIAL_PRESENCE) || (command == NotificationMessages::K_PRINCIPAL_STATUS) ) { std::string temp = message->GetParam(0); //find status Status *status = Status::GetStatusForAbbreviation(temp); if (status) { //find contactID if available std::string contactPassport = message->GetParam(1); m_contactListProtocolDelegate->ContactStatusChanged(contactPassport, status); } } else if (command == NotificationMessages::K_ADD_BEHAVIOUR_MSG) { std::string value = message->GetParam(0); if (value == AddBehaviour::K_INFORM_USER) { m_contactListProtocolDelegate->SetInformUserUponListChange(true); } else if (value == AddBehaviour::K_ADD_IMMEDIATELY) { m_contactListProtocolDelegate->SetInformUserUponListChange(false); } } else if (command == NotificationMessages::K_DEFAULT_CONTACT_LIST_MSG) { std::string value = message->GetParam(0); if (value == DefaultContactListTypes::K_DEFAULT_ALLOWED) { m_contactListProtocolDelegate->SetDefaultContactList(IContactListProtocolDelegate::K_ALLOW_LIST); } else if (value == DefaultContactListTypes::K_DEFAULT_BLOCKED) { m_contactListProtocolDelegate->SetDefaultContactList(IContactListProtocolDelegate::K_BLOCK_LIST); } } else if (command == NotificationMessages::K_PRINCIPAL_STATUS) { } else if (command == NotificationMessages::K_ADD_PRINCIPAL) { } else if (command == NotificationMessages::K_REMOVE_PRINCIPAL) { } else if (command == NotificationMessages::K_RENAME_PRINCIPAL) { //see if still works!!! } else if (command == NotificationMessages::K_CONTACT_PERSONAL_MSG) { //buddy sent a personal message std::string principalPassport = message->GetParam(0); //get the message std::string payload = message->PayloadString(); XMLDocument* personalMessageXML = PlatformSpecific::GetXMLDocumentFromString(payload); //find and set the personal message vector<XMLNode*> children = personalMessageXML->RootElement()->Children(); for (int i = 0; i < children.size(); i++) { XMLNode* child = children[i]; if (child->Name() == "PSM") { std::string personalMessage = child->StringValue(); m_contactListProtocolDelegate->ContactPersonalMessageFound(personalMessage); break; } } } else if (command == NotificationMessages::K_CONTACT_PHONE_NUMBERS) { std::string subCommand = message->GetParam(0); if (subCommand == SettingTypes::K_HOME_PHONE_NUMBER) { std::string phoneNumber = Common::decodeURL(message->GetParam(1)); m_contactListProtocolDelegate->ContactPhoneNumberFound(K_HOME_PHONE_NUMBER, phoneNumber); } else if (subCommand == SettingTypes::K_WORK_PHONE_NUMBER) { std::string phoneNumber = Common::decodeURL(message->GetParam(1)); m_contactListProtocolDelegate->ContactPhoneNumberFound(K_WORK_PHONE_NUMBER, phoneNumber); } else if (subCommand == SettingTypes::K_MOBILE_PHONE_NUMBER) { std::string phoneNumber = Common::decodeURL(message->GetParam(1)); m_contactListProtocolDelegate->ContactPhoneNumberFound(K_MOBILE_PHONE_NUMBER, phoneNumber); } else if (subCommand == SettingTypes::K_HAS_MSN_SPACE_BLOG) { bool hasBlog = atoi(message->GetParam(1).c_str()); m_contactListProtocolDelegate->ContactBlogSettingFound(hasBlog); } else if (subCommand == SettingTypes::K_CAN_PAGE_MOBILE) { std::string value = Common::decodeURL(message->GetParam(1)); if (value == "Y") { m_contactListProtocolDelegate->ContactCanPageSettingFound(true); } } else if (subCommand == SettingTypes::K_CAN_DIRECT_PAGE_MOBILE) { std::string value = Common::decodeURL(message->GetParam(1)); if (value == "2") { m_contactListProtocolDelegate->ContactMSNDirectCapableSettingFound(true); } else { m_contactListProtocolDelegate->ContactMSNDirectCapableSettingFound(false); } } } }
int main(int argc, char* argv[]) { Arc::LogStream logcerr(std::cerr); logcerr.setFormat(Arc::ShortFormat); Arc::Logger::getRootLogger().addDestination(logcerr); Arc::Logger::getRootLogger().setThreshold(Arc::VERBOSE); if(argc < 3) usage(); std::string command(argv[1]); URL url(argv[2]); if(!url) exit(1); std::string conffile; Arc::UserConfig usercfg(conffile,initializeCredentialsType::RequireCredentials); MCCConfig cfg; usercfg.ApplyToConfig(cfg); EMIESClient ac(url,cfg,30); if(command == "sstat") { XMLNode info; if(!ac.sstat(info)) { logger.msg(ERROR,"Resource query failed"); return 1; }; std::string s; info.GetXML(s,true); std::cout<<s<<std::endl; } else if(command == "submit") { if(argc < 4) usage(); XMLNode adl; adl.ReadFromFile(argv[3]); if(!adl) usage(); std::string adls; adl.GetDoc(adls); EMIESJob job; EMIESJobState state; if(!ac.submit(adls,job,state)) { logger.msg(ERROR,"Submission failed"); return 1; }; print(job); print(state); } else if(command == "stat") { EMIESJob job; FillJob(job,argc,argv); EMIESJobState state; if(!ac.stat(job,state)) { logger.msg(ERROR,"Obtaining status failed"); return 1; }; print(job); print(state); } else if(command == "info") { EMIESJob job; FillJob(job,argc,argv); Job info; if(!ac.info(job,info)) { logger.msg(ERROR,"Obtaining information failed"); return 1; }; print(job); for(std::list<URL>::const_iterator s = job.stagein.begin();s!=job.stagein.end();++s) { std::cout<<"stagein: "<<s->fullstr()<<std::endl; } for(std::list<URL>::const_iterator s = job.session.begin();s!=job.session.end();++s) { std::cout<<"session: "<<s->fullstr()<<std::endl; } for(std::list<URL>::const_iterator s = job.stageout.begin();s!=job.stageout.end();++s) { std::cout<<"stageout: "<<s->fullstr()<<std::endl; } } else if(command == "clean") { EMIESJob job; FillJob(job,argc,argv); if(!ac.clean(job)) { logger.msg(ERROR,"Cleaning failed"); return 1; }; } else if(command == "notify") { EMIESJob job; FillJob(job,argc,argv); if(!ac.notify(job)) { logger.msg(ERROR,"Notify failed"); return 1; }; } else if(command == "kill") { EMIESJob job; FillJob(job,argc,argv); if(!ac.kill(job)) { logger.msg(ERROR,"Kill failed"); return 1; }; } else if(command == "list") { std::list<EMIESJob> jobs; if(!ac.list(jobs)) { logger.msg(ERROR,"List failed"); return 1; } print(jobs); } else if(command == "ivalidate") { std::map<std::string,std::string> interfaces; interfaces["org.ogf.glue.emies.activitycreation"] = ""; interfaces["org.ogf.glue.emies.activitymanagement"] = ""; interfaces["org.ogf.glue.emies.activityinfo"] = ""; interfaces["org.ogf.glue.emies.resourceinfo"] = ""; interfaces["org.ogf.glue.emies.delegation"] = ""; logger.msg(INFO,"Fetching resource description from %s",url.str()); XMLNode info; if(!ac.sstat(info,false)) { logger.msg(ERROR,"Failed to obtain resource description: %s",ac.failure()); return 1; }; int n = 0; int cnum1 = 0; for(;;++n) { XMLNode node = info.Child(n); if(!node) break; if(node.Namespace() != GLUE2_NAMESPACE) { logger.msg(ERROR,"Resource description contains unexpected element: %s:%s",node.Namespace(),node.Name()); return 1; }; if((node.Name() != "ComputingService") && (node.Name() != "Service")) { logger.msg(ERROR,"Resource description contains unexpected element: %s:%s",node.Namespace(),node.Name()); return 1; }; std::string errstr; std::string glue2_schema = ArcLocation::GetDataDir()+G_DIR_SEPARATOR_S+"schema"+G_DIR_SEPARATOR_S+"GLUE2.xsd"; if(!node.Validate(glue2_schema,errstr)) { logger.msg(ERROR,"Resource description validation according to GLUE2 schema failed: "); for(std::string::size_type p = 0;;) { if(p >= errstr.length()) break; std::string::size_type e = errstr.find('\n',p); if(e == std::string::npos) e = errstr.length(); logger.msg(ERROR,"%s", errstr.substr(p,e-p)); p = e + 1; }; return 1; }; if(node.Name() == "ComputingService") { ++cnum1; XMLNode endpoint = node["ComputingEndpoint"]; for(;(bool)endpoint;++endpoint) { XMLNode name = endpoint["InterfaceName"]; for(;(bool)name;++name) { std::string iname = (std::string)name; if((bool)endpoint["URL"]) { if(interfaces.find(iname) != interfaces.end()) interfaces[iname] = (std::string)endpoint["URL"]; }; }; }; }; }; if(n == 0) { logger.msg(ERROR,"Resource description is empty"); return 1; }; int inum = 0; for(std::map<std::string,std::string>::iterator i = interfaces.begin(); i != interfaces.end(); ++i) { if(!i->second.empty()) { logger.msg(INFO,"Resource description provides URL for interface %s: %s",i->first,i->second); ++inum; }; }; if(inum == 0) { logger.msg(ERROR,"Resource description provides no URLs for interfaces"); return 1; }; logger.msg(INFO,"Resource description validation passed"); int depth = 1; logger.msg(INFO,"Requesting ComputingService elements of resource description at %s",url.str()); XMLNodeContainer items; bool query_passed = false; bool all_elements = false; if(!query_passed) { logger.msg(INFO,"Performing /Services/ComputingService query"); if(!ac.squery("/Services/ComputingService",items,false)) { logger.msg(INFO,"Failed to obtain resource description: %s",ac.failure()); } else if(items.Size() <= 0) { logger.msg(INFO,"Query returned no elements."); } else { query_passed = true; }; }; if(!query_passed) { logger.msg(INFO,"Performing /ComputingService query"); if(!ac.squery("/ComputingService",items,false)) { logger.msg(INFO,"Failed to obtain resource description: %s",ac.failure()); } else if(items.Size() <= 0) { logger.msg(INFO,"Query returned no elements."); } else { query_passed = true; }; }; if(!query_passed) { all_elements = true; logger.msg(INFO,"Performing /* query"); if(!ac.squery("/*",items,false)) { logger.msg(INFO,"Failed to obtain resource description: %s",ac.failure()); } else if(items.Size() <= 0) { logger.msg(INFO,"Query returned no elements."); } else { query_passed = true; }; }; if(!query_passed) { logger.msg(ERROR,"All queries failed"); return 1; }; // In current implementation we can have different response // 1. ComputingService elements inside every Item element (ARC) // 2. Content of ComputingService elements inside every Item element (UNICORE) // 3. All elements inside every Item element // 4. Content of all elements inside every Item element int cnum2 = 0; for(int n = 0; n < items.Size(); ++n) { if((items[n].Size() > 0) && (items[n]["ComputingService"])) { // Case 1 and 3. for(int nn = 0; nn < items[n].Size(); ++nn) { if((all_elements) && (items[n].Name() != "ComputingService")) continue; // case 3 if(!CheckComputingService(items[n].Child(nn))) return 1; ++cnum2; }; } else { // Assuming 2 and 4. Because 4 can't be reliably recognised // just assume it never happens. XMLNode result; NS ns("glue2arc",GLUE2_NAMESPACE); items[n].New(result); result.Namespaces(ns,true,0); result.Name(result.NamespacePrefix(GLUE2_NAMESPACE)+":ComputingService"); if(!CheckComputingService(result)) return 1; ++cnum2; }; }; if(cnum1 != cnum2) { logger.msg(ERROR,"Number of ComputingService elements obtained from full document and XPath qury do not match: %d != %d",cnum1,cnum2); return 1; }; logger.msg(INFO,"Resource description query validation passed"); } else { logger.msg(ERROR,"Unsupported command: %s",command); return 1; } return 0; }
XMLNode XMLNode::NewChild(const char *name, const NS& namespaces, int n, bool global_order) { XMLNode x = NewChild("", n, global_order); // placeholder x.Namespaces(namespaces); x.Name(name); return x; }
void GLUE2::ParseExecutionTargets(XMLNode glue2tree, std::list<ComputingServiceType>& targets) { XMLNode GLUEService = glue2tree; if(GLUEService.Name() != "ComputingService") { GLUEService = glue2tree["ComputingService"]; } for (; GLUEService; ++GLUEService) { ComputingServiceType cs; if (GLUEService["ID"]) { cs->ID = (std::string)GLUEService["ID"]; } if (GLUEService["Name"]) { cs->Name = (std::string)GLUEService["Name"]; } if (GLUEService["Capability"]) { for (XMLNode n = GLUEService["Capability"]; n; ++n) { cs->Capability.insert((std::string)n); } } if (GLUEService["Type"]) { cs->Type = (std::string)GLUEService["Type"]; } else { logger.msg(VERBOSE, "The Service doesn't advertise its Type."); } if (GLUEService["QualityLevel"]) { cs->QualityLevel = (std::string)GLUEService["QualityLevel"]; } else { logger.msg(VERBOSE, "The ComputingService doesn't advertise its Quality Level."); } if (GLUEService["TotalJobs"]) { cs->TotalJobs = stringtoi((std::string)GLUEService["TotalJobs"]); } if (GLUEService["RunningJobs"]) { cs->RunningJobs = stringtoi((std::string)GLUEService["RunningJobs"]); } if (GLUEService["WaitingJobs"]) { cs->WaitingJobs = stringtoi((std::string)GLUEService["WaitingJobs"]); } if (GLUEService["StagingJobs"]) { cs->StagingJobs = stringtoi((std::string)GLUEService["StagingJobs"]); } if (GLUEService["SuspendedJobs"]) { cs->SuspendedJobs = stringtoi((std::string)GLUEService["SuspendedJobs"]); } if (GLUEService["PreLRMSWaitingJobs"]) { cs->PreLRMSWaitingJobs = stringtoi((std::string)GLUEService["PreLRMSWaitingJobs"]); } // The GLUE2 specification does not have attribute ComputingService.LocalRunningJobs //if (GLUEService["LocalRunningJobs"]) { // cs->LocalRunningJobs = stringtoi((std::string)GLUEService["LocalRunningJobs"]); //} // The GLUE2 specification does not have attribute ComputingService.LocalWaitingJobs //if (GLUEService["LocalWaitingJobs"]) { // cs->LocalWaitingJobs = stringtoi((std::string)GLUEService["LocalWaitingJobs"]); //} // The GLUE2 specification does not have attribute ComputingService.LocalSuspendedJobs //if (GLUEService["LocalSuspendedJobs"]) { // cs->LocalWaitingJobs = stringtoi((std::string)GLUEService["LocalSuspendedJobs"]); //} XMLNode xmlCENode = GLUEService["ComputingEndpoint"]; int endpointID = 0; for(;(bool)xmlCENode;++xmlCENode) { ComputingEndpointType ComputingEndpoint; if (xmlCENode["URL"]) { ComputingEndpoint->URLString = (std::string)xmlCENode["URL"]; } else { logger.msg(VERBOSE, "The ComputingEndpoint has no URL."); } if (xmlCENode["HealthState"]) { ComputingEndpoint->HealthState = (std::string)xmlCENode["HealthState"]; } else { logger.msg(VERBOSE, "The Service advertises no Health State."); } if (xmlCENode["HealthStateInfo"]) { ComputingEndpoint->HealthStateInfo = (std::string)xmlCENode["HealthStateInfo"]; } if (xmlCENode["Capability"]) { for (XMLNode n = xmlCENode["Capability"]; n; ++n) { ComputingEndpoint->Capability.insert((std::string)n); } } if (xmlCENode["QualityLevel"]) { ComputingEndpoint->QualityLevel = (std::string)xmlCENode["QualityLevel"]; } else { logger.msg(VERBOSE, "The ComputingEndpoint doesn't advertise its Quality Level."); } if (xmlCENode["Technology"]) { ComputingEndpoint->Technology = (std::string)xmlCENode["Technology"]; } if (xmlCENode["InterfaceName"]) { ComputingEndpoint->InterfaceName = lower((std::string)xmlCENode["InterfaceName"]); } else if (xmlCENode["Interface"]) { // No such attribute according to GLUE2 document. Legacy/backward compatibility? ComputingEndpoint->InterfaceName = lower((std::string)xmlCENode["Interface"]); } else { logger.msg(VERBOSE, "The ComputingService doesn't advertise its Interface."); } if (xmlCENode["InterfaceVersion"]) { for (XMLNode n = xmlCENode["InterfaceVersion"]; n; ++n) { ComputingEndpoint->InterfaceVersion.push_back((std::string)n); } } if (xmlCENode["InterfaceExtension"]) { for (XMLNode n = xmlCENode["InterfaceExtension"]; n; ++n) { ComputingEndpoint->InterfaceExtension.push_back((std::string)n); } } if (xmlCENode["SupportedProfile"]) { for (XMLNode n = xmlCENode["SupportedProfile"]; n; ++n) { ComputingEndpoint->SupportedProfile.push_back((std::string)n); } } if (xmlCENode["Implementor"]) { ComputingEndpoint->Implementor = (std::string)xmlCENode["Implementor"]; } if (xmlCENode["ImplementationName"]) { if (xmlCENode["ImplementationVersion"]) { ComputingEndpoint->Implementation = Software((std::string)xmlCENode["ImplementationName"], (std::string)xmlCENode["ImplementationVersion"]); } else { ComputingEndpoint->Implementation = Software((std::string)xmlCENode["ImplementationName"]); } } if (xmlCENode["ServingState"]) { ComputingEndpoint->ServingState = (std::string)xmlCENode["ServingState"]; } else { logger.msg(VERBOSE, "The ComputingEndpoint doesn't advertise its Serving State."); } if (xmlCENode["IssuerCA"]) { ComputingEndpoint->IssuerCA = (std::string)xmlCENode["IssuerCA"]; } if (xmlCENode["TrustedCA"]) { XMLNode n = xmlCENode["TrustedCA"]; while (n) { // Workaround to drop non-conforming records generated by EGI services std::string subject = (std::string)n; if(CheckConformingDN(subject)) { ComputingEndpoint->TrustedCA.push_back(subject); } ++n; //The increment operator works in an unusual manner (returns void) } } if (xmlCENode["DowntimeStart"]) { ComputingEndpoint->DowntimeStarts = (std::string)xmlCENode["DowntimeStart"]; } if (xmlCENode["DowntimeEnd"]) { ComputingEndpoint->DowntimeEnds = (std::string)xmlCENode["DowntimeEnd"]; } if (xmlCENode["Staging"]) { ComputingEndpoint->Staging = (std::string)xmlCENode["Staging"]; } if (xmlCENode["JobDescription"]) { for (XMLNode n = xmlCENode["JobDescription"]; n; ++n) { ComputingEndpoint->JobDescriptions.push_back((std::string)n); } } if (xmlCENode["TotalJobs"]) { ComputingEndpoint->TotalJobs = stringtoi((std::string)xmlCENode["TotalJobs"]); } if (xmlCENode["RunningJobs"]) { ComputingEndpoint->RunningJobs = stringtoi((std::string)xmlCENode["RunningJobs"]); } if (xmlCENode["WaitingJobs"]) { ComputingEndpoint->WaitingJobs = stringtoi((std::string)xmlCENode["WaitingJobs"]); } if (xmlCENode["StagingJobs"]) { ComputingEndpoint->StagingJobs = stringtoi((std::string)xmlCENode["StagingJobs"]); } if (xmlCENode["SuspendedJobs"]) { ComputingEndpoint->SuspendedJobs = stringtoi((std::string)xmlCENode["SuspendedJobs"]); } if (xmlCENode["PreLRMSWaitingJobs"]) { ComputingEndpoint->PreLRMSWaitingJobs = stringtoi((std::string)xmlCENode["PreLRMSWaitingJobs"]); } // The GLUE2 specification does not have attribute ComputingEndpoint.LocalRunningJobs //if (xmlCENode["LocalRunningJobs"]) { // ComputingEndpoint->LocalRunningJobs = stringtoi((std::string)xmlCENode["LocalRunningJobs"]); //} // The GLUE2 specification does not have attribute ComputingEndpoint.LocalWaitingJobs //if (xmlCENode["LocalWaitingJobs"]) { // ComputingEndpoint->LocalWaitingJobs = stringtoi((std::string)xmlCENode["LocalWaitingJobs"]); //} // The GLUE2 specification does not have attribute ComputingEndpoint.LocalSuspendedJobs //if (xmlCENode["LocalSuspendedJobs"]) { // ComputingEndpoint->LocalSuspendedJobs = stringtoi((std::string)xmlCENode["LocalSuspendedJobs"]); //} cs.ComputingEndpoint.insert(std::pair<int, ComputingEndpointType>(endpointID++, ComputingEndpoint)); } XMLNode xComputingShare = GLUEService["ComputingShare"]; int shareID = 0; for (;(bool)xComputingShare;++xComputingShare) { ComputingShareType ComputingShare; if (xComputingShare["FreeSlots"]) { ComputingShare->FreeSlots = stringtoi((std::string)xComputingShare["FreeSlots"]); } if (xComputingShare["FreeSlotsWithDuration"]) { // Format: ns[:t] [ns[:t]]..., where ns is number of slots and t is the duration. ComputingShare->FreeSlotsWithDuration.clear(); const std::string fswdValue = (std::string)xComputingShare["FreeSlotsWithDuration"]; std::list<std::string> fswdList; tokenize(fswdValue, fswdList); for (std::list<std::string>::iterator it = fswdList.begin(); it != fswdList.end(); it++) { std::list<std::string> fswdPair; tokenize(*it, fswdPair, ":"); long duration = LONG_MAX; int freeSlots = 0; if (fswdPair.size() > 2 || !stringto(fswdPair.front(), freeSlots) || (fswdPair.size() == 2 && !stringto(fswdPair.back(), duration)) ) { logger.msg(VERBOSE, "The \"FreeSlotsWithDuration\" attribute published by \"%s\" is wrongly formatted. Ignoring it."); logger.msg(DEBUG, "Wrong format of the \"FreeSlotsWithDuration\" = \"%s\" (\"%s\")", fswdValue, *it); continue; } ComputingShare->FreeSlotsWithDuration[Period(duration)] = freeSlots; } } if (xComputingShare["UsedSlots"]) { ComputingShare->UsedSlots = stringtoi((std::string)xComputingShare["UsedSlots"]); } if (xComputingShare["RequestedSlots"]) { ComputingShare->RequestedSlots = stringtoi((std::string)xComputingShare["RequestedSlots"]); } if (xComputingShare["Name"]) { ComputingShare->Name = (std::string)xComputingShare["Name"]; } if (xComputingShare["MaxWallTime"]) { ComputingShare->MaxWallTime = (std::string)xComputingShare["MaxWallTime"]; } if (xComputingShare["MaxTotalWallTime"]) { ComputingShare->MaxTotalWallTime = (std::string)xComputingShare["MaxTotalWallTime"]; } if (xComputingShare["MinWallTime"]) { ComputingShare->MinWallTime = (std::string)xComputingShare["MinWallTime"]; } if (xComputingShare["DefaultWallTime"]) { ComputingShare->DefaultWallTime = (std::string)xComputingShare["DefaultWallTime"]; } if (xComputingShare["MaxCPUTime"]) { ComputingShare->MaxCPUTime = (std::string)xComputingShare["MaxCPUTime"]; } if (xComputingShare["MaxTotalCPUTime"]) { ComputingShare->MaxTotalCPUTime = (std::string)xComputingShare["MaxTotalCPUTime"]; } if (xComputingShare["MinCPUTime"]) { ComputingShare->MinCPUTime = (std::string)xComputingShare["MinCPUTime"]; } if (xComputingShare["DefaultCPUTime"]) { ComputingShare->DefaultCPUTime = (std::string)xComputingShare["DefaultCPUTime"]; } if (xComputingShare["MaxTotalJobs"]) { ComputingShare->MaxTotalJobs = stringtoi((std::string)xComputingShare["MaxTotalJobs"]); } if (xComputingShare["MaxRunningJobs"]) { ComputingShare->MaxRunningJobs = stringtoi((std::string)xComputingShare["MaxRunningJobs"]); } if (xComputingShare["MaxWaitingJobs"]) { ComputingShare->MaxWaitingJobs = stringtoi((std::string)xComputingShare["MaxWaitingJobs"]); } if (xComputingShare["MaxPreLRMSWaitingJobs"]) { ComputingShare->MaxPreLRMSWaitingJobs = stringtoi((std::string)xComputingShare["MaxPreLRMSWaitingJobs"]); } if (xComputingShare["MaxUserRunningJobs"]) { ComputingShare->MaxUserRunningJobs = stringtoi((std::string)xComputingShare["MaxUserRunningJobs"]); } if (xComputingShare["MaxSlotsPerJob"]) { ComputingShare->MaxSlotsPerJob = stringtoi((std::string)xComputingShare["MaxSlotsPerJob"]); } if (xComputingShare["MaxStageInStreams"]) { ComputingShare->MaxStageInStreams = stringtoi((std::string)xComputingShare["MaxStageInStreams"]); } if (xComputingShare["MaxStageOutStreams"]) { ComputingShare->MaxStageOutStreams = stringtoi((std::string)xComputingShare["MaxStageOutStreams"]); } if (xComputingShare["SchedulingPolicy"]) { ComputingShare->SchedulingPolicy = (std::string)xComputingShare["SchedulingPolicy"]; } if (xComputingShare["MaxMainMemory"]) { ComputingShare->MaxMainMemory = stringtoi((std::string)xComputingShare["MaxMainMemory"]); } if (xComputingShare["MaxVirtualMemory"]) { ComputingShare->MaxVirtualMemory = stringtoi((std::string)xComputingShare["MaxVirtualMemory"]); } if (xComputingShare["MaxDiskSpace"]) { ComputingShare->MaxDiskSpace = stringtoi((std::string)xComputingShare["MaxDiskSpace"]); } if (xComputingShare["DefaultStorageService"]) { ComputingShare->DefaultStorageService = (std::string)xComputingShare["DefaultStorageService"]; } if (xComputingShare["Preemption"]) { ComputingShare->Preemption = ((std::string)xComputingShare["Preemption"] == "true") ? true : false; } if (xComputingShare["EstimatedAverageWaitingTime"]) { ComputingShare->EstimatedAverageWaitingTime = (std::string)xComputingShare["EstimatedAverageWaitingTime"]; } if (xComputingShare["EstimatedWorstWaitingTime"]) { ComputingShare->EstimatedWorstWaitingTime = stringtoi((std::string)xComputingShare["EstimatedWorstWaitingTime"]); } if (xComputingShare["ReservationPolicy"]) { ComputingShare->ReservationPolicy = stringtoi((std::string)xComputingShare["ReservationPolicy"]); } cs.ComputingShare.insert(std::pair<int, ComputingShareType>(shareID++, ComputingShare)); } /* * A ComputingShare is linked to multiple ExecutionEnvironments. * Due to bug 2101 multiple ExecutionEnvironments per ComputingShare * will be ignored. The ExecutionEnvironment information will only be * stored if there is one ExecutionEnvironment associated with a * ComputingShare. */ /* * TODO: Store ExecutionEnvironment information in the list of * ExecutionEnvironmentType objects and issue a warning when the * resources published in multiple ExecutionEnvironment are * requested in a job description document. */ int managerID = 0; for (XMLNode xComputingManager = GLUEService["ComputingManager"]; (bool)xComputingManager; ++xComputingManager) { ComputingManagerType ComputingManager; if (xComputingManager["ProductName"]) { ComputingManager->ProductName = (std::string)xComputingManager["ProductName"]; } // The GlUE2 specification does not have attribute ComputingManager.Type //if (xComputingManager["Type"]) { // ComputingManager->Type = (std::string)xComputingManager["Type"]; //} if (xComputingManager["ProductVersion"]) { ComputingManager->ProductVersion = (std::string)xComputingManager["ProductVersion"]; } if (xComputingManager["Reservation"]) { ComputingManager->Reservation = ((std::string)xComputingManager["Reservation"] == "true"); } if (xComputingManager["BulkSubmission"]) { ComputingManager->BulkSubmission = ((std::string)xComputingManager["BulkSubmission"] == "true"); } if (xComputingManager["TotalPhysicalCPUs"]) { ComputingManager->TotalPhysicalCPUs = stringtoi((std::string)xComputingManager["TotalPhysicalCPUs"]); } if (xComputingManager["TotalLogicalCPUs"]) { ComputingManager->TotalLogicalCPUs = stringtoi((std::string)xComputingManager["TotalLogicalCPUs"]); } if (xComputingManager["TotalSlots"]) { ComputingManager->TotalSlots = stringtoi((std::string)xComputingManager["TotalSlots"]); } if (xComputingManager["Homogeneous"]) { ComputingManager->Homogeneous = ((std::string)xComputingManager["Homogeneous"] == "true"); } if (xComputingManager["NetworkInfo"]) { for (XMLNode n = xComputingManager["NetworkInfo"]; n; ++n) { ComputingManager->NetworkInfo.push_back((std::string)n); } } if (xComputingManager["WorkingAreaShared"]) { ComputingManager->WorkingAreaShared = ((std::string)xComputingManager["WorkingAreaShared"] == "true"); } if (xComputingManager["WorkingAreaFree"]) { ComputingManager->WorkingAreaFree = stringtoi((std::string)xComputingManager["WorkingAreaFree"]); } if (xComputingManager["WorkingAreaTotal"]) { ComputingManager->WorkingAreaTotal = stringtoi((std::string)xComputingManager["WorkingAreaTotal"]); } if (xComputingManager["WorkingAreaLifeTime"]) { ComputingManager->WorkingAreaLifeTime = (std::string)xComputingManager["WorkingAreaLifeTime"]; } if (xComputingManager["CacheFree"]) { ComputingManager->CacheFree = stringtoi((std::string)xComputingManager["CacheFree"]); } if (xComputingManager["CacheTotal"]) { ComputingManager->CacheTotal = stringtoi((std::string)xComputingManager["CacheTotal"]); } for (XMLNode n = xComputingManager["Benchmark"]; n; ++n) { double value; if (n["Type"] && n["Value"] && stringto((std::string)n["Value"], value)) { (*ComputingManager.Benchmarks)[(std::string)n["Type"]] = value; } else { logger.msg(VERBOSE, "Couldn't parse benchmark XML:\n%s", (std::string)n); continue; } } for (XMLNode n = xComputingManager["ApplicationEnvironments"]["ApplicationEnvironment"]; n; ++n) { ApplicationEnvironment ae((std::string)n["AppName"], (std::string)n["AppVersion"]); ae.State = (std::string)n["State"]; if (n["FreeSlots"]) { ae.FreeSlots = stringtoi((std::string)n["FreeSlots"]); } //else { // ae.FreeSlots = ComputingShare->FreeSlots; // Non compatible??, i.e. a ComputingShare is unrelated to the ApplicationEnvironment. //} if (n["FreeJobs"]) { ae.FreeJobs = stringtoi((std::string)n["FreeJobs"]); } else { ae.FreeJobs = -1; } if (n["FreeUserSeats"]) { ae.FreeUserSeats = stringtoi((std::string)n["FreeUserSeats"]); } else { ae.FreeUserSeats = -1; } ComputingManager.ApplicationEnvironments->push_back(ae); } int eeID = 0; for (XMLNode xExecutionEnvironment = xComputingManager["ExecutionEnvironments"]["ExecutionEnvironment"]; (bool)xExecutionEnvironment; ++xExecutionEnvironment) { ExecutionEnvironmentType ExecutionEnvironment; if (xExecutionEnvironment["Platform"]) { ExecutionEnvironment->Platform = (std::string)xExecutionEnvironment["Platform"]; } if (xExecutionEnvironment["MainMemorySize"]) { ExecutionEnvironment->MainMemorySize = stringtoi((std::string)xExecutionEnvironment["MainMemorySize"]); } if (xExecutionEnvironment["OSName"]) { if (xExecutionEnvironment["OSVersion"]) { if (xExecutionEnvironment["OSFamily"]) { ExecutionEnvironment->OperatingSystem = Software((std::string)xExecutionEnvironment["OSFamily"], (std::string)xExecutionEnvironment["OSName"], (std::string)xExecutionEnvironment["OSVersion"]); } else { ExecutionEnvironment->OperatingSystem = Software((std::string)xExecutionEnvironment["OSName"], (std::string)xExecutionEnvironment["OSVersion"]); } } else { ExecutionEnvironment->OperatingSystem = Software((std::string)xExecutionEnvironment["OSName"]); } } if (xExecutionEnvironment["ConnectivityIn"]) { ExecutionEnvironment->ConnectivityIn = (lower((std::string)xExecutionEnvironment["ConnectivityIn"]) == "true"); } if (xExecutionEnvironment["ConnectivityOut"]) { ExecutionEnvironment->ConnectivityOut = (lower((std::string)xExecutionEnvironment["ConnectivityOut"]) == "true"); } ComputingManager.ExecutionEnvironment.insert(std::pair<int, ExecutionEnvironmentType>(eeID++, ExecutionEnvironment)); } cs.ComputingManager.insert(std::pair<int, ComputingManagerType>(managerID++, ComputingManager)); } targets.push_back(cs); } }