code improvement

This commit is contained in:
Shinsuke Sugaya 2016-07-12 22:37:17 +09:00
parent bb7f65c957
commit 723c9a2c83
29 changed files with 36 additions and 59 deletions

View file

@ -112,7 +112,7 @@ public class JsonApiManager extends BaseApiManager {
}
protected void processPingRequest(final HttpServletRequest request, final HttpServletResponse response, final FilterChain chain) {
final FessEsClient fessEsClient = ComponentUtil.getElasticsearchClient();
final FessEsClient fessEsClient = ComponentUtil.getFessEsClient();
int status;
Exception err = null;
try {
@ -547,7 +547,7 @@ public class JsonApiManager extends BaseApiManager {
sb.append(" [ ").append(sw.toString()).append(" ]");
try {
sw.close();
} catch (IOException ignore) {}
} catch (final IOException ignore) {}
writeJsonResponse(status, body, sb.toString());
}

View file

@ -111,7 +111,7 @@ public class AdminEsreqAction extends FessAdminAction {
return redirect(getClass()); // no-op
}
private CurlRequest getCurlRequest(String header) {
private CurlRequest getCurlRequest(final String header) {
if (StringUtil.isBlank(header)) {
return null;
}
@ -143,7 +143,7 @@ public class AdminEsreqAction extends FessAdminAction {
return null;
}
private HtmlResponse asListHtml(Runnable runnable) {
private HtmlResponse asListHtml(final Runnable runnable) {
if (runnable != null) {
runnable.run();
}

View file

@ -371,7 +371,7 @@ public class AdminUpgradeAction extends FessAdminAction {
roleTypeBhv.queryDelete(cb -> {});
roleBhv.selectEntity(cb -> cb.query().setName_Equal("guest")).orElseGet(() -> {
Role entity = new Role();
final Role entity = new Role();
entity.setName("guest");
roleBhv.insert(entity);
return entity;
@ -450,7 +450,7 @@ public class AdminUpgradeAction extends FessAdminAction {
if (!pmResponse.isAcknowledged()) {
logger.warn("Failed to add " + field + " to " + index + "/" + type);
}
} catch (Exception e) {
} catch (final Exception e) {
logger.warn("Failed to add " + field + " to " + index + "/" + type, e);
}
}

View file

@ -118,7 +118,7 @@ public abstract class FessSearchAction extends FessBaseAction {
locale = Locale.ENGLISH;
}
runtime.registerData("langItems", systemHelper.getLanguageItems(locale));
String username = systemHelper.getUsername();
final String username = systemHelper.getUsername();
runtime.registerData("username", username);
runtime.registerData("adminUser", fessConfig.isAdminUser(username));

View file

@ -144,8 +144,8 @@ public class FessLoginAssist extends TypicalLoginAssist<String, FessUserBean, Fe
// ==============
@Override
public HtmlResponse loginRedirect(String account, String password, LoginOpCall opLambda, LoginRedirectSuccessCall oneArgLambda)
throws LoginFailureException {
public HtmlResponse loginRedirect(final String account, final String password, final LoginOpCall opLambda,
final LoginRedirectSuccessCall oneArgLambda) throws LoginFailureException {
return loginRedirect(new UserPasswordLoginCredential(account, password), opLambda, oneArgLambda);
}

View file

@ -22,16 +22,16 @@ public interface LoginCredential {
Object getResource();
public default void assertLoginAccountRequired(String account) {
public default void assertLoginAccountRequired(final String account) {
if (account == null || account.length() == 0) {
String msg = "The argument 'account' should not be null for login.";
final String msg = "The argument 'account' should not be null for login.";
throw new IllegalArgumentException(msg);
}
}
public default void assertLoginPasswordRequired(String password) {
public default void assertLoginPasswordRequired(final String password) {
if (password == null || password.length() == 0) {
String msg = "The argument 'password' should not be null for login.";
final String msg = "The argument 'password' should not be null for login.";
throw new IllegalArgumentException(msg);
}
}

View file

@ -18,7 +18,7 @@ package org.codelibs.fess.app.web.base.login;
import org.dbflute.util.DfCollectionUtil;
public class SSOLoginCredential implements LoginCredential {
private String username;
private final String username;
// private Principal principal;

View file

@ -18,8 +18,8 @@ package org.codelibs.fess.app.web.base.login;
import org.dbflute.util.DfCollectionUtil;
public class UserPasswordLoginCredential implements LoginCredential {
private String username;
private String password;
private final String username;
private final String password;
public UserPasswordLoginCredential(final String username, final String password) {
this.username = username;

View file

@ -23,7 +23,6 @@ import javax.validation.constraints.Size;
import org.lastaflute.web.validation.Required;
public class CacheForm {
private static final long serialVersionUID = 1L;
@Required
@Size(max = 100)

View file

@ -20,8 +20,6 @@ import java.util.Map;
public class ErrorForm {
private static final long serialVersionUID = 1L;
public Map<String, String[]> fields = new HashMap<>();
public String q;

View file

@ -18,7 +18,6 @@ package org.codelibs.fess.app.web.login;
import org.hibernate.validator.constraints.NotBlank;
public class LoginForm {
private static final long serialVersionUID = 1L;
@NotBlank
public String username;

View file

@ -22,7 +22,6 @@ package org.codelibs.fess.app.web.profile;
import org.hibernate.validator.constraints.NotBlank;
public class ProfileForm {
private static final long serialVersionUID = 1L;
@NotBlank
public String oldPassword;

View file

@ -23,7 +23,6 @@ import javax.validation.constraints.Size;
import org.lastaflute.web.validation.Required;
public class ScreenshotForm {
private static final long serialVersionUID = 1L;
@Required
@Size(max = 100)

View file

@ -66,7 +66,7 @@ public class FessCrawlerThread extends CrawlerThread {
final CrawlingInfoHelper crawlingInfoHelper = ComponentUtil.getCrawlingInfoHelper();
final SambaHelper sambaHelper = ComponentUtil.getSambaHelper();
final IndexingHelper indexingHelper = ComponentUtil.getIndexingHelper();
final FessEsClient fessEsClient = ComponentUtil.getElasticsearchClient();
final FessEsClient fessEsClient = ComponentUtil.getFessEsClient();
final String url = urlQueue.getUrl();
ResponseData responseData = null;

View file

@ -60,7 +60,7 @@ public class CharMappingFile extends DictionaryFile<CharMappingItem> {
}
@Override
public OptionalEntity<CharMappingItem> get(long id) {
public OptionalEntity<CharMappingItem> get(final long id) {
if (mappingItemList == null) {
reload(null, null);
}
@ -137,7 +137,7 @@ public class CharMappingFile extends DictionaryFile<CharMappingItem> {
String[] inputs;
String output;
Matcher m = parsePattern.matcher(line.trim());
final Matcher m = parsePattern.matcher(line.trim());
if (!m.find()) {
throw new DictionaryException("Failed to parse " + path);

View file

@ -182,7 +182,7 @@ public class FileListIndexUpdateCallbackImpl implements IndexUpdateCallback, Aut
deleteIdList.add(ComponentUtil.getCrawlingInfoHelper().generateId(dataMap));
if (deleteIdList.size() >= maxDeleteDocumentCacheSize) {
final FessEsClient fessEsClient = ComponentUtil.getElasticsearchClient();
final FessEsClient fessEsClient = ComponentUtil.getFessEsClient();
final IndexingHelper indexingHelper = ComponentUtil.getIndexingHelper();
for (final String id : deleteIdList) {
indexingHelper.deleteDocument(fessEsClient, id);
@ -200,7 +200,7 @@ public class FileListIndexUpdateCallbackImpl implements IndexUpdateCallback, Aut
@Override
public void commit() {
if (!deleteIdList.isEmpty()) {
final FessEsClient fessEsClient = ComponentUtil.getElasticsearchClient();
final FessEsClient fessEsClient = ComponentUtil.getFessEsClient();
final IndexingHelper indexingHelper = ComponentUtil.getIndexingHelper();
for (final String id : deleteIdList) {
indexingHelper.deleteDocument(fessEsClient, id);

View file

@ -57,7 +57,7 @@ public class IndexUpdateCallbackImpl implements IndexUpdateCallback {
public void store(final Map<String, String> paramMap, final Map<String, Object> dataMap) {
final long startTime = System.currentTimeMillis();
final FessConfig fessConfig = ComponentUtil.getFessConfig();
final FessEsClient fessEsClient = ComponentUtil.getElasticsearchClient();
final FessEsClient fessEsClient = ComponentUtil.getFessEsClient();
if (logger.isDebugEnabled()) {
logger.debug("Adding " + dataMap);
@ -119,7 +119,7 @@ public class IndexUpdateCallbackImpl implements IndexUpdateCallback {
synchronized (docList) {
if (!docList.isEmpty()) {
final IndexingHelper indexingHelper = ComponentUtil.getIndexingHelper();
final FessEsClient fessEsClient = ComponentUtil.getElasticsearchClient();
final FessEsClient fessEsClient = ComponentUtil.getFessEsClient();
indexingHelper.sendDocuments(fessEsClient, docList);
}
}

View file

@ -21,7 +21,7 @@ public class ServletRuntimeException extends RuntimeException {
private static final long serialVersionUID = 1L;
public ServletRuntimeException(ServletException e) {
public ServletRuntimeException(final ServletException e) {
super(e);
}

View file

@ -42,6 +42,7 @@ import org.codelibs.spnego.SpnegoHttpServletRequest;
*/
public class SpnegoFilter extends SpnegoHttpFilter {
@Override
public void init(final FilterConfig filterConfig) throws ServletException {
ComponentUtil.processAfterContainerInit(() -> {
if (ComponentUtil.getFessConfig().isSsoEnabled()) {
@ -65,7 +66,7 @@ public class SpnegoFilter extends SpnegoHttpFilter {
}
@Override
public String getInitParameter(String name) {
public String getInitParameter(final String name) {
if (Constants.KRB5_CONF.equals(name)) {
final String krb5Conf = ComponentUtil.getFessConfig().getSpnegoKrb5Conf();
if (StringUtil.isNotBlank(krb5Conf)) {
@ -125,19 +126,19 @@ public class SpnegoFilter extends SpnegoHttpFilter {
throws IOException, ServletException {
if (StringUtil.isNotBlank(request.getRemoteUser())) {
// TODO save path and parameters into session
RequestDispatcher dispatcher = request.getRequestDispatcher(ComponentUtil.getFessConfig().getSsoLoginPath());
final RequestDispatcher dispatcher = request.getRequestDispatcher(ComponentUtil.getFessConfig().getSsoLoginPath());
dispatcher.forward(request, response);
} else {
chain.doFilter(request, response);
}
}
protected void doFilter(DoFilterCallback callback) {
protected void doFilter(final DoFilterCallback callback) {
try {
callback.run();
} catch (IOException e) {
} catch (final IOException e) {
throw new IORuntimeException(e);
} catch (ServletException e) {
} catch (final ServletException e) {
throw new ServletRuntimeException(e);
}
}

View file

@ -258,8 +258,8 @@ public class DataIndexHelper {
.should(QueryBuilders.missingQuery(fessConfig.getIndexFieldExpires())))
.mustNot(QueryBuilders.termQuery(fessConfig.getIndexFieldSegment(), sessionId));
try {
ComponentUtil.getElasticsearchClient().deleteByQuery(fessConfig.getIndexDocumentUpdateIndex(),
fessConfig.getIndexDocumentType(), queryBuilder);
ComponentUtil.getFessEsClient().deleteByQuery(fessConfig.getIndexDocumentUpdateIndex(), fessConfig.getIndexDocumentType(),
queryBuilder);
} catch (final Exception e) {
logger.error("Could not delete old docs at " + dataConfig, e);
}

View file

@ -26,8 +26,6 @@ import org.codelibs.fess.util.ComponentUtil;
public class DocumentHelper {
private static final long serialVersionUID = 1L;
public String getContent(final ResponseData responseData, final String content, final Map<String, Object> dataMap) {
if (content == null) {
return StringUtil.EMPTY; // empty

View file

@ -26,8 +26,6 @@ import org.codelibs.fess.util.ComponentUtil;
public class DuplicateHostHelper {
private static final long serialVersionUID = 1L;
protected List<DuplicateHost> duplicateHostList;
@PostConstruct

View file

@ -86,7 +86,7 @@ public class KeyMatchHelper {
}
protected List<Map<String, Object>> getDocumentList(final KeyMatch keyMatch) {
final FessEsClient fessEsClient = ComponentUtil.getElasticsearchClient();
final FessEsClient fessEsClient = ComponentUtil.getFessEsClient();
final FessConfig fessConfig = ComponentUtil.getFessConfig();
final List<Map<String, Object>> documentList =
fessEsClient.getDocumentList(

View file

@ -171,7 +171,7 @@ public class LabelTypeHelper {
return permissions;
}
public void setPermissions(String[] permissions) {
public void setPermissions(final String[] permissions) {
this.permissions = permissions;
}
}

View file

@ -32,8 +32,6 @@ import org.slf4j.LoggerFactory;
public class PathMappingHelper {
private static final long serialVersionUID = 1L;
private static final Logger logger = LoggerFactory.getLogger(PathMappingHelper.class);
private final Map<String, List<PathMapping>> pathMappingMap = new HashMap<>();

View file

@ -58,8 +58,6 @@ import com.ibm.icu.util.ULocale;
public class SystemHelper {
private static final Logger logger = LoggerFactory.getLogger(SystemHelper.class);
private static final long serialVersionUID = 1L;
protected final Map<String, String> designJspFileNameMap = new HashMap<>();
protected final AtomicBoolean forceStop = new AtomicBoolean(false);

View file

@ -88,8 +88,6 @@ public class ViewHelper {
private static final Pattern SHARED_FOLDER_PATTERN = Pattern.compile("^file:/+[^/]\\.");
private static final long serialVersionUID = 1L;
private static final Logger logger = LoggerFactory.getLogger(ViewHelper.class);
@Resource

View file

@ -47,8 +47,6 @@ import org.slf4j.LoggerFactory;
public class WebFsIndexHelper {
private static final long serialVersionUID = 1L;
private static final Logger logger = LoggerFactory.getLogger(WebFsIndexHelper.class);
@Resource

View file

@ -147,8 +147,6 @@ public final class ComponentUtil {
private static final String INDEXING_HELPER = "indexingHelper";
private static final String ELASTICSEARCH_CLIENT = FESS_ES_CLIENT;
private static IndexingHelper indexingHelper;
private static CrawlingConfigHelper crawlingConfigHelper;
@ -162,7 +160,7 @@ public final class ComponentUtil {
private ComponentUtil() {
}
public static void processAfterContainerInit(Runnable process) {
public static void processAfterContainerInit(final Runnable process) {
if (available()) {
process.run();
} else {
@ -170,7 +168,7 @@ public final class ComponentUtil {
}
}
public static void doInitProcesses(Consumer<? super Runnable> action) {
public static void doInitProcesses(final Consumer<? super Runnable> action) {
try {
initProcesses.forEach(action);
} finally {
@ -299,10 +297,6 @@ public final class ComponentUtil {
return getComponent(USER_INFO_HELPER);
}
public static FessEsClient getElasticsearchClient() {
return getComponent(ELASTICSEARCH_CLIENT);
}
public static MessageManager getMessageManager() {
return getComponent(MESSAGE_MANAGER);
}