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;
25 * DefaultBidirectionalRepositoryLayout - the layout mechanism for use by Maven 2.x repositories.
27 * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
30 * @plexus.component role="org.apache.maven.archiva.repository.content.BidirectionalRepositoryLayout"
33 public class DefaultBidirectionalRepositoryLayout implements BidirectionalRepositoryLayout
35 private static final char PATH_SEPARATOR = '/';
37 private static final char GROUP_SEPARATOR = '.';
39 private static final char ARTIFACT_SEPARATOR = '-';
41 private ArtifactExtensionMapping extensionMapper = new DefaultArtifactExtensionMapping();
48 public String pathOf( ArchivaArtifact artifact )
50 StringBuffer path = new StringBuffer();
52 path.append( formatAsDirectory( artifact.getGroupId() ) ).append( PATH_SEPARATOR );
53 path.append( artifact.getArtifactId() ).append( PATH_SEPARATOR );
54 path.append( artifact.getBaseVersion() ).append( PATH_SEPARATOR );
55 path.append( artifact.getArtifactId() ).append( ARTIFACT_SEPARATOR ).append( artifact.getVersion() );
57 if ( artifact.hasClassifier() )
59 path.append( ARTIFACT_SEPARATOR ).append( artifact.getClassifier() );
62 path.append( GROUP_SEPARATOR ).append( extensionMapper.getExtension( artifact ) );
64 return path.toString();
67 private String formatAsDirectory( String directory )
69 return directory.replace( GROUP_SEPARATOR, PATH_SEPARATOR );
72 public ArchivaArtifact toArtifact( String path )