Search in sources :

Example 26 with Status

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

the class ApiAdminFileauthAction method post$setting.

// POST /api/admin/fileauth/setting
@Execute
public JsonResponse<ApiResult> post$setting(final EditBody body) {
    validateApi(body, messages -> {
    });
    body.crudMode = CrudMode.EDIT;
    final FileAuthentication fileAuth = getFileAuthentication(body).map(entity -> {
        try {
            fileAuthService.store(entity);
        } catch (final Exception e) {
            throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToUpdateCrudTable(GLOBAL, buildThrowableMessage(e)));
        }
        return entity;
    }).orElseGet(() -> {
        throwValidationErrorApi(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, body.id));
        return null;
    });
    return asJson(new ApiUpdateResponse().id(fileAuth.getId()).created(false).status(Status.OK).result());
}
Also used : FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) AdminFileauthAction.getFileAuthentication(org.codelibs.fess.app.web.admin.fileauth.AdminFileauthAction.getFileAuthentication) Resource(javax.annotation.Resource) FileAuthenticationService(org.codelibs.fess.app.service.FileAuthenticationService) 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) Status(org.codelibs.fess.app.web.api.ApiResult.Status) List(java.util.List) CrudMode(org.codelibs.fess.app.web.CrudMode) FileConfigService(org.codelibs.fess.app.service.FileConfigService) Execute(org.lastaflute.web.Execute) ApiResponse(org.codelibs.fess.app.web.api.ApiResult.ApiResponse) ApiErrorResponse(org.codelibs.fess.app.web.api.ApiResult.ApiErrorResponse) FileAuthPager(org.codelibs.fess.app.pager.FileAuthPager) FileAuthentication(org.codelibs.fess.es.config.exentity.FileAuthentication) ApiUpdateResponse(org.codelibs.fess.app.web.api.ApiResult.ApiUpdateResponse) AdminFileauthAction.getFileAuthentication(org.codelibs.fess.app.web.admin.fileauth.AdminFileauthAction.getFileAuthentication) FileAuthentication(org.codelibs.fess.es.config.exentity.FileAuthentication) Execute(org.lastaflute.web.Execute)

Example 27 with Status

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

the class ApiAdminFileconfigAction method post$setting.

// POST /api/admin/fileconfig/setting
@Execute
public JsonResponse<ApiResult> post$setting(final EditBody body) {
    validateApi(body, messages -> {
    });
    body.crudMode = CrudMode.EDIT;
    final FileConfig fileConfig = getFileConfig(body).map(entity -> {
        try {
            fileConfigService.store(entity);
        } catch (final Exception e) {
            throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToUpdateCrudTable(GLOBAL, buildThrowableMessage(e)));
        }
        return entity;
    }).orElseGet(() -> {
        throwValidationErrorApi(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, body.id));
        return null;
    });
    return asJson(new ApiUpdateResponse().id(fileConfig.getId()).created(false).status(Status.OK).result());
}
Also used : FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) AdminFileconfigAction.getFileConfig(org.codelibs.fess.app.web.admin.fileconfig.AdminFileconfigAction.getFileConfig) 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) FileConfigPager(org.codelibs.fess.app.pager.FileConfigPager) Status(org.codelibs.fess.app.web.api.ApiResult.Status) List(java.util.List) CrudMode(org.codelibs.fess.app.web.CrudMode) FileConfigService(org.codelibs.fess.app.service.FileConfigService) Execute(org.lastaflute.web.Execute) ApiResponse(org.codelibs.fess.app.web.api.ApiResult.ApiResponse) FileConfig(org.codelibs.fess.es.config.exentity.FileConfig) AdminFileconfigAction.getFileConfig(org.codelibs.fess.app.web.admin.fileconfig.AdminFileconfigAction.getFileConfig) FileConfig(org.codelibs.fess.es.config.exentity.FileConfig) ApiUpdateResponse(org.codelibs.fess.app.web.api.ApiResult.ApiUpdateResponse) Execute(org.lastaflute.web.Execute)

Example 28 with Status

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

the class ApiAdminAccesstokenAction method put$setting.

// PUT /api/admin/accesstoken/setting
@Execute
public JsonResponse<ApiResult> put$setting(final CreateBody body) {
    validateApi(body, messages -> {
    });
    body.crudMode = CrudMode.CREATE;
    final AccessToken accessToken = getAccessToken(body).map(entity -> {
        entity.setToken(systemHelper.generateAccessToken());
        try {
            accessTokenService.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(accessToken.getId()).created(true).status(Status.OK).result());
}
Also used : AccessTokenPager(org.codelibs.fess.app.pager.AccessTokenPager) AdminAccesstokenAction.getAccessToken(org.codelibs.fess.app.web.admin.accesstoken.AdminAccesstokenAction.getAccessToken) Constants(org.codelibs.fess.Constants) StreamUtil.stream(org.codelibs.core.stream.StreamUtil.stream) AccessTokenService(org.codelibs.fess.app.service.AccessTokenService) FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) Resource(javax.annotation.Resource) StringUtil(org.codelibs.core.lang.StringUtil) ApiConfigResponse(org.codelibs.fess.app.web.api.ApiResult.ApiConfigResponse) JsonResponse(org.lastaflute.web.response.JsonResponse) PermissionHelper(org.codelibs.fess.helper.PermissionHelper) Collectors(java.util.stream.Collectors) ApiResult(org.codelibs.fess.app.web.api.ApiResult) ApiUpdateResponse(org.codelibs.fess.app.web.api.ApiResult.ApiUpdateResponse) Status(org.codelibs.fess.app.web.api.ApiResult.Status) List(java.util.List) CrudMode(org.codelibs.fess.app.web.CrudMode) AdminAccesstokenAction(org.codelibs.fess.app.web.admin.accesstoken.AdminAccesstokenAction) ComponentUtil(org.codelibs.fess.util.ComponentUtil) AccessToken(org.codelibs.fess.es.config.exentity.AccessToken) Execute(org.lastaflute.web.Execute) ApiResponse(org.codelibs.fess.app.web.api.ApiResult.ApiResponse) ApiConfigsResponse(org.codelibs.fess.app.web.api.ApiResult.ApiConfigsResponse) AdminAccesstokenAction.getAccessToken(org.codelibs.fess.app.web.admin.accesstoken.AdminAccesstokenAction.getAccessToken) AccessToken(org.codelibs.fess.es.config.exentity.AccessToken) ApiUpdateResponse(org.codelibs.fess.app.web.api.ApiResult.ApiUpdateResponse) Execute(org.lastaflute.web.Execute)

Example 29 with Status

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

the class ApiAdminBoostdocAction method post$setting.

// POST /api/admin/boostdoc/setting
@Execute
public JsonResponse<ApiResult> post$setting(final EditBody body) {
    validateApi(body, messages -> {
    });
    body.crudMode = CrudMode.EDIT;
    final BoostDocumentRule boostDoc = getBoostDocumentRule(body).map(entity -> {
        try {
            boostDocumentRuleService.store(entity);
        } catch (final Exception e) {
            throwValidationErrorApi(messages -> messages.addErrorsCrudFailedToUpdateCrudTable(GLOBAL, buildThrowableMessage(e)));
        }
        return entity;
    }).orElseGet(() -> {
        throwValidationErrorApi(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, body.id));
        return null;
    });
    return asJson(new ApiUpdateResponse().id(boostDoc.getId()).created(false).status(Status.OK).result());
}
Also used : FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) Resource(javax.annotation.Resource) BoostDocumentRule(org.codelibs.fess.es.config.exentity.BoostDocumentRule) ApiConfigResponse(org.codelibs.fess.app.web.api.ApiResult.ApiConfigResponse) JsonResponse(org.lastaflute.web.response.JsonResponse) AdminBoostdocAction.getBoostDocumentRule(org.codelibs.fess.app.web.admin.boostdoc.AdminBoostdocAction.getBoostDocumentRule) Collectors(java.util.stream.Collectors) ApiResult(org.codelibs.fess.app.web.api.ApiResult) ApiUpdateResponse(org.codelibs.fess.app.web.api.ApiResult.ApiUpdateResponse) Status(org.codelibs.fess.app.web.api.ApiResult.Status) List(java.util.List) CrudMode(org.codelibs.fess.app.web.CrudMode) BoostDocumentRuleService(org.codelibs.fess.app.service.BoostDocumentRuleService) Execute(org.lastaflute.web.Execute) ApiResponse(org.codelibs.fess.app.web.api.ApiResult.ApiResponse) BoostDocPager(org.codelibs.fess.app.pager.BoostDocPager) ApiConfigsResponse(org.codelibs.fess.app.web.api.ApiResult.ApiConfigsResponse) BoostDocumentRule(org.codelibs.fess.es.config.exentity.BoostDocumentRule) AdminBoostdocAction.getBoostDocumentRule(org.codelibs.fess.app.web.admin.boostdoc.AdminBoostdocAction.getBoostDocumentRule) ApiUpdateResponse(org.codelibs.fess.app.web.api.ApiResult.ApiUpdateResponse) Execute(org.lastaflute.web.Execute)

Example 30 with Status

use of org.codelibs.fess.app.web.api.ApiResult.Status 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)

Aggregations

Resource (javax.annotation.Resource)31 ApiResult (org.codelibs.fess.app.web.api.ApiResult)31 ApiResponse (org.codelibs.fess.app.web.api.ApiResult.ApiResponse)31 Status (org.codelibs.fess.app.web.api.ApiResult.Status)31 FessApiAdminAction (org.codelibs.fess.app.web.api.admin.FessApiAdminAction)31 Execute (org.lastaflute.web.Execute)31 JsonResponse (org.lastaflute.web.response.JsonResponse)31 CrudMode (org.codelibs.fess.app.web.CrudMode)29 List (java.util.List)27 Collectors (java.util.stream.Collectors)27 ApiUpdateResponse (org.codelibs.fess.app.web.api.ApiResult.ApiUpdateResponse)26 ApiConfigResponse (org.codelibs.fess.app.web.api.ApiResult.ApiConfigResponse)22 Constants (org.codelibs.fess.Constants)9 StringUtil (org.codelibs.core.lang.StringUtil)6 WebConfigService (org.codelibs.fess.app.service.WebConfigService)6 ApiErrorResponse (org.codelibs.fess.app.web.api.ApiResult.ApiErrorResponse)6 ComponentUtil (org.codelibs.fess.util.ComponentUtil)6 Map (java.util.Map)4 FileConfigService (org.codelibs.fess.app.service.FileConfigService)4 ApiConfigsResponse (org.codelibs.fess.app.web.api.ApiResult.ApiConfigsResponse)4