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