Is it possible to restrict a curation task
to only execute when it is invoked for a single item and abort when it is invoked for a community, collection or the entire DSpace?
I know that it is possible to restrict a curation task
to process only items as opposed to communities and collections, but that's not what I am looking for.
Background:
I have a curation task
that sends an email about an item.
It is intended to be invoked on a single item.
If someone would accidentally invoke it on a collection or the entire DSpace, it would send thousands of emails, which would be, obviously, a problem.
The answer was to be found in the manual:
Since tasks operate on DSOs that can either be simple (Items) or containers (Collections, and Communities), there is a fundamental problem or ambiguity in how a task is invoked: if the DSO is a collection, should the CS invoke the task on each member of the collection, or does the task "know" how to do that itself? The decision is made by looking for the @Distributive annotation: if present, CS assumes that the task will manage the details, otherwise CS will walk the collection, and invoke the task on each member.
So to make the task non-distributive, you set the @Distributive
annotation, to tell the Curation System that you handle distribution yourself and then do not implement distribution in your task.
What the @Distributive
annotation means is, "handles distribution on its own" instead of "let's the curation system handle distribution". So the name of the annotation is a bit misleading.
This works when you implement the org.dspace.curate.CurationTask
interface as well as when you extend the org.dspace.curate.AbstractCurationTask
class.