001/* 002 * #%L 003 * Netarchivesuite - archive 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.archive.bitarchive.distribute; 024 025import dk.netarkivet.common.distribute.ChannelID; 026import dk.netarkivet.common.distribute.Channels; 027import dk.netarkivet.common.distribute.NetarkivetMessage; 028import dk.netarkivet.common.exceptions.ArgumentNotValid; 029 030/** 031 * Message for telling the bitarchives to terminate a specific batchjob. 032 */ 033@SuppressWarnings({"serial"}) 034public class BatchTerminationMessage extends NetarkivetMessage { 035 036 /** The ID of the batchjob to terminate. */ 037 private String terminateID; 038 039 /** 040 * Constructor. 041 * 042 * @param to Where the message should be sent. 043 * @param batchID The ID of the batchjob to terminate. 044 * @throws ArgumentNotValid If the batchID is either null or the empty string. 045 */ 046 public BatchTerminationMessage(ChannelID to, String batchID) throws ArgumentNotValid { 047 this(to, Channels.getError(), batchID); 048 } 049 050 /** 051 * Constructor. 052 * 053 * @param to Where the message should be sent. 054 * @param replyTo Where the message is sent from. 055 * @param batchID The ID of the batchjob to terminate. 056 * @throws ArgumentNotValid If the batchID is either null or the empty string. 057 */ 058 public BatchTerminationMessage(ChannelID to, ChannelID replyTo, String batchID) throws ArgumentNotValid { 059 super(to, replyTo); 060 ArgumentNotValid.checkNotNullOrEmpty(batchID, "String batchID"); 061 terminateID = batchID; 062 } 063 064 /** 065 * Method for retrieving the ID of the batchjob to terminate. 066 * 067 * @return The ID of the batchjob to terminate. 068 */ 069 public String getTerminateID() { 070 return terminateID; 071 } 072 073 /** 074 * Extends the default toString of NetarkiveMessage with the terminateID. 075 * 076 * @return The string representation of this message. 077 */ 078 public String toString() { 079 return super.toString() + ", terminateID = " + terminateID; 080 } 081}