protected static MediaType processResult(FileProcessResult result, Metadata metadata,
                                             boolean returnMime) {
        metadata.set(ExternalProcess.EXIT_VALUE, result.getExitValue());
        metadata.set(ExternalProcess.IS_TIMEOUT, result.isTimeout());

        if (result.isTimeout()) {
            metadata.set(MAGIKA_STATUS, STATUS.TIMEOUT.name());
            return MediaType.OCTET_STREAM;
        }
        if (result.getExitValue() != 0) {
            metadata.set(MAGIKA_STATUS, STATUS.CRASH.name());
            return MediaType.OCTET_STREAM;
        }
        JsonNode rootArray;
        try {
            rootArray = OBJECT_MAPPER.readTree(result.getStdout());
        } catch (JsonProcessingException e) {
            metadata.set(MAGIKA_STATUS, STATUS.JSON_PARSE_EXCEPTION.name());
            return MediaType.OCTET_STREAM;
        }
        if (! rootArray.isArray() || rootArray.isEmpty()) {
            //something went wrong
            return MediaType.OCTET_STREAM;
        }
        //for now just take the first value
        JsonNode root = rootArray.get(0);
        //this is the more modern version
        if (root.has("result")) {
            return processNewer(root.get("result"), metadata, returnMime);
        } else {
            return processOlder(root, metadata, returnMime);
        }
    }
As default behavior, Tika runs magika to add its detection
to the metadata, but NOT to use detection in determining parsers
etc.  If this is set to <code>true</code>, this detector
will return the first mime detected by magika and that
mime will be used by the AutoDetectParser to select the appropriate
parser.

@param useMime
tika-detectors/tika-detector-magika/src/main/java/org/apache/tika/detect/magika/MagikaDetector.java