Class ProcessServiceImpl

java.lang.Object
org.dspace.scripts.ProcessServiceImpl
All Implemented Interfaces:
ProcessService

public class ProcessServiceImpl extends Object implements ProcessService
The implementation for the ProcessService class
  • Constructor Details

    • ProcessServiceImpl

      public ProcessServiceImpl()
  • Method Details

    • create

      public Process create(Context context, EPerson ePerson, String scriptName, List<DSpaceCommandLineParameter> parameters, Set<Group> specialGroups) throws SQLException
      Description copied from interface: ProcessService
      This method will create a Process object in the database
      Specified by:
      create in interface ProcessService
      Parameters:
      context - The relevant DSpace context
      ePerson - The ePerson for which this process will be created on
      scriptName - The script name to be used for the process
      parameters - The parameters to be used for the process
      specialGroups - Allows to set special groups, associated with application context when process is created, other than the ones derived from the eperson membership.
      Returns:
      The created process
      Throws:
      SQLException - If something goes wrong
    • find

      public Process find(Context context, int processId) throws SQLException
      Description copied from interface: ProcessService
      This method will retrieve a Process object from the Database with the given ID
      Specified by:
      find in interface ProcessService
      Parameters:
      context - The relevant DSpace context
      processId - 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: ProcessService
      Returns a list of all Process objects in the database
      Specified by:
      findAll in interface ProcessService
      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: ProcessService
      Returns a list of all Process objects in the database
      Specified by:
      findAll in interface ProcessService
      Parameters:
      context - The relevant DSpace context
      limit - The limit for the amount of Processes returned
      offset - 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: ProcessService
      Returns a list of all Process objects in the database sorted by script name
      Specified by:
      findAllSortByScript in interface ProcessService
      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: ProcessService
      Returns a list of all Process objects in the database sorted by start time The most recent one will be shown first
      Specified by:
      findAllSortByStartTime in interface ProcessService
      Parameters:
      context - The relevant DSpace context
      Returns:
      The list of all Process objects sorted by start time
      Throws:
      SQLException - If something goes wrong
    • findByUser

      public List<Process> findByUser(Context context, EPerson eperson, int limit, int offset) throws SQLException
      Description copied from interface: ProcessService
      Returns a list of all Process objects in the database by the given user.
      Specified by:
      findByUser in interface ProcessService
      Parameters:
      context - The relevant DSpace context
      eperson - The user to search for
      limit - The limit for the amount of Processes returned
      offset - The offset for the Processes to be returned
      Returns:
      The list of all Process objects in the Database
      Throws:
      SQLException - If something goes wrong
    • start

      public void start(Context context, Process process) throws SQLException
      Description copied from interface: ProcessService
      This method will perform the logic needed to update the Process object in the database to represent a started state. A started state refers to ProcessStatus.RUNNING
      Specified by:
      start in interface ProcessService
      Parameters:
      context - The relevant DSpace context
      process - 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: ProcessService
      This method will perform the logic needed to update the Process object in the database to represent a failed state
      Specified by:
      fail in interface ProcessService
      Parameters:
      context - The relevant DSpace context
      process - 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: ProcessService
      This method will perform the logic needed to update the Process object in the database to represent a complete state
      Specified by:
      complete in interface ProcessService
      Parameters:
      context - The relevant DSpace context
      process - 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: ProcessService
      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 process
      Specified by:
      appendFile in interface ProcessService
      Parameters:
      context - The relevant DSpace context
      process - The process for which the bitstream will be made
      is - The inputstream for the bitstream
      type - The type of the bitstream
      fileName - The name of the bitstream
      Throws:
      IOException - If something goes wrong
      SQLException - If something goes wrong
      AuthorizeException - If something goes wrong
    • delete

      public void delete(Context context, Process process) throws SQLException, IOException, AuthorizeException
      Description copied from interface: ProcessService
      This method will delete the given Process object from the database
      Specified by:
      delete in interface ProcessService
      Parameters:
      context - The relevant DSpace context
      process - The Process object to be deleted
      Throws:
      SQLException - If something goes wrong
      IOException
      AuthorizeException
    • update

      public void update(Context context, Process process) throws SQLException
      Description copied from interface: ProcessService
      This method will be used to update the given Process object in the database
      Specified by:
      update in interface ProcessService
      Parameters:
      context - The relevant DSpace context
      process - The Process object to be updated
      Throws:
      SQLException - If something goes wrong
    • getParameters

      public List<DSpaceCommandLineParameter> getParameters(Process process)
      Description copied from interface: ProcessService
      This method will retrieve the list of parameters from the Process in its String format and it will parse these parameters to a list of DSpaceCommandLineParameter objects for better usability throughout DSpace
      Specified by:
      getParameters in interface ProcessService
      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: ProcessService
      This method will return the Bitstream that matches the given name for the given Process
      Specified by:
      getBitstreamByName in interface ProcessService
      Parameters:
      context - The relevant DSpace context
      process - The process that should hold the requested Bitstream
      bitstreamName - 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: ProcessService
      This method will return the Bitstream for a given process with a given type
      Specified by:
      getBitstream in interface ProcessService
      Parameters:
      context - The relevant DSpace context
      process - The process that holds the Bitstreams to be searched in
      type - 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: ProcessService
      This method will return all the Bitstreams for a given process
      Specified by:
      getBitstreams in interface ProcessService
      Parameters:
      context - The relevant DSpace context
      process - 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: ProcessService
      Returns the total amount of Process objects in the dataase
      Specified by:
      countTotal in interface ProcessService
      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: ProcessService
      This will return a list of Strings where each String represents the type of a Bitstream in the Process given
      Specified by:
      getFileTypesForProcessBitstreams in interface ProcessService
      Parameters:
      context - The DSpace context
      process - 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: ProcessService
      Returns 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:
      search in interface ProcessService
      Parameters:
      context - The relevant DSpace context
      processQueryParameterContainer - The ProcessQueryParameterContainer containing all the values that the returned Process objects must adhere to
      limit - The limit for the amount of Processes returned
      offset - 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: ProcessService
      Count all the processes which match the requirements. The requirements are evaluated like the search method.
      Specified by:
      countSearch in interface ProcessService
      Parameters:
      context - The relevant DSpace context
      processQueryParameterContainer - The ProcessQueryParameterContainer containing all the values that the returned Process objects 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 IOException
      Description copied from interface: ProcessService
      This method will append the given output to the Process its logs
      Specified by:
      appendLog in interface ProcessService
      Parameters:
      processId - The ID of the Process to append the log for
      scriptName - The name of the Script that Process runs
      output - The output to append
      processLogLevel - 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
      This method will create a Bitstream containing the logs for the given Process
      Specified by:
      createLogBitstream in interface ProcessService
      Parameters:
      context - The relevant DSpace context
      process - The Process for which we're making the Bitstream
      Throws:
      IOException - If something goes wrong
      SQLException - If something goes wrong
      AuthorizeException - If something goes wrong
    • findByStatusAndCreationTimeOlderThan

      public List<Process> findByStatusAndCreationTimeOlderThan(Context context, List<ProcessStatus> statuses, Instant date) throws SQLException
      Description copied from interface: ProcessService
      Find all the processes with one of the given status and with a creation time older than the specified date.
      Specified by:
      findByStatusAndCreationTimeOlderThan in interface ProcessService
      Parameters:
      context - The relevant DSpace context
      statuses - the statuses of the processes to search for
      date - the creation date to search for
      Returns:
      The list of all Processes which match requirements
      Throws:
      SQLException
    • countByUser

      public int countByUser(Context context, EPerson user) throws SQLException
      Description copied from interface: ProcessService
      Count all the processes which is related to the given user.
      Specified by:
      countByUser in interface ProcessService
      Parameters:
      context - The relevant DSpace context
      user - The user to search for
      Returns:
      The number of results matching the query
      Throws:
      SQLException - If something goes wrong
    • failRunningProcesses

      public void failRunningProcesses(Context context) throws SQLException, IOException, AuthorizeException
      Description copied from interface: ProcessService
      Cleans up running processes by failing them an attaching their logs to the process objects.
      Specified by:
      failRunningProcesses in interface ProcessService
      Parameters:
      context - The DSpace context
      Throws:
      SQLException
      IOException
      AuthorizeException