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  import org.apache.maven.artifact.Artifact;
23  import org.apache.maven.artifact.repository.ArtifactRepository;
24  
25  /**
26   * @author Jason van Zyl
27   */
28  public class ArtifactNotFoundException extends AbstractArtifactResolutionException {
29      private String downloadUrl;
30  
31      protected ArtifactNotFoundException(
32              String message, Artifact artifact, List<ArtifactRepository> remoteRepositories) {
33          super(message, artifact, remoteRepositories);
34      }
35  
36      public ArtifactNotFoundException(String message, Artifact artifact) {
37          this(
38                  message,
39                  artifact.getGroupId(),
40                  artifact.getArtifactId(),
41                  artifact.getVersion(),
42                  artifact.getType(),
43                  artifact.getClassifier(),
44                  null,
45                  artifact.getDownloadUrl(),
46                  artifact.getDependencyTrail());
47      }
48  
49      protected ArtifactNotFoundException(
50              String message, Artifact artifact, List<ArtifactRepository> remoteRepositories, Throwable cause) {
51          this(
52                  message,
53                  artifact.getGroupId(),
54                  artifact.getArtifactId(),
55                  artifact.getVersion(),
56                  artifact.getType(),
57                  artifact.getClassifier(),
58                  remoteRepositories,
59                  artifact.getDownloadUrl(),
60                  artifact.getDependencyTrail(),
61                  cause);
62      }
63  
64      @SuppressWarnings("checkstyle:parameternumber")
65      public ArtifactNotFoundException(
66              String message,
67              String groupId,
68              String artifactId,
69              String version,
70              String type,
71              String classifier,
72              List<ArtifactRepository> remoteRepositories,
73              String downloadUrl,
74              List<String> path,
75              Throwable cause) {
76          super(
77                  constructMissingArtifactMessage(
78                          message, "", groupId, artifactId, version, type, classifier, downloadUrl, path),
79                  groupId,
80                  artifactId,
81                  version,
82                  type,
83                  classifier,
84                  remoteRepositories,
85                  null,
86                  cause);
87  
88          this.downloadUrl = downloadUrl;
89      }
90  
91      @SuppressWarnings("checkstyle:parameternumber")
92      private ArtifactNotFoundException(
93              String message,
94              String groupId,
95              String artifactId,
96              String version,
97              String type,
98              String classifier,
99              List<ArtifactRepository> remoteRepositories,
100             String downloadUrl,
101             List<String> path) {
102         super(
103                 constructMissingArtifactMessage(
104                         message, "", groupId, artifactId, version, type, classifier, downloadUrl, path),
105                 groupId,
106                 artifactId,
107                 version,
108                 type,
109                 classifier,
110                 remoteRepositories,
111                 null);
112 
113         this.downloadUrl = downloadUrl;
114     }
115 
116     public String getDownloadUrl() {
117         return downloadUrl;
118     }
119 }