001package org.eclipse.aether.transfer; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022import org.eclipse.aether.metadata.Metadata; 023import org.eclipse.aether.repository.LocalRepository; 024import org.eclipse.aether.repository.RemoteRepository; 025 026/** 027 * Thrown when metadata was not found in a particular repository. 028 */ 029public class MetadataNotFoundException 030 extends MetadataTransferException 031{ 032 033 /** 034 * Creates a new exception with the specified metadata and local repository. 035 * 036 * @param metadata The missing metadata, may be {@code null}. 037 * @param repository The involved local repository, may be {@code null}. 038 */ 039 public MetadataNotFoundException( Metadata metadata, LocalRepository repository ) 040 { 041 super( metadata, null, "Could not find metadata " + metadata + getString( " in ", repository ) ); 042 } 043 044 private static String getString( String prefix, LocalRepository repository ) 045 { 046 if ( repository == null ) 047 { 048 return ""; 049 } 050 else 051 { 052 return prefix + repository.getId() + " (" + repository.getBasedir() + ")"; 053 } 054 } 055 056 /** 057 * Creates a new exception with the specified metadata and repository. 058 * 059 * @param metadata The missing metadata, may be {@code null}. 060 * @param repository The involved remote repository, may be {@code null}. 061 */ 062 public MetadataNotFoundException( Metadata metadata, RemoteRepository repository ) 063 { 064 super( metadata, repository, "Could not find metadata " + metadata + getString( " in ", repository ) ); 065 } 066 067 /** 068 * Creates a new exception with the specified metadata, repository and detail message. 069 * 070 * @param metadata The missing metadata, may be {@code null}. 071 * @param repository The involved remote repository, may be {@code null}. 072 * @param message The detail message, may be {@code null}. 073 */ 074 public MetadataNotFoundException( Metadata metadata, RemoteRepository repository, String message ) 075 { 076 super( metadata, repository, message ); 077 } 078 079 /** 080 * Creates a new exception with the specified metadata, repository and detail message. 081 * 082 * @param metadata The missing metadata, may be {@code null}. 083 * @param repository The involved remote repository, may be {@code null}. 084 * @param message The detail message, may be {@code null}. 085 * @param fromCache {@code true} if the exception was played back from the error cache, {@code false} if the 086 * exception actually just occurred. 087 */ 088 public MetadataNotFoundException( Metadata metadata, RemoteRepository repository, String message, boolean fromCache ) 089 { 090 super( metadata, repository, message, fromCache ); 091 } 092 093 /** 094 * Creates a new exception with the specified metadata, repository, detail message and cause. 095 * 096 * @param metadata The missing metadata, may be {@code null}. 097 * @param repository The involved remote repository, may be {@code null}. 098 * @param message The detail message, may be {@code null}. 099 * @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}