Package org.mycore.pi
Class MCRPIService<T extends MCRPersistentIdentifier>
java.lang.Object
org.mycore.pi.MCRPIService<T>
- Direct Known Subclasses:
MCRPIJobService
,MCRURNGranularOAIService
,MCRURNGranularRESTService
,MCRURNOAIService
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
addFlagToObject
(MCRBase obj, MCRPI databaseEntry) protected void
Checks the service parameters.protected abstract void
Should handle deletion of a Object with the PI.protected MCRPIGenerator<T>
protected static com.google.gson.Gson
getGson()
protected T
getNewIdentifier
(MCRBase id, String additional) getPredicateInstance
(String predicateProperty) final String
protected MCRPI
getTableEntry
(MCRObjectID id, String additional) final String
getType()
static boolean
hasFlag
(MCRBase obj, String additional, MCRPIRegistrationInfo mcrpi) static boolean
hasFlag
(MCRObjectID id, String additional, MCRPIRegistrationInfo mcrpi) boolean
hasRegistrationStarted
(MCRObjectID id, String additional) void
insertIdentifierToDatabase
(MCRBase obj, String additional, T identifier) boolean
isCreated
(MCRObjectID id, String additional) boolean
isRegistered
(MCRObjectID id, String additional) protected final void
protected final void
protected Date
provideRegisterDate
(MCRBase obj, String additional) Adds a identifier to the object.shorthand forregister(MCRBase, String, boolean)
with update = trueValidates everything, registers a new Identifier, inserts the identifier to object metadata and writes a information to the Database.protected abstract void
registerIdentifier
(MCRBase obj, String additional, T pi) static MCRPI
removeFlagFromObject
(MCRBase obj, MCRPI databaseEntry) Removes a flag from aMCRObject
protected String
requireNotEmptyProperty
(String propertyName) Validates a property of this servicevoid
setProperties
(Map<String, String> properties) protected abstract void
Should handle updates of a Object with the PI.void
updateFlag
(MCRObjectID id, String additional, MCRPI mcrpi) static void
protected void
validateAlreadyCreated
(MCRObjectID id, String additional) protected void
validatePermission
(MCRBase obj, boolean writePermission) void
validateRegistration
(MCRBase obj, String additional) Validates if an object can get an Identifier assigned from this service!void
validateRegistration
(MCRBase obj, String additional, boolean checkWritePermission)
-
Field Details
-
REGISTRATION_CONFIG_PREFIX
- See Also:
-
GENERATOR_CONFIG_PREFIX
- See Also:
-
METADATA_SERVICE_CONFIG_PREFIX
- See Also:
-
PI_FLAG
- See Also:
-
GENERATOR_PROPERTY_KEY
- See Also:
-
METADATA_SERVICE_PROPERTY_KEY
- See Also:
-
TRANSLATE_PREFIX
- See Also:
-
-
Constructor Details
-
MCRPIService
-
-
Method Details
-
init
-
getGson
protected static com.google.gson.Gson getGson() -
getServiceID
-
checkConfiguration
Checks the service parameters.- Throws:
MCRConfigurationException
- if parameter is missing or wrong!
-
getMetadataService
-
getGenerator
-
addFlagToObject
-
removeFlagFromObject
Removes a flag from aMCRObject
- Parameters:
obj
- the objectdatabaseEntry
- the database entry- Returns:
- the remove entry parsed from json or null
-
hasFlag
-
hasFlag
-
validatePermission
- Throws:
MCRAccessException
-
validateAlreadyCreated
protected void validateAlreadyCreated(MCRObjectID id, String additional) throws MCRPersistentIdentifierException - Throws:
MCRPersistentIdentifierException
-
validateRegistration
public void validateRegistration(MCRBase obj, String additional) throws MCRPersistentIdentifierException, MCRAccessException Validates if an object can get an Identifier assigned from this service! Better call super when overwrite!- Parameters:
obj
-- Throws:
MCRPersistentIdentifierException
- seeorg.mycore.pi.exceptions
MCRAccessException
- if the user does not have the rights to assign a pi to the specific object
-
validateRegistration
public void validateRegistration(MCRBase obj, String additional, boolean checkWritePermission) throws MCRPersistentIdentifierException, MCRAccessException -
register
public T register(MCRBase obj, String additional) throws MCRAccessException, MCRActiveLinkException, MCRPersistentIdentifierException, ExecutionException, InterruptedException shorthand forregister(MCRBase, String, boolean)
with update = true -
register
public T register(MCRBase obj) throws MCRAccessException, MCRActiveLinkException, MCRPersistentIdentifierException, ExecutionException, InterruptedException Adds a identifier to the object. Validates everything, registers a new Identifier, inserts the identifier to object metadata and writes a information to the Database.- Parameters:
obj
- the object which has to be identified- Returns:
- the assigned Identifier
- Throws:
MCRAccessException
- the current User doesn't have the rights to insert the Identifier to MetadataMCRActiveLinkException
- theMCRPIMetadataService
letsMCRMetadataManager.update(MCRObject)
throw thisMCRPersistentIdentifierException
- seeorg.mycore.pi.exceptions
ExecutionException
InterruptedException
-
register
public T register(MCRBase obj, String additional, boolean updateObject) throws MCRAccessException, MCRActiveLinkException, MCRPersistentIdentifierException, ExecutionException, InterruptedException Validates everything, registers a new Identifier, inserts the identifier to object metadata and writes a information to the Database.- Parameters:
obj
- the object which has to be identifiedadditional
- additional information for the persistent identifierupdateObject
- if true this method callsMCRMetadataManager.update(MCRBase)
- Returns:
- the assigned Identifier
- Throws:
MCRAccessException
- the current User doesn't have the rights to insert the Identifier to MetadataMCRActiveLinkException
- theMCRPIMetadataService
letsMCRMetadataManager.update(MCRObject)
throw thisMCRPersistentIdentifierException
- seeorg.mycore.pi.exceptions
ExecutionException
InterruptedException
-
provideRegisterDate
-
insertIdentifierToDatabase
-
updateFlagsInDatabase
-
getType
-
registerIdentifier
protected abstract void registerIdentifier(MCRBase obj, String additional, T pi) throws MCRPersistentIdentifierException - Throws:
MCRPersistentIdentifierException
-
onDelete
protected final void onDelete(T identifier, MCRBase obj, String additional) throws MCRPersistentIdentifierException - Throws:
MCRPersistentIdentifierException
-
onUpdate
protected final void onUpdate(T identifier, MCRBase obj, String additional) throws MCRPersistentIdentifierException - Throws:
MCRPersistentIdentifierException
-
delete
protected abstract void delete(T identifier, MCRBase obj, String additional) throws MCRPersistentIdentifierException Should handle deletion of a Object with the PI. E.g. TheMCRDOIService
sets the active flag in Datacite datacentre to false.- Parameters:
identifier
- the Identifierobj
- the deleted objectadditional
-- Throws:
MCRPersistentIdentifierException
- to abort deletion of the object or if something went wrong, (e.g.MCRDOIService
throws if not a superuser tries to delete the object)
-
update
protected abstract void update(T identifier, MCRBase obj, String additional) throws MCRPersistentIdentifierException Should handle updates of a Object with the PI. E.g. TheMCRDOIService
sends the updated metadata to the Datacite datacentre.- Parameters:
identifier
- the Identifierobj
- the deleted objectadditional
-- Throws:
MCRPersistentIdentifierException
- to abort update of the object or if something went wrong.
-
isCreated
-
isRegistered
-
hasRegistrationStarted
-
getProperties
-
setProperties
-
getNewIdentifier
- Throws:
MCRPersistentIdentifierException
-
getTableEntry
-
updateFlag
-
requireNotEmptyProperty
Validates a property of this service- Parameters:
propertyName
- the property to check- Returns:
- the property
- Throws:
MCRConfigurationException
- if property is not set or empty
-
getCreationPredicate
-
getRegistrationPredicate
-
getPredicateInstance
-