SPARK-1013 helper functions on the admin data

This commit is contained in:
Taha Afzal committed 2018-04-26 07:30:48 -04:00
1 parent a8aa62aaaa
commit ed1b3aca92
3 files changed
+31 -2

No files matched your search

+14 -1
View File
@@ -19,6 +19,7 @@ AdminServiceServer::AdminServiceServer(bts::api::ServiceContext& context)
bts::api::admin::AdminServiceBase (context),
_table_name("users"),
_unique_key("0"),
_default_group_name("DEFAULT"),
_state(),
_store(new bts::persistence::SqliteStore("user_model"))
{
@@ -43,6 +44,10 @@ AdminServiceServer::AdminServiceServer(bts::api::ServiceContext& context)
{
// first time
// TODO add default group
bts::api::admin::BTSUserGroup default_group;
default_group.set_id(0);
default_group.set_name(_default_group_name);
AdminServiceUtils::create_group(&_state, default_group);
_update_and_publish();
}
}
@@ -55,6 +60,8 @@ void AdminServiceServer::create_account(const api::admin::AccountCreateAPIArgume
if (AdminServiceUtils::find_account(_state, acct_create_arg.account_name())==nullptr){
bts::api::admin::BTSAccount* new_account = _state.add_accounts();
new_account->set_id(AdminServiceUtils::find_curr_acct_id(_state)+1);
if(acct_create_arg.has_parent_account_id())
new_account->mutable_parent_account_id()->set_id(acct_create_arg.parent_account_id().id());
new_account->set_name(acct_create_arg.account_name());
new_account->set_description(acct_create_arg.description());
new_account->set_is_active(false);
@@ -113,9 +120,15 @@ void AdminServiceServer::set_account_exchange_data(const api::admin::AccountExch
reply(result);
}
void AdminServiceServer::create_user(const api::admin::UserCreateAPIArgument&,
void AdminServiceServer::create_user(const api::admin::UserCreateAPIArgument& new_user,
const api::Response<::bts::api::VoidMessage>&)
{
bts::api::admin::BTSUser* new_user_ptr = _state.add_users();
// test for name
new_user_ptr->set_name(new_user.name());
new_user_ptr->set_password (new_user.password());
new_user_ptr->mutable_license_entitlements()->CopyFrom(new_user.license_entitlements());
_update_and_publish();
}
void AdminServiceServer::set_user_account_association(const api::admin::UserAccountAssociationAPIArgument&,