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;
20  
21  /**
22   * Exception thrown when the identity of an artifact can not be established,
23   * eg. one of groupId, artifactId, version or type is null.
24   */
25  public class InvalidArtifactRTException extends RuntimeException {
26  
27      private final String groupId;
28      private final String artifactId;
29      private final String version;
30      private final String type;
31      private final String baseMessage;
32  
33      public InvalidArtifactRTException(String groupId, String artifactId, String version, String type, String message) {
34          this.groupId = groupId;
35          this.artifactId = artifactId;
36          this.version = version;
37          this.type = type;
38          this.baseMessage = message;
39      }
40  
41      public InvalidArtifactRTException(
42              String groupId, String artifactId, String version, String type, String message, Throwable cause) {
43          super(cause);
44  
45          this.groupId = groupId;
46          this.artifactId = artifactId;
47          this.version = version;
48          this.type = type;
49          this.baseMessage = message;
50      }
51  
52      public String getMessage() {
53          return "For artifact {" + getArtifactKey() + "}: " + getBaseMessage();
54      }
55  
56      public String getBaseMessage() {
57          return baseMessage;
58      }
59  
60      public String getArtifactId() {
61          return artifactId;
62      }
63  
64      public String getGroupId() {
65          return groupId;
66      }
67  
68      public String getType() {
69          return type;
70      }
71  
72      public String getVersion() {
73          return version;
74      }
75  
76      public String getArtifactKey() {
77          return groupId + ":" + artifactId + ":" + version + ":" + type;
78      }
79  }