<commit_before>/*
 * Copyright (C) 2016 the original author or authors.
 *
 * This file is part of jBB Application Project.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  You may obtain a copy of the License at
 *        http://www.apache.org/licenses/LICENSE-2.0
 */

package org.jbb.lib.properties;

import com.google.common.base.Throwables;

import org.apache.commons.lang3.StringUtils;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;


public final class JbbHomePath {
    private static final String DEFAULT_JBB_HOME_PATH = System.getProperty("user.home") + "/jbb";
    private static final String ENV_JBB_HOME_PATH = System.getenv("JBB_HOME");
    private static final String EFFECTIVE_JBB_HOME_PATH_KEY = "<KEY>";

    private JbbHomePath() {
        // util class..
    }

    public static void resolveEffectiveAndStoreToSystemProperty() {
        //TODO check in JNDI first
        if (StringUtils.isNotEmpty(ENV_JBB_HOME_PATH)) {
            setSystemProperty(ENV_JBB_HOME_PATH);
        } else {
            setSystemProperty(DEFAULT_JBB_HOME_PATH);
        }
    }

    private static void setSystemProperty(String jbbPath) {
        System.setProperty(EFFECTIVE_JBB_HOME_PATH_KEY, jbbPath);
    }

    public static String getEffective() {
        return System.getProperty(EFFECTIVE_JBB_HOME_PATH_KEY);
    }

    public static void createIfNotExists() {
        try {
            Path jbbPath = Paths.get(JbbHomePath.getEffective());
            if (Files.notExists(jbbPath)) {
                Files.createDirectory(jbbPath);
            }
        } catch (IOException e) {
            Throwables.propagate(e);
        }
    }
}<commit_msg>Another check: is a jbbHomePath a directory<commit_after>/*
 * Copyright (C) 2016 the original author or authors.
 *
 * This file is part of jBB Application Project.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  You may obtain a copy of the License at
 *        http://www.apache.org/licenses/LICENSE-2.0
 */

package org.jbb.lib.properties;

import com.google.common.base.Throwables;

import org.apache.commons.lang.Validate;
import org.apache.commons.lang3.StringUtils;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;


public final class JbbHomePath {
    private static final String DEFAULT_JBB_HOME_PATH = System.getProperty("user.home") + "/jbb";
    private static final String ENV_JBB_HOME_PATH = System.getenv("JBB_HOME");
    private static final String EFFECTIVE_JBB_HOME_PATH_KEY = "<KEY>";

    private JbbHomePath() {
        // util class..
    }

    public static void resolveEffectiveAndStoreToSystemProperty() {
        //TODO check in JNDI first
        if (StringUtils.isNotEmpty(ENV_JBB_HOME_PATH)) {
            setSystemProperty(ENV_JBB_HOME_PATH);
        } else {
            setSystemProperty(DEFAULT_JBB_HOME_PATH);
        }
    }

    private static void setSystemProperty(String jbbPath) {
        System.setProperty(EFFECTIVE_JBB_HOME_PATH_KEY, jbbPath);
    }

    public static String getEffective() {
        return System.getProperty(EFFECTIVE_JBB_HOME_PATH_KEY);
    }

    public static void createIfNotExists() {
        try {
            Path jbbPath = Paths.get(JbbHomePath.getEffective());
            if (Files.notExists(jbbPath)) {
                Files.createDirectory(jbbPath);
            }
            Validate.isTrue(Files.isDirectory(jbbPath), String.format("%s is not a directory!", jbbPath));
        } catch (IOException e) {
            Throwables.propagate(e);
        }
    }
}
{'fraction_non_alphanumeric': 0.0979858464888405, 'fraction_numerical': 0.004899292324442025, 'mean_word_length': 2.888888888888889, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3877740', 'n_tokens_mistral': 1135, 'n_tokens_neox': 1118, 'n_words': 253}