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.checksum.distribute; 024 025import dk.netarkivet.archive.bitarchive.distribute.UploadMessage; 026import dk.netarkivet.archive.distribute.ArchiveMessageHandler; 027import dk.netarkivet.common.distribute.ChannelID; 028import dk.netarkivet.common.distribute.JMSConnection; 029import dk.netarkivet.common.utils.CleanupIF; 030 031/** 032 * Any subclass must be invoked through a method called 'getInstance'. 033 */ 034public abstract class ChecksumArchiveServer extends ArchiveMessageHandler implements CleanupIF { 035 036 /** 037 * The JMS connection. 038 */ 039 protected JMSConnection jmsCon; 040 041 /** 042 * The unique id for this instance. 043 */ 044 protected String checksumAppId; 045 046 /** 047 * The channel used for communication. 048 */ 049 protected ChannelID theCR; 050 051 /** 052 * Method for closing. 053 */ 054 abstract void close(); 055 056 /** 057 * Method for cleaning up. 058 */ 059 public abstract void cleanup(); 060 061 /** 062 * Method for retrieving the application id. 063 * 064 * @return The application id. 065 */ 066 public abstract String getAppId(); 067 068 /** 069 * Requiring all inheritors of this interface to handle the UploadMessage. The data should be fetched and put into 070 * the archive. 071 * 072 * @param msg The UploadMessage to be handled. 073 */ 074 public abstract void visit(UploadMessage msg); 075 076 /** 077 * Requiring all inheritors of this interface to handle the CorrectMessage. If an entry in the archive corresponds 078 * to the 'wrong' entry described in the CorrectMessage, then the file in the CorrectMessage should replace the 079 * current entry in the archive. 080 * 081 * @param msg The CorrectMessage to be handled. 082 */ 083 public abstract void visit(CorrectMessage msg); 084 085 /** 086 * Requiring all inheritors of this interface to handle the GetChecksumMessage. The checksum of the wanted entry in 087 * the archive should be fetched and returned. 088 * 089 * @param msg The GetChecksumMessage to be handled. 090 */ 091 public abstract void visit(GetChecksumMessage msg); 092 093 /** 094 * Requiring all inheritors of this interface to handle the GetAllChecksumMessage. The entire archive should be put 095 * into a file corresponding to a ChecksumJob file, then made into a remote file and sent back through the reply. 096 * 097 * @param msg The GetAllChecksumMessage to be handled. 098 */ 099 public abstract void visit(GetAllChecksumsMessage msg); 100 101 /** 102 * Requiring all inheritors of this interface to handle the GetAllFilenamesMessage. The filenames of all the entries 103 * in the archive should be placed in a file corresponding to a FilelistJob and sent back through the reply. 104 * 105 * @param msg The GetAllFilenamesMessage to be handled. 106 */ 107 public abstract void visit(GetAllFilenamesMessage msg); 108}