View Javadoc

1   package org.sonatype.aether.transfer;
2   
3   /*******************************************************************************
4    * Copyright (c) 2010-2011 Sonatype, Inc.
5    * All rights reserved. This program and the accompanying materials
6    * are made available under the terms of the Eclipse Public License v1.0
7    * which accompanies this distribution, and is available at
8    *   http://www.eclipse.org/legal/epl-v10.html
9    *******************************************************************************/
10  
11  import org.sonatype.aether.RepositoryException;
12  import org.sonatype.aether.artifact.Artifact;
13  import org.sonatype.aether.repository.RemoteRepository;
14  
15  /**
16   * Thrown when an artifact could not be uploaded/downloaded to/from a particular remote repository.
17   * 
18   * @author Benjamin Bentmann
19   */
20  public class ArtifactTransferException
21      extends RepositoryException
22  {
23  
24      private final Artifact artifact;
25  
26      private final RemoteRepository repository;
27  
28      static String getString( String prefix, RemoteRepository repository )
29      {
30          if ( repository == null )
31          {
32              return "";
33          }
34          else
35          {
36              return prefix + repository.getId() + " (" + repository.getUrl() + ")";
37          }
38      }
39  
40      public ArtifactTransferException( Artifact artifact, RemoteRepository repository, String message )
41      {
42          super( message );
43  
44          this.artifact = artifact;
45          this.repository = repository;
46      }
47  
48      public ArtifactTransferException( Artifact artifact, RemoteRepository repository, Throwable cause )
49      {
50          super( "Could not transfer artifact " + artifact + getString( " from/to ", repository )
51              + getMessage( ": ", cause ), cause );
52  
53          this.artifact = artifact;
54          this.repository = repository;
55      }
56  
57      public ArtifactTransferException( Artifact artifact, RemoteRepository repository, String message, Throwable cause )
58      {
59          super( message, cause );
60  
61          this.artifact = artifact;
62          this.repository = repository;
63      }
64  
65      public Artifact getArtifact()
66      {
67          return artifact;
68      }
69  
70      public RemoteRepository getRepository()
71      {
72          return repository;
73      }
74  
75  }