Package org.mycore.pi
Class MCRPIJobService<T extends MCRPersistentIdentifier>
java.lang.Object
org.mycore.pi.MCRPIService<T>
org.mycore.pi.MCRPIJobService<T>
- Type Parameters:
T
-
- Direct Known Subclasses:
MCRDOIBaseService
,MCREpicService
,MCRPURLService
Implementation of a
MCRPIService
which helps to outsource a registration task to a MCRJob
e.G. send a POST request to a REST api-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final String
static final String
protected static final String
Fields inherited from class org.mycore.pi.MCRPIService
GENERATOR_CONFIG_PREFIX, GENERATOR_PROPERTY_KEY, METADATA_SERVICE_CONFIG_PREFIX, METADATA_SERVICE_PROPERTY_KEY, PI_FLAG, REGISTRATION_CONFIG_PREFIX, TRANSLATE_PREFIX
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
addDeleteJob
(Map<String, String> contextParameters) protected void
addRegisterJob
(Map<String, String> contextParameters) Adds a register job which will be called in the persistentMCRJob
environment in a extra thread.protected void
addUpdateJob
(Map<String, String> contextParameters) protected void
Checks the service parameters.protected abstract void
protected MCRPIJobService.PiJobAction
getJobInformation
(Map<String, String> contextParameters) Result of this will be passed toMCRJobAction.name()
Deprecated.parseIdentifier
(String identifier) Tries to parse a identifier with a specific type.protected abstract void
registerJob
(Map<String, String> parameters) protected void
rollbackDeleteJob
(Map<String, String> parameters) Hook in to rollback mechanism ofMCRJobAction.rollback()
by overwriting this method.protected void
rollbackRegisterJob
(Map<String, String> parameters) Hook in to rollback mechanism ofMCRJobAction.rollback()
by overwriting this method.protected void
rollbackUpdateJob
(Map<String, String> parameters) Hook in to rollback mechanism ofMCRJobAction.rollback()
by overwriting this method.void
runAsJobUser
(org.mycore.pi.MCRPIJobService.PIRunnable task) protected abstract void
protected void
updateRegistrationDate
(MCRObjectID mycoreID, String additional, Date date) Can be used to update the registration date in the database.protected void
updateStartRegistrationDate
(MCRObjectID mycoreID, String additional, Date date) Can be used to update the startRegistration date in the database.protected void
If you useupdateRegistrationDate(MCRObjectID, String, Date)
orupdateStartRegistrationDate(MCRObjectID, String, Date)
then you should validate if the user has the rights for this.Methods inherited from class org.mycore.pi.MCRPIService
addFlagToObject, delete, getCreationPredicate, getGenerator, getGson, getMetadataService, getNewIdentifier, getPredicateInstance, getProperties, getRegistrationPredicate, getServiceID, getTableEntry, getType, hasFlag, hasFlag, hasRegistrationStarted, init, insertIdentifierToDatabase, isCreated, isRegistered, onDelete, onUpdate, provideRegisterDate, register, register, register, registerIdentifier, removeFlagFromObject, requireNotEmptyProperty, setProperties, update, updateFlag, updateFlagsInDatabase, validateAlreadyCreated, validatePermission, validateRegistration, validateRegistration
-
Field Details
-
JOB_API_USER_PROPERTY
- See Also:
-
REGISTRATION_PREDICATE
- See Also:
-
CREATION_PREDICATE
- See Also:
-
-
Constructor Details
-
MCRPIJobService
-
-
Method Details
-
deleteJob
protected abstract void deleteJob(Map<String, String> parameters) throws MCRPersistentIdentifierException- Throws:
MCRPersistentIdentifierException
-
updateJob
protected abstract void updateJob(Map<String, String> parameters) throws MCRPersistentIdentifierException- Throws:
MCRPersistentIdentifierException
-
registerJob
protected abstract void registerJob(Map<String, String> parameters) throws MCRPersistentIdentifierException- Throws:
MCRPersistentIdentifierException
-
rollbackDeleteJob
protected void rollbackDeleteJob(Map<String, String> parameters) throws MCRPersistentIdentifierExceptionHook in to rollback mechanism ofMCRJobAction.rollback()
by overwriting this method.- Parameters:
parameters
- the parameters which was passed toaddDeleteJob(Map)
- Throws:
MCRPersistentIdentifierException
- throwMCRPersistentIdentifierException
if something goes wrong during rollback
-
rollbackUpdateJob
protected void rollbackUpdateJob(Map<String, String> parameters) throws MCRPersistentIdentifierExceptionHook in to rollback mechanism ofMCRJobAction.rollback()
by overwriting this method.- Parameters:
parameters
- the parameters which was passed toupdateJob(Map)
- Throws:
MCRPersistentIdentifierException
- throwMCRPersistentIdentifierException
if something goes wrong during rollback
-
rollbackRegisterJob
protected void rollbackRegisterJob(Map<String, String> parameters) throws MCRPersistentIdentifierExceptionHook in to rollback mechanism ofMCRJobAction.rollback()
by overwriting this method.- Parameters:
parameters
- the parameters which was passed toaddRegisterJob(Map)
- Throws:
MCRPersistentIdentifierException
- throwMCRPersistentIdentifierException
if something goes wrong during rollback
-
addDeleteJob
- See Also:
-
addUpdateJob
- See Also:
-
addRegisterJob
Adds a register job which will be called in the persistentMCRJob
environment in a extra thread.- Parameters:
contextParameters
- pass parameters which are needed to register the PI. The parameter action and registrationServiceID will be added, because they are necessary to reassign the job to the rightMCRPIJobService
and method.
-
validateJobUserRights
If you useupdateRegistrationDate(MCRObjectID, String, Date)
orupdateStartRegistrationDate(MCRObjectID, String, Date)
then you should validate if the user has the rights for this. This methods validates this and throws a handsome exception.- Parameters:
id
- of the object- Throws:
MCRPersistentIdentifierException
-
updateRegistrationDate
Can be used to update the registration date in the database. The mostMCRPIJobService
only add the pi to the object and then to the database, with registration date of null. Later the job will register the pi and then change the registration date to the right value. If you use this methods from a job you should have calledvalidateJobUserRights(org.mycore.datamodel.metadata.MCRObjectID)
before!- Parameters:
mycoreID
- the id of theMCRBase
which has the pi assignedadditional
- information like path to a filedate
- the new registration date
-
updateStartRegistrationDate
Can be used to update the startRegistration date in the database. The mostMCRPIJobService
only add the pi to the object and then to the database, with registration or startRegistration date of null. After a job is created the Registration service should update the date. If you use this methods from a job you should have calledvalidateJobUserRights(org.mycore.datamodel.metadata.MCRObjectID)
before!- Parameters:
mycoreID
- the id of theMCRBase
which has the pi assignedadditional
- information like path to a filedate
- the new registration date
-
parseIdentifier
Tries to parse a identifier with a specific type.- Parameters:
identifier
- the identifier to parse- Returns:
- parsed identifier or
Optional.empty()
if there is no parser for the type or the parser can't parse the identifier - Throws:
ClassCastException
- when type does not match the type of T
-
getJobInformation
Result of this will be passed toMCRJobAction.name()
- Parameters:
contextParameters
- the parameters of the job- Returns:
- Some Information what this job will do or just
Optional.empty()
, then a default message is generated.
-
runAsJobUser
public void runAsJobUser(org.mycore.pi.MCRPIJobService.PIRunnable task) throws MCRPersistentIdentifierException - Throws:
MCRPersistentIdentifierException
-
getAction
-
getRegistrationCondition
Deprecated.This function is replaced by getRegistrationPredicate() in parent class MCRPIJobService- Returns:
- the registration predicate
- See Also:
-
checkConfiguration
Description copied from class:MCRPIService
Checks the service parameters.- Overrides:
checkConfiguration
in classMCRPIService<T extends MCRPersistentIdentifier>
- Throws:
MCRConfigurationException
- if parameter is missing or wrong!
-