Package org.dspace.scripts
Class ProcessServiceImpl
- java.lang.Object
-
- org.dspace.scripts.ProcessServiceImpl
-
- All Implemented Interfaces:
ProcessService
public class ProcessServiceImpl extends Object implements ProcessService
The implementation for theProcessServiceclass
-
-
Constructor Summary
Constructors Constructor Description ProcessServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappendFile(Context context, Process process, InputStream is, String type, String fileName)The method will create a bitstream from the given inputstream with the given type as metadata and given name as name and attach it to the given processvoidappendLog(int processId, String scriptName, String output, ProcessLogLevel processLogLevel)This method will append the given output to theProcessits logsvoidcomplete(Context context, Process process)This method will perform the logic needed to update the Process object in the database to represent a complete stateintcountSearch(Context context, ProcessQueryParameterContainer processQueryParameterContainer)Count all the processes which match the requirements.intcountTotal(Context context)Returns the total amount of Process objects in the dataaseProcesscreate(Context context, EPerson ePerson, String scriptName, List<DSpaceCommandLineParameter> parameters)This method will create a Process object in the databasevoidcreateLogBitstream(Context context, Process process)voiddelete(Context context, Process process)This method will delete the given Process object from the databasevoidfail(Context context, Process process)This method will perform the logic needed to update the Process object in the database to represent a failed stateProcessfind(Context context, int processId)This method will retrieve a Process object from the Database with the given IDList<Process>findAll(Context context)Returns a list of all Process objects in the databaseList<Process>findAll(Context context, int limit, int offset)Returns a list of all Process objects in the databaseList<Process>findAllSortByScript(Context context)Returns a list of all Process objects in the database sorted by script nameList<Process>findAllSortByStartTime(Context context)Returns a list of all Process objects in the database sorted by start time The most recent one will be shown firstBitstreamgetBitstream(Context context, Process process, String type)This method will return the Bitstream for a given process with a given typeBitstreamgetBitstreamByName(Context context, Process process, String bitstreamName)This method will return the Bitstream that matches the given name for the given ProcessList<Bitstream>getBitstreams(Context context, Process process)This method will return all the Bitstreams for a given processList<String>getFileTypesForProcessBitstreams(Context context, Process process)This will return a list of Strings where each String represents the type of a Bitstream in the Process givenList<DSpaceCommandLineParameter>getParameters(Process process)This method will retrieve the list of parameters from the Process in its String format and it will parse these parameters to a list ofDSpaceCommandLineParameterobjects for better usability throughout DSpaceList<Process>search(Context context, ProcessQueryParameterContainer processQueryParameterContainer, int limit, int offset)Returns a list of all Processes in the database which match the given field requirements.voidstart(Context context, Process process)This method will perform the logic needed to update the Process object in the database to represent a started state.voidupdate(Context context, Process process)This method will be used to update the given Process object in the database
-
-
-
Method Detail
-
create
public Process create(Context context, EPerson ePerson, String scriptName, List<DSpaceCommandLineParameter> parameters) throws SQLException
Description copied from interface:ProcessServiceThis method will create a Process object in the database- Specified by:
createin interfaceProcessService- Parameters:
context- The relevant DSpace contextePerson- The ePerson for which this process will be created onscriptName- The script name to be used for the processparameters- The parameters to be used for the process- Returns:
- The created process
- Throws:
SQLException- If something goes wrong
-
find
public Process find(Context context, int processId) throws SQLException
Description copied from interface:ProcessServiceThis method will retrieve a Process object from the Database with the given ID- Specified by:
findin interfaceProcessService- Parameters:
context- The relevant DSpace contextprocessId- The process id on which we'll search for in the database- Returns:
- The process that holds the given process id
- Throws:
SQLException- If something goes wrong
-
findAll
public List<Process> findAll(Context context) throws SQLException
Description copied from interface:ProcessServiceReturns a list of all Process objects in the database- Specified by:
findAllin interfaceProcessService- Parameters:
context- The relevant DSpace context- Returns:
- The list of all Process objects in the Database
- Throws:
SQLException- If something goes wrong
-
findAll
public List<Process> findAll(Context context, int limit, int offset) throws SQLException
Description copied from interface:ProcessServiceReturns a list of all Process objects in the database- Specified by:
findAllin interfaceProcessService- Parameters:
context- The relevant DSpace contextlimit- The limit for the amount of Processes returnedoffset- The offset for the Processes to be returned- Returns:
- The list of all Process objects in the Database
- Throws:
SQLException- If something goes wrong
-
findAllSortByScript
public List<Process> findAllSortByScript(Context context) throws SQLException
Description copied from interface:ProcessServiceReturns a list of all Process objects in the database sorted by script name- Specified by:
findAllSortByScriptin interfaceProcessService- Parameters:
context- The relevant DSpace context- Returns:
- The list of all Process objects in the database sorted by script name
- Throws:
SQLException- If something goes wrong
-
findAllSortByStartTime
public List<Process> findAllSortByStartTime(Context context) throws SQLException
Description copied from interface:ProcessServiceReturns a list of all Process objects in the database sorted by start time The most recent one will be shown first- Specified by:
findAllSortByStartTimein interfaceProcessService- Parameters:
context- The relevant DSpace context- Returns:
- The list of all Process objects sorted by start time
- Throws:
SQLException- If something goes wrong
-
start
public void start(Context context, Process process) throws SQLException
Description copied from interface:ProcessServiceThis method will perform the logic needed to update the Process object in the database to represent a started state. A started state refers toProcessStatus.RUNNING- Specified by:
startin interfaceProcessService- Parameters:
context- The relevant DSpace contextprocess- The Process object to be updated- Throws:
SQLException- If something goes wrong
-
fail
public void fail(Context context, Process process) throws SQLException
Description copied from interface:ProcessServiceThis method will perform the logic needed to update the Process object in the database to represent a failed state- Specified by:
failin interfaceProcessService- Parameters:
context- The relevant DSpace contextprocess- The Process object to be updated- Throws:
SQLException- If something goes wrong
-
complete
public void complete(Context context, Process process) throws SQLException
Description copied from interface:ProcessServiceThis method will perform the logic needed to update the Process object in the database to represent a complete state- Specified by:
completein interfaceProcessService- Parameters:
context- The relevant DSpace contextprocess- The Process object to be updated- Throws:
SQLException- If something goes wrong
-
appendFile
public void appendFile(Context context, Process process, InputStream is, String type, String fileName) throws IOException, SQLException, AuthorizeException
Description copied from interface:ProcessServiceThe method will create a bitstream from the given inputstream with the given type as metadata and given name as name and attach it to the given process- Specified by:
appendFilein interfaceProcessService- Parameters:
context- The relevant DSpace contextprocess- The process for which the bitstream will be madeis- The inputstream for the bitstreamtype- The type of the bitstreamfileName- The name of the bitstream- Throws:
IOException- If something goes wrongSQLException- If something goes wrongAuthorizeException- If something goes wrong
-
delete
public void delete(Context context, Process process) throws SQLException, IOException, AuthorizeException
Description copied from interface:ProcessServiceThis method will delete the given Process object from the database- Specified by:
deletein interfaceProcessService- Parameters:
context- The relevant DSpace contextprocess- The Process object to be deleted- Throws:
SQLException- If something goes wrongIOExceptionAuthorizeException
-
update
public void update(Context context, Process process) throws SQLException
Description copied from interface:ProcessServiceThis method will be used to update the given Process object in the database- Specified by:
updatein interfaceProcessService- Parameters:
context- The relevant DSpace contextprocess- The Process object to be updated- Throws:
SQLException- If something goes wrong
-
getParameters
public List<DSpaceCommandLineParameter> getParameters(Process process)
Description copied from interface:ProcessServiceThis method will retrieve the list of parameters from the Process in its String format and it will parse these parameters to a list ofDSpaceCommandLineParameterobjects for better usability throughout DSpace- Specified by:
getParametersin interfaceProcessService- Parameters:
process- The Process object for which we'll return the parameters- Returns:
- The list of parsed parameters from the Process object
-
getBitstreamByName
public Bitstream getBitstreamByName(Context context, Process process, String bitstreamName)
Description copied from interface:ProcessServiceThis method will return the Bitstream that matches the given name for the given Process- Specified by:
getBitstreamByNamein interfaceProcessService- Parameters:
context- The relevant DSpace contextprocess- The process that should hold the requested BitstreambitstreamName- The name of the requested Bitstream- Returns:
- The Bitstream from the given Process that matches the given bitstream name
-
getBitstream
public Bitstream getBitstream(Context context, Process process, String type)
Description copied from interface:ProcessServiceThis method will return the Bitstream for a given process with a given type- Specified by:
getBitstreamin interfaceProcessService- Parameters:
context- The relevant DSpace contextprocess- The process that holds the Bitstreams to be searched intype- The type that the Bitstream must have- Returns:
- The Bitstream of the given type for the given Process
-
getBitstreams
public List<Bitstream> getBitstreams(Context context, Process process)
Description copied from interface:ProcessServiceThis method will return all the Bitstreams for a given process- Specified by:
getBitstreamsin interfaceProcessService- Parameters:
context- The relevant DSpace contextprocess- The process that holds the Bitstreams to be searched in- Returns:
- The list of Bitstreams
-
countTotal
public int countTotal(Context context) throws SQLException
Description copied from interface:ProcessServiceReturns the total amount of Process objects in the dataase- Specified by:
countTotalin interfaceProcessService- Parameters:
context- The relevant DSpace context- Returns:
- An integer that describes the amount of Process objects in the database
- Throws:
SQLException- If something goes wrong
-
getFileTypesForProcessBitstreams
public List<String> getFileTypesForProcessBitstreams(Context context, Process process)
Description copied from interface:ProcessServiceThis will return a list of Strings where each String represents the type of a Bitstream in the Process given- Specified by:
getFileTypesForProcessBitstreamsin interfaceProcessService- Parameters:
context- The DSpace contextprocess- The Process object that we'll use to find the bitstreams- Returns:
- A list of Strings where each String represents a fileType that is in the Process
-
search
public List<Process> search(Context context, ProcessQueryParameterContainer processQueryParameterContainer, int limit, int offset) throws SQLException
Description copied from interface:ProcessServiceReturns a list of all Processes in the database which match the given field requirements. If the requirements are not null, they will be combined with an AND operation.- Specified by:
searchin interfaceProcessService- Parameters:
context- The relevant DSpace contextprocessQueryParameterContainer- TheProcessQueryParameterContainercontaining all the values that the returnedProcessobjects must adhere tolimit- The limit for the amount of Processes returnedoffset- The offset for the Processes to be returned- Returns:
- The list of all Processes which match the metadata requirements
- Throws:
SQLException- If something goes wrong
-
countSearch
public int countSearch(Context context, ProcessQueryParameterContainer processQueryParameterContainer) throws SQLException
Description copied from interface:ProcessServiceCount all the processes which match the requirements. The requirements are evaluated like the search method.- Specified by:
countSearchin interfaceProcessService- Parameters:
context- The relevant DSpace contextprocessQueryParameterContainer- TheProcessQueryParameterContainercontaining all the values that the returnedProcessobjects must adhere to- Returns:
- The number of results matching the query
- Throws:
SQLException- If something goes wrong
-
appendLog
public void appendLog(int processId, String scriptName, String output, ProcessLogLevel processLogLevel) throws IOExceptionDescription copied from interface:ProcessServiceThis method will append the given output to theProcessits logs- Specified by:
appendLogin interfaceProcessService- Parameters:
processId- The ID of theProcessto append the log forscriptName- The name of the Script that Process runsoutput- The output to appendprocessLogLevel- The loglevel of the output- Throws:
IOException- If something goes wrong
-
createLogBitstream
public void createLogBitstream(Context context, Process process) throws IOException, SQLException, AuthorizeException
Description copied from interface:ProcessService- Specified by:
createLogBitstreamin interfaceProcessService- Parameters:
context- The relevant DSpace contextprocess- TheProcessfor which we're making theBitstream- Throws:
IOException- If something goes wrongSQLException- If something goes wrongAuthorizeException- If something goes wrong
-
-