package at.procon.dip.extraction.impl;

import at.procon.dip.domain.document.DocumentType;
import at.procon.dip.extraction.spi.DocumentExtractor;
import at.procon.dip.extraction.spi.ExtractionRequest;
import at.procon.dip.extraction.spi.ExtractionResult;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Component;

/**
 * Fallback extractor for binary formats not yet supported by specialized extractors.
 */
@Component
public class BinaryPassThroughDocumentExtractor implements DocumentExtractor {

    @Override
    public boolean supports(DocumentType documentType, String mimeType) {
        return documentType == DocumentType.DOCX
                || documentType == DocumentType.ZIP_ARCHIVE
                || documentType == DocumentType.GENERIC_BINARY
                || documentType == DocumentType.MIME_MESSAGE
                || documentType == DocumentType.UNKNOWN;
    }

    @Override
    public ExtractionResult extract(ExtractionRequest extractionRequest) {
        return new ExtractionResult(Map.of(), List.of(), List.of(
                "No specialized extractor available yet for " + extractionRequest.detectionResult().documentType()));
    }
}
