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.eclipse.aether.transfer;
20  
21  import org.eclipse.aether.metadata.Metadata;
22  import org.eclipse.aether.repository.LocalRepository;
23  import org.eclipse.aether.repository.RemoteRepository;
24  
25  /**
26   * Thrown when metadata was not found in a particular repository.
27   */
28  public class MetadataNotFoundException extends MetadataTransferException {
29  
30      /**
31       * Creates a new exception with the specified metadata and local repository.
32       *
33       * @param metadata The missing metadata, may be {@code null}.
34       * @param repository The involved local repository, may be {@code null}.
35       */
36      public MetadataNotFoundException(Metadata metadata, LocalRepository repository) {
37          super(metadata, null, "Could not find metadata " + metadata + getString(" in ", repository));
38      }
39  
40      private static String getString(String prefix, LocalRepository repository) {
41          if (repository == null) {
42              return "";
43          } else {
44              return prefix + repository.getId() + " (" + repository.getBasePath().toAbsolutePath() + ")";
45          }
46      }
47  
48      /**
49       * Creates a new exception with the specified metadata and repository.
50       *
51       * @param metadata The missing metadata, may be {@code null}.
52       * @param repository The involved remote repository, may be {@code null}.
53       */
54      public MetadataNotFoundException(Metadata metadata, RemoteRepository repository) {
55          super(metadata, repository, "Could not find metadata " + metadata + getString(" in ", repository));
56      }
57  
58      /**
59       * Creates a new exception with the specified metadata, repository and detail message.
60       *
61       * @param metadata The missing metadata, may be {@code null}.
62       * @param repository The involved remote repository, may be {@code null}.
63       * @param message The detail message, may be {@code null}.
64       */
65      public MetadataNotFoundException(Metadata metadata, RemoteRepository repository, String message) {
66          super(metadata, repository, message);
67      }
68  
69      /**
70       * Creates a new exception with the specified metadata, repository and detail message.
71       *
72       * @param metadata The missing metadata, may be {@code null}.
73       * @param repository The involved remote repository, may be {@code null}.
74       * @param message The detail message, may be {@code null}.
75       * @param fromCache {@code true} if the exception was played back from the error cache, {@code false} if the
76       *            exception actually just occurred.
77       */
78      public MetadataNotFoundException(
79              Metadata metadata, RemoteRepository repository, String message, boolean fromCache) {
80          super(metadata, repository, message, fromCache);
81      }
82  
83      /**
84       * Creates a new exception with the specified metadata, repository, detail message and cause.
85       *
86       * @param metadata The missing metadata, may be {@code null}.
87       * @param repository The involved remote repository, may be {@code null}.
88       * @param message The detail message, may be {@code null}.
89       * @param cause The exception that caused this one, may be {@code null}.
90       */
91      public MetadataNotFoundException(Metadata metadata, RemoteRepository repository, String message, Throwable cause) {
92          super(metadata, repository, message, cause);
93      }
94  }