Search in sources :

Example 6 with StringUtil

use of org.codelibs.core.lang.StringUtil in project fess by codelibs.

the class AdminLabeltypeAction method getLabelType.

public static OptionalEntity<LabelType> getLabelType(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) Secured(org.codelibs.fess.annotation.Secured) 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) SystemHelper(org.codelibs.fess.helper.SystemHelper) PermissionHelper(org.codelibs.fess.helper.PermissionHelper) StringUtil(org.codelibs.core.lang.StringUtil)

Example 7 with StringUtil

use of org.codelibs.core.lang.StringUtil in project fess by codelibs.

the class AdminFileconfigAction method getFileConfig.

public static OptionalEntity<FileConfig> getFileConfig(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, Constants.VIRTUAL_HOSTS)).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])));
        entity.setVirtualHosts(split(form.virtualHosts, "\n").get(stream -> stream.filter(StringUtil::isNotBlank).distinct().map(String::trim).toArray(n -> new String[n])));
        return entity;
    });
}
Also used : Constants(org.codelibs.fess.Constants) 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) RoleTypeService(org.codelibs.fess.app.service.RoleTypeService) FileConfig(org.codelibs.fess.es.config.exentity.FileConfig) HtmlResponse(org.lastaflute.web.response.HtmlResponse) ConfigType(org.codelibs.fess.es.config.exentity.CrawlingConfig.ConfigType) Secured(org.codelibs.fess.annotation.Secured) 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) FileConfigPager(org.codelibs.fess.app.pager.FileConfigPager) LabelTypeService(org.codelibs.fess.app.service.LabelTypeService) Stream(java.util.stream.Stream) ComponentUtil(org.codelibs.fess.util.ComponentUtil) SystemHelper(org.codelibs.fess.helper.SystemHelper) FileConfigService(org.codelibs.fess.app.service.FileConfigService) Execute(org.lastaflute.web.Execute) SystemHelper(org.codelibs.fess.helper.SystemHelper) PermissionHelper(org.codelibs.fess.helper.PermissionHelper) StringUtil(org.codelibs.core.lang.StringUtil)

Example 8 with StringUtil

use of org.codelibs.core.lang.StringUtil in project fess by codelibs.

the class FessProp method getLdapAdminRoleObjectClassAttribute.

default Attribute getLdapAdminRoleObjectClassAttribute() {
    final Attribute oc = new BasicAttribute("objectClass");
    split(getLdapAdminRoleObjectClasses(), ",").of(stream -> stream.filter(StringUtil::isNotBlank).forEach(s -> oc.add(s.trim())));
    return oc;
}
Also used : BasicAttribute(javax.naming.directory.BasicAttribute) Arrays(java.util.Arrays) Constants(org.codelibs.fess.Constants) SocketAddress(java.net.SocketAddress) Enumeration(java.util.Enumeration) Date(java.util.Date) JobConcurrentExec(org.lastaflute.job.subsidiary.JobConcurrentExec) OptionalThing(org.dbflute.optional.OptionalThing) SortBuilders(org.opensearch.search.sort.SortBuilders) PermissionHelper(org.codelibs.fess.helper.PermissionHelper) JvmUtil(org.codelibs.fess.util.JvmUtil) Attribute(javax.naming.directory.Attribute) StreamUtil.split(org.codelibs.core.stream.StreamUtil.split) Proxy(java.net.Proxy) Locale(java.util.Locale) Map(java.util.Map) Tuple4(org.codelibs.core.misc.Tuple4) Authenticator(java.net.Authenticator) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) Tuple3(org.codelibs.core.misc.Tuple3) InetSocketAddress(java.net.InetSocketAddress) Collectors(java.util.stream.Collectors) List(java.util.List) Stream(java.util.stream.Stream) ComponentUtil(org.codelibs.fess.util.ComponentUtil) Type(java.net.Proxy.Type) Pattern(java.util.regex.Pattern) DoubleTypeValidator(org.lastaflute.web.validation.theme.typed.DoubleTypeValidator) ClassNotFoundRuntimeException(org.codelibs.core.exception.ClassNotFoundRuntimeException) Pair(org.codelibs.core.misc.Pair) HashMap(java.util.HashMap) IntegerTypeValidator(org.lastaflute.web.validation.theme.typed.IntegerTypeValidator) LongTypeValidator(org.lastaflute.web.validation.theme.typed.LongTypeValidator) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) BasicAttribute(javax.naming.directory.BasicAttribute) FessUserBean(org.codelibs.fess.mylasta.action.FessUserBean) SortOrder(org.opensearch.search.sort.SortOrder) PasswordAuthentication(java.net.PasswordAuthentication) PrunedTag(org.codelibs.fess.util.PrunedTag) LaJob(org.lastaflute.job.LaJob) StreamUtil.stream(org.codelibs.core.stream.StreamUtil.stream) FloatTypeValidator(org.lastaflute.web.validation.theme.typed.FloatTypeValidator) StringUtil(org.codelibs.core.lang.StringUtil) RequiredValidator(org.lastaflute.web.validation.RequiredValidator) SortBuilder(org.opensearch.search.sort.SortBuilder) DfTypeUtil(org.dbflute.util.DfTypeUtil) Collections(java.util.Collections) FessFunctions(org.codelibs.fess.taglib.FessFunctions) Attribute(javax.naming.directory.Attribute) BasicAttribute(javax.naming.directory.BasicAttribute) StringUtil(org.codelibs.core.lang.StringUtil)

Example 9 with StringUtil

use of org.codelibs.core.lang.StringUtil in project fess by codelibs.

the class FessProp method getSearchGuestPermissionList.

default List<String> getSearchGuestPermissionList() {
    @SuppressWarnings("unchecked") List<String> list = (List<String>) propMap.get(SEARCH_GUEST_PERMISSION_LIST);
    if (list == null) {
        final PermissionHelper permissionHelper = ComponentUtil.getPermissionHelper();
        list = split(getRoleSearchGuestPermissions(), ",").get(stream -> stream.map(s -> permissionHelper.encode(s)).filter(StringUtil::isNotBlank).collect(Collectors.toList()));
        list.add(getRoleSearchUserPrefix() + Constants.GUEST_USER);
        propMap.put(SEARCH_GUEST_PERMISSION_LIST, list);
    }
    return list;
}
Also used : Arrays(java.util.Arrays) Constants(org.codelibs.fess.Constants) SocketAddress(java.net.SocketAddress) Enumeration(java.util.Enumeration) Date(java.util.Date) JobConcurrentExec(org.lastaflute.job.subsidiary.JobConcurrentExec) OptionalThing(org.dbflute.optional.OptionalThing) SortBuilders(org.opensearch.search.sort.SortBuilders) PermissionHelper(org.codelibs.fess.helper.PermissionHelper) JvmUtil(org.codelibs.fess.util.JvmUtil) Attribute(javax.naming.directory.Attribute) StreamUtil.split(org.codelibs.core.stream.StreamUtil.split) Proxy(java.net.Proxy) Locale(java.util.Locale) Map(java.util.Map) Tuple4(org.codelibs.core.misc.Tuple4) Authenticator(java.net.Authenticator) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) Tuple3(org.codelibs.core.misc.Tuple3) InetSocketAddress(java.net.InetSocketAddress) Collectors(java.util.stream.Collectors) List(java.util.List) Stream(java.util.stream.Stream) ComponentUtil(org.codelibs.fess.util.ComponentUtil) Type(java.net.Proxy.Type) Pattern(java.util.regex.Pattern) DoubleTypeValidator(org.lastaflute.web.validation.theme.typed.DoubleTypeValidator) ClassNotFoundRuntimeException(org.codelibs.core.exception.ClassNotFoundRuntimeException) Pair(org.codelibs.core.misc.Pair) HashMap(java.util.HashMap) IntegerTypeValidator(org.lastaflute.web.validation.theme.typed.IntegerTypeValidator) LongTypeValidator(org.lastaflute.web.validation.theme.typed.LongTypeValidator) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) BasicAttribute(javax.naming.directory.BasicAttribute) FessUserBean(org.codelibs.fess.mylasta.action.FessUserBean) SortOrder(org.opensearch.search.sort.SortOrder) PasswordAuthentication(java.net.PasswordAuthentication) PrunedTag(org.codelibs.fess.util.PrunedTag) LaJob(org.lastaflute.job.LaJob) StreamUtil.stream(org.codelibs.core.stream.StreamUtil.stream) FloatTypeValidator(org.lastaflute.web.validation.theme.typed.FloatTypeValidator) StringUtil(org.codelibs.core.lang.StringUtil) RequiredValidator(org.lastaflute.web.validation.RequiredValidator) SortBuilder(org.opensearch.search.sort.SortBuilder) DfTypeUtil(org.dbflute.util.DfTypeUtil) Collections(java.util.Collections) FessFunctions(org.codelibs.fess.taglib.FessFunctions) PermissionHelper(org.codelibs.fess.helper.PermissionHelper) List(java.util.List) ArrayList(java.util.ArrayList)

Example 10 with StringUtil

use of org.codelibs.core.lang.StringUtil in project fess by codelibs.

the class ElevateWordService method exportCsv.

public void exportCsv(final Writer writer) {
    final PermissionHelper permissionHelper = ComponentUtil.getPermissionHelper();
    final CsvConfig cfg = new CsvConfig(',', '"', '"');
    cfg.setEscapeDisabled(false);
    cfg.setQuoteDisabled(false);
    @SuppressWarnings("resource") final CsvWriter csvWriter = new CsvWriter(writer, cfg);
    try {
        final List<String> list = new ArrayList<>();
        list.add("SuggestWord");
        list.add("Reading");
        list.add("Permissions");
        list.add("Labels");
        list.add("Boost");
        csvWriter.writeValues(list);
        elevateWordBhv.selectCursor(cb -> cb.query().matchAll(), new EntityRowHandler<ElevateWord>() {

            @Override
            public void handle(final ElevateWord entity) {
                final List<String> list = new ArrayList<>();
                final String permissions = stream(entity.getPermissions()).get(stream -> stream.map(s -> permissionHelper.decode(s)).filter(StringUtil::isNotBlank).distinct().collect(Collectors.joining(",")));
                final String labels = elevateWordToLabelBhv.selectList(cb -> cb.query().setElevateWordId_Equal(entity.getId())).stream().map(e -> labelTypeBhv.selectByPK(e.getLabelTypeId()).map(LabelType::getValue).filter(StringUtil::isNotBlank).orElse(null)).distinct().sorted().collect(Collectors.joining(","));
                addToList(list, entity.getSuggestWord());
                addToList(list, entity.getReading());
                addToList(list, permissions);
                addToList(list, labels);
                addToList(list, entity.getBoost());
                try {
                    csvWriter.writeValues(list);
                } catch (final IOException e) {
                    logger.warn("Failed to write a sugget elevate word: {}", entity, e);
                }
            }

            private void addToList(final List<String> list, final Object value) {
                if (value == null) {
                    list.add(StringUtil.EMPTY);
                } else {
                    list.add(value.toString());
                }
            }
        });
        csvWriter.flush();
    } catch (final IOException e) {
        logger.warn("Failed to write a sugget elevate word.", e);
    }
}
Also used : BeanUtil(org.codelibs.core.beans.util.BeanUtil) EntityRowHandler(org.dbflute.bhv.readable.EntityRowHandler) Constants(org.codelibs.fess.Constants) ElevateWordPager(org.codelibs.fess.app.pager.ElevateWordPager) SearchEngineClient(org.codelibs.fess.es.client.SearchEngineClient) PermissionHelper(org.codelibs.fess.helper.PermissionHelper) LabelType(org.codelibs.fess.es.config.exentity.LabelType) ArrayList(java.util.ArrayList) FessConfig(org.codelibs.fess.mylasta.direction.FessConfig) StreamUtil.split(org.codelibs.core.stream.StreamUtil.split) PagingResultBean(org.dbflute.cbean.result.PagingResultBean) LabelTypeBhv(org.codelibs.fess.es.config.exbhv.LabelTypeBhv) ElevateWordBhv(org.codelibs.fess.es.config.exbhv.ElevateWordBhv) ElevateWordCB(org.codelibs.fess.es.config.cbean.ElevateWordCB) ElevateWordToLabel(org.codelibs.fess.es.config.exentity.ElevateWordToLabel) StreamUtil.stream(org.codelibs.core.stream.StreamUtil.stream) OptionalEntity(org.dbflute.optional.OptionalEntity) Resource(javax.annotation.Resource) StringUtil(org.codelibs.core.lang.StringUtil) CsvWriter(com.orangesignal.csv.CsvWriter) IOException(java.io.IOException) Reader(java.io.Reader) Collectors(java.util.stream.Collectors) CsvConfig(com.orangesignal.csv.CsvConfig) List(java.util.List) Logger(org.apache.logging.log4j.Logger) ComponentUtil(org.codelibs.fess.util.ComponentUtil) ElevateWordToLabelBhv(org.codelibs.fess.es.config.exbhv.ElevateWordToLabelBhv) Writer(java.io.Writer) ElevateWord(org.codelibs.fess.es.config.exentity.ElevateWord) LogManager(org.apache.logging.log4j.LogManager) CsvReader(com.orangesignal.csv.CsvReader) CsvWriter(com.orangesignal.csv.CsvWriter) ArrayList(java.util.ArrayList) IOException(java.io.IOException) ElevateWord(org.codelibs.fess.es.config.exentity.ElevateWord) PermissionHelper(org.codelibs.fess.helper.PermissionHelper) ArrayList(java.util.ArrayList) List(java.util.List) CsvConfig(com.orangesignal.csv.CsvConfig) StringUtil(org.codelibs.core.lang.StringUtil)

Aggregations

StringUtil (org.codelibs.core.lang.StringUtil)46 ComponentUtil (org.codelibs.fess.util.ComponentUtil)41 Constants (org.codelibs.fess.Constants)40 StreamUtil.stream (org.codelibs.core.stream.StreamUtil.stream)38 Collectors (java.util.stream.Collectors)35 List (java.util.List)30 StreamUtil.split (org.codelibs.core.stream.StreamUtil.split)27 PermissionHelper (org.codelibs.fess.helper.PermissionHelper)26 ArrayList (java.util.ArrayList)25 Resource (javax.annotation.Resource)20 CrudMode (org.codelibs.fess.app.web.CrudMode)19 FessConfig (org.codelibs.fess.mylasta.direction.FessConfig)19 OptionalThing (org.dbflute.optional.OptionalThing)19 Execute (org.lastaflute.web.Execute)19 Map (java.util.Map)17 Stream (java.util.stream.Stream)17 SystemHelper (org.codelibs.fess.helper.SystemHelper)17 OptionalEntity (org.dbflute.optional.OptionalEntity)17 LogManager (org.apache.logging.log4j.LogManager)16 Logger (org.apache.logging.log4j.Logger)16