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.archive.distribute.ArchiveMessage; 026import dk.netarkivet.archive.distribute.ArchiveMessageVisitor; 027import dk.netarkivet.common.distribute.ChannelID; 028import dk.netarkivet.common.distribute.RemoteFile; 029import dk.netarkivet.common.exceptions.ArgumentNotValid; 030 031/** 032 * Container for upload request. 033 */ 034@SuppressWarnings({"serial"}) 035public class UploadMessage extends ArchiveMessage { 036 /** the name of the file to upload. */ 037 private String arcfileName; 038 039 /** The actual data. */ 040 private RemoteFile theRemoteFile; 041 042 /** 043 * Construct UploadMessage. 044 * 045 * @param to Channel to message to 046 * @param replyTo Channel to reply back to 047 * @param rf The RemoteFile to upload 048 */ 049 public UploadMessage(ChannelID to, ChannelID replyTo, RemoteFile rf) { 050 super(to, replyTo); 051 ArgumentNotValid.checkNotNull(rf, "rf"); 052 arcfileName = rf.getName(); 053 theRemoteFile = rf; 054 } 055 056 /** 057 * Retrieve name of the uploaded file. 058 * 059 * @return current value of arcfileName 060 */ 061 public String getArcfileName() { 062 return arcfileName; 063 } 064 065 /** 066 * Get method for field theRemoteFile. 067 * 068 * @return Current value of theRemoteFile 069 */ 070 public RemoteFile getRemoteFile() { 071 return theRemoteFile; 072 } 073 074 /** 075 * Should be implemented as a part of the visitor pattern. fx.: public void accept(ArchiveMessageVisitor v) { 076 * v.visit(this); } 077 * 078 * @param v A message visitor 079 */ 080 public void accept(ArchiveMessageVisitor v) { 081 v.visit(this); 082 } 083 084 /** 085 * Generate String representation of this object. 086 * 087 * @return String representation of this object 088 */ 089 public String toString() { 090 return super.toString() + " Arcfile: " + arcfileName; 091 } 092 093}