import logging

from gateway_core.application.ports.NotificationPort import NotificationPort
from gateway_core.application.ports.FileSystemPort import FileSystemPort
from gateway_core.domain.FileSystemData import FileListDto

logger = logging.getLogger(__name__)

class FileListUseCase:
    """
    This class should implement the business logic fo file handling.

    Maybe needs a Adapter for specific file sistem or how to access?
    """

    def __init__(
        self,
        fileSystem: FileSystemPort,
        notifier: NotificationPort,
    ) -> None:
        self._fileSystem = fileSystem
        self._notifier = notifier

    async def execute(self, fileListDto: FileListDto) -> None:
        listOfFiles = await self._fileSystem.gatherFileList(fileListDto.path, fileListDto.datatypes, fileListDto.recursive)

        await self._notifier.notifyFileList(fileListDto.taskId, listOfFiles)
