View Javadoc

1   package org.apache.maven.artifact;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  /**
23   * Exception thrown when the identity of an artifact can not be established,
24   * eg. one of groupId, artifactId, version or type is null.
25   */
26  public class InvalidArtifactRTException
27      extends RuntimeException
28  {
29  
30      private final String groupId;
31      private final String artifactId;
32      private final String version;
33      private final String type;
34      private final String baseMessage;
35  
36      public InvalidArtifactRTException( String groupId,
37                                         String artifactId,
38                                         String version,
39                                         String type,
40                                         String message )
41      {
42          this.groupId = groupId;
43          this.artifactId = artifactId;
44          this.version = version;
45          this.type = type;
46          this.baseMessage = message;
47      }
48  
49      public InvalidArtifactRTException( String groupId,
50                                         String artifactId,
51                                         String version,
52                                         String type,
53                                         String message,
54                                         Throwable cause )
55      {
56          super( cause );
57  
58          this.groupId = groupId;
59          this.artifactId = artifactId;
60          this.version = version;
61          this.type = type;
62          this.baseMessage = message;
63      }
64  
65      public String getMessage()
66      {
67          return "For artifact {" + getArtifactKey() + "}: " + getBaseMessage();
68      }
69  
70      public String getBaseMessage()
71      {
72          return baseMessage;
73      }
74  
75      public String getArtifactId()
76      {
77          return artifactId;
78      }
79  
80      public String getGroupId()
81      {
82          return groupId;
83      }
84  
85      public String getType()
86      {
87          return type;
88      }
89  
90      public String getVersion()
91      {
92          return version;
93      }
94  
95      public String getArtifactKey()
96      {
97          return groupId + ":" + artifactId + ":" + version + ":" + type;
98      }
99  
100 }