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;
}
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)));
}
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);
}
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;
}
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);
}
Aggregations