X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.slc.repo%2Fsrc%2Forg%2Feclipse%2Faether%2Ftransfer%2FMetadataNotFoundException.java;fp=org.argeo.slc.repo%2Fsrc%2Forg%2Feclipse%2Faether%2Ftransfer%2FMetadataNotFoundException.java;h=af9a84001dda40ae4c5f08061c3ba7b73bbd8908;hb=825d60c5348dbe3f5be25b0bccf7bdebfe694219;hp=0000000000000000000000000000000000000000;hpb=5e991fff5cba01858dcc5747a27e637325bc5c8e;p=gpl%2Fargeo-jcr.git diff --git a/org.argeo.slc.repo/src/org/eclipse/aether/transfer/MetadataNotFoundException.java b/org.argeo.slc.repo/src/org/eclipse/aether/transfer/MetadataNotFoundException.java new file mode 100644 index 0000000..af9a840 --- /dev/null +++ b/org.argeo.slc.repo/src/org/eclipse/aether/transfer/MetadataNotFoundException.java @@ -0,0 +1,97 @@ +/******************************************************************************* + * Copyright (c) 2010, 2014 Sonatype, Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Sonatype, Inc. - initial API and implementation + *******************************************************************************/ +package org.eclipse.aether.transfer; + +import org.eclipse.aether.metadata.Metadata; +import org.eclipse.aether.repository.LocalRepository; +import org.eclipse.aether.repository.RemoteRepository; + +/** + * Thrown when metadata was not found in a particular repository. + */ +public class MetadataNotFoundException + extends MetadataTransferException +{ + + /** + * Creates a new exception with the specified metadata and local repository. + * + * @param metadata The missing metadata, may be {@code null}. + * @param repository The involved local repository, may be {@code null}. + */ + public MetadataNotFoundException( Metadata metadata, LocalRepository repository ) + { + super( metadata, null, "Could not find metadata " + metadata + getString( " in ", repository ) ); + } + + private static String getString( String prefix, LocalRepository repository ) + { + if ( repository == null ) + { + return ""; + } + else + { + return prefix + repository.getId() + " (" + repository.getBasedir() + ")"; + } + } + + /** + * Creates a new exception with the specified metadata and repository. + * + * @param metadata The missing metadata, may be {@code null}. + * @param repository The involved remote repository, may be {@code null}. + */ + public MetadataNotFoundException( Metadata metadata, RemoteRepository repository ) + { + super( metadata, repository, "Could not find metadata " + metadata + getString( " in ", repository ) ); + } + + /** + * Creates a new exception with the specified metadata, repository and detail message. + * + * @param metadata The missing metadata, may be {@code null}. + * @param repository The involved remote repository, may be {@code null}. + * @param message The detail message, may be {@code null}. + */ + public MetadataNotFoundException( Metadata metadata, RemoteRepository repository, String message ) + { + super( metadata, repository, message ); + } + + /** + * Creates a new exception with the specified metadata, repository and detail message. + * + * @param metadata The missing metadata, may be {@code null}. + * @param repository The involved remote repository, may be {@code null}. + * @param message The detail message, may be {@code null}. + * @param fromCache {@code true} if the exception was played back from the error cache, {@code false} if the + * exception actually just occurred. + */ + public MetadataNotFoundException( Metadata metadata, RemoteRepository repository, String message, boolean fromCache ) + { + super( metadata, repository, message, fromCache ); + } + + /** + * Creates a new exception with the specified metadata, repository, detail message and cause. + * + * @param metadata The missing metadata, may be {@code null}. + * @param repository The involved remote repository, may be {@code null}. + * @param message The detail message, may be {@code null}. + * @param cause The exception that caused this one, may be {@code null}. + */ + public MetadataNotFoundException( Metadata metadata, RemoteRepository repository, String message, Throwable cause ) + { + super( metadata, repository, message, cause ); + } + +}