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
.RepositoryException
;
14 import org
.eclipse
.aether
.metadata
.Metadata
;
15 import org
.eclipse
.aether
.repository
.RemoteRepository
;
18 * Thrown when metadata could not be uploaded/downloaded to/from a particular remote repository.
20 public class MetadataTransferException
21 extends RepositoryException
24 private final transient Metadata metadata
;
26 private final transient RemoteRepository repository
;
28 private final boolean fromCache
;
30 static String
getString( String prefix
, RemoteRepository repository
)
32 if ( repository
== null )
38 return prefix
+ repository
.getId() + " (" + repository
.getUrl() + ")";
43 * Creates a new exception with the specified metadata, repository and detail message.
45 * @param metadata The untransferable metadata, may be {@code null}.
46 * @param repository The involved remote repository, may be {@code null}.
47 * @param message The detail message, may be {@code null}.
49 public MetadataTransferException( Metadata metadata
, RemoteRepository repository
, String message
)
51 this( metadata
, repository
, message
, false );
55 * Creates a new exception with the specified metadata, repository and detail message.
57 * @param metadata The untransferable metadata, may be {@code null}.
58 * @param repository The involved remote repository, may be {@code null}.
59 * @param message The detail message, may be {@code null}.
60 * @param fromCache {@code true} if the exception was played back from the error cache, {@code false} if the
61 * exception actually just occurred.
63 public MetadataTransferException( Metadata metadata
, RemoteRepository repository
, String message
, boolean fromCache
)
66 this.metadata
= metadata
;
67 this.repository
= repository
;
68 this.fromCache
= fromCache
;
72 * Creates a new exception with the specified metadata, repository and cause.
74 * @param metadata The untransferable metadata, may be {@code null}.
75 * @param repository The involved remote repository, may be {@code null}.
76 * @param cause The exception that caused this one, may be {@code null}.
78 public MetadataTransferException( Metadata metadata
, RemoteRepository repository
, Throwable cause
)
80 this( metadata
, repository
, "Could not transfer metadata " + metadata
+ getString( " from/to ", repository
)
81 + getMessage( ": ", cause
), cause
);
85 * Creates a new exception with the specified metadata, repository, detail message and cause.
87 * @param metadata The untransferable metadata, may be {@code null}.
88 * @param repository The involved remote repository, may be {@code null}.
89 * @param message The detail message, may be {@code null}.
90 * @param cause The exception that caused this one, may be {@code null}.
92 public MetadataTransferException( Metadata metadata
, RemoteRepository repository
, String message
, Throwable cause
)
94 super( message
, cause
);
95 this.metadata
= metadata
;
96 this.repository
= repository
;
97 this.fromCache
= false;
101 * Gets the metadata that could not be transferred.
103 * @return The troublesome metadata or {@code null} if unknown.
105 public Metadata
getMetadata()
111 * Gets the remote repository involved in the transfer.
113 * @return The involved remote repository or {@code null} if unknown.
115 public RemoteRepository
getRepository()
121 * Indicates whether this exception actually just occurred or was played back from the error cache.
123 * @return {@code true} if the exception was played back from the error cache, {@code false} if the exception
124 * actually occurred just now.
126 public boolean isFromCache()