package com.atlassian.bitbucket.mirroring.mirror;

import com.atlassian.bitbucket.event.repository.RepositoryEvent;
import com.atlassian.bitbucket.repository.Repository;
import com.atlassian.event.api.AsynchronousPreferred;

import javax.annotation.Nonnull;

import static java.util.Objects.requireNonNull;

/**
 * Event that is raised when a mirrored repository has failed to update.
 *
 * @since 4.3
 */
@AsynchronousPreferred
public class RepositorySynchronizationFailedEvent extends RepositoryEvent {

    private final String upstreamServerId;

    public RepositorySynchronizationFailedEvent(@Nonnull Object source, @Nonnull Repository repository,
                                                @Nonnull String upstreamServerId) {
        super(source, repository);
        this.upstreamServerId = requireNonNull(upstreamServerId, "upstreamServerId");
    }

    @Nonnull
    public String getUpstreamServer() {
        return upstreamServerId;
    }
}
