Class AbstractCurationTask

    • Constructor Detail

      • AbstractCurationTask

        public AbstractCurationTask()
    • Method Detail

      • init

        public void init​(Curator curator,
                         String taskId)
                  throws IOException
        Description copied from interface: CurationTask
        Initialize task - parameters inform the task of it's invoking curator. Since the curator can provide services to the task, this represents curation DI.
        Specified by:
        init in interface CurationTask
        Parameters:
        curator - the Curator controlling this task
        taskId - identifier task should use in invoking services
        Throws:
        IOException - if error
      • distribute

        protected void distribute​(DSpaceObject dso)
                           throws IOException
        Distributes a task through a DSpace container - a convenience method for tasks declaring the @Distributive property.

        This method invokes the 'performObject()' method on the current DSO, and then recursively invokes the 'performObject()' method on all DSOs contained within the current DSO. For example: if a Community is passed in, then 'performObject()' will be called on that Community object, as well as on all SubCommunities/Collections/Items contained in that Community.

        Individual tasks MUST override either the performObject method or the performItem method to ensure the task is run on either all DSOs or just all Items, respectively.

        Parameters:
        dso - current DSpaceObject
        Throws:
        IOException - if IO error
      • performObject

        protected void performObject​(DSpaceObject dso)
                              throws SQLException,
                                     IOException
        Performs task upon a single DSpaceObject. Used in conjunction with the distribute method to run a single task across multiple DSpaceObjects.

        By default, this method just wraps a call to performItem for each Item Object.

        You should override this method if you want to use distribute to run your task across multiple DSpace Objects.

        Either this method or performItem should be overridden if distribute method is used.

        Parameters:
        dso - the DSpaceObject
        Throws:
        SQLException - if database error
        IOException - if IO error
      • performItem

        protected void performItem​(Item item)
                            throws SQLException,
                                   IOException
        Performs task upon a single DSpace Item. Used in conjunction with the distribute method to run a single task across multiple Items.

        You should override this method if you want to use distribute to run your task across multiple DSpace Items.

        Either this method or performObject should be overridden if distribute method is used.

        Parameters:
        item - the DSpace Item
        Throws:
        SQLException - if database error
        IOException - if IO error
      • perform

        public int perform​(Context ctx,
                           String id)
                    throws IOException
        Description copied from interface: CurationTask
        Perform the curation task for passed id
        Specified by:
        perform in interface CurationTask
        Parameters:
        ctx - DSpace context object
        id - persistent ID for DSpace object
        Returns:
        status code
        Throws:
        IOException - if error
      • dereference

        protected DSpaceObject dereference​(Context ctx,
                                           String id)
                                    throws IOException
        Returns a DSpaceObject for passed identifier, if it exists
        Parameters:
        ctx - DSpace context
        id - canonical id of object
        Returns:
        dso DSpace object, or null if no object with id exists
        Throws:
        IOException - if IO error
      • report

        protected void report​(String message)
        Sends message to the reporting stream
        Parameters:
        message - the message to stream
      • setResult

        protected void setResult​(String result)
        Assigns the result of the task performance
        Parameters:
        result - the result string
      • taskProperty

        protected String taskProperty​(String name)
        Returns task configuration property value for passed name, else null if no properties defined or no value for passed key. If a taskID/Name is specified, prepend it on the configuration name.
        Parameters:
        name - the property name
        Returns:
        value the property value, or null
      • taskIntProperty

        protected int taskIntProperty​(String name,
                                      int defaultValue)
        Returns task configuration integer property value for passed name, else passed default value if no properties defined or no value for passed key. If a taskID/Name is specified, prepend it on the configuration name.
        Parameters:
        name - the property name
        defaultValue - value the default value
        Returns:
        value the property value, or default value
      • taskLongProperty

        protected long taskLongProperty​(String name,
                                        long defaultValue)
        Returns task configuration long property value for passed name, else passed default value if no properties defined or no value for passed key. If a taskID/Name is specified, prepend it on the configuration name.
        Parameters:
        name - the property name
        defaultValue - value the default value
        Returns:
        value the property value, or default
      • taskBooleanProperty

        protected boolean taskBooleanProperty​(String name,
                                              boolean defaultValue)
        Returns task configuration boolean property value for passed name, else passed default value if no properties defined or no value for passed key. If a taskID/Name is specified, prepend it on the configuration name.
        Parameters:
        name - the property name
        defaultValue - value the default value
        Returns:
        value the property value, or default
      • taskArrayProperty

        protected String[] taskArrayProperty​(String name)
        Returns task configuration Array property value for passed name, else null if no properties defined or no value for passed key. If a taskID/Name is specified, prepend it on the configuration name.
        Parameters:
        name - the property name
        Returns:
        value the property value, or null