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   * e.g. 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      @Override
53      public String getMessage() {
54          return "For artifact {" + getArtifactKey() + "}: " + getBaseMessage();
55      }
56  
57      public String getBaseMessage() {
58          return baseMessage;
59      }
60  
61      public String getArtifactId() {
62          return artifactId;
63      }
64  
65      public String getGroupId() {
66          return groupId;
67      }
68  
69      public String getType() {
70          return type;
71      }
72  
73      public String getVersion() {
74          return version;
75      }
76  
77      public String getArtifactKey() {
78          return groupId + ":" + artifactId + ":" + version + ":" + type;
79      }
80  }