Search in sources :

Example 16 with ApiUpdateResponse

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

the class ApiAdminLabeltypeAction method put$setting.

// PUT /api/admin/labeltype/setting
@Execute
public JsonResponse<ApiResult> put$setting(final CreateBody body) {
    validateApi(body, messages -> {
    });
    body.crudMode = CrudMode.CREATE;
    final LabelType labelType = getLabelType(body).map(entity -> {
        try {
            labelTypeService.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(labelType.getId()).created(true).status(Status.OK).result());
}
Also used : AdminLabeltypeAction.getLabelType(org.codelibs.fess.app.web.admin.labeltype.AdminLabeltypeAction.getLabelType) LabelTypePager(org.codelibs.fess.app.pager.LabelTypePager) 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) LabelType(org.codelibs.fess.es.config.exentity.LabelType) LabelTypeService(org.codelibs.fess.app.service.LabelTypeService) Status(org.codelibs.fess.app.web.api.ApiResult.Status) List(java.util.List) CrudMode(org.codelibs.fess.app.web.CrudMode) Execute(org.lastaflute.web.Execute) ApiResponse(org.codelibs.fess.app.web.api.ApiResult.ApiResponse) AdminLabeltypeAction.getLabelType(org.codelibs.fess.app.web.admin.labeltype.AdminLabeltypeAction.getLabelType) LabelType(org.codelibs.fess.es.config.exentity.LabelType) ApiUpdateResponse(org.codelibs.fess.app.web.api.ApiResult.ApiUpdateResponse) Execute(org.lastaflute.web.Execute)

Example 17 with ApiUpdateResponse

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

the class ApiAdminWebauthAction method put$setting.

// PUT /api/admin/webauth/setting
@Execute
public JsonResponse<ApiResult> put$setting(final CreateBody body) {
    validateApi(body, messages -> {
    });
    if (!isValidWebConfigId(body.webConfigId)) {
        return asJson(new ApiErrorResponse().message("invalid webConfigId").status(Status.BAD_REQUEST).result());
    }
    body.crudMode = CrudMode.CREATE;
    final WebAuthentication webAuth = getWebAuthentication(body).map(entity -> {
        try {
            webAuthService.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(webAuth.getId()).created(true).status(Status.OK).result());
}
Also used : WebAuthentication(org.codelibs.fess.es.config.exentity.WebAuthentication) WebAuthPager(org.codelibs.fess.app.pager.WebAuthPager) FessApiAdminAction(org.codelibs.fess.app.web.api.admin.FessApiAdminAction) WebAuthenticationService(org.codelibs.fess.app.service.WebAuthenticationService) WebConfigService(org.codelibs.fess.app.service.WebConfigService) 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) Status(org.codelibs.fess.app.web.api.ApiResult.Status) List(java.util.List) CrudMode(org.codelibs.fess.app.web.CrudMode) AdminWebauthAction.getWebAuthentication(org.codelibs.fess.app.web.admin.webauth.AdminWebauthAction.getWebAuthentication) Execute(org.lastaflute.web.Execute) ApiResponse(org.codelibs.fess.app.web.api.ApiResult.ApiResponse) ApiErrorResponse(org.codelibs.fess.app.web.api.ApiResult.ApiErrorResponse) WebAuthentication(org.codelibs.fess.es.config.exentity.WebAuthentication) AdminWebauthAction.getWebAuthentication(org.codelibs.fess.app.web.admin.webauth.AdminWebauthAction.getWebAuthentication) ApiUpdateResponse(org.codelibs.fess.app.web.api.ApiResult.ApiUpdateResponse) ApiErrorResponse(org.codelibs.fess.app.web.api.ApiResult.ApiErrorResponse) Execute(org.lastaflute.web.Execute)

Example 18 with ApiUpdateResponse

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

the class ApiAdminKeymatchAction method put$setting.

// PUT /api/admin/keymatch/setting
@Execute
public JsonResponse<ApiResult> put$setting(final CreateBody body) {
    validateApi(body, messages -> {
    });
    body.crudMode = CrudMode.CREATE;
    final KeyMatch keyMatch = getKeyMatch(body).map(entity -> {
        try {
            keyMatchService.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(keyMatch.getId()).created(true).status(Status.OK).result());
}
Also used : 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) KeyMatchService(org.codelibs.fess.app.service.KeyMatchService) Status(org.codelibs.fess.app.web.api.ApiResult.Status) List(java.util.List) CrudMode(org.codelibs.fess.app.web.CrudMode) KeyMatch(org.codelibs.fess.es.config.exentity.KeyMatch) Execute(org.lastaflute.web.Execute) ApiResponse(org.codelibs.fess.app.web.api.ApiResult.ApiResponse) AdminKeymatchAction.getKeyMatch(org.codelibs.fess.app.web.admin.keymatch.AdminKeymatchAction.getKeyMatch) KeyMatchPager(org.codelibs.fess.app.pager.KeyMatchPager) KeyMatch(org.codelibs.fess.es.config.exentity.KeyMatch) AdminKeymatchAction.getKeyMatch(org.codelibs.fess.app.web.admin.keymatch.AdminKeymatchAction.getKeyMatch) ApiUpdateResponse(org.codelibs.fess.app.web.api.ApiResult.ApiUpdateResponse) Execute(org.lastaflute.web.Execute)

Example 19 with ApiUpdateResponse

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

the class ApiAdminDuplicatehostAction method put$setting.

// PUT /api/admin/duplicatehost/setting
@Execute
public JsonResponse<ApiResult> put$setting(final CreateBody body) {
    validateApi(body, messages -> {
    });
    body.crudMode = CrudMode.CREATE;
    final DuplicateHost duplicateHost = getDuplicateHost(body).map(entity -> {
        try {
            duplicateHostService.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(duplicateHost.getId()).created(true).status(Status.OK).result());
}
Also used : DuplicateHostPager(org.codelibs.fess.app.pager.DuplicateHostPager) 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) Status(org.codelibs.fess.app.web.api.ApiResult.Status) List(java.util.List) CrudMode(org.codelibs.fess.app.web.CrudMode) DuplicateHostService(org.codelibs.fess.app.service.DuplicateHostService) Execute(org.lastaflute.web.Execute) ApiResponse(org.codelibs.fess.app.web.api.ApiResult.ApiResponse) AdminDuplicatehostAction.getDuplicateHost(org.codelibs.fess.app.web.admin.duplicatehost.AdminDuplicatehostAction.getDuplicateHost) DuplicateHost(org.codelibs.fess.es.config.exentity.DuplicateHost) ApiUpdateResponse(org.codelibs.fess.app.web.api.ApiResult.ApiUpdateResponse) AdminDuplicatehostAction.getDuplicateHost(org.codelibs.fess.app.web.admin.duplicatehost.AdminDuplicatehostAction.getDuplicateHost) DuplicateHost(org.codelibs.fess.es.config.exentity.DuplicateHost) Execute(org.lastaflute.web.Execute)

Example 20 with ApiUpdateResponse

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

Aggregations

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