1 package org.apache.maven.archiva.repository.content;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import org.apache.maven.archiva.repository.ArchivaArtifact;
24 import java.util.HashMap;
28 * LegacyBidirectionalRepositoryLayout - the layout mechanism for use by Maven 1.x repositories.
30 * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
33 * @plexus.component role="org.apache.maven.archiva.repository.content.BidirectionalRepositoryLayout"
36 public class LegacyBidirectionalRepositoryLayout implements BidirectionalRepositoryLayout
38 private static final String PATH_SEPARATOR = "/";
40 private ArtifactExtensionMapping extensionMapper = new LegacyArtifactExtensionMapping();
42 private Map typeToDirectoryMap;
44 public LegacyBidirectionalRepositoryLayout()
46 typeToDirectoryMap = new HashMap();
47 typeToDirectoryMap.put( "ejb-client", "ejb" );
48 typeToDirectoryMap.put( "distribution-tgz", "distribution" );
49 typeToDirectoryMap.put( "distribution-zip", "distribution" );
57 public String pathOf( ArchivaArtifact artifact )
59 StringBuffer path = new StringBuffer();
61 path.append( artifact.getGroupId() ).append( PATH_SEPARATOR );
62 path.append( getDirectory( artifact ) ).append( PATH_SEPARATOR );
63 path.append( artifact.getArtifactId() ).append( '-' ).append( artifact.getVersion() );
65 if ( artifact.hasClassifier() )
67 path.append( '-' ).append( artifact.getClassifier() );
70 path.append( '.' ).append( extensionMapper.getExtension( artifact ) );
72 return path.toString();
75 private String getDirectory( ArchivaArtifact artifact )
77 // Special Cases involving classifiers and type.
78 if ( "jar".equals( artifact.getType() ) && "sources".equals( artifact.getClassifier() ) )
80 return "javadoc.jars";
83 // Special Cases involving only type.
84 String dirname = (String) typeToDirectoryMap.get( artifact.getType() );
86 if ( dirname != null )
92 return artifact.getType() + "s";
95 public ArchivaArtifact toArtifact( String path )
97 // TODO Auto-generated method stub