<commit_before>package dk.statsbiblioteket.doms.transformers.fileobjectcreator;

import dk.statsbiblioteket.doms.central.CentralWebservice;
import dk.statsbiblioteket.doms.central.InvalidCredentialsException;
import dk.statsbiblioteket.doms.central.InvalidResourceException;
import dk.statsbiblioteket.doms.central.MethodFailedException;
import dk.statsbiblioteket.doms.transformers.common.DomsWebserviceFactory;
import dk.statsbiblioteket.doms.transformers.common.FFProbeLocationDomsConfig;
import dk.statsbiblioteket.doms.transformers.fileobjectcreator.MuxFileChannelCalculator;
import jsr166y.ForkJoinTask;
import jsr166y.RecursiveAction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;


public class FileObjectCreatorWorker extends RecursiveAction {
    private static Logger log = LoggerFactory.getLogger(FileObjectCreatorWorker.class);

    private MuxFileChannelCalculator muxFileChannelCalculator;
    private FFProbeLocationDomsConfig config;
    private ResultWriter resultWriter;
    private String baseUrl;
    private List<String> data;

    private static boolean shutdown = false;

    public FileObjectCreatorWorker(FFProbeLocationDomsConfig config,
                                   ResultWriter resultWriter,
                                   String baseUrl,
                                   List<String> data,
                                   MuxFileChannelCalculator muxFileChannelCalculator) {
        this.config = config;
        this.resultWriter = resultWriter;
        this.baseUrl = baseUrl;
        this.data = data;
        this.muxFileChannelCalculator = muxFileChannelCalculator;
    }

    @Override
    protected void compute() {
        if (data.size() == 1) {
            try {
                DomsObject domsObject = DomsFileParser.parse(config, baseUrl, data.get(0), muxFileChannelCalculator);
                if (domsObject != null) {
                    doWork(domsObject);
                } else {
                    resultWriter.logIgnored(data.get(0));
                }
            } catch (ParseException e) {
                log.info("Error while parsing: " + data.get(0));
            } catch (FileIgnoredException e) {
                log.info("Ignored file: " + e.getFilename());
            }
        } else if (permissionToRun()) {<commit_msg>FileObjectCreator: Fix broken fault barrier to some degree.<commit_after>package dk.statsbiblioteket.doms.transformers.fileobjectcreator;

import dk.statsbiblioteket.doms.central.CentralWebservice;
import dk.statsbiblioteket.doms.central.InvalidCredentialsException;
import dk.statsbiblioteket.doms.central.InvalidResourceException;
import dk.statsbiblioteket.doms.central.MethodFailedException;
import dk.statsbiblioteket.doms.transformers.common.DomsWebserviceFactory;
import dk.statsbiblioteket.doms.transformers.common.FFProbeLocationDomsConfig;
import dk.statsbiblioteket.doms.transformers.fileobjectcreator.MuxFileChannelCalculator;
import jsr166y.ForkJoinTask;
import jsr166y.RecursiveAction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;


public class FileObjectCreatorWorker extends RecursiveAction {
    private static Logger log = LoggerFactory.getLogger(FileObjectCreatorWorker.class);

    private MuxFileChannelCalculator muxFileChannelCalculator;
    private FFProbeLocationDomsConfig config;
    private ResultWriter resultWriter;
    private String baseUrl;
    private List<String> data;

    private static boolean shutdown = false;

    public FileObjectCreatorWorker(FFProbeLocationDomsConfig config,
                                   ResultWriter resultWriter,
                                   String baseUrl,
                                   List<String> data,
                                   MuxFileChannelCalculator muxFileChannelCalculator) {
        this.config = config;
        this.resultWriter = resultWriter;
        this.baseUrl = baseUrl;
        this.data = data;
        this.muxFileChannelCalculator = muxFileChannelCalculator;
    }

    @Override
    protected void compute() {
        if (data.size() == 1) {
            try {
                DomsObject domsObject = DomsFileParser.parse(config, baseUrl, data.get(0), muxFileChannelCalculator);
                if (domsObject != null) {
                    doWork(domsObject);
                } else {
                    resultWriter.logIgnored(data.get(0));
                }
            } catch (ParseException e) {
                log.info("Error while parsing: " + data.get(0));
            } catch (FileIgnoredException e) {
                log.info("Ignored file: " + e.getFilename());
            } catch (Exception e) {
                log.error("Well well, this was unexpected. I was just processing '{}' when this exception showed up :(", data.get(0), e);
            }
        } else if (permissionToRun()) {
{'fraction_non_alphanumeric': 0.07964774951076321, 'fraction_numerical': 0.004892367906066536, 'mean_word_length': 2.7498165810711663, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4633457', 'n_tokens_mistral': 1485, 'n_tokens_neox': 1389, 'n_words': 268}