/*
 * Copyright 2014-2017 Groupon, Inc
 * Copyright 2014-2017 The Billing Project, LLC
 *
 * The Billing Project licenses this file to you under the Apache License, version 2.0
 * (the "License"); you may not use this file except in compliance with the
 * License.  You may obtain a copy of the License at:
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */

package org.killbill.billing.invoice.plugin.api;

import java.util.Arrays;
import java.util.List;

import org.joda.time.Period;

public class InvoicePluginApiRetryException extends RuntimeException {

    public static final List<Period> DEFAULT_RETRY_SCHEDULE = Arrays.asList(Period.minutes(5),
                                                                            Period.minutes(15),
                                                                            Period.hours(1),
                                                                            Period.hours(6),
                                                                            Period.hours(24));

    private final List<Period> retrySchedule;

    public InvoicePluginApiRetryException() {
        this(null, null);
    }

    public InvoicePluginApiRetryException(final Exception e) {
        this(e, null);
    }

    public InvoicePluginApiRetryException(final List<Period> retrySchedule) {
        this(null, retrySchedule);
    }

    public InvoicePluginApiRetryException(final Exception e, final List<Period> retrySchedule) {
        super(e);
        this.retrySchedule = retrySchedule != null ? retrySchedule : DEFAULT_RETRY_SCHEDULE;
    }

    public List<Period> getRetrySchedule() {
        return retrySchedule;
    }

    @Override
    public String toString() {
        return String.format("%s (retrySchedule: %s)", super.toString(), retrySchedule);
    }
}

/*
 * Copyright 2014-2017 Groupon, Inc
 * Copyright 2014-2017 The Billing Project, LLC
 *
 * The Billing Project licenses this file to you under the Apache License, version 2.0
 * (the "License"); you may not use this file except in compliance with the
 * License.  You may obtain a copy of the License at:
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */

package org.killbill.billing.invoice.plugin.api;

import org.killbill.billing.util.queue.QueueRetryException;

public class InvoicePluginApiRetryException extends QueueRetryException {
}

make InvoicePluginApiRetryException extend QueueRetryException