Package org.mycore.ocfl
Class MCROCFLXMLMetadataManager
java.lang.Object
org.mycore.ocfl.MCROCFLXMLMetadataManager
- All Implemented Interfaces:
MCRXMLMetadataManagerAdapter
Manages persistence of MCRObject and MCRDerivate xml metadata. Provides
methods to create, retrieve, update and delete object metadata using OCFL
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
create
(MCRObjectID mcrid, MCRContent xml, Date lastModified) Stores metadata of a new MCRObject in the persistent store.void
create
(MCRObjectID mcrid, MCRContent xml, Date lastModified, String user) void
delete
(MCRObjectID mcrid) Delete metadata in store.void
delete
(MCRObjectID mcrid, Date date, String user) boolean
exists
(MCRObjectID mcrid) Checks if an object with the given MCRObjectID exists in the store.int
getHighestStoredID
(String project, String type) This method returns the highest stored ID number for a given MCRObjectID base, or 0 if no object is stored for this type and project.long
getLastModified
(String ocflObjectId) long
Returns the time when the xml data of a MCRObject was last modified.getLastModifiedHandle
(MCRObjectID id, long expire, TimeUnit unit) Returns all used base ids of MCRObjects/MCRDerivates.Returns all stored object types of MCRObjects/MCRDerivates.edu.wisc.library.ocfl.api.OcflRepository
getStoredIDs
(String project, String type) listIDs()
Lists all MCRObjectIDs of all types and projects stored in any metadata storelistIDsForBase
(String base) Lists all MCRObjectIDs stored for the given base, which is {project}_{type}listIDsOfType
(String type) Lists all MCRObjectIDs stored for the given object type, for all projectsLists all versions of this metadata object available in the subversion repository.void
reload()
Reads configuration properties, checks and creates base directories and builds the singleton.retrieveContent
(MCRObjectID mcrid) Retrieves the (latest) content of a metadata object.retrieveContent
(MCRObjectID mcrid, String revision) Retrieves the content of a specific revision of a metadata object.retrieveObjectDates
(List<String> ids) Returns an enhanced list of object ids and their last modified datevoid
setRepositoryKey
(String repositoryKey) void
update
(MCRObjectID mcrid, MCRContent xml, Date lastModified) Updates metadata of existing MCRObject in the persistent store.void
update
(MCRObjectID mcrid, MCRContent xml, Date lastModified, String user) void
verifyStore
(String base) Try to validate a store.
-
Constructor Details
-
MCROCFLXMLMetadataManager
public MCROCFLXMLMetadataManager()
-
-
Method Details
-
getRepository
public edu.wisc.library.ocfl.api.OcflRepository getRepository() -
getRepositoryKey
-
setRepositoryKey
-
reload
public void reload()Description copied from interface:MCRXMLMetadataManagerAdapter
Reads configuration properties, checks and creates base directories and builds the singleton.- Specified by:
reload
in interfaceMCRXMLMetadataManagerAdapter
-
verifyStore
Description copied from interface:MCRXMLMetadataManagerAdapter
Try to validate a store.- Specified by:
verifyStore
in interfaceMCRXMLMetadataManagerAdapter
- Parameters:
base
- The base ID of a to-be-validated store
-
create
public void create(MCRObjectID mcrid, MCRContent xml, Date lastModified) throws MCRPersistenceException Description copied from interface:MCRXMLMetadataManagerAdapter
Stores metadata of a new MCRObject in the persistent store.- Specified by:
create
in interfaceMCRXMLMetadataManagerAdapter
- Parameters:
mcrid
- the MCRObjectIDxml
- the xml metadata of the MCRObjectlastModified
- the date of last modification to set- Throws:
MCRPersistenceException
- the object couldn't be created due persistence problems
-
create
public void create(MCRObjectID mcrid, MCRContent xml, Date lastModified, String user) throws MCRPersistenceException - Throws:
MCRPersistenceException
-
delete
Description copied from interface:MCRXMLMetadataManagerAdapter
Delete metadata in store.- Specified by:
delete
in interfaceMCRXMLMetadataManagerAdapter
- Parameters:
mcrid
- the MCRObjectID- Throws:
MCRPersistenceException
- if an error occurs during the deletion
-
delete
- Throws:
MCRPersistenceException
-
update
public void update(MCRObjectID mcrid, MCRContent xml, Date lastModified) throws MCRPersistenceException Description copied from interface:MCRXMLMetadataManagerAdapter
Updates metadata of existing MCRObject in the persistent store.- Specified by:
update
in interfaceMCRXMLMetadataManagerAdapter
- Parameters:
mcrid
- the MCRObjectIDxml
- the xml metadata of the MCRObjectlastModified
- the date of last modification to set- Throws:
MCRPersistenceException
-
update
public void update(MCRObjectID mcrid, MCRContent xml, Date lastModified, String user) throws MCRPersistenceException - Throws:
MCRPersistenceException
-
retrieveContent
Description copied from interface:MCRXMLMetadataManagerAdapter
Retrieves the (latest) content of a metadata object.- Specified by:
retrieveContent
in interfaceMCRXMLMetadataManagerAdapter
- Parameters:
mcrid
- the id of the object to be retrieved- Returns:
- a
MCRContent
representing theMCRObject
ornull
if there is no such object - Throws:
IOException
-
retrieveContent
Description copied from interface:MCRXMLMetadataManagerAdapter
Retrieves the content of a specific revision of a metadata object.- Specified by:
retrieveContent
in interfaceMCRXMLMetadataManagerAdapter
- Parameters:
mcrid
- the id of the object to be retrievedrevision
- the revision to be returned, specify -1 if you want to retrieve the latest revision (includes deleted objects also)- Returns:
- a
MCRContent
representing theMCRObject
of the given revision ornull
if there is no such object with the given revision - Throws:
IOException
-
listRevisions
Description copied from interface:MCRXMLMetadataManagerAdapter
Lists all versions of this metadata object available in the subversion repository.- Specified by:
listRevisions
in interfaceMCRXMLMetadataManagerAdapter
- Parameters:
id
- the id of the object to be retrieved- Returns:
List
with allMCRMetadataVersion
of the given object or null if the id is null or the metadata store doesn't support versioning
-
getStoredIDs
- Throws:
MCRPersistenceException
-
getHighestStoredID
Description copied from interface:MCRXMLMetadataManagerAdapter
This method returns the highest stored ID number for a given MCRObjectID base, or 0 if no object is stored for this type and project.- Specified by:
getHighestStoredID
in interfaceMCRXMLMetadataManagerAdapter
- Parameters:
project
- the project ID part of the MCRObjectID basetype
- the type ID part of the MCRObjectID base- Returns:
- the highest stored ID number as a String
-
exists
Description copied from interface:MCRXMLMetadataManagerAdapter
Checks if an object with the given MCRObjectID exists in the store.- Specified by:
exists
in interfaceMCRXMLMetadataManagerAdapter
- Parameters:
mcrid
- the MCRObjectID to check- Returns:
- true if the ID exists, or false if it doesn't
- Throws:
MCRPersistenceException
- if an error occurred in the store
-
listIDsForBase
Description copied from interface:MCRXMLMetadataManagerAdapter
Lists all MCRObjectIDs stored for the given base, which is {project}_{type}- Specified by:
listIDsForBase
in interfaceMCRXMLMetadataManagerAdapter
- Parameters:
base
- the MCRObjectID base, e.g. DocPortal_document- Returns:
- List of Strings with all MyCoRe identifiers found in the metadata stores for the given base
-
listIDsOfType
Description copied from interface:MCRXMLMetadataManagerAdapter
Lists all MCRObjectIDs stored for the given object type, for all projects- Specified by:
listIDsOfType
in interfaceMCRXMLMetadataManagerAdapter
- Parameters:
type
- the MCRObject type, e.g. document- Returns:
- List of Strings with all MyCoRe identifiers found in the metadata store for the given type
-
listIDs
Description copied from interface:MCRXMLMetadataManagerAdapter
Lists all MCRObjectIDs of all types and projects stored in any metadata store- Specified by:
listIDs
in interfaceMCRXMLMetadataManagerAdapter
- Returns:
- List of Strings with all MyCoRe identifiers found in the metadata store
-
getObjectTypes
Description copied from interface:MCRXMLMetadataManagerAdapter
Returns all stored object types of MCRObjects/MCRDerivates.- Specified by:
getObjectTypes
in interfaceMCRXMLMetadataManagerAdapter
- Returns:
- Collection of Strings with all object types
- See Also:
-
getObjectBaseIds
Description copied from interface:MCRXMLMetadataManagerAdapter
Returns all used base ids of MCRObjects/MCRDerivates.- Specified by:
getObjectBaseIds
in interfaceMCRXMLMetadataManagerAdapter
- Returns:
- Collection of Strings with all object base identifier
- See Also:
-
retrieveObjectDates
Description copied from interface:MCRXMLMetadataManagerAdapter
Returns an enhanced list of object ids and their last modified date- Specified by:
retrieveObjectDates
in interfaceMCRXMLMetadataManagerAdapter
- Parameters:
ids
- MCRObject ids- Throws:
IOException
-
getLastModified
Description copied from interface:MCRXMLMetadataManagerAdapter
Returns the time when the xml data of a MCRObject was last modified.- Specified by:
getLastModified
in interfaceMCRXMLMetadataManagerAdapter
- Parameters:
id
- the MCRObjectID of an object- Returns:
- the last modification data of the object
- Throws:
IOException
- thrown while retrieving the object from the store
-
getLastModified
- Throws:
IOException
-
getLastModifiedHandle
- Specified by:
getLastModifiedHandle
in interfaceMCRXMLMetadataManagerAdapter
- Returns:
-