Starting Portal Jobs Using IDK Remote APIs
To start an existing ALI job from a remote application,
use the IJobManager interface in the IDK.
A job is a collection of related portal operations. Each
operation is one task, such as a crawl for documents, an import of
users, or one of the system maintenance tasks. The return code from
starting a job indicates whether or not the call was successful (whether
or not the object is locked). See the IDK API documentation for
LockStatus for more information on what each return value
indicates.
To start a portal job, follow the steps below.
- Create a session with the portal. For details, see Initiating a PRC Session to Use IDK Remote APIs.
- Retrieve an IJobManager by calling IRemoteSession.getJobManager.
- Query for the objectID of the job. For details, see Querying ALI Object Properties Using IDK Remote APIs.
- Create a new method to start a job and start the job as
shown in the code below. It is a best practice to check the return
code in the response and print out a description.
Note: The startJob method does not technically
start the portal job; it sets the start time for the job to the current
time. If there are problems that prevent the job from running once
it is rescheduled, they are not accessible from this call.
This example checks to see if the job object is locked. If
it is unlocked, the code assumes that the job will start.
Java
public static voidstartJob(IJobManager jobManager, int jobID)
{
int status = jobManager.startJob(jobID);
if(status == LockStatus.UNLOCKED) //LockStatus.UNLOCKED = 0
System.out.println("Job started successfully");
else
System.out.println("Job failed to start");
}
.NET (C#)
public static voidStartJob(IJobManager jobManager, int jobID)
{
int status = jobManager.startJob(jobID);
if(status == LockStatus.Unlocked) //LockStatus.Unlocked = 0
Console.WriteLine("Job started successfully");
else
Console.WriteLine("Job failed to start");
}
.NET (VB)
Public Shared SubStartJob ByVal jobManager As IJobManager, ByVal jobID As Integer)
Dim objectManager As Integer = jobManager.StartJob(jobID)
If status = LockStatus.UnlockedThen 'LockStatus.Unlocked = 0
Console.WriteLine "Job started successfully");
Else
Console.WriteLine("Job failed to start");
End If
End Sub