Package com.carfey.ops.api.embedded
Class JobManager
- java.lang.Object
-
- com.carfey.ops.api.embedded.AbstractAPIManager
-
- com.carfey.ops.api.embedded.JobManager
-
public class JobManager extends AbstractAPIManager
Class to manage jobs using the Obsidian public embedded API. SeeAbstractAPIManagerfor 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
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.carfey.ops.api.embedded.AbstractAPIManager
AbstractAPIManager.ActionCallable
-
-
Constructor Summary
Constructors Constructor Description JobManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JobChainaddChain(JobChainUpdateRequest request, java.lang.String auditUser)Creates a new job chain with the supplied configuration.JobDetailaddJob(JobCreationRequest request, java.lang.String auditUser)Creates a new configured job.JobScheduleListingaddJobSchedule(long jobId, ScheduleCreationRequest request, java.lang.String auditUser)Adds a new job schedule to a job, merging and splitting existing schedules as required.JobChaindeleteChain(long jobChainId, java.lang.String auditUser)Deletes the requested job chain.JobDetaildeleteJob(long jobId, boolean cascade, java.lang.String auditUser)Deletes a configured job.JobChaingetChain(long jobChainId)Loads details on an existing job chain.JobDetailgetJob(long jobId)Loads details on an existing job.JobChainListinglistChains(JobChainListingParameters parameters)Searches/lists configured job chains.ConflictListinglistConflicts()Lists the configured job conflicts, with each conflicting set in order of execution precedence.GlobalParameterListinglistGlobalParameters()Lists configured global parameters.JobConflictListinglistJobConflicts(long jobId)Lists jobs that conflict with the supplied job ID.JobFolderListinglistJobFolders()Lists configured job folders, providing both flat and hierarchical views.JobListinglistJobs(JobListingParameters parameters)Searches/lists configured jobs.JobScheduleListinglistJobSchedules(long jobId)Lists the full schedule history for the requested job.JobScheduleListinglistJobSchedules(long jobId, JobScheduleListingParameters parameters)Lists the full schedule history for the requested job.JobChainupdateChain(long jobChainId, JobChainUpdateRequest request, java.lang.String auditUser)Updates the requested job chain with the supplied configuration.ConflictListingupdateConflicts(ConflictUpdateRequest request, java.lang.String auditUser)Updates the configured job conflicts and returns a listing of conflicted job sets, each in order of execution precedence.GlobalParameterListingupdateGlobalParameters(GlobalParameterUpdateRequest request, java.lang.String auditUser)Replaces the configured global parameters with those supplied in the request.JobDetailupdateJob(long jobId, JobUpdateRequest request, java.lang.String auditUser)Updates an existing job.-
Methods inherited from class com.carfey.ops.api.embedded.AbstractAPIManager
addParameter, runApiTarget, validateRequired, withTransaction
-
-
-
-
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
JobListingmatching 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 withaddJobSchedule(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 updaterequest- 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 deletecascade- 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
JobScheduleListingfor 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
JobScheduleListingfor 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 changerequest- 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
ConflictListingincluding 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
JobConflictListingcontaining 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 saveauditUser- Optional user that is marked in audit columns. Defaults to "embeddedAPI".- Returns:
- the updated
ConflictListingincluding 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
JobChainListingmatching 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 saveauditUser- 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 updaterequest- the job chain to saveauditUser- 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 deleteauditUser- 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
-
listGlobalParameters
public GlobalParameterListing listGlobalParameters() throws ValidationException, java.lang.Exception
Lists configured global parameters.- Returns:
- the
GlobalParameterListingfor configured global parameters - Throws:
ValidationException- A validation error which prevents the action from succeeding.java.lang.Exception- Any other type of unexpected exception.- Since:
- 2.5
-
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 parametersauditUser- 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
JobFolderListingfor 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
-
-