This project has retired. For details please refer to its Attic page.
Source code
001package org.apache.archiva.converter.artifact;
002/*
003 * Licensed to the Apache Software Foundation (ASF) under one
004 * or more contributor license agreements.  See the NOTICE file
005 * distributed with this work for additional information
006 * regarding copyright ownership.  The ASF licenses this file
007 * to you under the Apache License, Version 2.0 (the
008 * "License"); you may not use this file except in compliance
009 * with the License.  You may obtain a copy of the License at
010 *
011 *  http://www.apache.org/licenses/LICENSE-2.0
012 *
013 * Unless required by applicable law or agreed to in writing,
014 * software distributed under the License is distributed on an
015 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
016 * KIND, either express or implied.  See the License for the
017 * specific language governing permissions and limitations
018 * under the License.
019 */
020
021import org.apache.maven.artifact.Artifact;
022import org.apache.maven.artifact.handler.ArtifactHandler;
023import org.apache.maven.artifact.metadata.ArtifactMetadata;
024import org.apache.maven.artifact.repository.ArtifactRepository;
025import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
026import org.codehaus.plexus.component.annotations.Component;
027
028/**
029 * @author jdcasey
030 */
031@Component( role = ArtifactRepositoryLayout.class, hint = "legacy")
032public class LegacyRepositoryLayout
033    implements ArtifactRepositoryLayout
034{
035
036    private static final String PATH_SEPARATOR = "/";
037
038    public String getId()
039    {
040        return "legacy";
041    }
042
043    @Override
044    public String pathOf( Artifact artifact )
045    {
046        ArtifactHandler artifactHandler = artifact.getArtifactHandler();
047
048        StringBuilder path = new StringBuilder( 128 );
049
050        path.append( artifact.getGroupId() ).append( '/' );
051        path.append( artifactHandler.getDirectory() ).append( '/' );
052        path.append( artifact.getArtifactId() ).append( '-' ).append( artifact.getVersion() );
053
054        if ( artifact.hasClassifier() )
055        {
056            path.append( '-' ).append( artifact.getClassifier() );
057        }
058
059        if ( artifactHandler.getExtension() != null && artifactHandler.getExtension().length() > 0 )
060        {
061            path.append( '.' ).append( artifactHandler.getExtension() );
062        }
063
064        return path.toString();
065    }
066
067    @Override
068    public String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository )
069    {
070        return pathOfRepositoryMetadata( metadata, metadata.getLocalFilename( repository ) );
071    }
072
073    private String pathOfRepositoryMetadata( ArtifactMetadata metadata, String filename )
074    {
075        StringBuilder path = new StringBuilder( 128 );
076
077        path.append( metadata.getGroupId() ).append( PATH_SEPARATOR ).append( "poms" ).append( PATH_SEPARATOR );
078
079        path.append( filename );
080
081        return path.toString();
082    }
083
084    @Override
085    public String pathOfRemoteRepositoryMetadata( ArtifactMetadata metadata )
086    {
087        return pathOfRepositoryMetadata( metadata, metadata.getRemoteFilename() );
088    }
089
090}