001/*
002 * #%L
003 * Netarchivesuite - harvester
004 * %%
005 * Copyright (C) 2005 - 2014 The Royal Danish Library, the Danish State and University Library,
006 *             the National Library of France and the Austrian National Library.
007 * %%
008 * This program is free software: you can redistribute it and/or modify
009 * it under the terms of the GNU Lesser General Public License as
010 * published by the Free Software Foundation, either version 2.1 of the
011 * License, or (at your option) any later version.
012 * 
013 * This program is distributed in the hope that it will be useful,
014 * but WITHOUT ANY WARRANTY; without even the implied warranty of
015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016 * GNU General Lesser Public License for more details.
017 * 
018 * You should have received a copy of the GNU General Lesser Public
019 * License along with this program.  If not, see
020 * <http://www.gnu.org/licenses/lgpl-2.1.html>.
021 * #L%
022 */
023package dk.netarkivet.harvester.distribute;
024
025import dk.netarkivet.common.distribute.ChannelID;
026import dk.netarkivet.common.exceptions.ArgumentNotValid;
027
028/**
029 * A message to send from the IndexServer to HarvestJobManager, that the index required by harvest with a given ID is
030 * ready.
031 */
032@SuppressWarnings({"serial"})
033public class IndexReadyMessage extends HarvesterMessage {
034
035    /** The ID for a specific harvest. */
036    private Long harvestId;
037    /** Is the index OK for the harvest. */
038    private boolean indexOK;
039
040    /**
041     * Constructor for the IndexReadyMessage.
042     *
043     * @param harvestId The harvestId that requires the index.
044     * @param indexIsOK is the index now OK or not
045     * @param to The destination channel
046     * @param replyTo The channel to reply to (not really used).
047     */
048    public IndexReadyMessage(Long harvestId, boolean indexIsOK, ChannelID to, ChannelID replyTo) {
049        super(to, replyTo);
050        ArgumentNotValid.checkNotNull(harvestId, "Long harvestId");
051        this.harvestId = harvestId;
052        this.indexOK = indexIsOK;
053    }
054
055    /**
056     * @return the Id of the harvest that requires this index.
057     */
058    public Long getHarvestId() {
059        return this.harvestId;
060    }
061
062    @Override
063    public void accept(HarvesterMessageVisitor v) {
064        v.visit(this);
065    }
066
067    /**
068     * Is the index OK.
069     *
070     * @return true, if the index is OK, else false.
071     */
072    public boolean getIndexOK() {
073        return indexOK;
074    }
075}