<commit_before>package org.carlspring.strongbox.artifact.locator;

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

import org.carlspring.strongbox.artifact.locator.handlers.ArtifactDirectoryOperation;
import org.carlspring.strongbox.providers.io.RepositoryPath;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author mtodorov
 */
public class ArtifactDirectoryLocator
{

    private static final Logger logger = LoggerFactory.getLogger(ArtifactDirectoryLocator.class);

    private ArtifactDirectoryOperation operation;

    /**
     * The basedir to start analyzing from. Define this only, if you need to pass null values for operation.storage and
     * operation.repository.
     */
    private RepositoryPath basedir;

    public void locateArtifactDirectories()
        throws IOException
    {
        long startTime = System.currentTimeMillis();

        Files.walk(getStartingPath())
             .filter(Files::isDirectory)
             // Skip directories which start with a dot (like, for example: .index)
             .filter(path -> !(path.getNameCount() == 0 ? path.toString() : path.getName(path.getNameCount() - 1)).toString().startsWith("."))
             // Note: Sorting can be expensive:
             .sorted()
             .forEach(this::execute);

        long endTime = System.currentTimeMillis();

        logger.debug("Executed (cache: " + operation.getVisitedRootPaths().size() + ")" +
                     " visits in " + (endTime - startTime) + " ms.");

        getOperation().getVisitedRootPaths().clear();
    }

    public RepositoryPath getStartingPath()
    {
        // The root path
        RepositoryPath rootPath = basedir != null ? basedir : getOperation().getBasePath();
        rootPath = rootPath.normalize();

        logger.debug(String.format("ArtifactDirectoryLocator started in: path-[%s]", rootPath));

        return Files.isDirectory(rootPath) ? rootPath : rootPath.getParent();
    }

    public ArtifactDirectoryOperation getOperation()
    {
        return operation;
    }

    public void setOperation(ArtifactDirectoryOperation operation)
    {
        this.operation = operation;<commit_msg>SB-791: tests fixed<commit_after>package org.carlspring.strongbox.artifact.locator;

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

import org.carlspring.strongbox.artifact.locator.handlers.ArtifactDirectoryOperation;
import org.carlspring.strongbox.providers.io.RepositoryPath;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author mtodorov
 */
public class ArtifactDirectoryLocator
{

    private static final Logger logger = LoggerFactory.getLogger(ArtifactDirectoryLocator.class);

    private ArtifactDirectoryOperation operation;

    /**
     * The basedir to start analyzing from. Define this only, if you need to pass null values for operation.storage and
     * operation.repository.
     */
    private RepositoryPath basedir;

    public void locateArtifactDirectories()
        throws IOException
    {
        long startTime = System.currentTimeMillis();

        Files.walk(getStartingPath())
             .filter(Files::isDirectory)
             // Skip directories which start with a dot (like, for example: .index)
             .filter(path -> !(path.getNameCount() == 0 ? path.toString() : path.getName(path.getNameCount() - 1)).toString().startsWith("."))
             // Note: Sorting can be expensive:
             .sorted()
             .forEach(this::execute);

        long endTime = System.currentTimeMillis();

        logger.debug("Executed (cache: " + operation.getVisitedRootPaths().size() + ")" +
                     " visits in " + (endTime - startTime) + " ms.");

        getOperation().getVisitedRootPaths().clear();
    }

    public RepositoryPath getStartingPath()
    {
        // The root path
        RepositoryPath rootPath = basedir != null ? basedir : getOperation().getBasePath().getFileSystem().getRootDirectory();
        rootPath = rootPath.resolve(getOperation().getBasePath());
        rootPath = rootPath.normalize();

        logger.debug(String.format("ArtifactDirectoryLocator started in: path-[%s]", rootPath));

        return Files.isDirectory(rootPath) ? rootPath : rootPath.getParent();
    }

    public ArtifactDirectoryOperation getOperation()
    {
        return operation;
    }

    public void setOperation(ArtifactDirectoryOperation operation)
    {
        this.operation = operation;
{'fraction_non_alphanumeric': 0.11037234042553191, 'fraction_numerical': 0.0024379432624113476, 'mean_word_length': 3.0475336322869957, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3529800', 'n_tokens_mistral': 1233, 'n_tokens_neox': 1187, 'n_words': 269}