Class TaskResolver

java.lang.Object
org.dspace.curate.TaskResolver

public class TaskResolver extends Object
TaskResolver takes a logical name of a curation task and attempts to deliver a suitable implementation object. Supported implementation types include: (1) Classpath-local Java classes configured and loaded via PluginService. (2) Local script-based tasks, viz. coded in any scripting language whose runtimes are accessible via the JSR-223 scripting API. This really amounts to the family of dynamic JVM languages: JRuby, Jython, Groovy, Javascript, etc Note that the requisite jars and other resources for these languages must be installed in the DSpace instance for them to be used here. Further work may involve remote URL-loadable code, etc. Scripted tasks are managed in a directory configured with the dspace/config/modules/curate.cfg property "script.dir". A catalog of scripted tasks named 'task.catalog" is kept in this directory. Each task has a 'descriptor' property with value syntax: <engine>|<relFilePath>|<implClassCtor> An example property: linkchecker = ruby|rubytask.rb|LinkChecker.new This descriptor means that a 'ruby' script engine will be created, a script file named 'rubytask.rb' in the directory <script.dir> will be loaded and the resolver will expect an evaluation of 'LinkChecker.new' will provide a correct implementation object. Script files may embed their descriptors to facilitate deployment. To accomplish this, a script must include the descriptor string with syntax: $td=<descriptor> somewhere on a comment line. for example: My descriptor $td=ruby|rubytask.rb|LinkChecker.new For portability, the <relFilePath> component may be omitted in this context. Thus, $td=ruby||LinkChecker.new will be expanded to a descriptor with the name of the embedding file.
Author:
richardrodgers
  • Field Details

  • Constructor Details

    • TaskResolver

      public TaskResolver()
  • Method Details

    • installScript

      public boolean installScript(String taskName, String fileName)
      Installs a task script. Succeeds only if script: (1) exists in the configured script directory and (2) contains a recognizable descriptor in a comment line. If script lacks a descriptor, it may still be installed by manually invoking addDescriptor.
      Parameters:
      taskName - logical name of task to associate with script
      fileName - name of file containing task script
      Returns:
      true if script installed, false if installation failed
    • addDescriptor

      public void addDescriptor(String taskName, String descriptor)
      Adds a task descriptor property and flushes catalog to disk.
      Parameters:
      taskName - logical task name
      descriptor - descriptor for task
    • resolveTask

      public ResolvedTask resolveTask(String taskName)
      Returns a task implementation for a given task name, or null if no implementation could be obtained.
      Parameters:
      taskName - logical task name
      Returns:
      task an object that implements the CurationTask interface
    • loadCatalog

      protected void loadCatalog()
      Loads catalog of descriptors for tasks if not already loaded