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