'*** old implementation for backward compatibility ***
POST /api/libraries/{encoded_library_id}/permissions
Updates the library permissions.'

def set_permissions_old(self, trans, library, payload, **kwd):

    params = util.Params(payload)
    permissions = {}
    for (k, v) in trans.app.model.Library.permitted_actions.items():
        role_params = params.get((k + '_in'), [])
        in_roles = [trans.sa_session.query(trans.app.model.Role).get(trans.security.decode_id(x)) for x in util.listify(role_params)]
        permissions[trans.app.security_agent.get_action(v.action)] = in_roles
    trans.app.security_agent.set_all_library_permissions(trans, library, permissions)
    trans.sa_session.refresh(library)
    trans.app.security_agent.copy_library_permissions(trans, library, library.root_folder)
    item = library.to_dict(view='element', value_mapper={'id': trans.security.encode_id, 'root_folder_id': trans.security.encode_id})
    return item
