fix #2603 code cleanup

This commit is contained in:
Shinsuke Sugaya 2021-12-01 06:55:00 +09:00
parent 9283746c6b
commit 075a66d7ab
68 changed files with 234 additions and 299 deletions

View file

@ -23,7 +23,7 @@ import org.codelibs.core.lang.StringUtil;
public class Constants extends CoreLibConstants {
public static final String LINE_SEPARATOR = System.getProperty("line.separator");
public static final String LINE_SEPARATOR = System.lineSeparator();
public static final int DEFAULT_ADMIN_PAGE_NUMBER = 1;
@ -353,10 +353,9 @@ public class Constants extends CoreLibConstants {
public static final String DATA_CRAWLER_TYPE = "data_crawling";
public static final String[] COMMON_CONVERSION_RULE =
new String[] { "crudMode", "createdBy", "createdTime", "updatedBy", "updatedTime" };
public static final String[] COMMON_CONVERSION_RULE = { "crudMode", "createdBy", "createdTime", "updatedBy", "updatedTime" };
public static final String[] COMMON_API_CONVERSION_RULE = new String[] { "crudMode" };
public static final String[] COMMON_API_CONVERSION_RULE = { "crudMode" };
public static final String USER_INFO = "LoginInfo";

View file

@ -45,8 +45,7 @@ public abstract class BaseJsonApiManager extends BaseApiManager {
return;
}
if (t instanceof InvalidAccessTokenException) {
final InvalidAccessTokenException e = (InvalidAccessTokenException) t;
if (t instanceof InvalidAccessTokenException e) {
final HttpServletResponse response = LaResponseUtil.getResponse();
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
response.setHeader("WWW-Authenticate", "Bearer error=\"" + e.getType() + "\"");

View file

@ -23,7 +23,7 @@ import javax.servlet.http.HttpServletRequest;
public class WebApiManagerFactory {
protected WebApiManager[] webApiManagers = new WebApiManager[0];
protected WebApiManager[] webApiManagers = {};
public void add(final WebApiManager webApiManager) {
final List<WebApiManager> list = new ArrayList<>();

View file

@ -54,7 +54,7 @@ public class EsApiManager extends BaseApiManager {
private static final Logger logger = LogManager.getLogger(EsApiManager.class);
protected String[] acceptedRoles = new String[] { "admin" };
protected String[] acceptedRoles = { "admin" };
public EsApiManager() {
setPathPrefix(ADMIN_SERVER);

View file

@ -321,8 +321,7 @@ public class GsaApiManager extends BaseApiManager {
if (logger.isDebugEnabled()) {
logger.debug("Failed to process a search request.", e);
}
if (e instanceof InvalidAccessTokenException) {
final InvalidAccessTokenException iate = (InvalidAccessTokenException) e;
if (e instanceof InvalidAccessTokenException iate) {
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
response.setHeader("WWW-Authenticate", "Bearer error=\"" + iate.getType() + "\"");
}

View file

@ -154,8 +154,7 @@ public class SuggestApiManager extends BaseJsonApiManager {
if (logger.isDebugEnabled()) {
logger.debug("Failed to process a suggest request.", e);
}
if (e instanceof InvalidAccessTokenException) {
final InvalidAccessTokenException iate = (InvalidAccessTokenException) e;
if (e instanceof InvalidAccessTokenException iate) {
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
response.setHeader("WWW-Authenticate", "Bearer error=\"" + iate.getType() + "\"");
}

View file

@ -113,9 +113,8 @@ public class ElevateWordService {
op.setRefreshPolicy(Constants.TRUE);
});
final String elevateWordId = elevateWord.getId();
if (isNew) {
// Insert
if (labelTypeIds != null) {
if (labelTypeIds != null) {
if (isNew) {
final List<ElevateWordToLabel> wctltmList = new ArrayList<>();
for (final String id : labelTypeIds) {
final ElevateWordToLabel mapping = new ElevateWordToLabel();
@ -126,39 +125,38 @@ public class ElevateWordService {
elevateWordToLabelBhv.batchInsert(wctltmList, op -> {
op.setRefreshPolicy(Constants.TRUE);
});
}
} else // Update
if (labelTypeIds != null) {
final List<ElevateWordToLabel> list = elevateWordToLabelBhv.selectList(wctltmCb -> {
wctltmCb.query().setElevateWordId_Equal(elevateWordId);
wctltmCb.fetchFirst(fessConfig.getPageLabeltypeMaxFetchSizeAsInteger());
});
final List<ElevateWordToLabel> newList = new ArrayList<>();
final List<ElevateWordToLabel> matchedList = new ArrayList<>();
for (final String id : labelTypeIds) {
boolean exist = false;
for (final ElevateWordToLabel mapping : list) {
if (mapping.getLabelTypeId().equals(id)) {
exist = true;
matchedList.add(mapping);
break;
} else {
final List<ElevateWordToLabel> list = elevateWordToLabelBhv.selectList(wctltmCb -> {
wctltmCb.query().setElevateWordId_Equal(elevateWordId);
wctltmCb.fetchFirst(fessConfig.getPageLabeltypeMaxFetchSizeAsInteger());
});
final List<ElevateWordToLabel> newList = new ArrayList<>();
final List<ElevateWordToLabel> matchedList = new ArrayList<>();
for (final String id : labelTypeIds) {
boolean exist = false;
for (final ElevateWordToLabel mapping : list) {
if (mapping.getLabelTypeId().equals(id)) {
exist = true;
matchedList.add(mapping);
break;
}
}
if (!exist) {
// new
final ElevateWordToLabel mapping = new ElevateWordToLabel();
mapping.setElevateWordId(elevateWordId);
mapping.setLabelTypeId(id);
newList.add(mapping);
}
}
if (!exist) {
// new
final ElevateWordToLabel mapping = new ElevateWordToLabel();
mapping.setElevateWordId(elevateWordId);
mapping.setLabelTypeId(id);
newList.add(mapping);
}
list.removeAll(matchedList);
elevateWordToLabelBhv.batchInsert(newList, op -> {
op.setRefreshPolicy(Constants.TRUE);
});
elevateWordToLabelBhv.batchDelete(list, op -> {
op.setRefreshPolicy(Constants.TRUE);
});
}
list.removeAll(matchedList);
elevateWordToLabelBhv.batchInsert(newList, op -> {
op.setRefreshPolicy(Constants.TRUE);
});
elevateWordToLabelBhv.batchDelete(list, op -> {
op.setRefreshPolicy(Constants.TRUE);
});
}
}

View file

@ -479,9 +479,8 @@ public class SearchLogService {
}
if (SearchLogPager.LOG_TYPE_USERINFO.equalsIgnoreCase(logType)) {
return userInfoBhv.selectByPK(id);
} else {
return searchLogBhv.selectByPK(id);
}
return searchLogBhv.selectByPK(id);
}
public Map<String, String> getSearchLogMap(final String logType, final String id) {
@ -521,33 +520,32 @@ public class SearchLogService {
params.put("Requested Time", FessFunctions.formatDate(e.getRequestedAt()));
return params;
}).get();
} else {
return searchLogBhv.selectByPK(id).map(e -> {
final Map<String, String> params = new LinkedHashMap<>();
params.put("ID", e.getId());
params.put("Query ID", e.getQueryId());
params.put("User Info ID", e.getUserInfoId());
params.put("User Session ID", e.getUserSessionId());
params.put("Access Type", e.getAccessType());
params.put("Search Word", e.getSearchWord());
params.put("Requested Time", FessFunctions.formatDate(e.getRequestedAt()));
params.put("Query Time", toNumberString(e.getQueryTime()));
params.put("Response Time", toNumberString(e.getResponseTime()));
params.put("Hit Count", toNumberString(e.getHitCount()));
params.put("Offset", toNumberString(e.getQueryOffset()));
params.put("Page Size", toNumberString(e.getQueryPageSize()));
params.put("Client IP", e.getClientIp());
params.put("Referer", e.getReferer());
params.put("Languages", e.getLanguages());
params.put("Virtual Host", e.getVirtualHost());
params.put("Roles", e.getRoles() != null ? String.join(" ", e.getRoles()) : StringUtil.EMPTY);
params.put("User Agent", e.getUserAgent());
e.getSearchFieldLogList().stream().forEach(p -> {
params.put(p.getFirst(), p.getSecond());
});
return params;
}).get();
}
return searchLogBhv.selectByPK(id).map(e -> {
final Map<String, String> params = new LinkedHashMap<>();
params.put("ID", e.getId());
params.put("Query ID", e.getQueryId());
params.put("User Info ID", e.getUserInfoId());
params.put("User Session ID", e.getUserSessionId());
params.put("Access Type", e.getAccessType());
params.put("Search Word", e.getSearchWord());
params.put("Requested Time", FessFunctions.formatDate(e.getRequestedAt()));
params.put("Query Time", toNumberString(e.getQueryTime()));
params.put("Response Time", toNumberString(e.getResponseTime()));
params.put("Hit Count", toNumberString(e.getHitCount()));
params.put("Offset", toNumberString(e.getQueryOffset()));
params.put("Page Size", toNumberString(e.getQueryPageSize()));
params.put("Client IP", e.getClientIp());
params.put("Referer", e.getReferer());
params.put("Languages", e.getLanguages());
params.put("Virtual Host", e.getVirtualHost());
params.put("Roles", e.getRoles() != null ? String.join(" ", e.getRoles()) : StringUtil.EMPTY);
params.put("User Agent", e.getUserAgent());
e.getSearchFieldLogList().stream().forEach(p -> {
params.put(p.getFirst(), p.getSecond());
});
return params;
}).get();
}
private String toNumberString(final Number value) {

View file

@ -313,7 +313,8 @@ public class AdminAction extends FessAdminAction {
}
if (user.hasRoles(getActionRoles(AdminGeneralAction.ROLE))) {
return AdminGeneralAction.class;
} else if (user.hasRoles(getActionRoles(AdminSchedulerAction.ROLE))) {
}
if (user.hasRoles(getActionRoles(AdminSchedulerAction.ROLE))) {
return AdminSchedulerAction.class;
} else if (user.hasRoles(getActionRoles(AdminDesignAction.ROLE))) {
return AdminDesignAction.class;

View file

@ -305,7 +305,8 @@ public class AdminBackupAction extends FessAdminAction {
}
if ("user_info".equals(name)) {
return writeNdjsonResponse(id, getUserInfoNdjsonWriteCall());
} else if ("click_log".equals(name)) {
}
if ("click_log".equals(name)) {
return writeNdjsonResponse(id, getClickLogNdjsonWriteCall());
} else if ("favorite_log".equals(name)) {
return writeNdjsonResponse(id, getFavoriteLogNdjsonWriteCall());

View file

@ -15,9 +15,7 @@
*/
package org.codelibs.fess.app.web.admin.maintenance;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.net.InetAddress;
import java.nio.file.Files;
import java.nio.file.Path;
@ -35,7 +33,6 @@ import javax.annotation.Resource;
import org.apache.commons.text.StringEscapeUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.codelibs.core.exception.IORuntimeException;
import org.codelibs.core.io.CopyUtil;
import org.codelibs.core.lang.StringUtil;
import org.codelibs.curl.CurlResponse;
@ -62,8 +59,8 @@ public class AdminMaintenanceAction extends FessAdminAction {
private static final Logger logger = LogManager.getLogger(AdminMaintenanceAction.class);
private static final String[] ES_CAT_NAMES =
new String[] { "aliases", "allocation", "count", "fielddata", "health", "indices", "master", "nodeattrs", "nodes",
"pending_tasks", "plugins", "recovery", "repositories", "thread_pool", "shards", "segments", "snapshots", "templates" };
{ "aliases", "allocation", "count", "fielddata", "health", "indices", "master", "nodeattrs", "nodes", "pending_tasks",
"plugins", "recovery", "repositories", "thread_pool", "shards", "segments", "snapshots", "templates" };
// ===================================================================================
// Attribute

View file

@ -139,7 +139,7 @@ public class AdminSchedulerAction extends FessAdminAction {
scheduledJobForm.cronExpression = null;
final String decodedName = new String(Base64.getUrlDecoder().decode(name), Constants.CHARSET_UTF_8);
scheduledJobForm.name = MessageFormat.format(fessConfig.getJobTemplateTitle(type), decodedName);
final String[] ids = new String[] { "", "", "" };
final String[] ids = { "", "", "" };
if (Constants.WEB_CRAWLER_TYPE.equals(type)) {
ids[0] = "\"" + id + "\"";
} else if (Constants.FILE_CRAWLER_TYPE.equals(type)) {

View file

@ -37,7 +37,7 @@ public class AdminSearchlogAction extends FessAdminAction {
public static final String ROLE = "admin-searchlog";
private static final String[] CONDITION_FIELDS =
new String[] { "logType", "queryId", "userSessionId", "accessType", "requestedTimeRange", "pageSize" };
{ "logType", "queryId", "userSessionId", "accessType", "requestedTimeRange", "pageSize" };
// ===================================================================================
// Attribute

View file

@ -131,8 +131,7 @@ public class AdminSysteminfoAction extends FessAdminAction {
}
itemList.add(createItem(k, value));
});
if (fessConfig instanceof ObjectiveConfig) {
final ObjectiveConfig config = (ObjectiveConfig) fessConfig;
if (fessConfig instanceof ObjectiveConfig config) {
config.keySet().stream().forEach(k -> {
final String value;
if (isMaskedValue(k)) {

View file

@ -104,7 +104,8 @@ public class ApiAdminBackupAction extends FessApiAdminAction {
final String name = id.substring(0, id.length() - NDJSON_EXTENTION.length());
if ("search_log".equals(name)) {
return writeNdjsonResponse(id, getSearchLogNdjsonWriteCall());
} else if ("user_info".equals(name)) {
}
if ("user_info".equals(name)) {
return writeNdjsonResponse(id, getUserInfoNdjsonWriteCall());
} else if ("click_log".equals(name)) {
return writeNdjsonResponse(id, getClickLogNdjsonWriteCall());

View file

@ -85,8 +85,7 @@ public class ThumbnailAction extends FessSearchAction {
}
if (path.endsWith(".jpg") || path.endsWith(".jpeg")) {
return "image/jpeg";
} else {
return "application/octet-stream";
}
return "application/octet-stream";
}
}

View file

@ -24,7 +24,7 @@ import org.codelibs.fess.es.user.exentity.User;
public class AuthenticationManager {
protected AuthenticationChain[] chains = new AuthenticationChain[0];
protected AuthenticationChain[] chains = {};
public void insert(final User user) {
chains().of(stream -> stream.forEach(c -> c.update(user)));

View file

@ -23,6 +23,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
import java.util.LinkedList;
import java.util.List;
@ -45,7 +46,7 @@ public class CommandChain implements AuthenticationChain {
protected long executionTimeout = 30L * 1000L; // 30sec
protected String commandOutputEncoding = System.getProperty("file.encoding");
protected String commandOutputEncoding = Charset.defaultCharset().displayName();
protected String[] updateCommand;

View file

@ -346,8 +346,7 @@ public abstract class AbstractFessFileTransformer extends AbstractTransformer im
if (lastModified != null) {
return lastModified;
}
} else if (lastModifiedObj instanceof String[]) {
final String[] lastModifieds = (String[]) lastModifiedObj;
} else if (lastModifiedObj instanceof String[] lastModifieds) {
if (lastModifieds.length > 0) {
final Date lastModified = FessFunctions.parseDate(lastModifieds[0]);
if (lastModified != null) {
@ -434,9 +433,8 @@ public abstract class AbstractFessFileTransformer extends AbstractTransformer im
}
if (pos == -1) {
return value;
} else {
return "localhost";
}
return "localhost";
}
if (url.startsWith("file:")) {
return "localhost";
@ -470,10 +468,9 @@ public abstract class AbstractFessFileTransformer extends AbstractTransformer im
if (value.length() > 2 && value.charAt(2) == ':') {
// Windows
return abbreviateSite(value.substring(1).replace('/', '\\'));
} else {
// Unix
return abbreviateSite(value);
}
// Unix
return abbreviateSite(value);
}
if (url.startsWith("smb:") || url.startsWith("smb1:")) {
final String value = url.replaceFirst("^smb.?:/+", StringUtil.EMPTY);

View file

@ -86,14 +86,11 @@ public interface FessTransformer {
if (encoding != null) {
String enc;
if (StringUtil.isNotBlank(getFessConfig().getCrawlerDocumentSiteEncoding())) {
if (getFessConfig().isCrawlerDocumentUseSiteEncodingOnEnglish()) {
if ("ISO-8859-1".equalsIgnoreCase(encoding) || "US-ASCII".equalsIgnoreCase(encoding)) {
enc = getFessConfig().getCrawlerDocumentSiteEncoding();
} else {
enc = encoding;
}
} else {
if (!getFessConfig().isCrawlerDocumentUseSiteEncodingOnEnglish()
|| ("ISO-8859-1".equalsIgnoreCase(encoding) || "US-ASCII".equalsIgnoreCase(encoding))) {
enc = getFessConfig().getCrawlerDocumentSiteEncoding();
} else {
enc = encoding;
}
} else {
enc = encoding;
@ -153,7 +150,7 @@ public interface FessTransformer {
}
}
default Object evaluateValue(final String scriptType, String template, final Map<String, Object> paramMap) {
default Object evaluateValue(final String scriptType, final String template, final Map<String, Object> paramMap) {
if (StringUtil.isEmpty(template)) {
return StringUtil.EMPTY;
}

View file

@ -301,8 +301,7 @@ public class FessXpathTransformer extends XpathTransformer implements FessTransf
protected Map<String, String> getConfigPrameterMap(final ResponseData responseData, final ConfigName config) {
final CrawlingConfigHelper crawlingConfigHelper = ComponentUtil.getCrawlingConfigHelper();
final CrawlingConfig crawlingConfig = crawlingConfigHelper.get(responseData.getSessionId());
final Map<String, String> configMap = crawlingConfig.getConfigParameterMap(config);
return configMap;
return crawlingConfig.getConfigParameterMap(config);
}
protected boolean isValidUrl(final String urlStr) {
@ -320,10 +319,7 @@ public class FessXpathTransformer extends XpathTransformer implements FessTransf
try {
final URL url = new java.net.URL(value);
final String host = url.getHost();
if (StringUtil.isBlank(host)) {
return false;
}
if ("http".equalsIgnoreCase(host) || "https".equalsIgnoreCase(host)) {
if (StringUtil.isBlank(host) || "http".equalsIgnoreCase(host) || "https".equalsIgnoreCase(host)) {
return false;
}
} catch (final MalformedURLException e) {

View file

@ -237,9 +237,8 @@ public class KuromojiFile extends DictionaryFile<KuromojiItem> {
writer.write(Constants.LINE_SEPARATOR);
return new KuromojiItem(item.getId(), item.getNewToken(), item.getNewSegmentation(), item.getNewReading(),
item.getNewPos());
} else {
return null;
}
return null;
} finally {
item.setNewToken(null);
}

View file

@ -118,10 +118,7 @@ public class KuromojiItem extends DictionaryItem {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
if ((obj == null) || (getClass() != obj.getClass())) {
return false;
}
final KuromojiItem other = (KuromojiItem) obj;

View file

@ -250,9 +250,8 @@ public class CharMappingFile extends DictionaryFile<CharMappingItem> {
writer.write(item.toLineString());
writer.write(Constants.LINE_SEPARATOR);
return new CharMappingItem(item.getId(), item.getNewInputs(), item.getNewOutput());
} else {
return null;
}
return null;
} finally {
item.setNewInputs(null);
item.setNewOutput(null);

View file

@ -102,10 +102,7 @@ public class CharMappingItem extends DictionaryItem {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
if ((obj == null) || (getClass() != obj.getClass())) {
return false;
}
final CharMappingItem other = (CharMappingItem) obj;

View file

@ -235,9 +235,8 @@ public class ProtwordsFile extends DictionaryFile<ProtwordsItem> {
writer.write(item.toLineString());
writer.write(Constants.LINE_SEPARATOR);
return new ProtwordsItem(item.getId(), item.getNewInput());
} else {
return null;
}
return null;
} finally {
item.setNewInput(null);
}

View file

@ -65,8 +65,7 @@ public class ProtwordsItem extends DictionaryItem {
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + input.hashCode();
return result;
return prime * result + input.hashCode();
}
@Override
@ -74,10 +73,7 @@ public class ProtwordsItem extends DictionaryItem {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
if ((obj == null) || (getClass() != obj.getClass())) {
return false;
}
final ProtwordsItem other = (ProtwordsItem) obj;

View file

@ -247,9 +247,8 @@ public class StemmerOverrideFile extends DictionaryFile<StemmerOverrideItem> {
writer.write(item.toLineString());
writer.write(Constants.LINE_SEPARATOR);
return new StemmerOverrideItem(item.getId(), item.getNewInput(), item.getNewOutput());
} else {
return null;
}
return null;
} finally {
item.setNewInput(null);
item.setNewOutput(null);

View file

@ -83,10 +83,7 @@ public class StemmerOverrideItem extends DictionaryItem {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
if ((obj == null) || (getClass() != obj.getClass())) {
return false;
}
final StemmerOverrideItem other = (StemmerOverrideItem) obj;

View file

@ -235,9 +235,8 @@ public class StopwordsFile extends DictionaryFile<StopwordsItem> {
writer.write(item.toLineString());
writer.write(Constants.LINE_SEPARATOR);
return new StopwordsItem(item.getId(), item.getNewInput());
} else {
return null;
}
return null;
} finally {
item.setNewInput(null);
}

View file

@ -65,8 +65,7 @@ public class StopwordsItem extends DictionaryItem {
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + input.hashCode();
return result;
return prime * result + input.hashCode();
}
@Override
@ -74,10 +73,7 @@ public class StopwordsItem extends DictionaryItem {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
if ((obj == null) || (getClass() != obj.getClass())) {
return false;
}
final StopwordsItem other = (StopwordsItem) obj;

View file

@ -311,9 +311,8 @@ public class SynonymFile extends DictionaryFile<SynonymItem> {
writer.write(item.toLineString());
writer.write(Constants.LINE_SEPARATOR);
return new SynonymItem(item.getId(), item.getNewInputs(), item.getNewOutputs());
} else {
return null;
}
return null;
} finally {
item.setNewInputs(null);
item.setNewOutputs(null);

View file

@ -100,10 +100,7 @@ public class SynonymItem extends DictionaryItem {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
if ((obj == null) || (getClass() != obj.getClass())) {
return false;
}
final SynonymItem other = (SynonymItem) obj;

View file

@ -47,26 +47,31 @@ public class ParamMap<K, V> implements Map<K, V> {
return keyStr;
}
@Override
public int size() {
return parent.size();
}
@Override
public boolean isEmpty() {
return parent.isEmpty();
}
public boolean containsKey(Object key) {
@Override
public boolean containsKey(final Object key) {
if (parent.containsKey(key)) {
return true;
}
return parent.containsKey(toCamelCase(key));
}
public boolean containsValue(Object value) {
@Override
public boolean containsValue(final Object value) {
return parent.containsValue(value);
}
public V get(Object key) {
@Override
public V get(final Object key) {
final V value = parent.get(key);
if (value != null) {
return value;
@ -74,11 +79,13 @@ public class ParamMap<K, V> implements Map<K, V> {
return parent.get(toCamelCase(key));
}
public V put(K key, V value) {
@Override
public V put(final K key, final V value) {
return parent.put(key, value);
}
public V remove(Object key) {
@Override
public V remove(final Object key) {
final V value = parent.remove(key);
if (value != null) {
return value;
@ -86,37 +93,45 @@ public class ParamMap<K, V> implements Map<K, V> {
return parent.remove(key);
}
public void putAll(Map<? extends K, ? extends V> m) {
@Override
public void putAll(final Map<? extends K, ? extends V> m) {
parent.putAll(m);
}
@Override
public void clear() {
parent.clear();
}
@Override
public Set<K> keySet() {
// return original keys
return parent.keySet();
}
@Override
public Collection<V> values() {
return parent.values();
}
@Override
public Set<Entry<K, V>> entrySet() {
// return original keys
return parent.entrySet();
}
public boolean equals(Object o) {
@Override
public boolean equals(final Object o) {
return parent.equals(o);
}
@Override
public int hashCode() {
return parent.hashCode();
}
public V getOrDefault(Object key, V defaultValue) {
@Override
public V getOrDefault(final Object key, final V defaultValue) {
final V value = parent.get(key);
if (value != null) {
return value;
@ -124,53 +139,63 @@ public class ParamMap<K, V> implements Map<K, V> {
return parent.getOrDefault(toCamelCase(key), defaultValue);
}
public void forEach(BiConsumer<? super K, ? super V> action) {
@Override
public void forEach(final BiConsumer<? super K, ? super V> action) {
parent.forEach(action);
}
public void replaceAll(BiFunction<? super K, ? super V, ? extends V> function) {
@Override
public void replaceAll(final BiFunction<? super K, ? super V, ? extends V> function) {
parent.replaceAll(function);
}
public V putIfAbsent(K key, V value) {
@Override
public V putIfAbsent(final K key, final V value) {
return parent.putIfAbsent(key, value);
}
public boolean remove(Object key, Object value) {
@Override
public boolean remove(final Object key, final Object value) {
if (parent.remove(key, value)) {
return true;
}
return parent.remove(toCamelCase(key), value);
}
public boolean replace(K key, V oldValue, V newValue) {
@Override
public boolean replace(final K key, final V oldValue, final V newValue) {
if (parent.replace(key, oldValue, newValue)) {
return true;
}
return parent.replace(key, oldValue, newValue);
}
public V replace(K key, V value) {
@Override
public V replace(final K key, final V value) {
// use original key
return parent.replace(key, value);
}
public V computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction) {
@Override
public V computeIfAbsent(final K key, final Function<? super K, ? extends V> mappingFunction) {
// use original key
return parent.computeIfAbsent(key, mappingFunction);
}
public V computeIfPresent(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
@Override
public V computeIfPresent(final K key, final BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
// use original key
return parent.computeIfPresent(key, remappingFunction);
}
public V compute(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
@Override
public V compute(final K key, final BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
// use original key
return parent.compute(key, remappingFunction);
}
public V merge(K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction) {
@Override
public V merge(final K key, final V value, final BiFunction<? super V, ? super V, ? extends V> remappingFunction) {
// use original key
return parent.merge(key, value, remappingFunction);
}

View file

@ -394,7 +394,7 @@ public class SearchEngineClient implements Client {
if (fessConfig.availableProcessors() >= 4) {
return null;
}
String requestsPerSecond = String.valueOf(fessConfig.getIndexReindexSizeAsInteger() * fessConfig.availableProcessors());
final String requestsPerSecond = String.valueOf(fessConfig.getIndexReindexSizeAsInteger() * fessConfig.availableProcessors());
logger.info("Set requests_per_second to {}", requestsPerSecond);
return requestsPerSecond;
}
@ -451,11 +451,10 @@ public class SearchEngineClient implements Client {
if (StringUtil.isNotBlank(dictionaryPath) && !dictionaryPath.endsWith("/")) {
dictionaryPath = dictionaryPath + "/";
}
source = source.replaceAll(Pattern.quote("${fess.dictionary.path}"), dictionaryPath);
source = source.replaceAll(Pattern.quote("${fess.index.codec}"), fessConfig.getIndexCodec());
source = source.replaceAll(Pattern.quote("${fess.index.number_of_shards}"), numberOfShards);
source = source.replaceAll(Pattern.quote("${fess.index.auto_expand_replicas}"), autoExpandReplicas);
return source;
return source.replaceAll(Pattern.quote("${fess.dictionary.path}"), dictionaryPath)//
.replaceAll(Pattern.quote("${fess.index.codec}"), fessConfig.getIndexCodec())//
.replaceAll(Pattern.quote("${fess.index.number_of_shards}"), numberOfShards)//
.replaceAll(Pattern.quote("${fess.index.auto_expand_replicas}"), autoExpandReplicas);
}
protected String getResourcePath(final String basePath, final String type, final String path) {

View file

@ -41,11 +41,10 @@ public class ImplementedInvokerAssistant implements InvokerAssistant {
// ===================================================================================
// Attribute
// =========
protected static final String[] DEFAULT_CLIENT_INVOKE_NAMES =
new String[] { "Page", "Action", "Controller", "ControllerImpl", "Task", "Test" };
protected static final String[] DEFAULT_CLIENT_INVOKE_NAMES = { "Page", "Action", "Controller", "ControllerImpl", "Task", "Test" };
protected static final String[] DEFAULT_BYPASS_INVOKE_NAMES =
new String[] { "Service", "ServiceImpl", "Facade", "FacadeImpl", "Logic", "LogicImpl" };
{ "Service", "ServiceImpl", "Facade", "FacadeImpl", "Logic", "LogicImpl" };
@Override
public DBDef assistCurrentDBDef() {

View file

@ -41,7 +41,7 @@ public class DuplicateHost extends BsDuplicateHost {
}
public String convert(final String url) {
final String targetStr = getDuplicateHostName().replaceAll("\\.", "\\\\.");
final String targetStr = getDuplicateHostName().replace(".", "\\.");
return url.replaceFirst("://" + targetStr + "$", "://" + getRegularName()).replaceFirst("://" + targetStr + "([:/])",
"://" + getRegularName() + "$1");
}

View file

@ -72,7 +72,8 @@ public class WebAuthentication extends BsWebAuthentication {
props.setProperty(e.getKey(), e.getValue());
});
return new NTLMScheme(new JcifsEngine(props));
} else if (Constants.FORM.equals(scheme)) {
}
if (Constants.FORM.equals(scheme)) {
final Map<String, String> parameterMap = ParameterUtil.parse(getParameters());
return new FormScheme(parameterMap);
}

View file

@ -50,8 +50,7 @@ public class ClickLogBhv extends BsClickLogBhv {
if (value != null) {
try {
final Instant instant = Instant.from(DateTimeFormatter.ISO_INSTANT.parse(value.toString()));
final LocalDateTime date = LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
return date;
return LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
} catch (final DateTimeParseException e) {
logger.debug("Invalid date format: {}", value, e);
}

View file

@ -50,8 +50,7 @@ public class FavoriteLogBhv extends BsFavoriteLogBhv {
if (value != null) {
try {
final Instant instant = Instant.from(DateTimeFormatter.ISO_INSTANT.parse(value.toString()));
final LocalDateTime date = LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
return date;
return LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
} catch (final DateTimeParseException e) {
logger.debug("Invalid date format: {}", value, e);
}

View file

@ -55,8 +55,7 @@ public class SearchLogBhv extends BsSearchLogBhv {
if (value != null) {
try {
final Instant instant = Instant.from(DateTimeFormatter.ISO_INSTANT.parse(value.toString()));
final LocalDateTime date = LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
return date;
return LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
} catch (final DateTimeParseException e) {
logger.debug("Invalid date format: {}", value, e);
}

View file

@ -50,8 +50,7 @@ public class UserInfoBhv extends BsUserInfoBhv {
if (value != null) {
try {
final Instant instant = Instant.from(DateTimeFormatter.ISO_INSTANT.parse(value.toString()));
final LocalDateTime date = LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
return date;
return LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
} catch (final DateTimeParseException e) {
logger.debug("Invalid date format: {}", value, e);
}

View file

@ -70,8 +70,7 @@ public class ClickLog extends BsClickLog implements SearchLogEvent {
@Override
protected void addFieldToSource(final Map<String, Object> sourceMap, final String field, final Object value) {
if (value instanceof LocalDateTime) {
final LocalDateTime ldt = (LocalDateTime) value;
if (value instanceof LocalDateTime ldt) {
final ZonedDateTime zdt = ZonedDateTime.of(ldt, ZoneId.systemDefault());
super.addFieldToSource(sourceMap, field, DateTimeFormatter.ISO_INSTANT.format(zdt));
} else {

View file

@ -74,8 +74,7 @@ public class FavoriteLog extends BsFavoriteLog implements SearchLogEvent {
@Override
protected void addFieldToSource(final Map<String, Object> sourceMap, final String field, final Object value) {
if (value instanceof LocalDateTime) {
final LocalDateTime ldt = (LocalDateTime) value;
if (value instanceof LocalDateTime ldt) {
final ZonedDateTime zdt = ZonedDateTime.of(ldt, ZoneId.systemDefault());
super.addFieldToSource(sourceMap, field, DateTimeFormatter.ISO_INSTANT.format(zdt));
} else {

View file

@ -126,8 +126,7 @@ public class SearchLog extends BsSearchLog implements SearchLogEvent {
@Override
protected void addFieldToSource(final Map<String, Object> sourceMap, final String field, final Object value) {
if (value instanceof LocalDateTime) {
final LocalDateTime ldt = (LocalDateTime) value;
if (value instanceof LocalDateTime ldt) {
final ZonedDateTime zdt = ZonedDateTime.of(ldt, ZoneId.systemDefault());
super.addFieldToSource(sourceMap, field, DateTimeFormatter.ISO_INSTANT.format(zdt));
} else {

View file

@ -74,8 +74,7 @@ public class UserInfo extends BsUserInfo implements SearchLogEvent {
@Override
protected void addFieldToSource(final Map<String, Object> sourceMap, final String field, final Object value) {
if (value instanceof LocalDateTime) {
final LocalDateTime ldt = (LocalDateTime) value;
if (value instanceof LocalDateTime ldt) {
final ZonedDateTime zdt = ZonedDateTime.of(ldt, ZoneId.systemDefault());
super.addFieldToSource(sourceMap, field, DateTimeFormatter.ISO_INSTANT.format(zdt));
} else {

View file

@ -23,7 +23,7 @@ public abstract class AbstractConfigHelper {
protected long reloadInterval = 1000L;
public void update() {
CommonPoolUtil.execute(() -> load());
CommonPoolUtil.execute(this::load);
}
protected void waitForNext() {

View file

@ -210,9 +210,7 @@ public class DocumentHelper {
final byte[] data = resultData.getData();
if (data != null) {
try {
@SuppressWarnings("unchecked")
final Map<String, Object> result = (Map<String, Object>) SerializeUtil.fromBinaryToObject(data);
return result;
return (Map<String, Object>) SerializeUtil.fromBinaryToObject(data);
} catch (final Exception e) {
throw new CrawlerSystemException("Could not create an instance from bytes.", e);
}

View file

@ -134,13 +134,8 @@ public class LabelTypeHelper extends AbstractConfigHelper {
if (targetLocale.equals(requestLocale) || targetLocale.equals(Locale.ROOT)) {
return true;
}
if (requestLocale == null) {
return false;
}
if (!requestLocale.getLanguage().equals(targetLocale.getLanguage())) {
return false;
}
if (targetLocale.getCountry().length() > 0 && !requestLocale.getCountry().equals(targetLocale.getCountry())) {
if ((requestLocale == null) || !requestLocale.getLanguage().equals(targetLocale.getLanguage())
|| (targetLocale.getCountry().length() > 0 && !requestLocale.getCountry().equals(targetLocale.getCountry()))) {
return false;
}
return true;
@ -232,7 +227,7 @@ public class LabelTypeHelper extends AbstractConfigHelper {
return locale;
}
public void setLocale(Locale locale) {
public void setLocale(final Locale locale) {
this.locale = locale;
}
}

View file

@ -84,16 +84,14 @@ public class PermissionHelper {
if (lower.startsWith(groupPrefix)) {
if (permission.length() > groupPrefix.length()) {
return aclPrefix + systemHelper.getSearchRoleByGroup(permission.substring(groupPrefix.length()));
} else {
return null;
}
return null;
}
if (lower.startsWith(rolePrefix)) {
if (permission.length() > rolePrefix.length()) {
return aclPrefix + systemHelper.getSearchRoleByRole(permission.substring(rolePrefix.length()));
} else {
return null;
}
return null;
}
return permission;
}

View file

@ -433,19 +433,18 @@ public class QueryHelper {
}
if (query instanceof PhraseQuery) {
return convertPhraseQuery(context, (PhraseQuery) query, boost);
} else if (query instanceof FuzzyQuery) {
}
if (query instanceof FuzzyQuery) {
return convertFuzzyQuery(context, (FuzzyQuery) query, boost);
} else if (query instanceof PrefixQuery) {
return convertPrefixQuery(context, (PrefixQuery) query, boost);
} else if (query instanceof WildcardQuery) {
return convertWildcardQuery(context, (WildcardQuery) query, boost);
} else if (query instanceof BooleanQuery) {
final BooleanQuery booleanQuery = (BooleanQuery) query;
} else if (query instanceof BooleanQuery booleanQuery) {
return convertBooleanQuery(context, booleanQuery, boost);
} else if (query instanceof MatchAllDocsQuery) {
return QueryBuilders.matchAllQuery();
} else if (query instanceof BoostQuery) {
final BoostQuery boostQuery = (BoostQuery) query;
} else if (query instanceof BoostQuery boostQuery) {
return convertQuery(context, boostQuery.getQuery(), boostQuery.getBoost());
}
throw new InvalidQueryException(messages -> messages.addErrorsInvalidQueryUnknown(UserMessages.GLOBAL_PROPERTY_KEY),
@ -530,10 +529,9 @@ public class QueryHelper {
context.addFieldLog(field, prefixQuery.getPrefix().text());
if (notAnalyzedFieldSet.contains(field)) {
return QueryBuilders.prefixQuery(field, toLowercaseWildcard(prefixQuery.getPrefix().text())).boost(boost);
} else {
return QueryBuilders.matchPhrasePrefixQuery(field, toLowercaseWildcard(prefixQuery.getPrefix().text())).boost(boost)
.maxExpansions(fessConfig.getQueryPrefixExpansionsAsInteger()).slop(fessConfig.getQueryPrefixSlopAsInteger());
}
return QueryBuilders.matchPhrasePrefixQuery(field, toLowercaseWildcard(prefixQuery.getPrefix().text())).boost(boost)
.maxExpansions(fessConfig.getQueryPrefixExpansionsAsInteger()).slop(fessConfig.getQueryPrefixSlopAsInteger());
}
protected QueryBuilder convertFuzzyQuery(final QueryContext context, final FuzzyQuery fuzzyQuery, final float boost) {
@ -653,7 +651,8 @@ public class QueryHelper {
context.addSorts(createFieldSortBuilder(sortField, sortOrder));
}));
return null;
} else if (INURL_FIELD.equals(field) || (StringUtil.equals(field, context.getDefaultField())
}
if (INURL_FIELD.equals(field) || (StringUtil.equals(field, context.getDefaultField())
&& fessConfig.getIndexFieldUrl().equals(context.getDefaultField()))) {
return QueryBuilders.wildcardQuery(fessConfig.getIndexFieldUrl(), "*" + text + "*").boost(boost);
} else if (SITE_FIELD.equals(field)) {

View file

@ -247,9 +247,7 @@ public class ViewHelper {
protected OptionalThing<Set<String>> getQuerySet() {
return LaRequestUtil.getOptionalRequest().map(req -> {
@SuppressWarnings("unchecked")
final Set<String> querySet = (Set<String>) req.getAttribute(Constants.HIGHLIGHT_QUERIES);
return querySet;
return (Set<String>) req.getAttribute(Constants.HIGHLIGHT_QUERIES);
}).filter(s -> s != null);
}
@ -819,7 +817,7 @@ public class ViewHelper {
for (int i = 0; i < fragments.length; i++) {
texts[i] = fragments[i].string();
}
String value = StringUtils.join(texts, ELLIPSIS);
final String value = StringUtils.join(texts, ELLIPSIS);
if (StringUtil.isNotBlank(value) && !ComponentUtil.getFessConfig().endsWithFullstop(value)) {
return value + ELLIPSIS;
}
@ -852,7 +850,7 @@ public class ViewHelper {
public TextFragment[] createTextFragmentsByQuery() {
return LaRequestUtil.getOptionalRequest().map(req -> {
@SuppressWarnings("unchecked")
Set<String> querySet = (Set<String>) req.getAttribute(Constants.HIGHLIGHT_QUERIES);
final Set<String> querySet = (Set<String>) req.getAttribute(Constants.HIGHLIGHT_QUERIES);
if (querySet != null) {
return querySet.stream().map(s -> new TextFragment(null, s, null, null)).toArray(n -> new TextFragment[n]);
}
@ -953,10 +951,10 @@ public class ViewHelper {
// #:~:text=[prefix-,]textStart[,textEnd][,-suffix]
public static class TextFragment {
private String prefix;
private String textStart;
private String textEnd;
private String suffix;
private final String prefix;
private final String textStart;
private final String textEnd;
private final String suffix;
TextFragment(final String prefix, final String textStart, final String textEnd, final String suffix) {
this.prefix = prefix;

View file

@ -27,7 +27,7 @@ public class DocBoostMatcher {
private String matchExpression;
private String scriptType;
private final String scriptType;
public DocBoostMatcher() {
scriptType = Constants.DEFAULT_SCRIPT;
@ -67,7 +67,8 @@ public class DocBoostMatcher {
}
if (value instanceof Float) {
return ((Float) value);
} else if (value instanceof Double) {
}
if (value instanceof Double) {
return ((Double) value).floatValue();
} else if (value != null) {
return Float.parseFloat(value.toString());

View file

@ -397,7 +397,7 @@ public class IndexUpdater extends Thread {
private AccessResultData<?> getAccessResultData(final EsAccessResult accessResult) {
try {
return accessResult.getAccessResultData();
} catch (Exception e) {
} catch (final Exception e) {
logger.warn("Failed to get data from {}", accessResult.getUrl(), e);
}
return null;

View file

@ -23,7 +23,7 @@ import org.apache.logging.log4j.Logger;
public class IngestFactory {
private static final Logger logger = LogManager.getLogger(IngestFactory.class);
private Ingester[] ingesters = new Ingester[0];
private Ingester[] ingesters = {};
public synchronized void add(final Ingester ingester) {
if (logger.isDebugEnabled()) {

View file

@ -150,11 +150,7 @@ public class LdapManager {
}
public OptionalEntity<FessUser> login(final String username, final String password) {
if (StringUtil.isBlank(fessConfig.getLdapProviderUrl())) {
return OptionalEntity.empty();
}
if (!validate()) {
if (StringUtil.isBlank(fessConfig.getLdapProviderUrl()) || !validate()) {
return OptionalEntity.empty();
}

View file

@ -238,10 +238,7 @@ public interface FessProp {
}
return list.stream().map(p -> {
final String key = p.getFirst();
if (StringUtil.isEmpty(key)) {
return p.getSecond();
}
if (userBean
if (StringUtil.isEmpty(key) || userBean
.map(user -> stream(user.getRoles()).get(stream -> stream.anyMatch(s -> (ROLE_VALUE_PREFIX + s).equals(key)))
|| stream(user.getGroups()).get(stream -> stream.anyMatch(s -> (GROUP_VALUE_PREFIX + s).equals(key))))
.orElse(false)) {
@ -285,10 +282,7 @@ public interface FessProp {
}
return map.entrySet().stream().flatMap(e -> {
final String key = e.getKey();
if (StringUtil.isEmpty(key)) {
return e.getValue().stream();
}
if (userBean
if (StringUtil.isEmpty(key) || userBean
.map(user -> stream(user.getRoles()).get(stream -> stream.anyMatch(s -> (ROLE_VALUE_PREFIX + s).equals(key)))
|| stream(user.getGroups()).get(stream -> stream.anyMatch(s -> (GROUP_VALUE_PREFIX + s).equals(key))))
.orElse(false)) {
@ -924,9 +918,7 @@ public interface FessProp {
default Class<? extends LaJob> getSchedulerJobClassAsClass() {
try {
@SuppressWarnings("unchecked")
final Class<? extends LaJob> clazz = (Class<? extends LaJob>) Class.forName(getSchedulerJobClass());
return clazz;
return (Class<? extends LaJob>) Class.forName(getSchedulerJobClass());
} catch (final ClassNotFoundException e) {
throw new ClassNotFoundRuntimeException(e);
}
@ -944,7 +936,7 @@ public interface FessProp {
Pattern[] patterns = (Pattern[]) propMap.get(CRAWLER_METADATA_CONTENT_EXCLUDES);
if (patterns == null) {
patterns = split(getCrawlerMetadataContentExcludes(), ",")
.get(stream -> stream.filter(StringUtil::isNotBlank).map(v -> Pattern.compile(v)).toArray(n -> new Pattern[n]));
.get(stream -> stream.filter(StringUtil::isNotBlank).map(Pattern::compile).toArray(n -> new Pattern[n]));
propMap.put(CRAWLER_METADATA_CONTENT_EXCLUDES, patterns);
}
return !stream(patterns).get(stream -> stream.anyMatch(p -> p.matcher(name).matches()));
@ -1031,8 +1023,7 @@ public interface FessProp {
if (lang1 != null) {
return lang1;
}
final String lang2 = mapping.get(s.split("[\\-_]")[0]);
return lang2;
return mapping.get(s.split("[\\-_]")[0]);
}).filter(StringUtil::isNotBlank).distinct().toArray(n -> new String[n]));
}
@ -1078,14 +1069,15 @@ public interface FessProp {
for (final String key : mapping.keySet()) {
if (value.endsWith("_" + key.toLowerCase(Locale.ROOT))) {
final String[] values = key.split("_");
if (values.length == 1) {
switch (values.length) {
case 1:
return new Locale(values[0]);
}
if (values.length == 2) {
case 2:
return new Locale(values[0], values[1]);
}
if (values.length == 3) {
case 3:
return new Locale(values[0], values[1], values[2]);
default:
break;
}
}
}
@ -1785,11 +1777,8 @@ public interface FessProp {
java.math.BigDecimal getThumbnailHtmlImageMaxAspectRatioAsDecimal();
default boolean validateThumbnailSize(final int width, final int height) {
if (width <= 0 || height <= 0) {
return false;
}
if (width < getThumbnailHtmlImageMinWidthAsInteger().intValue() || height < getThumbnailHtmlImageMinHeightAsInteger().intValue()) {
if (width <= 0 || height <= 0 || width < getThumbnailHtmlImageMinWidthAsInteger().intValue()
|| height < getThumbnailHtmlImageMinHeightAsInteger().intValue()) {
return false;
}

View file

@ -264,8 +264,7 @@ public class FessMultipartRequestHandler implements MultipartRequestHandler {
}
haveValue = true;
}
if (request instanceof MultipartRequestWrapper) {
final MultipartRequestWrapper wrapper = (MultipartRequestWrapper) request;
if (request instanceof MultipartRequestWrapper wrapper) {
wrapper.setParameter(name, value);
}
final String[] oldArray = elementsText.get(name);

View file

@ -199,8 +199,7 @@ public class AzureAdAuthenticator implements SsoAuthenticator {
}
final AuthenticationResponse authResponse = parseAuthenticationResponse(urlBuf.toString(), params);
if (authResponse instanceof AuthenticationSuccessResponse) {
final AuthenticationSuccessResponse oidcResponse = (AuthenticationSuccessResponse) authResponse;
if (authResponse instanceof AuthenticationSuccessResponse oidcResponse) {
validateAuthRespMatchesCodeFlow(oidcResponse);
final AuthenticationResult authData = getAccessToken(oidcResponse.getAuthorizationCode(), getReplyUrl(request));
validateNonce(stateData, authData);

View file

@ -159,7 +159,7 @@ public class SpnegoAuthenticator implements SsoAuthenticator {
}
protected class SpengoConfig implements FilterConfig {
protected static class SpengoConfig implements FilterConfig {
@Override
public String getFilterName() {
@ -180,7 +180,8 @@ public class SpnegoAuthenticator implements SsoAuthenticator {
}
if (logger.isDebugEnabled()) {
return "3";
} else if (logger.isInfoEnabled()) {
}
if (logger.isInfoEnabled()) {
return "5";
} else if (logger.isWarnEnabled()) {
return "6";
@ -195,7 +196,8 @@ public class SpnegoAuthenticator implements SsoAuthenticator {
}
if (SpnegoHttpFilter.Constants.KRB5_CONF.equals(name)) {
return getResourcePath(getProperty(SPNEGO_KRB5_CONF, "krb5.conf"));
} else if (SpnegoHttpFilter.Constants.CLIENT_MODULE.equals(name)) {
}
if (SpnegoHttpFilter.Constants.CLIENT_MODULE.equals(name)) {
return getProperty(SPNEGO_LOGIN_CLIENT_MODULE, "spnego-client");
} else if (SpnegoHttpFilter.Constants.SERVER_MODULE.equals(name)) {
return getProperty(SPNEGO_LOGIN_SERVER_MODULE, "spnego-server");

View file

@ -512,9 +512,7 @@ public final class ComponentUtil {
throw new ContainerNotAvailableException(componentName);
} catch (final ComponentNotFoundException e) {
if (componentMap.containsKey(componentName)) {
@SuppressWarnings("unchecked")
final T c = (T) componentMap.get(componentName);
return c;
return (T) componentMap.get(componentName);
}
throw e;
}

View file

@ -100,9 +100,8 @@ public final class DocumentUtil {
if (clazz.isAssignableFrom(Date.class)) {
if (value instanceof Date) {
return (T) value;
} else {
return (T) FessFunctions.parseDate(value.toString());
}
return (T) FessFunctions.parseDate(value.toString());
}
if (clazz.isAssignableFrom(Long.class)) {
if (value instanceof Long) {
@ -110,7 +109,8 @@ public final class DocumentUtil {
} else {
return (T) Long.valueOf(value.toString());
}
} else if (clazz.isAssignableFrom(Integer.class)) {
}
if (clazz.isAssignableFrom(Integer.class)) {
if (value instanceof Integer) {
return (T) value;
} else {

View file

@ -68,9 +68,9 @@ public class GsaConfigParser extends DefaultHandler {
protected static final String BAD_URLS = "bad_urls";
protected String[] webProtocols = new String[] { "http:", "https:" };
protected String[] webProtocols = { "http:", "https:" };
protected String[] fileProtocols = new String[] { "file:", "smb:", "smb1:", "ftp:", "storage:" };
protected String[] fileProtocols = { "file:", "smb:", "smb1:", "ftp:", "storage:" };
protected LinkedList<String> tagQueue;
@ -262,7 +262,8 @@ public class GsaConfigParser extends DefaultHandler {
final StringBuilder buf = new StringBuilder(100);
buf.append("(?i)");
return appendFileterPath(buf, unescape(v));
} else if (s.startsWith(REGEXP_CASE)) {
}
if (s.startsWith(REGEXP_CASE)) {
final String v = s.substring(REGEXP_CASE.length());
final StringBuilder buf = new StringBuilder(100);
return appendFileterPath(buf, unescape(v));
@ -288,7 +289,8 @@ public class GsaConfigParser extends DefaultHandler {
}
if (s.startsWith("^")) {
return "^" + Pattern.quote(s.substring(1));
} else if (s.endsWith("$")) {
}
if (s.endsWith("$")) {
return Pattern.quote(s.substring(0, s.length() - 1)) + "$";
}
return Pattern.quote(s);

View file

@ -58,7 +58,8 @@ public final class MemoryUtil {
}
if (obj instanceof Number) {
return 24L;
} else if (obj instanceof Date) {
}
if (obj instanceof Date) {
return 32L;
} else if (obj instanceof LocalDateTime) {
return 80L;

View file

@ -78,10 +78,7 @@ public class PrunedTag {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
if ((obj == null) || (getClass() != obj.getClass())) {
return false;
}
final PrunedTag other = (PrunedTag) obj;

View file

@ -33,8 +33,7 @@ public class RenderDataUtil {
if (value instanceof Entity) {
data.register(key, BeanUtil.copyBeanToNewMap(value));
} else {
if (value instanceof Collection<?>) {
final Collection<?> coll = ((Collection<?>) value);
if (value instanceof Collection<?> coll) {
if (!coll.isEmpty()) {
// care performance for List that the most frequent pattern
final Object first = coll instanceof List<?> ? ((List<?>) coll).get(0) : coll.iterator().next();

View file

@ -30,9 +30,7 @@ public final class WebApiUtil {
}
public static <T> T getObject(final String name) {
@SuppressWarnings("unchecked")
final T value = (T) LaRequestUtil.getRequest().getAttribute(name);
return value;
return (T) LaRequestUtil.getRequest().getAttribute(name);
}
public static void setError(final int statusCode, final String message) {

View file

@ -27,16 +27,11 @@ public class UriTypeValidator implements ConstraintValidator<UriType, String> {
@Override
public void initialize(final UriType uriType) {
switch (uriType.protocolType()) {
case WEB:
protocols = ComponentUtil.getFessConfig().getCrawlerWebProtocolsAsArray();
break;
case FILE:
protocols = ComponentUtil.getFessConfig().getCrawlerFileProtocolsAsArray();
break;
default:
throw new ConstraintDefinitionException("protocolType is emtpy.");
}
protocols = switch (uriType.protocolType()) {
case WEB -> ComponentUtil.getFessConfig().getCrawlerWebProtocolsAsArray();
case FILE -> ComponentUtil.getFessConfig().getCrawlerFileProtocolsAsArray();
default -> throw new ConstraintDefinitionException("protocolType is emtpy.");
};
}
@Override