Search in sources :

Example 11 with LabelType

use of org.codelibs.fess.es.config.exentity.LabelType 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) Constants(org.codelibs.fess.Constants) LabelTypePager(org.codelibs.fess.app.pager.LabelTypePager) StreamUtil.stream(org.codelibs.core.stream.StreamUtil.stream) 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) 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) ComponentUtil(org.codelibs.fess.util.ComponentUtil) 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 12 with LabelType

use of org.codelibs.fess.es.config.exentity.LabelType in project fess by codelibs.

the class ApiAdminLabeltypeAction method createEditBody.

protected EditBody createEditBody(final LabelType entity) {
    final EditBody body = new EditBody();
    copyBeanToBean(entity, body, copyOp -> {
        copyOp.excludeNull();
        copyOp.exclude(Constants.PERMISSIONS);
    });
    final PermissionHelper permissionHelper = ComponentUtil.getPermissionHelper();
    body.permissions = stream(entity.getPermissions()).get(stream -> stream.map(s -> permissionHelper.decode(s)).filter(StringUtil::isNotBlank).distinct().collect(Collectors.joining("\n")));
    return body;
}
Also used : AdminLabeltypeAction.getLabelType(org.codelibs.fess.app.web.admin.labeltype.AdminLabeltypeAction.getLabelType) Constants(org.codelibs.fess.Constants) LabelTypePager(org.codelibs.fess.app.pager.LabelTypePager) StreamUtil.stream(org.codelibs.core.stream.StreamUtil.stream) 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) 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) ComponentUtil(org.codelibs.fess.util.ComponentUtil) Execute(org.lastaflute.web.Execute) ApiResponse(org.codelibs.fess.app.web.api.ApiResult.ApiResponse) PermissionHelper(org.codelibs.fess.helper.PermissionHelper) StringUtil(org.codelibs.core.lang.StringUtil)

Aggregations

LabelType (org.codelibs.fess.es.config.exentity.LabelType)12 Collectors (java.util.stream.Collectors)6 StringUtil (org.codelibs.core.lang.StringUtil)6 Constants (org.codelibs.fess.Constants)6 ArrayList (java.util.ArrayList)5 List (java.util.List)5 Resource (javax.annotation.Resource)5 StreamUtil.stream (org.codelibs.core.stream.StreamUtil.stream)5 LabelTypePager (org.codelibs.fess.app.pager.LabelTypePager)5 LabelTypeService (org.codelibs.fess.app.service.LabelTypeService)5 PermissionHelper (org.codelibs.fess.helper.PermissionHelper)5 ComponentUtil (org.codelibs.fess.util.ComponentUtil)5 Execute (org.lastaflute.web.Execute)5 CrudMode (org.codelibs.fess.app.web.CrudMode)4 AdminLabeltypeAction.getLabelType (org.codelibs.fess.app.web.admin.labeltype.AdminLabeltypeAction.getLabelType)4 ApiResult (org.codelibs.fess.app.web.api.ApiResult)4 StreamUtil.split (org.codelibs.core.stream.StreamUtil.split)3 ApiConfigResponse (org.codelibs.fess.app.web.api.ApiResult.ApiConfigResponse)3 ApiResponse (org.codelibs.fess.app.web.api.ApiResult.ApiResponse)3 ApiUpdateResponse (org.codelibs.fess.app.web.api.ApiResult.ApiUpdateResponse)3