<commit_before>package com.imcode.imcms.persistence.components;

import java.io.IOException;
import java.net.ProtocolException;
import java.net.URI;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.Path;
import java.nio.file.Paths;

import static java.util.Collections.singletonMap;

/**
 * Provides possibility to dynamically resolve SQL resources path no matter
 * is it in jar file or not.
 */
public class SqlResourcePathResolver implements AutoCloseable {

    private final URI sqlResourceDirectoryURI;

    private FileSystem jarFileSystem;

    public SqlResourcePathResolver(URI sqlResourceDirectoryURI) {
        this.sqlResourceDirectoryURI = sqlResourceDirectoryURI;
    }

    public Path resolveSqlResourceSubPath(String subPath) throws IOException {
        return resolveSqlResourcePath().resolve(subPath);
    }

    public Path resolveSqlResourcePath() throws IOException {
        final String protocol = sqlResourceDirectoryURI.getScheme();
        switch (protocol) {
            case "file":
                return Paths.get(sqlResourceDirectoryURI);
            case "jar":
                jarFileSystem = FileSystems.newFileSystem(sqlResourceDirectoryURI, singletonMap("create", true));
                return jarFileSystem.getPath("sql");
            default:
                throw new ProtocolException("Unsupported protocol - " + protocol);
        }
    }
<commit_msg>IMCMS-255 - Upgrade server side to work with new client: - Getting filesystem is such is created.<commit_after>package com.imcode.imcms.persistence.components;

import java.io.IOException;
import java.net.ProtocolException;
import java.net.URI;
import java.nio.file.*;

import static java.util.Collections.singletonMap;

/**
 * Provides possibility to dynamically resolve SQL resources path no matter
 * is it in jar file or not.
 */
public class SqlResourcePathResolver implements AutoCloseable {

    private final URI sqlResourceDirectoryURI;

    private FileSystem jarFileSystem;

    public SqlResourcePathResolver(URI sqlResourceDirectoryURI) {
        this.sqlResourceDirectoryURI = sqlResourceDirectoryURI;
    }

    public Path resolveSqlResourceSubPath(String subPath) throws IOException {
        return resolveSqlResourcePath().resolve(subPath);
    }

    public Path resolveSqlResourcePath() throws IOException {
        final String protocol = sqlResourceDirectoryURI.getScheme();
        switch (protocol) {
            case "file":
                return Paths.get(sqlResourceDirectoryURI);
            case "jar":
                try {
                    jarFileSystem = FileSystems.newFileSystem(sqlResourceDirectoryURI, singletonMap("create", true));
                } catch (FileSystemAlreadyExistsException e) {
                    jarFileSystem = FileSystems.getFileSystem(sqlResourceDirectoryURI);
                }
                return jarFileSystem.getPath("sql");
            default:
                throw new ProtocolException("Unsupported protocol - " + protocol);
        }
    }

{'fraction_non_alphanumeric': 0.07571288102261553, 'fraction_numerical': 0.0009832841691248771, 'mean_word_length': 3.1021505376344085, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1569358', 'n_tokens_mistral': 759, 'n_tokens_neox': 729, 'n_words': 194}