Search in sources :

Example 1 with AbstractRequest

use of org.xwiki.job.AbstractRequest in project xwiki-platform by xwiki.

the class ExtensionJobEventConverter method fromRemote.

@Override
public boolean fromRemote(RemoteEventData remoteEvent, LocalEventData localEvent) {
    if (remoteEvent.getEvent() instanceof JobStartedEvent) {
        JobStartedEvent jobEvent = (JobStartedEvent) remoteEvent.getEvent();
        if (JOBS.contains(jobEvent.getJobType())) {
            Request request = jobEvent.getRequest();
            // Indicate the job has been triggered by a remote event
            if (!(request instanceof AbstractRequest)) {
                request = new DefaultRequest(request);
            }
            ((AbstractRequest) request).setRemote(true);
            // We don't want to directly simulate a new JobStartedEvent event but we want to start a new job
            // which will generate a new JobStartedEvent
            localEvent.setEvent(new RemoteExtensionJobStartedEvent(jobEvent.getJobType(), request));
            return true;
        }
    }
    return false;
}
Also used : DefaultRequest(org.xwiki.job.DefaultRequest) AbstractRequest(org.xwiki.job.AbstractRequest) Request(org.xwiki.job.Request) AbstractRequest(org.xwiki.job.AbstractRequest) DefaultRequest(org.xwiki.job.DefaultRequest) JobStartedEvent(org.xwiki.job.event.JobStartedEvent)

Aggregations

AbstractRequest (org.xwiki.job.AbstractRequest)1 DefaultRequest (org.xwiki.job.DefaultRequest)1 Request (org.xwiki.job.Request)1 JobStartedEvent (org.xwiki.job.event.JobStartedEvent)1