/
ViewerArcRepositoryClient.java
74 lines (66 loc) · 2.99 KB
/
ViewerArcRepositoryClient.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
* #%L
* Netarchivesuite - common
* %%
* Copyright (C) 2005 - 2018 The Royal Danish Library,
* the National Library of France and the Austrian National Library.
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 2.1 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
package dk.netarkivet.common.distribute.arcrepository;
import java.io.File;
import dk.netarkivet.common.exceptions.ArgumentNotValid;
import dk.netarkivet.common.exceptions.IOFailure;
import dk.netarkivet.common.utils.batch.FileBatchJob;
/**
* Implements the Facade pattern to shield off the methods in JMSArcRepositoryClient not to be used by the bit
* preservation system.
*/
public interface ViewerArcRepositoryClient extends AutoCloseable{
/** Call on shutdown to release external resources. */
@Override
void close();
/**
* Gets a single ARC record out of the ArcRepository.
*
* @param arcfile The name of a file containing the desired record.
* @param index The offset of the desired record in the file
* @return a BitarchiveRecord-object, or null if request times out or object is not found.
* @throws ArgumentNotValid If the get operation failed.
*/
BitarchiveRecord get(String arcfile, long index) throws ArgumentNotValid;
/**
* Retrieves a file from an ArcRepository and places it in a local file.
*
* @param arcfilename Name of the arcfile to retrieve.
* @param replica The bitarchive to retrieve the data from.
* @param toFile Filename of a place where the file fetched can be put.
* @throws IOFailure if there are problems getting a reply or the file could not be found.
*/
void getFile(String arcfilename, Replica replica, File toFile);
/**
* Runs a batch batch job on each file in the ArcRepository.
*
* @param job An object that implements the FileBatchJob interface. The initialize() method will be called before
* processing and the finish() method will be called afterwards. The process() method will be called with each File
* entry. An optional function postProcess() allows handling the combined results of the batchjob, e.g. summing the
* results, sorting, etc.
* @param replicaId The archive to execute the job on.
* @param args The arguments for the batchjob.
* @return The status of the batch job after it ended.
*/
BatchStatus batch(FileBatchJob job, String replicaId, String... args);
}