Search in sources :

Example 11 with PermissionHelper

use of org.codelibs.fess.helper.PermissionHelper in project fess by codelibs.

the class AdminElevatewordAction method getElevateWord.

public static OptionalEntity<ElevateWord> getElevateWord(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);
        BeanUtil.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(permissionHelper::encode).filter(StringUtil::isNotBlank).distinct().toArray(n -> new String[n])));
        return entity;
    });
}
Also used : BeanUtil(org.codelibs.core.beans.util.BeanUtil) Constants(org.codelibs.fess.Constants) FessSystemException(org.codelibs.fess.exception.FessSystemException) ElevateWordPager(org.codelibs.fess.app.pager.ElevateWordPager) OptionalThing(org.dbflute.optional.OptionalThing) PermissionHelper(org.codelibs.fess.helper.PermissionHelper) ActionRuntime(org.lastaflute.web.ruts.process.ActionRuntime) RenderDataUtil(org.codelibs.fess.util.RenderDataUtil) StreamUtil.split(org.codelibs.core.stream.StreamUtil.split) CrudMode(org.codelibs.fess.app.web.CrudMode) FessAdminAction(org.codelibs.fess.app.web.base.FessAdminAction) RenderData(org.lastaflute.web.response.render.RenderData) OutputStreamWriter(java.io.OutputStreamWriter) HtmlResponse(org.lastaflute.web.response.HtmlResponse) Path(java.nio.file.Path) StreamUtil.stream(org.codelibs.core.stream.StreamUtil.stream) ElevateWordService(org.codelibs.fess.app.service.ElevateWordService) Files(java.nio.file.Files) BufferedWriter(java.io.BufferedWriter) OptionalEntity(org.dbflute.optional.OptionalEntity) Resource(javax.annotation.Resource) StringUtil(org.codelibs.core.lang.StringUtil) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) Collectors(java.util.stream.Collectors) LabelTypeService(org.codelibs.fess.app.service.LabelTypeService) ActionResponse(org.lastaflute.web.response.ActionResponse) Stream(java.util.stream.Stream) ComponentUtil(org.codelibs.fess.util.ComponentUtil) SystemHelper(org.codelibs.fess.helper.SystemHelper) Writer(java.io.Writer) Execute(org.lastaflute.web.Execute) ElevateWord(org.codelibs.fess.es.config.exentity.ElevateWord) BufferedReader(java.io.BufferedReader) SuggestHelper(org.codelibs.fess.helper.SuggestHelper) InputStream(java.io.InputStream) SystemHelper(org.codelibs.fess.helper.SystemHelper) PermissionHelper(org.codelibs.fess.helper.PermissionHelper) StringUtil(org.codelibs.core.lang.StringUtil)

Example 12 with PermissionHelper

use of org.codelibs.fess.helper.PermissionHelper 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)

Example 13 with PermissionHelper

use of org.codelibs.fess.helper.PermissionHelper in project fess by codelibs.

the class AdminLabeltypeAction method details.

// -----------------------------------------------------
//                                               Details
//                                               -------
@Execute
public HtmlResponse details(final int crudMode, final String id) {
    verifyCrudMode(crudMode, CrudMode.DETAILS);
    saveToken();
    return asHtml(path_AdminLabeltype_AdminLabeltypeDetailsJsp).useForm(EditForm.class, op -> {
        op.setup(form -> {
            labelTypeService.getLabelType(id).ifPresent(entity -> {
                copyBeanToBean(entity, form, copyOp -> {
                    copyOp.excludeNull();
                    copyOp.exclude(Constants.PERMISSIONS);
                });
                final PermissionHelper permissionHelper = ComponentUtil.getPermissionHelper();
                form.permissions = stream(entity.getPermissions()).get(stream -> stream.map(s -> permissionHelper.decode(s)).filter(StringUtil::isNotBlank).distinct().collect(Collectors.joining("\n")));
                form.crudMode = crudMode;
            }).orElse(() -> {
                throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), () -> asListHtml());
            });
        });
    }).renderWith(data -> {
        registerRoleTypeItems(data);
    });
}
Also used : Constants(org.codelibs.fess.Constants) LabelTypePager(org.codelibs.fess.app.pager.LabelTypePager) 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) LabelType(org.codelibs.fess.es.config.exentity.LabelType) 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) Execute(org.lastaflute.web.Execute) RenderData(org.lastaflute.web.response.render.RenderData) RoleTypeService(org.codelibs.fess.app.service.RoleTypeService) HtmlResponse(org.lastaflute.web.response.HtmlResponse) PermissionHelper(org.codelibs.fess.helper.PermissionHelper) StringUtil(org.codelibs.core.lang.StringUtil) Execute(org.lastaflute.web.Execute)

Example 14 with PermissionHelper

use of org.codelibs.fess.helper.PermissionHelper 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)

Example 15 with PermissionHelper

use of org.codelibs.fess.helper.PermissionHelper in project fess by codelibs.

the class AdminAccesstokenAction method getAccessToken.

public static OptionalEntity<AccessToken> getAccessToken(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);
        BeanUtil.copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE).exclude(TOKEN, Constants.PERMISSIONS, EXPIRED_TIME).dateConverter(Constants.DEFAULT_DATETIME_FORMAT, EXPIRES));
        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 : BeanUtil(org.codelibs.core.beans.util.BeanUtil) AccessTokenPager(org.codelibs.fess.app.pager.AccessTokenPager) Constants(org.codelibs.fess.Constants) StreamUtil.stream(org.codelibs.core.stream.StreamUtil.stream) AccessTokenService(org.codelibs.fess.app.service.AccessTokenService) 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) RenderDataUtil(org.codelibs.fess.util.RenderDataUtil) StreamUtil.split(org.codelibs.core.stream.StreamUtil.split) CrudMode(org.codelibs.fess.app.web.CrudMode) ComponentUtil(org.codelibs.fess.util.ComponentUtil) FessAdminAction(org.codelibs.fess.app.web.base.FessAdminAction) AccessToken(org.codelibs.fess.es.config.exentity.AccessToken) SystemHelper(org.codelibs.fess.helper.SystemHelper) Execute(org.lastaflute.web.Execute) RenderData(org.lastaflute.web.response.render.RenderData) HtmlResponse(org.lastaflute.web.response.HtmlResponse) SystemHelper(org.codelibs.fess.helper.SystemHelper) PermissionHelper(org.codelibs.fess.helper.PermissionHelper) StringUtil(org.codelibs.core.lang.StringUtil)

Aggregations

Collectors (java.util.stream.Collectors)16 StringUtil (org.codelibs.core.lang.StringUtil)16 StreamUtil.stream (org.codelibs.core.stream.StreamUtil.stream)16 PermissionHelper (org.codelibs.fess.helper.PermissionHelper)16 ComponentUtil (org.codelibs.fess.util.ComponentUtil)16 Resource (javax.annotation.Resource)14 Constants (org.codelibs.fess.Constants)14 StreamUtil.split (org.codelibs.core.stream.StreamUtil.split)13 CrudMode (org.codelibs.fess.app.web.CrudMode)12 Execute (org.lastaflute.web.Execute)12 OptionalEntity (org.dbflute.optional.OptionalEntity)11 OptionalThing (org.dbflute.optional.OptionalThing)11 FessAdminAction (org.codelibs.fess.app.web.base.FessAdminAction)9 SystemHelper (org.codelibs.fess.helper.SystemHelper)9 RenderDataUtil (org.codelibs.fess.util.RenderDataUtil)9 HtmlResponse (org.lastaflute.web.response.HtmlResponse)9 RenderData (org.lastaflute.web.response.render.RenderData)9 ActionRuntime (org.lastaflute.web.ruts.process.ActionRuntime)9 List (java.util.List)8 Stream (java.util.stream.Stream)8