Esempio n. 1
0
/**
 * \brief Function to remove a machine
 * \fn  int deleteMachine()
 * \return raises an exception on error
 */
int MachineProxy::deleteMachine()
{
  diet_profile_t* deleteProfile = NULL;
  std::string sessionKey;
  std::string machineId;
  char* errorInfo;
  std::string msg = "call of function diet_string_set is rejected ";

  deleteProfile = diet_profile_alloc("machineDelete", 1, 1, 2);
  sessionKey = msessionProxy.getSessionKey();
  machineId = mmachine.getMachineId();

  //IN Parameters
  if(diet_string_set(diet_parameter(deleteProfile,0), strdup(sessionKey.c_str()), DIET_VOLATILE)) {
    msg += "with sessionKey parameter "+sessionKey;
    raiseDietMsgException(msg);
  }
  if(diet_string_set(diet_parameter(deleteProfile,1), strdup(machineId.c_str()), DIET_VOLATILE)) {
    msg += "with machineId parameter "+machineId;
    raiseDietMsgException(msg);
  }

  //OUT Parameters
  diet_string_set(diet_parameter(deleteProfile,2), NULL, DIET_VOLATILE);

  if(!diet_call(deleteProfile)) {
    if(diet_string_get(diet_parameter(deleteProfile,2), &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);
  
  diet_profile_free(deleteProfile);

  return 0;
}
Esempio n. 2
0
/**
 * \brief Function to update user information
 * \param user The object which encapsulates the user information
 * \return raises an exception on error
 */
int
UserProxy::update(const UMS_Data::User& user) {

    diet_profile_t* profile = diet_profile_alloc(SERVICES_UMS[USERUPDATE], 2);
    //To serialize the user object in to userToString
    ::ecorecpp::serializer::serializer _ser;
    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_profile_free(profile);
    return 0;
}
Esempio n. 3
0
/**
 * \brief Function to reset user password
 * \param user The object which encapsulates the user information
 * \return raises an exception on error
 */
int
UserProxy::resetPassword(UMS_Data::User& user) {

    diet_profile_t* profile = diet_profile_alloc(SERVICES_UMS[USERPASSWORDRESET], 2);
    diet_string_set(profile, 0, msessionProxy->getSessionKey());
    diet_string_set(profile, 1, user.getUserId());

    if (diet_call(profile)) {
        raiseCommunicationMsgException("RPC call failed");
    }
    raiseExceptionOnErrorResult(profile);

    std::string tmpPassword;
    diet_string_get(profile, 1, tmpPassword);

    /*To set the temporary password*/
    muser.setUserId(user.getUserId());
    muser.setPassword(tmpPassword);

    diet_profile_free(profile);

    return 0;
}
Esempio n. 4
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;

}
Esempio n. 5
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;
}