1 /*******************************************************************************
2 * Copyright (c) 2010, 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
9 * Sonatype, Inc. - initial API and implementation
10 *******************************************************************************/
11 package org
.eclipse
.aether
.transfer
;
13 import org
.eclipse
.aether
.artifact
.Artifact
;
14 import org
.eclipse
.aether
.artifact
.ArtifactProperties
;
15 import org
.eclipse
.aether
.repository
.RemoteRepository
;
18 * Thrown when an artifact was not found in a particular repository.
20 public class ArtifactNotFoundException
21 extends ArtifactTransferException
25 * Creates a new exception with the specified artifact and repository.
27 * @param artifact The missing artifact, may be {@code null}.
28 * @param repository The involved remote repository, may be {@code null}.
30 public ArtifactNotFoundException( Artifact artifact
, RemoteRepository repository
)
32 super( artifact
, repository
, getMessage( artifact
, repository
) );
35 private static String
getMessage( Artifact artifact
, RemoteRepository repository
)
37 StringBuilder buffer
= new StringBuilder( 256 );
38 buffer
.append( "Could not find artifact " ).append( artifact
);
39 buffer
.append( getString( " in ", repository
) );
40 if ( artifact
!= null )
42 String localPath
= artifact
.getProperty( ArtifactProperties
.LOCAL_PATH
, null );
43 if ( localPath
!= null && repository
== null )
45 buffer
.append( " at specified path " ).append( localPath
);
47 String downloadUrl
= artifact
.getProperty( ArtifactProperties
.DOWNLOAD_URL
, null );
48 if ( downloadUrl
!= null )
50 buffer
.append( ", try downloading from " ).append( downloadUrl
);
53 return buffer
.toString();
57 * Creates a new exception with the specified artifact, repository and detail message.
59 * @param artifact The missing artifact, may be {@code null}.
60 * @param repository The involved remote repository, may be {@code null}.
61 * @param message The detail message, may be {@code null}.
63 public ArtifactNotFoundException( Artifact artifact
, RemoteRepository repository
, String message
)
65 super( artifact
, repository
, message
);
69 * Creates a new exception with the specified artifact, repository and detail message.
71 * @param artifact The missing artifact, may be {@code null}.
72 * @param repository The involved remote repository, may be {@code null}.
73 * @param message The detail message, may be {@code null}.
74 * @param fromCache {@code true} if the exception was played back from the error cache, {@code false} if the
75 * exception actually just occurred.
77 public ArtifactNotFoundException( Artifact artifact
, RemoteRepository repository
, String message
, boolean fromCache
)
79 super( artifact
, repository
, message
, fromCache
);
83 * Creates a new exception with the specified artifact, repository, detail message and cause.
85 * @param artifact The missing artifact, may be {@code null}.
86 * @param repository The involved remote repository, may be {@code null}.
87 * @param message The detail message, may be {@code null}.
88 * @param cause The exception that caused this one, may be {@code null}.
90 public ArtifactNotFoundException( Artifact artifact
, RemoteRepository repository
, String message
, Throwable cause
)
92 super( artifact
, repository
, message
, cause
);