Search in sources :

Example 11 with HtmlResponse

use of org.lastaflute.web.response.HtmlResponse in project fess by codelibs.

the class AdminFileconfigAction method edit.

@Execute
public HtmlResponse edit(final EditForm form) {
    validate(form, messages -> {
    }, () -> asListHtml());
    final PermissionHelper permissionHelper = ComponentUtil.getPermissionHelper();
    final String id = form.id;
    fileConfigService.getFileConfig(id).ifPresent(entity -> {
        copyBeanToBean(entity, form, copyOp -> {
            copyOp.excludeNull();
            copyOp.exclude(Constants.PERMISSIONS);
        });
        form.permissions = stream(entity.getPermissions()).get(stream -> stream.map(permissionHelper::decode).filter(StringUtil::isNotBlank).distinct().collect(Collectors.joining("\n")));
    }).orElse(() -> throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), () -> asListHtml()));
    saveToken();
    if (form.crudMode.intValue() == CrudMode.EDIT) {
        // back
        form.crudMode = CrudMode.DETAILS;
        return asDetailsHtml();
    } else {
        form.crudMode = CrudMode.EDIT;
        return asEditHtml();
    }
}
Also used : Constants(org.codelibs.fess.Constants) StreamUtil.stream(org.codelibs.core.stream.StreamUtil.stream) OptionalEntity(org.dbflute.optional.OptionalEntity) OptionalThing(org.dbflute.optional.OptionalThing) Resource(javax.annotation.Resource) StringUtil(org.codelibs.core.lang.StringUtil) PermissionHelper(org.codelibs.fess.helper.PermissionHelper) Collectors(java.util.stream.Collectors) ActionRuntime(org.lastaflute.web.ruts.process.ActionRuntime) FileConfigPager(org.codelibs.fess.app.pager.FileConfigPager) RenderDataUtil(org.codelibs.fess.util.RenderDataUtil) LabelTypeService(org.codelibs.fess.app.service.LabelTypeService) StreamUtil.split(org.codelibs.core.stream.StreamUtil.split) Stream(java.util.stream.Stream) CrudMode(org.codelibs.fess.app.web.CrudMode) ComponentUtil(org.codelibs.fess.util.ComponentUtil) FessAdminAction(org.codelibs.fess.app.web.base.FessAdminAction) SystemHelper(org.codelibs.fess.helper.SystemHelper) FileConfigService(org.codelibs.fess.app.service.FileConfigService) Execute(org.lastaflute.web.Execute) RenderData(org.lastaflute.web.response.render.RenderData) RoleTypeService(org.codelibs.fess.app.service.RoleTypeService) FileConfig(org.codelibs.fess.es.config.exentity.FileConfig) HtmlResponse(org.lastaflute.web.response.HtmlResponse) PermissionHelper(org.codelibs.fess.helper.PermissionHelper) Execute(org.lastaflute.web.Execute)

Aggregations

Execute (org.lastaflute.web.Execute)11 HtmlResponse (org.lastaflute.web.response.HtmlResponse)11 StringUtil (org.codelibs.core.lang.StringUtil)9 Resource (javax.annotation.Resource)8 Constants (org.codelibs.fess.Constants)8 FessAdminAction (org.codelibs.fess.app.web.base.FessAdminAction)8 ActionRuntime (org.lastaflute.web.ruts.process.ActionRuntime)8 RenderDataUtil (org.codelibs.fess.util.RenderDataUtil)7 Logger (org.slf4j.Logger)7 LoggerFactory (org.slf4j.LoggerFactory)7 List (java.util.List)6 StreamUtil.stream (org.codelibs.core.stream.StreamUtil.stream)6 ComponentUtil (org.codelibs.fess.util.ComponentUtil)6 OptionalEntity (org.dbflute.optional.OptionalEntity)6 ArrayList (java.util.ArrayList)5 Collectors (java.util.stream.Collectors)4 ActionResponse (org.lastaflute.web.response.ActionResponse)4 RenderData (org.lastaflute.web.response.render.RenderData)4 HashMap (java.util.HashMap)3 Map (java.util.Map)3