Class DSpaceRunnable<T extends ScriptConfiguration>

java.lang.Object
org.dspace.scripts.DSpaceRunnable<T>
Type Parameters:
T -
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
BulkAccessControl, Curation, Harvest, IndexClient, ItemExport, ItemImport, MediaFilterScript, MetadataDeletion, MetadataExport, MetadataExportFilteredItemsReport, MetadataExportSearch, MetadataImport, OpenaireEventsImport, OrcidBulkPush, ProcessCleaner, PublicationLoaderRunnable, RetryFailedOpenUrlTracker, SolrDatabaseResyncCli, SubmissionFormsMigration, SubscriptionEmailNotification

public abstract class DSpaceRunnable<T extends ScriptConfiguration> extends Object implements Runnable
This is the class that should be extended for each Script. This class will contain the logic needed to run and it'll fetch the information that it needs from the ScriptConfiguration provided through the diamond operators. This will be the dspaceRunnableClass for the ScriptConfiguration beans. Specifically created for each script
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected org.apache.commons.cli.CommandLine
    The CommandLine object for the script that'll hold the information
    The handler that deals with this script.
    protected org.apache.commons.cli.CommandLine
    The minimal CommandLine object for the script that'll hold help information
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Generic getter for the epersonIdentifier This EPerson identifier variable is the uuid of the eperson that's running the script
    This method will traverse all the options and it'll grab options defined as an InputStream type to then save the filename specified by that option in a list of Strings that'll be returned in the end
    abstract T
    This method will return the Configuration that the implementing DSpaceRunnable uses
    initialize(String[] args, DSpaceRunnableHandler dSpaceRunnableHandler, EPerson currentUser)
    This method sets the appropriate DSpaceRunnableHandler depending on where it was ran from and it parses the arguments given to the script
    abstract void
    This method has to be included in every script and this will be the main execution block for the script that'll contain all the logic needed
    void
    This method will call upon the DSpaceRunnableHandler.printHelp(Options, String) method with the script's options and name
    void
    run()
    This is the run() method from the Runnable interface that we implement.
    void
    setEpersonIdentifier(UUID epersonIdentifier)
    Generic setter for the epersonIdentifier.
    abstract void
    This method has to be included in every script and handles the setup of the script by parsing the CommandLine and setting the variables

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • commandLine

      protected org.apache.commons.cli.CommandLine commandLine
      The CommandLine object for the script that'll hold the information
    • helpCommandLine

      protected org.apache.commons.cli.CommandLine helpCommandLine
      The minimal CommandLine object for the script that'll hold help information
    • handler

      protected DSpaceRunnableHandler handler
      The handler that deals with this script. This handler can currently either be a RestDSpaceRunnableHandler or a CommandlineDSpaceRunnableHandler depending from where the script is called
  • Constructor Details

    • DSpaceRunnable

      public DSpaceRunnable()
  • Method Details

    • getScriptConfiguration

      public abstract T getScriptConfiguration()
      This method will return the Configuration that the implementing DSpaceRunnable uses
      Returns:
      The ScriptConfiguration that this implementing DspaceRunnable uses
    • initialize

      public DSpaceRunnable.StepResult initialize(String[] args, DSpaceRunnableHandler dSpaceRunnableHandler, EPerson currentUser) throws org.apache.commons.cli.ParseException
      This method sets the appropriate DSpaceRunnableHandler depending on where it was ran from and it parses the arguments given to the script
      Parameters:
      args - The arguments given to the script
      dSpaceRunnableHandler - The DSpaceRunnableHandler object that defines from where the script was ran
      currentUser -
      Returns:
      the result of this step; StepResult.Continue: continue the normal process, initialize is successful; otherwise exit the process (the help or version is shown)
      Throws:
      org.apache.commons.cli.ParseException - If something goes wrong
    • setup

      public abstract void setup() throws org.apache.commons.cli.ParseException
      This method has to be included in every script and handles the setup of the script by parsing the CommandLine and setting the variables
      Throws:
      org.apache.commons.cli.ParseException - If something goes wrong
    • run

      public void run()
      This is the run() method from the Runnable interface that we implement. This method will handle the running of the script and all the database modifications needed for the Process object that resulted from this script
      Specified by:
      run in interface Runnable
    • internalRun

      public abstract void internalRun() throws Exception
      This method has to be included in every script and this will be the main execution block for the script that'll contain all the logic needed
      Throws:
      Exception - If something goes wrong
    • printHelp

      public void printHelp()
      This method will call upon the DSpaceRunnableHandler.printHelp(Options, String) method with the script's options and name
    • getFileNamesFromInputStreamOptions

      public List<String> getFileNamesFromInputStreamOptions()
      This method will traverse all the options and it'll grab options defined as an InputStream type to then save the filename specified by that option in a list of Strings that'll be returned in the end
      Returns:
      The list of Strings representing filenames from the options given to the script
    • getEpersonIdentifier

      public UUID getEpersonIdentifier()
      Generic getter for the epersonIdentifier This EPerson identifier variable is the uuid of the eperson that's running the script
      Returns:
      the epersonIdentifier value of this DSpaceRunnable
    • setEpersonIdentifier

      public void setEpersonIdentifier(UUID epersonIdentifier)
      Generic setter for the epersonIdentifier. This EPerson identifier variable is the UUID of the EPerson that's running the script.
      Parameters:
      epersonIdentifier - The epersonIdentifier to be set on this DSpaceRunnable