def delete_file( git_name, git_mail, collection_path, entity_id, file_basename, agent='' ): """ @param collection_path: string @param entity_id: string @param file_basename: string @param git_name: Username of git committer. @param git_mail: Email of git committer. @param agent: (optional) Name of software making the change. """ logger.debug('delete_file(%s,%s,%s,%s,%s,%s)' % (git_name, git_mail, collection_path, entity_id, file_basename, agent)) gitstatus.lock(settings.MEDIA_BASE, 'delete_file') file_id = os.path.splitext(file_basename)[0] file_ = DDRFile.from_identifier(Identifier(file_id)) entity = Entity.from_identifier(Identifier(entity_id)) collection = Collection.from_identifier(Identifier(path=collection_path)) logger.debug('delete from repository') rm_files,updated_files = entity.prep_rm_file(file_) status,message = commands.file_destroy( git_name, git_mail, collection, entity, rm_files, updated_files, agent ) logger.debug('delete from search index') try: docstore.delete(settings.DOCSTORE_HOSTS, settings.DOCSTORE_INDEX, file_.id) except ConnectionError: logger.error('Could not delete document from Elasticsearch.') return status,message,collection_path,file_basename
def delete_entity( git_name, git_mail, collection_path, entity_id, agent='' ): """ @param collection_path: string @param entity_id: string @param git_name: Username of git committer. @param git_mail: Email of git committer. @param agent: (optional) Name of software making the change. """ gitstatus.lock(settings.MEDIA_BASE, 'delete_entity') logger.debug('collection_delete_entity(%s,%s,%s,%s,%s)' % (git_name, git_mail, collection_path, entity_id, agent)) # remove the entity collection = Collection.from_identifier(Identifier(collection_path)) entity = Entity.from_identifier(Identifier(entity_id)) status,message = commands.entity_destroy( git_name, git_mail, collection, entity, agent ) # update search index try: docstore.delete(settings.DOCSTORE_HOSTS, settings.DOCSTORE_INDEX, entity_id) except ConnectionError: logger.error('Could not delete document from Elasticsearch.') return status,message,collection_path,entity_id