use of org.codelibs.fess.es.config.exentity.ScheduledJob in project fess by codelibs.
the class AdminWizardAction method startCrawling.
@Execute
public HtmlResponse startCrawling(final StartCrawlingForm form) {
verifyToken(() -> asIndexHtml());
if (!processHelper.isProcessRunning()) {
final List<ScheduledJob> scheduledJobList = scheduledJobService.getCrawlerJobList();
final JobManager jobManager = ComponentUtil.getJobManager();
for (final ScheduledJob scheduledJob : scheduledJobList) {
jobManager.findJobByUniqueOf(LaJobUnique.of(scheduledJob.getId())).ifPresent(job -> {
job.launchNow();
});
}
saveInfo(messages -> messages.addSuccessStartCrawlProcess(GLOBAL));
} else {
saveError(messages -> messages.addErrorsFailedToStartCrawlProcess(GLOBAL));
}
return redirect(AdminWizardAction.class);
}
use of org.codelibs.fess.es.config.exentity.ScheduledJob in project fess by codelibs.
the class ApiAdminSchedulerAction method settings.
// GET /api/admin/scheduler
// POST /api/admin/scheduler
@Execute
public JsonResponse<ApiResult> settings(final SearchBody body) {
validateApi(body, messages -> {
});
final SchedulerPager pager = copyBeanToNewBean(body, SchedulerPager.class);
final List<ScheduledJob> list = scheduledJobService.getScheduledJobList(pager);
return asJson(new ApiResult.ApiConfigsResponse<EditBody>().settings(list.stream().map(entity -> createEditBody(entity)).collect(Collectors.toList())).total(pager.getAllRecordCount()).status(ApiResult.Status.OK).result());
}
use of org.codelibs.fess.es.config.exentity.ScheduledJob in project fess by codelibs.
the class ApiAdminSchedulerAction method delete$setting.
// DELETE /api/admin/scheduler/setting/{id}
@Execute
public JsonResponse<ApiResult> delete$setting(final String id) {
final ScheduledJob entity = scheduledJobService.getScheduledJob(id).orElseGet(() -> {
throwValidationErrorApi(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id));
return null;
});
try {
scheduledJobService.delete(entity);
saveInfo(messages -> messages.addSuccessCrudDeleteCrudTable(GLOBAL));
} catch (final Exception e) {
throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToDeleteCrudTable(GLOBAL, buildThrowableMessage(e)));
}
return asJson(new ApiResult.ApiUpdateResponse().id(id).created(false).status(ApiResult.Status.OK).result());
}
use of org.codelibs.fess.es.config.exentity.ScheduledJob in project fess by codelibs.
the class ApiAdminSchedulerAction method put$setting.
// PUT /api/admin/scheduler/setting
@Execute
public JsonResponse<ApiResult> put$setting(final CreateBody body) {
validateApi(body, messages -> {
});
body.crudMode = CrudMode.CREATE;
final ScheduledJob entity = getScheduledJob(body).orElseGet(() -> {
throwValidationErrorApi(messages -> {
messages.addErrorsCrudFailedToCreateInstance(GLOBAL);
});
return null;
});
try {
scheduledJobService.store(entity);
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
} catch (final Exception e) {
throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL, buildThrowableMessage(e)));
}
return asJson(new ApiResult.ApiUpdateResponse().id(entity.getId()).created(true).status(ApiResult.Status.OK).result());
}
use of org.codelibs.fess.es.config.exentity.ScheduledJob in project fess by codelibs.
the class ApiAdminSchedulerAction method post$setting.
// POST /api/admin/scheduler/setting
@Execute
public JsonResponse<ApiResult> post$setting(final EditBody body) {
validateApi(body, messages -> {
});
body.crudMode = CrudMode.EDIT;
final ScheduledJob entity = getScheduledJob(body).orElseGet(() -> {
throwValidationErrorApi(messages -> {
messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, body.id);
});
return null;
});
try {
scheduledJobService.store(entity);
} catch (final Exception e) {
throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToUpdateCrudTable(GLOBAL, buildThrowableMessage(e)));
}
return asJson(new ApiResult.ApiUpdateResponse().id(entity.getId()).created(false).status(ApiResult.Status.OK).result());
}
Aggregations