001package co.codewizards.cloudstore.core.repo.local; 002 003import co.codewizards.cloudstore.core.oio.File; 004 005 006/** 007 * Thrown if a {@link LocalRepoManager} could not be created for a given {@link File}, because the file 008 * is already a repository and the {@code LocalRepoManager} was instructed to create a new repository 009 * from a simple file. 010 * <p> 011 * Note, that this exception is thrown for simple files or directories inside a repository, too. 012 * <p> 013 * The same applies, if the directory in question contains at least one other repository. 014 * @author Marco หงุ่ยตระกูล-Schulze - marco at codewizards dot co 015 */ 016public class FileAlreadyRepositoryException extends LocalRepoManagerException { 017 private static final long serialVersionUID = 1L; 018 019 private final File file; 020 021 public FileAlreadyRepositoryException(final File file) { 022 super(createMessage(file)); 023 this.file = file; 024 } 025 026 public FileAlreadyRepositoryException(final File file, final Throwable cause) { 027 super(createMessage(file), cause); 028 this.file = file; 029 } 030 031 public File getFile() { 032 return file; 033 } 034 035 private static String createMessage(final File file) { 036 return String.format("File is already (in) a repository (cannot be converted into one): %s", file == null ? null : file.getAbsolutePath()); 037 } 038}