]> git.argeo.org Git - gpl/argeo-jcr.git/blob - org.argeo.slc.repo/src/org/eclipse/aether/transfer/NoTransporterException.java
Move Argeo SLC JCR components to Argeo JCR
[gpl/argeo-jcr.git] / org.argeo.slc.repo / src / org / eclipse / aether / transfer / NoTransporterException.java
1 /*******************************************************************************
2 * Copyright (c) 2013, 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 transport protocol.
18 */
19 public class NoTransporterException
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 transport layout is not supported, may be {@code null}.
29 */
30 public NoTransporterException( 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 transport layout is not supported, may be {@code null}.
39 * @param message The detail message, may be {@code null}.
40 */
41 public NoTransporterException( 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 transport layout is not supported, may be {@code null}.
51 * @param cause The exception that caused this one, may be {@code null}.
52 */
53 public NoTransporterException( 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 transport layout 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 NoTransporterException( 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 "Unsupported transport protocol " + repository.getProtocol();
76 }
77 else
78 {
79 return "Unsupported transport protocol";
80 }
81 }
82
83 /**
84 * Gets the remote repository whose transport protocol is not supported.
85 *
86 * @return The unsupported remote repository or {@code null} if unknown.
87 */
88 public RemoteRepository getRepository()
89 {
90 return repository;
91 }
92
93 }