View Javadoc
1   /*******************************************************************************
2    * Copyright (c) 2010, 2014 Sonatype, Inc.
3    * All rights reserved. This program and the accompanying materials
4    * are made available under the terms of the Eclipse Public License v1.0
5    * which accompanies this distribution, and is available at
6    * http://www.eclipse.org/legal/epl-v10.html
7    *
8    * Contributors:
9    *    Sonatype, Inc. - initial API and implementation
10   *******************************************************************************/
11  package org.eclipse.aether.transfer;
12  
13  import org.eclipse.aether.metadata.Metadata;
14  import org.eclipse.aether.repository.LocalRepository;
15  import org.eclipse.aether.repository.RemoteRepository;
16  
17  /**
18   * Thrown when metadata was not found in a particular repository.
19   */
20  public class MetadataNotFoundException
21      extends MetadataTransferException
22  {
23  
24      /**
25       * Creates a new exception with the specified metadata and local repository.
26       * 
27       * @param metadata The missing metadata, may be {@code null}.
28       * @param repository The involved local repository, may be {@code null}.
29       */
30      public MetadataNotFoundException( Metadata metadata, LocalRepository repository )
31      {
32          super( metadata, null, "Could not find metadata " + metadata + getString( " in ", repository ) );
33      }
34  
35      private static String getString( String prefix, LocalRepository repository )
36      {
37          if ( repository == null )
38          {
39              return "";
40          }
41          else
42          {
43              return prefix + repository.getId() + " (" + repository.getBasedir() + ")";
44          }
45      }
46  
47      /**
48       * Creates a new exception with the specified metadata and repository.
49       * 
50       * @param metadata The missing metadata, may be {@code null}.
51       * @param repository The involved remote repository, may be {@code null}.
52       */
53      public MetadataNotFoundException( Metadata metadata, RemoteRepository repository )
54      {
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      {
67          super( metadata, repository, message );
68      }
69  
70      /**
71       * Creates a new exception with the specified metadata, repository and detail message.
72       * 
73       * @param metadata The missing metadata, may be {@code null}.
74       * @param repository The involved remote repository, may be {@code null}.
75       * @param message The detail message, may be {@code null}.
76       * @param fromCache {@code true} if the exception was played back from the error cache, {@code false} if the
77       *            exception actually just occurred.
78       */
79      public MetadataNotFoundException( Metadata metadata, RemoteRepository repository, String message, boolean fromCache )
80      {
81          super( metadata, repository, message, fromCache );
82      }
83  
84      /**
85       * Creates a new exception with the specified metadata, repository, detail message and cause.
86       * 
87       * @param metadata The missing metadata, may be {@code null}.
88       * @param repository The involved remote repository, may be {@code null}.
89       * @param message The detail message, may be {@code null}.
90       * @param cause The exception that caused this one, may be {@code null}.
91       */
92      public MetadataNotFoundException( Metadata metadata, RemoteRepository repository, String message, Throwable cause )
93      {
94          super( metadata, repository, message, cause );
95      }
96  
97  }