Class BitmagUtils
- java.lang.Object
-
- dk.netarkivet.common.distribute.bitrepository.BitmagUtils
-
public class BitmagUtils extends Object
Utility class to abstract away the specifics of setting up and obtaining bitrepository.org clients.
-
-
Field Summary
Fields Modifier and Type Field Description static String
BITREPOSITORY_COLLECTIONID
static String
BITREPOSITORY_GETFILEIDS_MAX_RESULTS
static String
BITREPOSITORY_KEYFILENAME
static String
BITREPOSITORY_SETTINGS_DIR
static String
BITREPOSITORY_STORE_MAX_PILLAR_FAILURES
static String
BITREPOSITORY_TEMPDIR
static String
BITREPOSITORY_USEPILLAR
-
Constructor Summary
Constructors Constructor Description BitmagUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
generateComponentID()
Generates a component id, which includes the hostname and a random UUID.static org.bitrepository.access.getchecksums.GetChecksumsClient
getChecksumsClient()
Retreive a GetChecksumsClientstatic org.bitrepository.bitrepositoryelements.ChecksumSpecTYPE
getChecksumSpec(org.bitrepository.bitrepositoryelements.ChecksumType checksumType)
static String
getDefaultCollectionID()
Retrieves the default collectionID to use from settings.static org.bitrepository.access.getfile.GetFileClient
getFileClient()
Retreive a GetFileClientstatic org.bitrepository.protocol.FileExchange
getFileExchange()
Method to retrieve the instance of the FileExchange.static URL
getFileExchangeBaseURL()
Method to get the base part of the URL to the file exchange server.static org.bitrepository.access.getfileids.GetFileIDsClient
getFileIDsClient()
Retreive a GetFileIDsClientstatic List<String>
getKnownCollections()
Method to get the list of known collectionsstatic List<String>
getKnownPillars(String collectionID)
Method to get the list of known pillars in a collectionstatic org.bitrepository.modify.putfile.PutFileClient
getPutFileClient()
Retreive a PutFileClientstatic org.bitrepository.bitrepositoryelements.ChecksumDataForFileTYPE
getValidationChecksum(File file, org.bitrepository.bitrepositoryelements.ChecksumSpecTYPE csSpec)
Creates the data structure for encapsulating the validation checksums for validation of the PutFile operation.static void
initialize()
Method to initialize the utility class.static void
shutdown()
Method to shutdown the bitrepository connections if such exists.
-
-
-
Field Detail
-
BITREPOSITORY_GETFILEIDS_MAX_RESULTS
public static final String BITREPOSITORY_GETFILEIDS_MAX_RESULTS
- See Also:
- Constant Field Values
-
BITREPOSITORY_TEMPDIR
public static final String BITREPOSITORY_TEMPDIR
- See Also:
- Constant Field Values
-
BITREPOSITORY_KEYFILENAME
public static final String BITREPOSITORY_KEYFILENAME
- See Also:
- Constant Field Values
-
BITREPOSITORY_STORE_MAX_PILLAR_FAILURES
public static final String BITREPOSITORY_STORE_MAX_PILLAR_FAILURES
- See Also:
- Constant Field Values
-
BITREPOSITORY_COLLECTIONID
public static final String BITREPOSITORY_COLLECTIONID
- See Also:
- Constant Field Values
-
BITREPOSITORY_USEPILLAR
public static final String BITREPOSITORY_USEPILLAR
- See Also:
- Constant Field Values
-
BITREPOSITORY_SETTINGS_DIR
public static String BITREPOSITORY_SETTINGS_DIR
-
-
Method Detail
-
initialize
public static void initialize()
Method to initialize the utility class. Must be called prior to use of any other method as it initializes internal state.
-
getKnownPillars
public static List<String> getKnownPillars(String collectionID)
Method to get the list of known pillars in a collection- Parameters:
collectionID
- The ID of the collection to obtain pillars for- Returns:
- the list of known pillarIDs
-
getKnownCollections
public static List<String> getKnownCollections()
Method to get the list of known collections- Returns:
- the list of known collectionIDs
-
generateComponentID
public static String generateComponentID()
Generates a component id, which includes the hostname and a random UUID.- Returns:
- The Bitrepository component id for this NetarchiveSuite application.
-
getFileExchangeBaseURL
public static URL getFileExchangeBaseURL() throws MalformedURLException
Method to get the base part of the URL to the file exchange server.- Returns:
URL
URL with the base part of the file exchange server.- Throws:
MalformedURLException
- if the file exchange configuration results in an invalid url
-
getFileExchange
public static org.bitrepository.protocol.FileExchange getFileExchange()
Method to retrieve the instance of the FileExchange. To be used for transferring files to and from the FileExchange server- Returns:
FileExchange
The FileExchange instance
-
getValidationChecksum
public static org.bitrepository.bitrepositoryelements.ChecksumDataForFileTYPE getValidationChecksum(File file, org.bitrepository.bitrepositoryelements.ChecksumSpecTYPE csSpec)
Creates the data structure for encapsulating the validation checksums for validation of the PutFile operation.- Parameters:
file
- The file to have the checksum calculated.csSpec
- A given ChecksumSpecTYPE- Returns:
- The ChecksumDataForFileTYPE for the pillars to validate the PutFile operation.
-
getChecksumSpec
public static org.bitrepository.bitrepositoryelements.ChecksumSpecTYPE getChecksumSpec(org.bitrepository.bitrepositoryelements.ChecksumType checksumType)
-
getPutFileClient
public static org.bitrepository.modify.putfile.PutFileClient getPutFileClient()
Retreive a PutFileClient- Returns:
PutFileClient
The PutFileClient
-
getFileIDsClient
public static org.bitrepository.access.getfileids.GetFileIDsClient getFileIDsClient()
Retreive a GetFileIDsClient- Returns:
GetFileIDsClient
The GetFileIDsClient
-
getChecksumsClient
public static org.bitrepository.access.getchecksums.GetChecksumsClient getChecksumsClient()
Retreive a GetChecksumsClient- Returns:
GetChecksumsClient
The GetChecksumsClient
-
getFileClient
public static org.bitrepository.access.getfile.GetFileClient getFileClient()
Retreive a GetFileClient- Returns:
GetFileClient
The GetFileClient
-
getDefaultCollectionID
public static String getDefaultCollectionID()
Retrieves the default collectionID to use from settings. If the collectionID is not set it defaults to the environment name.- Returns:
- The ID of the default collection to execute actions on.
-
shutdown
public static void shutdown() throws javax.jms.JMSException
Method to shutdown the bitrepository connections if such exists. Should only be called when all interactions with the bitrepository from this client is done.- Throws:
javax.jms.JMSException
- if there is trouble shutting down the messagebus connection
-
-