예제 #1
0
def get_current_sharing_model():
    LOG.info("[usermgnt.modules.um_sharing_model] [get_current_sharing_model] Getting current sharing model ...")
    sharing_model = data_adapter.get_current_sharing_model()
    if sharing_model is None:
        return common.gen_response(500, 'Error', 'sharing_model', 'not found / error', 'sharing_model', {})
    elif sharing_model == -1:
        return common.gen_response_ko('Warning: Sharing-model not found', 'sharing_model', 'not found / error', 'sharing_model', {})
    else:
        return common.gen_response_ok('Sharing-model found', 'sharing_model', sharing_model)
예제 #2
0
def delete_sharing_model_by_id(sharing_model_id):
    LOG.info("[usermgnt.modules.um_sharing_model] [delete_sharing_model_by_id] sharing_model_id=" + sharing_model_id)
    # deletes sharing_model
    res = data_adapter.delete_sharing_model_by_id(sharing_model_id)
    if res is None:
        return common.gen_response(500, 'Exception', 'sharing_model_id', sharing_model_id)
    elif res == -1:
        return common.gen_response_ko('Warning: Sharing-model not found', 'sharing_model_id', sharing_model_id)
    else:
        return common.gen_response_ok('Sharing-model deleted', 'sharing_model_id', sharing_model_id)
예제 #3
0
def update_sharing_model_by_id(sharing_model_id, data):
    LOG.info("[usermgnt.modules.um_sharing_model] [update_sharing_model_by_id] sharing_model_id=" + sharing_model_id + ", data=" + str(data))
    # updates sharing_model
    sharing_model = data_adapter.update_sharing_model_by_id(sharing_model_id, data)
    if sharing_model is None:
        return common.gen_response(500, 'Exception', 'data', str(data), 'sharing_model', {})
    elif sharing_model == -1:
        return common.gen_response_ko('Warning: Sharing model not found', 'sharing_model_id', sharing_model_id, 'sharing_model', {})
    else:
        return common.gen_response_ok('Sharing-model updated', 'data', str(data), 'sharing_model', sharing_model)
예제 #4
0
def get_sharing_model_by_id(sharing_model_id):
    LOG.info("[usermgnt.modules.um_sharing_model] [get_sharing_model_by_id] sharing_model_id=" + sharing_model_id)
    # get sharing_model
    sharing_model = data_adapter.get_sharing_model_by_id(sharing_model_id)
    if sharing_model is None:
        return common.gen_response(500, 'Exception', 'sharing_model_id', sharing_model_id, 'sharing_model', {})
    elif sharing_model == -1:
        return common.gen_response_ko('Warning: Sharing-model not found', 'sharing_model_id', sharing_model_id, 'sharing_model', {})
    else:
        return common.gen_response_ok('Sharing model found', 'sharing_model_id', sharing_model_id, 'sharing_model', sharing_model)
예제 #5
0
def get_user_profile_by_id(profile_id):
    LOG.debug(
        "[usermgnt.modules.um_profiling] [get_user_profile_by_id] profile_id="
        + profile_id)
    user_profile = data_adapter.get_user_profile_by_id(profile_id)
    if user_profile is None:
        return common.gen_response(500, 'Error', 'profile_id', profile_id,
                                   'profile', {})
    elif user_profile == -1:
        return common.gen_response_ko('Warning: User profile not found',
                                      'profile_id', profile_id, 'profile', {})
    else:
        return common.gen_response_ok('User found', 'profile_id', profile_id,
                                      'profile', user_profile)
예제 #6
0
def update_user_profile_by_id(profile_id, data):
    LOG.debug(
        "[usermgnt.modules.um_profiling] [update_user_profile_by_id] profile_id="
        + profile_id + ", data=" + str(data))
    # update user
    user_profile = data_adapter.update_user_profile_by_id(profile_id, data)
    if user_profile is None:
        return common.gen_response(500, 'Error', 'profile_id', profile_id,
                                   'profile', {})
    elif user_profile == -1:
        return common.gen_response_ko('Warning: User profile not found',
                                      'profile_id', profile_id, 'profile', {})
    else:
        return common.gen_response_ok('User updated', 'profile_id', profile_id,
                                      'profile', user_profile)
예제 #7
0
def get_current_user_profile():
    LOG.info(
        "[usermgnt.modules.um_profiling] [get_current_user_profile] Getting current user-profile value ..."
    )
    user_profile = data_adapter.get_current_user_profile()
    if user_profile is None:
        return common.gen_response(500, 'Error', 'user_profile',
                                   'not found / error', 'profile', {})
    elif user_profile == -1:
        return common.gen_response_ko('Warning: User profile not found',
                                      'user_profile', 'not found / error',
                                      'profile', {})
    else:
        return common.gen_response_ok('User found', 'user_profile',
                                      user_profile)
예제 #8
0
def __getCurrentUser():
    LOG.info(
        "[usermgnt.modules.current] [__getCurrentUser] Getting current user ..."
    )
    user_profile = data_adapter.get_current_user_profile()
    if user_profile is None:
        return common.gen_response(500, 'Error', 'cause', 'not found / error',
                                   'user', '')
    elif user_profile == -1:
        return common.gen_response_ko('Warning: User profile not found',
                                      'cause', 'not found / error', 'user', '')
    else:
        return common.gen_response_ok(
            'User found', 'user_profile', user_profile, 'user_id',
            user_profile['acl']['owner']['principal'])
예제 #9
0
def __getCurrentDevice():
    LOG.info(
        "[usermgnt.modules.current] [__getCurrentDevice] Getting current device ..."
    )
    user_profile = data_adapter.get_current_user_profile()
    if user_profile is None:
        return common.gen_response(500, 'Error', 'cause', 'not found / error',
                                   'device', '')
    elif user_profile == -1:
        return common.gen_response_ko('Warning: User profile not found',
                                      'cause', 'not found / error', 'device',
                                      '')
    else:
        return common.gen_response_ok('User found', 'user_profile',
                                      user_profile, 'device',
                                      user_profile['device_id'])
예제 #10
0
def __getCurrentAll():
    LOG.info(
        "[usermgnt.modules.current] [__getCurrentAll] Getting current device ..."
    )
    user_profile = data_adapter.get_current_user_profile()
    sharing_model = data_adapter.get_current_sharing_model()
    agent = data_adapter.get_agent_info()
    if user_profile is None:
        return common.gen_response(500, 'Error', 'cause', 'not found / error',
                                   'info', {})
    elif user_profile == -1:
        return common.gen_response_ko(
            'Warning: user_profile / sharing_model / agent not found', 'cause',
            'not found / error', 'info', {})
    else:
        return common.gen_response_ok(
            'User found', 'info', {
                "user_profile": user_profile,
                "sharing_model": sharing_model,
                "agent": agent
            })