001/*
002 * acme4j - Java ACME client
003 *
004 * Copyright (C) 2016 Richard "Shred" Körber
005 *   http://acme4j.shredzone.org
006 *
007 * Licensed under the Apache License, Version 2.0 (the "License");
008 * you may not use this file except in compliance with the License.
009 *
010 * This program is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
013 */
014package org.shredzone.acme4j.exception;
015
016import java.time.Instant;
017import java.util.Objects;
018
019import org.shredzone.acme4j.AcmeJsonResource;
020
021/**
022 * A server side process has not been completed yet. The server also provides an estimate
023 * of when the process is expected to complete.
024 * <p>
025 * Note: Prefer to use {@link AcmeJsonResource#fetch()}. Invoking
026 * {@link AcmeJsonResource#update()} and catching this exception is unnecessary
027 * complicated and a legacy from acme4j v2 which will disappear in a future release.
028 *
029 * @deprecated Will be removed in a future version.
030 */
031@Deprecated
032public class AcmeRetryAfterException extends AcmeException {
033    private static final long serialVersionUID = 4461979121063649905L;
034
035    private final Instant retryAfter;
036
037    /**
038     * Creates a new {@link AcmeRetryAfterException}.
039     *
040     * @param msg
041     *            Error details
042     * @param retryAfter
043     *            retry-after date returned by the server
044     */
045    public AcmeRetryAfterException(String msg, Instant retryAfter) {
046        super(msg);
047        this.retryAfter = Objects.requireNonNull(retryAfter);
048    }
049
050    /**
051     * Returns the retry-after instant returned by the server. This is only an estimate
052     * of when a retry attempt might succeed.
053     */
054    public Instant getRetryAfter() {
055        return retryAfter;
056    }
057
058}