• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ UserServer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中UserServer的典型用法代码示例。如果您正苦于以下问题:C++ UserServer类的具体用法?C++ UserServer怎么用?C++ UserServer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了UserServer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: UMSVishnuException

/**
 * \brief Function to reconnect the session
 * \param user The object which manipulates user information
 * \param host The object which manipulates client machine information
 * \param sessionId The session identifier
 * \return raises an exception on error
 */
int
SessionServer::reconnect(UserServer user, MachineClientServer clientMachineServer,
                         std::string sessionId) {
  msession.setSessionId(sessionId);

  if (! user.isAuthenticate()) {
    throw UMSVishnuException (ERRCODE_UNKNOWN_USER);
  }

  int state = getState(true);
  if (state < 0) {
    throw UMSVishnuException (ERRCODE_UNKNOWN_SESSION_ID);
  }

  if (state != vishnu::SESSION_ACTIVE) {
    throw UMSVishnuException (ERRCODE_UNKNOWN_SESSION_ID);
  }

  int existSessionKey = getSessionkey(clientMachineServer.getId(),
                                      user.getNumUserFromLoginInfo(user.getData().getUserId(),user.getData().getPassword()),
                                      user.isAdmin());

  if (existSessionKey == -1) {
    throw UMSVishnuException (ERRCODE_SESSIONKEY_NOT_FOUND);
  }

  return 0;
}
开发者ID:SysFera,项目名称:vishnu,代码行数:35,代码来源:SessionServer.cpp


示例2: processOptions

  /**
   * \brief Function to treat the ListLocalAccountsServer options
   * \param userServer the object which encapsulates user information
   * \param options the object which contains the ListLocalAccountsServer options
   * \param sqlRequest the sql data base request
   * \return raises an exception on error
   */
  void processOptions(UserServer userServer, const UMS_Data::ListLocalAccOptions_ptr& options, std::string& sqlRequest)
  {

    if (! userServer.isAdmin()
        && (! options->getUserId().empty() || options->isAdminListOption())) {
      throw UMSVishnuException(ERRCODE_NO_ADMIN);
    }

    if(! options->isAdminListOption()) {
      addOptionRequest("userid", userServer.getData().getUserId(), sqlRequest);
    }

    //The admin option
    if (! options->getUserId().empty()) {
      addOptionRequest("users.userid", options->getUserId(), sqlRequest);
    }

    if (! options->getMachineId().empty()) {
      addOptionRequest("machine.machineid", options->getMachineId(), sqlRequest);

      if (! options->isAdminListOption()
          && options->getUserId().empty()) {
        addOptionRequest("users.userid", userServer.getData().getUserId(), sqlRequest);
      }
    }
  }
开发者ID:SysFera,项目名称:vishnu,代码行数:33,代码来源:ListLocalAccountsServer.hpp


示例3: processOptions

  /**
   * \brief Function to treat the listSessionServer options
   * \param userServer the object which encapsulates user information
   * \param options the object which contains the ListSessionServer options values
   * \param sqlRequest the sql data base request
   * \return raises an exception on error
   */
  void
  processOptions(UserServer userServer, const UMS_Data::ListSessionOptions_ptr& options, std::string& query)
  {
    boost::posix_time::ptime pt;
    bool listAll = options->isAdminListOption();

    if (! userServer.isAdmin()
        && (! options->getUserId().empty() || listAll)) {
      throw UMSVishnuException (ERRCODE_NO_ADMIN);
    }

    if(! options->getMachineId().empty()) {
      addOptionRequest("clmachine.name", options->getMachineId(), query);
    }

    if(! options->getUserId().empty()) {
      addOptionRequest("users.userid", options->getUserId(), query);
    } else {
      if (! listAll) {
        addOptionRequest("users.userid", userServer.getData().getUserId(), query);
      }
    }

    int status = options->getStatus();
    if (status == vishnu::STATUS_UNDEFINED) {
      status = vishnu::STATUS_ACTIVE;
    }

    addIntegerOptionRequest("state", status, query);

    if (options->getSessionClosePolicy()) {
      addIntegerOptionRequest("closepolicy", options->getSessionClosePolicy(), query);
    }

    if (options->getSessionInactivityDelay() < 0) {
      throw UMSVishnuException(ERRCODE_INCORRECT_TIMEOUT);
    }

    if (options->getSessionInactivityDelay()) {
      addIntegerOptionRequest("timeout", options->getSessionInactivityDelay(), query);
    }

    if (! options->getSessionId().empty()) {
      addOptionRequest("vsessionid", options->getSessionId(), query);
    }

    time_t startDate = static_cast<time_t>(options->getStartDateOption());
    if (startDate > 0) {
      addTimeRequest("creation", vishnu::timeToTimestamp(startDate), query, ">=");
    }

    time_t endDate = static_cast<time_t>(options->getEndDateOption());
    if (endDate > 0) {
      addTimeRequest("closure", vishnu::timeToTimestamp(endDate), query, "<=");
    }
  }
开发者ID:SysFera,项目名称:vishnu,代码行数:63,代码来源:ListSessionsServer.hpp


示例4: e

/**
 * \brief Function to connect the session
 * \param user The object which manipulates user information
 * \param host The object which manipulates client machine information
 * \param connectOpt The options data structure for connection
 * \return raises an exception on error
 */
int
SessionServer::connectSession(UserServer user, MachineClientServer host, UMS_Data::ConnectOptions* connectOpt) {
  std::string numSubstituteUserId;
  std::string numUserIdToconnect;

  //To record the connection identifier
  msession.setAuthenId(user.getData().getUserId());

  //if the user exist
  if (user.isAuthenticate()) {
    //if a user to substitute is defined
    if (connectOpt->getSubstituteUserId().size() != 0) {
      // if the user is admin
      if (user.isAdmin()) {
        numSubstituteUserId = user.getAttribut("where "
                                               "userid='"+mdatabaseVishnu->escapeData(connectOpt->getSubstituteUserId())+"'");
        //If the user to substitute exist
        if (! user.getNumUserId(connectOpt->getSubstituteUserId()).empty()) {
          numUserIdToconnect = numSubstituteUserId;
          msession.setUserId(connectOpt->getSubstituteUserId());
        } //End If the user to substitute exist
        else {
          UMSVishnuException e(ERRCODE_UNKNOWN_USERID);
          throw e;
        }
      } // END if the user is admin
      else {
        UMSVishnuException e(ERRCODE_NO_ADMIN);
        throw e;
      }
    } //End if a user to substitute is defined

    //if there is not a numSubstituteUserId
    if (numUserIdToconnect.size() == 0) {
      numUserIdToconnect = user.getAttribut("where userid='"+mdatabaseVishnu->escapeData(user.getData().getUserId())+"'"
                                            " and pwd='"+mdatabaseVishnu->escapeData(user.getData().getPassword())+"'");
      msession.setUserId(user.getData().getUserId());
    } //END if There is not a numSubstituteUserId

    generateSessionKey(user.getData().getUserId());
    generateSessionId(user.getData().getUserId());

    //To solve the connection mode
    solveConnectionMode(connectOpt, numUserIdToconnect);

    host.recordMachineClient();
    recordSessionServer(host.getId(), numUserIdToconnect);

  } // END if the user exist
  else {
    UMSVishnuException e(ERRCODE_UNKNOWN_USER);
    throw e;
  }
  return 0;
}//END: connectSession(UserServer, MachineClientServer, ConnectOptions*)
开发者ID:keoo,项目名称:vishnu,代码行数:62,代码来源:SessionServer.cpp


示例5: UserServer

/**
* \brief Function to update a VISHNU machine
* \return raises an exception on error
*/
int
MachineServer::update() {

  std::string sqlCommand = "";

  UserServer userServer = UserServer(msessionServer);
  userServer.init();

  //if the user exists
  if (! userServer.exist()) {
    throw UMSVishnuException (ERRCODE_UNKNOWN_USER);
  }
  if (! userServer.isAdmin()) {
    throw UMSVishnuException (ERRCODE_NO_ADMIN);
  }

  //if the machine to update exists
  std::string numMachineId = getEntryAttribute(mmachine->getMachineId(), "nummachineid");
  if (numMachineId.empty()) {
    throw UMSVishnuException (ERRCODE_UNKNOWN_MACHINE);
  }

  if (! mmachine->getAddress().empty()) {
    std::string query = boost::str(boost::format("UPDATE machine SET address='%1%'"
                                                 " WHERE nummachineid='%2%';")
                                   % mdatabase->escapeData(mmachine->getAddress())
                                   % numMachineId);
    sqlCommand.append(query);
  }

  if (mmachine->getStatus() != vishnu::STATUS_UNDEFINED) {
    std::string query = boost::str(
                          boost::format("UPDATE machine SET status='%1%'"
                                        " WHERE nummachineid='%2%';")
                          % mmachine->getStatus()
                          % numMachineId);
    sqlCommand.append(query);
  }

  if (! mmachine->getDescription().empty()) {
    std::string query = boost::str(
                          boost::format("UPDATE machine SET description='%1%'"
                                        " WHERE machine_nummachineid='%2%';")
                          % mdatabase->escapeData(mmachine->getDescription())
                          % numMachineId);

    sqlCommand.append(query);
  }

  if (! sqlCommand.empty()) {
    mdatabase->process(sqlCommand);
  }

  return 0;
}
开发者ID:SysFera,项目名称:vishnu,代码行数:59,代码来源:MachineServer.cpp


示例6: list

  /**
   * \brief Function to list commands information
   * \return The pointer to the UMS_Data::ListCommands containing commands information
   * \return raises an exception on error
   */
  UMS_Data::ListCommands* list(UMS_Data::ListCmdOptions_ptr option)
  {
    std::string query;
    std::vector<std::string>::iterator ii;
    std::vector<std::string> results;
    std::string description;

    query = "SELECT DISTINCT ctype, vsessionid, name, description, starttime, endtime, command.status"
            " FROM vsession, clmachine, command, users"
            " WHERE vsession.numsessionid=command.vsession_numsessionid"
            "  AND vsession.clmachine_numclmachineid=clmachine.numclmachineid"
            "  AND vsession.users_numuserid=users.numuserid";


    UMS_Data::UMS_DataFactory_ptr ecoreFactory = UMS_Data::UMS_DataFactory::_instance();
    mlistObject = ecoreFactory->createListCommands();

    //Creation of the object user
    UserServer userServer = UserServer(msessionServer);
    userServer.init();
    //if the user exists
    if (!userServer.exist()) {
      UMSVishnuException e (ERRCODE_UNKNOWN_USER);
      throw e;
    }

    processOptions(userServer, option, query);
    query.append(" order by starttime");
    //To get the list of commands from the database
    boost::scoped_ptr<DatabaseResult> ListOfCommands (mdatabase->getResult(query.c_str()));
    for (size_t i = 0; i < ListOfCommands->getNbTuples(); ++i) {

      results.clear();
      results = ListOfCommands->get(i);
      ii = results.begin();

      UMS_Data::Command_ptr command = ecoreFactory->createCommand();
      vishnu::CmdType currentCmdType = static_cast<vishnu::CmdType>(vishnu::convertToInt(*ii));
      command->setCommandId(convertCmdType(static_cast<vishnu::CmdType>(currentCmdType)));
      command->setSessionId(*(++ii));
      command->setMachineId(*(++ii));
      //MAPPER CREATION
      Mapper* mapper = MapperRegistry::getInstance()->getMapper(convertypetoMapperName(currentCmdType));
      description = mapper->decode(*(++ii));
      command->setCmdDescription(description);
      command->setCmdStartTime(convertToTimeType(*(++ii)));
      command->setCmdEndTime(convertToTimeType(*(++ii)));
      command->setStatus(vishnu::convertToInt(*(++ii)));

      mlistObject->getCommands().push_back(command);
    }
    return mlistObject;
  }
开发者ID:SysFera,项目名称:vishnu,代码行数:58,代码来源:ListCommandsServer.hpp


示例7: list

  /**
   * \brief Function to list sessions information
   * \return The pointer to the UMS_Data::ListSessions containing sessions information
   * \return raises an exception on error
   */
  UMS_Data::ListSessions*
  list(UMS_Data::ListSessionOptions_ptr option)
  {
    std::string query = (boost::format("SELECT DISTINCT vsessionid, userid, sessionkey, state, closepolicy, "
                                       "                timeout, lastconnect, creation, closure, authid "
                                       " FROM vsession, users, clmachine"
                                       " WHERE vsession.state            = %1%"
                                       "    AND users.status             = %1%"
                                       "    AND vsession.users_numuserid = users.numuserid"
                                       "    AND vsession.clmachine_numclmachineid=clmachine.numclmachineid")
                         % vishnu::STATUS_ACTIVE).str();

    std::vector<std::string>::iterator dbResultIter;
    std::vector<std::string> dbResults;
    UMS_Data::UMS_DataFactory_ptr ecoreFactory = UMS_Data::UMS_DataFactory::_instance();
    mlistObject = ecoreFactory->createListSessions();

    //Creation of the object user
    UserServer userServer = UserServer(msessionServer);
    userServer.init();

    if (! userServer.exist()) {
      throw UMSVishnuException (ERRCODE_UNKNOWN_USER);
    }

    processOptions(userServer, option, query);
    query.append(" order by creation");
    //To get the list of sessions from the database
    boost::scoped_ptr<DatabaseResult> ListOfSessions (mdatabase->getResult(query));

    if (ListOfSessions->getNbTuples() != 0){
      for (size_t i = 0; i < ListOfSessions->getNbTuples(); ++i) {
        dbResults.clear();
        dbResults = ListOfSessions->get(i);
        dbResultIter = dbResults.begin();

        UMS_Data::Session_ptr session = ecoreFactory->createSession();
        session->setSessionId(*(dbResultIter));
        session->setUserId(*(++dbResultIter));
        session->setSessionKey(*(++dbResultIter));
        session->setStatus(vishnu::convertToInt(*(++dbResultIter)));
        session->setClosePolicy(vishnu::convertToInt(*(++dbResultIter)));
        session->setTimeout(vishnu::convertToInt(*(++dbResultIter)));
        session->setDateLastConnect(convertToTimeType(*(++dbResultIter)));
        session->setDateCreation(convertToTimeType(*(++dbResultIter)));
        session->setDateClosure(convertToTimeType(*(++dbResultIter)));
        session->setAuthenId(*(++dbResultIter));
        mlistObject->getSessions().push_back(session);
      }
    }

    return mlistObject;
  }
开发者ID:SysFera,项目名称:vishnu,代码行数:58,代码来源:ListSessionsServer.hpp


示例8: list

  /**
   * \brief Function to list sessions information
   * \return The pointer to the UMS_Data::ListSessions containing sessions information
   * \return raises an exception on error
   */
  UMS_Data::ListSessions*
  list(UMS_Data::ListSessionOptions_ptr option)
  {
    std::string sqlListOfSessions = "SELECT vsessionid, userid, sessionkey, state, closepolicy, timeout, lastconnect, "
                                    "creation, closure, authid from vsession, users where vsession.users_numuserid=users.numuserid";

    std::vector<std::string>::iterator ii;
    std::vector<std::string> results;
    UMS_Data::UMS_DataFactory_ptr ecoreFactory = UMS_Data::UMS_DataFactory::_instance();
    mlistObject = ecoreFactory->createListSessions();

    //Creation of the object user
    UserServer userServer = UserServer(msessionServer);
    userServer.init();
    //if the user exists
    if (userServer.exist()) {

      processOptions(userServer, option, sqlListOfSessions);
      sqlListOfSessions.append(" order by creation");
      //To get the list of sessions from the database
      boost::scoped_ptr<DatabaseResult> ListOfSessions (mdatabaseInstance->getResult(sqlListOfSessions.c_str()));

      if (ListOfSessions->getNbTuples() != 0){
        for (size_t i = 0; i < ListOfSessions->getNbTuples(); ++i) {
          results.clear();
          results = ListOfSessions->get(i);
          ii = results.begin();

          UMS_Data::Session_ptr session = ecoreFactory->createSession();
          session->setSessionId(*(ii));
          session->setUserId(*(++ii));
          session->setSessionKey(*(++ii));
          session->setStatus(vishnu::convertToInt(*(++ii)));
          session->setClosePolicy(vishnu::convertToInt(*(++ii)));
          session->setTimeout(vishnu::convertToInt(*(++ii)));
          session->setDateLastConnect(convertToTimeType(*(++ii)));
          session->setDateCreation(convertToTimeType(*(++ii)));
          session->setDateClosure(convertToTimeType(*(++ii)));
          session->setAuthenId(*(++ii));

          mlistObject->getSessions().push_back(session);
        }
      }
    }
    else {
      UMSVishnuException e (ERRCODE_UNKNOWN_USER);
      throw e;
    }
    return mlistObject;
  }
开发者ID:absila,项目名称:vishnu,代码行数:55,代码来源:ListSessionsServer.hpp


示例9: transferId

/**
 * \brief Function to treat the Stop file transfer options
 * \param options the object which contains the Stop file transfers options values
 * \param sqlRequest the sql data base request
 * \return raises an exception on error
 */
void
FileTransferServer::processOptions(const FMS_Data::StopTransferOptions& options,
                                   std::string& sqlRequest) {

  std::string transferId(options.getTransferId()),machineName(options.getFromMachineId()),userId(options.getUserId());

  //To check if the transferId is defined
  if (transferId.size() != 0) {

    if (transferId.compare("all")!=0 && transferId.compare("ALL")!=0){
      //To check the transfer Id
      FileTransferServer::checkTransferId(options.getTransferId());
      //To add the transferId on the request
      FileTransferServer::addOptionRequest("transferId", options.getTransferId(), sqlRequest);

    }

  }

  //To check if the fromMachineId is defined
  if (machineName.size() != 0) {

    sqlRequest.append(" and (sourceMachineId='"+FileTransferServer::getDatabaseInstance()->escapeData(machineName)+"'"+" or destinationMachineId='"+FileTransferServer::getDatabaseInstance()->escapeData(machineName)+"')");
  }

  //Creation of the object user
  UserServer userServer = UserServer(msessionServer);

  userServer.init();

  //To check if the userId is defined
  if (userId.size() != 0) {

    if (!userServer.isAdmin()) {
      UMSVishnuException e (ERRCODE_NO_ADMIN);
      throw e;
    }

    if (userId.compare("all")!=0 && userId.compare("ALL")!=0){
      //To check the user Id
      FileTransferServer::checkUserId(options.getUserId());

      //To add the userId on the request
      FileTransferServer::addOptionRequest("userId", userId, sqlRequest);
    }
  } else {
    FileTransferServer::addOptionRequest("userId", userServer.getData().getUserId(), sqlRequest);
  }
}
开发者ID:absila,项目名称:vishnu,代码行数:55,代码来源:FileTransferServer.cpp


示例10: processOptions

  /**
   * \brief Function to treat the ListUsersServer options
   * \param userServer the object which encapsulates user information
   * \param options The object which encapsulates the information of ListUsersServer  options
   * \param sqlRequest the sql data base request
   * \return raises an exception on error
   */
  void
  processOptions(UserServer userServer, const UMS_Data::ListUsersOptions_ptr& options, std::string& sqlRequest) {


    if(! userServer.isAdmin()) {
      throw UMSVishnuException (ERRCODE_NO_ADMIN);
    }
    std::string  userId = options->getUserId();
    if(userId.size()!=0) {
      //To check if the user id is correct
      checkUserId(options->getUserId());
      addOptionRequest("userid", userId, sqlRequest);
    }

    std::string  authSystemId = options->getAuthSystemId();
    if(authSystemId.size()!=0) {
      //To check if the authSystem identifier is correct
      checkAuthSystemId(authSystemId);
      //addOptionRequest("authsystemid", authSystemId, sqlRequest);
      std::string luserCmd = boost::str(boost::format("SELECT userid "
                                                      " FROM authsystem, users, authaccount "
                                                      " WHERE authaccount.authsystem_authsystemid=authsystem.numauthsystemid"
                                                      " AND authaccount.users_numuserid=users.numuserid"
                                                      " AND authsystemid='%1%'"
                                                      " AND authsystem.status!=%2%"
                                                      " AND users.status!=%2%"
                                                      " AND authaccount.status!=%2%"
                                                      )
                                        % mdatabaseInstance->escapeData(authSystemId)
                                        % vishnu::STATUS_DELETED);
      sqlRequest.append(" AND userid IN ("+mdatabaseInstance->escapeData(luserCmd)+")");
    }

  }
开发者ID:absila,项目名称:vishnu,代码行数:41,代码来源:ListUsersServer.hpp


示例11: list

  /**
   * \brief Function to list locoal accounts information
   * \return The pointer to the UMS_Data::ListLocalAccounts containing local accounts information
   * \return raises an exception on error
   */
  UMS_Data::ListLocalAccounts* list(UMS_Data::ListLocalAccOptions_ptr option)
  {
    std::string query = boost::str(boost::format("SELECT DISTINCT machineid, userid, aclogin, home"
                                                 " FROM account, machine, users"
                                                 " WHERE account.status               = %1%"
                                                 "   AND machine.status               = %1%"
                                                 "   AND users.status                 = %1%"
                                                 "   AND account.machine_nummachineid = machine.nummachineid"
                                                 "   AND account.users_numuserid      = users.numuserid"
                                                 ) % vishnu::STATUS_ACTIVE);


    std::vector<std::string>::iterator dbResultIter;
    std::vector<std::string> dbResults;
    UMS_Data::UMS_DataFactory_ptr ecoreFactory = UMS_Data::UMS_DataFactory::_instance();
    mlistObject = ecoreFactory->createListLocalAccounts();

    //Creation of the object user
    UserServer userServer = UserServer(msessionServer);
    userServer.init();
    if (! userServer.exist()) {
      throw UMSVishnuException (ERRCODE_UNKNOWN_USER);
    }

    //To process options
    processOptions(userServer, option, query);

    boost::scoped_ptr<DatabaseResult> resultAccount(mdatabase->getResult(query));
    if (resultAccount->getNbTuples() != 0){
      for (size_t i = 0; i < resultAccount->getNbTuples(); ++i) {
        dbResults.clear();
        dbResults = resultAccount->get(i);
        dbResultIter = dbResults.begin();

        UMS_Data::LocalAccount_ptr localAccount = ecoreFactory->createLocalAccount();
        localAccount->setMachineId(*dbResultIter);
        localAccount->setUserId(*(++dbResultIter));
        localAccount->setAcLogin(*(++dbResultIter));
        localAccount->setHomeDirectory(*(++dbResultIter));

        mlistObject->getAccounts().push_back(localAccount);
      }
    }

    return mlistObject;
  }
开发者ID:SysFera,项目名称:vishnu,代码行数:51,代码来源:ListLocalAccountsServer.hpp


示例12: getState

/**
 * \brief Function to reconnect the session
 * \param user The object which manipulates user information
 * \param host The object which manipulates client machine information
 * \param sessionId The session identifier
 * \return raises an exception on error
 */
int
SessionServer::reconnect(UserServer user, MachineClientServer host,
                         std::string sessionId) {
  msession.setSessionId(sessionId);

  //If the user exists
  if (user.isAuthenticate()) {
    int state = getState(true);
    // -1 is an error code of getState when nohting has found
    if (state != -1) {
      //if the session is active
      if (state == 1) {
        int existSessionKey = 0;

        //if user is an admin
        if (user.isAdmin()) {
          existSessionKey = getSessionkey("", "", true);
        } //END if user is an admin
        else {
          existSessionKey = getSessionkey(host.getId(), user.getAttribut("where userid='"+mdatabaseVishnu->escapeData(user.getData().getUserId())+"'"
                                                                         " and pwd='"+mdatabaseVishnu->escapeData(user.getData().getPassword())+"'"));
        }
        //if there is no session key with the previous parameters
        if (existSessionKey == -1) {
          UMSVishnuException e(ERRCODE_SESSIONKEY_NOT_FOUND);
          throw e;
        }
      }//if the session is active
      else {
        UMSVishnuException e(ERRCODE_SESSIONKEY_EXPIRED);
        throw e;
      }
    }//END if state != -1
    else {
      UMSVishnuException e(ERRCODE_UNKNOWN_SESSION_ID);
      throw e;
    }
  } //END IF user.exist
  else {
    UMSVishnuException e(ERRCODE_UNKNOWN_USER);
    throw e;
  }
  return 0;
}//END: reconnect(UserServer, MachineClientServer, string sessionId)
开发者ID:keoo,项目名称:vishnu,代码行数:51,代码来源:SessionServer.cpp


示例13: processOptions

  /**
   * \brief Function to treat the ListMachinesServer options
   * \fn void processOptions(UserServer userServer,
   *                         const UMS_Data::ListMachineOptions_ptr& options,
   *                         std::string& sqlRequest)
   * \param userServer the object which encapsulates user information
   * \param options the object which contains the ListMachinesServer options values
   * \param sqlRequest the sql data base request
   * \return raises an exception on error
   */
  void processOptions(UserServer userServer, const UMS_Data::ListMachineOptions_ptr& options, std::string& sqlRequest)
  {
    std::string sqlListofMachinesWithJointure = "SELECT machineid, name, site, machine.status, lang, description, userid "
    " from machine, description, account, users where machine.nummachineid = description.machine_nummachineid "
    " and account.machine_nummachineid=machine.nummachineid and account.users_numuserid=users.numuserid";

    std::string sqlListofMachinesIntial =  sqlRequest;

    size_t userIdSize = options->getUserId().size();
    size_t machineIdSize = options->getMachineId().size();
    bool isListAll = options->isListAllMachine();

    if ((!userServer.isAdmin()) && userIdSize!=0) {
      UMSVishnuException e (ERRCODE_NO_ADMIN);
      throw e;
    }

    if(!isListAll) {
       sqlRequest = sqlListofMachinesWithJointure;
       addOptionRequest("userid", userServer.getData().getUserId(), sqlRequest);
    }

    //The admin option
    if(userIdSize!=0) {
      //To check if the user id is correct
      checkUserId(options->getUserId());

      sqlRequest = sqlListofMachinesWithJointure;
      addOptionRequest("userid", options->getUserId(), sqlRequest);
    }

    if(machineIdSize!=0) {
      //To check if the machine id is correct
      checkMachineId(options->getMachineId());

      if(!isListAll && userIdSize==0) {
         sqlRequest=sqlListofMachinesIntial;
      }
      addOptionRequest("machineid", options->getMachineId(), sqlRequest);
    }

 }
开发者ID:Ecapo,项目名称:vishnu,代码行数:52,代码来源:ListMachinesServer.hpp


示例14: list

 /**
  * \brief Function to list machines information
  * \fn UMS_Data::ListMachines* list()
  * \return The pointer to the UMS_Data::ListMachines containing machines information
  * \return raises an exception on error
  */
 UMS_Data::ListMachines* list() {
    std::string sqlListofMachines = "SELECT machineid, name, site, status, lang, description from machine, description "
    "where machine.nummachineid = description.machine_nummachineid";

    std::vector<std::string>::iterator ii;
    std::vector<std::string> results;
    UMS_Data::UMS_DataFactory_ptr ecoreFactory = UMS_Data::UMS_DataFactory::_instance();
    mlistObject = ecoreFactory->createListMachines();

    //Creation of the object user
    UserServer userServer = UserServer(msessionServer);
    userServer.init();
    //if the user exists
    if (userServer.exist()) {

      //To process options
      processOptions(userServer, mparameters, sqlListofMachines);

      boost::scoped_ptr<DatabaseResult> ListofMachines (mdatabaseVishnu->getResult(sqlListofMachines.c_str()));
      if (ListofMachines->getNbTuples() != 0){
        for (size_t i = 0; i < ListofMachines->getNbTuples(); ++i) {
          results.clear();
          results = ListofMachines->get(i);
          ii = results.begin();
          UMS_Data::Machine_ptr machine = ecoreFactory->createMachine();
          machine->setMachineId(*ii);
          machine->setName(*(++ii));
          machine->setSite(*(++ii));
          machine->setStatus(convertToInt(*(++ii)));
          machine->setLanguage(*(++ii));
          machine->setMachineDescription(*(++ii));

          mlistObject->getMachines().push_back(machine);
        }
      }

    } else {
      UMSVishnuException e (ERRCODE_UNKNOWN_USER);
      throw e;
    }
    return mlistObject;
  }
开发者ID:Ecapo,项目名称:vishnu,代码行数:48,代码来源:ListMachinesServer.hpp


示例15: list

  /**
  * \brief Function to list machines information
  * \return The pointer to the UMS_Data::ListMachines containing machines information
  * \return raises an exception on error
  */
  UMS_Data::ListMachines* list(UMS_Data::ListMachineOptions_ptr option) {
    std::string sqlListofMachines = boost::str(boost::format("SELECT machineid, address, status, description"
                                                             " FROM machine"
                                                             " WHERE machine.status != %1%") % vishnu::STATUS_DELETED);
    std::vector<std::string>::iterator dbResultIter;
    std::vector<std::string> dbResults;
    UMS_Data::UMS_DataFactory_ptr ecoreFactory = UMS_Data::UMS_DataFactory::_instance();
    mlistObject = ecoreFactory->createListMachines();

    //Creation of the object user
    UserServer userServer = UserServer(msessionServer);
    userServer.init();
    //if the user exists
    if (userServer.exist()) {

      //To process options
      processOptions(userServer, option, sqlListofMachines);

      boost::scoped_ptr<DatabaseResult> ListofMachines (mdatabase->getResult(sqlListofMachines.c_str()));
      if (ListofMachines->getNbTuples() != 0){
        for (size_t i = 0; i < ListofMachines->getNbTuples(); ++i) {
          dbResults.clear();
          dbResults = ListofMachines->get(i);
          dbResultIter = dbResults.begin();
          UMS_Data::Machine_ptr machine = ecoreFactory->createMachine();
          machine->setMachineId(*dbResultIter);
          machine->setAddress(*(++dbResultIter));
          machine->setStatus(vishnu::convertToInt(*(++dbResultIter)));
          machine->setDescription(*(++dbResultIter));

          mlistObject->getMachines().push_back(machine);
        }
      }

    } else {
      UMSVishnuException e (ERRCODE_UNKNOWN_USER);
      throw e;
    }
    return mlistObject;
  }
开发者ID:SysFera,项目名称:vishnu,代码行数:45,代码来源:ListMachinesServer.hpp


示例16: UserServer

/**
* \brief Function to close the session
* \return raises an exception on error
*/
int
SessionServer::close() {

  std::string closePolicyStr = "";
  UserServer user = UserServer(SessionServer(msession.getSessionKey()));
  CommandServer commanderServer = CommandServer(SessionServer(msession.getSessionKey()));
  //The init function initializes login and password using the sessionKey
  user.init();
  //If The user exist
  if (user.exist()) {
    int state = getState();
    //if the session is not already closed
    if (state != 0) {
      //if no running commands
      if (!commanderServer.isRunning()) {
        mdatabaseVishnu->process((boost::format("UPDATE vsession"
                                                " SET state=0"
                                                " WHERE sessionkey='%1%';")%mdatabaseVishnu->escapeData(msession.getSessionKey())).str());
        mdatabaseVishnu->process((boost::format("UPDATE vsession"
                                                " SET closure=CURRENT_TIMESTAMP"
                                                " WHERE sessionkey='%1%';")%mdatabaseVishnu->escapeData(msession.getSessionKey())).str());
      } else {
        //To get the close policy associated to the session
        closePolicyStr = (boost::format(" WHERE sessionkey='%1%';")%mdatabaseVishnu->escapeData(msession.getSessionKey())).str();
        getAttribut(closePolicyStr, "closepolicy");
        //If the session close policy is CLOSE_ON_DISCONNECT
        if (convertToInt(closePolicyStr) == 2) {
          disconnetToTimeout(user);
        }  else {
          throw  UMSVishnuException (ERRCODE_COMMAND_RUNNING);
        }
      }
    } else {
      UMSVishnuException e (ERRCODE_SESSIONKEY_EXPIRED);
      throw e;
    }
  } //END If The user exist
  return 0;
}//END: close()
开发者ID:keoo,项目名称:vishnu,代码行数:43,代码来源:SessionServer.cpp


示例17: processOptions

  /**
   * \brief Function to treat the ListCommandsServer options
   * \param userServer the object which encapsulates user information
   * \param options the object which contains the ListCommandsServer options values
   * \param sqlRequest the sql data base request
   * \return raises an exception on error
   */
  void
  processOptions(UserServer userServer, const UMS_Data::ListCmdOptions_ptr& options, std::string& sqlRequest)
  {
    boost::posix_time::ptime pt;
    bool listAll = options->isAdminListOption();

    if (! userServer.isAdmin()
        && (! options->getUserId().empty() || listAll)) {
      throw UMSVishnuException (ERRCODE_NO_ADMIN);
    }

    if(! options->getUserId().empty()) {
      addOptionRequest("users.numuserid", getNumUser(options->getUserId()), sqlRequest);
    } else {
      if(! listAll) {
        addOptionRequest("userid", userServer.getData().getUserId(), sqlRequest);
      }
    }

    if (! options->getSessionId().empty()) {
      checkSessionId(options->getSessionId());

      addOptionRequest("vsessionid", options->getSessionId(), sqlRequest);
    }

    time_t startDate = static_cast<time_t>(options->getStartDateOption());
    if (startDate != -1) {
      pt =  boost::posix_time::from_time_t(startDate);
      std::string startDateStr =  boost::posix_time::to_iso_string(pt);
      addTimeRequest("starttime", startDateStr, sqlRequest, ">=");
    }

    time_t endDate = static_cast<time_t>(options->getEndDateOption());
    if(endDate!=-1) {
      pt =  boost::posix_time::from_time_t(endDate);
      std::string endDateStr =  boost::posix_time::to_iso_string(pt);
      addTimeRequest("endtime", endDateStr, sqlRequest, "<=");
    }
  }
开发者ID:SysFera,项目名称:vishnu,代码行数:46,代码来源:ListCommandsServer.hpp


示例18: processOptions

  /**
   * \brief Function to treat the ListMachinesServer options
   * \param userServer the object which encapsulates user information
   * \param options the object which contains the ListMachinesServer options values
   * \param sqlRequest the sql data base request
   * \return raises an exception on error
   */
  void
  processOptions(UserServer userServer, const UMS_Data::ListMachineOptions_ptr& options, std::string& sqlRequest)
  {
    std::string sqlJoinLstMachines = boost::str(boost::format("SELECT DISTINCT machineid, address, machine.status, description, userid "
                                                              " FROM machine, account, users"
                                                              " WHERE account.machine_nummachineid = machine.nummachineid "
                                                              " AND account.users_numuserid = users.numuserid "
                                                              " AND machine.status != %1%"
                                                              " AND account.status != %1%"
                                                              " AND users.status   != %1%"
                                                              ) % vishnu::STATUS_DELETED);
    std::string sqlListofMachinesIntial = sqlRequest;
    bool isListAll = options->isListAllMachine();

    if (! userServer.isAdmin() && ! options->getUserId().empty()) {
      throw UMSVishnuException (ERRCODE_NO_ADMIN);
    }

    if(! isListAll) {
      sqlRequest = sqlJoinLstMachines;
      addOptionRequest("userid", userServer.getData().getUserId(), sqlRequest);
    }

    //The admin option
    if (! options->getUserId().empty()) {
      sqlRequest = sqlJoinLstMachines;
      addOptionRequest("users.numuserid", getNumUser(options->getUserId()), sqlRequest);
    }

    if (! options->getMachineId().empty()) {
      getNumMachine( options->getMachineId() );

      if(! isListAll && options->getUserId().empty()) {
        sqlRequest = sqlListofMachinesIntial;
      }

      addOptionRequest("machineid", options->getMachineId(), sqlRequest);
    }
  }
开发者ID:SysFera,项目名称:vishnu,代码行数:46,代码来源:ListMachinesServer.hpp


示例19:

/**
 * \brief Function to change the closure connection mode disconnet to timeout
 * \param user The object which manipulates user information
 * \return the new connection parameters are registered on the session data structure
 */
int
SessionServer::disconnetToTimeout(UserServer user) {

  OptionValueServer optionValueServer;
  std::string numuserId;

  //To change the session close policy on CLOSE_ON_TIMEOUT on the database
  mdatabaseVishnu->process("UPDATE vsession SET closepolicy=1"
                           " WHERE sessionkey='"+mdatabaseVishnu->escapeData(msession.getSessionKey())+"';");

  //To change the session close policy on CLOSE_ON_TIMEOUT on the msession object
  msession.setClosePolicy(1);

  numuserId = user.getAttribut("where userid='"+mdatabaseVishnu->escapeData(user.getData().getUserId())+"'"
                               " an 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ UserSession类代码示例发布时间:2022-05-31
下一篇:
C++ UserScriptVector类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap