Class JobManager


  • public class JobManager
    extends AbstractAPIManager
    Class to manage jobs using the Obsidian public embedded API. See AbstractAPIManager for details on how transactions are managed within all requests.

    Operations include:

    • creating/updating jobs
    • creating/updating job conflicts
    • creating/updating job chains
    • searching/listing jobs
    • searching/listing job chains
    • listing conflicts
    • listing/updating global parameters

    Example:

        JobDetail deleted = new JobManager().deleteJob(123L, true, "Fred");
        System.out.println("Fred deleted this job: " + deleted);
     
    Since:
    2.3
    See Also:
    Embedded API Wiki, REST API Wiki, Carfey Date
    • Constructor Detail

      • JobManager

        public JobManager()
    • Method Detail

      • listJobs

        public JobListing listJobs​(JobListingParameters parameters)
                            throws ValidationException,
                                   java.lang.Exception
        Searches/lists configured jobs.
        Parameters:
        parameters - options for searching configured jobs (defaulted if null)
        Returns:
        the JobListing matching the supplied parameter (never null)
        Throws:
        ValidationException - A validation error which prevents the action from succeeding.
        java.lang.Exception - Any other type of unexpected exception.
      • getJob

        public JobDetail getJob​(long jobId)
                         throws MissingEntityException,
                                java.lang.Exception
        Loads details on an existing job.
        Parameters:
        jobId - ID of the job to load
        Returns:
        the configured job
        Throws:
        MissingEntityException - If the job with the requested ID does not exist.
        java.lang.Exception - Any other type of unexpected exception.
      • addJob

        public JobDetail addJob​(JobCreationRequest request,
                                java.lang.String auditUser)
                         throws ValidationException,
                                java.lang.Exception
        Creates a new configured job.
        Parameters:
        request - Details of the creation request (not null)
        auditUser - Optional user that is marked in audit columns. Defaults to "embeddedAPI".
        Returns:
        the newly created job
        Throws:
        ValidationException - A validation error which prevents the action from succeeding.
        java.lang.Exception - Any other type of unexpected exception.
      • updateJob

        public JobDetail updateJob​(long jobId,
                                   JobUpdateRequest request,
                                   java.lang.String auditUser)
                            throws MissingEntityException,
                                   ValidationException,
                                   java.lang.Exception
        Updates an existing job. Schedule changes must be made with addJobSchedule(long, ScheduleCreationRequest, String).

        Note: Only the fields you wish to update have to be supplied in the request. Any fields that you wish to leave alone can be left null.

        Parameters:
        jobId - ID of the job to update
        request - Details of the create request (not null)
        auditUser - Optional user that is marked in audit columns. Defaults to "embeddedAPI".
        Returns:
        the updated job
        Throws:
        MissingEntityException - If the job with the requested ID does not exist.
        ValidationException - A validation error which prevents the action from succeeding.
        java.lang.Exception - Any other type of unexpected exception.
      • deleteJob

        public JobDetail deleteJob​(long jobId,
                                   boolean cascade,
                                   java.lang.String auditUser)
                            throws MissingEntityException,
                                   ValidationException,
                                   java.lang.Exception
        Deletes a configured job.
        Parameters:
        jobId - ID of the job to delete
        cascade - Whether related job conflicts and chains should be forced to be deleted. This is equivalent to the "Delete all active job configuration?" option in the Obsidian Admin UI.
        auditUser - Optional user that is marked in audit columns. Defaults to "embeddedAPI".
        Returns:
        the job as it existed before it was deleted (never null)
        Throws:
        MissingEntityException - If the job with the requested ID does not exist.
        ValidationException - A validation error which prevents the action from succeeding.
        java.lang.Exception - Any other type of unexpected exception.
      • listJobSchedules

        public JobScheduleListing listJobSchedules​(long jobId)
                                            throws MissingEntityException,
                                                   java.lang.Exception
        Lists the full schedule history for the requested job.
        Parameters:
        jobId - ID of the job to load history for.
        Returns:
        The JobScheduleListing for the job (never null)
        Throws:
        MissingEntityException - If the job with the requested ID does not exist.
        java.lang.Exception - Any other type of unexpected exception.
      • listJobSchedules

        public JobScheduleListing listJobSchedules​(long jobId,
                                                   JobScheduleListingParameters parameters)
                                            throws MissingEntityException,
                                                   java.lang.Exception
        Lists the full schedule history for the requested job.
        Parameters:
        jobId - ID of the job to load history for.
        parameters - options to refine the search (null will use default options)
        Returns:
        The JobScheduleListing for the job (never null)
        Throws:
        MissingEntityException - If the job with the requested ID does not exist.
        java.lang.Exception - Any other type of unexpected exception.
        Since:
        3.7
      • addJobSchedule

        public JobScheduleListing addJobSchedule​(long jobId,
                                                 ScheduleCreationRequest request,
                                                 java.lang.String auditUser)
                                          throws MissingEntityException,
                                                 ValidationException,
                                                 java.lang.Exception
        Adds a new job schedule to a job, merging and splitting existing schedules as required. This can be to add a future schedule, replace the current one, disable a job, etc.
        Parameters:
        jobId - ID of the job to which you want to make a schedule change
        request - Details of the schedule to add (not null)
        auditUser - Optional user that is marked in audit columns. Defaults to "embeddedAPI".
        Returns:
        the updated JobScheduleListing (never null)
        Throws:
        MissingEntityException - If the job with the requested ID does not exist.
        ValidationException - A validation error which prevents the action from succeeding.
        java.lang.Exception - Any other type of unexpected exception.
      • listConflicts

        public ConflictListing listConflicts()
                                      throws java.lang.Exception
        Lists the configured job conflicts, with each conflicting set in order of execution precedence. Non-conflicted jobs are also included in the return value.
        Returns:
        the ConflictListing including conflicted job sets and non-conflicted jobs
        Throws:
        java.lang.Exception - Any type of unexpected exception.
        Since:
        2.4
      • listJobConflicts

        public JobConflictListing listJobConflicts​(long jobId)
                                            throws MissingEntityException,
                                                   java.lang.Exception
        Lists jobs that conflict with the supplied job ID. Conflicting jobs are returned in priority order, including the job for which this request was made, in order that its priority within the set can be determined. Note that if the job has no conflicts, the returned conflicting jobs list will be empty, and will not contain the requested job.
        Parameters:
        jobId - the job for which conflicts are returned
        Returns:
        the JobConflictListing containing jobs which conflict with the supplied job ID
        Throws:
        MissingEntityException - If the job with the requested ID does not exist.
        java.lang.Exception - Any other type of unexpected exception.
        Since:
        2.4
      • updateConflicts

        public ConflictListing updateConflicts​(ConflictUpdateRequest request,
                                               java.lang.String auditUser)
                                        throws ValidationException,
                                               java.lang.Exception
        Updates the configured job conflicts and returns a listing of conflicted job sets, each in order of execution precedence. Non-conflicted jobs are also included in the return value.
        Parameters:
        request - the job conflict sets to save
        auditUser - Optional user that is marked in audit columns. Defaults to "embeddedAPI".
        Returns:
        the updated ConflictListing including conflicted job sets and non-conflicted jobs
        Throws:
        ValidationException - A validation error which prevents the action from succeeding.
        java.lang.Exception - Any other type of unexpected exception.
        Since:
        2.4
      • listChains

        public JobChainListing listChains​(JobChainListingParameters parameters)
                                   throws ValidationException,
                                          java.lang.Exception
        Searches/lists configured job chains.
        Parameters:
        parameters - options for searching configured job chains (defaulted if null)
        Returns:
        the JobChainListing matching the supplied parameter (never null)
        Throws:
        ValidationException - A validation error which prevents the action from succeeding.
        java.lang.Exception - Any other type of unexpected exception.
        Since:
        2.4
      • getChain

        public JobChain getChain​(long jobChainId)
                          throws MissingEntityException,
                                 java.lang.Exception
        Loads details on an existing job chain.
        Parameters:
        jobChainId - ID of the job chain to load
        Returns:
        the configured JobChain
        Throws:
        MissingEntityException - If the job chain with the requested ID does not exist.
        java.lang.Exception - Any other type of unexpected exception.
        Since:
        2.4
      • addChain

        public JobChain addChain​(JobChainUpdateRequest request,
                                 java.lang.String auditUser)
                          throws ValidationException,
                                 java.lang.Exception
        Creates a new job chain with the supplied configuration.
        Parameters:
        request - the job chain to save
        auditUser - Optional user that is marked in audit columns. Defaults to "embeddedAPI".
        Returns:
        the updated JobChain
        Throws:
        ValidationException - A validation error which prevents the action from succeeding.
        java.lang.Exception - Any other type of unexpected exception.
        Since:
        2.4
      • updateChain

        public JobChain updateChain​(long jobChainId,
                                    JobChainUpdateRequest request,
                                    java.lang.String auditUser)
                             throws ValidationException,
                                    MissingEntityException,
                                    java.lang.Exception
        Updates the requested job chain with the supplied configuration.
        Parameters:
        jobChainId - ID of the job chain to update
        request - the job chain to save
        auditUser - Optional user that is marked in audit columns. Defaults to "embeddedAPI".
        Returns:
        the updated JobChain
        Throws:
        ValidationException - A validation error which prevents the action from succeeding.
        MissingEntityException - If the job chain with the requested ID does not exist.
        java.lang.Exception - Any other type of unexpected exception.
        Since:
        2.4
      • deleteChain

        public JobChain deleteChain​(long jobChainId,
                                    java.lang.String auditUser)
                             throws ValidationException,
                                    MissingEntityException,
                                    java.lang.Exception
        Deletes the requested job chain.
        Parameters:
        jobChainId - ID of the job chain to delete
        auditUser - Optional user that is marked in audit columns. Defaults to "embeddedAPI".
        Returns:
        the deleted JobChain
        Throws:
        ValidationException - A validation error which prevents the action from succeeding.
        MissingEntityException - If the job chain with the requested ID does not exist.
        java.lang.Exception - Any other type of unexpected exception.
        Since:
        2.6
      • updateGlobalParameters

        public GlobalParameterListing updateGlobalParameters​(GlobalParameterUpdateRequest request,
                                                             java.lang.String auditUser)
                                                      throws ValidationException,
                                                             java.lang.Exception
        Replaces the configured global parameters with those supplied in the request. To remove all global parameters, supply an empty list of parameters within the request.
        Parameters:
        request - the global parameters
        auditUser - Optional user that is marked in audit columns. Defaults to "embeddedAPI".
        Returns:
        the updated GlobalParameterListing
        Throws:
        ValidationException - A validation error which prevents the action from succeeding.
        java.lang.Exception - Any other type of unexpected exception.
        Since:
        2.5
      • listJobFolders

        public JobFolderListing listJobFolders()
                                        throws ValidationException,
                                               java.lang.Exception
        Lists configured job folders, providing both flat and hierarchical views.
        Returns:
        the JobFolderListing for job folders in use.
        Throws:
        ValidationException - A validation error which prevents the action from succeeding.
        java.lang.Exception - Any other type of unexpected exception.
        Since:
        4.1