View Javadoc

1   /*
2    * ModeShape (http://www.modeshape.org)
3    * See the COPYRIGHT.txt file distributed with this work for information
4    * regarding copyright ownership.  Some portions may be licensed
5    * to Red Hat, Inc. under one or more contributor license agreements.
6    * See the AUTHORS.txt file in the distribution for a full listing of 
7    * individual contributors. 
8    *
9    * ModeShape is free software. Unless otherwise indicated, all code in ModeShape
10   * is licensed to you under the terms of the GNU Lesser General Public License as
11   * published by the Free Software Foundation; either version 2.1 of
12   * the License, or (at your option) any later version.
13   *
14   * ModeShape is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17   * Lesser General Public License for more details.
18   *
19   * You should have received a copy of the GNU Lesser General Public
20   * License along with this software; if not, write to the Free
21   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
23   */
24  package org.modeshape.maven.spi;
25  
26  import java.net.MalformedURLException;
27  import java.net.URL;
28  import java.net.URLConnection;
29  import java.util.Properties;
30  import org.modeshape.maven.ArtifactType;
31  import org.modeshape.maven.MavenId;
32  import org.modeshape.maven.MavenRepository;
33  import org.modeshape.maven.MavenRepositoryException;
34  import org.modeshape.maven.SignatureType;
35  
36  /**
37   * The definition of a URL provider for Maven 2 repositories.
38   */
39  public interface MavenUrlProvider {
40  
41      /**
42       * Configure this provider given the configuration properties. This method is intended to be called by the
43       * {@link MavenRepository} that instantiates this provider, and only once immediately after instantiation and before any calls
44       * to {@link #getUrl(MavenId, ArtifactType, SignatureType, boolean)}.
45       * 
46       * @param properties the configuration properties
47       * @throws MavenRepositoryException if there is a problem connecting to or using the Maven repository, as configured
48       */
49      public void configure( Properties properties ) throws MavenRepositoryException;
50  
51      /**
52       * Get the URL for the artifact with the specified type in the given Maven project. The resulting URL can be used to
53       * {@link URL#openConnection() connect} to the repository to {@link URLConnection#getInputStream() read} or
54       * {@link URLConnection#getOutputStream() write} the artifact's content.
55       * 
56       * @param mavenId the ID of the Maven project; may not be null
57       * @param artifactType the type of artifact; may be null, but the URL will not be able to be read or written to
58       * @param signatureType the type of signature; may be null if the signature file is not desired
59       * @param createIfRequired true if the node structure should be created if any part of it does not exist; this always expects
60       *        that the path to the top of the repository tree exists.
61       * @return the URL to this artifact, or null if the artifact does not exist
62       * @throws MalformedURLException if the supplied information cannot be turned into a valid URL
63       * @throws MavenRepositoryException if there is a problem connecting to or using the Maven repository, as configured
64       */
65      public URL getUrl( MavenId mavenId,
66                         ArtifactType artifactType,
67                         SignatureType signatureType,
68                         boolean createIfRequired ) throws MalformedURLException, MavenRepositoryException;
69  
70  }