Class BitmagUtils
- java.lang.Object
-
- dk.netarkivet.common.distribute.bitrepository.BitmagUtils
-
public class BitmagUtils extends java.lang.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 java.lang.String
BITREPOSITORY_COLLECTIONID
static java.lang.String
BITREPOSITORY_GETFILEIDS_MAX_RESULTS
static java.lang.String
BITREPOSITORY_KEYFILENAME
static java.lang.String
BITREPOSITORY_SETTINGS_DIR
static java.lang.String
BITREPOSITORY_STORE_MAX_PILLAR_FAILURES
static java.lang.String
BITREPOSITORY_TEMPDIR
static java.lang.String
BITREPOSITORY_USEPILLAR
-
Constructor Summary
Constructors Constructor Description BitmagUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.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 java.lang.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 java.net.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 java.util.List<java.lang.String>
getKnownCollections()
Method to get the list of known collectionsstatic java.util.List<java.lang.String>
getKnownPillars(java.lang.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(java.io.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 java.lang.String BITREPOSITORY_GETFILEIDS_MAX_RESULTS
- See Also:
- Constant Field Values
-
BITREPOSITORY_TEMPDIR
public static final java.lang.String BITREPOSITORY_TEMPDIR
- See Also:
- Constant Field Values
-
BITREPOSITORY_KEYFILENAME
public static final java.lang.String BITREPOSITORY_KEYFILENAME
- See Also:
- Constant Field Values
-
BITREPOSITORY_STORE_MAX_PILLAR_FAILURES
public static final java.lang.String BITREPOSITORY_STORE_MAX_PILLAR_FAILURES
- See Also:
- Constant Field Values
-
BITREPOSITORY_COLLECTIONID
public static final java.lang.String BITREPOSITORY_COLLECTIONID
- See Also:
- Constant Field Values
-
BITREPOSITORY_USEPILLAR
public static final java.lang.String BITREPOSITORY_USEPILLAR
- See Also:
- Constant Field Values
-
BITREPOSITORY_SETTINGS_DIR
public static java.lang.String BITREPOSITORY_SETTINGS_DIR
-
-
Constructor Detail
-
BitmagUtils
public BitmagUtils()
-
-
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 java.util.List<java.lang.String> getKnownPillars(java.lang.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 java.util.List<java.lang.String> getKnownCollections()
Method to get the list of known collections- Returns:
- the list of known collectionIDs
-
generateComponentID
public static java.lang.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 java.net.URL getFileExchangeBaseURL() throws java.net.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:
java.net.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(java.io.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 java.lang.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
-
-