org.outerj.daisy.doctaskrunner
Interface DocumentTaskManager


public interface DocumentTaskManager

The DocumentTaskManager is concerned with the execution of a certain task on a set of documents. The task is executed in a background-thread. The task is executed once for each document in the set, and the state of execution for each document is tracked individually. This execution progress is recorded persistently, so it is possible to see afterwards if the task has run on all documents, and what the outcome was (succesful or error), even after server restarts.

The run-information of a task can afterwards be explicitely deleted, or the implementation of DocumentTaskManager may provide automatic cleanup based on an expiration interval.


Method Summary
 DocumentSelection createEnumerationDocumentSelection(org.outerj.daisy.repository.VariantKey[] variantKeys)
           
 DocumentSelection createQueryDocumentSelection(java.lang.String query)
           
 SimpleActionsTaskSpecification createSimpleActionsTaskSpecification(java.lang.String description, boolean stopOnFirstError)
           
 TaskSpecification createTaskSpecification(java.lang.String description, java.lang.String script, java.lang.String scriptLanguage, boolean stopOnFirstError)
           
 void deleteTask(long id)
          Deletes a task.
 Task getTask(long id)
           
 TaskDocDetails getTaskDocDetails(long taskId)
           
 Tasks getTasks()
          For non-administrator users, this returns all tasks belonging to the user.
 void interruptTask(long id)
          Interrupts a task (i.e.
 long runTask(DocumentSelection documentSelection, TaskSpecification taskSpecification)
          Runs a task.
 

Method Detail

runTask

long runTask(DocumentSelection documentSelection,
             TaskSpecification taskSpecification)
             throws TaskException,
                    org.outerj.daisy.repository.RepositoryException
Runs a task.

The documentSelection can be created via createEnumerationDocumentSelection(org.outerj.daisy.repository.VariantKey[]) or createQueryDocumentSelection(String).

The taskSpecification can be created via createTaskSpecification(String, String, String, boolean) or createSimpleActionsTaskSpecification(String, boolean).

Non-administrator users can only run tasks created via createSimpleActionsTaskSpecification(String, boolean), since using generic scripting languages nasty things can be done (infinite loops, calling System.exit, etc.).

After creation of the task, this method returns immediatelly. The state of the task can then be queried using the getTask(long) method.

Returns:
the ID of the task
Throws:
TaskException
org.outerj.daisy.repository.RepositoryException

getTask

Task getTask(long id)
             throws TaskException,
                    org.outerj.daisy.repository.RepositoryException
Throws:
TaskException
org.outerj.daisy.repository.RepositoryException

getTasks

Tasks getTasks()
               throws TaskException,
                      org.outerj.daisy.repository.RepositoryException
For non-administrator users, this returns all tasks belonging to the user. For users acting in the Administrator role, this returns all tasks, of all users.

Throws:
TaskException
org.outerj.daisy.repository.RepositoryException

deleteTask

void deleteTask(long id)
                throws TaskException,
                       org.outerj.daisy.repository.RepositoryException
Deletes a task. A task can only be deleted if it isn't running.

Throws:
TaskException
org.outerj.daisy.repository.RepositoryException

interruptTask

void interruptTask(long id)
                   throws TaskException,
                          org.outerj.daisy.repository.RepositoryException
Interrupts a task (i.e. stop it after the document that's currently processed).

Throws:
TaskException
org.outerj.daisy.repository.RepositoryException

getTaskDocDetails

TaskDocDetails getTaskDocDetails(long taskId)
                                 throws TaskException,
                                        org.outerj.daisy.repository.RepositoryException
Throws:
TaskException
org.outerj.daisy.repository.RepositoryException

createTaskSpecification

TaskSpecification createTaskSpecification(java.lang.String description,
                                          java.lang.String script,
                                          java.lang.String scriptLanguage,
                                          boolean stopOnFirstError)

createSimpleActionsTaskSpecification

SimpleActionsTaskSpecification createSimpleActionsTaskSpecification(java.lang.String description,
                                                                    boolean stopOnFirstError)

createQueryDocumentSelection

DocumentSelection createQueryDocumentSelection(java.lang.String query)

createEnumerationDocumentSelection

DocumentSelection createEnumerationDocumentSelection(org.outerj.daisy.repository.VariantKey[] variantKeys)


Copyright © -2012 . All Rights Reserved.