Example #1
0
UserAf* UserContainer::addUser( const std::string & username, const std::string & hostname, MonitorContainer * monitoring)
{
   {
      UserContainerIt usersIt( this);
      for(UserAf *user = usersIt.user(); user != NULL; usersIt.next(), user = usersIt.user())
      {
         if( username == user->getName())
         {
            if( user->getHostName() != hostname)
            {
               user->setHostName( hostname);
               if( monitoring) monitoring->addEvent( af::Msg::TMonitorUsersChanged, user->getId());
            }
            return user;
         }
      }
   }

   UserAf *user = new UserAf( username, hostname);
   if( addUser(user) == 0)
   {
      AFERROR("UserContainer::addUser: Can't add user to container.\n");
      delete user;
      return NULL;
   }

   if( monitoring) monitoring->addEvent( af::Msg::TMonitorUsersAdd, user->getId());

   AFCommon::QueueLog("User registered: " + user->v_generateInfoString( false));
   return user;
}
Example #2
0
UserAf* UserContainer::addUser( const std::string & i_usernmae, const std::string & i_hostname, MonitorContainer * i_monitoring)
{
	{
		UserContainerIt usersIt( this);
		for(UserAf *user = usersIt.user(); user != NULL; usersIt.next(), user = usersIt.user())
		{
			if( i_usernmae == user->getName())
			{
				if( user->getHostName() != i_hostname)
				{
					user->setHostName( i_hostname);
					if( i_monitoring) i_monitoring->addEvent( af::Monitor::EVT_users_change, user->getId());
				}
				return user;
			}
		}
	}

	UserAf *user = new UserAf( i_usernmae, i_hostname);
	if( addUser(user) == 0)
	{
		AFERROR("UserContainer::addUser: Can't add user to container.\n");
		delete user;
		return NULL;
	}

	if( i_monitoring) i_monitoring->addEvent( af::Monitor::EVT_users_add, user->getId());

	AFCommon::QueueLog("New job user registered: " + user->v_generateInfoString( false));
	return user;
}