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;
026
027/**
028 * @author jdcasey
029 */
030public class LegacyRepositoryLayout
031    implements ArtifactRepositoryLayout
032{
033
034    private static final String PATH_SEPARATOR = "/";
035
036    public String getId()
037    {
038        return "legacy";
039    }
040
041    @Override
042    public String pathOf( Artifact artifact )
043    {
044        ArtifactHandler artifactHandler = artifact.getArtifactHandler();
045
046        StringBuilder path = new StringBuilder( 128 );
047
048        path.append( artifact.getGroupId() ).append( '/' );
049        path.append( artifactHandler.getDirectory() ).append( '/' );
050        path.append( artifact.getArtifactId() ).append( '-' ).append( artifact.getVersion() );
051
052        if ( artifact.hasClassifier() )
053        {
054            path.append( '-' ).append( artifact.getClassifier() );
055        }
056
057        if ( artifactHandler.getExtension() != null && artifactHandler.getExtension().length() > 0 )
058        {
059            path.append( '.' ).append( artifactHandler.getExtension() );
060        }
061
062        return path.toString();
063    }
064
065    @Override
066    public String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository )
067    {
068        return pathOfRepositoryMetadata( metadata, metadata.getLocalFilename( repository ) );
069    }
070
071    private String pathOfRepositoryMetadata( ArtifactMetadata metadata, String filename )
072    {
073        StringBuilder path = new StringBuilder( 128 );
074
075        path.append( metadata.getGroupId() ).append( PATH_SEPARATOR ).append( "poms" ).append( PATH_SEPARATOR );
076
077        path.append( filename );
078
079        return path.toString();
080    }
081
082    @Override
083    public String pathOfRemoteRepositoryMetadata( ArtifactMetadata metadata )
084    {
085        return pathOfRepositoryMetadata( metadata, metadata.getRemoteFilename() );
086    }
087
088}