From f2a0f043a907ba18a3706415373b5926dc759ddb Mon Sep 17 00:00:00 2001 From: Shinsuke Sugaya Date: Sat, 10 Sep 2016 12:53:39 +0900 Subject: [PATCH] fix #672 replace with split --- .../fess/app/service/ElevateWordService.java | 3 +- .../dataconfig/AdminDataconfigAction.java | 3 +- .../seunjeon/AdminDictSeunjeonAction.java | 4 +- .../elevateword/AdminElevatewordAction.java | 3 +- .../fileconfig/AdminFileconfigAction.java | 3 +- .../admin/labeltype/AdminLabeltypeAction.java | 3 +- .../web/admin/upgrade/AdminUpgradeAction.java | 7 +- .../admin/webconfig/AdminWebconfigAction.java | 3 +- .../fess/ds/impl/EsDataStoreImpl.java | 4 +- .../java/org/codelibs/fess/job/CrawlJob.java | 3 +- .../fess/mylasta/direction/FessProp.java | 97 +++++++++---------- 11 files changed, 67 insertions(+), 66 deletions(-) diff --git a/src/main/java/org/codelibs/fess/app/service/ElevateWordService.java b/src/main/java/org/codelibs/fess/app/service/ElevateWordService.java index e67d44e771..db64be5f3c 100644 --- a/src/main/java/org/codelibs/fess/app/service/ElevateWordService.java +++ b/src/main/java/org/codelibs/fess/app/service/ElevateWordService.java @@ -15,6 +15,7 @@ */ package org.codelibs.fess.app.service; +import static org.codelibs.core.stream.StreamUtil.split; import static org.codelibs.core.stream.StreamUtil.stream; import java.io.IOException; @@ -197,7 +198,7 @@ public void importCsv(final Reader reader) { } try { final String[] permissions = - stream(getValue(list, 2).split(",")).get( + split(getValue(list, 2), ",").get( stream -> stream.map(permissionHelper::encode).filter(StringUtil::isNotBlank).distinct() .toArray(n -> new String[n])); final String label = getValue(list, 3); diff --git a/src/main/java/org/codelibs/fess/app/web/admin/dataconfig/AdminDataconfigAction.java b/src/main/java/org/codelibs/fess/app/web/admin/dataconfig/AdminDataconfigAction.java index 7a25361a13..26081abdfb 100644 --- a/src/main/java/org/codelibs/fess/app/web/admin/dataconfig/AdminDataconfigAction.java +++ b/src/main/java/org/codelibs/fess/app/web/admin/dataconfig/AdminDataconfigAction.java @@ -15,6 +15,7 @@ */ package org.codelibs.fess.app.web.admin.dataconfig; +import static org.codelibs.core.stream.StreamUtil.split; import static org.codelibs.core.stream.StreamUtil.stream; import java.util.ArrayList; @@ -298,7 +299,7 @@ protected OptionalEntity getDataConfig(final CreateForm form) { 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(stream(form.permissions.split("\n")).get( + 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; diff --git a/src/main/java/org/codelibs/fess/app/web/admin/dict/seunjeon/AdminDictSeunjeonAction.java b/src/main/java/org/codelibs/fess/app/web/admin/dict/seunjeon/AdminDictSeunjeonAction.java index 692c25c4af..de55220350 100644 --- a/src/main/java/org/codelibs/fess/app/web/admin/dict/seunjeon/AdminDictSeunjeonAction.java +++ b/src/main/java/org/codelibs/fess/app/web/admin/dict/seunjeon/AdminDictSeunjeonAction.java @@ -15,7 +15,7 @@ */ package org.codelibs.fess.app.web.admin.dict.seunjeon; -import static org.codelibs.core.stream.StreamUtil.stream; +import static org.codelibs.core.stream.StreamUtil.split; import java.io.File; import java.io.IOException; @@ -359,7 +359,7 @@ private String[] splitLine(final String value) { if (StringUtil.isBlank(value)) { return StringUtil.EMPTY_STRINGS; } - return stream(value.split(",")).get(stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).toArray(n -> new String[n])); + return split(value, ",").get(stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).toArray(n -> new String[n])); } // =================================================================================== diff --git a/src/main/java/org/codelibs/fess/app/web/admin/elevateword/AdminElevatewordAction.java b/src/main/java/org/codelibs/fess/app/web/admin/elevateword/AdminElevatewordAction.java index 0ff2b088e0..c7c889855d 100644 --- a/src/main/java/org/codelibs/fess/app/web/admin/elevateword/AdminElevatewordAction.java +++ b/src/main/java/org/codelibs/fess/app/web/admin/elevateword/AdminElevatewordAction.java @@ -15,6 +15,7 @@ */ package org.codelibs.fess.app.web.admin.elevateword; +import static org.codelibs.core.stream.StreamUtil.split; import static org.codelibs.core.stream.StreamUtil.stream; import java.io.BufferedReader; @@ -362,7 +363,7 @@ protected OptionalEntity getElevateWord(final CreateForm form) { 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(stream(form.permissions.split("\n")).get( + entity.setPermissions(split(form.permissions, "\n").get( stream -> stream.map(permissionHelper::encode).filter(StringUtil::isNotBlank).distinct() .toArray(n -> new String[n]))); return entity; diff --git a/src/main/java/org/codelibs/fess/app/web/admin/fileconfig/AdminFileconfigAction.java b/src/main/java/org/codelibs/fess/app/web/admin/fileconfig/AdminFileconfigAction.java index b1f62ef915..9d7b0c8754 100644 --- a/src/main/java/org/codelibs/fess/app/web/admin/fileconfig/AdminFileconfigAction.java +++ b/src/main/java/org/codelibs/fess/app/web/admin/fileconfig/AdminFileconfigAction.java @@ -15,6 +15,7 @@ */ package org.codelibs.fess.app.web.admin.fileconfig; +import static org.codelibs.core.stream.StreamUtil.split; import static org.codelibs.core.stream.StreamUtil.stream; import java.util.stream.Collectors; @@ -290,7 +291,7 @@ protected OptionalEntity getFileConfig(final CreateForm form) { 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(stream(form.permissions.split("\n")).get( + 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; diff --git a/src/main/java/org/codelibs/fess/app/web/admin/labeltype/AdminLabeltypeAction.java b/src/main/java/org/codelibs/fess/app/web/admin/labeltype/AdminLabeltypeAction.java index 12c65d09dc..af168e8c1e 100644 --- a/src/main/java/org/codelibs/fess/app/web/admin/labeltype/AdminLabeltypeAction.java +++ b/src/main/java/org/codelibs/fess/app/web/admin/labeltype/AdminLabeltypeAction.java @@ -15,6 +15,7 @@ */ package org.codelibs.fess.app.web.admin.labeltype; +import static org.codelibs.core.stream.StreamUtil.split; import static org.codelibs.core.stream.StreamUtil.stream; import java.util.stream.Collectors; @@ -296,7 +297,7 @@ protected OptionalEntity getLabelType(final CreateForm form) { 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(stream(form.permissions.split("\n")).get( + 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; diff --git a/src/main/java/org/codelibs/fess/app/web/admin/upgrade/AdminUpgradeAction.java b/src/main/java/org/codelibs/fess/app/web/admin/upgrade/AdminUpgradeAction.java index fa035b436a..0fc6dc1bb8 100644 --- a/src/main/java/org/codelibs/fess/app/web/admin/upgrade/AdminUpgradeAction.java +++ b/src/main/java/org/codelibs/fess/app/web/admin/upgrade/AdminUpgradeAction.java @@ -15,6 +15,7 @@ */ package org.codelibs.fess.app.web.admin.upgrade; +import static org.codelibs.core.stream.StreamUtil.split; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import java.io.File; @@ -31,7 +32,6 @@ import org.codelibs.core.io.FileUtil; import org.codelibs.core.io.ResourceUtil; import org.codelibs.core.lang.StringUtil; -import org.codelibs.core.stream.StreamUtil; import org.codelibs.elasticsearch.runner.net.Curl; import org.codelibs.elasticsearch.runner.net.CurlResponse; import org.codelibs.fess.app.service.ScheduledJobService; @@ -941,9 +941,8 @@ private void upgradeFrom10_0() { .filter(e -> StringUtil.isNotBlank(e.getTargetRole())) .map(e -> { final String[] permissions = - StreamUtil - .stream(e.getTargetRole().split(",")) - .get(stream -> stream.filter(StringUtil::isNotBlank).map( + split(e.getTargetRole(), ",").get( + stream -> stream.filter(StringUtil::isNotBlank).map( s -> fessConfig.getRoleSearchRolePrefix() + s)).toArray(n -> new String[n]); e.setPermissions(permissions); e.setTargetRole(null); diff --git a/src/main/java/org/codelibs/fess/app/web/admin/webconfig/AdminWebconfigAction.java b/src/main/java/org/codelibs/fess/app/web/admin/webconfig/AdminWebconfigAction.java index fd7ac4fa8b..49dc828fef 100644 --- a/src/main/java/org/codelibs/fess/app/web/admin/webconfig/AdminWebconfigAction.java +++ b/src/main/java/org/codelibs/fess/app/web/admin/webconfig/AdminWebconfigAction.java @@ -15,6 +15,7 @@ */ package org.codelibs.fess.app.web.admin.webconfig; +import static org.codelibs.core.stream.StreamUtil.split; import static org.codelibs.core.stream.StreamUtil.stream; import java.util.stream.Collectors; @@ -297,7 +298,7 @@ protected OptionalEntity getWebConfig(final CreateForm form) { 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(stream(form.permissions.split("\n")).get( + 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; diff --git a/src/main/java/org/codelibs/fess/ds/impl/EsDataStoreImpl.java b/src/main/java/org/codelibs/fess/ds/impl/EsDataStoreImpl.java index 479945f1f1..8adb30db5b 100644 --- a/src/main/java/org/codelibs/fess/ds/impl/EsDataStoreImpl.java +++ b/src/main/java/org/codelibs/fess/ds/impl/EsDataStoreImpl.java @@ -15,7 +15,7 @@ */ package org.codelibs.fess.ds.impl; -import static org.codelibs.core.stream.StreamUtil.stream; +import static org.codelibs.core.stream.StreamUtil.split; import java.net.InetAddress; import java.util.HashMap; @@ -90,7 +90,7 @@ protected void storeData(final DataConfig dataConfig, final IndexUpdateCallback Collectors.toMap(e -> e.getKey().replaceFirst("^settings\\.", StringUtil.EMPTY), e -> e.getValue()))) .build(); logger.info("Connecting to " + hostsStr + " with [" + settings.toDelimitedString(',') + "]"); - final InetSocketTransportAddress[] addresses = stream(hostsStr.split(",")).get(stream -> stream.map(h -> { + final InetSocketTransportAddress[] addresses = split(hostsStr, ",").get(stream -> stream.map(h -> { final String[] values = h.trim().split(":"); try { if (values.length == 1) { diff --git a/src/main/java/org/codelibs/fess/job/CrawlJob.java b/src/main/java/org/codelibs/fess/job/CrawlJob.java index ed290beccf..ee60d7a57c 100644 --- a/src/main/java/org/codelibs/fess/job/CrawlJob.java +++ b/src/main/java/org/codelibs/fess/job/CrawlJob.java @@ -15,6 +15,7 @@ */ package org.codelibs.fess.job; +import static org.codelibs.core.stream.StreamUtil.split; import static org.codelibs.core.stream.StreamUtil.stream; import java.io.File; @@ -330,7 +331,7 @@ protected void executeCrawler() { } if (StringUtil.isNotBlank(jvmOptions)) { - stream(jvmOptions.split(" ")).of(stream -> stream.filter(StringUtil::isNotBlank).forEach(s -> cmdList.add(s))); + split(jvmOptions, " ").of(stream -> stream.filter(StringUtil::isNotBlank).forEach(s -> cmdList.add(s))); } cmdList.add(Crawler.class.getCanonicalName()); diff --git a/src/main/java/org/codelibs/fess/mylasta/direction/FessProp.java b/src/main/java/org/codelibs/fess/mylasta/direction/FessProp.java index 2a81f76fe6..2377cbff24 100644 --- a/src/main/java/org/codelibs/fess/mylasta/direction/FessProp.java +++ b/src/main/java/org/codelibs/fess/mylasta/direction/FessProp.java @@ -15,6 +15,7 @@ */ package org.codelibs.fess.mylasta.direction; +import static org.codelibs.core.stream.StreamUtil.split; import static org.codelibs.core.stream.StreamUtil.stream; import java.util.Collections; @@ -164,7 +165,7 @@ public default String[] getDefaultSortValues(final OptionalThing u list = Collections.emptyList(); } else { final Set keySet = new HashSet<>(); - list = stream(value.split("\n")).get(stream -> stream.filter(StringUtil::isNotBlank).map(s -> { + list = split(value, "\n").get(stream -> stream.filter(StringUtil::isNotBlank).map(s -> { final String[] pair = s.split("="); if (pair.length == 1) { return new Pair<>(StringUtil.EMPTY, pair[0].trim()); @@ -215,7 +216,7 @@ public default String[] getDefaultLabelValues(final OptionalThing map = Collections.emptyMap(); } else { final Set keySet = new HashSet<>(); - map = stream(value.split("\n")).get(stream -> (Map) stream.filter(StringUtil::isNotBlank).map(s -> { + map = split(value, "\n").get(stream -> (Map) stream.filter(StringUtil::isNotBlank).map(s -> { final String[] pair = s.split("="); if (pair.length == 1) { return new Pair<>(StringUtil.EMPTY, pair[0].trim()); @@ -605,7 +606,7 @@ public default boolean isSystemJobId(final String id) { if (StringUtil.isBlank(getJobSystemJobIds())) { return false; } - return stream(getJobSystemJobIds().split(",")).get(stream -> stream.anyMatch(s -> s.equals(id))); + return split(getJobSystemJobIds(), ",").get(stream -> stream.anyMatch(s -> s.equals(id))); } String getSmbAvailableSidTypes(); @@ -615,13 +616,13 @@ public default boolean isAvailableSmbSidType(final int sidType) { return false; } final String value = Integer.toString(sidType); - return stream(getSmbAvailableSidTypes().split(",")).get(stream -> stream.anyMatch(s -> s.equals(value))); + return split(getSmbAvailableSidTypes(), ",").get(stream -> stream.anyMatch(s -> s.equals(value))); } String getSupportedLanguages(); public default String[] getSupportedLanguagesAsArray() { - return stream(getSupportedLanguages().split(",")).get(stream -> stream.filter(StringUtil::isNotBlank).toArray(n -> new String[n])); + return split(getSupportedLanguages(), ",").get(stream -> stream.filter(StringUtil::isNotBlank).toArray(n -> new String[n])); } String getOnlineHelpSupportedLangs(); @@ -630,28 +631,27 @@ public default boolean isOnlineHelpSupportedLang(final String lang) { if (StringUtil.isBlank(getOnlineHelpSupportedLangs())) { return false; } - return stream(getOnlineHelpSupportedLangs().split(",")).get( - stream -> stream.filter(StringUtil::isNotBlank).anyMatch(s -> s.equals(lang))); + return split(getOnlineHelpSupportedLangs(), ",").get(stream -> stream.filter(StringUtil::isNotBlank).anyMatch(s -> s.equals(lang))); } String getSupportedUploadedJsExtentions(); public default String[] getSupportedUploadedJsExtentionsAsArray() { - return stream(getSupportedUploadedJsExtentions().split(",")).get( + return split(getSupportedUploadedJsExtentions(), ",").get( stream -> stream.filter(StringUtil::isNotBlank).toArray(n -> new String[n])); } String getSupportedUploadedCssExtentions(); public default String[] getSupportedUploadedCssExtentionsAsArray() { - return stream(getSupportedUploadedCssExtentions().split(",")).get( + return split(getSupportedUploadedCssExtentions(), ",").get( stream -> stream.filter(StringUtil::isNotBlank).toArray(n -> new String[n])); } String getSupportedUploadedMediaExtentions(); public default String[] getSupportedUploadedMediaExtentionsAsArray() { - return stream(getSupportedUploadedMediaExtentions().split(",")).get( + return split(getSupportedUploadedMediaExtentions(), ",").get( stream -> stream.filter(StringUtil::isNotBlank).toArray(n -> new String[n])); } @@ -696,7 +696,7 @@ public default boolean isCrawlerMetadataContentIncluded(final String name) { Pattern[] patterns = (Pattern[]) propMap.get(CRAWLER_METADATA_CONTENT_EXCLUDES); if (patterns == null) { patterns = - stream(getCrawlerMetadataContentExcludes().split(",")).get( + split(getCrawlerMetadataContentExcludes(), ",").get( stream -> stream.filter(StringUtil::isNotBlank).map(v -> Pattern.compile(v)).toArray(n -> new Pattern[n])); propMap.put(CRAWLER_METADATA_CONTENT_EXCLUDES, patterns); } @@ -710,7 +710,7 @@ public default Pair getCrawlerMetadataNameMapping(final String n Map> params = (Map>) propMap.get(CRAWLER_METADATA_NAME_MAPPING); if (params == null) { params = - stream(getCrawlerMetadataNameMapping().split("\n")).get( + split(getCrawlerMetadataNameMapping(), "\n").get( stream -> (Map>) stream.filter(StringUtil::isNotBlank).map(v -> { final String[] values = v.split("="); if (values.length == 2) { @@ -731,22 +731,20 @@ public default Pair getCrawlerMetadataNameMapping(final String n String getSuggestPopularWordFields(); public default String[] getSuggestPopularWordFieldsAsArray() { - return stream(getSuggestPopularWordFields().split("\n")).get( - stream -> stream.filter(StringUtil::isNotBlank).toArray(n -> new String[n])); + return split(getSuggestPopularWordFields(), "\n").get(stream -> stream.filter(StringUtil::isNotBlank).toArray(n -> new String[n])); } String getSuggestPopularWordTags(); public default String[] getSuggestPopularWordTagsAsArray() { - return stream(getSuggestPopularWordTags().split("\n")).get( - stream -> stream.filter(StringUtil::isNotBlank).toArray(n -> new String[n])); + return split(getSuggestPopularWordTags(), "\n").get(stream -> stream.filter(StringUtil::isNotBlank).toArray(n -> new String[n])); } String getSuggestPopularWordExcludes(); public default String[] getSuggestPopularWordExcludesAsArray() { - return stream(getSuggestPopularWordExcludes().split("\n")).get( - stream -> stream.filter(StringUtil::isNotBlank).toArray(n -> new String[n])); + return split(getSuggestPopularWordExcludes(), "\n") + .get(stream -> stream.filter(StringUtil::isNotBlank).toArray(n -> new String[n])); } String getQueryReplaceTermWithPrefixQuery(); @@ -763,7 +761,7 @@ public default String[] getQueryLanguages(final Enumeration locales, fin if (StringUtil.isNotBlank(getQueryDefaultLanguages())) { String[] langs = (String[]) propMap.get("queryDefaultLanguages"); if (langs == null) { - langs = stream(getQueryDefaultLanguages().split(",")).get(stream -> stream.map(s -> s.trim()).toArray(n -> new String[n])); + langs = split(getQueryDefaultLanguages(), ",").get(stream -> stream.map(s -> s.trim()).toArray(n -> new String[n])); propMap.put("queryDefaultLanguages", langs); } @@ -815,7 +813,7 @@ public default String[] getQueryLanguages(final Enumeration locales, fin String getSupportedUploadedFiles(); public default boolean isSupportedUploadedFile(final String name) { - return stream(getSuggestPopularWordExcludes().split(",")).get( + return split(getSuggestPopularWordExcludes(), ",").get( stream -> stream.filter(StringUtil::isNotBlank).anyMatch(s -> s.equals(name))); } @@ -823,8 +821,7 @@ public default boolean isSupportedUploadedFile(final String name) { public default Attribute getLdapAdminUserObjectClassAttribute() { final Attribute oc = new BasicAttribute("objectClass"); - stream(getLdapAdminUserObjectClasses().split(",")).of( - stream -> stream.filter(StringUtil::isNotBlank).forEach(s -> oc.add(s.trim()))); + split(getLdapAdminUserObjectClasses(), ",").of(stream -> stream.filter(StringUtil::isNotBlank).forEach(s -> oc.add(s.trim()))); return oc; } @@ -849,8 +846,7 @@ public default String getLdapAdminUserSecurityPrincipal(final String name) { public default Attribute getLdapAdminRoleObjectClassAttribute() { final Attribute oc = new BasicAttribute("objectClass"); - stream(getLdapAdminRoleObjectClasses().split(",")).of( - stream -> stream.filter(StringUtil::isNotBlank).forEach(s -> oc.add(s.trim()))); + split(getLdapAdminRoleObjectClasses(), ",").of(stream -> stream.filter(StringUtil::isNotBlank).forEach(s -> oc.add(s.trim()))); return oc; } @@ -875,8 +871,7 @@ public default String getLdapAdminRoleSecurityPrincipal(final String name) { public default Attribute getLdapAdminGroupObjectClassAttribute() { final Attribute oc = new BasicAttribute("objectClass"); - stream(getLdapAdminGroupObjectClasses().split(",")).of( - stream -> stream.filter(StringUtil::isNotBlank).forEach(s -> oc.add(s.trim()))); + split(getLdapAdminGroupObjectClasses(), ",").of(stream -> stream.filter(StringUtil::isNotBlank).forEach(s -> oc.add(s.trim()))); return oc; } @@ -900,7 +895,7 @@ public default String getLdapAdminGroupSecurityPrincipal(final String name) { String getAuthenticationAdminUsers(); public default boolean isAdminUser(final String username) { - return stream(getAuthenticationAdminUsers().split(",")).get(stream -> stream.anyMatch(s -> s.equals(username))); + return split(getAuthenticationAdminUsers(), ",").get(stream -> stream.anyMatch(s -> s.equals(username))); } boolean isLdapAdminEnabled(); @@ -915,7 +910,7 @@ public default boolean isLdapAdminEnabled(final String username) { String getCrawlerWebProtocols(); public default String[] getCrawlerWebProtocolsAsArray() { - return stream(getCrawlerWebProtocols().split(",")).get( + return split(getCrawlerWebProtocols(), ",").get( stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim() + ":").toArray(n -> new String[n])); } @@ -926,7 +921,7 @@ public default boolean isValidCrawlerWebProtocol(final String url) { String getCrawlerFileProtocols(); public default String[] getCrawlerFileProtocolsAsArray() { - return stream(getCrawlerFileProtocols().split(",")).get( + return split(getCrawlerFileProtocols(), ",").get( stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim() + ":").toArray(n -> new String[n])); } @@ -957,7 +952,7 @@ public default void processSearchPreference(final SearchRequestBuilder searchReq public default String[] getSearchDefaultPermissionsAsArray() { final PermissionHelper permissionHelper = ComponentUtil.getPermissionHelper(); - return stream(getRoleSearchDefaultPermissions().split(",")) + return split(getRoleSearchDefaultPermissions(), ",") .get(stream -> stream.map(p -> permissionHelper.encode(p)).filter(StringUtil::isNotBlank).distinct() .toArray(n -> new String[n])); } @@ -966,20 +961,20 @@ public default String[] getSearchDefaultPermissionsAsArray() { public default String[] getSearchDefaultDisplayEncodedPermissions() { final PermissionHelper permissionHelper = ComponentUtil.getPermissionHelper(); - return stream(getRoleSearchDefaultDisplayPermissions().split(",")) + return split(getRoleSearchDefaultDisplayPermissions(), ",") .get(stream -> stream.map(p -> permissionHelper.encode(p)).filter(StringUtil::isNotBlank).distinct() .toArray(n -> new String[n])); } public default String getSearchDefaultDisplayPermission() { - return stream(getRoleSearchDefaultDisplayPermissions().split(",")).get( + return split(getRoleSearchDefaultDisplayPermissions(), ",").get( stream -> stream.filter(StringUtil::isNotBlank).distinct().collect(Collectors.joining("\n"))); } String getQueryGeoFields(); public default String[] getQueryGeoFieldsAsArray() { - return stream(getQueryGeoFields().split(",")).get( + return split(getQueryGeoFields(), ",").get( stream -> stream.map(s -> s.trim()).filter(StringUtil::isNotBlank).toArray(n -> new String[n])); } @@ -994,7 +989,7 @@ public default boolean isValidSearchLogPermissions(final String[] permissions) { if (validPermissionList == null) { final PermissionHelper permissionHelper = ComponentUtil.getPermissionHelper(); validPermissionList = - stream(getSuggestSearchLogPermissions().split(",")).get( + split(getSuggestSearchLogPermissions(), ",").get( stream -> stream.map(s -> permissionHelper.encode(s)).filter(StringUtil::isNotBlank) .collect(Collectors.toList())); propMap.put(SUGGEST_SEARCH_LOG_PERMISSIONS, validPermissionList); @@ -1013,7 +1008,7 @@ public default List getSearchGuestPermissionList() { if (list == null) { final PermissionHelper permissionHelper = ComponentUtil.getPermissionHelper(); list = - stream(getRoleSearchGuestPermissions().split(",")).get( + split(getRoleSearchGuestPermissions(), ",").get( stream -> stream.map(s -> permissionHelper.encode(s)).filter(StringUtil::isNotBlank) .collect(Collectors.toList())); list.add(getRoleSearchUserPrefix() + Constants.GUEST_USER); @@ -1031,7 +1026,7 @@ public default String[] getOicDefaultGroupsAsArray() { array = StringUtil.EMPTY_STRINGS; } else { array = - stream(getOicDefaultGroups().split(",")).get( + split(getOicDefaultGroups(), ",").get( stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).toArray(n -> new String[n])); } propMap.put(OIC_DEFAULT_GROUPS, array); @@ -1048,7 +1043,7 @@ public default String[] getOicDefaultRolesAsArray() { array = StringUtil.EMPTY_STRINGS; } else { array = - stream(getOicDefaultRoles().split(",")).get( + split(getOicDefaultRoles(), ",").get( stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).toArray(n -> new String[n])); } propMap.put(OIC_DEFAULT_ROLES, array); @@ -1063,7 +1058,7 @@ public default Set getIndexAdminArrayFieldSet() { Set fieldSet = (Set) propMap.get(INDEX_ADMIN_ARRAY_FIELD_SET); if (fieldSet == null) { fieldSet = - stream(getIndexAdminArrayFields().split(",")).get( + split(getIndexAdminArrayFields(), ",").get( stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).collect(Collectors.toSet())); propMap.put(INDEX_ADMIN_ARRAY_FIELD_SET, fieldSet); } @@ -1076,7 +1071,7 @@ public default boolean validateIndexArrayFields(final Map source public default List invalidIndexArrayFields(final Map source) { // TODO always returns empty list - return stream(getIndexAdminArrayFields().split(",")).get( + return split(getIndexAdminArrayFields(), ",").get( stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).filter(s -> isNonEmptyValue(source.get(s))) .filter(s -> false) // TODO .collect(Collectors.toList())); @@ -1089,7 +1084,7 @@ public default Set getIndexAdminDateFieldSet() { Set fieldSet = (Set) propMap.get(INDEX_ADMIN_DATE_FIELD_SET); if (fieldSet == null) { fieldSet = - stream(getIndexAdminDateFields().split(",")).get( + split(getIndexAdminDateFields(), ",").get( stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).collect(Collectors.toSet())); propMap.put(INDEX_ADMIN_DATE_FIELD_SET, fieldSet); } @@ -1101,7 +1096,7 @@ public default boolean validateIndexDateFields(final Map source) } public default List invalidIndexDateFields(final Map source) { - return stream(getIndexAdminDateFields().split(",")).get( + return split(getIndexAdminDateFields(), ",").get( stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).filter(s -> isNonEmptyValue(source.get(s))) .filter(s -> !validateDateTimeString(source.get(s))).collect(Collectors.toList())); } @@ -1120,7 +1115,7 @@ public default Set getIndexAdminIntegerFieldSet() { Set fieldSet = (Set) propMap.get(INDEX_ADMIN_INTEGER_FIELD_SET); if (fieldSet == null) { fieldSet = - stream(getIndexAdminIntegerFields().split(",")).get( + split(getIndexAdminIntegerFields(), ",").get( stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).collect(Collectors.toSet())); propMap.put(INDEX_ADMIN_INTEGER_FIELD_SET, fieldSet); } @@ -1133,7 +1128,7 @@ public default boolean validateIndexIntegerFields(final Map sour public default List invalidIndexIntegerFields(final Map source) { final IntegerTypeValidator integerValidator = new IntegerTypeValidator(); - return stream(getIndexAdminIntegerFields().split(",")).get( + return split(getIndexAdminIntegerFields(), ",").get( stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).filter(s -> isNonEmptyValue(source.get(s))) .filter(s -> !integerValidator.isValid((String) source.get(s), null)).collect(Collectors.toList())); } @@ -1145,7 +1140,7 @@ public default Set getIndexAdminLongFieldSet() { Set fieldSet = (Set) propMap.get(INDEX_ADMIN_LONG_FIELD_SET); if (fieldSet == null) { fieldSet = - stream(getIndexAdminLongFields().split(",")).get( + split(getIndexAdminLongFields(), ",").get( stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).collect(Collectors.toSet())); propMap.put(INDEX_ADMIN_LONG_FIELD_SET, fieldSet); } @@ -1158,7 +1153,7 @@ public default boolean validateIndexLongFields(final Map source) public default List invalidIndexLongFields(final Map source) { final LongTypeValidator longValidator = new LongTypeValidator(); - return stream(getIndexAdminLongFields().split(",")).get( + return split(getIndexAdminLongFields(), ",").get( stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).filter(s -> isNonEmptyValue(source.get(s))) .filter(s -> !longValidator.isValid((String) source.get(s), null)).collect(Collectors.toList())); } @@ -1170,7 +1165,7 @@ public default Set getIndexAdminFloatFieldSet() { Set fieldSet = (Set) propMap.get(INDEX_ADMIN_FLOAT_FIELD_SET); if (fieldSet == null) { fieldSet = - stream(getIndexAdminFloatFields().split(",")).get( + split(getIndexAdminFloatFields(), ",").get( stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).collect(Collectors.toSet())); propMap.put(INDEX_ADMIN_FLOAT_FIELD_SET, fieldSet); } @@ -1183,7 +1178,7 @@ public default boolean validateIndexFloatFields(final Map source public default List invalidIndexFloatFields(final Map source) { final FloatTypeValidator floatValidator = new FloatTypeValidator(); - return stream(getIndexAdminFloatFields().split(",")).get( + return split(getIndexAdminFloatFields(), ",").get( stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).filter(s -> isNonEmptyValue(source.get(s))) .filter(s -> !floatValidator.isValid((String) source.get(s), null)).collect(Collectors.toList())); } @@ -1195,7 +1190,7 @@ public default Set getIndexAdminDoubleFieldSet() { Set fieldSet = (Set) propMap.get(INDEX_ADMIN_DOUBLE_FIELD_SET); if (fieldSet == null) { fieldSet = - stream(getIndexAdminDoubleFields().split(",")).get( + split(getIndexAdminDoubleFields(), ",").get( stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).collect(Collectors.toSet())); propMap.put(INDEX_ADMIN_DOUBLE_FIELD_SET, fieldSet); } @@ -1208,7 +1203,7 @@ public default boolean validateIndexDoubleFields(final Map sourc public default List invalidIndexDoubleFields(final Map source) { final DoubleTypeValidator doubleValidator = new DoubleTypeValidator(); - return stream(getIndexAdminDoubleFields().split(",")).get( + return split(getIndexAdminDoubleFields(), ",").get( stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).filter(s -> isNonEmptyValue(source.get(s))) .filter(s -> !doubleValidator.isValid((String) source.get(s), null)).collect(Collectors.toList())); } @@ -1269,7 +1264,7 @@ public default Map convertToStorableDoc(final Map stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).collect(Collectors.toList())); } else if (dateFieldSet.contains(key)) { // TODO time zone @@ -1295,7 +1290,7 @@ public default boolean validateIndexRequiredFields(final Map sou public default List invalidIndexRequiredFields(final Map source) { final RequiredValidator requiredValidator = new RequiredValidator(); - return stream(getIndexAdminRequiredFields().split(",")).get( + return split(getIndexAdminRequiredFields(), ",").get( stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()) .filter(s -> !requiredValidator.isValid(source.get(s), null)).collect(Collectors.toList())); }