// Path: spi/src/main/java/com/redhat/ceylon/cmr/spi/Node.java
// public interface Node {
//     String getLabel();
// 
//     <T> T getValue(Class<T> valueType);
// 
//     Node getChild(String label);
// 
//     Iterable<? extends Node> getChildren();
// 
//     boolean hasBinaries();
// 
//     /**
//      * @deprecated see getSizedInputStream
//      */
//     InputStream getInputStream() throws IOException;
// 
//     SizedInputStream getSizedInputStream() throws IOException;
// 
//     <T> T getContent(Class<T> contentType) throws IOException;
// 
//     long getLastModified() throws IOException;
// 
//     long getSize() throws IOException;
// 
//     Node getParent(String label);
// 
//     Iterable<? extends Node> getParents();
// 
//     boolean isRemote();
// 
//     String getDisplayString();
// 
//     String getStoreDisplayString();
// }


import java.io.File;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import com.redhat.ceylon.cmr.spi.Node;
import com.redhat.ceylon.common.log.Logger;
import com.redhat.ceylon.model.cmr.ArtifactResult;
import com.redhat.ceylon.model.cmr.RepositoryException;

    public File[] resolve(String name, String version) throws RepositoryException {
        final ArtifactContext context = new ArtifactContext(name, version);
        return resolve(context);
    }

    public File[] resolve(ArtifactContext context) throws RepositoryException {
        final ArtifactResult result = getArtifactResult(context);
        return flatten(result);
    }

    public File getArtifact(String name, String version) throws RepositoryException {
        ArtifactContext context = new ArtifactContext();
        context.setName(name);
        context.setVersion(version);
        return getArtifact(context);
    }

    public File getArtifact(ArtifactContext context) throws RepositoryException {
        final ArtifactResult result = getArtifactResult(context);
        return (result != null) ? result.artifact() : null;
    }

    public ArtifactResult getArtifactResult(String name, String version) throws RepositoryException {
        ArtifactContext context = new ArtifactContext();
        context.setName(name);
        context.setVersion(version);
        return getArtifactResult(context);
    }

// Path: spi/src/main/java/com/redhat/ceylon/cmr/spi/Node.java
// public interface Node {
//     String getLabel();
// 
//     <T> T getValue(Class<T> valueType);
// 
//     Node getChild(String label);
// 
//     Iterable<? extends Node> getChildren();
// 
//     boolean hasBinaries();
// 
//     /**
//      * @deprecated see getSizedInputStream
//      */
//     InputStream getInputStream() throws IOException;
// 
//     SizedInputStream getSizedInputStream() throws IOException;
// 
//     <T> T getContent(Class<T> contentType) throws IOException;
// 
//     long getLastModified() throws IOException;
// 
//     long getSize() throws IOException;
// 
//     Node getParent(String label);
// 
//     Iterable<? extends Node> getParents();
// 
//     boolean isRemote();
// 
//     String getDisplayString();
// 
//     String getStoreDisplayString();
// }


// Path: api/src/main/java/com/redhat/ceylon/cmr/api/AbstractRepositoryManager.java
import java.io.File;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import com.redhat.ceylon.cmr.spi.Node;
import com.redhat.ceylon.common.log.Logger;
import com.redhat.ceylon.model.cmr.ArtifactResult;
import com.redhat.ceylon.model.cmr.RepositoryException;


    public File[] resolve(String name, String version) throws RepositoryException {
        final ArtifactContext context = new ArtifactContext(name, version);
        return resolve(context);
    }

    public File[] resolve(ArtifactContext context) throws RepositoryException {
        final ArtifactResult result = getArtifactResult(context);
        return flatten(result);
    }

    public File getArtifact(String name, String version) throws RepositoryException {
        ArtifactContext context = new ArtifactContext();
        context.setName(name);
        context.setVersion(version);
        return getArtifact(context);
    }

    public File getArtifact(ArtifactContext context) throws RepositoryException {
        final ArtifactResult result = getArtifactResult(context);
        return (result != null) ? result.artifact() : null;
    }

    public ArtifactResult getArtifactResult(String name, String version) throws RepositoryException {
        ArtifactContext context = new ArtifactContext();
        context.setName(name);
        context.setVersion(version);
        return getArtifactResult(context);
    }

    protected ArtifactResult getFolder(ArtifactContext context, Node node) throws RepositoryException {