ListObject* QueryProxy<QueryParameters, ListObject>::list() { //If the query uses the machineId (machineId not null) diet_profile_t* profile =NULL; if (! mmachineId.empty()) { profile = diet_profile_alloc(mserviceName, 3); } else { profile = diet_profile_alloc(mserviceName, 2); } std::string queryParmetersToString = SerializeAdaptor<QueryParameters>::serialize(mparameters); // Set parameters diet_string_set(profile, 0, msessionProxy.getSessionKey()); if (! mmachineId.empty()) { diet_string_set(profile, 1, mmachineId); diet_string_set(profile, 2, queryParmetersToString); } else { diet_string_set(profile, 1, queryParmetersToString); } if (diet_call(profile)) { raiseCommunicationMsgException("RPC call failed"); } raiseExceptionOnErrorResult(profile); std::string listObjectInString; diet_string_get(profile,1, listObjectInString); parseEmfObject(listObjectInString, mlistObject, "Error by receiving List object serialized"); return mlistObject; }
/** * \brief Function to add new user * \param user The object which encapsulates the user information * \return raises an exception on error */ int UserProxy::add(UMS_Data::User& user) { std::string sessionKey; std::string userInString; diet_profile_t* profile = diet_profile_alloc(SERVICES_UMS[USERCREATE], 2); sessionKey = msessionProxy->getSessionKey(); ::ecorecpp::serializer::serializer _ser; //To serialize the user object in to userToString std::string userToString = _ser.serialize_str(const_cast<UMS_Data::User_ptr>(&user)); //IN Parameters diet_string_set(profile, 0, msessionProxy->getSessionKey()); diet_string_set(profile, 1, userToString); if (diet_call(profile)) { raiseCommunicationMsgException("RPC call failed"); } raiseExceptionOnErrorResult(profile); diet_string_get(profile,1, userInString); //To parse User object serialized UMS_Data::User_ptr user_ptr; parseEmfObject(userInString, user_ptr, "Error by receiving User object serialized"); user = *user_ptr; muser = user; delete user_ptr; diet_profile_free(profile); return 0; }
/** * \brief Function to add new user * \fn int add(UMS_Data::User& user) * \param user The object which encapsulates the user information * \return raises an exception on error */ int UserProxy::add(UMS_Data::User& user) { diet_profile_t* profile = NULL; std::string sessionKey; char* userToString; char* errorInfo; char* userInString; std::string msg = "call of function diet_string_set is rejected "; profile = diet_profile_alloc("userCreate", 1, 1, 3); sessionKey = msessionProxy->getSessionKey(); ::ecorecpp::serializer::serializer _ser; //To serialize the user object in to userToString userToString = strdup(_ser.serialize_str(const_cast<UMS_Data::User_ptr>(&user)).c_str()); //IN Parameters if(diet_string_set(diet_parameter(profile,0), strdup(sessionKey.c_str()), DIET_VOLATILE)) { msg += "with sessionKey parameter "+sessionKey; raiseDietMsgException(msg); } if(diet_string_set(diet_parameter(profile,1), userToString, DIET_VOLATILE)) { msg += "with userToString parameter "+std::string(userToString); raiseDietMsgException(msg); } //OUT Parameters diet_string_set(diet_parameter(profile,2), NULL, DIET_VOLATILE); diet_string_set(diet_parameter(profile,3), NULL, DIET_VOLATILE); if(!diet_call(profile)) { if(diet_string_get(diet_parameter(profile,2), &userInString, NULL)){ msg += " by receiving User serialized message"; raiseDietMsgException(msg); } if(diet_string_get(diet_parameter(profile,3), &errorInfo, NULL)){ msg += " by receiving errorInfo message"; raiseDietMsgException(msg); } } else { raiseDietMsgException("DIET call failure"); } /*To raise a vishnu exception if the receiving message is not empty*/ raiseExceptionIfNotEmptyMsg(errorInfo); UMS_Data::User_ptr user_ptr; //To parse User object serialized parseEmfObject(std::string(userInString), user_ptr, "Error by receiving User object serialized"); user = *user_ptr; muser = user; delete user_ptr; diet_profile_free(profile); return 0; }
/** * \brief Function to add a new machine * \fn int add() * \return raises an exception on error */ int MachineProxy::add() { diet_profile_t* addProfile = NULL; std::string sessionKey; std::string machineToString; char* machineInString; char* errorInfo; std::string msg = "call of function diet_string_set is rejected "; addProfile = diet_profile_alloc("machineCreate", 1, 1, 3); sessionKey = msessionProxy.getSessionKey(); ::ecorecpp::serializer::serializer _ser; //To serialize the mmachine object in to machineToString machineToString = _ser.serialize_str(const_cast<UMS_Data::Machine_ptr>(&mmachine)); std::string sshKeyFilePath = mmachine.getSshPublicKey(); if(sshKeyFilePath.find("\"")!=std::string::npos) { throw UMSVishnuException(ERRCODE_INVALID_PARAM, " The machine SshPublicKey contains special character double quote \""); } //IN Parameters if(diet_string_set(diet_parameter(addProfile,0), strdup(sessionKey.c_str()), DIET_VOLATILE)) { msg += "with sessionKey parameter "+sessionKey; raiseDietMsgException(msg); } if(diet_string_set(diet_parameter(addProfile,1), strdup(machineToString.c_str()), DIET_VOLATILE)) { msg += "with machineToString parameter "+machineToString; raiseDietMsgException(msg); } //OUT Parameters diet_string_set(diet_parameter(addProfile,2), NULL, DIET_VOLATILE); diet_string_set(diet_parameter(addProfile,3), NULL, DIET_VOLATILE); if(!diet_call(addProfile)) { if(diet_string_get(diet_parameter(addProfile,2), &machineInString, NULL)){ msg += "by receiving Machine serialized message"; raiseDietMsgException(msg); } if(diet_string_get(diet_parameter(addProfile,3), &errorInfo, NULL)){ msg += "by receiving errorInfo message"; raiseDietMsgException(msg); } } else { raiseDietMsgException("DIET call failure"); } /*To raise a vishnu exception if the receiving message is not empty*/ raiseExceptionIfNotEmptyMsg(errorInfo); UMS_Data::Machine_ptr machine_ptr; //To parse machine object serialized parseEmfObject(std::string(machineInString), machine_ptr, "Error by receiving Machine object serialized"); mmachine = *machine_ptr; delete machine_ptr; diet_profile_free(addProfile); return 0; }
/** * \brief Function to add an authentication system * \return raises an exception on error */ int AuthSystemProxy::add() { diet_profile_t* profile = NULL; std::string sessionKey; std::string authSystemToString; char* authSystemInString; char* errorInfo; std::string msg = "call of function diet_string_set is rejected "; profile = diet_profile_alloc("authSystemCreate", 1, 1, 3); sessionKey = msessionProxy.getSessionKey(); ::ecorecpp::serializer::serializer _ser; //To serialize the mauthSystem object in to authSystemToString authSystemToString = _ser.serialize_str(const_cast<UMS_Data::AuthSystem_ptr>(&mauthSystem)); //IN Parameters if(diet_string_set(diet_parameter(profile,0), strdup(sessionKey.c_str()), DIET_VOLATILE)) { msg += "with sessionKey parameter "+sessionKey; raiseDietMsgException(msg); } if(diet_string_set(diet_parameter(profile,1), strdup(authSystemToString.c_str()), DIET_VOLATILE)) { msg += "with authSystemToString parameter "+authSystemToString; raiseDietMsgException(msg); } //OUT Parameters diet_string_set(diet_parameter(profile,2), NULL, DIET_VOLATILE); diet_string_set(diet_parameter(profile,3), NULL, DIET_VOLATILE); if(!diet_call(profile)) { if(diet_string_get(diet_parameter(profile,2), &authSystemInString, NULL)) { msg += "with authSystemInString parameter "+std::string(authSystemInString); raiseDietMsgException(msg); } if(diet_string_get(diet_parameter(profile,3), &errorInfo, NULL)){ msg += "by receiving errorInfo message"; raiseDietMsgException(msg); } } else { raiseDietMsgException("DIET call failure"); } /*To raise a vishnu exception if the receiving message is not empty*/ raiseExceptionIfNotEmptyMsg(errorInfo); UMS_Data::AuthSystem_ptr authSystem_ptr; //To parse User object serialized parseEmfObject(std::string(authSystemInString), authSystem_ptr, "Error by receiving AuthSystem object serialized"); mauthSystem = *authSystem_ptr; delete authSystem_ptr; diet_profile_free(profile); return 0; }