001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 */ 019package org.eclipse.aether.repository; 020 021import org.eclipse.aether.RepositoryException; 022 023/** 024 * Thrown in case of an unsupported local repository type. 025 */ 026public class NoLocalRepositoryManagerException extends RepositoryException { 027 028 private final transient LocalRepository repository; 029 030 /** 031 * Creates a new exception with the specified repository. 032 * 033 * @param repository The local repository for which no support is available, may be {@code null}. 034 */ 035 public NoLocalRepositoryManagerException(LocalRepository repository) { 036 this(repository, toMessage(repository)); 037 } 038 039 /** 040 * Creates a new exception with the specified repository and detail message. 041 * 042 * @param repository The local repository for which no support is available, may be {@code null}. 043 * @param message The detail message, may be {@code null}. 044 */ 045 public NoLocalRepositoryManagerException(LocalRepository repository, String message) { 046 super(message); 047 this.repository = repository; 048 } 049 050 /** 051 * Creates a new exception with the specified repository and cause. 052 * 053 * @param repository The local repository for which no support is available, may be {@code null}. 054 * @param cause The exception that caused this one, may be {@code null}. 055 */ 056 public NoLocalRepositoryManagerException(LocalRepository repository, Throwable cause) { 057 this(repository, toMessage(repository), cause); 058 } 059 060 /** 061 * Creates a new exception with the specified repository, detail message and cause. 062 * 063 * @param repository The local repository for which no support is available, may be {@code null}. 064 * @param message The detail message, may be {@code null}. 065 * @param cause The exception that caused this one, may be {@code null}. 066 */ 067 public NoLocalRepositoryManagerException(LocalRepository repository, String message, Throwable cause) { 068 super(message, cause); 069 this.repository = repository; 070 } 071 072 private static String toMessage(LocalRepository repository) { 073 if (repository != null) { 074 return "No manager available for local repository (" 075 + repository.getBasePath().toAbsolutePath() + ") of type " + repository.getContentType(); 076 } else { 077 return "No manager available for local repository"; 078 } 079 } 080 081 /** 082 * Gets the local repository whose content type is not supported. 083 * 084 * @return The unsupported local repository or {@code null} if unknown. 085 */ 086 public LocalRepository getRepository() { 087 return repository; 088 } 089}