use of org.xwiki.job.JobExecutor in project xwiki-platform by xwiki.
the class DeleteAction method startDeleteJob.
private Job startDeleteJob(EntityReference entityReference, XWikiContext context) throws XWikiException {
RefactoringScriptService refactoring = (RefactoringScriptService) Utils.getComponent(ScriptService.class, "refactoring");
EntityRequest deleteRequest = refactoring.createDeleteRequest(Arrays.asList(entityReference));
deleteRequest.setInteractive(isAsync(context.getRequest()));
try {
JobExecutor jobExecutor = Utils.getComponent(JobExecutor.class);
return jobExecutor.execute(RefactoringJobs.DELETE, deleteRequest);
} catch (JobException e) {
throw new XWikiException(String.format("Failed to schedule the delete job for [%s]", entityReference), e);
}
}
use of org.xwiki.job.JobExecutor in project xwiki-platform by xwiki.
the class UndeleteActionTest method setUp.
@Before
public void setUp() throws Exception {
mocker.registerMockComponent(CSRFToken.class);
mocker.registerComponent(ScriptService.class, "refactoring", refactoringScriptService);
Utils.setComponentManager(mocker);
when(context.getRequest()).thenReturn(request);
when(context.getWiki()).thenReturn(xwiki);
when(xwiki.getRightService()).thenReturn(rightsService);
when(context.getDoc()).thenReturn(document);
when(document.getDocumentReference()).thenReturn(new DocumentReference("xwiki", "Main", "DeletedDocument"));
jobExecutor = mocker.registerMockComponent(JobExecutor.class);
when(jobExecutor.execute(anyString(), any())).thenReturn(job);
jobRequest = mock(RestoreRequest.class);
when(refactoringScriptService.createRestoreRequest(any(List.class))).thenReturn(jobRequest);
when(refactoringScriptService.createRestoreRequest(anyString())).thenReturn(jobRequest);
}
use of org.xwiki.job.JobExecutor in project xwiki-platform by xwiki.
the class UndeleteAction method startRestoreJob.
private Job startRestoreJob(XWikiDeletedDocument deletedDocument, XWikiContext context) throws XWikiException {
XWikiRequest request = context.getRequest();
RefactoringScriptService refactoring = (RefactoringScriptService) Utils.getComponent(ScriptService.class, "refactoring");
RestoreRequest restoreRequest = null;
if (TRUE.equals(request.getParameter(INCLUDE_BATCH_PARAMETER))) {
// Restore the entire batch, including the current document.
String batchId = deletedDocument.getBatchId();
restoreRequest = refactoring.createRestoreRequest(batchId);
} else {
// Restore just the current document.
restoreRequest = refactoring.createRestoreRequest(Arrays.asList(deletedDocument.getId()));
}
restoreRequest.setInteractive(isAsync(request));
try {
JobExecutor jobExecutor = Utils.getComponent(JobExecutor.class);
return jobExecutor.execute(RefactoringJobs.RESTORE, restoreRequest);
} catch (JobException e) {
throw new XWikiException(String.format("Failed to schedule the restore job for deleted document [%s], id [%s] of batch [%s]", deletedDocument.getFullName(), deletedDocument.getId(), deletedDocument.getBatchId()), e);
}
}
Aggregations