@@ -0,0 +1,3230 @@
+/*-%0A * Copyright (c) 2014 Red Hat, Inc.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage org.fedoraproject.xmvn.resolver.impl;%0A%0Aimport java.nio.file.Path;%0Aimport java.nio.file.Paths;%0A%0Aimport javax.inject.Named;%0Aimport javax.inject.Singleton;%0A%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0Aimport org.fedoraproject.xmvn.artifact.Artifact;%0Aimport org.fedoraproject.xmvn.metadata.ArtifactMetadata;%0Aimport org.fedoraproject.xmvn.resolver.ResolutionRequest;%0Aimport org.fedoraproject.xmvn.resolver.ResolutionResult;%0Aimport org.fedoraproject.xmvn.resolver.Resolver;%0Aimport org.fedoraproject.xmvn.utils.FileUtils;%0A%0A/**%0A * Default implementation of XMvn %7B@code Resolver%7D interface.%0A * %3Cp%3E%0A * %3Cstrong%3EWARNING%3C/strong%3E: This class is part of internal implementation of XMvn and it is marked as public only for%0A * technical reasons. This class is not part of XMvn API. Client code using XMvn should %3Cstrong%3Enot%3C/strong%3E reference%0A * it directly.%0A * %0A * @author Mikolaj Izdebski%0A */%0A@Named%0A@Singleton%0Apublic class DefaultResolver%0A    implements Resolver%0A%7B%0A    private final Logger logger = LoggerFactory.getLogger( DefaultResolver.class );%0A%0A    private MetadataResolver metadataResolver;%0A%0A    private static final RpmDb rpmdb = new RpmDb();%0A%0A    @Override%0A    public ResolutionResult resolve( ResolutionRequest request )%0A    %7B%0A        // FIXME: bisect is not used%0A        Artifact artifact = request.getArtifact();%0A        logger.debug( %22Trying to resolve artifact %7B%7D%22, artifact );%0A%0A        String compatVersion;%0A        ArtifactMetadata metadata = metadataResolver.resolveArtifactMetadata( artifact );%0A%0A        if ( metadata == null )%0A        %7B%0A            metadata = metadataResolver.resolveArtifactMetadata( artifact.setVersion( Artifact.DEFAULT_VERSION ) );%0A            compatVersion = null;%0A        %7D%0A        else%0A        %7B%0A            compatVersion = artifact.getVersion();%0A        %7D%0A%0A        if ( metadata != null )%0A        %7B%0A            // TODO: interpolate paths to expand variables like Java home%0A            Path artifactPath = Paths.get( metadata.getPath() );%0A            artifactPath = FileUtils.followSymlink( artifactPath );%0A%0A            DefaultResolutionResult result = new DefaultResolutionResult( artifactPath );%0A            result.setNamespace( metadata.getNamespace() );%0A            result.setCompatVersion( compatVersion );%0A            if ( request.isProviderNeeded() )%0A                result.setProvider( rpmdb.lookupPath( artifactPath ) );%0A%0A            logger.debug( %22Artifact %7B%7D was resolved to %7B%7D%22, artifact, artifactPath );%0A            return result;%0A        %7D%0A%0A        logger.debug( %22Failed to resolve artifact: %7B%7D%22, artifact );%0A        return new DefaultResolutionResult();%0A    %7D%0A%7D%0A

Implement DefaultResolver