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 */ 023 024package dk.netarkivet.archive.arcrepositoryadmin; 025 026import java.util.Set; 027 028import dk.netarkivet.archive.arcrepository.distribute.StoreMessage; 029import dk.netarkivet.common.distribute.arcrepository.Replica; 030import dk.netarkivet.common.distribute.arcrepository.ReplicaStoreState; 031 032/** 033 * The interface for the administration of the storage. This can be either a data file or a database. 034 */ 035public interface Admin { 036 /** 037 * Method for telling whether a file entry exists. 038 * 039 * @param filename The name of the file, the existence of whose entry is to be determined. 040 * @return Whether the entry exists. 041 */ 042 boolean hasEntry(String filename); 043 044 /** 045 * Method for adding an entry for administration. 046 * 047 * @param filename The name of the file to be stored. 048 * @param msg The StoreMessage of the entry. 049 * @param checksum The checksum of the entry. 050 */ 051 void addEntry(String filename, StoreMessage msg, String checksum); 052 053 /** 054 * Retrieves the checksum of a given file. 055 * 056 * @param filename The name of the file, whose checksum should be retrieved. 057 * @return The checksum of the file. 058 */ 059 String getCheckSum(String filename); 060 061 /** 062 * Sets the checksum of a given file. TODO Should it really be possible to change the checksum through 063 * arcrepository? 064 * 065 * @param filename The name of the file to have the checksum changed. 066 * @param checksum The new checksum for the file. 067 * @deprecated It should not be change the checksum through Admin. Only by voting through the bitpreservation 068 * interface should it be possible. 069 */ 070 void setCheckSum(String filename, String checksum); 071 072 /** 073 * Determines whether the StoreMessage of a given file exists. 074 * 075 * @param filename The name of the file to which the existence of the StoreMessage should be determined. 076 * @return Whether the StoreMessage of the file exists. 077 */ 078 boolean hasReplyInfo(String filename); 079 080 /** 081 * Assign a StoreMessage to a specific file. 082 * 083 * @param filename The name of the file to have a StoreMessage assigned. 084 * @param msg The StoreMessage to be assigned to a file. 085 */ 086 void setReplyInfo(String filename, StoreMessage msg); 087 088 /** 089 * Retrieves the StoreMessage of a specific file. 090 * 091 * @param filename The name of the file whose StoreMessage should be retrieved. 092 * @return The StoreMessage corresponding to the file. 093 */ 094 StoreMessage removeReplyInfo(String filename); 095 096 /** 097 * Returns the ReplicaStoreState of a given file in a specific replica. 098 * 099 * @param filename The name of the file for the ReplicaStoreState. 100 * @param replicaChannelName The name of the identification channel for the replica of for the ReplicaStoreState. 101 * @return The ReplicaStoreState of a given file in a specific replica. 102 */ 103 ReplicaStoreState getState(String filename, String replicaChannelName); 104 105 /** 106 * Determines whether a given file in a specific replica has a valid store state. 107 * 108 * @param filename The name of the file for the ReplicaStoreState. 109 * @param repChannelId The identification channel of the replica for the ReplicaStoreState. 110 * @return Whether a given file in a specific replica has a valid store state. 111 */ 112 boolean hasState(String filename, String repChannelId); 113 114 /** 115 * Sets the store state of an entry to a specific value. 116 * 117 * @param filename The name of the file for the entry. 118 * @param repChannelId The identification channel of the replica for the entry. 119 * @param state The new state for the entry. 120 */ 121 void setState(String filename, String repChannelId, ReplicaStoreState state); 122 123 /** 124 * Retrieves a set of the names for all the known files. 125 * 126 * @return A set of the names for all the known file. 127 */ 128 Set<String> getAllFileNames(); 129 130 /** 131 * Retrieves a set with the name of the files with a specific ReplicaStoreState in a specific replica. 132 * 133 * @param rep The replica where the files belong. 134 * @param state The ReplicaStoreState for the files. 135 * @return A set with the names of the files with a specific ReplicaStoreState in a specific replica. 136 */ 137 Set<String> getAllFileNames(Replica rep, ReplicaStoreState state); 138 139 /** 140 * Close and cleanup of this class. 141 */ 142 void close(); 143}