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