Search in sources :

Example 6 with DataConfig

use of org.codelibs.fess.es.config.exentity.DataConfig 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 7 with DataConfig

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

the class AdminDataconfigAction method getDataConfig.

public static OptionalEntity<DataConfig> getDataConfig(final CreateForm form) {
    final SystemHelper systemHelper = ComponentUtil.getSystemHelper();
    final String username = systemHelper.getUsername();
    final long currentTime = systemHelper.getCurrentTimeAsLong();
    return getEntity(form, username, currentTime).map(entity -> {
        entity.setUpdatedBy(username);
        entity.setUpdatedTime(currentTime);
        copyBeanToBean(form, entity, op -> op.exclude(Stream.concat(Stream.of(Constants.COMMON_CONVERSION_RULE), Stream.of(Constants.PERMISSIONS)).toArray(n -> new String[n])));
        final PermissionHelper permissionHelper = ComponentUtil.getPermissionHelper();
        entity.setPermissions(split(form.permissions, "\n").get(stream -> stream.map(s -> permissionHelper.encode(s)).filter(StringUtil::isNotBlank).distinct().toArray(n -> new String[n])));
        return entity;
    });
}
Also used : Constants(org.codelibs.fess.Constants) OptionalThing(org.dbflute.optional.OptionalThing) HashMap(java.util.HashMap) PermissionHelper(org.codelibs.fess.helper.PermissionHelper) ActionRuntime(org.lastaflute.web.ruts.process.ActionRuntime) RenderDataUtil(org.codelibs.fess.util.RenderDataUtil) ArrayList(java.util.ArrayList) DataConfigPager(org.codelibs.fess.app.pager.DataConfigPager) StreamUtil.split(org.codelibs.core.stream.StreamUtil.split) CrudMode(org.codelibs.fess.app.web.CrudMode) FessAdminAction(org.codelibs.fess.app.web.base.FessAdminAction) Map(java.util.Map) RenderData(org.lastaflute.web.response.render.RenderData) RoleTypeService(org.codelibs.fess.app.service.RoleTypeService) HtmlResponse(org.lastaflute.web.response.HtmlResponse) DataConfigService(org.codelibs.fess.app.service.DataConfigService) DataConfig(org.codelibs.fess.es.config.exentity.DataConfig) StreamUtil.stream(org.codelibs.core.stream.StreamUtil.stream) OptionalEntity(org.dbflute.optional.OptionalEntity) Resource(javax.annotation.Resource) StringUtil(org.codelibs.core.lang.StringUtil) Collectors(java.util.stream.Collectors) LabelTypeService(org.codelibs.fess.app.service.LabelTypeService) List(java.util.List) Stream(java.util.stream.Stream) ComponentUtil(org.codelibs.fess.util.ComponentUtil) SystemHelper(org.codelibs.fess.helper.SystemHelper) DataStoreFactory(org.codelibs.fess.ds.DataStoreFactory) Execute(org.lastaflute.web.Execute) SystemHelper(org.codelibs.fess.helper.SystemHelper) PermissionHelper(org.codelibs.fess.helper.PermissionHelper) StringUtil(org.codelibs.core.lang.StringUtil)

Aggregations

DataConfig (org.codelibs.fess.es.config.exentity.DataConfig)7 HashMap (java.util.HashMap)4 List (java.util.List)4 Collectors (java.util.stream.Collectors)4 DataConfigPager (org.codelibs.fess.app.pager.DataConfigPager)4 Execute (org.lastaflute.web.Execute)4 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 Resource (javax.annotation.Resource)3 StringUtil (org.codelibs.core.lang.StringUtil)3 Constants (org.codelibs.fess.Constants)3 DataConfigService (org.codelibs.fess.app.service.DataConfigService)3 CrudMode (org.codelibs.fess.app.web.CrudMode)3 AdminDataconfigAction.getDataConfig (org.codelibs.fess.app.web.admin.dataconfig.AdminDataconfigAction.getDataConfig)3 ApiResult (org.codelibs.fess.app.web.api.ApiResult)3 IndexUpdateCallback (org.codelibs.fess.ds.IndexUpdateCallback)3 ComponentUtil (org.codelibs.fess.util.ComponentUtil)3 StreamUtil.split (org.codelibs.core.stream.StreamUtil.split)2 StreamUtil.stream (org.codelibs.core.stream.StreamUtil.stream)2 ApiConfigResponse (org.codelibs.fess.app.web.api.ApiResult.ApiConfigResponse)2