@@ -0,0 +1,1486 @@
+package de.jeha.kame.crawler.service.ds;%0A%0Aimport de.jeha.kame.crawler.core.types.CrawlResult;%0Aimport de.jeha.kame.crawler.service.ds.util.FileNameUtils;%0Aimport org.apache.commons.io.FileUtils;%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0Aimport java.io.*;%0Aimport java.time.ZonedDateTime;%0Aimport java.util.zip.GZIPOutputStream;%0A%0A/**%0A * @author jenshadlich@googlemail.com%0A */%0Apublic class FileDocumentStore implements DocumentStore %7B%0A%0A    private static final Logger LOG = LoggerFactory.getLogger(FileDocumentStore.class);%0A%0A    private final String path;%0A%0A    public FileDocumentStore(String path) %7B%0A        this.path = path;%0A%0A        try %7B%0A            File root = new File(path);%0A            if (!root.exists()) %7B%0A                FileUtils.forceMkdir(root);%0A            %7D%0A        %7D catch (IOException e) %7B%0A            LOG.error(%22Could not create root directory%22, e);%0A        %7D%0A    %7D%0A%0A    @Override%0A    public void save(String crawlId, ZonedDateTime timestamp, CrawlResult result) throws IOException %7B%0A        final String filename = String.format(%22%25s-%25d-%25s.gz%22, crawlId, timestamp.toEpochSecond(), FileNameUtils.stripToFilename(result.getUrl()));%0A%0A        try (FileOutputStream output = new FileOutputStream(path + %22/%22 + filename)) %7B%0A            try (Writer writer = new OutputStreamWriter(new GZIPOutputStream(output), %22UTF-8%22)) %7B%0A                writer.write(result.getContent());%0A                LOG.debug(%22file '%7B%7D' written%22, filename);%0A            %7D%0A        %7D%0A    %7D%0A%0A%7D%0A

implement a file-based document store