Search in sources :

Example 1 with ScheduledJob

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);
}
Also used : ScheduledJob(org.codelibs.fess.es.config.exentity.ScheduledJob) JobManager(org.lastaflute.job.JobManager) Execute(org.lastaflute.web.Execute)

Example 2 with ScheduledJob

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());
}
Also used : ApiResult(org.codelibs.fess.app.web.api.ApiResult) AdminSchedulerAction.getScheduledJob(org.codelibs.fess.app.web.admin.scheduler.AdminSchedulerAction.getScheduledJob) ScheduledJob(org.codelibs.fess.es.config.exentity.ScheduledJob) SchedulerPager(org.codelibs.fess.app.pager.SchedulerPager) Execute(org.lastaflute.web.Execute)

Example 3 with ScheduledJob

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());
}
Also used : Constants(org.codelibs.fess.Constants) FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) Resource(javax.annotation.Resource) JsonResponse(org.lastaflute.web.response.JsonResponse) AdminSchedulerAction.getScheduledJob(org.codelibs.fess.app.web.admin.scheduler.AdminSchedulerAction.getScheduledJob) Collectors(java.util.stream.Collectors) ApiResult(org.codelibs.fess.app.web.api.ApiResult) Status(org.codelibs.fess.app.web.api.ApiResult.Status) List(java.util.List) CrudMode(org.codelibs.fess.app.web.CrudMode) SchedulerPager(org.codelibs.fess.app.pager.SchedulerPager) ScheduledJobService(org.codelibs.fess.app.service.ScheduledJobService) Execute(org.lastaflute.web.Execute) ApiResponse(org.codelibs.fess.app.web.api.ApiResult.ApiResponse) HtmlResponse(org.lastaflute.web.response.HtmlResponse) ScheduledJob(org.codelibs.fess.es.config.exentity.ScheduledJob) ApiResult(org.codelibs.fess.app.web.api.ApiResult) AdminSchedulerAction.getScheduledJob(org.codelibs.fess.app.web.admin.scheduler.AdminSchedulerAction.getScheduledJob) ScheduledJob(org.codelibs.fess.es.config.exentity.ScheduledJob) Execute(org.lastaflute.web.Execute)

Example 4 with ScheduledJob

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());
}
Also used : Constants(org.codelibs.fess.Constants) FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) Resource(javax.annotation.Resource) JsonResponse(org.lastaflute.web.response.JsonResponse) AdminSchedulerAction.getScheduledJob(org.codelibs.fess.app.web.admin.scheduler.AdminSchedulerAction.getScheduledJob) Collectors(java.util.stream.Collectors) ApiResult(org.codelibs.fess.app.web.api.ApiResult) Status(org.codelibs.fess.app.web.api.ApiResult.Status) List(java.util.List) CrudMode(org.codelibs.fess.app.web.CrudMode) SchedulerPager(org.codelibs.fess.app.pager.SchedulerPager) ScheduledJobService(org.codelibs.fess.app.service.ScheduledJobService) Execute(org.lastaflute.web.Execute) ApiResponse(org.codelibs.fess.app.web.api.ApiResult.ApiResponse) HtmlResponse(org.lastaflute.web.response.HtmlResponse) ScheduledJob(org.codelibs.fess.es.config.exentity.ScheduledJob) ApiResult(org.codelibs.fess.app.web.api.ApiResult) AdminSchedulerAction.getScheduledJob(org.codelibs.fess.app.web.admin.scheduler.AdminSchedulerAction.getScheduledJob) ScheduledJob(org.codelibs.fess.es.config.exentity.ScheduledJob) Execute(org.lastaflute.web.Execute)

Example 5 with ScheduledJob

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());
}
Also used : Constants(org.codelibs.fess.Constants) FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) Resource(javax.annotation.Resource) JsonResponse(org.lastaflute.web.response.JsonResponse) AdminSchedulerAction.getScheduledJob(org.codelibs.fess.app.web.admin.scheduler.AdminSchedulerAction.getScheduledJob) Collectors(java.util.stream.Collectors) ApiResult(org.codelibs.fess.app.web.api.ApiResult) Status(org.codelibs.fess.app.web.api.ApiResult.Status) List(java.util.List) CrudMode(org.codelibs.fess.app.web.CrudMode) SchedulerPager(org.codelibs.fess.app.pager.SchedulerPager) ScheduledJobService(org.codelibs.fess.app.service.ScheduledJobService) Execute(org.lastaflute.web.Execute) ApiResponse(org.codelibs.fess.app.web.api.ApiResult.ApiResponse) HtmlResponse(org.lastaflute.web.response.HtmlResponse) ScheduledJob(org.codelibs.fess.es.config.exentity.ScheduledJob) ApiResult(org.codelibs.fess.app.web.api.ApiResult) AdminSchedulerAction.getScheduledJob(org.codelibs.fess.app.web.admin.scheduler.AdminSchedulerAction.getScheduledJob) ScheduledJob(org.codelibs.fess.es.config.exentity.ScheduledJob) Execute(org.lastaflute.web.Execute)

Aggregations

ScheduledJob (org.codelibs.fess.es.config.exentity.ScheduledJob)7 Execute (org.lastaflute.web.Execute)5 Constants (org.codelibs.fess.Constants)4 SchedulerPager (org.codelibs.fess.app.pager.SchedulerPager)4 AdminSchedulerAction.getScheduledJob (org.codelibs.fess.app.web.admin.scheduler.AdminSchedulerAction.getScheduledJob)4 ApiResult (org.codelibs.fess.app.web.api.ApiResult)4 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 Resource (javax.annotation.Resource)3 ScheduledJobService (org.codelibs.fess.app.service.ScheduledJobService)3 CrudMode (org.codelibs.fess.app.web.CrudMode)3 ApiResponse (org.codelibs.fess.app.web.api.ApiResult.ApiResponse)3 Status (org.codelibs.fess.app.web.api.ApiResult.Status)3 FessApiAdminAction (org.codelibs.fess.app.web.api.admin.FessApiAdminAction)3 JobManager (org.lastaflute.job.JobManager)3 HtmlResponse (org.lastaflute.web.response.HtmlResponse)3 JsonResponse (org.lastaflute.web.response.JsonResponse)3 TimeoutTask (org.codelibs.core.timer.TimeoutTask)2 JobLog (org.codelibs.fess.es.config.exentity.JobLog)2 ScheduledJobException (org.codelibs.fess.job.ScheduledJobException)2