<commit_before>package io.hawt.aether;

import io.hawt.config.ConfigFacade;
import io.hawt.config.URLHandler;
import io.hawt.util.MBeanSupport;
import io.hawt.util.Strings;
import org.apache.maven.repository.internal.MavenRepositorySystemSession;
import org.codehaus.plexus.DefaultPlexusContainer;
import org.codehaus.plexus.PlexusContainerException;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonatype.aether.RepositorySystem;
import org.sonatype.aether.RepositorySystemSession;
import org.sonatype.aether.artifact.Artifact;
import org.sonatype.aether.collection.CollectRequest;
import org.sonatype.aether.collection.DependencyCollectionException;
import org.sonatype.aether.graph.Dependency;
import org.sonatype.aether.graph.DependencyNode;
import org.sonatype.aether.repository.Authentication;
import org.sonatype.aether.repository.LocalRepository;
import org.sonatype.aether.repository.RemoteRepository;
import org.sonatype.aether.repository.RepositoryPolicy;
import org.sonatype.aether.resolution.ArtifactRequest;
import org.sonatype.aether.resolution.ArtifactResolutionException;
import org.sonatype.aether.resolution.ArtifactResult;
import org.sonatype.aether.resolution.DependencyRequest;
import org.sonatype.aether.resolution.DependencyResolutionException;
import org.sonatype.aether.util.artifact.DefaultArtifact;
import org.sonatype.aether.util.graph.PreorderNodeListGenerator;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * A facade for working with Aether over JMX
 */
public class AetherFacade extends MBeanSupport implements AetherFacadeMXBean {
    private static final transient Logger LOG = LoggerFactory.getLogger(AetherFacade.class);

    public static final String AETHER_MBEAN_NAME = "hawtio:type=AetherFacade";
    protected static String DEFAULT_EXTENSION = "jar";
    protected static String DEFAULT_CLASSIFIER = "";

    private LocalRepository localRepository;
    private String localRepoDir;
    private RepositorySystem repositorySystem;
    private List<RemoteRepository> remoteRepositories;
    private List<RemoteRepository> defaultRemoteRepositories = Arrays.asList(
            new RemoteRepository("central", "default", "http://repo2.maven.org/maven2/"),
            new RemoteRepository("public.fusesource.com", "default", "http://repo.fusesource.com/nexus/content/groups/public"),
            new RemoteRepository("snapshots.fusesource.com", "default", "http://repo.fusesource.com/nexus/content/groups/public-snapshots"),
            new RemoteRepository("public.sonatype.com", "default", "https://oss.sonatype.org/content/groups/public"),
            new RemoteRepository("maven1.java.net", "default", "http://download.java.net/maven/1"),
            //new RemoteRepository("maven2.jboss.org", "default", "http://repository.jboss.org/maven2"),
            new RemoteRepository("com.springsource.repository.bundles.release", "default", "http://repository.springsource.com/maven/bundles/release"),
            new RemoteRepository("com.springsource.repository.bundles.external", "default", "http://repository.springsource.com/maven/bundles/external"),
            new RemoteRepository("com.springsource.repository.libraries.release", "default", "http://repository.springsource.com/maven/libraries/release"),
            new RemoteRepository("com.springsource.repository.libraries.external", "default", "http://repository.springsource.com/maven/libraries/external")
    );

    @Override
    public void init() throws Exception {
        ConfigFacade.getSingleton().addUrlHandler("mvn", new URLHandler() {
            @Override
            public InputStream openStream(String url) {
                try {
                    return new OpenMavenURL(url).getInputStream();
                } catch (MalformedURLException e) {
                    throw new IllegalArgumentException("Could not parse URL: " + url + ". " + e, e);
                } catch (IOException e) {
                    throw new IllegalArgumentException("Could not read URL: " + url + ". " + e, e);
                }
            }
        });
        super.init();
    }

    @Override
    public String resolveArtifactUrlToFileName(String mvnUrl) throws MalformedURLException, ComponentLookupException, DependencyCollectionException, PlexusContainerException, DependencyResolutionException, ArtifactResolutionException {
        MavenURL mavenUrl = new MavenURL(mvnUrl);
        ArtifactResult result = resolveArtifact(mavenUrl.getGroup(), mavenUrl.getArtifact(), mavenUrl.getVersion(), mavenUrl.getType(), mavenUrl.getClassifier());
        return artifactResultToFilePath(result);
    }<commit_msg>add extra debugging if a download fails<commit_after>package io.hawt.aether;

import io.hawt.config.ConfigFacade;
import io.hawt.config.URLHandler;
import io.hawt.util.MBeanSupport;
import io.hawt.util.Strings;
import org.apache.maven.repository.internal.MavenRepositorySystemSession;
import org.codehaus.plexus.DefaultPlexusContainer;
import org.codehaus.plexus.PlexusContainerException;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonatype.aether.RepositorySystem;
import org.sonatype.aether.RepositorySystemSession;
import org.sonatype.aether.artifact.Artifact;
import org.sonatype.aether.collection.CollectRequest;
import org.sonatype.aether.collection.DependencyCollectionException;
import org.sonatype.aether.graph.Dependency;
import org.sonatype.aether.graph.DependencyNode;
import org.sonatype.aether.repository.Authentication;
import org.sonatype.aether.repository.LocalRepository;
import org.sonatype.aether.repository.RemoteRepository;
import org.sonatype.aether.repository.RepositoryPolicy;
import org.sonatype.aether.resolution.ArtifactRequest;
import org.sonatype.aether.resolution.ArtifactResolutionException;
import org.sonatype.aether.resolution.ArtifactResult;
import org.sonatype.aether.resolution.DependencyRequest;
import org.sonatype.aether.resolution.DependencyResolutionException;
import org.sonatype.aether.util.artifact.DefaultArtifact;
import org.sonatype.aether.util.graph.PreorderNodeListGenerator;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * A facade for working with Aether over JMX
 */
public class AetherFacade extends MBeanSupport implements AetherFacadeMXBean {
    private static final transient Logger LOG = LoggerFactory.getLogger(AetherFacade.class);

    public static final String AETHER_MBEAN_NAME = "hawtio:type=AetherFacade";
    protected static String DEFAULT_EXTENSION = "jar";
    protected static String DEFAULT_CLASSIFIER = "";

    private LocalRepository localRepository;
    private String localRepoDir;
    private RepositorySystem repositorySystem;
    private List<RemoteRepository> remoteRepositories;
    private List<RemoteRepository> defaultRemoteRepositories = Arrays.asList(
            new RemoteRepository("central", "default", "http://repo2.maven.org/maven2/"),
            new RemoteRepository("public.fusesource.com", "default", "http://repo.fusesource.com/nexus/content/groups/public"),
            new RemoteRepository("snapshots.fusesource.com", "default", "http://repo.fusesource.com/nexus/content/groups/public-snapshots"),
            new RemoteRepository("public.sonatype.com", "default", "https://oss.sonatype.org/content/groups/public"),
            new RemoteRepository("maven1.java.net", "default", "http://download.java.net/maven/1"),
            //new RemoteRepository("maven2.jboss.org", "default", "http://repository.jboss.org/maven2"),
            new RemoteRepository("com.springsource.repository.bundles.release", "default", "http://repository.springsource.com/maven/bundles/release"),
            new RemoteRepository("com.springsource.repository.bundles.external", "default", "http://repository.springsource.com/maven/bundles/external"),
            new RemoteRepository("com.springsource.repository.libraries.release", "default", "http://repository.springsource.com/maven/libraries/release"),
            new RemoteRepository("com.springsource.repository.libraries.external", "default", "http://repository.springsource.com/maven/libraries/external")
    );

    @Override
    public void init() throws Exception {
        ConfigFacade.getSingleton().addUrlHandler("mvn", new URLHandler() {
            @Override
            public InputStream openStream(String url) {
                try {
                    return new OpenMavenURL(url).getInputStream();
                } catch (MalformedURLException e) {
                    throw new IllegalArgumentException("Could not parse URL: " + url + " for remote URLs " + getRemoteUrlsText() + ". " + e, e);
                } catch (IOException e) {
                    throw new IllegalArgumentException("Could not read URL: " + url + " for remote URLs " + getRemoteUrlsText() + ". " + e, e);
                }
            }
        });
        super.init();
    }

    protected String getRemoteUrlsText() {
        StringBuilder buffer = new StringBuilder();
        List<RemoteRepository> list = getRemoteRepositories();
        for (RemoteRepository repo : list) {
            String url = repo.getUrl();
            if (Strings.isNotBlank(url)) {
                if (buffer.length() > 0) {
                    buffer.append(", ");
                }
                buffer.append(url);
            }
        }
        return buffer.toString();
    }

    @Override
    public String resolveArtifactUrlToFileName(String mvnUrl) throws MalformedURLException, ComponentLookupException, DependencyCollectionException, PlexusContainerException, DependencyResolutionException, ArtifactResolutionException {
        MavenURL mavenUrl = new MavenURL(mvnUrl);
        ArtifactResult result = resolveArtifact(mavenUrl.getGroup(), mavenUrl.getArtifact(), mavenUrl.getVersion(), mavenUrl.getType(), mavenUrl.getClassifier());
        return artifactResultToFilePath(result);
    }
{'fraction_non_alphanumeric': 0.10825387652894154, 'fraction_numerical': 0.0016372917268612155, 'mean_word_length': 4.085210577864839, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7658313', 'n_tokens_mistral': 2859, 'n_tokens_neox': 2798, 'n_words': 510}