1 package org.eclipse.aether.repository; 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.RepositoryException; 23 24 /** 25 * Thrown in case of an unsupported local repository type. 26 */ 27 public class NoLocalRepositoryManagerException 28 extends RepositoryException 29 { 30 31 private final transient LocalRepository repository; 32 33 /** 34 * Creates a new exception with the specified repository. 35 * 36 * @param repository The local repository for which no support is available, may be {@code null}. 37 */ 38 public NoLocalRepositoryManagerException( LocalRepository repository ) 39 { 40 this( repository, toMessage( repository ) ); 41 } 42 43 /** 44 * Creates a new exception with the specified repository and detail message. 45 * 46 * @param repository The local repository for which no support is available, may be {@code null}. 47 * @param message The detail message, may be {@code null}. 48 */ 49 public NoLocalRepositoryManagerException( LocalRepository repository, String message ) 50 { 51 super( message ); 52 this.repository = repository; 53 } 54 55 /** 56 * Creates a new exception with the specified repository and cause. 57 * 58 * @param repository The local repository for which no support is available, may be {@code null}. 59 * @param cause The exception that caused this one, may be {@code null}. 60 */ 61 public NoLocalRepositoryManagerException( LocalRepository repository, Throwable cause ) 62 { 63 this( repository, toMessage( repository ), cause ); 64 } 65 66 /** 67 * Creates a new exception with the specified repository, detail message and cause. 68 * 69 * @param repository The local repository for which no support is available, may be {@code null}. 70 * @param message The detail message, may be {@code null}. 71 * @param cause The exception that caused this one, may be {@code null}. 72 */ 73 public NoLocalRepositoryManagerException( LocalRepository repository, String message, Throwable cause ) 74 { 75 super( message, cause ); 76 this.repository = repository; 77 } 78 79 private static String toMessage( LocalRepository repository ) 80 { 81 if ( repository != null ) 82 { 83 return "No manager available for local repository (" + repository.getBasedir().getAbsolutePath() 84 + ") of type " + repository.getContentType(); 85 } 86 else 87 { 88 return "No manager available for local repository"; 89 } 90 } 91 92 /** 93 * Gets the local repository whose content type is not supported. 94 * 95 * @return The unsupported local repository or {@code null} if unknown. 96 */ 97 public LocalRepository getRepository() 98 { 99 return repository; 100 } 101 102 }