001package org.apache.maven.artifact.repository.metadata;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 *  http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022import java.util.Iterator;
023import java.util.List;
024
025import org.apache.maven.artifact.repository.ArtifactRepository;
026
027/**
028 * Metadata for the group directory of the repository.
029 * Class copied from maven-compat for to remove dependency but keep compatibility with Maven 3 (and Nexus Staging
030 * Plugin, see <a href="https://issues.apache.org/jira/browse/MPLUGIN-384">MPLUGIN-384</a>)
031 *
032 * @author <a href="mailto:brett@apache.org">Brett Porter</a>
033 */
034public class GroupRepositoryMetadata
035    extends AbstractRepositoryMetadata
036{
037    private final String groupId;
038
039    public GroupRepositoryMetadata( String groupId )
040    {
041        super( new Metadata() );
042        this.groupId = groupId;
043    }
044
045    public boolean storedInGroupDirectory()
046    {
047        return true;
048    }
049
050    public boolean storedInArtifactVersionDirectory()
051    {
052        return false;
053    }
054
055    public String getGroupId()
056    {
057        return groupId;
058    }
059
060    public String getArtifactId()
061    {
062        return null;
063    }
064
065    public String getBaseVersion()
066    {
067        return null;
068    }
069
070    public void addPluginMapping( String goalPrefix,
071                                  String artifactId )
072    {
073        addPluginMapping( goalPrefix, artifactId, artifactId );
074    }
075
076    public void addPluginMapping( String goalPrefix,
077                                  String artifactId,
078                                  String name )
079    {
080        List<Plugin> plugins = getMetadata().getPlugins();
081        boolean found = false;
082        for ( Iterator<Plugin> i = plugins.iterator(); i.hasNext() && !found; )
083        {
084            Plugin plugin = i.next();
085            if ( plugin.getPrefix().equals( goalPrefix ) )
086            {
087                found = true;
088            }
089        }
090        if ( !found )
091        {
092            Plugin plugin = new Plugin();
093            plugin.setPrefix( goalPrefix );
094            plugin.setArtifactId( artifactId );
095            plugin.setName( name );
096
097
098            getMetadata().addPlugin( plugin );
099        }
100    }
101
102    public Object getKey()
103    {
104        return groupId;
105    }
106
107    public boolean isSnapshot()
108    {
109        return false;
110    }
111
112    public ArtifactRepository getRepository()
113    {
114        return null;
115    }
116
117    public void setRepository( ArtifactRepository remoteRepository )
118    {
119        // intentionally blank
120    }
121}