]>
git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.repo/src/org/eclipse/aether/transfer/ChecksumFailureException.java
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
;
16 * Thrown in case of a checksum failure during an artifact/metadata download.
18 public class ChecksumFailureException
19 extends RepositoryException
22 private final String expected
;
24 private final String actual
;
26 private final boolean retryWorthy
;
29 * Creates a new exception with the specified expected and actual checksum. The resulting exception is
30 * {@link #isRetryWorthy() retry-worthy}.
32 * @param expected The expected checksum as declared by the hosting repository, may be {@code null}.
33 * @param actual The actual checksum as computed from the local bytes, may be {@code null}.
35 public ChecksumFailureException( String expected
, String actual
)
37 super( "Checksum validation failed, expected " + expected
+ " but is " + actual
);
38 this.expected
= expected
;
44 * Creates a new exception with the specified detail message. The resulting exception is not
45 * {@link #isRetryWorthy() retry-worthy}.
47 * @param message The detail message, may be {@code null}.
49 public ChecksumFailureException( String message
)
51 this( false, message
, null );
55 * Creates a new exception with the specified cause. The resulting exception is not {@link #isRetryWorthy()
58 * @param cause The exception that caused this one, may be {@code null}.
60 public ChecksumFailureException( Throwable cause
)
62 this( "Checksum validation failed" + getMessage( ": ", cause
), cause
);
66 * Creates a new exception with the specified detail message and cause. The resulting exception is not
67 * {@link #isRetryWorthy() retry-worthy}.
69 * @param message The detail message, may be {@code null}.
70 * @param cause The exception that caused this one, may be {@code null}.
72 public ChecksumFailureException( String message
, Throwable cause
)
74 this( false, message
, cause
);
78 * Creates a new exception with the specified retry flag, detail message and cause.
80 * @param retryWorthy {@code true} if the exception is retry-worthy, {@code false} otherwise.
81 * @param message The detail message, may be {@code null}.
82 * @param cause The exception that caused this one, may be {@code null}.
84 public ChecksumFailureException( boolean retryWorthy
, String message
, Throwable cause
)
86 super( message
, cause
);
87 expected
= actual
= "";
88 this.retryWorthy
= retryWorthy
;
92 * Gets the expected checksum for the downloaded artifact/metadata.
94 * @return The expected checksum as declared by the hosting repository or {@code null} if unknown.
96 public String
getExpected()
102 * Gets the actual checksum for the downloaded artifact/metadata.
104 * @return The actual checksum as computed from the local bytes or {@code null} if unknown.
106 public String
getActual()
112 * Indicates whether the corresponding download is retry-worthy.
114 * @return {@code true} if retrying the download might solve the checksum failure, {@code false} if the checksum
115 * failure is non-recoverable.
117 public boolean isRetryWorthy()