@utilities.arguments_not_none<EOL><INDENT>def add_asset(self, asset_id, composition_id):<DEDENT>
<EOL>from dlkit.abstract_osid.id.primitives import Id as ABCId<EOL>if not isinstance(asset_id, ABCId):<EOL><INDENT>raise errors.InvalidArgument('<STR_LIT>')<EOL><DEDENT>if (not isinstance(composition_id, ABCId) and<EOL>composition_id.get_identifier_namespace() != '<STR_LIT>'):<EOL><INDENT>raise errors.InvalidArgument('<STR_LIT>')<EOL><DEDENT>if asset_id.get_identifier_namespace() != '<STR_LIT>':<EOL><INDENT>if asset_id.get_authority() != self._authority:<EOL><INDENT>raise errors.InvalidArgument()<EOL><DEDENT>else:<EOL><INDENT>mgr = self._get_provider_manager('<STR_LIT>')<EOL>admin_session = mgr.get_asset_admin_session_for_repository(self._catalog_id, proxy=self._proxy)<EOL>asset_id = admin_session._get_asset_id_with_enclosure(asset_id)<EOL><DEDENT><DEDENT>collection = JSONClientValidated('<STR_LIT>',<EOL>collection='<STR_LIT>',<EOL>runtime=self._runtime)<EOL>asset = collection.find_one({'<STR_LIT>': ObjectId(asset_id.get_identifier())})<EOL>collection = JSONClientValidated('<STR_LIT>',<EOL>collection='<STR_LIT>',<EOL>runtime=self._runtime)<EOL>composition = collection.find_one({'<STR_LIT>': ObjectId(composition_id.get_identifier())})<EOL>if '<STR_LIT>' in composition:<EOL><INDENT>if str(asset_id) not in composition['<STR_LIT>']:<EOL><INDENT>composition['<STR_LIT>'].append(str(asset_id))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>composition['<STR_LIT>'] = [str(asset_id)]<EOL><DEDENT>collection.save(composition)<EOL>
Appends an asset to a composition.

        arg:    asset_id (osid.id.Id): ``Id`` of the ``Asset``
        arg:    composition_id (osid.id.Id): ``Id`` of the
                ``Composition``
        raise:  AlreadyExists - ``asset_id`` already part
                ``composition_id``
        raise:  NotFound - ``asset_id`` or ``composition_id`` not found
        raise:  NullArgument - ``asset_id`` or ``composition_id`` is
                ``null``
        raise:  OperationFailed - unable to complete request
        raise:  PermissionDenied - authorization fauilure
        *compliance: mandatory -- This method must be implemented.*