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