Class DSpaceRunnable

  • All Implemented Interfaces:
    Runnable
    Direct Known Subclasses:
    IndexClient

    public abstract class DSpaceRunnable
    extends Object
    implements Runnable
    This abstract class is the class that should be extended by each script. it provides the basic variables to be hold by the script as well as the means to initialize, parse and run the script Every DSpaceRunnable that is implemented in this way should be defined in the scripts.xml config file as a bean
    • Field Detail

      • commandLine

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

        protected org.apache.commons.cli.Options options
        The possible options for this script
      • 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 Detail

      • DSpaceRunnable

        public DSpaceRunnable()
    • Method Detail

      • getName

        public String getName()
      • setName

        public void setName​(String name)
      • getDescription

        public String getDescription()
      • setDescription

        public void setDescription​(String description)
      • getOptions

        public org.apache.commons.cli.Options getOptions()
      • 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
      • initialize

        public void initialize​(String[] args,
                               DSpaceRunnableHandler dSpaceRunnableHandler)
                        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
        Throws:
        org.apache.commons.cli.ParseException - If something goes wrong
      • 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
      • 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
      • isAllowedToExecute

        public boolean isAllowedToExecute​(Context context)
        This method will return if the script is allowed to execute in the given context. This is by default set to the currentUser in the context being an admin, however this can be overwritten by each script individually if different rules apply
        Parameters:
        context - The relevant DSpace context
        Returns:
        A boolean indicating whether the script is allowed to execute or not