001 package 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
022 import org.apache.maven.artifact.repository.ArtifactRepository;
023
024 import java.util.Iterator;
025 import java.util.List;
026
027 /**
028 * Metadata for the group directory of the repository.
029 *
030 * @author <a href="mailto:brett@apache.org">Brett Porter</a>
031 */
032 public class GroupRepositoryMetadata
033 extends AbstractRepositoryMetadata
034 {
035 private final String groupId;
036
037 public GroupRepositoryMetadata( String groupId )
038 {
039 super( new Metadata() );
040 this.groupId = groupId;
041 }
042
043 public boolean storedInGroupDirectory()
044 {
045 return true;
046 }
047
048 public boolean storedInArtifactVersionDirectory()
049 {
050 return false;
051 }
052
053 public String getGroupId()
054 {
055 return groupId;
056 }
057
058 public String getArtifactId()
059 {
060 return null;
061 }
062
063 public String getBaseVersion()
064 {
065 return null;
066 }
067
068 public void addPluginMapping( String goalPrefix,
069 String artifactId )
070 {
071 addPluginMapping( goalPrefix, artifactId, artifactId );
072 }
073
074 public void addPluginMapping( String goalPrefix,
075 String artifactId,
076 String name )
077 {
078 List plugins = getMetadata().getPlugins();
079 boolean found = false;
080 for ( Iterator i = plugins.iterator(); i.hasNext() && !found; )
081 {
082 Plugin plugin = (Plugin) i.next();
083 if ( plugin.getPrefix().equals( goalPrefix ) )
084 {
085 found = true;
086 }
087 }
088 if ( !found )
089 {
090 Plugin plugin = new Plugin();
091 plugin.setPrefix( goalPrefix );
092 plugin.setArtifactId( artifactId );
093 plugin.setName( name );
094
095
096 getMetadata().addPlugin( plugin );
097 }
098 }
099
100 public Object getKey()
101 {
102 return groupId;
103 }
104
105 public boolean isSnapshot()
106 {
107 return false;
108 }
109
110 public ArtifactRepository getRepository()
111 {
112 return null;
113 }
114
115 public void setRepository( ArtifactRepository remoteRepository )
116 {
117 // intentionally blank
118 }
119 }