Package org.dspace.curate
Class Curator
java.lang.Object
org.dspace.curate.Curator
Curator orchestrates and manages the application of a one or more curation
tasks to a DSpace object. It provides common services and runtime
environment to the tasks.
- Author:
- richardrodgers
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enuminvocation modes - used bySuspendabletasksprotected classstatic enum -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected CommunityServicestatic final inttask encountered an error in processingstatic final inttask failedstatic final intCurator unable to find requested taskstatic final inttask was not applicable to passed objectstatic final inttask completed successfullystatic final intno assigned status code - typically because task not yet performedprotected static final ThreadLocal<Context>protected DSpaceRunnableHandlerprotected HandleServiceprotected Curator.Invokedprotected ItemServiceprotected Appendableprotected TaskResolverprotected TaskQueueprotected Map<String,Curator.TaskRunner> protected Curator.TxScope -
Constructor Summary
ConstructorsConstructorDescriptionCurator()No-arg constructorCurator(DSpaceRunnableHandler handler) constructor that uses an handler for logging -
Method Summary
Modifier and TypeMethodDescriptionvoidaddParameter(String name, String value) Set a parameter visible to all tasks in this Curator instance.voidaddParameters(Map<String, String> parameters) Set many parameters visible to all tasks in this Curator instance.Add a task to the set to be performed.voidclear()Removes all configured tasks from the Curator.voidcurate(DSpaceObject dso) Performs all configured tasks upon DSpace object (Community, Collection or Item).voidPerforms all configured tasks upon object identified by id.voidcurate(Context c, DSpaceObject dso) Performs all configured tasks upon DSpace object (Community, Collection or Item).static ContextReturns the context object used in the current curation thread.protected booleandoCollection(Curator.TaskRunner tr, Collection coll) Run task for Collection along with all Items in that collection.protected booleandoCommunity(Curator.TaskRunner tr, Community comm) Run task for Community along with all sub-communities and collections.protected booleandoSite(Curator.TaskRunner tr, Site site) Run task for entire Site (including all Communities, Collections and Items)Returns the result string for the latest performance of the named task.getRunParameter(String name) Look up a run parameter.intReturns the status code for the latest performance of the named task.booleanReturns whether this curator has the specified taskstatic booleanisContainer(DSpaceObject dso) Returns whether a given DSO is a 'container' - collection or communityprotected voidlogWarning(String message) Proxt method for logging with WARN levelprotected voidlogWarning(String message, Object object) Proxy method for logging with WARN level and aMessageformatterthat generates the final log.voidPlaces a curation request for the object identified by id on a managed queue named by the queueId.removeTask(String taskName) Removes a task from the set to be performed.voidAdds a message to the configured reporting stream.setInvoked(Curator.Invoked mode) Assigns invocation mode.setReporter(Appendable reporter) Sets the reporting stream for this curator.voidAssigns a result to the performance of the named task.Defines the transactional scope of curator executions.protected voidvisit(DSpaceObject dso) Record a 'visit' to a DSpace object and enforce any policies set on this curator.
-
Field Details
-
CURATE_NOTASK
public static final int CURATE_NOTASKCurator unable to find requested task- See Also:
-
CURATE_UNSET
public static final int CURATE_UNSETno assigned status code - typically because task not yet performed- See Also:
-
CURATE_ERROR
public static final int CURATE_ERRORtask encountered an error in processing- See Also:
-
CURATE_SUCCESS
public static final int CURATE_SUCCESStask completed successfully- See Also:
-
CURATE_FAIL
public static final int CURATE_FAILtask failed- See Also:
-
CURATE_SKIP
public static final int CURATE_SKIPtask was not applicable to passed object- See Also:
-
curationCtx
-
runParameters
-
trMap
-
perfList
-
taskQ
-
reporter
-
iMode
-
resolver
-
txScope
-
communityService
-
itemService
-
handleService
-
handler
-
-
Constructor Details
-
Curator
constructor that uses an handler for logging- Parameters:
handler-DSpaceRunnableHandlerused to logs infos
-
Curator
public Curator()No-arg constructor
-
-
Method Details
-
addParameter
Set a parameter visible to all tasks in this Curator instance.- Parameters:
name- the parameter's name.value- the parameter's value.
-
addParameters
Set many parameters visible to all tasks in this Curator instance.- Parameters:
parameters- parameter name/value pairs.
-
getRunParameter
Look up a run parameter.- Parameters:
name- the name of the desired parameter.- Returns:
- the value of the named parameter.
-
addTask
Add a task to the set to be performed. Caller should make no assumptions on execution ordering.- Parameters:
taskName- - logical name of task- Returns:
- this curator - to support concatenating invocation style
-
hasTask
Returns whether this curator has the specified task- Parameters:
taskName- - logical name of the task- Returns:
- true if task has been configured, else false
-
removeTask
Removes a task from the set to be performed.- Parameters:
taskName- - logical name of the task- Returns:
- this curator - to support concatenating invocation style
-
setInvoked
Assigns invocation mode.- Parameters:
mode- one of INTERACTIVE, BATCH, ANY- Returns:
- the Curator instance.
-
setReporter
Sets the reporting stream for this curator.- Parameters:
reporter- name of reporting stream. The name '-' causes reporting to standard out.- Returns:
- return self (Curator instance) with reporter set
-
setTransactionScope
Defines the transactional scope of curator executions. The default is 'open' meaning that no commits are performed by the framework during curation. A scope of 'curation' means that a single commit will occur after the entire performance is complete, and a scope of 'object' will commit for each object (e.g. item) encountered in a given execution.- Parameters:
scope- transactional scope- Returns:
- return self (Curator instance) with given scope set
-
curate
Performs all configured tasks upon object identified by id. If the object can be resolved as a handle, the DSO will be the target object.Note: this method has the side-effect of setting this instance's Context reference. The setting is retained on return.
- Parameters:
c- a DSpace contextid- an object identifier- Throws:
IOException- if IO error
-
curate
Performs all configured tasks upon DSpace object (Community, Collection or Item).- Parameters:
dso- the DSpace object- Throws:
IOException- if IO error
-
curate
Performs all configured tasks upon DSpace object (Community, Collection or Item).Note: this method has the side-effect of setting this instance's Context reference. The setting is retained on return.
- Parameters:
c- session context in which curation takes place.dso- the single object to be curated.- Throws:
IOException- passed through.
-
queue
Places a curation request for the object identified by id on a managed queue named by the queueId.- Parameters:
c- A DSpace contextid- an object IdqueueId- name of a queue. If queue does not exist, it will be created automatically.- Throws:
IOException- if IO error
-
clear
public void clear()Removes all configured tasks from the Curator. -
report
Adds a message to the configured reporting stream.- Parameters:
message- the message to output to the reporting stream.
-
getStatus
Returns the status code for the latest performance of the named task.- Parameters:
taskName- the task name- Returns:
- the status code - one of CURATE_ values
-
getResult
Returns the result string for the latest performance of the named task.- Parameters:
taskName- the task name- Returns:
- the result string, or
nullif task has not set it.
-
setResult
Assigns a result to the performance of the named task.- Parameters:
taskName- the task nameresult- a string indicating results of performing task.
-
curationContext
Returns the context object used in the current curation thread. This is primarily a utility method to allow tasks access to the context when necessary.If the context is null or not set, then this just returns a brand new Context object representing an Anonymous User.
- Returns:
- curation thread's Context object (or a new, anonymous Context if no curation Context exists)
- Throws:
SQLException- An exception that provides information on a database access error or other errors.
-
isContainer
Returns whether a given DSO is a 'container' - collection or community- Parameters:
dso- a DSpace object- Returns:
- true if a container, false otherwise
-
doSite
Run task for entire Site (including all Communities, Collections and Items)- Parameters:
tr- TaskRunnersite- DSpace Site object- Returns:
- true if successful, false otherwise
- Throws:
IOException- if IO error
-
doCommunity
Run task for Community along with all sub-communities and collections.- Parameters:
tr- TaskRunnercomm- Community- Returns:
- true if successful, false otherwise
- Throws:
IOException- if IO error
-
doCollection
Run task for Collection along with all Items in that collection.- Parameters:
tr- TaskRunnercoll- Collection- Returns:
- true if successful, false otherwise
- Throws:
IOException- if IO error
-
visit
Record a 'visit' to a DSpace object and enforce any policies set on this curator.- Parameters:
dso- the DSpace object- Throws:
IOException- A general class of exceptions produced by failed or interrupted I/O operations.
-
logWarning
Proxt method for logging with WARN level- Parameters:
message-
-
logWarning
Proxy method for logging with WARN level and aMessageformatterthat generates the final log.- Parameters:
message- Target message to format or printobject- Object to use inside the message, or null
-