Search in sources :

Example 81 with ApiResult

use of org.codelibs.fess.app.web.api.ApiResult in project fess by codelibs.

the class ApiAdminCrawlinginfoAction method delete$all.

// DELETE /api/admin/crawlinginfo/all
@Execute
public JsonResponse<ApiResult> delete$all() {
    try {
        crawlingInfoService.deleteOldSessions(processHelper.getRunningSessionIdSet());
        saveInfo(messages -> messages.addSuccessCrawlingInfoDeleteAll(GLOBAL));
    } catch (final Exception e) {
        throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToDeleteCrudTable(GLOBAL, buildThrowableMessage(e)));
    }
    return asJson(new ApiResponse().status(Status.OK).result());
}
Also used : CrawlingInfoPager(org.codelibs.fess.app.pager.CrawlingInfoPager) ProcessHelper(org.codelibs.fess.helper.ProcessHelper) FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) Resource(javax.annotation.Resource) ApiLogResponse(org.codelibs.fess.app.web.api.ApiResult.ApiLogResponse) JsonResponse(org.lastaflute.web.response.JsonResponse) Collectors(java.util.stream.Collectors) ApiResult(org.codelibs.fess.app.web.api.ApiResult) CrawlingInfoService(org.codelibs.fess.app.service.CrawlingInfoService) Status(org.codelibs.fess.app.web.api.ApiResult.Status) List(java.util.List) CrawlingInfo(org.codelibs.fess.es.config.exentity.CrawlingInfo) Execute(org.lastaflute.web.Execute) ApiResponse(org.codelibs.fess.app.web.api.ApiResult.ApiResponse) ApiResponse(org.codelibs.fess.app.web.api.ApiResult.ApiResponse) Execute(org.lastaflute.web.Execute)

Example 82 with ApiResult

use of org.codelibs.fess.app.web.api.ApiResult in project fess by codelibs.

the class ApiAdminCrawlinginfoAction method logs.

// ===================================================================================
//                                                                      Search Execute
//                                                                      ==============
// GET /api/admin/crawlinginfo/logs
// POST /api/admin/crawlinginfo/logs
@Execute
public JsonResponse<ApiResult> logs(final SearchBody body) {
    validateApi(body, messages -> {
    });
    final CrawlingInfoPager pager = copyBeanToNewBean(body, CrawlingInfoPager.class);
    final List<CrawlingInfo> list = crawlingInfoService.getCrawlingInfoList(pager);
    return asJson(new ApiResult.ApiLogsResponse<EditBody>().logs(list.stream().map(entity -> createEditBody(entity)).collect(Collectors.toList())).total(pager.getAllRecordCount()).status(ApiResult.Status.OK).result());
}
Also used : CrawlingInfoPager(org.codelibs.fess.app.pager.CrawlingInfoPager) CrawlingInfo(org.codelibs.fess.es.config.exentity.CrawlingInfo) ApiResult(org.codelibs.fess.app.web.api.ApiResult) Execute(org.lastaflute.web.Execute)

Example 83 with ApiResult

use of org.codelibs.fess.app.web.api.ApiResult in project fess by codelibs.

the class ApiAdminDataconfigAction method put$setting.

// PUT /api/admin/dataconfig/setting
@Execute
public JsonResponse<ApiResult> put$setting(final CreateBody body) {
    validateApi(body, messages -> {
    });
    body.crudMode = CrudMode.CREATE;
    final DataConfig dataConfig = getDataConfig(body).map(entity -> {
        try {
            dataConfigService.store(entity);
        } catch (final Exception e) {
            throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL, buildThrowableMessage(e)));
        }
        return entity;
    }).orElseGet(() -> {
        throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToCreateInstance(GLOBAL));
        return null;
    });
    return asJson(new ApiUpdateResponse().id(dataConfig.getId()).created(true).status(Status.OK).result());
}
Also used : DataConfigService(org.codelibs.fess.app.service.DataConfigService) DataConfig(org.codelibs.fess.es.config.exentity.DataConfig) FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) Resource(javax.annotation.Resource) ApiConfigResponse(org.codelibs.fess.app.web.api.ApiResult.ApiConfigResponse) JsonResponse(org.lastaflute.web.response.JsonResponse) Collectors(java.util.stream.Collectors) ApiResult(org.codelibs.fess.app.web.api.ApiResult) ApiUpdateResponse(org.codelibs.fess.app.web.api.ApiResult.ApiUpdateResponse) DataConfigPager(org.codelibs.fess.app.pager.DataConfigPager) Status(org.codelibs.fess.app.web.api.ApiResult.Status) List(java.util.List) CrudMode(org.codelibs.fess.app.web.CrudMode) AdminDataconfigAction.getDataConfig(org.codelibs.fess.app.web.admin.dataconfig.AdminDataconfigAction.getDataConfig) Execute(org.lastaflute.web.Execute) ApiResponse(org.codelibs.fess.app.web.api.ApiResult.ApiResponse) DataConfig(org.codelibs.fess.es.config.exentity.DataConfig) AdminDataconfigAction.getDataConfig(org.codelibs.fess.app.web.admin.dataconfig.AdminDataconfigAction.getDataConfig) ApiUpdateResponse(org.codelibs.fess.app.web.api.ApiResult.ApiUpdateResponse) Execute(org.lastaflute.web.Execute)

Example 84 with ApiResult

use of org.codelibs.fess.app.web.api.ApiResult in project fess by codelibs.

the class ApiAdminDictKuromojiAction method get$settings.

// GET /api/admin/dict/kuromoji/settings/{dictId}
@Execute
public JsonResponse<ApiResult> get$settings(final String dictId, final SearchBody body) {
    body.dictId = dictId;
    validateApi(body, messages -> {
    });
    final KuromojiPager pager = copyBeanToNewBean(body, KuromojiPager.class);
    return asJson(new ApiResult.ApiConfigsResponse<EditBody>().settings(kuromojiService.getKuromojiList(body.dictId, pager).stream().map(protwordsItem -> createEditBody(protwordsItem, dictId)).collect(Collectors.toList())).status(ApiResult.Status.OK).result());
}
Also used : FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) Resource(javax.annotation.Resource) JsonResponse(org.lastaflute.web.response.JsonResponse) Collectors(java.util.stream.Collectors) ApiResult(org.codelibs.fess.app.web.api.ApiResult) File(java.io.File) KuromojiItem(org.codelibs.fess.dict.kuromoji.KuromojiItem) StreamResponse(org.lastaflute.web.response.StreamResponse) KuromojiPager(org.codelibs.fess.app.pager.KuromojiPager) CrudMode(org.codelibs.fess.app.web.CrudMode) KuromojiFile(org.codelibs.fess.dict.kuromoji.KuromojiFile) Execute(org.lastaflute.web.Execute) AdminDictKuromojiAction.createKuromojiItem(org.codelibs.fess.app.web.admin.dict.kuromoji.AdminDictKuromojiAction.createKuromojiItem) KuromojiService(org.codelibs.fess.app.service.KuromojiService) InputStream(java.io.InputStream) UploadForm(org.codelibs.fess.app.web.admin.dict.kuromoji.UploadForm) KuromojiPager(org.codelibs.fess.app.pager.KuromojiPager) Execute(org.lastaflute.web.Execute)

Example 85 with ApiResult

use of org.codelibs.fess.app.web.api.ApiResult in project fess by codelibs.

the class ApiAdminDictKuromojiAction method post$upload.

// POST /api/admin/dict/kuromoji/upload/{dictId}
@Execute
public JsonResponse<ApiResult> post$upload(final String dictId, final UploadForm form) {
    form.dictId = dictId;
    validateApi(form, messages -> {
    });
    final KuromojiFile file = kuromojiService.getKuromojiFile(form.dictId).orElseGet(() -> {
        throwValidationErrorApi(messages -> messages.addErrorsFailedToUploadProtwordsFile(GLOBAL));
        return null;
    });
    try (InputStream inputStream = form.kuromojiFile.getInputStream()) {
        file.update(inputStream);
    } catch (final Throwable e) {
        e.printStackTrace();
        throwValidationErrorApi(messages -> messages.addErrorsFailedToUploadProtwordsFile(GLOBAL));
    }
    return asJson(new ApiResult.ApiResponse().status(ApiResult.Status.OK).result());
}
Also used : FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) Resource(javax.annotation.Resource) JsonResponse(org.lastaflute.web.response.JsonResponse) Collectors(java.util.stream.Collectors) ApiResult(org.codelibs.fess.app.web.api.ApiResult) File(java.io.File) KuromojiItem(org.codelibs.fess.dict.kuromoji.KuromojiItem) StreamResponse(org.lastaflute.web.response.StreamResponse) KuromojiPager(org.codelibs.fess.app.pager.KuromojiPager) CrudMode(org.codelibs.fess.app.web.CrudMode) KuromojiFile(org.codelibs.fess.dict.kuromoji.KuromojiFile) Execute(org.lastaflute.web.Execute) AdminDictKuromojiAction.createKuromojiItem(org.codelibs.fess.app.web.admin.dict.kuromoji.AdminDictKuromojiAction.createKuromojiItem) KuromojiService(org.codelibs.fess.app.service.KuromojiService) InputStream(java.io.InputStream) UploadForm(org.codelibs.fess.app.web.admin.dict.kuromoji.UploadForm) ApiResult(org.codelibs.fess.app.web.api.ApiResult) KuromojiFile(org.codelibs.fess.dict.kuromoji.KuromojiFile) InputStream(java.io.InputStream) Execute(org.lastaflute.web.Execute)

Aggregations

ApiResult (org.codelibs.fess.app.web.api.ApiResult)88 Execute (org.lastaflute.web.Execute)88 Resource (javax.annotation.Resource)65 FessApiAdminAction (org.codelibs.fess.app.web.api.admin.FessApiAdminAction)65 JsonResponse (org.lastaflute.web.response.JsonResponse)65 CrudMode (org.codelibs.fess.app.web.CrudMode)63 Collectors (java.util.stream.Collectors)61 List (java.util.List)43 ApiResponse (org.codelibs.fess.app.web.api.ApiResult.ApiResponse)31 Status (org.codelibs.fess.app.web.api.ApiResult.Status)31 ApiUpdateResponse (org.codelibs.fess.app.web.api.ApiResult.ApiUpdateResponse)26 InputStream (java.io.InputStream)23 StreamResponse (org.lastaflute.web.response.StreamResponse)23 ApiConfigResponse (org.codelibs.fess.app.web.api.ApiResult.ApiConfigResponse)22 File (java.io.File)18 Constants (org.codelibs.fess.Constants)12 StringUtil (org.codelibs.core.lang.StringUtil)9 ComponentUtil (org.codelibs.fess.util.ComponentUtil)9 BufferedReader (java.io.BufferedReader)7 InputStreamReader (java.io.InputStreamReader)7