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 when a transfer could not be performed because a remote repository is not accessible in offline mode. 27 */ 28 public class RepositoryOfflineException 29 extends RepositoryException 30 { 31 32 private final transient RemoteRepository repository; 33 34 private static String getMessage( RemoteRepository repository ) 35 { 36 if ( repository == null ) 37 { 38 return "Cannot access remote repositories in offline mode"; 39 } 40 else 41 { 42 return "Cannot access " + repository.getId() + " (" + repository.getUrl() + ") in offline mode"; 43 } 44 } 45 46 /** 47 * Creates a new exception with the specified repository. 48 * 49 * @param repository The inaccessible remote repository, may be {@code null}. 50 */ 51 public RepositoryOfflineException( RemoteRepository repository ) 52 { 53 super( getMessage( repository ) ); 54 this.repository = repository; 55 } 56 57 /** 58 * Creates a new exception with the specified repository and detail message. 59 * 60 * @param repository The inaccessible remote repository, may be {@code null}. 61 * @param message The detail message, may be {@code null}. 62 */ 63 public RepositoryOfflineException( RemoteRepository repository, String message ) 64 { 65 super( message ); 66 this.repository = repository; 67 } 68 69 /** 70 * Gets the remote repository that could not be accessed due to offline mode. 71 * 72 * @return The inaccessible remote repository or {@code null} if unknown. 73 */ 74 public RemoteRepository getRepository() 75 { 76 return repository; 77 } 78 79 }