Package org.dspace.scripts
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 -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.apache.commons.cli.CommandLineThe CommandLine object for the script that'll hold the informationprotected DSpaceRunnableHandlerThe handler that deals with this script.protected org.apache.commons.cli.CommandLineThe minimal CommandLine object for the script that'll hold help information -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGeneric getter for the epersonIdentifier This EPerson identifier variable is the uuid of the eperson that's running the scriptThis 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 endabstract TThis method will return the Configuration that the implementing DSpaceRunnable usesinitialize(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 scriptabstract voidThis 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 neededvoidThis method will call upon theDSpaceRunnableHandler.printHelp(Options, String)method with the script's options and namevoidrun()This is the run() method from the Runnable interface that we implement.voidsetEpersonIdentifier(UUID epersonIdentifier) Generic setter for the epersonIdentifier.abstract voidsetup()This method has to be included in every script and handles the setup of the script by parsing the CommandLine and setting the variables
-
Field Details
-
commandLine
protected org.apache.commons.cli.CommandLine commandLineThe CommandLine object for the script that'll hold the information -
helpCommandLine
protected org.apache.commons.cli.CommandLine helpCommandLineThe minimal CommandLine object for the script that'll hold help information -
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
This method will return the Configuration that the implementing DSpaceRunnable uses- Returns:
- The
ScriptConfigurationthat 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 scriptdSpaceRunnableHandler- The DSpaceRunnableHandler object that defines from where the script was rancurrentUser-- 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.ParseExceptionThis 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 -
internalRun
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 theDSpaceRunnableHandler.printHelp(Options, String)method with the script's options and name -
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
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
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
-