Skip to content

Commit

Permalink
fix #672 replace with split
Browse files Browse the repository at this point in the history
  • Loading branch information
marevol committed Sep 29, 2016
1 parent 3fd2ec4 commit f2a0f04
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -298,7 +299,7 @@ protected OptionalEntity<DataConfig> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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]));
}

// ===================================================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -362,7 +363,7 @@ protected OptionalEntity<ElevateWord> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -290,7 +291,7 @@ protected OptionalEntity<FileConfig> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -296,7 +297,7 @@ protected OptionalEntity<LabelType> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -297,7 +298,7 @@ protected OptionalEntity<WebConfig> 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;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/codelibs/fess/ds/impl/EsDataStoreImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/codelibs/fess/job/CrawlJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down
Loading

0 comments on commit f2a0f04

Please # to comment.