'Raise exception if user cannot add to the specified library item (i.e.
Folder). Can set check_accessible to False if folder was loaded with
this check.'

def check_user_can_add_to_library_item(self, trans, item, check_accessible=True):

    if (not trans.user):
        return False
    current_user_roles = trans.get_current_user_roles()
    if trans.user_is_admin():
        return True
    if check_accessible:
        if (not trans.app.security_agent.can_access_library_item(current_user_roles, item, trans.user)):
            raise exceptions.ItemAccessibilityException('You    do    not    have    access    to    the    requested    item')
    if (not trans.app.security_agent.can_add_library_item(trans.get_current_user_roles(), item)):
        raise exceptions.ItemOwnershipException('User    cannot    add    to    library    item.')
