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:
Curation,Harvest,IndexClient,MetadataDeletion,MetadataExport,MetadataImport,RetryFailedOpenUrlTracker,SubmissionFormsMigration
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 theScriptConfigurationprovided through the diamond operators. This will be the dspaceRunnableClass for theScriptConfigurationbeans. Specifically created for each script
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.commons.cli.CommandLinecommandLineThe CommandLine object for the script that'll hold the informationprotected DSpaceRunnableHandlerhandlerThe handler that deals with this script.
-
Constructor Summary
Constructors Constructor Description DSpaceRunnable()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description UUIDgetEpersonIdentifier()Generic getter for the epersonIdentifier This EPerson identifier variable is the uuid of the eperson that's running the scriptList<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 endabstract TgetScriptConfiguration()This method will return the Configuration that the implementing DSpaceRunnable usesvoidinitialize(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 voidinternalRun()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 neededvoidprintHelp()This 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 Detail
-
commandLine
protected org.apache.commons.cli.CommandLine commandLine
The CommandLine object for the script that'll hold the 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
-
-
Method Detail
-
getScriptConfiguration
public abstract T getScriptConfiguration()
This method will return the Configuration that the implementing DSpaceRunnable uses- Returns:
- The
ScriptConfigurationthat this implementing DspaceRunnable uses
-
initialize
public void 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-- 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
public abstract void internalRun() throws ExceptionThis 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
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
-
-