1 package org.apache.maven.archiva.repository;
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.artifact.Artifact;
23 import org.apache.maven.artifact.metadata.ArtifactMetadata;
24 import org.apache.maven.artifact.repository.ArtifactRepository;
25 import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
26 import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
31 * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
34 public class Repository
35 implements ArtifactRepository
39 protected String name;
41 protected String source;
43 protected RepositoryURL url;
45 protected ArtifactRepositoryLayout layout;
47 protected ArtifactRepositoryPolicy releases;
49 protected ArtifactRepositoryPolicy snapshots;
51 protected boolean blacklisted;
53 /* .\ Constructor \.__________________________________________________ */
56 * Construct a Repository.
58 * @param id the unique identifier for this repository.
59 * @param name the name for this repository.
60 * @param url the base URL for this repository (this should point to the top level URL for the entire repository)
61 * @param layout the layout technique for this repository.
63 public Repository( String id, String name, String url, ArtifactRepositoryLayout layout )
67 this.url = new RepositoryURL( url );
71 /* .\ Information \.__________________________________________________ */
74 * Get the unique ID for this repository.
76 * @return the unique ID for this repository.
84 * Get the Name of this repository.
85 * This is usually the human readable name for the repository.
87 * @return the name of this repository.
89 public String getName()
94 public String getUrl()
96 return url.toString();
99 public void setLayout( ArtifactRepositoryLayout layout )
101 this.layout = layout;
104 public ArtifactRepositoryLayout getLayout()
109 public void setSource( String source )
111 this.source = source;
114 public String getSource()
119 /* .\ Tasks \.________________________________________________________ */
121 public String pathOf( Artifact artifact )
123 return getLayout().pathOf( artifact );
126 /* .\ State \.________________________________________________________ */
128 public void setBlacklisted( boolean blacklisted )
130 this.blacklisted = blacklisted;
133 public boolean isBlacklisted()
138 public boolean isManaged()
140 return this.url.getProtocol().equals( "file" );
143 public boolean isRemote()
145 return !this.url.getProtocol().equals( "file" );
148 public void setSnapshots( ArtifactRepositoryPolicy snapshots )
150 this.snapshots = snapshots;
153 public ArtifactRepositoryPolicy getSnapshots()
158 public void setReleases( ArtifactRepositoryPolicy releases )
160 this.releases = releases;
163 public ArtifactRepositoryPolicy getReleases()
168 public boolean equals( Object other )
170 return ( other == this || ( ( other instanceof Repository ) && ( (Repository) other ).getId().equals( getId() ) ) );
173 public int hashCode()
175 return getId().hashCode();
178 /* .\ ArtifactRepository Requirements \.______________________________ */
180 public String getBasedir()
182 return url.getPath();
185 public String getKey()
190 public String getProtocol()
192 return url.getProtocol();
195 public boolean isUniqueVersion()
197 // TODO: Determine Importance
201 public String pathOfRemoteRepositoryMetadata( ArtifactMetadata artifactMetadata )
203 return layout.pathOfRemoteRepositoryMetadata( artifactMetadata );
206 public String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository )
208 return layout.pathOfLocalRepositoryMetadata( metadata, repository );