Search in sources :

Example 31 with StringUtil

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

the class FessProp method getLdapAdminGroupObjectClassAttribute.

default Attribute getLdapAdminGroupObjectClassAttribute() {
    final Attribute oc = new BasicAttribute("objectClass");
    split(getLdapAdminGroupObjectClasses(), ",").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 32 with StringUtil

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

the class FessProp method isValidSearchLogPermissions.

default boolean isValidSearchLogPermissions(final String[] permissions) {
    if (permissions == null) {
        return false;
    }
    @SuppressWarnings("unchecked") List<String> validPermissionList = (List<String>) propMap.get(SUGGEST_SEARCH_LOG_PERMISSIONS);
    if (validPermissionList == null) {
        final PermissionHelper permissionHelper = ComponentUtil.getPermissionHelper();
        validPermissionList = split(getSuggestSearchLogPermissions(), ",").get(stream -> stream.map(s -> permissionHelper.encode(s)).filter(StringUtil::isNotBlank).collect(Collectors.toList()));
        propMap.put(SUGGEST_SEARCH_LOG_PERMISSIONS, validPermissionList);
    }
    final List<String> list = validPermissionList;
    return stream(permissions).get(stream -> stream.allMatch(v -> list.contains(v)));
}
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 33 with StringUtil

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

the class GsaConfigParser method endElement.

@Override
public void endElement(final String uri, final String localName, final String qName) throws SAXException {
    if (logger.isDebugEnabled()) {
        logger.debug("End Element: {}", qName);
    }
    if (GOOD_URLS.equalsIgnoreCase(qName)) {
        if (labelType != null) {
            labelType.setIncludedPaths(parseFilterPaths(textBuf.toString(), true, true));
        } else if (GLOBALPARAMS.equalsIgnoreCase(tagQueue.get(tagQueue.size() - 2))) {
            globalParams.put(GOOD_URLS, textBuf.toString());
        }
    } else if (BAD_URLS.equalsIgnoreCase(qName)) {
        if (labelType != null) {
            labelType.setExcludedPaths(parseFilterPaths(textBuf.toString(), true, true));
        } else if (GLOBALPARAMS.equalsIgnoreCase(tagQueue.get(tagQueue.size() - 2))) {
            globalParams.put(BAD_URLS, textBuf.toString());
        }
    } else if (START_URLS.equalsIgnoreCase(qName) && GLOBALPARAMS.equalsIgnoreCase(tagQueue.get(tagQueue.size() - 2))) {
        globalParams.put(START_URLS, textBuf.toString());
    } else if (labelType != null && COLLECTION.equalsIgnoreCase(qName)) {
        labelList.add(labelType);
        labelType = null;
    } else if (GLOBALPARAMS.equalsIgnoreCase(qName)) {
        final Object startUrls = globalParams.get(START_URLS);
        if (startUrls != null) {
            final long now = System.currentTimeMillis();
            final List<String> urlList = split(startUrls.toString(), "\n").get(stream -> stream.map(String::trim).filter(StringUtil::isNotBlank).collect(Collectors.toList()));
            final String webUrls = urlList.stream().filter(s -> Arrays.stream(webProtocols).anyMatch(p -> s.startsWith(p))).collect(Collectors.joining("\n"));
            if (StringUtil.isNotBlank(webUrls)) {
                webConfig = new WebConfig();
                webConfig.setName("Default");
                webConfig.setAvailable(true);
                webConfig.setBoost(1.0f);
                webConfig.setConfigParameter(StringUtil.EMPTY);
                webConfig.setIntervalTime(1000);
                webConfig.setNumOfThread(3);
                webConfig.setSortOrder(1);
                webConfig.setUrls(webUrls);
                webConfig.setIncludedUrls(parseFilterPaths(globalParams.get(GOOD_URLS), true, false));
                webConfig.setIncludedDocUrls(StringUtil.EMPTY);
                webConfig.setExcludedUrls(parseFilterPaths(globalParams.get(BAD_URLS), true, false));
                webConfig.setExcludedDocUrls(StringUtil.EMPTY);
                webConfig.setUserAgent(userAgent);
                webConfig.setPermissions(new String[] { "Rguest" });
                webConfig.setCreatedBy(Constants.SYSTEM_USER);
                webConfig.setCreatedTime(now);
                webConfig.setUpdatedBy(Constants.SYSTEM_USER);
                webConfig.setUpdatedTime(now);
            }
            final String fileUrls = urlList.stream().filter(s -> Arrays.stream(fileProtocols).anyMatch(p -> s.startsWith(p))).collect(Collectors.joining("\n"));
            if (StringUtil.isNotBlank(fileUrls)) {
                fileConfig = new FileConfig();
                fileConfig.setName("Default");
                fileConfig.setAvailable(true);
                fileConfig.setBoost(1.0f);
                fileConfig.setConfigParameter(StringUtil.EMPTY);
                fileConfig.setIntervalTime(0);
                fileConfig.setNumOfThread(5);
                fileConfig.setSortOrder(2);
                fileConfig.setPaths(fileUrls);
                fileConfig.setIncludedPaths(parseFilterPaths(globalParams.get(GOOD_URLS), false, true));
                fileConfig.setIncludedDocPaths(StringUtil.EMPTY);
                fileConfig.setExcludedPaths(parseFilterPaths(globalParams.get(BAD_URLS), false, true));
                fileConfig.setExcludedDocPaths(StringUtil.EMPTY);
                fileConfig.setPermissions(new String[] { "Rguest" });
                fileConfig.setCreatedBy(Constants.SYSTEM_USER);
                fileConfig.setCreatedTime(now);
                fileConfig.setUpdatedBy(Constants.SYSTEM_USER);
                fileConfig.setUpdatedTime(now);
            }
        }
    } else if ("user_agent".equalsIgnoreCase(qName) && GLOBALPARAMS.equalsIgnoreCase(tagQueue.get(tagQueue.size() - 2))) {
        userAgent = textBuf.toString().trim();
    }
    tagQueue.pollLast();
    textBuf.setLength(0);
}
Also used : Arrays(java.util.Arrays) Constants(org.codelibs.fess.Constants) SAXParserFactory(javax.xml.parsers.SAXParserFactory) HashMap(java.util.HashMap) LabelType(org.codelibs.fess.es.config.exentity.LabelType) ArrayList(java.util.ArrayList) StreamUtil.split(org.codelibs.core.stream.StreamUtil.split) GsaConfigException(org.codelibs.fess.exception.GsaConfigException) Map(java.util.Map) SAXParser(javax.xml.parsers.SAXParser) Attributes(org.xml.sax.Attributes) LinkedList(java.util.LinkedList) XMLConstants(javax.xml.XMLConstants) FileConfig(org.codelibs.fess.es.config.exentity.FileConfig) WebConfig(org.codelibs.fess.es.config.exentity.WebConfig) InputSource(org.xml.sax.InputSource) OptionalEntity(org.dbflute.optional.OptionalEntity) StringUtil(org.codelibs.core.lang.StringUtil) Collectors(java.util.stream.Collectors) DefaultHandler(org.xml.sax.helpers.DefaultHandler) List(java.util.List) Logger(org.apache.logging.log4j.Logger) SAXException(org.xml.sax.SAXException) Pattern(java.util.regex.Pattern) LogManager(org.apache.logging.log4j.LogManager) FileConfig(org.codelibs.fess.es.config.exentity.FileConfig) WebConfig(org.codelibs.fess.es.config.exentity.WebConfig) StringUtil(org.codelibs.core.lang.StringUtil)

Example 34 with StringUtil

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

the class FessProp method getLdapAdminUserObjectClassAttribute.

default Attribute getLdapAdminUserObjectClassAttribute() {
    final Attribute oc = new BasicAttribute("objectClass");
    split(getLdapAdminUserObjectClasses(), ",").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 35 with StringUtil

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

the class AbstractDataStore method store.

@Override
public void store(final DataConfig config, final IndexUpdateCallback callback, final Map<String, String> initParamMap) {
    final CrawlingInfoHelper crawlingInfoHelper = ComponentUtil.getCrawlingInfoHelper();
    final SystemHelper systemHelper = ComponentUtil.getSystemHelper();
    final Date documentExpires = crawlingInfoHelper.getDocumentExpires(config);
    final FessConfig fessConfig = ComponentUtil.getFessConfig();
    final Map<String, String> paramEnvMap = systemHelper.getFilteredEnvMap(fessConfig.getCrawlerDataEnvParamKeyPattern());
    final Map<String, String> configParamMap = config.getHandlerParameterMap().entrySet().stream().map(e -> {
        final String key = e.getKey();
        String value = e.getValue();
        for (final Map.Entry<String, String> entry : paramEnvMap.entrySet()) {
            value = value.replace("${" + entry.getKey() + "}", entry.getValue());
        }
        return new Pair<>(key, value);
    }).collect(Collectors.toMap(Pair<String, String>::getFirst, Pair<String, String>::getSecond));
    final Map<String, String> configScriptMap = config.getHandlerScriptMap();
    initParamMap.putAll(configParamMap);
    final Map<String, String> paramMap = initParamMap;
    // default values
    final Map<String, Object> defaultDataMap = new HashMap<>();
    // cid
    final String configId = config.getConfigId();
    if (configId != null) {
        defaultDataMap.put(fessConfig.getIndexFieldConfigId(), configId);
    }
    // expires
    if (documentExpires != null) {
        defaultDataMap.put(fessConfig.getIndexFieldExpires(), documentExpires);
    }
    // segment
    defaultDataMap.put(fessConfig.getIndexFieldSegment(), initParamMap.get(Constants.SESSION_ID));
    // created
    defaultDataMap.put(fessConfig.getIndexFieldCreated(), systemHelper.getCurrentTime());
    // boost
    defaultDataMap.put(fessConfig.getIndexFieldBoost(), config.getBoost().toString());
    // label: labelType
    // role: roleType
    final List<String> roleTypeList = new ArrayList<>();
    stream(config.getPermissions()).of(stream -> stream.forEach(p -> roleTypeList.add(p)));
    defaultDataMap.put(fessConfig.getIndexFieldRole(), roleTypeList);
    // mimetype
    defaultDataMap.put(fessConfig.getIndexFieldMimetype(), mimeType);
    // title
    // content
    // cache
    // digest
    // host
    // site
    // url
    // anchor
    // content_length
    // last_modified
    // id
    // virtual_host
    defaultDataMap.put(fessConfig.getIndexFieldVirtualHost(), stream(config.getVirtualHosts()).get(stream -> stream.filter(StringUtil::isNotBlank).collect(Collectors.toList())));
    storeData(config, callback, new ParamMap<>(paramMap), configScriptMap, defaultDataMap);
}
Also used : DataConfig(org.codelibs.fess.es.config.exentity.DataConfig) ThreadUtil(org.codelibs.core.lang.ThreadUtil) Constants(org.codelibs.fess.Constants) StreamUtil.stream(org.codelibs.core.stream.StreamUtil.stream) Date(java.util.Date) IndexUpdateCallback(org.codelibs.fess.ds.callback.IndexUpdateCallback) StringUtil(org.codelibs.core.lang.StringUtil) Pair(org.codelibs.core.misc.Pair) HashMap(java.util.HashMap) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) List(java.util.List) FessConfig(org.codelibs.fess.mylasta.direction.FessConfig) Logger(org.apache.logging.log4j.Logger) ComponentUtil(org.codelibs.fess.util.ComponentUtil) CrawlingInfoHelper(org.codelibs.fess.helper.CrawlingInfoHelper) SystemHelper(org.codelibs.fess.helper.SystemHelper) Map(java.util.Map) LogManager(org.apache.logging.log4j.LogManager) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) FessConfig(org.codelibs.fess.mylasta.direction.FessConfig) Date(java.util.Date) SystemHelper(org.codelibs.fess.helper.SystemHelper) CrawlingInfoHelper(org.codelibs.fess.helper.CrawlingInfoHelper)

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