View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.artifact.resolver;
20  
21  import java.util.List;
22  
23  import org.apache.maven.artifact.Artifact;
24  import org.apache.maven.artifact.repository.ArtifactRepository;
25  
26  /**
27   * @author Jason van Zyl
28   */
29  public class ArtifactNotFoundException extends AbstractArtifactResolutionException {
30      private String downloadUrl;
31  
32      protected ArtifactNotFoundException(
33              String message, Artifact artifact, List<ArtifactRepository> remoteRepositories) {
34          super(message, artifact, remoteRepositories);
35      }
36  
37      public ArtifactNotFoundException(String message, Artifact artifact) {
38          this(
39                  message,
40                  artifact.getGroupId(),
41                  artifact.getArtifactId(),
42                  artifact.getVersion(),
43                  artifact.getType(),
44                  artifact.getClassifier(),
45                  null,
46                  artifact.getDownloadUrl(),
47                  artifact.getDependencyTrail());
48      }
49  
50      protected ArtifactNotFoundException(
51              String message, Artifact artifact, List<ArtifactRepository> remoteRepositories, Throwable cause) {
52          this(
53                  message,
54                  artifact.getGroupId(),
55                  artifact.getArtifactId(),
56                  artifact.getVersion(),
57                  artifact.getType(),
58                  artifact.getClassifier(),
59                  remoteRepositories,
60                  artifact.getDownloadUrl(),
61                  artifact.getDependencyTrail(),
62                  cause);
63      }
64  
65      @SuppressWarnings("checkstyle:parameternumber")
66      public ArtifactNotFoundException(
67              String message,
68              String groupId,
69              String artifactId,
70              String version,
71              String type,
72              String classifier,
73              List<ArtifactRepository> remoteRepositories,
74              String downloadUrl,
75              List<String> path,
76              Throwable cause) {
77          super(
78                  constructMissingArtifactMessage(
79                          message, "", groupId, artifactId, version, type, classifier, downloadUrl, path),
80                  groupId,
81                  artifactId,
82                  version,
83                  type,
84                  classifier,
85                  remoteRepositories,
86                  null,
87                  cause);
88  
89          this.downloadUrl = downloadUrl;
90      }
91  
92      @SuppressWarnings("checkstyle:parameternumber")
93      private ArtifactNotFoundException(
94              String message,
95              String groupId,
96              String artifactId,
97              String version,
98              String type,
99              String classifier,
100             List<ArtifactRepository> remoteRepositories,
101             String downloadUrl,
102             List<String> path) {
103         super(
104                 constructMissingArtifactMessage(
105                         message, "", groupId, artifactId, version, type, classifier, downloadUrl, path),
106                 groupId,
107                 artifactId,
108                 version,
109                 type,
110                 classifier,
111                 remoteRepositories,
112                 null);
113 
114         this.downloadUrl = downloadUrl;
115     }
116 
117     public String getDownloadUrl() {
118         return downloadUrl;
119     }
120 }