diff --git a/src/config/eclipse/formatter/java.xml b/src/config/eclipse/formatter/java.xml index 294707f17..19bd52f77 100644 --- a/src/config/eclipse/formatter/java.xml +++ b/src/config/eclipse/formatter/java.xml @@ -1,298 +1,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -335,7 +43,7 @@ - + @@ -357,7 +65,7 @@ - + @@ -419,7 +127,7 @@ - + @@ -577,1178 +285,10 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/src/main/java/org/codelibs/fess/Constants.java b/src/main/java/org/codelibs/fess/Constants.java index 09b05e13a..7a46b8507 100644 --- a/src/main/java/org/codelibs/fess/Constants.java +++ b/src/main/java/org/codelibs/fess/Constants.java @@ -26,11 +26,9 @@ public class Constants extends CoreLibConstants { public static final int MINOR_VERSION = 3; - public static final String FESS_VERSION = String.valueOf(MAJOR_VERSION) - + "." + String.valueOf(MINOR_VERSION); + public static final String FESS_VERSION = String.valueOf(MAJOR_VERSION) + "." + String.valueOf(MINOR_VERSION); - public static final String LINE_SEPARATOR = System - .getProperty("line.separator"); + public static final String LINE_SEPARATOR = System.getProperty("line.separator"); public static final int DEFAULT_ADMIN_PAGE_SIZE = 25; @@ -191,10 +189,8 @@ public class Constants extends CoreLibConstants { public static final String DEFAULT_PURGE_DAY = "30"; - public static final String DEFAULT_PURGE_BY_BOTS = "BaiduMobaider," - + "Baiduspider," + "CCBot," + "Googlebot," + "ia_archive," - + "Mediapartners-Google," + "mobile goo," + "msnbot," - + "Slurp,Yeti"; + public static final String DEFAULT_PURGE_BY_BOTS = "BaiduMobaider," + "Baiduspider," + "CCBot," + "Googlebot," + "ia_archive," + + "Mediapartners-Google," + "mobile goo," + "msnbot," + "Slurp,Yeti"; public static final String DEFAULT_FROM_EMAIL = "Administrator "; @@ -256,14 +252,12 @@ public class Constants extends CoreLibConstants { public static final String SAMBA = "SAMBA"; - public static final String[] RESERVED = { "+", "-", "&&", "||", "!", "(", - ")", "{", "}", "[", "]", "^", "~", "*", "?", "\\", ";", ":", "/" }; + public static final String[] RESERVED = { "+", "-", "&&", "||", "!", "(", ")", "{", "}", "[", "]", "^", "~", "*", "?", "\\", ";", ":", + "/" }; - public static final Pattern SOLR_FIELD_RESERVED_PATTERN = Pattern - .compile("([+\\-!\\(\\){}\\[\\]^\"~\\\\:\\p{Zs}]|(&&)|(\\|\\|))"); // "*", "?", + public static final Pattern SOLR_FIELD_RESERVED_PATTERN = Pattern.compile("([+\\-!\\(\\){}\\[\\]^\"~\\\\:\\p{Zs}]|(&&)|(\\|\\|))"); // "*", "?", - public static final Pattern SOLR_RANGE_FIELD_RESERVED_PATTERN = Pattern - .compile("([!\\(\\){}\\[\\]\"~\\\\:\\p{Zs}]|(&&)|(\\|\\|))"); + public static final Pattern SOLR_RANGE_FIELD_RESERVED_PATTERN = Pattern.compile("([!\\(\\){}\\[\\]\"~\\\\:\\p{Zs}]|(&&)|(\\|\\|))"); public static final String SEARCH_LOG_ACCESS_TYPE = "searchLogAccessType"; diff --git a/src/main/java/org/codelibs/fess/InvalidQueryException.java b/src/main/java/org/codelibs/fess/InvalidQueryException.java index 32d2c4283..cd9349407 100644 --- a/src/main/java/org/codelibs/fess/InvalidQueryException.java +++ b/src/main/java/org/codelibs/fess/InvalidQueryException.java @@ -22,8 +22,7 @@ public class InvalidQueryException extends FessSystemException { private final String messageCode; - public InvalidQueryException(final String messageCode, - final String message, final Throwable cause) { + public InvalidQueryException(final String messageCode, final String message, final Throwable cause) { super(message, cause); this.messageCode = messageCode; } diff --git a/src/main/java/org/codelibs/fess/WebApiException.java b/src/main/java/org/codelibs/fess/WebApiException.java index 3caa334af..d49334374 100644 --- a/src/main/java/org/codelibs/fess/WebApiException.java +++ b/src/main/java/org/codelibs/fess/WebApiException.java @@ -26,8 +26,7 @@ public class WebApiException extends FessSystemException { return statusCode; } - public WebApiException(final int statusCode, final String message, - final Throwable cause) { + public WebApiException(final int statusCode, final String message, final Throwable cause) { super(message, cause); this.statusCode = statusCode; } diff --git a/src/main/java/org/codelibs/fess/action/AppletAction.java b/src/main/java/org/codelibs/fess/action/AppletAction.java index 321490e2c..60d924433 100644 --- a/src/main/java/org/codelibs/fess/action/AppletAction.java +++ b/src/main/java/org/codelibs/fess/action/AppletAction.java @@ -35,8 +35,7 @@ import org.slf4j.LoggerFactory; public class AppletAction { - private static final Logger logger = LoggerFactory - .getLogger(AppletAction.class); + private static final Logger logger = LoggerFactory.getLogger(AppletAction.class); @ActionForm @Resource @@ -61,8 +60,7 @@ public class AppletAction { if (logger.isDebugEnabled()) { logger.debug(e.getMessage(), e); } - throw new SSCActionMessagesException(e, - "errors.failed_to_redirect", appletForm.uri); + throw new SSCActionMessagesException(e, "errors.failed_to_redirect", appletForm.uri); } return null; } @@ -71,13 +69,11 @@ public class AppletAction { public String launcher() { launcherJarFile = systemHelper.getLauncherJarPath(); if (StringUtil.isBlank(launcherJarFile)) { - throw new SSCActionMessagesException( - "errors.no_launcher_applet_jar"); + throw new SSCActionMessagesException("errors.no_launcher_applet_jar"); } launcherJnlpFile = systemHelper.getLauncherJnlpPath(); if (StringUtil.isBlank(launcherJnlpFile)) { - throw new SSCActionMessagesException( - "errors.no_launcher_applet_jar"); + throw new SSCActionMessagesException("errors.no_launcher_applet_jar"); } String encoding = appletForm.encoding; diff --git a/src/main/java/org/codelibs/fess/action/IndexAction.java b/src/main/java/org/codelibs/fess/action/IndexAction.java index db3fd5807..51408b9a1 100644 --- a/src/main/java/org/codelibs/fess/action/IndexAction.java +++ b/src/main/java/org/codelibs/fess/action/IndexAction.java @@ -113,8 +113,7 @@ import org.slf4j.LoggerFactory; public class IndexAction { - private static final Logger logger = LoggerFactory - .getLogger(IndexAction.class); + private static final Logger logger = LoggerFactory.getLogger(IndexAction.class); private static final String REDIRECT_TO_INDEX = "index?redirect=true"; @@ -130,8 +129,7 @@ public class IndexAction { protected static final int DEFAULT_SPELLCHECK_PAGE_SIZE = 5; - protected static final Pattern FIELD_EXTRACTION_PATTERN = Pattern - .compile("^([a-zA-Z0-9_]+):.*"); + protected static final Pattern FIELD_EXTRACTION_PATTERN = Pattern.compile("^([a-zA-Z0-9_]+):.*"); @ActionForm @Resource @@ -238,10 +236,8 @@ public class IndexAction { @InitMethod public void init() { - searchLogSupport = Constants.TRUE.equals(crawlerProperties.getProperty( - Constants.SEARCH_LOG_PROPERTY, Constants.TRUE)); - favoriteSupport = Constants.TRUE.equals(crawlerProperties.getProperty( - Constants.USER_FAVORITE_PROPERTY, Constants.FALSE)); + searchLogSupport = Constants.TRUE.equals(crawlerProperties.getProperty(Constants.SEARCH_LOG_PROPERTY, Constants.TRUE)); + favoriteSupport = Constants.TRUE.equals(crawlerProperties.getProperty(Constants.USER_FAVORITE_PROPERTY, Constants.FALSE)); } public String getPagingQuery() { @@ -250,11 +246,8 @@ public class IndexAction { if (indexForm.additional != null) { final Set fieldSet = new HashSet(); for (final String additional : indexForm.additional) { - if (StringUtil.isNotBlank(additional) - && additional.length() < 1000 - && !hasFieldInQuery(fieldSet, additional)) { - buf.append("&additional=").append( - S2Functions.u(additional)); + if (StringUtil.isNotBlank(additional) && additional.length() < 1000 && !hasFieldInQuery(fieldSet, additional)) { + buf.append("&additional=").append(S2Functions.u(additional)); } } } @@ -272,8 +265,7 @@ public class IndexAction { langSet.clear(); break; } - final String normalizeLang = systemHelper - .normalizeLang(lang); + final String normalizeLang = systemHelper.normalizeLang(lang); if (normalizeLang != null) { langSet.add(normalizeLang); } @@ -286,15 +278,12 @@ public class IndexAction { } } if (!indexForm.fields.isEmpty()) { - for (final Map.Entry entry : indexForm.fields - .entrySet()) { + for (final Map.Entry entry : indexForm.fields.entrySet()) { final String[] values = entry.getValue(); if (values != null) { for (final String v : values) { if (StringUtil.isNotBlank(v)) { - buf.append("&fields.") - .append(S2Functions.u(entry.getKey())) - .append('=').append(S2Functions.u(v)); + buf.append("&fields.").append(S2Functions.u(entry.getKey())).append('=').append(S2Functions.u(v)); } } } @@ -317,12 +306,10 @@ public class IndexAction { } protected void searchAvailable() { - final String supportedSearch = crawlerProperties.getProperty( - Constants.SUPPORTED_SEARCH_FEATURE_PROPERTY, - Constants.SUPPORTED_SEARCH_WEB); + final String supportedSearch = + crawlerProperties.getProperty(Constants.SUPPORTED_SEARCH_FEATURE_PROPERTY, Constants.SUPPORTED_SEARCH_WEB); if (Constants.SUPPORTED_SEARCH_NONE.equals(supportedSearch)) { - throw new UnsupportedSearchException("A search is not supported: " - + RequestUtil.getRequest().getRequestURL()); + throw new UnsupportedSearchException("A search is not supported: " + RequestUtil.getRequest().getRequestURL()); } } @@ -331,8 +318,7 @@ public class IndexAction { if (StringUtil.isBlank(indexForm.query)) { try { - final String optionQuery = queryHelper - .buildOptionQuery(indexForm.options); + final String optionQuery = queryHelper.buildOptionQuery(indexForm.options); indexForm.query = optionQuery; } catch (final InvalidQueryException e) { if (logger.isDebugEnabled()) { @@ -359,24 +345,18 @@ public class IndexAction { public String cache() { Map doc = null; try { - doc = searchService.getDocument(fieldHelper.docIdField + ":" - + indexForm.docId, queryHelper.getCacheResponseFields(), - null); + doc = searchService.getDocument(fieldHelper.docIdField + ":" + indexForm.docId, queryHelper.getCacheResponseFields(), null); } catch (final Exception e) { logger.warn("Failed to request: " + indexForm.docId, e); } if (doc == null) { - errorMessage = MessageResourcesUtil.getMessage(RequestUtil - .getRequest().getLocale(), "errors.docid_not_found", - indexForm.docId); + errorMessage = MessageResourcesUtil.getMessage(RequestUtil.getRequest().getLocale(), "errors.docid_not_found", indexForm.docId); return "error.jsp"; } final String content = viewHelper.createCacheContent(doc, indexForm.hq); if (content == null) { - errorMessage = MessageResourcesUtil.getMessage(RequestUtil - .getRequest().getLocale(), "errors.docid_not_found", - indexForm.docId); + errorMessage = MessageResourcesUtil.getMessage(RequestUtil.getRequest().getLocale(), "errors.docid_not_found", indexForm.docId); return "error.jsp"; } ResponseUtil.write(content, "text/html", Constants.UTF_8); @@ -388,39 +368,33 @@ public class IndexAction { public String go() throws IOException { Map doc = null; try { - doc = searchService.getDocument(fieldHelper.docIdField + ":" - + indexForm.docId, queryHelper.getResponseFields(), - new String[] { fieldHelper.clickCountField }); + doc = + searchService.getDocument(fieldHelper.docIdField + ":" + indexForm.docId, queryHelper.getResponseFields(), + new String[] { fieldHelper.clickCountField }); } catch (final Exception e) { logger.warn("Failed to request: " + indexForm.docId, e); } if (doc == null) { - errorMessage = MessageResourcesUtil.getMessage(RequestUtil - .getRequest().getLocale(), "errors.docid_not_found", - indexForm.docId); + errorMessage = MessageResourcesUtil.getMessage(RequestUtil.getRequest().getLocale(), "errors.docid_not_found", indexForm.docId); return "error.jsp"; } final Object urlObj = doc.get(fieldHelper.urlField); if (urlObj == null) { - errorMessage = MessageResourcesUtil.getMessage(RequestUtil - .getRequest().getLocale(), "errors.document_not_found", - indexForm.docId); + errorMessage = + MessageResourcesUtil.getMessage(RequestUtil.getRequest().getLocale(), "errors.document_not_found", indexForm.docId); return "error.jsp"; } final String url = urlObj.toString(); - if (Constants.TRUE.equals(crawlerProperties.getProperty( - Constants.SEARCH_LOG_PROPERTY, Constants.TRUE))) { + if (Constants.TRUE.equals(crawlerProperties.getProperty(Constants.SEARCH_LOG_PROPERTY, Constants.TRUE))) { final String userSessionId = userInfoHelper.getUserCode(); if (userSessionId != null) { - final SearchLogHelper searchLogHelper = ComponentUtil - .getSearchLogHelper(); + final SearchLogHelper searchLogHelper = ComponentUtil.getSearchLogHelper(); final ClickLog clickLog = new ClickLog(); clickLog.setUrl(url); LocalDateTime now = systemHelper.getCurrentTime(); clickLog.setRequestedTime(now); - clickLog.setQueryRequestedTime(LocalDateTime.ofInstant( - Instant.ofEpochMilli(Long.parseLong(indexForm.rt)), + clickLog.setQueryRequestedTime(LocalDateTime.ofInstant(Instant.ofEpochMilli(Long.parseLong(indexForm.rt)), ZoneId.systemDefault())); clickLog.setUserSessionId(userSessionId); clickLog.setDocId(indexForm.docId); @@ -436,16 +410,14 @@ public class IndexAction { String hash; if (StringUtil.isNotBlank(indexForm.hash)) { - final String value = URLUtil - .decode(indexForm.hash, Constants.UTF_8); + final String value = URLUtil.decode(indexForm.hash, Constants.UTF_8); final StringBuilder buf = new StringBuilder(value.length() + 100); for (final char c : value.toCharArray()) { if (CharUtil.isUrlChar(c) || c == ' ') { buf.append(c); } else { try { - buf.append(URLEncoder.encode(String.valueOf(c), - Constants.UTF_8)); + buf.append(URLEncoder.encode(String.valueOf(c), Constants.UTF_8)); } catch (final UnsupportedEncodingException e) { // NOP } @@ -457,49 +429,40 @@ public class IndexAction { } if (isFileSystemPath(url)) { - if (Constants.TRUE.equals(crawlerProperties.getProperty( - Constants.SEARCH_FILE_PROXY_PROPERTY, Constants.TRUE))) { - final CrawlingConfigHelper crawlingConfigHelper = ComponentUtil - .getCrawlingConfigHelper(); + if (Constants.TRUE.equals(crawlerProperties.getProperty(Constants.SEARCH_FILE_PROXY_PROPERTY, Constants.TRUE))) { + final CrawlingConfigHelper crawlingConfigHelper = ComponentUtil.getCrawlingConfigHelper(); try { crawlingConfigHelper.writeContent(doc); return null; } catch (final Exception e) { logger.error("Failed to load: " + doc, e); - errorMessage = MessageResourcesUtil.getMessage(RequestUtil - .getRequest().getLocale(), - "errors.not_load_from_server", url); + errorMessage = + MessageResourcesUtil.getMessage(RequestUtil.getRequest().getLocale(), "errors.not_load_from_server", url); return "error.jsp"; } - } else if (Constants.TRUE.equals(crawlerProperties.getProperty( - Constants.SEARCH_DESKTOP_PROPERTY, Constants.FALSE))) { + } else if (Constants.TRUE.equals(crawlerProperties.getProperty(Constants.SEARCH_DESKTOP_PROPERTY, Constants.FALSE))) { final String path = url.replaceFirst("file:/+", "//"); final File file = new File(path); if (!file.exists()) { - errorMessage = MessageResourcesUtil.getMessage(RequestUtil - .getRequest().getLocale(), - "errors.not_found_on_file_system", url); + errorMessage = + MessageResourcesUtil.getMessage(RequestUtil.getRequest().getLocale(), "errors.not_found_on_file_system", url); return "error.jsp"; } final Desktop desktop = Desktop.getDesktop(); try { desktop.open(file); } catch (final Exception e) { - errorMessage = MessageResourcesUtil.getMessage(RequestUtil - .getRequest().getLocale(), - "errors.could_not_open_on_system", url); + errorMessage = + MessageResourcesUtil.getMessage(RequestUtil.getRequest().getLocale(), "errors.could_not_open_on_system", url); logger.warn("Could not open " + path, e); return "error.jsp"; } - ResponseUtil.getResponse().setStatus( - HttpServletResponse.SC_NO_CONTENT); + ResponseUtil.getResponse().setStatus(HttpServletResponse.SC_NO_CONTENT); return null; - } else if (Constants.TRUE.equals(crawlerProperties.getProperty( - Constants.SEARCH_FILE_LAUNCHER_PROPERTY, Constants.TRUE))) { + } else if (Constants.TRUE.equals(crawlerProperties.getProperty(Constants.SEARCH_FILE_LAUNCHER_PROPERTY, Constants.TRUE))) { ResponseUtil.getResponse().sendRedirect( - RequestUtil.getRequest().getContextPath() - + "/applet/launcher?uri=" + S2Functions.u(url)); + RequestUtil.getRequest().getContextPath() + "/applet/launcher?uri=" + S2Functions.u(url)); } else { ResponseUtil.getResponse().sendRedirect(url + hash); } @@ -542,19 +505,15 @@ public class IndexAction { OutputStream out = null; BufferedInputStream in = null; try { - final Map doc = searchService - .getDocument(fieldHelper.docIdField + ":" + indexForm.docId); - final String url = doc == null ? null : (String) doc - .get(fieldHelper.urlField); - if (StringUtil.isBlank(indexForm.queryId) - || StringUtil.isBlank(url) || screenShotManager == null) { + final Map doc = searchService.getDocument(fieldHelper.docIdField + ":" + indexForm.docId); + final String url = doc == null ? null : (String) doc.get(fieldHelper.urlField); + if (StringUtil.isBlank(indexForm.queryId) || StringUtil.isBlank(url) || screenShotManager == null) { // 404 response.sendError(HttpServletResponse.SC_NOT_FOUND); return null; } - final File screenShotFile = screenShotManager.getScreenShotFile( - indexForm.queryId, indexForm.docId); + final File screenShotFile = screenShotManager.getScreenShotFile(indexForm.queryId, indexForm.docId); if (screenShotFile == null) { // 404 response.sendError(HttpServletResponse.SC_NOT_FOUND); @@ -600,8 +559,7 @@ public class IndexAction { @Execute(validator = false) public String suggestApi() { - if (Constants.FALSE.equals(crawlerProperties.getProperty( - Constants.WEB_API_SUGGEST_PROPERTY, Constants.TRUE))) { + if (Constants.FALSE.equals(crawlerProperties.getProperty(Constants.WEB_API_SUGGEST_PROPERTY, Constants.TRUE))) { WebApiUtil.setError(9, "Unsupported operation."); return null; } @@ -649,9 +607,8 @@ public class IndexAction { roleSet = new HashSet<>(); } - final SuggestResponse suggestResponse = suggestService - .getSuggestResponse(indexForm.query, suggestFieldName, - labelList, new ArrayList(roleSet), num); + final SuggestResponse suggestResponse = + suggestService.getSuggestResponse(indexForm.query, suggestFieldName, labelList, new ArrayList(roleSet), num); if (!suggestResponse.isEmpty()) { suggestResultList.add(suggestResponse); @@ -666,8 +623,7 @@ public class IndexAction { @Execute(validator = false) public String spellCheckApi() { - if (Constants.FALSE.equals(crawlerProperties.getProperty( - Constants.WEB_API_SPELLCHECK_PROPERTY, Constants.TRUE))) { + if (Constants.FALSE.equals(crawlerProperties.getProperty(Constants.WEB_API_SPELLCHECK_PROPERTY, Constants.TRUE))) { WebApiUtil.setError(9, "Unsupported operation."); return null; } @@ -715,10 +671,9 @@ public class IndexAction { roleSet = new HashSet<>(); } - final SpellCheckResponse spellCheckResponse = suggestService - .getSpellCheckResponse(indexForm.query, - spellCheckFieldName, labelList, - new ArrayList(roleSet), num); + final SpellCheckResponse spellCheckResponse = + suggestService.getSpellCheckResponse(indexForm.query, spellCheckFieldName, labelList, new ArrayList(roleSet), + num); if (!spellCheckResponse.isEmpty()) { spellCheckResultList.add(spellCheckResponse); @@ -733,8 +688,7 @@ public class IndexAction { @Execute(validator = false) public String analysisApi() { - if (Constants.FALSE.equals(crawlerProperties.getProperty( - Constants.WEB_API_ANALYSIS_PROPERTY, Constants.TRUE))) { + if (Constants.FALSE.equals(crawlerProperties.getProperty(Constants.WEB_API_ANALYSIS_PROPERTY, Constants.TRUE))) { WebApiUtil.setError(9, "Unsupported operation."); return null; } @@ -751,8 +705,7 @@ public class IndexAction { try { final String[] fieldNames = indexForm.fn; - final FieldAnalysisResponse fieldAnalysis = searchService - .getFieldAnalysisResponse(fieldNames, indexForm.query); + final FieldAnalysisResponse fieldAnalysis = searchService.getFieldAnalysisResponse(fieldNames, indexForm.query); WebApiUtil.setObject("fieldAnalysis", fieldAnalysis); } catch (final Exception e) { WebApiUtil.setError(1, e); @@ -762,8 +715,7 @@ public class IndexAction { @Execute(validator = false) public String hotSearchWordApi() { - if (Constants.FALSE.equals(crawlerProperties.getProperty( - Constants.WEB_API_HOT_SEARCH_WORD_PROPERTY, Constants.TRUE))) { + if (Constants.FALSE.equals(crawlerProperties.getProperty(Constants.WEB_API_HOT_SEARCH_WORD_PROPERTY, Constants.TRUE))) { WebApiUtil.setError(9, "Unsupported operation."); return null; } @@ -773,24 +725,19 @@ public class IndexAction { range = Range.ENTIRE; } else if ("day".equals(indexForm.range) || "1".equals(indexForm.range)) { range = Range.ONE_DAY; - } else if ("week".equals(indexForm.range) - || "7".equals(indexForm.range)) { + } else if ("week".equals(indexForm.range) || "7".equals(indexForm.range)) { range = Range.ONE_DAY; - } else if ("month".equals(indexForm.range) - || "30".equals(indexForm.range)) { + } else if ("month".equals(indexForm.range) || "30".equals(indexForm.range)) { range = Range.ONE_DAY; - } else if ("year".equals(indexForm.range) - || "365".equals(indexForm.range)) { + } else if ("year".equals(indexForm.range) || "365".equals(indexForm.range)) { range = Range.ONE_DAY; } else { range = Range.ENTIRE; } try { - final HotSearchWordHelper hotSearchWordHelper = ComponentUtil - .getHotSearchWordHelper(); - final List hotSearchWordList = hotSearchWordHelper - .getHotSearchWordList(range); + final HotSearchWordHelper hotSearchWordHelper = ComponentUtil.getHotSearchWordHelper(); + final List hotSearchWordList = hotSearchWordHelper.getHotSearchWordList(range); WebApiUtil.setObject("hotSearchWordList", hotSearchWordList); } catch (final Exception e) { WebApiUtil.setError(1, e); @@ -801,20 +748,17 @@ public class IndexAction { @Execute(validator = false) public String favoriteApi() { - if (Constants.FALSE.equals(crawlerProperties.getProperty( - Constants.USER_FAVORITE_PROPERTY, Constants.FALSE))) { + if (Constants.FALSE.equals(crawlerProperties.getProperty(Constants.USER_FAVORITE_PROPERTY, Constants.FALSE))) { WebApiUtil.setError(9, "Unsupported operation."); return null; } try { - final Map doc = indexForm.docId == null ? null - : searchService.getDocument(fieldHelper.docIdField + ":" - + indexForm.docId, queryHelper.getResponseFields(), - new String[] { fieldHelper.favoriteCountField }); + final Map doc = + indexForm.docId == null ? null : searchService.getDocument(fieldHelper.docIdField + ":" + indexForm.docId, + queryHelper.getResponseFields(), new String[] { fieldHelper.favoriteCountField }); final String userCode = userInfoHelper.getUserCode(); - final String favoriteUrl = doc == null ? null : (String) doc - .get(fieldHelper.urlField); + final String favoriteUrl = doc == null ? null : (String) doc.get(fieldHelper.urlField); if (StringUtil.isBlank(userCode)) { WebApiUtil.setError(2, "No user session."); @@ -824,8 +768,7 @@ public class IndexAction { return null; } - final String[] docIds = userInfoHelper.getResultDocIds(URLDecoder - .decode(indexForm.queryId, Constants.UTF_8)); + final String[] docIds = userInfoHelper.getResultDocIds(URLDecoder.decode(indexForm.queryId, Constants.UTF_8)); if (docIds == null) { WebApiUtil.setError(6, "No searched urls."); return null; @@ -848,16 +791,12 @@ public class IndexAction { return null; } - final DocumentHelper documentHelper = ComponentUtil - .getDocumentHelper(); + final DocumentHelper documentHelper = ComponentUtil.getDocumentHelper(); final Object count = doc.get(fieldHelper.favoriteCountField); if (count instanceof Long) { - documentHelper.update(indexForm.docId, - fieldHelper.favoriteCountField, - ((Long) count).longValue() + 1); + documentHelper.update(indexForm.docId, fieldHelper.favoriteCountField, ((Long) count).longValue() + 1); } else { - WebApiUtil - .setError(7, "Failed to update count: " + favoriteUrl); + WebApiUtil.setError(7, "Failed to update count: " + favoriteUrl); return null; } } catch (final Exception e) { @@ -869,8 +808,7 @@ public class IndexAction { @Execute(validator = false) public String favoritesApi() { - if (Constants.FALSE.equals(crawlerProperties.getProperty( - Constants.USER_FAVORITE_PROPERTY, Constants.FALSE))) { + if (Constants.FALSE.equals(crawlerProperties.getProperty(Constants.USER_FAVORITE_PROPERTY, Constants.FALSE))) { WebApiUtil.setError(9, "Unsupported operation."); return null; } @@ -886,13 +824,10 @@ public class IndexAction { return null; } - final String[] docIds = userInfoHelper - .getResultDocIds(indexForm.queryId); - final List> docList = searchService - .getDocumentListByDocIds(docIds, - queryHelper.getResponseFields(), - new String[] { fieldHelper.favoriteCountField }, - getMaxPageSize()); + final String[] docIds = userInfoHelper.getResultDocIds(indexForm.queryId); + final List> docList = + searchService.getDocumentListByDocIds(docIds, queryHelper.getResponseFields(), + new String[] { fieldHelper.favoriteCountField }, getMaxPageSize()); List urlList = new ArrayList(docList.size()); for (final Map doc : docList) { final Object urlObj = doc.get(fieldHelper.urlField); @@ -947,16 +882,13 @@ public class IndexAction { if (indexForm.additional != null) { final Set fieldSet = new HashSet(); for (final String additional : indexForm.additional) { - if (StringUtil.isNotBlank(additional) - && additional.length() < 1000 - && !hasFieldInQuery(fieldSet, additional)) { + if (StringUtil.isNotBlank(additional) && additional.length() < 1000 && !hasFieldInQuery(fieldSet, additional)) { queryBuf.append(' ').append(additional); } } } if (!indexForm.fields.isEmpty()) { - for (final Map.Entry entry : indexForm.fields - .entrySet()) { + for (final Map.Entry entry : indexForm.fields.entrySet()) { final List valueList = new ArrayList(); final String[] values = entry.getValue(); if (values != null) { @@ -965,17 +897,14 @@ public class IndexAction { } } if (valueList.size() == 1) { - queryBuf.append(' ').append(entry.getKey()).append(":\"") - .append(valueList.get(0)).append('\"'); + queryBuf.append(' ').append(entry.getKey()).append(":\"").append(valueList.get(0)).append('\"'); } else if (valueList.size() > 1) { queryBuf.append(" ("); for (int i = 0; i < valueList.size(); i++) { if (i != 0) { queryBuf.append(" OR"); } - queryBuf.append(' ').append(entry.getKey()) - .append(":\"").append(valueList.get(i)) - .append('\"'); + queryBuf.append(' ').append(entry.getKey()).append(":\"").append(valueList.get(i)).append('\"'); } queryBuf.append(')'); } @@ -992,8 +921,7 @@ public class IndexAction { if (Constants.ALL_LANGUAGES.equalsIgnoreCase(lang)) { langSet.add(Constants.ALL_LANGUAGES); } else { - final String normalizeLang = systemHelper - .normalizeLang(lang); + final String normalizeLang = systemHelper.normalizeLang(lang); if (normalizeLang != null) { langSet.add(normalizeLang); } @@ -1007,16 +935,13 @@ public class IndexAction { langSet.remove(Constants.ALL_LANGUAGES); } appendLangQuery(queryBuf, langSet); - } else if (Constants.TRUE.equals(crawlerProperties.getProperty( - Constants.USE_BROWSER_LOCALE_FOR_SEARCH_PROPERTY, - Constants.FALSE))) { + } else if (Constants.TRUE.equals(crawlerProperties.getProperty(Constants.USE_BROWSER_LOCALE_FOR_SEARCH_PROPERTY, Constants.FALSE))) { final Set langSet = new HashSet<>(); final Enumeration locales = request.getLocales(); if (locales != null) { while (locales.hasMoreElements()) { final Locale locale = locales.nextElement(); - final String normalizeLang = systemHelper - .normalizeLang(locale.toString()); + final String normalizeLang = systemHelper.normalizeLang(locale.toString()); if (normalizeLang != null) { langSet.add(normalizeLang); } @@ -1047,16 +972,14 @@ public class IndexAction { final int pageStart = Integer.parseInt(indexForm.start); final int pageNum = Integer.parseInt(indexForm.num); try { - documentItems = searchService.getDocumentList(query, pageStart, - pageNum, indexForm.facet, indexForm.geo, indexForm.mlt, - queryHelper.getResponseFields(), - queryHelper.getResponseDocValuesFields()); + documentItems = + searchService.getDocumentList(query, pageStart, pageNum, indexForm.facet, indexForm.geo, indexForm.mlt, + queryHelper.getResponseFields(), queryHelper.getResponseDocValuesFields()); } catch (final SolrLibQueryException e) { if (logger.isDebugEnabled()) { logger.debug(e.getMessage(), e); } - throw new SSCActionMessagesException(e, - "errors.invalid_query_unknown"); + throw new SSCActionMessagesException(e, "errors.invalid_query_unknown"); } catch (final InvalidQueryException e) { if (logger.isDebugEnabled()) { logger.debug(e.getMessage(), e); @@ -1066,20 +989,17 @@ public class IndexAction { if (logger.isDebugEnabled()) { logger.debug(e.getMessage(), e); } - throw new SSCActionMessagesException(e, - "errors.result_size_exceeded"); + throw new SSCActionMessagesException(e, "errors.result_size_exceeded"); } // search final QueryResponseList queryResponseList = (QueryResponseList) documentItems; facetResponse = queryResponseList.getFacetResponse(); moreLikeThisResponse = queryResponseList.getMoreLikeThisResponse(); - final NumberFormat nf = NumberFormat.getInstance(RequestUtil - .getRequest().getLocale()); + final NumberFormat nf = NumberFormat.getInstance(RequestUtil.getRequest().getLocale()); nf.setMaximumIntegerDigits(2); nf.setMaximumFractionDigits(2); try { - execTime = nf - .format((double) queryResponseList.getExecTime() / 1000); + execTime = nf.format((double) queryResponseList.getExecTime() / 1000); } catch (final Exception e) { // ignore } @@ -1089,11 +1009,9 @@ public class IndexAction { // favorite if (favoriteSupport || screenShotManager != null) { - indexForm.queryId = userInfoHelper.generateQueryId(query, - documentItems); + indexForm.queryId = userInfoHelper.generateQueryId(query, documentItems); if (screenShotManager != null) { - screenShotManager - .storeRequest(indexForm.queryId, documentItems); + screenShotManager.storeRequest(indexForm.queryId, documentItems); screenShotSupport = true; } } @@ -1102,13 +1020,11 @@ public class IndexAction { if (searchLogSupport) { final LocalDateTime now = systemHelper.getCurrentTime(); - final SearchLogHelper searchLogHelper = ComponentUtil - .getSearchLogHelper(); + final SearchLogHelper searchLogHelper = ComponentUtil.getSearchLogHelper(); final SearchLog searchLog = new SearchLog(); String userCode = null; - if (Constants.TRUE.equals(crawlerProperties.getProperty( - Constants.USER_INFO_PROPERTY, Constants.TRUE))) { + if (Constants.TRUE.equals(crawlerProperties.getProperty(Constants.USER_INFO_PROPERTY, Constants.TRUE))) { userCode = userInfoHelper.getUserCode(); if (StringUtil.isNotBlank(userCode)) { final UserInfo userInfo = new UserInfo(); @@ -1120,58 +1036,48 @@ public class IndexAction { } searchLog.setHitCount(queryResponseList.getAllRecordCount()); - searchLog.setResponseTime(Integer.valueOf((int) queryResponseList - .getExecTime())); + searchLog.setResponseTime(Integer.valueOf((int) queryResponseList.getExecTime())); searchLog.setSearchWord(StringUtils.abbreviate(query, 1000)); - searchLog.setSearchQuery(StringUtils.abbreviate( - queryResponseList.getSearchQuery(), 1000)); - searchLog.setSolrQuery(StringUtils.abbreviate( - queryResponseList.getSolrQuery(), 1000)); + searchLog.setSearchQuery(StringUtils.abbreviate(queryResponseList.getSearchQuery(), 1000)); + searchLog.setSolrQuery(StringUtils.abbreviate(queryResponseList.getSolrQuery(), 1000)); searchLog.setRequestedTime(now); searchLog.setQueryOffset(pageStart); searchLog.setQueryPageSize(pageNum); - searchLog.setClientIp(StringUtils.abbreviate( - request.getRemoteAddr(), 50)); - searchLog.setReferer(StringUtils.abbreviate( - request.getHeader("referer"), 1000)); - searchLog.setUserAgent(StringUtils.abbreviate( - request.getHeader("user-agent"), 255)); + searchLog.setClientIp(StringUtils.abbreviate(request.getRemoteAddr(), 50)); + searchLog.setReferer(StringUtils.abbreviate(request.getHeader("referer"), 1000)); + searchLog.setUserAgent(StringUtils.abbreviate(request.getHeader("user-agent"), 255)); if (userCode != null) { searchLog.setUserSessionId(userCode); } - final Object accessType = request - .getAttribute(Constants.SEARCH_LOG_ACCESS_TYPE); + final Object accessType = request.getAttribute(Constants.SEARCH_LOG_ACCESS_TYPE); if (accessType instanceof CDef.AccessType) { switch ((CDef.AccessType) accessType) { - case Json: - searchLog.setAccessType_Json(); - searchLog.setAccessType_Others(); - searchLog.setAccessType_Xml(); - break; - case Xml: - searchLog.setAccessType_Xml(); - break; - case Others: - searchLog.setAccessType_Others(); - break; - default: - searchLog.setAccessType_Web(); - break; + case Json: + searchLog.setAccessType_Json(); + searchLog.setAccessType_Others(); + searchLog.setAccessType_Xml(); + break; + case Xml: + searchLog.setAccessType_Xml(); + break; + case Others: + searchLog.setAccessType_Others(); + break; + default: + searchLog.setAccessType_Web(); + break; } } else { searchLog.setAccessType_Web(); } @SuppressWarnings("unchecked") - final Map> fieldLogMap = (Map>) request - .getAttribute(Constants.FIELD_LOGS); + final Map> fieldLogMap = (Map>) request.getAttribute(Constants.FIELD_LOGS); if (fieldLogMap != null) { - for (final Map.Entry> logEntry : fieldLogMap - .entrySet()) { + for (final Map.Entry> logEntry : fieldLogMap.entrySet()) { for (final String value : logEntry.getValue()) { - searchLog.addSearchFieldLogValue(logEntry.getKey(), - StringUtils.abbreviate(value, 1000)); + searchLog.addSearchFieldLogValue(logEntry.getKey(), StringUtils.abbreviate(value, 1000)); } } } @@ -1179,8 +1085,7 @@ public class IndexAction { searchLogHelper.addSearchLog(searchLog); } - final String[] highlightQueries = (String[]) request - .getAttribute(Constants.HIGHLIGHT_QUERIES); + final String[] highlightQueries = (String[]) request.getAttribute(Constants.HIGHLIGHT_QUERIES); if (highlightQueries != null) { final StringBuilder buf = new StringBuilder(100); for (final String q : highlightQueries) { @@ -1190,20 +1095,16 @@ public class IndexAction { } Beans.copy(documentItems, this) - .includes("pageSize", "currentPageNumber", "allRecordCount", - "allPageCount", "existNextPage", "existPrevPage", - "currentStartRecordNumber", "currentEndRecordNumber", - "pageNumberList", "partialResults", "queryTime", - "searchTime").execute(); + .includes("pageSize", "currentPageNumber", "allRecordCount", "allPageCount", "existNextPage", "existPrevPage", + "currentStartRecordNumber", "currentEndRecordNumber", "pageNumberList", "partialResults", "queryTime", "searchTime") + .execute(); return query; } - private void appendLangQuery(final StringBuilder queryBuf, - final Set langSet) { + private void appendLangQuery(final StringBuilder queryBuf, final Set langSet) { if (langSet.size() == 1) { - queryBuf.append(' ').append(fieldHelper.langField).append(':') - .append(langSet.iterator().next()); + queryBuf.append(' ').append(fieldHelper.langField).append(':').append(langSet.iterator().next()); } else if (langSet.size() > 1) { boolean first = true; for (final String lang : langSet) { @@ -1282,8 +1183,7 @@ public class IndexAction { public String getDisplayQuery() { final StringBuilder buf = new StringBuilder(100); buf.append(indexForm.query); - if (!indexForm.fields.isEmpty() - && indexForm.fields.containsKey(LABEL_FIELD)) { + if (!indexForm.fields.isEmpty() && indexForm.fields.containsKey(LABEL_FIELD)) { final String[] values = indexForm.fields.get(LABEL_FIELD); final List labelList = new ArrayList(); if (values != null) { @@ -1308,23 +1208,19 @@ public class IndexAction { // label labelTypeItems = labelTypeHelper.getLabelTypeItemList(); - if (!labelTypeItems.isEmpty() - && !indexForm.fields.containsKey(LABEL_FIELD)) { - final String defaultLabelValue = crawlerProperties.getProperty( - Constants.DEFAULT_LABEL_VALUE_PROPERTY, StringUtil.EMPTY); + if (!labelTypeItems.isEmpty() && !indexForm.fields.containsKey(LABEL_FIELD)) { + final String defaultLabelValue = crawlerProperties.getProperty(Constants.DEFAULT_LABEL_VALUE_PROPERTY, StringUtil.EMPTY); if (StringUtil.isNotBlank(defaultLabelValue)) { final String[] values = defaultLabelValue.split("\n"); if (values != null && values.length > 0) { - final List list = new ArrayList( - values.length); + final List list = new ArrayList(values.length); for (final String value : values) { if (StringUtil.isNotBlank(value)) { list.add(value); } } if (!list.isEmpty()) { - indexForm.fields.put(LABEL_FIELD, - list.toArray(new String[list.size()])); + indexForm.fields.put(LABEL_FIELD, list.toArray(new String[list.size()])); } } } @@ -1333,8 +1229,7 @@ public class IndexAction { final Map labelMap = new LinkedHashMap(); if (!labelTypeItems.isEmpty()) { for (final Map map : labelTypeItems) { - labelMap.put(map.get(Constants.ITEM_VALUE), - map.get(Constants.ITEM_LABEL)); + labelMap.put(map.get(Constants.ITEM_VALUE), map.get(Constants.ITEM_LABEL)); } } request.setAttribute(Constants.LABEL_VALUE_MAP, labelMap); @@ -1342,8 +1237,7 @@ public class IndexAction { if (viewHelper.isUseSession()) { final HttpSession session = request.getSession(false); if (session != null) { - final Object resultsPerPage = session - .getAttribute(Constants.RESULTS_PER_PAGE); + final Object resultsPerPage = session.getAttribute(Constants.RESULTS_PER_PAGE); if (resultsPerPage != null) { indexForm.num = resultsPerPage.toString(); } @@ -1368,16 +1262,12 @@ public class IndexAction { } protected void buildInitParams() { - buildInitParamMap(viewHelper.getInitFacetParamMap(), - Constants.FACET_QUERY, Constants.FACET_FORM); - buildInitParamMap(viewHelper.getInitMltParamMap(), Constants.MLT_QUERY, - Constants.MLT_FORM); - buildInitParamMap(viewHelper.getInitGeoParamMap(), Constants.GEO_QUERY, - Constants.GEO_FORM); + buildInitParamMap(viewHelper.getInitFacetParamMap(), Constants.FACET_QUERY, Constants.FACET_FORM); + buildInitParamMap(viewHelper.getInitMltParamMap(), Constants.MLT_QUERY, Constants.MLT_FORM); + buildInitParamMap(viewHelper.getInitGeoParamMap(), Constants.GEO_QUERY, Constants.GEO_FORM); } - protected void buildInitParamMap(final Map paramMap, - final String queryKey, final String formKey) { + protected void buildInitParamMap(final Map paramMap, final String queryKey, final String formKey) { if (!paramMap.isEmpty()) { final StringBuilder queryBuf = new StringBuilder(100); final StringBuilder formBuf = new StringBuilder(100); @@ -1416,8 +1306,7 @@ public class IndexAction { } protected int getMaxPageSize() { - Object maxPageSize = crawlerProperties - .get(Constants.SEARCH_RESULT_MAX_PAGE_SIZE); + Object maxPageSize = crawlerProperties.get(Constants.SEARCH_RESULT_MAX_PAGE_SIZE); if (maxPageSize == null) { return MAX_PAGE_SIZE; } @@ -1436,8 +1325,7 @@ public class IndexAction { return viewHelper.getPagePath("common/help"); } - protected boolean hasFieldInQuery(final Set fieldSet, - final String query) { + protected boolean hasFieldInQuery(final Set fieldSet, final String query) { final Matcher matcher = FIELD_EXTRACTION_PATTERN.matcher(query); if (matcher.matches()) { final String field = matcher.replaceFirst("$1"); diff --git a/src/main/java/org/codelibs/fess/action/LoginAction.java b/src/main/java/org/codelibs/fess/action/LoginAction.java index 1f52a38ad..93a155a85 100644 --- a/src/main/java/org/codelibs/fess/action/LoginAction.java +++ b/src/main/java/org/codelibs/fess/action/LoginAction.java @@ -48,8 +48,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class LoginAction implements Serializable { - private static final Logger logger = LoggerFactory - .getLogger(LoginAction.class); + private static final Logger logger = LoggerFactory.getLogger(LoginAction.class); private static final long serialVersionUID = 1L; @@ -78,34 +77,28 @@ public class LoginAction implements Serializable { if ("logout".equals(loginForm.type)) { if (logger.isInfoEnabled()) { - logger.info("Invalidated session. The username is " - + request.getRemoteUser()); + logger.info("Invalidated session. The username is " + request.getRemoteUser()); } session.invalidate(); } String returnPath; if (StringUtil.isNotBlank(loginForm.returnPath)) { - final CachedCipher cipher = ComponentUtil - .getCipher(Constants.AUTH_CIPHER); + final CachedCipher cipher = ComponentUtil.getCipher(Constants.AUTH_CIPHER); if (cipher == null) { - throw new FessSystemException( - "A cipher for authentication is null. Please check a filter setting."); + throw new FessSystemException("A cipher for authentication is null. Please check a filter setting."); } final String value = cipher.decryptoText(loginForm.returnPath); final int idx = value.indexOf('|'); if (idx >= 0) { returnPath = value.substring(idx + 1); - RequestUtil.getRequest().getSession() - .setAttribute(Constants.RETURN_PATH, returnPath); + RequestUtil.getRequest().getSession().setAttribute(Constants.RETURN_PATH, returnPath); } else { // invalid returnPath - RequestUtil.getRequest().getSession() - .removeAttribute(Constants.RETURN_PATH); + RequestUtil.getRequest().getSession().removeAttribute(Constants.RETURN_PATH); } } else { - RequestUtil.getRequest().getSession() - .removeAttribute(Constants.RETURN_PATH); + RequestUtil.getRequest().getSession().removeAttribute(Constants.RETURN_PATH); } return "login?redirect=true"; @@ -137,8 +130,7 @@ public class LoginAction implements Serializable { session.setAttribute(SSCConstants.USER_INFO, loginInfo); String returnPath; - final Set authenticatedRoleList = systemHelper - .getAuthenticatedRoleSet(); + final Set authenticatedRoleList = systemHelper.getAuthenticatedRoleSet(); final Set roleSet = new HashSet<>(); for (final String role : authenticatedRoleList) { if (request.isUserInRole(role)) { @@ -162,8 +154,7 @@ public class LoginAction implements Serializable { ActivityUtil.login(request.getRemoteUser(), request); } else { if (logger.isWarnEnabled()) { - logger.warn("Login Failure: " + request.getRemoteUser() - + " does not have authenticated roles."); + logger.warn("Login Failure: " + request.getRemoteUser() + " does not have authenticated roles."); } // logout session.invalidate(); @@ -181,8 +172,7 @@ public class LoginAction implements Serializable { try { response.sendRedirect(response.encodeURL(returnPath)); } catch (final IOException e) { - throw new FessSystemException( - "Failed to redirect to " + returnPath, e); + throw new FessSystemException("Failed to redirect to " + returnPath, e); } } diff --git a/src/main/java/org/codelibs/fess/action/admin/BoostDocumentRuleAction.java b/src/main/java/org/codelibs/fess/action/admin/BoostDocumentRuleAction.java index dd03b153b..8915cb805 100644 --- a/src/main/java/org/codelibs/fess/action/admin/BoostDocumentRuleAction.java +++ b/src/main/java/org/codelibs/fess/action/admin/BoostDocumentRuleAction.java @@ -37,8 +37,7 @@ public class BoostDocumentRuleAction extends BsBoostDocumentRuleAction { private static final long serialVersionUID = 1L; - private static final Log log = LogFactory - .getLog(BoostDocumentRuleAction.class); + private static final Log log = LogFactory.getLog(BoostDocumentRuleAction.class); @Resource protected SystemHelper systemHelper; @@ -50,18 +49,13 @@ public class BoostDocumentRuleAction extends BsBoostDocumentRuleAction { @Override protected void loadBoostDocumentRule() { - final BoostDocumentRule boostDocumentRule = boostDocumentRuleService - .getBoostDocumentRule(createKeyMap()); + final BoostDocumentRule boostDocumentRule = boostDocumentRuleService.getBoostDocumentRule(createKeyMap()); if (boostDocumentRule == null) { // throw an exception - throw new SSCActionMessagesException( - "errors.crud_could_not_find_crud_table", - new Object[] { boostDocumentRuleForm.id }); + throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { boostDocumentRuleForm.id }); } - FessBeans.copy(boostDocumentRule, boostDocumentRuleForm) - .commonColumnDateConverter().excludes("searchParams", "mode") - .execute(); + FessBeans.copy(boostDocumentRule, boostDocumentRuleForm).commonColumnDateConverter().excludes("searchParams", "mode").execute(); } @Override @@ -70,13 +64,10 @@ public class BoostDocumentRuleAction extends BsBoostDocumentRuleAction { final String username = systemHelper.getUsername(); final LocalDateTime currentTime = systemHelper.getCurrentTime(); if (boostDocumentRuleForm.crudMode == CommonConstants.EDIT_MODE) { - boostDocumentRule = boostDocumentRuleService - .getBoostDocumentRule(createKeyMap()); + boostDocumentRule = boostDocumentRuleService.getBoostDocumentRule(createKeyMap()); if (boostDocumentRule == null) { // throw an exception - throw new SSCActionMessagesException( - "errors.crud_could_not_find_crud_table", - new Object[] { boostDocumentRuleForm.id }); + throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { boostDocumentRuleForm.id }); } } else { boostDocumentRule = new BoostDocumentRule(); @@ -85,8 +76,7 @@ public class BoostDocumentRuleAction extends BsBoostDocumentRuleAction { } boostDocumentRule.setUpdatedBy(username); boostDocumentRule.setUpdatedTime(currentTime); - FessBeans.copy(boostDocumentRuleForm, boostDocumentRule) - .excludesCommonColumns().execute(); + FessBeans.copy(boostDocumentRuleForm, boostDocumentRule).excludesCommonColumns().execute(); return boostDocumentRule; } @@ -95,19 +85,15 @@ public class BoostDocumentRuleAction extends BsBoostDocumentRuleAction { @Execute(validator = false, input = "error.jsp") public String delete() { if (boostDocumentRuleForm.crudMode != CommonConstants.DELETE_MODE) { - throw new SSCActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - boostDocumentRuleForm.crudMode }); + throw new SSCActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, + boostDocumentRuleForm.crudMode }); } try { - final BoostDocumentRule boostDocumentRule = boostDocumentRuleService - .getBoostDocumentRule(createKeyMap()); + final BoostDocumentRule boostDocumentRule = boostDocumentRuleService.getBoostDocumentRule(createKeyMap()); if (boostDocumentRule == null) { // throw an exception - throw new SSCActionMessagesException( - "errors.crud_could_not_find_crud_table", - new Object[] { boostDocumentRuleForm.id }); + throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { boostDocumentRuleForm.id }); } // boostDocumentRuleService.delete(boostDocumentRule); @@ -124,12 +110,10 @@ public class BoostDocumentRuleAction extends BsBoostDocumentRuleAction { throw e; } catch (final CrudMessageException e) { log.error(e.getMessage(), e); - throw new SSCActionMessagesException(e, e.getMessageId(), - e.getArgs()); + throw new SSCActionMessagesException(e, e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new SSCActionMessagesException(e, - "errors.crud_failed_to_delete_crud_table"); + throw new SSCActionMessagesException(e, "errors.crud_failed_to_delete_crud_table"); } } } diff --git a/src/main/java/org/codelibs/fess/action/admin/CrawlAction.java b/src/main/java/org/codelibs/fess/action/admin/CrawlAction.java index 409ac1695..47c1f8e6b 100644 --- a/src/main/java/org/codelibs/fess/action/admin/CrawlAction.java +++ b/src/main/java/org/codelibs/fess/action/admin/CrawlAction.java @@ -40,8 +40,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class CrawlAction implements Serializable { - private static final Logger logger = LoggerFactory - .getLogger(CrawlAction.class); + private static final Logger logger = LoggerFactory.getLogger(CrawlAction.class); private static final long serialVersionUID = 1L; @@ -60,61 +59,33 @@ public class CrawlAction implements Serializable { } protected String showIndex(final boolean redirect) { - crawlForm.diffCrawling = crawlerProperties.getProperty( - Constants.DIFF_CRAWLING_PROPERTY, Constants.TRUE); - crawlForm.useAclAsRole = crawlerProperties.getProperty( - Constants.USE_ACL_AS_ROLE, Constants.FALSE); - crawlForm.serverRotation = crawlerProperties.getProperty( - Constants.SERVER_ROTATION_PROPERTY, Constants.FALSE); - crawlForm.dayForCleanup = crawlerProperties.getProperty( - Constants.DAY_FOR_CLEANUP_PROPERTY, "1"); - crawlForm.crawlingThreadCount = crawlerProperties.getProperty( - Constants.CRAWLING_THREAD_COUNT_PROPERTY, "5"); - crawlForm.searchLog = crawlerProperties.getProperty( - Constants.SEARCH_LOG_PROPERTY, Constants.TRUE); - crawlForm.userInfo = crawlerProperties.getProperty( - Constants.USER_INFO_PROPERTY, Constants.TRUE); - crawlForm.userFavorite = crawlerProperties.getProperty( - Constants.USER_FAVORITE_PROPERTY, Constants.FALSE); - crawlForm.webApiXml = crawlerProperties.getProperty( - Constants.WEB_API_XML_PROPERTY, Constants.TRUE); - crawlForm.webApiJson = crawlerProperties.getProperty( - Constants.WEB_API_JSON_PROPERTY, Constants.TRUE); - crawlForm.defaultLabelValue = crawlerProperties.getProperty( - Constants.DEFAULT_LABEL_VALUE_PROPERTY, StringUtil.EMPTY); - crawlForm.appendQueryParameter = crawlerProperties.getProperty( - Constants.APPEND_QUERY_PARAMETER_PROPERTY, Constants.FALSE); - crawlForm.supportedSearch = crawlerProperties.getProperty( - Constants.SUPPORTED_SEARCH_FEATURE_PROPERTY, - Constants.SUPPORTED_SEARCH_WEB); - crawlForm.ignoreFailureType = crawlerProperties.getProperty( - Constants.IGNORE_FAILURE_TYPE_PROPERTY, - Constants.DEFAULT_IGNORE_FAILURE_TYPE); - crawlForm.failureCountThreshold = crawlerProperties.getProperty( - Constants.FAILURE_COUNT_THRESHOLD_PROPERTY, - Constants.DEFAULT_FAILURE_COUNT); - crawlForm.hotSearchWord = crawlerProperties.getProperty( - Constants.WEB_API_HOT_SEARCH_WORD_PROPERTY, Constants.TRUE); - crawlForm.csvFileEncoding = crawlerProperties.getProperty( - Constants.CSV_FILE_ENCODING_PROPERTY, Constants.UTF_8); - crawlForm.purgeSearchLogDay = crawlerProperties.getProperty( - Constants.PURGE_SEARCH_LOG_DAY_PROPERTY, - Constants.DEFAULT_PURGE_DAY); - crawlForm.purgeJobLogDay = crawlerProperties.getProperty( - Constants.PURGE_JOB_LOG_DAY_PROPERTY, - Constants.DEFAULT_PURGE_DAY); - crawlForm.purgeUserInfoDay = crawlerProperties.getProperty( - Constants.PURGE_USER_INFO_DAY_PROPERTY, - Constants.DEFAULT_PURGE_DAY); - crawlForm.purgeByBots = crawlerProperties.getProperty( - Constants.PURGE_BY_BOTS_PROPERTY, - Constants.DEFAULT_PURGE_BY_BOTS); - crawlForm.notificationTo = crawlerProperties.getProperty( - Constants.NOTIFICATION_TO_PROPERTY, StringUtil.EMPTY); - crawlForm.suggestSearchLog = crawlerProperties.getProperty( - Constants.SUGGEST_SEARCH_LOG_PROPERTY, Constants.TRUE); - crawlForm.purgeSuggestSearchLogDay = crawlerProperties.getProperty( - Constants.PURGE_SUGGEST_SEARCH_LOG_DAY_PROPERTY, "30"); + crawlForm.diffCrawling = crawlerProperties.getProperty(Constants.DIFF_CRAWLING_PROPERTY, Constants.TRUE); + crawlForm.useAclAsRole = crawlerProperties.getProperty(Constants.USE_ACL_AS_ROLE, Constants.FALSE); + crawlForm.serverRotation = crawlerProperties.getProperty(Constants.SERVER_ROTATION_PROPERTY, Constants.FALSE); + crawlForm.dayForCleanup = crawlerProperties.getProperty(Constants.DAY_FOR_CLEANUP_PROPERTY, "1"); + crawlForm.crawlingThreadCount = crawlerProperties.getProperty(Constants.CRAWLING_THREAD_COUNT_PROPERTY, "5"); + crawlForm.searchLog = crawlerProperties.getProperty(Constants.SEARCH_LOG_PROPERTY, Constants.TRUE); + crawlForm.userInfo = crawlerProperties.getProperty(Constants.USER_INFO_PROPERTY, Constants.TRUE); + crawlForm.userFavorite = crawlerProperties.getProperty(Constants.USER_FAVORITE_PROPERTY, Constants.FALSE); + crawlForm.webApiXml = crawlerProperties.getProperty(Constants.WEB_API_XML_PROPERTY, Constants.TRUE); + crawlForm.webApiJson = crawlerProperties.getProperty(Constants.WEB_API_JSON_PROPERTY, Constants.TRUE); + crawlForm.defaultLabelValue = crawlerProperties.getProperty(Constants.DEFAULT_LABEL_VALUE_PROPERTY, StringUtil.EMPTY); + crawlForm.appendQueryParameter = crawlerProperties.getProperty(Constants.APPEND_QUERY_PARAMETER_PROPERTY, Constants.FALSE); + crawlForm.supportedSearch = + crawlerProperties.getProperty(Constants.SUPPORTED_SEARCH_FEATURE_PROPERTY, Constants.SUPPORTED_SEARCH_WEB); + crawlForm.ignoreFailureType = + crawlerProperties.getProperty(Constants.IGNORE_FAILURE_TYPE_PROPERTY, Constants.DEFAULT_IGNORE_FAILURE_TYPE); + crawlForm.failureCountThreshold = + crawlerProperties.getProperty(Constants.FAILURE_COUNT_THRESHOLD_PROPERTY, Constants.DEFAULT_FAILURE_COUNT); + crawlForm.hotSearchWord = crawlerProperties.getProperty(Constants.WEB_API_HOT_SEARCH_WORD_PROPERTY, Constants.TRUE); + crawlForm.csvFileEncoding = crawlerProperties.getProperty(Constants.CSV_FILE_ENCODING_PROPERTY, Constants.UTF_8); + crawlForm.purgeSearchLogDay = crawlerProperties.getProperty(Constants.PURGE_SEARCH_LOG_DAY_PROPERTY, Constants.DEFAULT_PURGE_DAY); + crawlForm.purgeJobLogDay = crawlerProperties.getProperty(Constants.PURGE_JOB_LOG_DAY_PROPERTY, Constants.DEFAULT_PURGE_DAY); + crawlForm.purgeUserInfoDay = crawlerProperties.getProperty(Constants.PURGE_USER_INFO_DAY_PROPERTY, Constants.DEFAULT_PURGE_DAY); + crawlForm.purgeByBots = crawlerProperties.getProperty(Constants.PURGE_BY_BOTS_PROPERTY, Constants.DEFAULT_PURGE_BY_BOTS); + crawlForm.notificationTo = crawlerProperties.getProperty(Constants.NOTIFICATION_TO_PROPERTY, StringUtil.EMPTY); + crawlForm.suggestSearchLog = crawlerProperties.getProperty(Constants.SUGGEST_SEARCH_LOG_PROPERTY, Constants.TRUE); + crawlForm.purgeSuggestSearchLogDay = crawlerProperties.getProperty(Constants.PURGE_SUGGEST_SEARCH_LOG_DAY_PROPERTY, "30"); if (redirect) { return "index?redirect=true"; } else { @@ -131,120 +102,52 @@ public class CrawlAction implements Serializable { @Token(save = false, validate = true) @Execute(validator = true, input = "index.jsp") public String update() { - crawlerProperties - .setProperty( - Constants.DIFF_CRAWLING_PROPERTY, - crawlForm.diffCrawling != null - && Constants.ON - .equalsIgnoreCase(crawlForm.diffCrawling) ? Constants.TRUE - : Constants.FALSE); - crawlerProperties - .setProperty( - Constants.USE_ACL_AS_ROLE, - crawlForm.useAclAsRole != null - && Constants.ON - .equalsIgnoreCase(crawlForm.useAclAsRole) ? Constants.TRUE - : Constants.FALSE); - crawlerProperties - .setProperty( - Constants.SERVER_ROTATION_PROPERTY, - crawlForm.serverRotation != null - && Constants.ON - .equalsIgnoreCase(crawlForm.serverRotation) ? Constants.TRUE - : Constants.FALSE); - crawlerProperties.setProperty(Constants.DAY_FOR_CLEANUP_PROPERTY, - crawlForm.dayForCleanup); - crawlerProperties.setProperty(Constants.CRAWLING_THREAD_COUNT_PROPERTY, - crawlForm.crawlingThreadCount); - crawlerProperties - .setProperty( - Constants.SEARCH_LOG_PROPERTY, - crawlForm.searchLog != null - && Constants.ON - .equalsIgnoreCase(crawlForm.searchLog) ? Constants.TRUE - : Constants.FALSE); - crawlerProperties - .setProperty( - Constants.USER_INFO_PROPERTY, - crawlForm.userInfo != null - && Constants.ON - .equalsIgnoreCase(crawlForm.userInfo) ? Constants.TRUE - : Constants.FALSE); - crawlerProperties - .setProperty( - Constants.USER_FAVORITE_PROPERTY, - crawlForm.userFavorite != null - && Constants.ON - .equalsIgnoreCase(crawlForm.userFavorite) ? Constants.TRUE - : Constants.FALSE); - crawlerProperties - .setProperty( - Constants.WEB_API_XML_PROPERTY, - crawlForm.webApiXml != null - && Constants.ON - .equalsIgnoreCase(crawlForm.webApiXml) ? Constants.TRUE - : Constants.FALSE); - crawlerProperties - .setProperty( - Constants.WEB_API_JSON_PROPERTY, - crawlForm.webApiJson != null - && Constants.ON - .equalsIgnoreCase(crawlForm.webApiJson) ? Constants.TRUE - : Constants.FALSE); - crawlerProperties.setProperty(Constants.DEFAULT_LABEL_VALUE_PROPERTY, - crawlForm.defaultLabelValue); - crawlerProperties - .setProperty( - Constants.APPEND_QUERY_PARAMETER_PROPERTY, - crawlForm.appendQueryParameter != null - && Constants.ON - .equalsIgnoreCase(crawlForm.appendQueryParameter) ? Constants.TRUE - : Constants.FALSE); - crawlerProperties.setProperty( - Constants.SUPPORTED_SEARCH_FEATURE_PROPERTY, - crawlForm.supportedSearch); - crawlerProperties.setProperty(Constants.IGNORE_FAILURE_TYPE_PROPERTY, - crawlForm.ignoreFailureType); - crawlerProperties.setProperty( - Constants.FAILURE_COUNT_THRESHOLD_PROPERTY, - crawlForm.failureCountThreshold); - crawlerProperties - .setProperty( - Constants.WEB_API_HOT_SEARCH_WORD_PROPERTY, - crawlForm.hotSearchWord != null - && Constants.ON - .equalsIgnoreCase(crawlForm.hotSearchWord) ? Constants.TRUE - : Constants.FALSE); - crawlerProperties.setProperty(Constants.CSV_FILE_ENCODING_PROPERTY, - crawlForm.csvFileEncoding); - crawlerProperties.setProperty(Constants.PURGE_SEARCH_LOG_DAY_PROPERTY, - crawlForm.purgeSearchLogDay); - crawlerProperties.setProperty(Constants.PURGE_JOB_LOG_DAY_PROPERTY, - crawlForm.purgeJobLogDay); - crawlerProperties.setProperty(Constants.PURGE_USER_INFO_DAY_PROPERTY, - crawlForm.purgeUserInfoDay); - crawlerProperties.setProperty(Constants.PURGE_BY_BOTS_PROPERTY, - crawlForm.purgeByBots); - crawlerProperties.setProperty(Constants.NOTIFICATION_TO_PROPERTY, - crawlForm.notificationTo); - crawlerProperties - .setProperty( - Constants.SUGGEST_SEARCH_LOG_PROPERTY, - crawlForm.suggestSearchLog != null - && Constants.ON - .equalsIgnoreCase(crawlForm.suggestSearchLog) ? Constants.TRUE - : Constants.FALSE); - crawlerProperties.setProperty( - Constants.PURGE_SUGGEST_SEARCH_LOG_DAY_PROPERTY, - crawlForm.purgeSuggestSearchLogDay); + crawlerProperties.setProperty(Constants.DIFF_CRAWLING_PROPERTY, + crawlForm.diffCrawling != null && Constants.ON.equalsIgnoreCase(crawlForm.diffCrawling) ? Constants.TRUE : Constants.FALSE); + crawlerProperties.setProperty(Constants.USE_ACL_AS_ROLE, + crawlForm.useAclAsRole != null && Constants.ON.equalsIgnoreCase(crawlForm.useAclAsRole) ? Constants.TRUE : Constants.FALSE); + crawlerProperties.setProperty(Constants.SERVER_ROTATION_PROPERTY, + crawlForm.serverRotation != null && Constants.ON.equalsIgnoreCase(crawlForm.serverRotation) ? Constants.TRUE + : Constants.FALSE); + crawlerProperties.setProperty(Constants.DAY_FOR_CLEANUP_PROPERTY, crawlForm.dayForCleanup); + crawlerProperties.setProperty(Constants.CRAWLING_THREAD_COUNT_PROPERTY, crawlForm.crawlingThreadCount); + crawlerProperties.setProperty(Constants.SEARCH_LOG_PROPERTY, + crawlForm.searchLog != null && Constants.ON.equalsIgnoreCase(crawlForm.searchLog) ? Constants.TRUE : Constants.FALSE); + crawlerProperties.setProperty(Constants.USER_INFO_PROPERTY, + crawlForm.userInfo != null && Constants.ON.equalsIgnoreCase(crawlForm.userInfo) ? Constants.TRUE : Constants.FALSE); + crawlerProperties.setProperty(Constants.USER_FAVORITE_PROPERTY, + crawlForm.userFavorite != null && Constants.ON.equalsIgnoreCase(crawlForm.userFavorite) ? Constants.TRUE : Constants.FALSE); + crawlerProperties.setProperty(Constants.WEB_API_XML_PROPERTY, + crawlForm.webApiXml != null && Constants.ON.equalsIgnoreCase(crawlForm.webApiXml) ? Constants.TRUE : Constants.FALSE); + crawlerProperties.setProperty(Constants.WEB_API_JSON_PROPERTY, + crawlForm.webApiJson != null && Constants.ON.equalsIgnoreCase(crawlForm.webApiJson) ? Constants.TRUE : Constants.FALSE); + crawlerProperties.setProperty(Constants.DEFAULT_LABEL_VALUE_PROPERTY, crawlForm.defaultLabelValue); + crawlerProperties.setProperty(Constants.APPEND_QUERY_PARAMETER_PROPERTY, + crawlForm.appendQueryParameter != null && Constants.ON.equalsIgnoreCase(crawlForm.appendQueryParameter) ? Constants.TRUE + : Constants.FALSE); + crawlerProperties.setProperty(Constants.SUPPORTED_SEARCH_FEATURE_PROPERTY, crawlForm.supportedSearch); + crawlerProperties.setProperty(Constants.IGNORE_FAILURE_TYPE_PROPERTY, crawlForm.ignoreFailureType); + crawlerProperties.setProperty(Constants.FAILURE_COUNT_THRESHOLD_PROPERTY, crawlForm.failureCountThreshold); + crawlerProperties.setProperty(Constants.WEB_API_HOT_SEARCH_WORD_PROPERTY, + crawlForm.hotSearchWord != null && Constants.ON.equalsIgnoreCase(crawlForm.hotSearchWord) ? Constants.TRUE + : Constants.FALSE); + crawlerProperties.setProperty(Constants.CSV_FILE_ENCODING_PROPERTY, crawlForm.csvFileEncoding); + crawlerProperties.setProperty(Constants.PURGE_SEARCH_LOG_DAY_PROPERTY, crawlForm.purgeSearchLogDay); + crawlerProperties.setProperty(Constants.PURGE_JOB_LOG_DAY_PROPERTY, crawlForm.purgeJobLogDay); + crawlerProperties.setProperty(Constants.PURGE_USER_INFO_DAY_PROPERTY, crawlForm.purgeUserInfoDay); + crawlerProperties.setProperty(Constants.PURGE_BY_BOTS_PROPERTY, crawlForm.purgeByBots); + crawlerProperties.setProperty(Constants.NOTIFICATION_TO_PROPERTY, crawlForm.notificationTo); + crawlerProperties.setProperty(Constants.SUGGEST_SEARCH_LOG_PROPERTY, + crawlForm.suggestSearchLog != null && Constants.ON.equalsIgnoreCase(crawlForm.suggestSearchLog) ? Constants.TRUE + : Constants.FALSE); + crawlerProperties.setProperty(Constants.PURGE_SUGGEST_SEARCH_LOG_DAY_PROPERTY, crawlForm.purgeSuggestSearchLogDay); try { crawlerProperties.store(); SAStrutsUtil.addSessionMessage("success.update_crawler_params"); return showIndex(true); } catch (final Exception e) { logger.error("Failed to update crawler parameters.", e); - throw new SSCActionMessagesException(e, - "errors.failed_to_update_crawler_params", e); + throw new SSCActionMessagesException(e, "errors.failed_to_update_crawler_params", e); } } @@ -262,17 +165,14 @@ public class CrawlAction implements Serializable { public List> getSupportedSearchItems() { final List> list = new ArrayList>(); - list.add(createItem(MessageResourcesUtil.getMessage(RequestUtil - .getRequest().getLocale(), "labels.supported_search_web"), + list.add(createItem(MessageResourcesUtil.getMessage(RequestUtil.getRequest().getLocale(), "labels.supported_search_web"), Constants.SUPPORTED_SEARCH_WEB)); - list.add(createItem(MessageResourcesUtil.getMessage(RequestUtil - .getRequest().getLocale(), "labels.supported_search_none"), + list.add(createItem(MessageResourcesUtil.getMessage(RequestUtil.getRequest().getLocale(), "labels.supported_search_none"), Constants.SUPPORTED_SEARCH_NONE)); return list; } - private Map createItem(final String label, - final String value) { + private Map createItem(final String label, final String value) { final Map map = new HashMap(); map.put(Constants.ITEM_LABEL, label); map.put(Constants.ITEM_VALUE, value); diff --git a/src/main/java/org/codelibs/fess/action/admin/CrawlingSessionAction.java b/src/main/java/org/codelibs/fess/action/admin/CrawlingSessionAction.java index a7763a96d..a66cb065c 100644 --- a/src/main/java/org/codelibs/fess/action/admin/CrawlingSessionAction.java +++ b/src/main/java/org/codelibs/fess/action/admin/CrawlingSessionAction.java @@ -44,16 +44,14 @@ public class CrawlingSessionAction extends BsCrawlingSessionAction { public List getCrawlingSessionInfoItems() { if (crawlingSessionForm.id != null) { - return crawlingSessionService.getCrawlingSessionInfoList(Long - .parseLong(crawlingSessionForm.id)); + return crawlingSessionService.getCrawlingSessionInfoList(Long.parseLong(crawlingSessionForm.id)); } return Collections.emptyList(); } @Execute(validator = false, input = "error.jsp") public String deleteall() { - crawlingSessionService.deleteOldSessions(jobHelper - .getRunningSessionIdSet()); + crawlingSessionService.deleteOldSessions(jobHelper.getRunningSessionIdSet()); SAStrutsUtil.addSessionMessage("success.crawling_session_delete_all"); return displayList(true); } diff --git a/src/main/java/org/codelibs/fess/action/admin/DataAction.java b/src/main/java/org/codelibs/fess/action/admin/DataAction.java index 689b188cb..82ee24ebc 100644 --- a/src/main/java/org/codelibs/fess/action/admin/DataAction.java +++ b/src/main/java/org/codelibs/fess/action/admin/DataAction.java @@ -60,8 +60,7 @@ public class DataAction implements Serializable { private static final long serialVersionUID = 1L; - private static final Logger logger = LoggerFactory - .getLogger(DataAction.class); + private static final Logger logger = LoggerFactory.getLogger(DataAction.class); @Resource @ActionForm @@ -98,8 +97,7 @@ public class DataAction implements Serializable { @Execute(validator = false) public String download() { - final DateFormat df = new SimpleDateFormat( - CoreLibConstants.DATE_FORMAT_DIGIT_ONLY); + final DateFormat df = new SimpleDateFormat(CoreLibConstants.DATE_FORMAT_DIGIT_ONLY); final StringBuilder buf = new StringBuilder(); buf.append("backup-"); buf.append(df.format(new Date())); @@ -107,8 +105,7 @@ public class DataAction implements Serializable { final HttpServletResponse response = ResponseUtil.getResponse(); response.setContentType("application/octet-stream"); - response.setHeader("Content-Disposition", "attachment; filename=\"" - + buf.toString() + "\""); + response.setHeader("Content-Disposition", "attachment; filename=\"" + buf.toString() + "\""); try { final ServletOutputStream sos = response.getOutputStream(); @@ -121,15 +118,13 @@ public class DataAction implements Serializable { return null; } catch (final Exception e) { logger.error("Failed to export data.", e); - throw new SSCActionMessagesException(e, - "errors.failed_to_export_data"); + throw new SSCActionMessagesException(e, "errors.failed_to_export_data"); } } @Execute(validator = false) public String downloadCrawlingSession() { - final DateFormat df = new SimpleDateFormat( - CoreLibConstants.DATE_FORMAT_DIGIT_ONLY); + final DateFormat df = new SimpleDateFormat(CoreLibConstants.DATE_FORMAT_DIGIT_ONLY); final StringBuilder buf = new StringBuilder(); buf.append("backup-cs-"); buf.append(df.format(new Date())); @@ -137,22 +132,19 @@ public class DataAction implements Serializable { final HttpServletResponse response = ResponseUtil.getResponse(); response.setContentType("application/octet-stream"); - response.setHeader("Content-Disposition", "attachment; filename=\"" - + buf.toString() + "\""); + response.setHeader("Content-Disposition", "attachment; filename=\"" + buf.toString() + "\""); Writer writer = null; try { - writer = new BufferedWriter(new OutputStreamWriter( - response.getOutputStream(), crawlerProperties.getProperty( - Constants.CSV_FILE_ENCODING_PROPERTY, - Constants.UTF_8))); + writer = + new BufferedWriter(new OutputStreamWriter(response.getOutputStream(), crawlerProperties.getProperty( + Constants.CSV_FILE_ENCODING_PROPERTY, Constants.UTF_8))); crawlingSessionService.exportCsv(writer); writer.flush(); return null; } catch (final Exception e) { logger.error("Failed to export data.", e); - throw new SSCActionMessagesException(e, - "errors.failed_to_export_data"); + throw new SSCActionMessagesException(e, "errors.failed_to_export_data"); } finally { IOUtils.closeQuietly(writer); } @@ -160,8 +152,7 @@ public class DataAction implements Serializable { @Execute(validator = false) public String downloadSearchLog() { - final DateFormat df = new SimpleDateFormat( - CoreLibConstants.DATE_FORMAT_DIGIT_ONLY); + final DateFormat df = new SimpleDateFormat(CoreLibConstants.DATE_FORMAT_DIGIT_ONLY); final StringBuilder buf = new StringBuilder(); buf.append("backup-sl-"); buf.append(df.format(new Date())); @@ -169,22 +160,19 @@ public class DataAction implements Serializable { final HttpServletResponse response = ResponseUtil.getResponse(); response.setContentType("application/octet-stream"); - response.setHeader("Content-Disposition", "attachment; filename=\"" - + buf.toString() + "\""); + response.setHeader("Content-Disposition", "attachment; filename=\"" + buf.toString() + "\""); Writer writer = null; try { - writer = new BufferedWriter(new OutputStreamWriter( - response.getOutputStream(), crawlerProperties.getProperty( - Constants.CSV_FILE_ENCODING_PROPERTY, - Constants.UTF_8))); + writer = + new BufferedWriter(new OutputStreamWriter(response.getOutputStream(), crawlerProperties.getProperty( + Constants.CSV_FILE_ENCODING_PROPERTY, Constants.UTF_8))); searchLogService.exportCsv(writer); writer.flush(); return null; } catch (final Exception e) { logger.error("Failed to export data.", e); - throw new SSCActionMessagesException(e, - "errors.failed_to_export_data"); + throw new SSCActionMessagesException(e, "errors.failed_to_export_data"); } finally { IOUtils.closeQuietly(writer); } @@ -192,8 +180,7 @@ public class DataAction implements Serializable { @Execute(validator = false) public String downloadClickLog() { - final DateFormat df = new SimpleDateFormat( - CoreLibConstants.DATE_FORMAT_DIGIT_ONLY); + final DateFormat df = new SimpleDateFormat(CoreLibConstants.DATE_FORMAT_DIGIT_ONLY); final StringBuilder buf = new StringBuilder(); buf.append("backup-cl-"); buf.append(df.format(new Date())); @@ -201,22 +188,19 @@ public class DataAction implements Serializable { final HttpServletResponse response = ResponseUtil.getResponse(); response.setContentType("application/octet-stream"); - response.setHeader("Content-Disposition", "attachment; filename=\"" - + buf.toString() + "\""); + response.setHeader("Content-Disposition", "attachment; filename=\"" + buf.toString() + "\""); Writer writer = null; try { - writer = new BufferedWriter(new OutputStreamWriter( - response.getOutputStream(), crawlerProperties.getProperty( - Constants.CSV_FILE_ENCODING_PROPERTY, - Constants.UTF_8))); + writer = + new BufferedWriter(new OutputStreamWriter(response.getOutputStream(), crawlerProperties.getProperty( + Constants.CSV_FILE_ENCODING_PROPERTY, Constants.UTF_8))); clickLogService.exportCsv(writer); writer.flush(); return null; } catch (final Exception e) { logger.error("Failed to export data.", e); - throw new SSCActionMessagesException(e, - "errors.failed_to_export_data"); + throw new SSCActionMessagesException(e, "errors.failed_to_export_data"); } finally { IOUtils.closeQuietly(writer); } @@ -227,16 +211,13 @@ public class DataAction implements Serializable { final String fileName = dataForm.uploadedFile.getFileName(); if (fileName.endsWith(".xml")) { try { - databaseService.importData( - dataForm.uploadedFile.getInputStream(), - dataForm.overwrite != null - && "on".equalsIgnoreCase(dataForm.overwrite)); + databaseService.importData(dataForm.uploadedFile.getInputStream(), + dataForm.overwrite != null && "on".equalsIgnoreCase(dataForm.overwrite)); SAStrutsUtil.addSessionMessage("success.importing_data"); return "index?redirect=true"; } catch (final Exception e) { logger.error("Failed to import data.", e); - throw new SSCActionMessagesException(e, - "errors.failed_to_import_data"); + throw new SSCActionMessagesException(e, "errors.failed_to_import_data"); } } else if (fileName.endsWith(".csv")) { BufferedInputStream is = null; @@ -245,8 +226,7 @@ public class DataAction implements Serializable { final byte[] b = new byte[20]; try { tempFile = File.createTempFile("fess-import-", ".csv"); - is = new BufferedInputStream( - dataForm.uploadedFile.getInputStream()); + is = new BufferedInputStream(dataForm.uploadedFile.getInputStream()); is.mark(20); if (is.read(b, 0, 20) <= 0) { throw new FessSystemException("no import data."); @@ -256,12 +236,10 @@ public class DataAction implements Serializable { StreamUtil.drain(is, fos); } catch (final Exception e) { if (tempFile != null && !tempFile.delete()) { - logger.warn("Could not delete " - + tempFile.getAbsolutePath()); + logger.warn("Could not delete " + tempFile.getAbsolutePath()); } logger.error("Failed to import data.", e); - throw new SSCActionMessagesException(e, - "errors.failed_to_import_data"); + throw new SSCActionMessagesException(e, "errors.failed_to_import_data"); } finally { IOUtils.closeQuietly(is); IOUtils.closeQuietly(fos); @@ -270,22 +248,17 @@ public class DataAction implements Serializable { final File oFile = tempFile; try { final String head = new String(b, Constants.UTF_8); - if (!head.startsWith("SessionId,") - && !head.startsWith("SearchWord,") - && !head.startsWith("SearchId,")) { + if (!head.startsWith("SessionId,") && !head.startsWith("SearchWord,") && !head.startsWith("SearchId,")) { logger.error("Unknown file: " + dataForm.uploadedFile); - throw new SSCActionMessagesException( - "errors.unknown_import_file"); + throw new SSCActionMessagesException("errors.unknown_import_file"); } - final String enc = crawlerProperties.getProperty( - Constants.CSV_FILE_ENCODING_PROPERTY, Constants.UTF_8); + final String enc = crawlerProperties.getProperty(Constants.CSV_FILE_ENCODING_PROPERTY, Constants.UTF_8); new Thread(new Runnable() { @Override public void run() { Reader reader = null; try { - reader = new BufferedReader(new InputStreamReader( - new FileInputStream(oFile), enc)); + reader = new BufferedReader(new InputStreamReader(new FileInputStream(oFile), enc)); if (head.startsWith("SessionId,")) { // Crawling Session crawlingSessionService.importCsv(reader); @@ -298,12 +271,10 @@ public class DataAction implements Serializable { } } catch (final Exception e) { logger.error("Failed to import data.", e); - throw new FessSystemException( - "Failed to import data.", e); + throw new FessSystemException("Failed to import data.", e); } finally { if (!oFile.delete()) { - logger.warn("Could not delete " - + oFile.getAbsolutePath()); + logger.warn("Could not delete " + oFile.getAbsolutePath()); } IOUtils.closeQuietly(reader); } @@ -319,8 +290,7 @@ public class DataAction implements Serializable { logger.warn("Could not delete " + oFile.getAbsolutePath()); } logger.error("Failed to import data.", e); - throw new SSCActionMessagesException(e, - "errors.failed_to_import_data"); + throw new SSCActionMessagesException(e, "errors.failed_to_import_data"); } } diff --git a/src/main/java/org/codelibs/fess/action/admin/DataCrawlingConfigAction.java b/src/main/java/org/codelibs/fess/action/admin/DataCrawlingConfigAction.java index 350ae0c8f..8eb1f3ea1 100644 --- a/src/main/java/org/codelibs/fess/action/admin/DataCrawlingConfigAction.java +++ b/src/main/java/org/codelibs/fess/action/admin/DataCrawlingConfigAction.java @@ -48,8 +48,7 @@ public class DataCrawlingConfigAction extends BsDataCrawlingConfigAction { private static final long serialVersionUID = 1L; - private static final Log log = LogFactory - .getLog(DataCrawlingConfigAction.class); + private static final Log log = LogFactory.getLog(DataCrawlingConfigAction.class); @Resource protected RoleTypeService roleTypeService; @@ -73,24 +72,17 @@ public class DataCrawlingConfigAction extends BsDataCrawlingConfigAction { @Override protected void loadDataCrawlingConfig() { - final DataCrawlingConfig dataCrawlingConfig = dataCrawlingConfigService - .getDataCrawlingConfig(createKeyMap()); + final DataCrawlingConfig dataCrawlingConfig = dataCrawlingConfigService.getDataCrawlingConfig(createKeyMap()); if (dataCrawlingConfig == null) { // throw an exception - throw new SSCActionMessagesException( - "errors.crud_could_not_find_crud_table", - new Object[] { dataCrawlingConfigForm.id }); + throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { dataCrawlingConfigForm.id }); } - FessBeans.copy(dataCrawlingConfig, dataCrawlingConfigForm) - .commonColumnDateConverter().excludes("searchParams", "mode") - .execute(); + FessBeans.copy(dataCrawlingConfig, dataCrawlingConfigForm).commonColumnDateConverter().excludes("searchParams", "mode").execute(); // normalize boost - if (dataCrawlingConfigForm.boost != null - && dataCrawlingConfigForm.boost.indexOf('.') > 0) { - dataCrawlingConfigForm.boost = dataCrawlingConfigForm.boost - .substring(0, dataCrawlingConfigForm.boost.indexOf('.')); + if (dataCrawlingConfigForm.boost != null && dataCrawlingConfigForm.boost.indexOf('.') > 0) { + dataCrawlingConfigForm.boost = dataCrawlingConfigForm.boost.substring(0, dataCrawlingConfigForm.boost.indexOf('.')); } } @@ -100,13 +92,10 @@ public class DataCrawlingConfigAction extends BsDataCrawlingConfigAction { final String username = systemHelper.getUsername(); final LocalDateTime currentTime = systemHelper.getCurrentTime(); if (dataCrawlingConfigForm.crudMode == CommonConstants.EDIT_MODE) { - dataCrawlingConfig = dataCrawlingConfigService - .getDataCrawlingConfig(createKeyMap()); + dataCrawlingConfig = dataCrawlingConfigService.getDataCrawlingConfig(createKeyMap()); if (dataCrawlingConfig == null) { // throw an exception - throw new SSCActionMessagesException( - "errors.crud_could_not_find_crud_table", - new Object[] { dataCrawlingConfigForm.id }); + throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { dataCrawlingConfigForm.id }); } } else { dataCrawlingConfig = new DataCrawlingConfig(); @@ -115,8 +104,7 @@ public class DataCrawlingConfigAction extends BsDataCrawlingConfigAction { } dataCrawlingConfig.setUpdatedBy(username); dataCrawlingConfig.setUpdatedTime(currentTime); - FessBeans.copy(dataCrawlingConfigForm, dataCrawlingConfig) - .excludesCommonColumns().execute(); + FessBeans.copy(dataCrawlingConfigForm, dataCrawlingConfig).excludesCommonColumns().execute(); return dataCrawlingConfig; } @@ -125,23 +113,18 @@ public class DataCrawlingConfigAction extends BsDataCrawlingConfigAction { @Execute(validator = false, input = "error.jsp") public String delete() { if (dataCrawlingConfigForm.crudMode != CommonConstants.DELETE_MODE) { - throw new SSCActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - dataCrawlingConfigForm.crudMode }); + throw new SSCActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, + dataCrawlingConfigForm.crudMode }); } try { - final DataCrawlingConfig dataCrawlingConfig = dataCrawlingConfigService - .getDataCrawlingConfig(createKeyMap()); + final DataCrawlingConfig dataCrawlingConfig = dataCrawlingConfigService.getDataCrawlingConfig(createKeyMap()); if (dataCrawlingConfig == null) { // throw an exception - throw new SSCActionMessagesException( - "errors.crud_could_not_find_crud_table", - new Object[] { dataCrawlingConfigForm.id }); + throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { dataCrawlingConfigForm.id }); } - failureUrlService - .deleteByConfigId(dataCrawlingConfig.getConfigId()); + failureUrlService.deleteByConfigId(dataCrawlingConfig.getConfigId()); //dataCrawlingConfigService.delete(dataCrawlingConfig); final String username = systemHelper.getUsername(); @@ -157,12 +140,10 @@ public class DataCrawlingConfigAction extends BsDataCrawlingConfigAction { throw e; } catch (final CrudMessageException e) { log.error(e.getMessage(), e); - throw new SSCActionMessagesException(e, e.getMessageId(), - e.getArgs()); + throw new SSCActionMessagesException(e, e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new SSCActionMessagesException(e, - "errors.crud_failed_to_delete_crud_table"); + throw new SSCActionMessagesException(e, "errors.crud_failed_to_delete_crud_table"); } } @@ -175,8 +156,7 @@ public class DataCrawlingConfigAction extends BsDataCrawlingConfigAction { } public List> getHandlerNameItems() { - final List dataStoreNameList = dataStoreFactory - .getDataStoreNameList(); + final List dataStoreNameList = dataStoreFactory.getDataStoreNameList(); final List> itemList = new ArrayList>(); for (final String name : dataStoreNameList) { final Map map = new HashMap(); diff --git a/src/main/java/org/codelibs/fess/action/admin/DesignAction.java b/src/main/java/org/codelibs/fess/action/admin/DesignAction.java index dfd6b7d6e..365273a19 100644 --- a/src/main/java/org/codelibs/fess/action/admin/DesignAction.java +++ b/src/main/java/org/codelibs/fess/action/admin/DesignAction.java @@ -49,8 +49,7 @@ import org.slf4j.LoggerFactory; public class DesignAction implements Serializable { private static final long serialVersionUID = 1L; - private static final Logger logger = LoggerFactory - .getLogger(DesignAction.class); + private static final Logger logger = LoggerFactory.getLogger(DesignAction.class); @ActionForm @Resource @@ -116,54 +115,41 @@ public class DesignAction implements Serializable { fileName = fileName.substring(pos + 1); } } catch (final Exception e) { - throw new SSCActionMessagesException(e, - "errors.design_file_name_is_invalid"); + throw new SSCActionMessagesException(e, "errors.design_file_name_is_invalid"); } } if (StringUtil.isBlank(fileName)) { - throw new SSCActionMessagesException( - "errors.design_file_name_is_not_found"); + throw new SSCActionMessagesException("errors.design_file_name_is_not_found"); } String baseDir = null; // normalize filename - if (checkFileType(fileName, - systemHelper.getSupportedUploadedMediaExtentions()) - && checkFileType(uploadedFileName, - systemHelper.getSupportedUploadedMediaExtentions())) { + if (checkFileType(fileName, systemHelper.getSupportedUploadedMediaExtentions()) + && checkFileType(uploadedFileName, systemHelper.getSupportedUploadedMediaExtentions())) { baseDir = "/images/"; - } else if (checkFileType(fileName, - systemHelper.getSupportedUploadedCssExtentions()) - && checkFileType(uploadedFileName, - systemHelper.getSupportedUploadedCssExtentions())) { + } else if (checkFileType(fileName, systemHelper.getSupportedUploadedCssExtentions()) + && checkFileType(uploadedFileName, systemHelper.getSupportedUploadedCssExtentions())) { baseDir = "/css/"; - } else if (checkFileType(fileName, - systemHelper.getSupportedUploadedJSExtentions()) - && checkFileType(uploadedFileName, - systemHelper.getSupportedUploadedJSExtentions())) { + } else if (checkFileType(fileName, systemHelper.getSupportedUploadedJSExtentions()) + && checkFileType(uploadedFileName, systemHelper.getSupportedUploadedJSExtentions())) { baseDir = "/js/"; } else { - throw new SSCActionMessagesException( - "errors.design_file_is_unsupported_type"); + throw new SSCActionMessagesException("errors.design_file_is_unsupported_type"); } - final File uploadFile = new File(ServletContextUtil.getServletContext() - .getRealPath(baseDir + fileName)); + final File uploadFile = new File(ServletContextUtil.getServletContext().getRealPath(baseDir + fileName)); final File parentFile = uploadFile.getParentFile(); if (!parentFile.exists() && !parentFile.mkdirs()) { logger.warn("Could not create " + parentFile.getAbsolutePath()); } try { - FileUtil.write(uploadFile.getAbsolutePath(), - designForm.designFile.getFileData()); - SAStrutsUtil.addSessionMessage("success.upload_design_file", - fileName); + FileUtil.write(uploadFile.getAbsolutePath(), designForm.designFile.getFileData()); + SAStrutsUtil.addSessionMessage("success.upload_design_file", fileName); return "index?redirect=true"; } catch (final Exception e) { logger.error("Failed to write an image file.", e); - throw new SSCActionMessagesException(e, - "errors.failed_to_write_design_image_file"); + throw new SSCActionMessagesException(e, "errors.failed_to_write_design_image_file"); } } @@ -176,8 +162,7 @@ public class DesignAction implements Serializable { final File jspFile = getJspFile(jspType); try { - designForm.content = new String(FileUtil.getBytes(jspFile), - Constants.UTF_8); + designForm.content = new String(FileUtil.getBytes(jspFile), Constants.UTF_8); } catch (final UnsupportedEncodingException e) { throw new FessSystemException("Invalid encoding", e); } @@ -193,8 +178,7 @@ public class DesignAction implements Serializable { final File jspFile = getJspFile(jspType); try { - designForm.content = new String(FileUtil.getBytes(jspFile), - Constants.UTF_8); + designForm.content = new String(FileUtil.getBytes(jspFile), Constants.UTF_8); } catch (final UnsupportedEncodingException e) { throw new FessSystemException("Invalid encoding", e); } @@ -214,15 +198,12 @@ public class DesignAction implements Serializable { } try { - FileUtil.write(jspFile.getAbsolutePath(), - designForm.content.getBytes(Constants.UTF_8)); - SAStrutsUtil.addSessionMessage("success.update_design_jsp_file", - systemHelper.getDesignJspFileName(designForm.fileName)); + FileUtil.write(jspFile.getAbsolutePath(), designForm.content.getBytes(Constants.UTF_8)); + SAStrutsUtil.addSessionMessage("success.update_design_jsp_file", systemHelper.getDesignJspFileName(designForm.fileName)); return "index?redirect=true"; } catch (final Exception e) { logger.error("Failed to update " + designForm.fileName, e); - throw new SSCActionMessagesException(e, - "errors.failed_to_update_jsp_file"); + throw new SSCActionMessagesException(e, "errors.failed_to_update_jsp_file"); } } @@ -232,8 +213,7 @@ public class DesignAction implements Serializable { final File file = getTargetFile(); if (file == null) { - throw new SSCActionMessagesException( - "errors.target_file_does_not_exist", designForm.fileName); + throw new SSCActionMessagesException("errors.target_file_does_not_exist", designForm.fileName); } BufferedInputStream bis = null; @@ -242,8 +222,7 @@ public class DesignAction implements Serializable { ResponseUtil.download(file.getName(), bis); } catch (final Exception e) { logger.error("Failed to download " + file.getAbsolutePath(), e); - throw new SSCActionMessagesException(e, - "errors.failed_to_download_file", designForm.fileName); + throw new SSCActionMessagesException(e, "errors.failed_to_download_file", designForm.fileName); } finally { IOUtils.closeQuietly(bis); } @@ -257,49 +236,39 @@ public class DesignAction implements Serializable { final File file = getTargetFile(); if (file == null) { - throw new SSCActionMessagesException( - "errors.target_file_does_not_exist", designForm.fileName); + throw new SSCActionMessagesException("errors.target_file_does_not_exist", designForm.fileName); } if (file.delete()) { - SAStrutsUtil.addSessionMessage("success.delete_file", - designForm.fileName); + SAStrutsUtil.addSessionMessage("success.delete_file", designForm.fileName); return "index?redirect=true"; } else { logger.error("Failed to delete " + file.getAbsolutePath()); - throw new SSCActionMessagesException( - "errors.failed_to_delete_file", designForm.fileName); + throw new SSCActionMessagesException("errors.failed_to_delete_file", designForm.fileName); } } private File getJspFile(final String jspType) { - final String jspFileName = systemHelper - .getDesignJspFileName(designForm.fileName); + final String jspFileName = systemHelper.getDesignJspFileName(designForm.fileName); if (jspFileName == null) { - throw new SSCActionMessagesException( - "errors.invalid_design_jsp_file_name"); + throw new SSCActionMessagesException("errors.invalid_design_jsp_file_name"); } - final File jspFile = new File(ServletContextUtil.getServletContext() - .getRealPath("/WEB-INF/" + jspType + "/" + jspFileName)); + final File jspFile = new File(ServletContextUtil.getServletContext().getRealPath("/WEB-INF/" + jspType + "/" + jspFileName)); if (jspFile == null || !jspFile.exists()) { - throw new SSCActionMessagesException( - "errors.design_jsp_file_does_not_exist"); + throw new SSCActionMessagesException("errors.design_jsp_file_does_not_exist"); } return jspFile; } private void checkEditorStatus() { - if (Constants.FALSE.equals(crawlerProperties.getProperty( - Constants.WEB_DESIGN_EDITOR_PROPERTY, Constants.TRUE))) { + if (Constants.FALSE.equals(crawlerProperties.getProperty(Constants.WEB_DESIGN_EDITOR_PROPERTY, Constants.TRUE))) { editable = false; - throw new SSCActionMessagesException( - "errors.design_editor_disabled"); + throw new SSCActionMessagesException("errors.design_editor_disabled"); } } private void loadFileNameItems() { - final File baseDir = new File(ServletContextUtil.getServletContext() - .getRealPath("/")); + final File baseDir = new File(ServletContextUtil.getServletContext().getRealPath("/")); fileNameItems = new ArrayList(); final List fileList = getAccessibleFileList(baseDir); final int length = baseDir.getAbsolutePath().length(); @@ -310,20 +279,15 @@ public class DesignAction implements Serializable { private List getAccessibleFileList(final File baseDir) { final List fileList = new ArrayList(); - fileList.addAll(FileUtils.listFiles(new File(baseDir, "images"), - systemHelper.getSupportedUploadedMediaExtentions(), true)); - fileList.addAll(FileUtils.listFiles(new File(baseDir, "css"), - systemHelper.getSupportedUploadedCssExtentions(), true)); - fileList.addAll(FileUtils.listFiles(new File(baseDir, "js"), - systemHelper.getSupportedUploadedJSExtentions(), true)); + fileList.addAll(FileUtils.listFiles(new File(baseDir, "images"), systemHelper.getSupportedUploadedMediaExtentions(), true)); + fileList.addAll(FileUtils.listFiles(new File(baseDir, "css"), systemHelper.getSupportedUploadedCssExtentions(), true)); + fileList.addAll(FileUtils.listFiles(new File(baseDir, "js"), systemHelper.getSupportedUploadedJSExtentions(), true)); return fileList; } private File getTargetFile() { - final File baseDir = new File(ServletContextUtil.getServletContext() - .getRealPath("/")); - final File targetFile = new File(ServletContextUtil.getServletContext() - .getRealPath(designForm.fileName)); + final File baseDir = new File(ServletContextUtil.getServletContext().getRealPath("/")); + final File targetFile = new File(ServletContextUtil.getServletContext().getRealPath(designForm.fileName)); final List fileList = getAccessibleFileList(baseDir); boolean exist = false; for (final File file : fileList) { diff --git a/src/main/java/org/codelibs/fess/action/admin/DocumentAction.java b/src/main/java/org/codelibs/fess/action/admin/DocumentAction.java index 4afa6cd53..d1e6d5717 100644 --- a/src/main/java/org/codelibs/fess/action/admin/DocumentAction.java +++ b/src/main/java/org/codelibs/fess/action/admin/DocumentAction.java @@ -63,8 +63,7 @@ public class DocumentAction implements Serializable { private static final String SUGGEST_TYPE_CONTENT = "content"; - private static final Logger logger = LoggerFactory - .getLogger(DocumentAction.class); + private static final Logger logger = LoggerFactory.getLogger(DocumentAction.class); private static final long serialVersionUID = 1L; @@ -102,8 +101,7 @@ public class DocumentAction implements Serializable { protected String showIndex(final boolean redirect) { final Map groupPropMap = new HashMap(); for (final String groupName : solrGroupManager.getSolrGroupNames()) { - final DynamicProperties props = ComponentUtil - .getSolrGroupProperties(groupName); + final DynamicProperties props = ComponentUtil.getSolrGroupProperties(groupName); if (props != null) { groupPropMap.put(groupName, props); } @@ -118,16 +116,12 @@ public class DocumentAction implements Serializable { map.put("serverName", names[1]); final DynamicProperties props = groupPropMap.get(names[0]); if (props != null) { - String status = props - .getProperty(StatusPolicyImpl.STATUS_PREFIX - + names[1]); + String status = props.getProperty(StatusPolicyImpl.STATUS_PREFIX + names[1]); if (StringUtil.isBlank(status)) { status = StatusPolicyImpl.ACTIVE; } map.put("status", status); - String index = props - .getProperty(StatusPolicyImpl.INDEX_PREFIX - + names[1]); + String index = props.getProperty(StatusPolicyImpl.INDEX_PREFIX + names[1]); if (StringUtil.isBlank(index)) { index = StatusPolicyImpl.READY; } @@ -143,24 +137,18 @@ public class DocumentAction implements Serializable { suggestDocumentNums = getSuggestDocumentNum(); // select group status - documentForm.currentServerForSelect = solrProperties - .getProperty(SolrLibConstants.SELECT_GROUP); - final SolrGroup selectSolrGroup = solrGroupManager - .getSolrGroup(documentForm.currentServerForSelect); - if (selectSolrGroup != null - && selectSolrGroup.isActive(QueryType.QUERY)) { + documentForm.currentServerForSelect = solrProperties.getProperty(SolrLibConstants.SELECT_GROUP); + final SolrGroup selectSolrGroup = solrGroupManager.getSolrGroup(documentForm.currentServerForSelect); + if (selectSolrGroup != null && selectSolrGroup.isActive(QueryType.QUERY)) { documentForm.currentServerStatusForSelect = Constants.ACTIVE; } else { documentForm.currentServerStatusForSelect = Constants.INACTIVE; } // update group status - documentForm.currentServerForUpdate = solrProperties - .getProperty(SolrLibConstants.SELECT_GROUP); - final SolrGroup updateSolrGroup = solrGroupManager - .getSolrGroup(documentForm.currentServerForUpdate); - if (updateSolrGroup != null - && updateSolrGroup.isActive(QueryType.QUERY)) { + documentForm.currentServerForUpdate = solrProperties.getProperty(SolrLibConstants.SELECT_GROUP); + final SolrGroup updateSolrGroup = solrGroupManager.getSolrGroup(documentForm.currentServerForUpdate); + if (updateSolrGroup != null && updateSolrGroup.isActive(QueryType.QUERY)) { documentForm.currentServerStatusForUpdate = Constants.ACTIVE; } else { documentForm.currentServerStatusForUpdate = Constants.INACTIVE; @@ -183,14 +171,11 @@ public class DocumentAction implements Serializable { @Execute(validator = true, input = "index") public String commit() { if (jobHelper.isCrawlProcessRunning()) { - throw new SSCActionMessagesException( - "errors.failed_to_start_solr_process_because_of_running"); + throw new SSCActionMessagesException("errors.failed_to_start_solr_process_because_of_running"); } - final SolrGroup solrGroup = solrGroupManager - .getSolrGroup(documentForm.groupName); + final SolrGroup solrGroup = solrGroupManager.getSolrGroup(documentForm.groupName); if (solrGroup == null) { - throw new SSCActionMessagesException( - "errors.failed_to_commit_solr_index"); + throw new SSCActionMessagesException("errors.failed_to_commit_solr_index"); } else { final Thread thread = new Thread(new Runnable() { @Override @@ -200,20 +185,16 @@ public class DocumentAction implements Serializable { try { systemHelper.updateStatus(solrGroup, QueryType.ADD); solrGroup.commit(true, true, false, true); - systemHelper.updateStatus(solrGroup, - QueryType.COMMIT); + systemHelper.updateStatus(solrGroup, QueryType.COMMIT); if (logger.isInfoEnabled()) { - logger.info("[EXEC TIME] index commit time: " - + (System.currentTimeMillis() - execTime) - + "ms"); + logger.info("[EXEC TIME] index commit time: " + (System.currentTimeMillis() - execTime) + "ms"); } } catch (final Exception e) { logger.error("Failed to commit index.", e); } } else { if (logger.isInfoEnabled()) { - logger.info("could not start index cleanup process" - + " because of running solr process."); + logger.info("could not start index cleanup process" + " because of running solr process."); } } } @@ -228,14 +209,11 @@ public class DocumentAction implements Serializable { @Execute(validator = true, input = "index") public String optimize() { if (jobHelper.isCrawlProcessRunning()) { - throw new SSCActionMessagesException( - "errors.failed_to_start_solr_process_because_of_running"); + throw new SSCActionMessagesException("errors.failed_to_start_solr_process_because_of_running"); } - final SolrGroup solrGroup = solrGroupManager - .getSolrGroup(documentForm.groupName); + final SolrGroup solrGroup = solrGroupManager.getSolrGroup(documentForm.groupName); if (solrGroup == null) { - throw new SSCActionMessagesException( - "errors.failed_to_optimize_solr_index"); + throw new SSCActionMessagesException("errors.failed_to_optimize_solr_index"); } else { final Thread thread = new Thread(new Runnable() { @Override @@ -245,20 +223,16 @@ public class DocumentAction implements Serializable { try { systemHelper.updateStatus(solrGroup, QueryType.ADD); solrGroup.optimize(); - systemHelper.updateStatus(solrGroup, - QueryType.OPTIMIZE); + systemHelper.updateStatus(solrGroup, QueryType.OPTIMIZE); if (logger.isInfoEnabled()) { - logger.info("[EXEC TIME] index optimize time: " - + (System.currentTimeMillis() - execTime) - + "ms"); + logger.info("[EXEC TIME] index optimize time: " + (System.currentTimeMillis() - execTime) + "ms"); } } catch (final Exception e) { logger.error("Failed to optimize index.", e); } } else { if (logger.isInfoEnabled()) { - logger.info("could not start index cleanup process" - + " because of running solr process."); + logger.info("could not start index cleanup process" + " because of running solr process."); } } } @@ -276,8 +250,7 @@ public class DocumentAction implements Serializable { if ("*".equals(documentForm.sessionId)) { deleteQuery = "*:*"; } else { - deleteQuery = fieldHelper.segmentField + ":" - + documentForm.sessionId; + deleteQuery = fieldHelper.segmentField + ":" + documentForm.sessionId; } return deleteByQuery(deleteQuery); } @@ -285,31 +258,25 @@ public class DocumentAction implements Serializable { @Token(save = false, validate = true) @Execute(validator = true, input = "index") public String confirmByUrl() { - final String confirmQuery = fieldHelper.urlField + ":\"" - + documentForm.deleteUrl + "\""; - return "/admin/searchList/search?query=" + S2Functions.u(confirmQuery) - + "&redirect=true"; + final String confirmQuery = fieldHelper.urlField + ":\"" + documentForm.deleteUrl + "\""; + return "/admin/searchList/search?query=" + S2Functions.u(confirmQuery) + "&redirect=true"; } @Token(save = false, validate = true) @Execute(validator = true, input = "index") public String deleteByUrl() { final String deleteUrl = documentForm.deleteUrl; - final String deleteQuery = fieldHelper.urlField + ":\"" + deleteUrl - + "\""; + final String deleteQuery = fieldHelper.urlField + ":\"" + deleteUrl + "\""; return deleteByQuery(deleteQuery); } private String deleteByQuery(final String deleteQuery) { if (jobHelper.isCrawlProcessRunning()) { - throw new SSCActionMessagesException( - "errors.failed_to_start_solr_process_because_of_running"); + throw new SSCActionMessagesException("errors.failed_to_start_solr_process_because_of_running"); } - final SolrGroup solrGroup = solrGroupManager - .getSolrGroup(documentForm.groupName); + final SolrGroup solrGroup = solrGroupManager.getSolrGroup(documentForm.groupName); if (solrGroup == null) { - throw new SSCActionMessagesException( - "errors.failed_to_delete_solr_index"); + throw new SSCActionMessagesException("errors.failed_to_delete_solr_index"); } else { final Thread thread = new Thread(new Runnable() { @Override @@ -317,25 +284,19 @@ public class DocumentAction implements Serializable { if (!jobHelper.isCrawlProcessRunning()) { final long execTime = System.currentTimeMillis(); try { - systemHelper.updateStatus(solrGroup, - QueryType.DELETE); + systemHelper.updateStatus(solrGroup, QueryType.DELETE); solrGroup.deleteByQuery(deleteQuery); solrGroup.commit(true, true, false, true); - systemHelper.updateStatus(solrGroup, - QueryType.OPTIMIZE); + systemHelper.updateStatus(solrGroup, QueryType.OPTIMIZE); if (logger.isInfoEnabled()) { - logger.info("[EXEC TIME] index cleanup time: " - + (System.currentTimeMillis() - execTime) - + "ms"); + logger.info("[EXEC TIME] index cleanup time: " + (System.currentTimeMillis() - execTime) + "ms"); } } catch (final Exception e) { - logger.error("Failed to delete index (query=" - + deleteQuery + ").", e); + logger.error("Failed to delete index (query=" + deleteQuery + ").", e); } } else { if (logger.isInfoEnabled()) { - logger.info("could not start index cleanup process" - + " because of running solr process."); + logger.info("could not start index cleanup process" + " because of running solr process."); } } } @@ -363,8 +324,7 @@ public class DocumentAction implements Serializable { return groupActionItems; } - protected SessionIdList> getSessionIdList( - final String groupName) { + protected SessionIdList> getSessionIdList(final String groupName) { final SessionIdList> sessionIdList = new SessionIdList>(); SolrGroup serverGroup; @@ -389,10 +349,8 @@ public class DocumentAction implements Serializable { final List facetEntries = facet.getValues(); if (facetEntries != null) { for (final FacetField.Count fcount : facetEntries) { - final Map map = new HashMap( - 3); - map.put("label", - fcount.getName() + " (" + fcount.getCount() + ")"); + final Map map = new HashMap(3); + map.put("label", fcount.getName() + " (" + fcount.getCount() + ")"); map.put("value", fcount.getName()); map.put("count", Long.toString(fcount.getCount())); sessionIdList.add(map); @@ -414,8 +372,7 @@ public class DocumentAction implements Serializable { protected Map getSuggestDocumentNum() { final Map map = new HashMap(); map.put(SUGGEST_TYPE_CONTENT, suggestService.getContentDocumentNum()); - map.put(SUGGEST_TYPE_SEARCH_LOG, - suggestService.getSearchLogDocumentNum()); + map.put(SUGGEST_TYPE_SEARCH_LOG, suggestService.getSearchLogDocumentNum()); map.put(SUGGEST_TYPE_ALL, suggestService.getDocumentNum()); return map; } @@ -423,18 +380,14 @@ public class DocumentAction implements Serializable { @Token(save = false, validate = true) @Execute(validator = true, input = "index") public String deleteSuggest() { - final SuggestSolrServer suggestSolrServer = suggestService - .getSuggestSolrServer(); + final SuggestSolrServer suggestSolrServer = suggestService.getSuggestSolrServer(); final String query; if (SUGGEST_TYPE_CONTENT.equals(documentForm.deleteSuggestType)) { - query = "*:* NOT " + SuggestConstants.SuggestFieldNames.SEGMENT - + ":" + SuggestConstants.SEGMENT_ELEVATE + " NOT " - + SuggestConstants.SuggestFieldNames.SEGMENT + ":" - + SuggestConstants.SEGMENT_QUERY; - } else if (SUGGEST_TYPE_SEARCH_LOG - .equals(documentForm.deleteSuggestType)) { - query = SuggestConstants.SuggestFieldNames.SEGMENT + ":" - + SuggestConstants.SEGMENT_QUERY; + query = + "*:* NOT " + SuggestConstants.SuggestFieldNames.SEGMENT + ":" + SuggestConstants.SEGMENT_ELEVATE + " NOT " + + SuggestConstants.SuggestFieldNames.SEGMENT + ":" + SuggestConstants.SEGMENT_QUERY; + } else if (SUGGEST_TYPE_SEARCH_LOG.equals(documentForm.deleteSuggestType)) { + query = SuggestConstants.SuggestFieldNames.SEGMENT + ":" + SuggestConstants.SEGMENT_QUERY; } else { query = ""; } @@ -449,19 +402,14 @@ public class DocumentAction implements Serializable { suggestSolrServer.deleteByQuery(query); suggestSolrServer.commit(); if (logger.isInfoEnabled()) { - logger.info("[EXEC TIME] suggest index cleanup time: " - + (System.currentTimeMillis() - execTime) - + "ms"); + logger.info("[EXEC TIME] suggest index cleanup time: " + (System.currentTimeMillis() - execTime) + "ms"); } } catch (final Exception e) { - logger.error( - "Failed to delete suggest index (query=" - + query + ").", e); + logger.error("Failed to delete suggest index (query=" + query + ").", e); } } else { if (logger.isInfoEnabled()) { - logger.info("could not start index cleanup process" - + " because of running solr process."); + logger.info("could not start index cleanup process" + " because of running solr process."); } } } diff --git a/src/main/java/org/codelibs/fess/action/admin/FavoriteLogAction.java b/src/main/java/org/codelibs/fess/action/admin/FavoriteLogAction.java index 095eb6436..cdd5f5df0 100644 --- a/src/main/java/org/codelibs/fess/action/admin/FavoriteLogAction.java +++ b/src/main/java/org/codelibs/fess/action/admin/FavoriteLogAction.java @@ -62,21 +62,17 @@ public class FavoriteLogAction extends BsFavoriteLogAction { public String download() { BufferedWriter writer = null; final SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); - final String fileName = "FessFavoriteLog_" + sdf.format(new Date()) - + ".csv"; + final String fileName = "FessFavoriteLog_" + sdf.format(new Date()) + ".csv"; final HttpServletResponse response = ResponseUtil.getResponse(); response.setContentType("text/csv"); - response.setHeader("Content-disposition", "attachment; filename=\"" - + fileName + "\""); + response.setHeader("Content-disposition", "attachment; filename=\"" + fileName + "\""); try { - writer = new BufferedWriter(new OutputStreamWriter( - response.getOutputStream(), getCsvEncoding())); + writer = new BufferedWriter(new OutputStreamWriter(response.getOutputStream(), getCsvEncoding())); favoriteLogService.dump(writer, favoriteLogPager); writer.flush(); } catch (final Exception e) { log.error("Could not create FessSearchLog.csv.", e); - throw new SSCActionMessagesException(e, - "errors.could_not_create_search_log_csv"); + throw new SSCActionMessagesException(e, "errors.could_not_create_search_log_csv"); } finally { IOUtils.closeQuietly(writer); } diff --git a/src/main/java/org/codelibs/fess/action/admin/FileAuthenticationAction.java b/src/main/java/org/codelibs/fess/action/admin/FileAuthenticationAction.java index 9ebb5140a..6dd6953ff 100644 --- a/src/main/java/org/codelibs/fess/action/admin/FileAuthenticationAction.java +++ b/src/main/java/org/codelibs/fess/action/admin/FileAuthenticationAction.java @@ -47,8 +47,7 @@ public class FileAuthenticationAction extends BsFileAuthenticationAction { private static final long serialVersionUID = 1L; - private static final Log log = LogFactory - .getLog(FileAuthenticationAction.class); + private static final Log log = LogFactory.getLog(FileAuthenticationAction.class); @Resource protected FileCrawlingConfigService fileCrawlingConfigService; @@ -63,18 +62,13 @@ public class FileAuthenticationAction extends BsFileAuthenticationAction { @Override protected void loadFileAuthentication() { - final FileAuthentication fileAuthentication = fileAuthenticationService - .getFileAuthentication(createKeyMap()); + final FileAuthentication fileAuthentication = fileAuthenticationService.getFileAuthentication(createKeyMap()); if (fileAuthentication == null) { // throw an exception - throw new SSCActionMessagesException( - "errors.crud_could_not_find_crud_table", - new Object[] { fileAuthenticationForm.id }); + throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { fileAuthenticationForm.id }); } - FessBeans.copy(fileAuthentication, fileAuthenticationForm) - .commonColumnDateConverter().excludes("searchParams", "mode") - .execute(); + FessBeans.copy(fileAuthentication, fileAuthenticationForm).commonColumnDateConverter().excludes("searchParams", "mode").execute(); if ("-1".equals(fileAuthenticationForm.port)) { fileAuthenticationForm.port = StringUtil.EMPTY; } @@ -86,13 +80,10 @@ public class FileAuthenticationAction extends BsFileAuthenticationAction { final String username = systemHelper.getUsername(); final LocalDateTime currentTime = systemHelper.getCurrentTime(); if (fileAuthenticationForm.crudMode == CommonConstants.EDIT_MODE) { - fileAuthentication = fileAuthenticationService - .getFileAuthentication(createKeyMap()); + fileAuthentication = fileAuthenticationService.getFileAuthentication(createKeyMap()); if (fileAuthentication == null) { // throw an exception - throw new SSCActionMessagesException( - "errors.crud_could_not_find_crud_table", - new Object[] { fileAuthenticationForm.id }); + throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { fileAuthenticationForm.id }); } } else { fileAuthentication = new FileAuthentication(); @@ -104,8 +95,7 @@ public class FileAuthenticationAction extends BsFileAuthenticationAction { if (StringUtil.isBlank(fileAuthenticationForm.port)) { fileAuthenticationForm.port = "-1"; } - FessBeans.copy(fileAuthenticationForm, fileAuthentication) - .excludesCommonColumns().execute(); + FessBeans.copy(fileAuthenticationForm, fileAuthentication).excludesCommonColumns().execute(); return fileAuthentication; } @@ -114,19 +104,15 @@ public class FileAuthenticationAction extends BsFileAuthenticationAction { @Execute(validator = false, input = "error.jsp") public String delete() { if (fileAuthenticationForm.crudMode != CommonConstants.DELETE_MODE) { - throw new SSCActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - fileAuthenticationForm.crudMode }); + throw new SSCActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, + fileAuthenticationForm.crudMode }); } try { - final FileAuthentication fileAuthentication = fileAuthenticationService - .getFileAuthentication(createKeyMap()); + final FileAuthentication fileAuthentication = fileAuthenticationService.getFileAuthentication(createKeyMap()); if (fileAuthentication == null) { // throw an exception - throw new SSCActionMessagesException( - "errors.crud_could_not_find_crud_table", - new Object[] { fileAuthenticationForm.id }); + throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { fileAuthenticationForm.id }); } // fileAuthenticationService.delete(fileAuthentication); @@ -143,41 +129,36 @@ public class FileAuthenticationAction extends BsFileAuthenticationAction { throw e; } catch (final CrudMessageException e) { log.error(e.getMessage(), e); - throw new SSCActionMessagesException(e, e.getMessageId(), - e.getArgs()); + throw new SSCActionMessagesException(e, e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new SSCActionMessagesException(e, - "errors.crud_failed_to_delete_crud_table"); + throw new SSCActionMessagesException(e, "errors.crud_failed_to_delete_crud_table"); } } public boolean isDisplayCreateLink() { - return !fileCrawlingConfigService.getAllFileCrawlingConfigList(false, - false, false, null).isEmpty(); + return !fileCrawlingConfigService.getAllFileCrawlingConfigList(false, false, false, null).isEmpty(); } public List> getFileCrawlingConfigItems() { final List> items = new ArrayList>(); - final List fileCrawlingConfigList = fileCrawlingConfigService - .getAllFileCrawlingConfigList(false, false, false, null); + final List fileCrawlingConfigList = + fileCrawlingConfigService.getAllFileCrawlingConfigList(false, false, false, null); for (final FileCrawlingConfig fileCrawlingConfig : fileCrawlingConfigList) { - items.add(createItem(fileCrawlingConfig.getName(), - fileCrawlingConfig.getId().toString())); + items.add(createItem(fileCrawlingConfig.getName(), fileCrawlingConfig.getId().toString())); } return items; } public List> getProtocolSchemeItems() { final List> items = new ArrayList>(); - items.add(createItem(MessageResourcesUtil.getMessage(RequestUtil - .getRequest().getLocale(), - "labels.file_authentication_scheme_samba"), Constants.SAMBA)); + items.add(createItem( + MessageResourcesUtil.getMessage(RequestUtil.getRequest().getLocale(), "labels.file_authentication_scheme_samba"), + Constants.SAMBA)); return items; } - protected Map createItem(final String label, - final String value) { + protected Map createItem(final String label, final String value) { final Map map = new HashMap(2); map.put("label", label); map.put("value", value); diff --git a/src/main/java/org/codelibs/fess/action/admin/FileCrawlingConfigAction.java b/src/main/java/org/codelibs/fess/action/admin/FileCrawlingConfigAction.java index d4da5154e..0aba13d9b 100644 --- a/src/main/java/org/codelibs/fess/action/admin/FileCrawlingConfigAction.java +++ b/src/main/java/org/codelibs/fess/action/admin/FileCrawlingConfigAction.java @@ -42,8 +42,7 @@ import org.seasar.struts.exception.ActionMessagesException; public class FileCrawlingConfigAction extends BsFileCrawlingConfigAction { private static final long serialVersionUID = 1L; - private static final Log log = LogFactory - .getLog(FileCrawlingConfigAction.class); + private static final Log log = LogFactory.getLog(FileCrawlingConfigAction.class); @Resource protected RoleTypeService roleTypeService; @@ -64,24 +63,17 @@ public class FileCrawlingConfigAction extends BsFileCrawlingConfigAction { @Override protected void loadFileCrawlingConfig() { - final FileCrawlingConfig fileCrawlingConfig = fileCrawlingConfigService - .getFileCrawlingConfig(createKeyMap()); + final FileCrawlingConfig fileCrawlingConfig = fileCrawlingConfigService.getFileCrawlingConfig(createKeyMap()); if (fileCrawlingConfig == null) { // throw an exception - throw new SSCActionMessagesException( - "errors.crud_could_not_find_crud_table", - new Object[] { fileCrawlingConfigForm.id }); + throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { fileCrawlingConfigForm.id }); } - FessBeans.copy(fileCrawlingConfig, fileCrawlingConfigForm) - .commonColumnDateConverter().excludes("searchParams", "mode") - .execute(); + FessBeans.copy(fileCrawlingConfig, fileCrawlingConfigForm).commonColumnDateConverter().excludes("searchParams", "mode").execute(); // normalize boost - if (fileCrawlingConfigForm.boost != null - && fileCrawlingConfigForm.boost.indexOf('.') > 0) { - fileCrawlingConfigForm.boost = fileCrawlingConfigForm.boost - .substring(0, fileCrawlingConfigForm.boost.indexOf('.')); + if (fileCrawlingConfigForm.boost != null && fileCrawlingConfigForm.boost.indexOf('.') > 0) { + fileCrawlingConfigForm.boost = fileCrawlingConfigForm.boost.substring(0, fileCrawlingConfigForm.boost.indexOf('.')); } } @@ -91,13 +83,10 @@ public class FileCrawlingConfigAction extends BsFileCrawlingConfigAction { final String username = systemHelper.getUsername(); final LocalDateTime currentTime = systemHelper.getCurrentTime(); if (fileCrawlingConfigForm.crudMode == CommonConstants.EDIT_MODE) { - fileCrawlingConfig = fileCrawlingConfigService - .getFileCrawlingConfig(createKeyMap()); + fileCrawlingConfig = fileCrawlingConfigService.getFileCrawlingConfig(createKeyMap()); if (fileCrawlingConfig == null) { // throw an exception - throw new SSCActionMessagesException( - "errors.crud_could_not_find_crud_table", - new Object[] { fileCrawlingConfigForm.id }); + throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { fileCrawlingConfigForm.id }); } } else { fileCrawlingConfig = new FileCrawlingConfig(); @@ -106,8 +95,7 @@ public class FileCrawlingConfigAction extends BsFileCrawlingConfigAction { } fileCrawlingConfig.setUpdatedBy(username); fileCrawlingConfig.setUpdatedTime(currentTime); - FessBeans.copy(fileCrawlingConfigForm, fileCrawlingConfig) - .excludesCommonColumns().execute(); + FessBeans.copy(fileCrawlingConfigForm, fileCrawlingConfig).excludesCommonColumns().execute(); return fileCrawlingConfig; } @@ -116,23 +104,18 @@ public class FileCrawlingConfigAction extends BsFileCrawlingConfigAction { @Execute(validator = false, input = "error.jsp") public String delete() { if (fileCrawlingConfigForm.crudMode != CommonConstants.DELETE_MODE) { - throw new SSCActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - fileCrawlingConfigForm.crudMode }); + throw new SSCActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, + fileCrawlingConfigForm.crudMode }); } try { - final FileCrawlingConfig fileCrawlingConfig = fileCrawlingConfigService - .getFileCrawlingConfig(createKeyMap()); + final FileCrawlingConfig fileCrawlingConfig = fileCrawlingConfigService.getFileCrawlingConfig(createKeyMap()); if (fileCrawlingConfig == null) { // throw an exception - throw new SSCActionMessagesException( - "errors.crud_could_not_find_crud_table", - new Object[] { fileCrawlingConfigForm.id }); + throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { fileCrawlingConfigForm.id }); } - failureUrlService - .deleteByConfigId(fileCrawlingConfig.getConfigId()); + failureUrlService.deleteByConfigId(fileCrawlingConfig.getConfigId()); //fileCrawlingConfigService.delete(fileCrawlingConfig); final String username = systemHelper.getUsername(); @@ -148,12 +131,10 @@ public class FileCrawlingConfigAction extends BsFileCrawlingConfigAction { throw e; } catch (final CrudMessageException e) { log.error(e.getMessage(), e); - throw new SSCActionMessagesException(e, e.getMessageId(), - e.getArgs()); + throw new SSCActionMessagesException(e, e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new SSCActionMessagesException(e, - "errors.crud_failed_to_delete_crud_table"); + throw new SSCActionMessagesException(e, "errors.crud_failed_to_delete_crud_table"); } } diff --git a/src/main/java/org/codelibs/fess/action/admin/KeyMatchAction.java b/src/main/java/org/codelibs/fess/action/admin/KeyMatchAction.java index 1e0dd6607..e4ac0d243 100644 --- a/src/main/java/org/codelibs/fess/action/admin/KeyMatchAction.java +++ b/src/main/java/org/codelibs/fess/action/admin/KeyMatchAction.java @@ -54,13 +54,10 @@ public class KeyMatchAction extends BsKeyMatchAction { final KeyMatch keyMatch = keyMatchService.getKeyMatch(createKeyMap()); if (keyMatch == null) { // throw an exception - throw new SSCActionMessagesException( - "errors.crud_could_not_find_crud_table", - new Object[] { keyMatchForm.id }); + throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { keyMatchForm.id }); } - FessBeans.copy(keyMatch, keyMatchForm).commonColumnDateConverter() - .excludes("searchParams", "mode").execute(); + FessBeans.copy(keyMatch, keyMatchForm).commonColumnDateConverter().excludes("searchParams", "mode").execute(); } @Override @@ -72,9 +69,7 @@ public class KeyMatchAction extends BsKeyMatchAction { keyMatch = keyMatchService.getKeyMatch(createKeyMap()); if (keyMatch == null) { // throw an exception - throw new SSCActionMessagesException( - "errors.crud_could_not_find_crud_table", - new Object[] { keyMatchForm.id }); + throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { keyMatchForm.id }); } } else { keyMatch = new KeyMatch(); @@ -83,8 +78,7 @@ public class KeyMatchAction extends BsKeyMatchAction { } keyMatch.setUpdatedBy(username); keyMatch.setUpdatedTime(currentTime); - FessBeans.copy(keyMatchForm, keyMatch).excludesCommonColumns() - .execute(); + FessBeans.copy(keyMatchForm, keyMatch).excludesCommonColumns().execute(); return keyMatch; } @@ -111,19 +105,15 @@ public class KeyMatchAction extends BsKeyMatchAction { @Execute(validator = false, input = "error.jsp") public String delete() { if (keyMatchForm.crudMode != CommonConstants.DELETE_MODE) { - throw new SSCActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - keyMatchForm.crudMode }); + throw new SSCActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, + keyMatchForm.crudMode }); } try { - final KeyMatch keyMatch = keyMatchService - .getKeyMatch(createKeyMap()); + final KeyMatch keyMatch = keyMatchService.getKeyMatch(createKeyMap()); if (keyMatch == null) { // throw an exception - throw new SSCActionMessagesException( - "errors.crud_could_not_find_crud_table", - new Object[] { keyMatchForm.id }); + throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { keyMatchForm.id }); } // keyMatchService.delete(keyMatch); @@ -142,12 +132,10 @@ public class KeyMatchAction extends BsKeyMatchAction { throw e; } catch (final CrudMessageException e) { log.error(e.getMessage(), e); - throw new SSCActionMessagesException(e, e.getMessageId(), - e.getArgs()); + throw new SSCActionMessagesException(e, e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new SSCActionMessagesException(e, - "errors.crud_failed_to_delete_crud_table"); + throw new SSCActionMessagesException(e, "errors.crud_failed_to_delete_crud_table"); } } diff --git a/src/main/java/org/codelibs/fess/action/admin/LabelTypeAction.java b/src/main/java/org/codelibs/fess/action/admin/LabelTypeAction.java index 3f95b2d08..baed973eb 100644 --- a/src/main/java/org/codelibs/fess/action/admin/LabelTypeAction.java +++ b/src/main/java/org/codelibs/fess/action/admin/LabelTypeAction.java @@ -54,17 +54,13 @@ public class LabelTypeAction extends BsLabelTypeAction { @Override protected void loadLabelType() { - final LabelType labelType = labelTypeService - .getLabelType(createKeyMap()); + final LabelType labelType = labelTypeService.getLabelType(createKeyMap()); if (labelType == null) { // throw an exception - throw new SSCActionMessagesException( - "errors.crud_could_not_find_crud_table", - new Object[] { labelTypeForm.id }); + throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { labelTypeForm.id }); } - FessBeans.copy(labelType, labelTypeForm).commonColumnDateConverter() - .excludes("searchParams", "mode").execute(); + FessBeans.copy(labelType, labelTypeForm).commonColumnDateConverter().excludes("searchParams", "mode").execute(); } @Override @@ -76,9 +72,7 @@ public class LabelTypeAction extends BsLabelTypeAction { labelType = labelTypeService.getLabelType(createKeyMap()); if (labelType == null) { // throw an exception - throw new SSCActionMessagesException( - "errors.crud_could_not_find_crud_table", - new Object[] { labelTypeForm.id }); + throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { labelTypeForm.id }); } } else { labelType = new LabelType(); @@ -87,8 +81,7 @@ public class LabelTypeAction extends BsLabelTypeAction { } labelType.setUpdatedBy(username); labelType.setUpdatedTime(currentTime); - FessBeans.copy(labelTypeForm, labelType).excludesCommonColumns() - .execute(); + FessBeans.copy(labelTypeForm, labelType).excludesCommonColumns().execute(); return labelType; } @@ -97,19 +90,15 @@ public class LabelTypeAction extends BsLabelTypeAction { @Execute(validator = false, input = "error.jsp") public String delete() { if (labelTypeForm.crudMode != CommonConstants.DELETE_MODE) { - throw new SSCActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - labelTypeForm.crudMode }); + throw new SSCActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, + labelTypeForm.crudMode }); } try { - final LabelType labelType = labelTypeService - .getLabelType(createKeyMap()); + final LabelType labelType = labelTypeService.getLabelType(createKeyMap()); if (labelType == null) { // throw an exception - throw new SSCActionMessagesException( - "errors.crud_could_not_find_crud_table", - new Object[] { labelTypeForm.id }); + throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { labelTypeForm.id }); } // labelTypeService.delete(labelType); @@ -126,12 +115,10 @@ public class LabelTypeAction extends BsLabelTypeAction { throw e; } catch (final CrudMessageException e) { log.error(e.getMessage(), e); - throw new SSCActionMessagesException(e, e.getMessageId(), - e.getArgs()); + throw new SSCActionMessagesException(e, e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new SSCActionMessagesException(e, - "errors.crud_failed_to_delete_crud_table"); + throw new SSCActionMessagesException(e, "errors.crud_failed_to_delete_crud_table"); } } diff --git a/src/main/java/org/codelibs/fess/action/admin/LogAction.java b/src/main/java/org/codelibs/fess/action/admin/LogAction.java index 15fa6441e..3983a16f6 100644 --- a/src/main/java/org/codelibs/fess/action/admin/LogAction.java +++ b/src/main/java/org/codelibs/fess/action/admin/LogAction.java @@ -50,8 +50,7 @@ public class LogAction implements Serializable { private static final long serialVersionUID = 1L; - private static final Logger logger = LoggerFactory - .getLogger(LogAction.class); + private static final Logger logger = LoggerFactory.getLogger(LogAction.class); @ActionForm @Resource @@ -71,47 +70,39 @@ public class LogAction implements Serializable { @Execute(validator = true, input = "index", urlPattern = "download/{logFileName}") public String download() { - final String logFilePath = ComponentUtil.getSystemHelper() - .getLogFilePath(); + final String logFilePath = ComponentUtil.getSystemHelper().getLogFilePath(); if (StringUtil.isNotBlank(logFilePath)) { final File file = new File(logFilePath); final File parentDir = file.getParentFile(); String fileName; try { - fileName = new String(Base64.decodeBase64(logForm.logFileName - .getBytes(Constants.UTF_8)), Constants.UTF_8); + fileName = new String(Base64.decodeBase64(logForm.logFileName.getBytes(Constants.UTF_8)), Constants.UTF_8); } catch (final UnsupportedEncodingException e1) { - fileName = new String(Base64.decodeBase64(logForm.logFileName - .getBytes(Charset.defaultCharset())), - Charset.defaultCharset()); + fileName = + new String(Base64.decodeBase64(logForm.logFileName.getBytes(Charset.defaultCharset())), Charset.defaultCharset()); } final File logFile = new File(parentDir, fileName); if (logFile.isFile()) { try { - ResponseUtil.download(fileName, - new FileInputStream(logFile)); + ResponseUtil.download(fileName, new FileInputStream(logFile)); return null; } catch (final FileNotFoundException e) { - logger.warn("Could not find " + logFile.getAbsolutePath(), - e); + logger.warn("Could not find " + logFile.getAbsolutePath(), e); } } } - throw new SSCActionMessagesException("errors.could_not_find_log_file", - new Object[] { logForm.logFileName }); + throw new SSCActionMessagesException("errors.could_not_find_log_file", new Object[] { logForm.logFileName }); } public List> getLogFileItems() { final List> logFileItems = new ArrayList>(); - final String logFilePath = ComponentUtil.getSystemHelper() - .getLogFilePath(); + final String logFilePath = ComponentUtil.getSystemHelper().getLogFilePath(); if (StringUtil.isNotBlank(logFilePath)) { try { final File file = new File(logFilePath); final File parentDir = file.getParentFile(); if (!parentDir.exists()) { - logger.warn("Log directory does not exist: " - + parentDir.getAbsolutePath()); + logger.warn("Log directory does not exist: " + parentDir.getAbsolutePath()); return logFileItems; } final File[] files = parentDir.listFiles(new FilenameFilter() { @@ -150,14 +141,10 @@ public class LogAction implements Serializable { final Map map = new HashMap(); map.put("name", file.getName()); try { - map.put("logFileName", - new String(Base64.encodeBase64(file.getName().getBytes( - Constants.UTF_8)), "UTF-8")); + map.put("logFileName", new String(Base64.encodeBase64(file.getName().getBytes(Constants.UTF_8)), "UTF-8")); } catch (final UnsupportedEncodingException e) { map.put("logFileName", - new String(Base64.encodeBase64(file.getName().getBytes( - Charset.defaultCharset())), Charset - .defaultCharset())); + new String(Base64.encodeBase64(file.getName().getBytes(Charset.defaultCharset())), Charset.defaultCharset())); } map.put("lastModified", new Date(file.lastModified())); return map; diff --git a/src/main/java/org/codelibs/fess/action/admin/OverlappingHostAction.java b/src/main/java/org/codelibs/fess/action/admin/OverlappingHostAction.java index 89ee9b510..49fc61238 100644 --- a/src/main/java/org/codelibs/fess/action/admin/OverlappingHostAction.java +++ b/src/main/java/org/codelibs/fess/action/admin/OverlappingHostAction.java @@ -37,8 +37,7 @@ public class OverlappingHostAction extends BsOverlappingHostAction { private static final long serialVersionUID = 1L; - private static final Log log = LogFactory - .getLog(OverlappingHostAction.class); + private static final Log log = LogFactory.getLog(OverlappingHostAction.class); @Resource protected SystemHelper systemHelper; @@ -50,18 +49,13 @@ public class OverlappingHostAction extends BsOverlappingHostAction { @Override protected void loadOverlappingHost() { - final OverlappingHost overlappingHost = overlappingHostService - .getOverlappingHost(createKeyMap()); + final OverlappingHost overlappingHost = overlappingHostService.getOverlappingHost(createKeyMap()); if (overlappingHost == null) { // throw an exception - throw new SSCActionMessagesException( - "errors.crud_could_not_find_crud_table", - new Object[] { overlappingHostForm.id }); + throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { overlappingHostForm.id }); } - FessBeans.copy(overlappingHost, overlappingHostForm) - .commonColumnDateConverter().excludes("searchParams", "mode") - .execute(); + FessBeans.copy(overlappingHost, overlappingHostForm).commonColumnDateConverter().excludes("searchParams", "mode").execute(); } @Override @@ -70,13 +64,10 @@ public class OverlappingHostAction extends BsOverlappingHostAction { final String username = systemHelper.getUsername(); final LocalDateTime currentTime = systemHelper.getCurrentTime(); if (overlappingHostForm.crudMode == CommonConstants.EDIT_MODE) { - overlappingHost = overlappingHostService - .getOverlappingHost(createKeyMap()); + overlappingHost = overlappingHostService.getOverlappingHost(createKeyMap()); if (overlappingHost == null) { // throw an exception - throw new SSCActionMessagesException( - "errors.crud_could_not_find_crud_table", - new Object[] { overlappingHostForm.id }); + throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { overlappingHostForm.id }); } } else { overlappingHost = new OverlappingHost(); @@ -85,8 +76,7 @@ public class OverlappingHostAction extends BsOverlappingHostAction { } overlappingHost.setUpdatedBy(username); overlappingHost.setUpdatedTime(currentTime); - FessBeans.copy(overlappingHostForm, overlappingHost) - .excludesCommonColumns().execute(); + FessBeans.copy(overlappingHostForm, overlappingHost).excludesCommonColumns().execute(); return overlappingHost; } @@ -95,19 +85,15 @@ public class OverlappingHostAction extends BsOverlappingHostAction { @Execute(validator = false, input = "error.jsp") public String delete() { if (overlappingHostForm.crudMode != CommonConstants.DELETE_MODE) { - throw new SSCActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - overlappingHostForm.crudMode }); + throw new SSCActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, + overlappingHostForm.crudMode }); } try { - final OverlappingHost overlappingHost = overlappingHostService - .getOverlappingHost(createKeyMap()); + final OverlappingHost overlappingHost = overlappingHostService.getOverlappingHost(createKeyMap()); if (overlappingHost == null) { // throw an exception - throw new SSCActionMessagesException( - "errors.crud_could_not_find_crud_table", - new Object[] { overlappingHostForm.id }); + throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { overlappingHostForm.id }); } // overlappingHostService.delete(overlappingHost); @@ -124,12 +110,10 @@ public class OverlappingHostAction extends BsOverlappingHostAction { throw e; } catch (final CrudMessageException e) { log.error(e.getMessage(), e); - throw new SSCActionMessagesException(e, e.getMessageId(), - e.getArgs()); + throw new SSCActionMessagesException(e, e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new SSCActionMessagesException(e, - "errors.crud_failed_to_delete_crud_table"); + throw new SSCActionMessagesException(e, "errors.crud_failed_to_delete_crud_table"); } } } diff --git a/src/main/java/org/codelibs/fess/action/admin/PathMappingAction.java b/src/main/java/org/codelibs/fess/action/admin/PathMappingAction.java index afa1fd1a1..ce5cfcc31 100644 --- a/src/main/java/org/codelibs/fess/action/admin/PathMappingAction.java +++ b/src/main/java/org/codelibs/fess/action/admin/PathMappingAction.java @@ -61,18 +61,13 @@ public class PathMappingAction extends BsPathMappingAction { @Override protected void loadPathMapping() { - final PathMapping pathMapping = pathMappingService - .getPathMapping(createKeyMap()); + final PathMapping pathMapping = pathMappingService.getPathMapping(createKeyMap()); if (pathMapping == null) { // throw an exception - throw new SSCActionMessagesException( - "errors.crud_could_not_find_crud_table", - new Object[] { pathMappingForm.id }); + throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { pathMappingForm.id }); } - FessBeans.copy(pathMapping, pathMappingForm) - .commonColumnDateConverter().excludes("searchParams", "mode") - .execute(); + FessBeans.copy(pathMapping, pathMappingForm).commonColumnDateConverter().excludes("searchParams", "mode").execute(); } @Override @@ -84,9 +79,7 @@ public class PathMappingAction extends BsPathMappingAction { pathMapping = pathMappingService.getPathMapping(createKeyMap()); if (pathMapping == null) { // throw an exception - throw new SSCActionMessagesException( - "errors.crud_could_not_find_crud_table", - new Object[] { pathMappingForm.id }); + throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { pathMappingForm.id }); } } else { pathMapping = new PathMapping(); @@ -95,8 +88,7 @@ public class PathMappingAction extends BsPathMappingAction { } pathMapping.setUpdatedBy(username); pathMapping.setUpdatedTime(currentTime); - FessBeans.copy(pathMappingForm, pathMapping).excludesCommonColumns() - .execute(); + FessBeans.copy(pathMappingForm, pathMapping).excludesCommonColumns().execute(); return pathMapping; } @@ -105,19 +97,15 @@ public class PathMappingAction extends BsPathMappingAction { @Execute(validator = false, input = "error.jsp") public String delete() { if (pathMappingForm.crudMode != CommonConstants.DELETE_MODE) { - throw new SSCActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - pathMappingForm.crudMode }); + throw new SSCActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, + pathMappingForm.crudMode }); } try { - final PathMapping pathMapping = pathMappingService - .getPathMapping(createKeyMap()); + final PathMapping pathMapping = pathMappingService.getPathMapping(createKeyMap()); if (pathMapping == null) { // throw an exception - throw new SSCActionMessagesException( - "errors.crud_could_not_find_crud_table", - new Object[] { pathMappingForm.id }); + throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { pathMappingForm.id }); } // pathMappingService.delete(pathMapping); @@ -134,12 +122,10 @@ public class PathMappingAction extends BsPathMappingAction { throw e; } catch (final CrudMessageException e) { log.error(e.getMessage(), e); - throw new SSCActionMessagesException(e, e.getMessageId(), - e.getArgs()); + throw new SSCActionMessagesException(e, e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new SSCActionMessagesException(e, - "errors.crud_failed_to_delete_crud_table"); + throw new SSCActionMessagesException(e, "errors.crud_failed_to_delete_crud_table"); } } diff --git a/src/main/java/org/codelibs/fess/action/admin/RequestHeaderAction.java b/src/main/java/org/codelibs/fess/action/admin/RequestHeaderAction.java index 82daa99f3..08eb8f3eb 100644 --- a/src/main/java/org/codelibs/fess/action/admin/RequestHeaderAction.java +++ b/src/main/java/org/codelibs/fess/action/admin/RequestHeaderAction.java @@ -60,18 +60,13 @@ public class RequestHeaderAction extends BsRequestHeaderAction { @Override protected void loadRequestHeader() { - final RequestHeader requestHeader = requestHeaderService - .getRequestHeader(createKeyMap()); + final RequestHeader requestHeader = requestHeaderService.getRequestHeader(createKeyMap()); if (requestHeader == null) { // throw an exception - throw new SSCActionMessagesException( - "errors.crud_could_not_find_crud_table", - new Object[] { requestHeaderForm.id }); + throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { requestHeaderForm.id }); } - FessBeans.copy(requestHeader, requestHeaderForm) - .commonColumnDateConverter().excludes("searchParams", "mode") - .execute(); + FessBeans.copy(requestHeader, requestHeaderForm).commonColumnDateConverter().excludes("searchParams", "mode").execute(); } @Override @@ -80,13 +75,10 @@ public class RequestHeaderAction extends BsRequestHeaderAction { final String username = systemHelper.getUsername(); final LocalDateTime currentTime = systemHelper.getCurrentTime(); if (requestHeaderForm.crudMode == CommonConstants.EDIT_MODE) { - requestHeader = requestHeaderService - .getRequestHeader(createKeyMap()); + requestHeader = requestHeaderService.getRequestHeader(createKeyMap()); if (requestHeader == null) { // throw an exception - throw new SSCActionMessagesException( - "errors.crud_could_not_find_crud_table", - new Object[] { requestHeaderForm.id }); + throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { requestHeaderForm.id }); } } else { requestHeader = new RequestHeader(); @@ -95,8 +87,7 @@ public class RequestHeaderAction extends BsRequestHeaderAction { } requestHeader.setUpdatedBy(username); requestHeader.setUpdatedTime(currentTime); - FessBeans.copy(requestHeaderForm, requestHeader) - .excludesCommonColumns().execute(); + FessBeans.copy(requestHeaderForm, requestHeader).excludesCommonColumns().execute(); return requestHeader; } @@ -105,19 +96,15 @@ public class RequestHeaderAction extends BsRequestHeaderAction { @Execute(validator = false, input = "error.jsp") public String delete() { if (requestHeaderForm.crudMode != CommonConstants.DELETE_MODE) { - throw new SSCActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - requestHeaderForm.crudMode }); + throw new SSCActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, + requestHeaderForm.crudMode }); } try { - final RequestHeader requestHeader = requestHeaderService - .getRequestHeader(createKeyMap()); + final RequestHeader requestHeader = requestHeaderService.getRequestHeader(createKeyMap()); if (requestHeader == null) { // throw an exception - throw new SSCActionMessagesException( - "errors.crud_could_not_find_crud_table", - new Object[] { requestHeaderForm.id }); + throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { requestHeaderForm.id }); } // requestHeaderService.delete(requestHeader); @@ -134,39 +121,33 @@ public class RequestHeaderAction extends BsRequestHeaderAction { throw e; } catch (final CrudMessageException e) { log.error(e.getMessage(), e); - throw new SSCActionMessagesException(e, e.getMessageId(), - e.getArgs()); + throw new SSCActionMessagesException(e, e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new SSCActionMessagesException(e, - "errors.crud_failed_to_delete_crud_table"); + throw new SSCActionMessagesException(e, "errors.crud_failed_to_delete_crud_table"); } } public List> getWebCrawlingConfigItems() { final List> items = new ArrayList>(); - final List webCrawlingConfigList = webCrawlingConfigService - .getAllWebCrawlingConfigList(false, false, false, null); + final List webCrawlingConfigList = + webCrawlingConfigService.getAllWebCrawlingConfigList(false, false, false, null); for (final WebCrawlingConfig webCrawlingConfig : webCrawlingConfigList) { - items.add(createItem(webCrawlingConfig.getName(), webCrawlingConfig - .getId().toString())); + items.add(createItem(webCrawlingConfig.getName(), webCrawlingConfig.getId().toString())); } return items; } public List> getProtocolSchemeItems() { final List> items = new ArrayList>(); - items.add(createItem(MessageResourcesUtil.getMessage(RequestUtil - .getRequest().getLocale(), - "labels.web_authentication_scheme_basic"), "BASIC")); - items.add(createItem(MessageResourcesUtil.getMessage(RequestUtil - .getRequest().getLocale(), - "labels.web_authentication_scheme_digest"), "DIGEST")); + items.add(createItem( + MessageResourcesUtil.getMessage(RequestUtil.getRequest().getLocale(), "labels.web_authentication_scheme_basic"), "BASIC")); + items.add(createItem( + MessageResourcesUtil.getMessage(RequestUtil.getRequest().getLocale(), "labels.web_authentication_scheme_digest"), "DIGEST")); return items; } - protected Map createItem(final String label, - final String value) { + protected Map createItem(final String label, final String value) { final Map map = new HashMap(2); map.put("label", label); map.put("value", value); @@ -174,7 +155,6 @@ public class RequestHeaderAction extends BsRequestHeaderAction { } public boolean isDisplayCreateLink() { - return !webCrawlingConfigService.getAllWebCrawlingConfigList(false, - false, false, null).isEmpty(); + return !webCrawlingConfigService.getAllWebCrawlingConfigList(false, false, false, null).isEmpty(); } } diff --git a/src/main/java/org/codelibs/fess/action/admin/RoleTypeAction.java b/src/main/java/org/codelibs/fess/action/admin/RoleTypeAction.java index 44c7c7eea..4a9b35f60 100644 --- a/src/main/java/org/codelibs/fess/action/admin/RoleTypeAction.java +++ b/src/main/java/org/codelibs/fess/action/admin/RoleTypeAction.java @@ -68,13 +68,10 @@ public class RoleTypeAction extends BsRoleTypeAction { final RoleType roleType = roleTypeService.getRoleType(createKeyMap()); if (roleType == null) { // throw an exception - throw new SSCActionMessagesException( - "errors.crud_could_not_find_crud_table", - new Object[] { roleTypeForm.id }); + throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { roleTypeForm.id }); } - FessBeans.copy(roleType, roleTypeForm).commonColumnDateConverter() - .excludes("searchParams", "mode").execute(); + FessBeans.copy(roleType, roleTypeForm).commonColumnDateConverter().excludes("searchParams", "mode").execute(); } @Override @@ -86,9 +83,7 @@ public class RoleTypeAction extends BsRoleTypeAction { roleType = roleTypeService.getRoleType(createKeyMap()); if (roleType == null) { // throw an exception - throw new SSCActionMessagesException( - "errors.crud_could_not_find_crud_table", - new Object[] { roleTypeForm.id }); + throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { roleTypeForm.id }); } } else { roleType = new RoleType(); @@ -98,8 +93,7 @@ public class RoleTypeAction extends BsRoleTypeAction { roleType.setUpdatedBy(username); roleType.setUpdatedTime(currentTime); roleTypeForm.value = roleTypeForm.value.trim(); - FessBeans.copy(roleTypeForm, roleType).excludesCommonColumns() - .execute(); + FessBeans.copy(roleTypeForm, roleType).excludesCommonColumns().execute(); return roleType; } @@ -109,19 +103,15 @@ public class RoleTypeAction extends BsRoleTypeAction { @Execute(validator = false, input = "error.jsp") public String delete() { if (roleTypeForm.crudMode != CommonConstants.DELETE_MODE) { - throw new SSCActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - roleTypeForm.crudMode }); + throw new SSCActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, + roleTypeForm.crudMode }); } try { - final RoleType roleType = roleTypeService - .getRoleType(createKeyMap()); + final RoleType roleType = roleTypeService.getRoleType(createKeyMap()); if (roleType == null) { // throw an exception - throw new SSCActionMessagesException( - "errors.crud_could_not_find_crud_table", - new Object[] { roleTypeForm.id }); + throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { roleTypeForm.id }); } // roleTypeService.delete(roleType); @@ -138,12 +128,10 @@ public class RoleTypeAction extends BsRoleTypeAction { throw e; } catch (final CrudMessageException e) { log.error(e.getMessage(), e); - throw new SSCActionMessagesException(e, e.getMessageId(), - e.getArgs()); + throw new SSCActionMessagesException(e, e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new SSCActionMessagesException(e, - "errors.crud_failed_to_delete_crud_table"); + throw new SSCActionMessagesException(e, "errors.crud_failed_to_delete_crud_table"); } } } diff --git a/src/main/java/org/codelibs/fess/action/admin/ScheduledJobAction.java b/src/main/java/org/codelibs/fess/action/admin/ScheduledJobAction.java index ec2f46bc3..70da20c53 100644 --- a/src/main/java/org/codelibs/fess/action/admin/ScheduledJobAction.java +++ b/src/main/java/org/codelibs/fess/action/admin/ScheduledJobAction.java @@ -65,15 +65,10 @@ public class ScheduledJobAction extends BsScheduledJobAction { final ScheduledJob scheduledJob = getScheduledJob(); - FessBeans.copy(scheduledJob, scheduledJobForm) - .commonColumnDateConverter() - .excludes("searchParams", "mode", "jobLogging").execute(); - scheduledJobForm.jobLogging = scheduledJob.isLoggingEnabled() ? Constants.ON - : null; - scheduledJobForm.crawler = scheduledJob.isCrawlerJob() ? Constants.ON - : null; - scheduledJobForm.available = scheduledJob.isEnabled() ? Constants.ON - : null; + FessBeans.copy(scheduledJob, scheduledJobForm).commonColumnDateConverter().excludes("searchParams", "mode", "jobLogging").execute(); + scheduledJobForm.jobLogging = scheduledJob.isLoggingEnabled() ? Constants.ON : null; + scheduledJobForm.crawler = scheduledJob.isCrawlerJob() ? Constants.ON : null; + scheduledJobForm.available = scheduledJob.isEnabled() ? Constants.ON : null; running = scheduledJob.isRunning(); } @@ -86,9 +81,7 @@ public class ScheduledJobAction extends BsScheduledJobAction { scheduledJob = scheduledJobService.getScheduledJob(createKeyMap()); if (scheduledJob == null) { // throw an exception - throw new SSCActionMessagesException( - "errors.crud_could_not_find_crud_table", - new Object[] { scheduledJobForm.id }); + throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { scheduledJobForm.id }); } } else { scheduledJob = new ScheduledJob(); @@ -97,17 +90,10 @@ public class ScheduledJobAction extends BsScheduledJobAction { } scheduledJob.setUpdatedBy(username); scheduledJob.setUpdatedTime(currentTime); - FessBeans.copy(scheduledJobForm, scheduledJob).excludesCommonColumns() - .execute(); - scheduledJob.setJobLogging(Constants.ON - .equals(scheduledJobForm.jobLogging) ? Constants.T - : Constants.F); - scheduledJob - .setCrawler(Constants.ON.equals(scheduledJobForm.crawler) ? Constants.T - : Constants.F); - scheduledJob - .setAvailable(Constants.ON.equals(scheduledJobForm.available) ? Constants.T - : Constants.F); + FessBeans.copy(scheduledJobForm, scheduledJob).excludesCommonColumns().execute(); + scheduledJob.setJobLogging(Constants.ON.equals(scheduledJobForm.jobLogging) ? Constants.T : Constants.F); + scheduledJob.setCrawler(Constants.ON.equals(scheduledJobForm.crawler) ? Constants.T : Constants.F); + scheduledJob.setAvailable(Constants.ON.equals(scheduledJobForm.available) ? Constants.T : Constants.F); return scheduledJob; } @@ -116,9 +102,8 @@ public class ScheduledJobAction extends BsScheduledJobAction { @Execute(validator = false, input = "error.jsp") public String delete() { if (scheduledJobForm.crudMode != CommonConstants.DELETE_MODE) { - throw new SSCActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - scheduledJobForm.crudMode }); + throw new SSCActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, + scheduledJobForm.crudMode }); } try { @@ -137,12 +122,10 @@ public class ScheduledJobAction extends BsScheduledJobAction { throw e; } catch (final CrudMessageException e) { log.error(e.getMessage(), e); - throw new SSCActionMessagesException(e, e.getMessageId(), - e.getArgs()); + throw new SSCActionMessagesException(e, e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new SSCActionMessagesException(e, - "errors.crud_failed_to_delete_crud_table"); + throw new SSCActionMessagesException(e, "errors.crud_failed_to_delete_crud_table"); } } @@ -151,13 +134,11 @@ public class ScheduledJobAction extends BsScheduledJobAction { final ScheduledJob scheduledJob = getScheduledJob(); try { scheduledJob.start(); - SAStrutsUtil.addSessionMessage("success.job_started", - scheduledJob.getName()); + SAStrutsUtil.addSessionMessage("success.job_started", scheduledJob.getName()); return displayList(true); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new SSCActionMessagesException(e, - "errors.failed_to_start_job", scheduledJob.getName()); + throw new SSCActionMessagesException(e, "errors.failed_to_start_job", scheduledJob.getName()); } } @@ -166,16 +147,13 @@ public class ScheduledJobAction extends BsScheduledJobAction { public String stop() { final ScheduledJob scheduledJob = getScheduledJob(); try { - final JobExecutor jobExecutoer = jobHelper - .getJobExecutoer(scheduledJob.getId()); + final JobExecutor jobExecutoer = jobHelper.getJobExecutoer(scheduledJob.getId()); jobExecutoer.shutdown(); - SAStrutsUtil.addSessionMessage("success.job_stopped", - scheduledJob.getName()); + SAStrutsUtil.addSessionMessage("success.job_stopped", scheduledJob.getName()); return displayList(true); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new SSCActionMessagesException(e, - "errors.failed_to_stop_job", scheduledJob.getName()); + throw new SSCActionMessagesException(e, "errors.failed_to_stop_job", scheduledJob.getName()); } } @@ -184,13 +162,10 @@ public class ScheduledJobAction extends BsScheduledJobAction { } protected ScheduledJob getScheduledJob() { - final ScheduledJob scheduledJob = scheduledJobService - .getScheduledJob(createKeyMap()); + final ScheduledJob scheduledJob = scheduledJobService.getScheduledJob(createKeyMap()); if (scheduledJob == null) { // throw an exception - throw new SSCActionMessagesException( - "errors.crud_could_not_find_crud_table", - new Object[] { scheduledJobForm.id }); + throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { scheduledJobForm.id }); } return scheduledJob; } diff --git a/src/main/java/org/codelibs/fess/action/admin/SearchListAction.java b/src/main/java/org/codelibs/fess/action/admin/SearchListAction.java index a91a7e860..da8946a8d 100644 --- a/src/main/java/org/codelibs/fess/action/admin/SearchListAction.java +++ b/src/main/java/org/codelibs/fess/action/admin/SearchListAction.java @@ -50,8 +50,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class SearchListAction implements Serializable { - private static final Logger logger = LoggerFactory - .getLogger(SearchListAction.class); + private static final Logger logger = LoggerFactory.getLogger(SearchListAction.class); private static final long serialVersionUID = 1L; @@ -161,10 +160,9 @@ public class SearchListAction implements Serializable { final int offset = Integer.parseInt(searchListForm.start); final int size = Integer.parseInt(searchListForm.num); try { - documentItems = searchService.getDocumentList(query, offset, size, - null, null, null, queryHelper.getResponseFields(), - new String[] { fieldHelper.clickCountField, - fieldHelper.favoriteCountField }, false); + documentItems = + searchService.getDocumentList(query, offset, size, null, null, null, queryHelper.getResponseFields(), new String[] { + fieldHelper.clickCountField, fieldHelper.favoriteCountField }, false); } catch (final InvalidQueryException e) { if (logger.isDebugEnabled()) { logger.debug(e.getMessage(), e); @@ -174,25 +172,19 @@ public class SearchListAction implements Serializable { if (logger.isDebugEnabled()) { logger.debug(e.getMessage(), e); } - throw new SSCActionMessagesException(e, - "errors.result_size_exceeded"); + throw new SSCActionMessagesException(e, "errors.result_size_exceeded"); } final QueryResponseList queryResponseList = (QueryResponseList) documentItems; - final NumberFormat nf = NumberFormat.getInstance(RequestUtil - .getRequest().getLocale()); + final NumberFormat nf = NumberFormat.getInstance(RequestUtil.getRequest().getLocale()); nf.setMaximumIntegerDigits(2); nf.setMaximumFractionDigits(2); try { - execTime = nf - .format((double) queryResponseList.getExecTime() / 1000); - } catch (final Exception e) { - } + execTime = nf.format((double) queryResponseList.getExecTime() / 1000); + } catch (final Exception e) {} Beans.copy(documentItems, this) - .includes("pageSize", "currentPageNumber", "allRecordCount", - "allPageCount", "existNextPage", "existPrevPage", - "currentStartRecordNumber", "currentEndRecordNumber", - "pageNumberList").execute(); + .includes("pageSize", "currentPageNumber", "allRecordCount", "allPageCount", "existNextPage", "existPrevPage", + "currentStartRecordNumber", "currentEndRecordNumber", "pageNumberList").execute(); return query; } @@ -261,14 +253,11 @@ public class SearchListAction implements Serializable { private String deleteByQuery(final String docId) { if (jobHelper.isCrawlProcessRunning()) { - throw new SSCActionMessagesException( - "errors.failed_to_start_solr_process_because_of_running"); + throw new SSCActionMessagesException("errors.failed_to_start_solr_process_because_of_running"); } - final SolrGroup solrGroup = solrGroupManager - .getSolrGroup(QueryType.DELETE); + final SolrGroup solrGroup = solrGroupManager.getSolrGroup(QueryType.DELETE); if (solrGroup == null) { - throw new SSCActionMessagesException( - "errors.failed_to_delete_solr_index"); + throw new SSCActionMessagesException("errors.failed_to_delete_solr_index"); } else { final Thread thread = new Thread(new Runnable() { @Override @@ -276,23 +265,17 @@ public class SearchListAction implements Serializable { if (!jobHelper.isCrawlProcessRunning()) { final long time = System.currentTimeMillis(); try { - solrGroup.deleteByQuery(fieldHelper.docIdField - + ":" + docId); + solrGroup.deleteByQuery(fieldHelper.docIdField + ":" + docId); solrGroup.commit(true, true, false, true); if (logger.isInfoEnabled()) { - logger.info("[EXEC TIME] index cleanup time: " - + (System.currentTimeMillis() - time) - + "ms"); + logger.info("[EXEC TIME] index cleanup time: " + (System.currentTimeMillis() - time) + "ms"); } } catch (final Exception e) { - logger.error("Failed to delete index (query=" - + fieldHelper.docIdField + ":" + docId - + ").", e); + logger.error("Failed to delete index (query=" + fieldHelper.docIdField + ":" + docId + ").", e); } } else { if (logger.isInfoEnabled()) { - logger.info("could not start index cleanup process" - + " because of running solr process."); + logger.info("could not start index cleanup process" + " because of running solr process."); } } } @@ -300,8 +283,7 @@ public class SearchListAction implements Serializable { thread.start(); SAStrutsUtil.addSessionMessage("success.delete_solr_index"); } - return "search?query=" + S2Functions.u(searchListForm.query) - + "&redirect=true"; + return "search?query=" + S2Functions.u(searchListForm.query) + "&redirect=true"; } public boolean isSolrProcessRunning() { diff --git a/src/main/java/org/codelibs/fess/action/admin/SearchLogAction.java b/src/main/java/org/codelibs/fess/action/admin/SearchLogAction.java index dcbe05153..a802552c2 100644 --- a/src/main/java/org/codelibs/fess/action/admin/SearchLogAction.java +++ b/src/main/java/org/codelibs/fess/action/admin/SearchLogAction.java @@ -61,8 +61,7 @@ public class SearchLogAction extends BsSearchLogAction { if (!searchParams.containsKey("startPage")) { searchParams.put("startPage", StringUtil.EMPTY); } - Beans.copy(searchParams, searchLogPager) - .excludes(CommonConstants.PAGER_CONVERSION_RULE).execute(); + Beans.copy(searchParams, searchLogPager).excludes(CommonConstants.PAGER_CONVERSION_RULE).execute(); return displayList(false); } @@ -78,21 +77,17 @@ public class SearchLogAction extends BsSearchLogAction { public String download() { BufferedWriter writer = null; final SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); - final String fileName = "FessSearchLog_" + sdf.format(new Date()) - + ".csv"; + final String fileName = "FessSearchLog_" + sdf.format(new Date()) + ".csv"; final HttpServletResponse response = ResponseUtil.getResponse(); response.setContentType("text/csv"); - response.setHeader("Content-disposition", "attachment; filename=\"" - + fileName + "\""); + response.setHeader("Content-disposition", "attachment; filename=\"" + fileName + "\""); try { - writer = new BufferedWriter(new OutputStreamWriter( - response.getOutputStream(), getCsvEncoding())); + writer = new BufferedWriter(new OutputStreamWriter(response.getOutputStream(), getCsvEncoding())); searchLogService.dump(writer, searchLogPager); writer.flush(); } catch (final Exception e) { log.error("Could not create FessSearchLog.csv.", e); - throw new SSCActionMessagesException(e, - "errors.could_not_create_search_log_csv"); + throw new SSCActionMessagesException(e, "errors.could_not_create_search_log_csv"); } finally { IOUtils.closeQuietly(writer); } @@ -111,7 +106,6 @@ public class SearchLogAction extends BsSearchLogAction { } public boolean isHasClickLog() { - return searchLogForm.clickLogList != null - && !searchLogForm.clickLogList.isEmpty(); + return searchLogForm.clickLogList != null && !searchLogForm.clickLogList.isEmpty(); } } diff --git a/src/main/java/org/codelibs/fess/action/admin/StatsAction.java b/src/main/java/org/codelibs/fess/action/admin/StatsAction.java index dcabc990d..72611f0dd 100644 --- a/src/main/java/org/codelibs/fess/action/admin/StatsAction.java +++ b/src/main/java/org/codelibs/fess/action/admin/StatsAction.java @@ -70,8 +70,7 @@ public class StatsAction implements Serializable { reportTypeItems = searchFieldLogService.getGroupedFieldNames(); // restore from pager - Beans.copy(statsPager, statsForm.searchParams) - .excludes(CommonConstants.PAGER_CONVERSION_RULE).execute(); + Beans.copy(statsPager, statsForm.searchParams).excludes(CommonConstants.PAGER_CONVERSION_RULE).execute(); if (redirect) { return "index?redirect=true"; @@ -90,8 +89,7 @@ public class StatsAction implements Serializable { // page navi if (StringUtil.isNotBlank(statsForm.pageNumber)) { try { - statsPager.setCurrentPageNumber(Integer - .parseInt(statsForm.pageNumber)); + statsPager.setCurrentPageNumber(Integer.parseInt(statsForm.pageNumber)); } catch (final NumberFormatException e) { if (log.isDebugEnabled()) { log.debug("Invalid value: " + statsForm.pageNumber, e); @@ -104,8 +102,7 @@ public class StatsAction implements Serializable { @Execute(validator = false, input = "error.jsp") public String search() { - Beans.copy(statsForm.searchParams, statsPager) - .excludes(CommonConstants.PAGER_CONVERSION_RULE).execute(); + Beans.copy(statsForm.searchParams, statsPager).excludes(CommonConstants.PAGER_CONVERSION_RULE).execute(); return displayList(false); } diff --git a/src/main/java/org/codelibs/fess/action/admin/SuggestBadWordAction.java b/src/main/java/org/codelibs/fess/action/admin/SuggestBadWordAction.java index 6924fc123..1bc6b6931 100644 --- a/src/main/java/org/codelibs/fess/action/admin/SuggestBadWordAction.java +++ b/src/main/java/org/codelibs/fess/action/admin/SuggestBadWordAction.java @@ -56,8 +56,7 @@ public class SuggestBadWordAction extends BsSuggestBadWordAction { private static final long serialVersionUID = 1L; - private static final Log log = LogFactory - .getLog(SuggestBadWordAction.class); + private static final Log log = LogFactory.getLog(SuggestBadWordAction.class); @Resource protected SystemHelper systemHelper; @@ -75,18 +74,13 @@ public class SuggestBadWordAction extends BsSuggestBadWordAction { @Override protected void loadSuggestBadWord() { - final SuggestBadWord suggestBadWord = suggestBadWordService - .getSuggestBadWord(createKeyMap()); + final SuggestBadWord suggestBadWord = suggestBadWordService.getSuggestBadWord(createKeyMap()); if (suggestBadWord == null) { // throw an exception - throw new SSCActionMessagesException( - "errors.crud_could_not_find_crud_table", - new Object[] { suggestBadWordForm.id }); + throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { suggestBadWordForm.id }); } - FessBeans.copy(suggestBadWord, suggestBadWordForm) - .commonColumnDateConverter().excludes("searchParams", "mode") - .execute(); + FessBeans.copy(suggestBadWord, suggestBadWordForm).commonColumnDateConverter().excludes("searchParams", "mode").execute(); } @Override @@ -95,13 +89,10 @@ public class SuggestBadWordAction extends BsSuggestBadWordAction { final String username = systemHelper.getUsername(); final LocalDateTime currentTime = systemHelper.getCurrentTime(); if (suggestBadWordForm.crudMode == CommonConstants.EDIT_MODE) { - suggestBadWord = suggestBadWordService - .getSuggestBadWord(createKeyMap()); + suggestBadWord = suggestBadWordService.getSuggestBadWord(createKeyMap()); if (suggestBadWord == null) { // throw an exception - throw new SSCActionMessagesException( - "errors.crud_could_not_find_crud_table", - new Object[] { suggestBadWordForm.id }); + throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { suggestBadWordForm.id }); } } else { suggestBadWord = new SuggestBadWord(); @@ -110,8 +101,7 @@ public class SuggestBadWordAction extends BsSuggestBadWordAction { } suggestBadWord.setUpdatedBy(username); suggestBadWord.setUpdatedTime(currentTime); - FessBeans.copy(suggestBadWordForm, suggestBadWord) - .excludesCommonColumns().execute(); + FessBeans.copy(suggestBadWordForm, suggestBadWord).excludesCommonColumns().execute(); return suggestBadWord; } @@ -120,19 +110,15 @@ public class SuggestBadWordAction extends BsSuggestBadWordAction { @Execute(validator = false, input = "error.jsp") public String delete() { if (suggestBadWordForm.crudMode != CommonConstants.DELETE_MODE) { - throw new SSCActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - suggestBadWordForm.crudMode }); + throw new SSCActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, + suggestBadWordForm.crudMode }); } try { - final SuggestBadWord suggestBadWord = suggestBadWordService - .getSuggestBadWord(createKeyMap()); + final SuggestBadWord suggestBadWord = suggestBadWordService.getSuggestBadWord(createKeyMap()); if (suggestBadWord == null) { // throw an exception - throw new SSCActionMessagesException( - "errors.crud_could_not_find_crud_table", - new Object[] { suggestBadWordForm.id }); + throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { suggestBadWordForm.id }); } // suggestBadWordService.delete(suggestBadWord); @@ -151,12 +137,10 @@ public class SuggestBadWordAction extends BsSuggestBadWordAction { throw e; } catch (final CrudMessageException e) { log.error(e.getMessage(), e); - throw new SSCActionMessagesException(e, e.getMessageId(), - e.getArgs()); + throw new SSCActionMessagesException(e, e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new SSCActionMessagesException(e, - "errors.crud_failed_to_delete_crud_table"); + throw new SSCActionMessagesException(e, "errors.crud_failed_to_delete_crud_table"); } } @@ -180,8 +164,7 @@ public class SuggestBadWordAction extends BsSuggestBadWordAction { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_create_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_create_crud_table"); } } @@ -205,8 +188,7 @@ public class SuggestBadWordAction extends BsSuggestBadWordAction { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_update_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_update_crud_table"); } } @@ -222,17 +204,15 @@ public class SuggestBadWordAction extends BsSuggestBadWordAction { final HttpServletResponse response = ResponseUtil.getResponse(); response.setContentType("application/octet-stream"); - response.setHeader("Content-Disposition", "attachment; filename=\"" - + "badword.csv" + "\""); + response.setHeader("Content-Disposition", "attachment; filename=\"" + "badword.csv" + "\""); - try (Writer writer = new BufferedWriter(new OutputStreamWriter( - response.getOutputStream(), crawlerProperties.getProperty( + try (Writer writer = + new BufferedWriter(new OutputStreamWriter(response.getOutputStream(), crawlerProperties.getProperty( Constants.CSV_FILE_ENCODING_PROPERTY, Constants.UTF_8)))) { suggestBadWordService.exportCsv(writer); } catch (final Exception e) { log.error("Failed to export data.", e); - throw new SSCActionMessagesException(e, - "errors.failed_to_export_data"); + throw new SSCActionMessagesException(e, "errors.failed_to_export_data"); } return null; } @@ -252,8 +232,7 @@ public class SuggestBadWordAction extends BsSuggestBadWordAction { final byte[] b = new byte[20]; try { tempFile = File.createTempFile("suggestbadword-import-", ".csv"); - is = new BufferedInputStream( - suggestBadWordForm.suggestBadWordFile.getInputStream()); + is = new BufferedInputStream(suggestBadWordForm.suggestBadWordFile.getInputStream()); is.mark(20); if (is.read(b, 0, 20) <= 0) { throw new FessSystemException("no import data."); @@ -266,8 +245,7 @@ public class SuggestBadWordAction extends BsSuggestBadWordAction { log.warn("Could not delete " + tempFile.getAbsolutePath()); } log.error("Failed to import data.", e); - throw new SSCActionMessagesException(e, - "errors.failed_to_import_data"); + throw new SSCActionMessagesException(e, "errors.failed_to_import_data"); } finally { IOUtils.closeQuietly(is); IOUtils.closeQuietly(fos); @@ -277,29 +255,23 @@ public class SuggestBadWordAction extends BsSuggestBadWordAction { try { final String head = new String(b, Constants.UTF_8); if (!(head.startsWith("\"BadWord\"") || head.startsWith("BadWord"))) { - log.error("Unknown file: " - + suggestBadWordForm.suggestBadWordFile); - throw new SSCActionMessagesException( - "errors.unknown_import_file"); + log.error("Unknown file: " + suggestBadWordForm.suggestBadWordFile); + throw new SSCActionMessagesException("errors.unknown_import_file"); } - final String enc = crawlerProperties.getProperty( - Constants.CSV_FILE_ENCODING_PROPERTY, Constants.UTF_8); + final String enc = crawlerProperties.getProperty(Constants.CSV_FILE_ENCODING_PROPERTY, Constants.UTF_8); new Thread(new Runnable() { @Override public void run() { Reader reader = null; try { - reader = new BufferedReader(new InputStreamReader( - new FileInputStream(oFile), enc)); + reader = new BufferedReader(new InputStreamReader(new FileInputStream(oFile), enc)); suggestBadWordService.importCsv(reader); } catch (final Exception e) { log.error("Failed to import data.", e); - throw new FessSystemException("Failed to import data.", - e); + throw new FessSystemException("Failed to import data.", e); } finally { if (!oFile.delete()) { - log.warn("Could not delete " - + oFile.getAbsolutePath()); + log.warn("Could not delete " + oFile.getAbsolutePath()); } IOUtils.closeQuietly(reader); suggestHelper.deleteAllBadWord(); @@ -317,8 +289,7 @@ public class SuggestBadWordAction extends BsSuggestBadWordAction { log.warn("Could not delete " + oFile.getAbsolutePath()); } log.error("Failed to import data.", e); - throw new SSCActionMessagesException(e, - "errors.failed_to_import_data"); + throw new SSCActionMessagesException(e, "errors.failed_to_import_data"); } SAStrutsUtil.addSessionMessage("success.upload_suggest_bad_word"); diff --git a/src/main/java/org/codelibs/fess/action/admin/SuggestElevateWordAction.java b/src/main/java/org/codelibs/fess/action/admin/SuggestElevateWordAction.java index a5ff1aa19..e78d8a83c 100644 --- a/src/main/java/org/codelibs/fess/action/admin/SuggestElevateWordAction.java +++ b/src/main/java/org/codelibs/fess/action/admin/SuggestElevateWordAction.java @@ -56,8 +56,7 @@ public class SuggestElevateWordAction extends BsSuggestElevateWordAction { private static final long serialVersionUID = 1L; - private static final Log log = LogFactory - .getLog(SuggestElevateWordAction.class); + private static final Log log = LogFactory.getLog(SuggestElevateWordAction.class); @Resource protected SystemHelper systemHelper; @@ -75,18 +74,13 @@ public class SuggestElevateWordAction extends BsSuggestElevateWordAction { @Override protected void loadSuggestElevateWord() { - final SuggestElevateWord suggestElevateWord = suggestElevateWordService - .getSuggestElevateWord(createKeyMap()); + final SuggestElevateWord suggestElevateWord = suggestElevateWordService.getSuggestElevateWord(createKeyMap()); if (suggestElevateWord == null) { // throw an exception - throw new SSCActionMessagesException( - "errors.crud_could_not_find_crud_table", - new Object[] { suggestElevateWordForm.id }); + throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { suggestElevateWordForm.id }); } - FessBeans.copy(suggestElevateWord, suggestElevateWordForm) - .commonColumnDateConverter().excludes("searchParams", "mode") - .execute(); + FessBeans.copy(suggestElevateWord, suggestElevateWordForm).commonColumnDateConverter().excludes("searchParams", "mode").execute(); } @Override @@ -95,13 +89,10 @@ public class SuggestElevateWordAction extends BsSuggestElevateWordAction { final String username = systemHelper.getUsername(); final LocalDateTime currentTime = systemHelper.getCurrentTime(); if (suggestElevateWordForm.crudMode == CommonConstants.EDIT_MODE) { - suggestElevateWord = suggestElevateWordService - .getSuggestElevateWord(createKeyMap()); + suggestElevateWord = suggestElevateWordService.getSuggestElevateWord(createKeyMap()); if (suggestElevateWord == null) { // throw an exception - throw new SSCActionMessagesException( - "errors.crud_could_not_find_crud_table", - new Object[] { suggestElevateWordForm.id }); + throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { suggestElevateWordForm.id }); } } else { suggestElevateWord = new SuggestElevateWord(); @@ -110,8 +101,7 @@ public class SuggestElevateWordAction extends BsSuggestElevateWordAction { } suggestElevateWord.setUpdatedBy(username); suggestElevateWord.setUpdatedTime(currentTime); - FessBeans.copy(suggestElevateWordForm, suggestElevateWord) - .excludesCommonColumns().execute(); + FessBeans.copy(suggestElevateWordForm, suggestElevateWord).excludesCommonColumns().execute(); return suggestElevateWord; } @@ -135,8 +125,7 @@ public class SuggestElevateWordAction extends BsSuggestElevateWordAction { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_create_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_create_crud_table"); } } @@ -159,8 +148,7 @@ public class SuggestElevateWordAction extends BsSuggestElevateWordAction { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_update_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_update_crud_table"); } } @@ -168,19 +156,15 @@ public class SuggestElevateWordAction extends BsSuggestElevateWordAction { @Execute(validator = false, input = "error.jsp") public String delete() { if (suggestElevateWordForm.crudMode != CommonConstants.DELETE_MODE) { - throw new SSCActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - suggestElevateWordForm.crudMode }); + throw new SSCActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, + suggestElevateWordForm.crudMode }); } try { - final SuggestElevateWord suggestElevateWord = suggestElevateWordService - .getSuggestElevateWord(createKeyMap()); + final SuggestElevateWord suggestElevateWord = suggestElevateWordService.getSuggestElevateWord(createKeyMap()); if (suggestElevateWord == null) { // throw an exception - throw new SSCActionMessagesException( - "errors.crud_could_not_find_crud_table", - new Object[] { suggestElevateWordForm.id }); + throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { suggestElevateWordForm.id }); } // suggestElevateWordService.delete(suggestElevateWord); @@ -198,12 +182,10 @@ public class SuggestElevateWordAction extends BsSuggestElevateWordAction { throw e; } catch (final CrudMessageException e) { log.error(e.getMessage(), e); - throw new SSCActionMessagesException(e, e.getMessageId(), - e.getArgs()); + throw new SSCActionMessagesException(e, e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new SSCActionMessagesException(e, - "errors.crud_failed_to_delete_crud_table"); + throw new SSCActionMessagesException(e, "errors.crud_failed_to_delete_crud_table"); } } @@ -219,17 +201,15 @@ public class SuggestElevateWordAction extends BsSuggestElevateWordAction { final HttpServletResponse response = ResponseUtil.getResponse(); response.setContentType("application/octet-stream"); - response.setHeader("Content-Disposition", "attachment; filename=\"" - + "elevateword.csv" + "\""); + response.setHeader("Content-Disposition", "attachment; filename=\"" + "elevateword.csv" + "\""); - try (Writer writer = new BufferedWriter(new OutputStreamWriter( - response.getOutputStream(), crawlerProperties.getProperty( + try (Writer writer = + new BufferedWriter(new OutputStreamWriter(response.getOutputStream(), crawlerProperties.getProperty( Constants.CSV_FILE_ENCODING_PROPERTY, Constants.UTF_8)))) { suggestElevateWordService.exportCsv(writer); } catch (final Exception e) { log.error("Failed to export data.", e); - throw new SSCActionMessagesException(e, - "errors.failed_to_export_data"); + throw new SSCActionMessagesException(e, "errors.failed_to_export_data"); } return null; } @@ -248,11 +228,8 @@ public class SuggestElevateWordAction extends BsSuggestElevateWordAction { FileOutputStream fos = null; final byte[] b = new byte[20]; try { - tempFile = File - .createTempFile("suggestelevateword-import-", ".csv"); - is = new BufferedInputStream( - suggestElevateWordForm.suggestElevateWordFile - .getInputStream()); + tempFile = File.createTempFile("suggestelevateword-import-", ".csv"); + is = new BufferedInputStream(suggestElevateWordForm.suggestElevateWordFile.getInputStream()); is.mark(20); if (is.read(b, 0, 20) <= 0) { throw new FessSystemException("no import data."); @@ -265,8 +242,7 @@ public class SuggestElevateWordAction extends BsSuggestElevateWordAction { log.warn("Could not delete " + tempFile.getAbsolutePath()); } log.error("Failed to import data.", e); - throw new SSCActionMessagesException(e, - "errors.failed_to_import_data"); + throw new SSCActionMessagesException(e, "errors.failed_to_import_data"); } finally { IOUtils.closeQuietly(is); IOUtils.closeQuietly(fos); @@ -275,31 +251,24 @@ public class SuggestElevateWordAction extends BsSuggestElevateWordAction { final File oFile = tempFile; try { final String head = new String(b, Constants.UTF_8); - if (!(head.startsWith("\"SuggestWord\"") || head - .startsWith("SuggestWord"))) { - log.error("Unknown file: " - + suggestElevateWordForm.suggestElevateWordFile); - throw new SSCActionMessagesException( - "errors.unknown_import_file"); + if (!(head.startsWith("\"SuggestWord\"") || head.startsWith("SuggestWord"))) { + log.error("Unknown file: " + suggestElevateWordForm.suggestElevateWordFile); + throw new SSCActionMessagesException("errors.unknown_import_file"); } - final String enc = crawlerProperties.getProperty( - Constants.CSV_FILE_ENCODING_PROPERTY, Constants.UTF_8); + final String enc = crawlerProperties.getProperty(Constants.CSV_FILE_ENCODING_PROPERTY, Constants.UTF_8); new Thread(new Runnable() { @Override public void run() { Reader reader = null; try { - reader = new BufferedReader(new InputStreamReader( - new FileInputStream(oFile), enc)); + reader = new BufferedReader(new InputStreamReader(new FileInputStream(oFile), enc)); suggestElevateWordService.importCsv(reader); } catch (final Exception e) { log.error("Failed to import data.", e); - throw new FessSystemException("Failed to import data.", - e); + throw new FessSystemException("Failed to import data.", e); } finally { if (!oFile.delete()) { - log.warn("Could not delete " - + oFile.getAbsolutePath()); + log.warn("Could not delete " + oFile.getAbsolutePath()); } IOUtils.closeQuietly(reader); suggestHelper.storeAllElevateWords(); @@ -316,8 +285,7 @@ public class SuggestElevateWordAction extends BsSuggestElevateWordAction { log.warn("Could not delete " + oFile.getAbsolutePath()); } log.error("Failed to import data.", e); - throw new SSCActionMessagesException(e, - "errors.failed_to_import_data"); + throw new SSCActionMessagesException(e, "errors.failed_to_import_data"); } SAStrutsUtil.addSessionMessage("success.upload_suggest_elevate_word"); diff --git a/src/main/java/org/codelibs/fess/action/admin/SystemAction.java b/src/main/java/org/codelibs/fess/action/admin/SystemAction.java index 93431fb75..837941b5b 100644 --- a/src/main/java/org/codelibs/fess/action/admin/SystemAction.java +++ b/src/main/java/org/codelibs/fess/action/admin/SystemAction.java @@ -54,8 +54,7 @@ import org.slf4j.LoggerFactory; public class SystemAction implements Serializable { private static final String STARTING_CRAWL_PROCESS = "startingCrawlProcess"; - private static final Logger logger = LoggerFactory - .getLogger(SystemAction.class); + private static final Logger logger = LoggerFactory.getLogger(SystemAction.class); private static final long serialVersionUID = 1L; @@ -88,8 +87,7 @@ public class SystemAction implements Serializable { protected String showIndex(final boolean redirect) { final Map groupPropMap = new HashMap(); for (final String groupName : solrGroupManager.getSolrGroupNames()) { - final DynamicProperties props = ComponentUtil - .getSolrGroupProperties(groupName); + final DynamicProperties props = ComponentUtil.getSolrGroupProperties(groupName); if (props != null) { groupPropMap.put(groupName, props); } @@ -106,16 +104,12 @@ public class SystemAction implements Serializable { map.put("serverName", names[1]); final DynamicProperties props = groupPropMap.get(names[0]); if (props != null) { - String status = props - .getProperty(StatusPolicyImpl.STATUS_PREFIX - + names[1]); + String status = props.getProperty(StatusPolicyImpl.STATUS_PREFIX + names[1]); if (StringUtil.isBlank(status)) { status = StatusPolicyImpl.ACTIVE; } map.put("status", status); - String index = props - .getProperty(StatusPolicyImpl.INDEX_PREFIX - + names[1]); + String index = props.getProperty(StatusPolicyImpl.INDEX_PREFIX + names[1]); if (StringUtil.isBlank(index)) { index = StatusPolicyImpl.READY; } @@ -128,24 +122,18 @@ public class SystemAction implements Serializable { } } // select group status - systemForm.currentServerForSelect = solrProperties - .getProperty(SolrLibConstants.SELECT_GROUP); - final SolrGroup selectSolrGroup = solrGroupManager - .getSolrGroup(systemForm.currentServerForSelect); - if (selectSolrGroup != null - && selectSolrGroup.isActive(QueryType.QUERY)) { + systemForm.currentServerForSelect = solrProperties.getProperty(SolrLibConstants.SELECT_GROUP); + final SolrGroup selectSolrGroup = solrGroupManager.getSolrGroup(systemForm.currentServerForSelect); + if (selectSolrGroup != null && selectSolrGroup.isActive(QueryType.QUERY)) { systemForm.currentServerStatusForSelect = Constants.ACTIVE; } else { systemForm.currentServerStatusForSelect = Constants.INACTIVE; } // update group status - systemForm.currentServerForUpdate = solrProperties - .getProperty(SolrLibConstants.SELECT_GROUP); - final SolrGroup updateSolrGroup = solrGroupManager - .getSolrGroup(systemForm.currentServerForUpdate); - if (updateSolrGroup != null - && updateSolrGroup.isActive(QueryType.QUERY)) { + systemForm.currentServerForUpdate = solrProperties.getProperty(SolrLibConstants.SELECT_GROUP); + final SolrGroup updateSolrGroup = solrGroupManager.getSolrGroup(systemForm.currentServerForUpdate); + if (updateSolrGroup != null && updateSolrGroup.isActive(QueryType.QUERY)) { systemForm.currentServerStatusForUpdate = Constants.ACTIVE; } else { systemForm.currentServerStatusForUpdate = Constants.INACTIVE; @@ -170,8 +158,7 @@ public class SystemAction implements Serializable { // load solr group properties final Map groupPropMap = new HashMap(); for (final String groupName : solrGroupManager.getSolrGroupNames()) { - final DynamicProperties props = ComponentUtil - .getSolrGroupProperties(groupName); + final DynamicProperties props = ComponentUtil.getSolrGroupProperties(groupName); if (props != null) { groupPropMap.put(groupName, props); } @@ -180,12 +167,10 @@ public class SystemAction implements Serializable { try { // server status for (final Map statusMap : systemForm.serverStatusList) { - for (final Map.Entry entry : statusMap - .entrySet()) { + for (final Map.Entry entry : statusMap.entrySet()) { final String[] names = entry.getKey().split("/"); if (names.length == 3) { - final DynamicProperties props = groupPropMap - .get(names[0]); + final DynamicProperties props = groupPropMap.get(names[0]); if (props != null) { final String value = entry.getValue(); String key; @@ -194,16 +179,13 @@ public class SystemAction implements Serializable { } else if ("index".equals(names[2])) { key = StatusPolicyImpl.INDEX_PREFIX + names[1]; } else { - logger.error("Invalid parameter: " - + entry.getKey()); - throw new SSCActionMessagesException( - "errors.failed_to_update_solr_params"); + logger.error("Invalid parameter: " + entry.getKey()); + throw new SSCActionMessagesException("errors.failed_to_update_solr_params"); } props.setProperty(key, value); props.store(); } else { - logger.warn("Solr group properties is not found: " - + names[0]); + logger.warn("Solr group properties is not found: " + names[0]); } } } @@ -212,8 +194,7 @@ public class SystemAction implements Serializable { SAStrutsUtil.addSessionMessage("success.update_solr_params"); } catch (final Exception e) { logger.error("Failed to update solr parameters.", e); - throw new SSCActionMessagesException(e, - "errors.failed_to_update_solr_params", e); + throw new SSCActionMessagesException(e, "errors.failed_to_update_solr_params", e); } return showIndex(true); @@ -223,26 +204,21 @@ public class SystemAction implements Serializable { @Token(save = false, validate = true) @Execute(validator = true, input = "index") public String start() { - final String groupName = solrProperties - .getProperty(SolrLibConstants.UPDATE_GROUP); + final String groupName = solrProperties.getProperty(SolrLibConstants.UPDATE_GROUP); final SolrGroup solrGroup = solrGroupManager.getSolrGroup(groupName); if (solrGroup != null) { if (!jobHelper.isCrawlProcessRunning()) { - final List scheduledJobList = scheduledJobService - .getCrawloerJobList(); + final List scheduledJobList = scheduledJobService.getCrawloerJobList(); for (final ScheduledJob scheduledJob : scheduledJobList) { scheduledJob.start(); } SAStrutsUtil.addSessionMessage("success.start_crawl_process"); - RequestUtil.getRequest().getSession() - .setAttribute(STARTING_CRAWL_PROCESS, Boolean.TRUE); + RequestUtil.getRequest().getSession().setAttribute(STARTING_CRAWL_PROCESS, Boolean.TRUE); } else { - SAStrutsUtil - .addSessionMessage("success.failed_to_start_crawl_process"); + SAStrutsUtil.addSessionMessage("success.failed_to_start_crawl_process"); } } else { - SAStrutsUtil - .addSessionMessage("success.failed_to_start_crawl_process"); + SAStrutsUtil.addSessionMessage("success.failed_to_start_crawl_process"); } return showIndex(true); } @@ -254,8 +230,7 @@ public class SystemAction implements Serializable { if (StringUtil.isNotBlank(systemForm.sessionId)) { jobHelper.destroyCrawlerProcess(systemForm.sessionId); } else { - for (final String sessionId : jobHelper - .getRunningSessionIdSet()) { + for (final String sessionId : jobHelper.getRunningSessionIdSet()) { jobHelper.destroyCrawlerProcess(sessionId); } } @@ -273,10 +248,8 @@ public class SystemAction implements Serializable { webManagementHelper.start(systemForm.solrInstanceName); SAStrutsUtil.addSessionMessage("success.starting_solr_instance"); } catch (final Exception e) { - logger.error("Failed to start a solr instance: " - + systemForm.solrInstanceName, e); - throw new SSCActionMessagesException(e, - "errors.failed_to_start_solr_instance"); + logger.error("Failed to start a solr instance: " + systemForm.solrInstanceName, e); + throw new SSCActionMessagesException(e, "errors.failed_to_start_solr_instance"); } return showIndex(true); } @@ -288,10 +261,8 @@ public class SystemAction implements Serializable { webManagementHelper.stop(systemForm.solrInstanceName); SAStrutsUtil.addSessionMessage("success.stopping_solr_instance"); } catch (final Exception e) { - logger.error("Failed to stop a solr instance: " - + systemForm.solrInstanceName, e); - throw new SSCActionMessagesException(e, - "errors.failed_to_stop_solr_instance"); + logger.error("Failed to stop a solr instance: " + systemForm.solrInstanceName, e); + throw new SSCActionMessagesException(e, "errors.failed_to_stop_solr_instance"); } return showIndex(true); } @@ -303,17 +274,14 @@ public class SystemAction implements Serializable { webManagementHelper.reload(systemForm.solrInstanceName); SAStrutsUtil.addSessionMessage("success.reloading_solr_instance"); } catch (final Exception e) { - logger.error("Failed to reload a solr instance: " - + systemForm.solrInstanceName, e); - throw new SSCActionMessagesException(e, - "errors.failed_to_reload_solr_instance"); + logger.error("Failed to reload a solr instance: " + systemForm.solrInstanceName, e); + throw new SSCActionMessagesException(e, "errors.failed_to_reload_solr_instance"); } return showIndex(true); } public List> getSolrInstanceList() { - final List solrInstanceNameList = webManagementHelper - .getSolrInstanceNameList(); + final List solrInstanceNameList = webManagementHelper.getSolrInstanceNameList(); final List> solrInstanceList = new ArrayList>(); for (final String solrInstanceName : solrInstanceNameList) { final Map map = new HashMap(); diff --git a/src/main/java/org/codelibs/fess/action/admin/SystemInfoAction.java b/src/main/java/org/codelibs/fess/action/admin/SystemInfoAction.java index 4c628b5b5..63bc07ccd 100644 --- a/src/main/java/org/codelibs/fess/action/admin/SystemInfoAction.java +++ b/src/main/java/org/codelibs/fess/action/admin/SystemInfoAction.java @@ -69,13 +69,11 @@ public class SystemInfoAction implements Serializable { envItems.add(createItem(entry.getKey(), entry.getValue())); } - for (final Map.Entry entry : System.getProperties() - .entrySet()) { + for (final Map.Entry entry : System.getProperties().entrySet()) { propItems.add(createItem(entry.getKey(), entry.getValue())); } - for (final Map.Entry entry : crawlerProperties - .entrySet()) { + for (final Map.Entry entry : crawlerProperties.entrySet()) { fessPropItems.add(createItem(entry.getKey(), entry.getValue())); } @@ -92,11 +90,9 @@ public class SystemInfoAction implements Serializable { bugReportItems.add(createPropItem("user.country")); bugReportItems.add(createPropItem("user.language")); bugReportItems.add(createPropItem("user.timezone")); - for (final Map.Entry entry : crawlerProperties - .entrySet()) { + for (final Map.Entry entry : crawlerProperties.entrySet()) { if (isBugReportTarget(entry.getKey())) { - bugReportItems - .add(createItem(entry.getKey(), entry.getValue())); + bugReportItems.add(createItem(entry.getKey(), entry.getValue())); } } @@ -114,13 +110,10 @@ public class SystemInfoAction implements Serializable { return createItem(key, System.getProperty(key)); } - private Map createItem(final Object label, - final Object value) { + private Map createItem(final Object label, final Object value) { final Map map = new HashMap(2); - map.put(Constants.ITEM_LABEL, label != null ? label.toString() - : StringUtil.EMPTY); - map.put(Constants.ITEM_VALUE, value != null ? value.toString() - : StringUtil.EMPTY); + map.put(Constants.ITEM_LABEL, label != null ? label.toString() : StringUtil.EMPTY); + map.put(Constants.ITEM_VALUE, value != null ? value.toString() : StringUtil.EMPTY); return map; } } \ No newline at end of file diff --git a/src/main/java/org/codelibs/fess/action/admin/WebAuthenticationAction.java b/src/main/java/org/codelibs/fess/action/admin/WebAuthenticationAction.java index 8756abad9..a037a875e 100644 --- a/src/main/java/org/codelibs/fess/action/admin/WebAuthenticationAction.java +++ b/src/main/java/org/codelibs/fess/action/admin/WebAuthenticationAction.java @@ -48,8 +48,7 @@ public class WebAuthenticationAction extends BsWebAuthenticationAction { private static final long serialVersionUID = 1L; - private static final Log log = LogFactory - .getLog(WebAuthenticationAction.class); + private static final Log log = LogFactory.getLog(WebAuthenticationAction.class); @Resource protected WebCrawlingConfigService webCrawlingConfigService; @@ -64,18 +63,13 @@ public class WebAuthenticationAction extends BsWebAuthenticationAction { @Override protected void loadWebAuthentication() { - final WebAuthentication webAuthentication = webAuthenticationService - .getWebAuthentication(createKeyMap()); + final WebAuthentication webAuthentication = webAuthenticationService.getWebAuthentication(createKeyMap()); if (webAuthentication == null) { // throw an exception - throw new SSCActionMessagesException( - "errors.crud_could_not_find_crud_table", - new Object[] { webAuthenticationForm.id }); + throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { webAuthenticationForm.id }); } - FessBeans.copy(webAuthentication, webAuthenticationForm) - .commonColumnDateConverter().excludes("searchParams", "mode") - .execute(); + FessBeans.copy(webAuthentication, webAuthenticationForm).commonColumnDateConverter().excludes("searchParams", "mode").execute(); if ("-1".equals(webAuthenticationForm.port)) { webAuthenticationForm.port = StringUtil.EMPTY; } @@ -87,13 +81,10 @@ public class WebAuthenticationAction extends BsWebAuthenticationAction { final String username = systemHelper.getUsername(); final LocalDateTime currentTime = systemHelper.getCurrentTime(); if (webAuthenticationForm.crudMode == CommonConstants.EDIT_MODE) { - webAuthentication = webAuthenticationService - .getWebAuthentication(createKeyMap()); + webAuthentication = webAuthenticationService.getWebAuthentication(createKeyMap()); if (webAuthentication == null) { // throw an exception - throw new SSCActionMessagesException( - "errors.crud_could_not_find_crud_table", - new Object[] { webAuthenticationForm.id }); + throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { webAuthenticationForm.id }); } } else { webAuthentication = new WebAuthentication(); @@ -105,8 +96,7 @@ public class WebAuthenticationAction extends BsWebAuthenticationAction { if (StringUtil.isBlank(webAuthenticationForm.port)) { webAuthenticationForm.port = "-1"; } - FessBeans.copy(webAuthenticationForm, webAuthentication) - .excludesCommonColumns().execute(); + FessBeans.copy(webAuthenticationForm, webAuthentication).excludesCommonColumns().execute(); return webAuthentication; } @@ -116,19 +106,15 @@ public class WebAuthenticationAction extends BsWebAuthenticationAction { @Execute(validator = false, input = "error.jsp") public String delete() { if (webAuthenticationForm.crudMode != CommonConstants.DELETE_MODE) { - throw new SSCActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - webAuthenticationForm.crudMode }); + throw new SSCActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, + webAuthenticationForm.crudMode }); } try { - final WebAuthentication webAuthentication = webAuthenticationService - .getWebAuthentication(createKeyMap()); + final WebAuthentication webAuthentication = webAuthenticationService.getWebAuthentication(createKeyMap()); if (webAuthentication == null) { // throw an exception - throw new SSCActionMessagesException( - "errors.crud_could_not_find_crud_table", - new Object[] { webAuthenticationForm.id }); + throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { webAuthenticationForm.id }); } // webAuthenticationService.delete(webAuthentication); @@ -145,47 +131,42 @@ public class WebAuthenticationAction extends BsWebAuthenticationAction { throw e; } catch (final CrudMessageException e) { log.error(e.getMessage(), e); - throw new SSCActionMessagesException(e, e.getMessageId(), - e.getArgs()); + throw new SSCActionMessagesException(e, e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new SSCActionMessagesException(e, - "errors.crud_failed_to_delete_crud_table"); + throw new SSCActionMessagesException(e, "errors.crud_failed_to_delete_crud_table"); } } public boolean isDisplayCreateLink() { - return !webCrawlingConfigService.getAllWebCrawlingConfigList(false, - false, false, null).isEmpty(); + return !webCrawlingConfigService.getAllWebCrawlingConfigList(false, false, false, null).isEmpty(); } public List> getWebCrawlingConfigItems() { final List> items = new ArrayList>(); - final List webCrawlingConfigList = webCrawlingConfigService - .getAllWebCrawlingConfigList(false, false, false, null); + final List webCrawlingConfigList = + webCrawlingConfigService.getAllWebCrawlingConfigList(false, false, false, null); for (final WebCrawlingConfig webCrawlingConfig : webCrawlingConfigList) { - items.add(createItem(webCrawlingConfig.getName(), webCrawlingConfig - .getId().toString())); + items.add(createItem(webCrawlingConfig.getName(), webCrawlingConfig.getId().toString())); } return items; } public List> getProtocolSchemeItems() { final List> items = new ArrayList>(); - items.add(createItem(MessageResourcesUtil.getMessage(RequestUtil - .getRequest().getLocale(), - "labels.web_authentication_scheme_basic"), Constants.BASIC)); - items.add(createItem(MessageResourcesUtil.getMessage(RequestUtil - .getRequest().getLocale(), - "labels.web_authentication_scheme_digest"), Constants.DIGEST)); - items.add(createItem(MessageResourcesUtil.getMessage(RequestUtil - .getRequest().getLocale(), - "labels.web_authentication_scheme_ntlm"), Constants.NTLM)); + items.add(createItem( + MessageResourcesUtil.getMessage(RequestUtil.getRequest().getLocale(), "labels.web_authentication_scheme_basic"), + Constants.BASIC)); + items.add(createItem( + MessageResourcesUtil.getMessage(RequestUtil.getRequest().getLocale(), "labels.web_authentication_scheme_digest"), + Constants.DIGEST)); + items.add(createItem( + MessageResourcesUtil.getMessage(RequestUtil.getRequest().getLocale(), "labels.web_authentication_scheme_ntlm"), + Constants.NTLM)); return items; } - protected Map createItem(final String label, - final String value) { + protected Map createItem(final String label, final String value) { final Map map = new HashMap(2); map.put("label", label); map.put("value", value); diff --git a/src/main/java/org/codelibs/fess/action/admin/WebCrawlingConfigAction.java b/src/main/java/org/codelibs/fess/action/admin/WebCrawlingConfigAction.java index 51259a587..00b330119 100644 --- a/src/main/java/org/codelibs/fess/action/admin/WebCrawlingConfigAction.java +++ b/src/main/java/org/codelibs/fess/action/admin/WebCrawlingConfigAction.java @@ -44,8 +44,7 @@ public class WebCrawlingConfigAction extends BsWebCrawlingConfigAction { private static final long serialVersionUID = 1L; - private static final Log log = LogFactory - .getLog(WebCrawlingConfigAction.class); + private static final Log log = LogFactory.getLog(WebCrawlingConfigAction.class); @Resource protected RoleTypeService roleTypeService; @@ -66,24 +65,17 @@ public class WebCrawlingConfigAction extends BsWebCrawlingConfigAction { @Override protected void loadWebCrawlingConfig() { - final CrawlingConfig webCrawlingConfig = webCrawlingConfigService - .getWebCrawlingConfig(createKeyMap()); + final CrawlingConfig webCrawlingConfig = webCrawlingConfigService.getWebCrawlingConfig(createKeyMap()); if (webCrawlingConfig == null) { // throw an exception - throw new SSCActionMessagesException( - "errors.crud_could_not_find_crud_table", - new Object[] { webCrawlingConfigForm.id }); + throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { webCrawlingConfigForm.id }); } - FessBeans.copy(webCrawlingConfig, webCrawlingConfigForm) - .commonColumnDateConverter().excludes("searchParams", "mode") - .execute(); + FessBeans.copy(webCrawlingConfig, webCrawlingConfigForm).commonColumnDateConverter().excludes("searchParams", "mode").execute(); // normalize boost - if (webCrawlingConfigForm.boost != null - && webCrawlingConfigForm.boost.indexOf('.') > 0) { - webCrawlingConfigForm.boost = webCrawlingConfigForm.boost - .substring(0, webCrawlingConfigForm.boost.indexOf('.')); + if (webCrawlingConfigForm.boost != null && webCrawlingConfigForm.boost.indexOf('.') > 0) { + webCrawlingConfigForm.boost = webCrawlingConfigForm.boost.substring(0, webCrawlingConfigForm.boost.indexOf('.')); } } @@ -93,13 +85,10 @@ public class WebCrawlingConfigAction extends BsWebCrawlingConfigAction { final String username = systemHelper.getUsername(); final LocalDateTime currentTime = systemHelper.getCurrentTime(); if (webCrawlingConfigForm.crudMode == CommonConstants.EDIT_MODE) { - webCrawlingConfig = webCrawlingConfigService - .getWebCrawlingConfig(createKeyMap()); + webCrawlingConfig = webCrawlingConfigService.getWebCrawlingConfig(createKeyMap()); if (webCrawlingConfig == null) { // throw an exception - throw new SSCActionMessagesException( - "errors.crud_could_not_find_crud_table", - new Object[] { webCrawlingConfigForm.id }); + throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { webCrawlingConfigForm.id }); } } else { webCrawlingConfig = new WebCrawlingConfig(); @@ -108,8 +97,7 @@ public class WebCrawlingConfigAction extends BsWebCrawlingConfigAction { } webCrawlingConfig.setUpdatedBy(username); webCrawlingConfig.setUpdatedTime(currentTime); - FessBeans.copy(webCrawlingConfigForm, webCrawlingConfig) - .excludesCommonColumns().execute(); + FessBeans.copy(webCrawlingConfigForm, webCrawlingConfig).excludesCommonColumns().execute(); return webCrawlingConfig; } @@ -118,19 +106,15 @@ public class WebCrawlingConfigAction extends BsWebCrawlingConfigAction { @Execute(validator = false, input = "error.jsp") public String delete() { if (webCrawlingConfigForm.crudMode != CommonConstants.DELETE_MODE) { - throw new SSCActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - webCrawlingConfigForm.crudMode }); + throw new SSCActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, + webCrawlingConfigForm.crudMode }); } try { - final WebCrawlingConfig webCrawlingConfig = webCrawlingConfigService - .getWebCrawlingConfig(createKeyMap()); + final WebCrawlingConfig webCrawlingConfig = webCrawlingConfigService.getWebCrawlingConfig(createKeyMap()); if (webCrawlingConfig == null) { // throw an exception - throw new SSCActionMessagesException( - "errors.crud_could_not_find_crud_table", - new Object[] { webCrawlingConfigForm.id }); + throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { webCrawlingConfigForm.id }); } failureUrlService.deleteByConfigId(webCrawlingConfig.getConfigId()); @@ -149,12 +133,10 @@ public class WebCrawlingConfigAction extends BsWebCrawlingConfigAction { throw e; } catch (final CrudMessageException e) { log.error(e.getMessage(), e); - throw new SSCActionMessagesException(e, e.getMessageId(), - e.getArgs()); + throw new SSCActionMessagesException(e, e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new SSCActionMessagesException(e, - "errors.crud_failed_to_delete_crud_table"); + throw new SSCActionMessagesException(e, "errors.crud_failed_to_delete_crud_table"); } } diff --git a/src/main/java/org/codelibs/fess/action/admin/WizardAction.java b/src/main/java/org/codelibs/fess/action/admin/WizardAction.java index 80bac1371..8443a3b97 100644 --- a/src/main/java/org/codelibs/fess/action/admin/WizardAction.java +++ b/src/main/java/org/codelibs/fess/action/admin/WizardAction.java @@ -52,8 +52,7 @@ import org.slf4j.LoggerFactory; public class WizardAction implements Serializable { private static final long serialVersionUID = 1L; - private static final Logger logger = LoggerFactory - .getLogger(WizardAction.class); + private static final Logger logger = LoggerFactory.getLogger(WizardAction.class); @ActionForm @Resource @@ -95,25 +94,20 @@ public class WizardAction implements Serializable { @Token(save = false, validate = true) @Execute(validator = true, input = "crawlingConfigForm") public String crawlingConfig() { - final String name = crawlingConfigInternal( - wizardForm.crawlingConfigName, wizardForm.crawlingConfigPath); - SAStrutsUtil.addSessionMessage( - "success.create_crawling_config_at_wizard", name); + final String name = crawlingConfigInternal(wizardForm.crawlingConfigName, wizardForm.crawlingConfigPath); + SAStrutsUtil.addSessionMessage("success.create_crawling_config_at_wizard", name); return "crawlingConfigForm?redirect=true"; } @Token(save = false, validate = true) @Execute(validator = true, input = "crawlingConfigForm") public String crawlingConfigNext() { - final String name = crawlingConfigInternal( - wizardForm.crawlingConfigName, wizardForm.crawlingConfigPath); - SAStrutsUtil.addSessionMessage( - "success.create_crawling_config_at_wizard", name); + final String name = crawlingConfigInternal(wizardForm.crawlingConfigName, wizardForm.crawlingConfigPath); + SAStrutsUtil.addSessionMessage("success.create_crawling_config_at_wizard", name); return "startCrawlingForm?redirect=true"; } - protected String crawlingConfigInternal(final String crawlingConfigName, - final String crawlingConfigPath) { + protected String crawlingConfigInternal(final String crawlingConfigName, final String crawlingConfigPath) { String configName = crawlingConfigName; String configPath = crawlingConfigPath.trim(); @@ -133,10 +127,8 @@ public class WizardAction implements Serializable { buf.append(c); } else { try { - buf.append(URLEncoder.encode(String.valueOf(c), - Constants.UTF_8)); - } catch (final UnsupportedEncodingException e) { - } + buf.append(URLEncoder.encode(String.valueOf(c), Constants.UTF_8)); + } catch (final UnsupportedEncodingException e) {} } } configPath = convertCrawlingPath(buf.toString()); @@ -155,33 +147,21 @@ public class WizardAction implements Serializable { if (StringUtil.isNotBlank(wizardForm.depth)) { wConfig.setDepth(Integer.parseInt(wizardForm.depth)); } - wConfig.setExcludedDocUrls(getDefaultString( - "default.config.web.excludedDocUrls", StringUtil.EMPTY)); - wConfig.setExcludedUrls(getDefaultString( - "default.config.web.excludedUrls", StringUtil.EMPTY)); - wConfig.setIncludedDocUrls(getDefaultString( - "default.config.web.includedDocUrls", StringUtil.EMPTY)); - wConfig.setIncludedUrls(getDefaultString( - "default.config.web.includedUrls", StringUtil.EMPTY)); - wConfig.setIntervalTime(getDefaultInteger( - "default.config.web.intervalTime", - Constants.DEFAULT_INTERVAL_TIME_FOR_WEB)); + wConfig.setExcludedDocUrls(getDefaultString("default.config.web.excludedDocUrls", StringUtil.EMPTY)); + wConfig.setExcludedUrls(getDefaultString("default.config.web.excludedUrls", StringUtil.EMPTY)); + wConfig.setIncludedDocUrls(getDefaultString("default.config.web.includedDocUrls", StringUtil.EMPTY)); + wConfig.setIncludedUrls(getDefaultString("default.config.web.includedUrls", StringUtil.EMPTY)); + wConfig.setIntervalTime(getDefaultInteger("default.config.web.intervalTime", Constants.DEFAULT_INTERVAL_TIME_FOR_WEB)); if (StringUtil.isNotBlank(wizardForm.maxAccessCount)) { - wConfig.setMaxAccessCount(Long - .parseLong(wizardForm.maxAccessCount)); + wConfig.setMaxAccessCount(Long.parseLong(wizardForm.maxAccessCount)); } wConfig.setName(configName); - wConfig.setNumOfThread(getDefaultInteger( - "default.config.web.numOfThread", - Constants.DEFAULT_NUM_OF_THREAD_FOR_WEB)); - wConfig.setSortOrder(getDefaultInteger( - "default.config.web.sortOrder", 1)); + wConfig.setNumOfThread(getDefaultInteger("default.config.web.numOfThread", Constants.DEFAULT_NUM_OF_THREAD_FOR_WEB)); + wConfig.setSortOrder(getDefaultInteger("default.config.web.sortOrder", 1)); wConfig.setUpdatedBy(username); wConfig.setUpdatedTime(now); wConfig.setUrls(configPath); - wConfig.setUserAgent(getDefaultString( - "default.config.web.userAgent", - ComponentUtil.getUserAgentName())); + wConfig.setUserAgent(getDefaultString("default.config.web.userAgent", ComponentUtil.getUserAgentName())); webCrawlingConfigService.store(wConfig); @@ -195,29 +175,17 @@ public class WizardAction implements Serializable { if (StringUtil.isNotBlank(wizardForm.depth)) { fConfig.setDepth(Integer.parseInt(wizardForm.depth)); } - fConfig.setExcludedDocPaths(getDefaultString( - "default.config.file.excludedDocPaths", - StringUtil.EMPTY)); - fConfig.setExcludedPaths(getDefaultString( - "default.config.file.excludedPaths", StringUtil.EMPTY)); - fConfig.setIncludedDocPaths(getDefaultString( - "default.config.file.includedDocPaths", - StringUtil.EMPTY)); - fConfig.setIncludedPaths(getDefaultString( - "default.config.file.includedPaths", StringUtil.EMPTY)); - fConfig.setIntervalTime(getDefaultInteger( - "default.config.file.intervalTime", - Constants.DEFAULT_INTERVAL_TIME_FOR_FS)); + fConfig.setExcludedDocPaths(getDefaultString("default.config.file.excludedDocPaths", StringUtil.EMPTY)); + fConfig.setExcludedPaths(getDefaultString("default.config.file.excludedPaths", StringUtil.EMPTY)); + fConfig.setIncludedDocPaths(getDefaultString("default.config.file.includedDocPaths", StringUtil.EMPTY)); + fConfig.setIncludedPaths(getDefaultString("default.config.file.includedPaths", StringUtil.EMPTY)); + fConfig.setIntervalTime(getDefaultInteger("default.config.file.intervalTime", Constants.DEFAULT_INTERVAL_TIME_FOR_FS)); if (StringUtil.isNotBlank(wizardForm.maxAccessCount)) { - fConfig.setMaxAccessCount(Long - .parseLong(wizardForm.maxAccessCount)); + fConfig.setMaxAccessCount(Long.parseLong(wizardForm.maxAccessCount)); } fConfig.setName(configName); - fConfig.setNumOfThread(getDefaultInteger( - "default.config.file.numOfThread", - Constants.DEFAULT_NUM_OF_THREAD_FOR_FS)); - fConfig.setSortOrder(getDefaultInteger( - "default.config.file.sortOrder", 1)); + fConfig.setNumOfThread(getDefaultInteger("default.config.file.numOfThread", Constants.DEFAULT_NUM_OF_THREAD_FOR_FS)); + fConfig.setSortOrder(getDefaultInteger("default.config.file.sortOrder", 1)); fConfig.setUpdatedBy(username); fConfig.setUpdatedTime(now); fConfig.setPaths(configPath); @@ -226,22 +194,17 @@ public class WizardAction implements Serializable { } return configName; } catch (final Exception e) { - logger.error("Failed to create crawling config: " - + wizardForm.crawlingConfigPath, e); - throw new SSCActionMessagesException(e, - "errors.failed_to_create_crawling_config_at_wizard", - wizardForm.crawlingConfigPath); + logger.error("Failed to create crawling config: " + wizardForm.crawlingConfigPath, e); + throw new SSCActionMessagesException(e, "errors.failed_to_create_crawling_config_at_wizard", wizardForm.crawlingConfigPath); } } - protected Integer getDefaultInteger(final String key, - final Integer defaultValue) { + protected Integer getDefaultInteger(final String key, final Integer defaultValue) { final String value = crawlerProperties.getProperty(key); if (value != null) { try { return Integer.parseInt(value); - } catch (final NumberFormatException e) { - } + } catch (final NumberFormatException e) {} } return defaultValue; } @@ -251,14 +214,12 @@ public class WizardAction implements Serializable { if (value != null) { try { return Long.parseLong(value); - } catch (final NumberFormatException e) { - } + } catch (final NumberFormatException e) {} } return defaultValue; } - protected String getDefaultString(final String key, - final String defaultValue) { + protected String getDefaultString(final String key, final String defaultValue) { final String value = crawlerProperties.getProperty(key); if (value != null) { return value; @@ -275,8 +236,7 @@ public class WizardAction implements Serializable { } protected String convertCrawlingPath(final String path) { - if (path.startsWith("http:") || path.startsWith("https:") - || path.startsWith("smb:")) { + if (path.startsWith("http:") || path.startsWith("https:") || path.startsWith("smb:")) { return path; } @@ -304,8 +264,7 @@ public class WizardAction implements Serializable { @Execute(validator = false) public String startCrawling() { if (!jobHelper.isCrawlProcessRunning()) { - final List scheduledJobList = scheduledJobService - .getCrawloerJobList(); + final List scheduledJobList = scheduledJobService.getCrawloerJobList(); for (final ScheduledJob scheduledJob : scheduledJobList) { new Thread(new Runnable() { @Override @@ -316,8 +275,7 @@ public class WizardAction implements Serializable { } SAStrutsUtil.addSessionMessage("success.start_crawl_process"); } else { - SAStrutsUtil - .addSessionMessage("success.failed_to_start_crawl_process"); + SAStrutsUtil.addSessionMessage("success.failed_to_start_crawl_process"); } return "../system/index?redirect=true"; } diff --git a/src/main/java/org/codelibs/fess/action/admin/dict/SynonymAction.java b/src/main/java/org/codelibs/fess/action/admin/dict/SynonymAction.java index 59b4f3660..562f79816 100644 --- a/src/main/java/org/codelibs/fess/action/admin/dict/SynonymAction.java +++ b/src/main/java/org/codelibs/fess/action/admin/dict/SynonymAction.java @@ -74,12 +74,10 @@ public class SynonymAction { protected String displayList(final boolean redirect) { // page navi - synonymItemItems = synonymService.getSynonymList(synonymForm.dictId, - synonymPager); + synonymItemItems = synonymService.getSynonymList(synonymForm.dictId, synonymPager); // restore from pager - Beans.copy(synonymPager, synonymForm.searchParams) - .excludes(CommonConstants.PAGER_CONVERSION_RULE).execute(); + Beans.copy(synonymPager, synonymForm.searchParams).excludes(CommonConstants.PAGER_CONVERSION_RULE).execute(); if (redirect) { return "index?dictId=" + synonymForm.dictId + "&redirect=true"; @@ -98,8 +96,7 @@ public class SynonymAction { // page navi if (StringUtil.isNotBlank(synonymForm.pageNumber)) { try { - synonymPager.setCurrentPageNumber(Integer - .parseInt(synonymForm.pageNumber)); + synonymPager.setCurrentPageNumber(Integer.parseInt(synonymForm.pageNumber)); } catch (final NumberFormatException e) { if (log.isDebugEnabled()) { log.debug("Invalid value: " + synonymForm.pageNumber, e); @@ -112,8 +109,7 @@ public class SynonymAction { @Execute(validator = false, input = "error.jsp") public String search() { - Beans.copy(synonymForm.searchParams, synonymPager) - .excludes(CommonConstants.PAGER_CONVERSION_RULE).execute(); + Beans.copy(synonymForm.searchParams, synonymPager).excludes(CommonConstants.PAGER_CONVERSION_RULE).execute(); return displayList(false); } @@ -140,8 +136,7 @@ public class SynonymAction { public String confirmpage() { if (synonymForm.crudMode != CommonConstants.CONFIRM_MODE) { throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.CONFIRM_MODE, - synonymForm.crudMode }); + new Object[] { CommonConstants.CONFIRM_MODE, synonymForm.crudMode }); } loadSynonym(); @@ -163,9 +158,7 @@ public class SynonymAction { @Execute(validator = false, input = "error.jsp", urlPattern = "editpage/{dictId}/{crudMode}/{id}") public String editpage() { if (synonymForm.crudMode != CommonConstants.EDIT_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.EDIT_MODE, - synonymForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE, synonymForm.crudMode }); } loadSynonym(); @@ -200,8 +193,7 @@ public class SynonymAction { public String deletepage() { if (synonymForm.crudMode != CommonConstants.DELETE_MODE) { throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - synonymForm.crudMode }); + new Object[] { CommonConstants.DELETE_MODE, synonymForm.crudMode }); } loadSynonym(); @@ -235,12 +227,10 @@ public class SynonymAction { throw e; } catch (final CrudMessageException e) { log.error(e.getMessage(), e); - throw new SSCActionMessagesException(e, e.getMessageId(), - e.getArgs()); + throw new SSCActionMessagesException(e, e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new SSCActionMessagesException(e, - "errors.crud_failed_to_create_crud_table"); + throw new SSCActionMessagesException(e, "errors.crud_failed_to_create_crud_table"); } } @@ -260,12 +250,10 @@ public class SynonymAction { throw e; } catch (final CrudMessageException e) { log.error(e.getMessage(), e); - throw new SSCActionMessagesException(e, e.getMessageId(), - e.getArgs()); + throw new SSCActionMessagesException(e, e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new SSCActionMessagesException(e, - "errors.crud_failed_to_update_crud_table"); + throw new SSCActionMessagesException(e, "errors.crud_failed_to_update_crud_table"); } } @@ -274,19 +262,16 @@ public class SynonymAction { public String delete() { if (synonymForm.crudMode != CommonConstants.DELETE_MODE) { throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - synonymForm.crudMode }); + new Object[] { CommonConstants.DELETE_MODE, synonymForm.crudMode }); } try { - final SynonymItem synonymItem = synonymService.getSynonym( - synonymForm.dictId, createKeyMap()); + final SynonymItem synonymItem = synonymService.getSynonym(synonymForm.dictId, createKeyMap()); if (synonymItem == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { synonymForm.id }); + new Object[] { synonymForm.id }); } @@ -301,23 +286,19 @@ public class SynonymAction { throw e; } catch (final CrudMessageException e) { log.error(e.getMessage(), e); - throw new SSCActionMessagesException(e, e.getMessageId(), - e.getArgs()); + throw new SSCActionMessagesException(e, e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new SSCActionMessagesException(e, - "errors.crud_failed_to_delete_crud_table"); + throw new SSCActionMessagesException(e, "errors.crud_failed_to_delete_crud_table"); } } @Token(save = true, validate = false) @Execute(validator = false, input = "downloadpage") public String downloadpage() { - final SynonymFile synonymFile = synonymService - .getSynonymFile(synonymForm.dictId); + final SynonymFile synonymFile = synonymService.getSynonymFile(synonymForm.dictId); if (synonymFile == null) { - throw new SSCActionMessagesException( - "errors.synonym_file_is_not_found"); + throw new SSCActionMessagesException("errors.synonym_file_is_not_found"); } filename = synonymFile.getSimpleName(); return "download.jsp"; @@ -326,17 +307,14 @@ public class SynonymAction { @Token(save = true, validate = true) @Execute(validator = false, input = "downloadpage") public String download() { - final SynonymFile synonymFile = synonymService - .getSynonymFile(synonymForm.dictId); + final SynonymFile synonymFile = synonymService.getSynonymFile(synonymForm.dictId); if (synonymFile == null) { - throw new SSCActionMessagesException( - "errors.synonym_file_is_not_found"); + throw new SSCActionMessagesException("errors.synonym_file_is_not_found"); } try (InputStream in = synonymFile.getInputStream()) { ResponseUtil.download(synonymFile.getSimpleName(), in); } catch (final IOException e) { - throw new SSCActionMessagesException( - "errors.failed_to_download_synonym_file"); + throw new SSCActionMessagesException("errors.failed_to_download_synonym_file"); } return null; @@ -345,11 +323,9 @@ public class SynonymAction { @Token(save = true, validate = false) @Execute(validator = false, input = "uploadpage") public String uploadpage() { - final SynonymFile synonymFile = synonymService - .getSynonymFile(synonymForm.dictId); + final SynonymFile synonymFile = synonymService.getSynonymFile(synonymForm.dictId); if (synonymFile == null) { - throw new SSCActionMessagesException( - "errors.synonym_file_is_not_found"); + throw new SSCActionMessagesException("errors.synonym_file_is_not_found"); } filename = synonymFile.getName(); return "upload.jsp"; @@ -358,17 +334,14 @@ public class SynonymAction { @Token(save = false, validate = true) @Execute(validator = true, input = "uploadpage") public String upload() { - final SynonymFile synonymFile = synonymService - .getSynonymFile(synonymForm.dictId); + final SynonymFile synonymFile = synonymService.getSynonymFile(synonymForm.dictId); if (synonymFile == null) { - throw new SSCActionMessagesException( - "errors.synonym_file_is_not_found"); + throw new SSCActionMessagesException("errors.synonym_file_is_not_found"); } try (InputStream in = synonymForm.synonymFile.getInputStream()) { synonymFile.update(in); } catch (final IOException e) { - throw new SSCActionMessagesException( - "errors.failed_to_upload_synonym_file"); + throw new SSCActionMessagesException("errors.failed_to_upload_synonym_file"); } SAStrutsUtil.addSessionMessage("success.upload_synonym_file"); @@ -378,13 +351,10 @@ public class SynonymAction { protected void loadSynonym() { - final SynonymItem synonymItem = synonymService.getSynonym( - synonymForm.dictId, createKeyMap()); + final SynonymItem synonymItem = synonymService.getSynonym(synonymForm.dictId, createKeyMap()); if (synonymItem == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", - new Object[] { synonymForm.id }); + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { synonymForm.id }); } @@ -396,19 +366,16 @@ public class SynonymAction { protected SynonymItem createSynonym() { SynonymItem synonymItem; if (synonymForm.crudMode == CommonConstants.EDIT_MODE) { - synonymItem = synonymService.getSynonym(synonymForm.dictId, - createKeyMap()); + synonymItem = synonymService.getSynonym(synonymForm.dictId, createKeyMap()); if (synonymItem == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { synonymForm.id }); + new Object[] { synonymForm.id }); } } else { - synonymItem = new SynonymItem(0, StringUtil.EMPTY_STRINGS, - StringUtil.EMPTY_STRINGS); + synonymItem = new SynonymItem(0, StringUtil.EMPTY_STRINGS, StringUtil.EMPTY_STRINGS); } final String[] newInputs = splitLine(synonymForm.inputs); diff --git a/src/main/java/org/codelibs/fess/action/admin/dict/UserDictAction.java b/src/main/java/org/codelibs/fess/action/admin/dict/UserDictAction.java index defb056f3..a1da4cc54 100644 --- a/src/main/java/org/codelibs/fess/action/admin/dict/UserDictAction.java +++ b/src/main/java/org/codelibs/fess/action/admin/dict/UserDictAction.java @@ -72,12 +72,10 @@ public class UserDictAction { protected String displayList(final boolean redirect) { // page navi - userDictItemItems = userDictService.getUserDictList( - userDictForm.dictId, userDictPager); + userDictItemItems = userDictService.getUserDictList(userDictForm.dictId, userDictPager); // restore from pager - Beans.copy(userDictPager, userDictForm.searchParams) - .excludes(CommonConstants.PAGER_CONVERSION_RULE).execute(); + Beans.copy(userDictPager, userDictForm.searchParams).excludes(CommonConstants.PAGER_CONVERSION_RULE).execute(); if (redirect) { return "index?dictId=" + userDictForm.dictId + "&redirect=true"; @@ -96,8 +94,7 @@ public class UserDictAction { // page navi if (StringUtil.isNotBlank(userDictForm.pageNumber)) { try { - userDictPager.setCurrentPageNumber(Integer - .parseInt(userDictForm.pageNumber)); + userDictPager.setCurrentPageNumber(Integer.parseInt(userDictForm.pageNumber)); } catch (final NumberFormatException e) { if (log.isDebugEnabled()) { log.debug("Invalid value: " + userDictForm.pageNumber, e); @@ -110,8 +107,7 @@ public class UserDictAction { @Execute(validator = false, input = "error.jsp") public String search() { - Beans.copy(userDictForm.searchParams, userDictPager) - .excludes(CommonConstants.PAGER_CONVERSION_RULE).execute(); + Beans.copy(userDictForm.searchParams, userDictPager).excludes(CommonConstants.PAGER_CONVERSION_RULE).execute(); return displayList(false); } @@ -137,9 +133,8 @@ public class UserDictAction { @Execute(validator = false, input = "error.jsp", urlPattern = "confirmpage/{dictId}/{crudMode}/{id}") public String confirmpage() { if (userDictForm.crudMode != CommonConstants.CONFIRM_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.CONFIRM_MODE, - userDictForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE, + userDictForm.crudMode }); } loadUserDict(); @@ -161,9 +156,7 @@ public class UserDictAction { @Execute(validator = false, input = "error.jsp", urlPattern = "editpage/{dictId}/{crudMode}/{id}") public String editpage() { if (userDictForm.crudMode != CommonConstants.EDIT_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.EDIT_MODE, - userDictForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE, userDictForm.crudMode }); } loadUserDict(); @@ -198,8 +191,7 @@ public class UserDictAction { public String deletepage() { if (userDictForm.crudMode != CommonConstants.DELETE_MODE) { throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - userDictForm.crudMode }); + new Object[] { CommonConstants.DELETE_MODE, userDictForm.crudMode }); } loadUserDict(); @@ -233,12 +225,10 @@ public class UserDictAction { throw e; } catch (final CrudMessageException e) { log.error(e.getMessage(), e); - throw new SSCActionMessagesException(e, e.getMessageId(), - e.getArgs()); + throw new SSCActionMessagesException(e, e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new SSCActionMessagesException(e, - "errors.crud_failed_to_create_crud_table"); + throw new SSCActionMessagesException(e, "errors.crud_failed_to_create_crud_table"); } } @@ -258,12 +248,10 @@ public class UserDictAction { throw e; } catch (final CrudMessageException e) { log.error(e.getMessage(), e); - throw new SSCActionMessagesException(e, e.getMessageId(), - e.getArgs()); + throw new SSCActionMessagesException(e, e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new SSCActionMessagesException(e, - "errors.crud_failed_to_update_crud_table"); + throw new SSCActionMessagesException(e, "errors.crud_failed_to_update_crud_table"); } } @@ -272,19 +260,16 @@ public class UserDictAction { public String delete() { if (userDictForm.crudMode != CommonConstants.DELETE_MODE) { throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - userDictForm.crudMode }); + new Object[] { CommonConstants.DELETE_MODE, userDictForm.crudMode }); } try { - final UserDictItem userDictItem = userDictService.getUserDict( - userDictForm.dictId, createKeyMap()); + final UserDictItem userDictItem = userDictService.getUserDict(userDictForm.dictId, createKeyMap()); if (userDictItem == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { userDictForm.id }); + new Object[] { userDictForm.id }); } @@ -299,23 +284,19 @@ public class UserDictAction { throw e; } catch (final CrudMessageException e) { log.error(e.getMessage(), e); - throw new SSCActionMessagesException(e, e.getMessageId(), - e.getArgs()); + throw new SSCActionMessagesException(e, e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new SSCActionMessagesException(e, - "errors.crud_failed_to_delete_crud_table"); + throw new SSCActionMessagesException(e, "errors.crud_failed_to_delete_crud_table"); } } @Token(save = true, validate = false) @Execute(validator = false, input = "downloadpage") public String downloadpage() { - final UserDictFile userdictFile = userDictService - .getUserDictFile(userDictForm.dictId); + final UserDictFile userdictFile = userDictService.getUserDictFile(userDictForm.dictId); if (userdictFile == null) { - throw new SSCActionMessagesException( - "errors.userdict_file_is_not_found"); + throw new SSCActionMessagesException("errors.userdict_file_is_not_found"); } filename = userdictFile.getSimpleName(); return "download.jsp"; @@ -324,17 +305,14 @@ public class UserDictAction { @Token(save = true, validate = true) @Execute(validator = false, input = "downloadpage") public String download() { - final UserDictFile userdictFile = userDictService - .getUserDictFile(userDictForm.dictId); + final UserDictFile userdictFile = userDictService.getUserDictFile(userDictForm.dictId); if (userdictFile == null) { - throw new SSCActionMessagesException( - "errors.userdict_file_is_not_found"); + throw new SSCActionMessagesException("errors.userdict_file_is_not_found"); } try (InputStream in = userdictFile.getInputStream()) { ResponseUtil.download(userdictFile.getSimpleName(), in); } catch (final IOException e) { - throw new SSCActionMessagesException( - "errors.failed_to_download_userdict_file"); + throw new SSCActionMessagesException("errors.failed_to_download_userdict_file"); } return null; @@ -343,11 +321,9 @@ public class UserDictAction { @Token(save = true, validate = false) @Execute(validator = false, input = "uploadpage") public String uploadpage() { - final UserDictFile userdictFile = userDictService - .getUserDictFile(userDictForm.dictId); + final UserDictFile userdictFile = userDictService.getUserDictFile(userDictForm.dictId); if (userdictFile == null) { - throw new SSCActionMessagesException( - "errors.userdict_file_is_not_found"); + throw new SSCActionMessagesException("errors.userdict_file_is_not_found"); } filename = userdictFile.getName(); return "upload.jsp"; @@ -356,17 +332,14 @@ public class UserDictAction { @Token(save = false, validate = true) @Execute(validator = true, input = "uploadpage") public String upload() { - final UserDictFile userdictFile = userDictService - .getUserDictFile(userDictForm.dictId); + final UserDictFile userdictFile = userDictService.getUserDictFile(userDictForm.dictId); if (userdictFile == null) { - throw new SSCActionMessagesException( - "errors.userdict_file_is_not_found"); + throw new SSCActionMessagesException("errors.userdict_file_is_not_found"); } try (InputStream in = userDictForm.userDictFile.getInputStream()) { userdictFile.update(in); } catch (final IOException e) { - throw new SSCActionMessagesException( - "errors.failed_to_upload_userdict_file"); + throw new SSCActionMessagesException("errors.failed_to_upload_userdict_file"); } SAStrutsUtil.addSessionMessage("success.upload_userdict_file"); @@ -376,13 +349,10 @@ public class UserDictAction { protected void loadUserDict() { - final UserDictItem userDictItem = userDictService.getUserDict( - userDictForm.dictId, createKeyMap()); + final UserDictItem userDictItem = userDictService.getUserDict(userDictForm.dictId, createKeyMap()); if (userDictItem == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", - new Object[] { userDictForm.id }); + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { userDictForm.id }); } @@ -396,19 +366,16 @@ public class UserDictAction { protected UserDictItem createUserDict() { UserDictItem userDictItem; if (userDictForm.crudMode == CommonConstants.EDIT_MODE) { - userDictItem = userDictService.getUserDict(userDictForm.dictId, - createKeyMap()); + userDictItem = userDictService.getUserDict(userDictForm.dictId, createKeyMap()); if (userDictItem == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { userDictForm.id }); + new Object[] { userDictForm.id }); } } else { - userDictItem = new UserDictItem(0, StringUtil.EMPTY, - StringUtil.EMPTY, StringUtil.EMPTY, StringUtil.EMPTY); + userDictItem = new UserDictItem(0, StringUtil.EMPTY, StringUtil.EMPTY, StringUtil.EMPTY, StringUtil.EMPTY); } userDictItem.setNewToken(userDictForm.token); diff --git a/src/main/java/org/codelibs/fess/api/WebApiManager.java b/src/main/java/org/codelibs/fess/api/WebApiManager.java index fdc4f10af..ccf7c2f99 100644 --- a/src/main/java/org/codelibs/fess/api/WebApiManager.java +++ b/src/main/java/org/codelibs/fess/api/WebApiManager.java @@ -27,7 +27,6 @@ public interface WebApiManager { boolean matches(HttpServletRequest request); - void process(HttpServletRequest request, HttpServletResponse response, - FilterChain chain) throws IOException, ServletException; + void process(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException; } diff --git a/src/main/java/org/codelibs/fess/api/WebApiRequest.java b/src/main/java/org/codelibs/fess/api/WebApiRequest.java index f3a69b919..843799522 100644 --- a/src/main/java/org/codelibs/fess/api/WebApiRequest.java +++ b/src/main/java/org/codelibs/fess/api/WebApiRequest.java @@ -22,16 +22,14 @@ import javax.servlet.http.HttpServletRequestWrapper; public class WebApiRequest extends HttpServletRequestWrapper { protected String servletPath; - public WebApiRequest(final HttpServletRequest request, - final String servletPath) { + public WebApiRequest(final HttpServletRequest request, final String servletPath) { super(request); this.servletPath = servletPath; } @Override public String getServletPath() { - if (getQueryString() != null - && getQueryString().indexOf("SAStruts.method") != -1) { + if (getQueryString() != null && getQueryString().indexOf("SAStruts.method") != -1) { return super.getServletPath(); } else { return servletPath; diff --git a/src/main/java/org/codelibs/fess/api/json/JsonApiManager.java b/src/main/java/org/codelibs/fess/api/json/JsonApiManager.java index 381355615..580fd224c 100644 --- a/src/main/java/org/codelibs/fess/api/json/JsonApiManager.java +++ b/src/main/java/org/codelibs/fess/api/json/JsonApiManager.java @@ -58,15 +58,13 @@ import org.slf4j.LoggerFactory; public class JsonApiManager extends BaseApiManager implements WebApiManager { - private static final Logger logger = LoggerFactory - .getLogger(JsonApiManager.class); + private static final Logger logger = LoggerFactory.getLogger(JsonApiManager.class); protected String jsonPathPrefix = "/json"; @Override public boolean matches(final HttpServletRequest request) { - if (Constants.FALSE.equals(ComponentUtil.getCrawlerProperties() - .getProperty(Constants.WEB_API_JSON_PROPERTY, Constants.TRUE))) { + if (Constants.FALSE.equals(ComponentUtil.getCrawlerProperties().getProperty(Constants.WEB_API_JSON_PROPERTY, Constants.TRUE))) { return false; } @@ -75,46 +73,44 @@ public class JsonApiManager extends BaseApiManager implements WebApiManager { } @Override - public void process(final HttpServletRequest request, - final HttpServletResponse response, final FilterChain chain) - throws IOException, ServletException { + public void process(final HttpServletRequest request, final HttpServletResponse response, final FilterChain chain) throws IOException, + ServletException { final String formatType = request.getParameter("type"); switch (getFormatType(formatType)) { - case SEARCH: - processSearchRequest(request, response, chain); - break; - case LABEL: - processLabelRequest(request, response, chain); - break; - case SUGGEST: - processSuggestRequest(request, response, chain); - break; - case SPELLCHECK: - processSpellCheckRequest(request, response, chain); - break; - case ANALYSIS: - processAnalysisRequest(request, response, chain); - break; - case HOTSEARCHWORD: - processHotSearchWordRequest(request, response, chain); - break; - case FAVORITE: - processFavoriteRequest(request, response, chain); - break; - case FAVORITES: - processFavoritesRequest(request, response, chain); - break; - case PING: - processPingRequest(request, response, chain); - break; - default: - writeJsonResponse(99, StringUtil.EMPTY, "Not found."); - break; + case SEARCH: + processSearchRequest(request, response, chain); + break; + case LABEL: + processLabelRequest(request, response, chain); + break; + case SUGGEST: + processSuggestRequest(request, response, chain); + break; + case SPELLCHECK: + processSpellCheckRequest(request, response, chain); + break; + case ANALYSIS: + processAnalysisRequest(request, response, chain); + break; + case HOTSEARCHWORD: + processHotSearchWordRequest(request, response, chain); + break; + case FAVORITE: + processFavoriteRequest(request, response, chain); + break; + case FAVORITES: + processFavoritesRequest(request, response, chain); + break; + case PING: + processPingRequest(request, response, chain); + break; + default: + writeJsonResponse(99, StringUtil.EMPTY, "Not found."); + break; } } - protected void processPingRequest(final HttpServletRequest request, - final HttpServletResponse response, final FilterChain chain) { + protected void processPingRequest(final HttpServletRequest request, final HttpServletResponse response, final FilterChain chain) { final SearchService searchService = ComponentUtil.getSearchService(); int status; final StringBuilder buf = new StringBuilder(1000); @@ -155,35 +151,27 @@ public class JsonApiManager extends BaseApiManager implements WebApiManager { writeJsonResponse(status, buf.toString(), errMsg); } - protected void processSearchRequest(final HttpServletRequest request, - final HttpServletResponse response, final FilterChain chain) { + protected void processSearchRequest(final HttpServletRequest request, final HttpServletResponse response, final FilterChain chain) { int status = 0; String errMsg = StringUtil.EMPTY; String query = null; final StringBuilder buf = new StringBuilder(1000); - request.setAttribute(Constants.SEARCH_LOG_ACCESS_TYPE, - CDef.AccessType.Json); + request.setAttribute(Constants.SEARCH_LOG_ACCESS_TYPE, CDef.AccessType.Json); final String queryId = request.getParameter("queryId"); try { - chain.doFilter(new WebApiRequest(request, SEARCH_API), - new WebApiResponse(response)); + chain.doFilter(new WebApiRequest(request, SEARCH_API), new WebApiResponse(response)); WebApiUtil.validate(); query = WebApiUtil.getObject("searchQuery"); final String execTime = WebApiUtil.getObject("execTime"); final String queryTime = WebApiUtil.getObject("queryTime"); final String searchTime = WebApiUtil.getObject("searchTime"); final String pageSize = WebApiUtil.getObject("pageSize"); - final String currentPageNumber = WebApiUtil - .getObject("currentPageNumber"); - final String allRecordCount = WebApiUtil - .getObject("allRecordCount"); + final String currentPageNumber = WebApiUtil.getObject("currentPageNumber"); + final String allRecordCount = WebApiUtil.getObject("allRecordCount"); final String allPageCount = WebApiUtil.getObject("allPageCount"); - final List> documentItems = WebApiUtil - .getObject("documentItems"); - final FacetResponse facetResponse = WebApiUtil - .getObject("facetResponse"); - final MoreLikeThisResponse moreLikeThisResponse = WebApiUtil - .getObject("moreLikeThisResponse"); + final List> documentItems = WebApiUtil.getObject("documentItems"); + final FacetResponse facetResponse = WebApiUtil.getObject("facetResponse"); + final MoreLikeThisResponse moreLikeThisResponse = WebApiUtil.getObject("moreLikeThisResponse"); buf.append("\"query\":"); buf.append(escapeJson(query)); @@ -222,13 +210,10 @@ public class JsonApiManager extends BaseApiManager implements WebApiManager { } buf.append('{'); boolean first2 = true; - for (final Map.Entry entry : document - .entrySet()) { + for (final Map.Entry entry : document.entrySet()) { final String name = entry.getKey(); - if (StringUtil.isNotBlank(name) - && entry.getValue() != null - && ComponentUtil.getQueryHelper() - .isApiResponseField(name)) { + if (StringUtil.isNotBlank(name) && entry.getValue() != null + && ComponentUtil.getQueryHelper().isApiResponseField(name)) { if (!first2) { buf.append(','); } else { @@ -259,8 +244,7 @@ public class JsonApiManager extends BaseApiManager implements WebApiManager { buf.append(escapeJson(field.getName())); buf.append(",\"result\":["); boolean first2 = true; - for (final Map.Entry entry : field - .getValueCountMap().entrySet()) { + for (final Map.Entry entry : field.getValueCountMap().entrySet()) { if (!first2) { buf.append(','); } else { @@ -282,8 +266,7 @@ public class JsonApiManager extends BaseApiManager implements WebApiManager { buf.append(','); buf.append("\"facetQuery\":["); boolean first1 = true; - for (final Map.Entry entry : facetResponse - .getQueryCountMap().entrySet()) { + for (final Map.Entry entry : facetResponse.getQueryCountMap().entrySet()) { if (!first1) { buf.append(','); } else { @@ -302,8 +285,7 @@ public class JsonApiManager extends BaseApiManager implements WebApiManager { buf.append(','); buf.append("\"moreLikeThis\":["); boolean first = true; - for (final Map.Entry>> mltEntry : moreLikeThisResponse - .entrySet()) { + for (final Map.Entry>> mltEntry : moreLikeThisResponse.entrySet()) { if (!first) { buf.append(','); } else { @@ -313,8 +295,7 @@ public class JsonApiManager extends BaseApiManager implements WebApiManager { buf.append(escapeJson(mltEntry.getKey())); buf.append(",\"result\":["); boolean first1 = true; - for (final Map document : mltEntry - .getValue()) { + for (final Map document : mltEntry.getValue()) { if (!first1) { buf.append(','); } else { @@ -322,10 +303,8 @@ public class JsonApiManager extends BaseApiManager implements WebApiManager { } buf.append('{'); boolean first2 = true; - for (final Map.Entry entry : document - .entrySet()) { - if (StringUtil.isNotBlank(entry.getKey()) - && entry.getValue() != null) { + for (final Map.Entry entry : document.entrySet()) { + if (StringUtil.isNotBlank(entry.getKey()) && entry.getValue() != null) { if (!first2) { buf.append(','); } else { @@ -357,14 +336,12 @@ public class JsonApiManager extends BaseApiManager implements WebApiManager { } - protected void processLabelRequest(final HttpServletRequest request, - final HttpServletResponse response, final FilterChain chain) { + protected void processLabelRequest(final HttpServletRequest request, final HttpServletResponse response, final FilterChain chain) { int status = 0; String errMsg = StringUtil.EMPTY; final StringBuilder buf = new StringBuilder(255); try { - final List> labelTypeItems = ComponentUtil - .getLabelTypeHelper().getLabelTypeItemList(); + final List> labelTypeItems = ComponentUtil.getLabelTypeHelper().getLabelTypeItemList(); buf.append("\"recordCount\":"); buf.append(labelTypeItems.size()); if (!labelTypeItems.isEmpty()) { @@ -397,22 +374,17 @@ public class JsonApiManager extends BaseApiManager implements WebApiManager { } - protected void processSuggestRequest(final HttpServletRequest request, - final HttpServletResponse response, final FilterChain chain) { + protected void processSuggestRequest(final HttpServletRequest request, final HttpServletResponse response, final FilterChain chain) { int status = 0; String errMsg = StringUtil.EMPTY; final StringBuilder buf = new StringBuilder(255); try { - chain.doFilter(new WebApiRequest(request, SUGGEST_API), - new WebApiResponse(response)); + chain.doFilter(new WebApiRequest(request, SUGGEST_API), new WebApiResponse(response)); WebApiUtil.validate(); - final Integer suggestRecordCount = WebApiUtil - .getObject("suggestRecordCount"); - final List suggestResultList = WebApiUtil - .getObject("suggestResultList"); - final List suggestFieldName = WebApiUtil - .getObject("suggestFieldName"); + final Integer suggestRecordCount = WebApiUtil.getObject("suggestRecordCount"); + final List suggestResultList = WebApiUtil.getObject("suggestResultList"); + final List suggestFieldName = WebApiUtil.getObject("suggestFieldName"); buf.append("\"recordCount\":"); buf.append(suggestRecordCount); @@ -423,11 +395,9 @@ public class JsonApiManager extends BaseApiManager implements WebApiManager { boolean first1 = true; for (int i = 0; i < suggestResultList.size(); i++) { - final SuggestResponse suggestResponse = suggestResultList - .get(i); + final SuggestResponse suggestResponse = suggestResultList.get(i); - for (final Map.Entry> entry : suggestResponse - .entrySet()) { + for (final Map.Entry> entry : suggestResponse.entrySet()) { final String fn = suggestFieldName.get(i); if (!first1) { buf.append(','); @@ -435,8 +405,7 @@ public class JsonApiManager extends BaseApiManager implements WebApiManager { first1 = false; } - final SuggestResponseList srList = (SuggestResponseList) entry - .getValue(); + final SuggestResponseList srList = (SuggestResponseList) entry.getValue(); buf.append("{\"token\":"); buf.append(escapeJson(entry.getKey())); @@ -481,22 +450,17 @@ public class JsonApiManager extends BaseApiManager implements WebApiManager { } - protected void processSpellCheckRequest(final HttpServletRequest request, - final HttpServletResponse response, final FilterChain chain) { + protected void processSpellCheckRequest(final HttpServletRequest request, final HttpServletResponse response, final FilterChain chain) { int status = 0; String errMsg = StringUtil.EMPTY; final StringBuilder buf = new StringBuilder(255); try { - chain.doFilter(new WebApiRequest(request, SPELLCHECK_API), - new WebApiResponse(response)); + chain.doFilter(new WebApiRequest(request, SPELLCHECK_API), new WebApiResponse(response)); WebApiUtil.validate(); - final Integer spellCheckRecordCount = WebApiUtil - .getObject("spellCheckRecordCount"); - final List spellCheckResultList = WebApiUtil - .getObject("spellCheckResultList"); - final List spellCheckFieldName = WebApiUtil - .getObject("spellCheckFieldName"); + final Integer spellCheckRecordCount = WebApiUtil.getObject("spellCheckRecordCount"); + final List spellCheckResultList = WebApiUtil.getObject("spellCheckResultList"); + final List spellCheckFieldName = WebApiUtil.getObject("spellCheckFieldName"); buf.append("\"recordCount\":"); buf.append(spellCheckRecordCount); @@ -507,11 +471,9 @@ public class JsonApiManager extends BaseApiManager implements WebApiManager { boolean first1 = true; for (int i = 0; i < spellCheckResultList.size(); i++) { - final SuggestResponse suggestResponse = spellCheckResultList - .get(i); + final SuggestResponse suggestResponse = spellCheckResultList.get(i); - for (final Map.Entry> entry : suggestResponse - .entrySet()) { + for (final Map.Entry> entry : suggestResponse.entrySet()) { final String fn = spellCheckFieldName.get(i); if (!first1) { buf.append(','); @@ -519,8 +481,7 @@ public class JsonApiManager extends BaseApiManager implements WebApiManager { first1 = false; } - final SuggestResponseList srList = (SuggestResponseList) entry - .getValue(); + final SuggestResponseList srList = (SuggestResponseList) entry.getValue(); buf.append("{\"token\":"); buf.append(escapeJson(entry.getKey())); @@ -565,18 +526,15 @@ public class JsonApiManager extends BaseApiManager implements WebApiManager { } - protected void processAnalysisRequest(final HttpServletRequest request, - final HttpServletResponse response, final FilterChain chain) { + protected void processAnalysisRequest(final HttpServletRequest request, final HttpServletResponse response, final FilterChain chain) { int status = 0; String errMsg = StringUtil.EMPTY; final StringBuilder buf = new StringBuilder(255); try { - chain.doFilter(new WebApiRequest(request, ANALYSIS_API), - new WebApiResponse(response)); + chain.doFilter(new WebApiRequest(request, ANALYSIS_API), new WebApiResponse(response)); WebApiUtil.validate(); - final FieldAnalysisResponse fieldAnalysis = WebApiUtil - .getObject("fieldAnalysis"); + final FieldAnalysisResponse fieldAnalysis = WebApiUtil.getObject("fieldAnalysis"); buf.append("\"recordCount\":"); buf.append(fieldAnalysis.size()); @@ -585,30 +543,23 @@ public class JsonApiManager extends BaseApiManager implements WebApiManager { buf.append(','); buf.append("\"result\":["); boolean first1 = true; - for (final Map.Entry>>> fEntry : fieldAnalysis - .entrySet()) { + for (final Map.Entry>>> fEntry : fieldAnalysis.entrySet()) { if (first1) { first1 = false; } else { buf.append(','); } - buf.append("{\"field\":") - .append(escapeJson(fEntry.getKey())) - .append(",\"analysis\":["); + buf.append("{\"field\":").append(escapeJson(fEntry.getKey())).append(",\"analysis\":["); boolean first2 = true; - for (final Map.Entry>> aEntry : fEntry - .getValue().entrySet()) { + for (final Map.Entry>> aEntry : fEntry.getValue().entrySet()) { if (first2) { first2 = false; } else { buf.append(','); } - buf.append("{\"name\":") - .append(escapeJson(aEntry.getKey())) - .append(",\"data\":["); + buf.append("{\"name\":").append(escapeJson(aEntry.getKey())).append(",\"data\":["); boolean first3 = true; - for (final Map dataMap : aEntry - .getValue()) { + for (final Map dataMap : aEntry.getValue()) { if (first3) { first3 = false; } else { @@ -616,8 +567,7 @@ public class JsonApiManager extends BaseApiManager implements WebApiManager { } buf.append('{'); boolean first4 = true; - for (final Map.Entry dEntry : dataMap - .entrySet()) { + for (final Map.Entry dEntry : dataMap.entrySet()) { final String key = dEntry.getKey(); final Object value = dEntry.getValue(); if (StringUtil.isNotBlank(key) && value != null) { @@ -626,8 +576,7 @@ public class JsonApiManager extends BaseApiManager implements WebApiManager { } else { buf.append(','); } - buf.append(escapeJson(key)).append(':') - .append(escapeJson(value)); + buf.append(escapeJson(key)).append(':').append(escapeJson(value)); } } buf.append('}'); @@ -654,19 +603,15 @@ public class JsonApiManager extends BaseApiManager implements WebApiManager { } - protected void processHotSearchWordRequest( - final HttpServletRequest request, - final HttpServletResponse response, final FilterChain chain) { + protected void processHotSearchWordRequest(final HttpServletRequest request, final HttpServletResponse response, final FilterChain chain) { int status = 0; String errMsg = StringUtil.EMPTY; final StringBuilder buf = new StringBuilder(255); try { - chain.doFilter(new WebApiRequest(request, HOT_SEARCH_WORD_API), - new WebApiResponse(response)); + chain.doFilter(new WebApiRequest(request, HOT_SEARCH_WORD_API), new WebApiResponse(response)); WebApiUtil.validate(); - final List hotSearchWordList = WebApiUtil - .getObject("hotSearchWordList"); + final List hotSearchWordList = WebApiUtil.getObject("hotSearchWordList"); buf.append("\"result\":["); boolean first1 = true; @@ -695,14 +640,12 @@ public class JsonApiManager extends BaseApiManager implements WebApiManager { } - protected void processFavoriteRequest(final HttpServletRequest request, - final HttpServletResponse response, final FilterChain chain) { + protected void processFavoriteRequest(final HttpServletRequest request, final HttpServletResponse response, final FilterChain chain) { int status = 0; String body = null; String errMsg = null; try { - chain.doFilter(new WebApiRequest(request, FAVORITE_API), - new WebApiResponse(response)); + chain.doFilter(new WebApiRequest(request, FAVORITE_API), new WebApiResponse(response)); WebApiUtil.validate(); body = "\"result\":\"ok\""; @@ -722,15 +665,13 @@ public class JsonApiManager extends BaseApiManager implements WebApiManager { writeJsonResponse(status, body, errMsg); } - protected void processFavoritesRequest(final HttpServletRequest request, - final HttpServletResponse response, final FilterChain chain) { + protected void processFavoritesRequest(final HttpServletRequest request, final HttpServletResponse response, final FilterChain chain) { int status = 0; String body = null; String errMsg = null; try { - chain.doFilter(new WebApiRequest(request, FAVORITES_API), - new WebApiResponse(response)); + chain.doFilter(new WebApiRequest(request, FAVORITES_API), new WebApiResponse(response)); WebApiUtil.validate(); final List docIdList = WebApiUtil.getObject("docIdList"); @@ -763,10 +704,8 @@ public class JsonApiManager extends BaseApiManager implements WebApiManager { } - protected void writeJsonResponse(final int status, final String body, - final String errMsg) { - final String callback = RequestUtil.getRequest().getParameter( - "callback"); + protected void writeJsonResponse(final int status, final String body, final String errMsg) { + final String callback = RequestUtil.getRequest().getParameter("callback"); final boolean isJsonp = StringUtil.isNotBlank(callback); final StringBuilder buf = new StringBuilder(1000); @@ -792,15 +731,12 @@ public class JsonApiManager extends BaseApiManager implements WebApiManager { if (isJsonp) { buf.append(')'); } - ResponseUtil.write(buf.toString(), "text/javascript+json", - Constants.UTF_8); + ResponseUtil.write(buf.toString(), "text/javascript+json", Constants.UTF_8); } protected String escapeCallbackName(final String callbackName) { - return "/**/" - + callbackName.replaceAll("[^0-9a-zA-Z_\\$\\.]", - StringUtil.EMPTY); + return "/**/" + callbackName.replaceAll("[^0-9a-zA-Z_\\$\\.]", StringUtil.EMPTY); } protected String escapeJson(final Object obj) { @@ -830,23 +766,16 @@ public class JsonApiManager extends BaseApiManager implements WebApiManager { } else { buf.append(','); } - buf.append(escapeJson(entry.getKey())).append(':') - .append(escapeJson(entry.getValue())); + buf.append(escapeJson(entry.getKey())).append(':').append(escapeJson(entry.getValue())); } buf.append('}'); - } else if (obj instanceof Integer || obj instanceof Long - || obj instanceof Float || obj instanceof Double - || obj instanceof Short) { + } else if (obj instanceof Integer || obj instanceof Long || obj instanceof Float || obj instanceof Double || obj instanceof Short) { buf.append(obj); } else if (obj instanceof Date) { - final SimpleDateFormat sdf = new SimpleDateFormat( - CoreLibConstants.DATE_FORMAT_ISO_8601_EXTEND); - buf.append('\"') - .append(StringEscapeUtils.escapeXml(sdf.format(obj))) - .append('\"'); + final SimpleDateFormat sdf = new SimpleDateFormat(CoreLibConstants.DATE_FORMAT_ISO_8601_EXTEND); + buf.append('\"').append(StringEscapeUtils.escapeXml(sdf.format(obj))).append('\"'); } else { - buf.append('\"').append(escapeJsonString(obj.toString())) - .append('\"'); + buf.append('\"').append(escapeJsonString(obj.toString())).append('\"'); } return buf.toString(); } @@ -871,50 +800,50 @@ public class JsonApiManager extends BaseApiManager implements WebApiManager { out.write(hex(ch)); } else if (ch < 32) { switch (ch) { - case '\b': - out.write('\\'); - out.write('b'); - break; - case '\n': - out.write('\\'); - out.write('n'); - break; - case '\t': - out.write('\\'); - out.write('t'); - break; - case '\f': - out.write('\\'); - out.write('f'); - break; - case '\r': - out.write('\\'); - out.write('r'); - break; - default: - if (ch > 0xf) { - out.write("\\u00"); - out.write(hex(ch)); - } else { - out.write("\\u000"); - out.write(hex(ch)); - } - break; + case '\b': + out.write('\\'); + out.write('b'); + break; + case '\n': + out.write('\\'); + out.write('n'); + break; + case '\t': + out.write('\\'); + out.write('t'); + break; + case '\f': + out.write('\\'); + out.write('f'); + break; + case '\r': + out.write('\\'); + out.write('r'); + break; + default: + if (ch > 0xf) { + out.write("\\u00"); + out.write(hex(ch)); + } else { + out.write("\\u000"); + out.write(hex(ch)); + } + break; } } else { switch (ch) { - case '"': - out.write("\\u0022"); - break; - case '\\': - out.write("\\u005C"); - break; - case '/': - out.write("\\u002F"); - break; - default: - out.write(ch); - break; + case '"': + out.write("\\u0022"); + break; + case '\\': + out.write("\\u005C"); + break; + case '/': + out.write("\\u002F"); + break; + default: + out.write(ch); + break; } } } diff --git a/src/main/java/org/codelibs/fess/api/xml/XmlApiManager.java b/src/main/java/org/codelibs/fess/api/xml/XmlApiManager.java index 4ebd48672..11dd85554 100644 --- a/src/main/java/org/codelibs/fess/api/xml/XmlApiManager.java +++ b/src/main/java/org/codelibs/fess/api/xml/XmlApiManager.java @@ -55,15 +55,13 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class XmlApiManager extends BaseApiManager implements WebApiManager { - private static final Logger logger = LoggerFactory - .getLogger(XmlApiManager.class); + private static final Logger logger = LoggerFactory.getLogger(XmlApiManager.class); protected String xmlPathPrefix = "/xml"; @Override public boolean matches(final HttpServletRequest request) { - if (Constants.FALSE.equals(ComponentUtil.getCrawlerProperties() - .getProperty(Constants.WEB_API_XML_PROPERTY, Constants.TRUE))) { + if (Constants.FALSE.equals(ComponentUtil.getCrawlerProperties().getProperty(Constants.WEB_API_XML_PROPERTY, Constants.TRUE))) { return false; } @@ -72,38 +70,36 @@ public class XmlApiManager extends BaseApiManager implements WebApiManager { } @Override - public void process(final HttpServletRequest request, - final HttpServletResponse response, final FilterChain chain) - throws IOException, ServletException { + public void process(final HttpServletRequest request, final HttpServletResponse response, final FilterChain chain) throws IOException, + ServletException { final String formatType = request.getParameter("type"); switch (getFormatType(formatType)) { - case SEARCH: - processSearchRequest(request, response, chain); - break; - case LABEL: - processLabelRequest(request, response, chain); - break; - case SUGGEST: - processSuggestRequest(request, response, chain); - break; - case SPELLCHECK: - processSpellCheckRequest(request, response, chain); - break; - case ANALYSIS: - processAnalysisRequest(request, response, chain); - break; - case PING: - processPingRequest(request, response, chain); - break; - default: - writeXmlResponse(-1, StringUtil.EMPTY, "Not found."); - break; + case SEARCH: + processSearchRequest(request, response, chain); + break; + case LABEL: + processLabelRequest(request, response, chain); + break; + case SUGGEST: + processSuggestRequest(request, response, chain); + break; + case SPELLCHECK: + processSpellCheckRequest(request, response, chain); + break; + case ANALYSIS: + processAnalysisRequest(request, response, chain); + break; + case PING: + processPingRequest(request, response, chain); + break; + default: + writeXmlResponse(-1, StringUtil.EMPTY, "Not found."); + break; } } - protected void processPingRequest(final HttpServletRequest request, - final HttpServletResponse response, final FilterChain chain) { + protected void processPingRequest(final HttpServletRequest request, final HttpServletResponse response, final FilterChain chain) { final SearchService searchService = ComponentUtil.getSearchService(); int status; final StringBuilder buf = new StringBuilder(1000); @@ -138,35 +134,27 @@ public class XmlApiManager extends BaseApiManager implements WebApiManager { writeXmlResponse(status, buf.toString(), errMsg); } - protected void processSearchRequest(final HttpServletRequest request, - final HttpServletResponse response, final FilterChain chain) { + protected void processSearchRequest(final HttpServletRequest request, final HttpServletResponse response, final FilterChain chain) { int status = 0; String errMsg = StringUtil.EMPTY; final StringBuilder buf = new StringBuilder(1000); String query = null; - request.setAttribute(Constants.SEARCH_LOG_ACCESS_TYPE, - CDef.AccessType.Xml); + request.setAttribute(Constants.SEARCH_LOG_ACCESS_TYPE, CDef.AccessType.Xml); final String queryId = request.getParameter("queryId"); try { - chain.doFilter(new WebApiRequest(request, SEARCH_API), - new WebApiResponse(response)); + chain.doFilter(new WebApiRequest(request, SEARCH_API), new WebApiResponse(response)); WebApiUtil.validate(); query = WebApiUtil.getObject("searchQuery"); final String execTime = WebApiUtil.getObject("execTime"); final String queryTime = WebApiUtil.getObject("queryTime"); final String searchTime = WebApiUtil.getObject("searchTime"); final String pageSize = WebApiUtil.getObject("pageSize"); - final String currentPageNumber = WebApiUtil - .getObject("currentPageNumber"); - final String allRecordCount = WebApiUtil - .getObject("allRecordCount"); + final String currentPageNumber = WebApiUtil.getObject("currentPageNumber"); + final String allRecordCount = WebApiUtil.getObject("allRecordCount"); final String allPageCount = WebApiUtil.getObject("allPageCount"); - final List> documentItems = WebApiUtil - .getObject("documentItems"); - final FacetResponse facetResponse = WebApiUtil - .getObject("facetResponse"); - final MoreLikeThisResponse moreLikeThisResponse = WebApiUtil - .getObject("moreLikeThisResponse"); + final List> documentItems = WebApiUtil.getObject("documentItems"); + final FacetResponse facetResponse = WebApiUtil.getObject("facetResponse"); + final MoreLikeThisResponse moreLikeThisResponse = WebApiUtil.getObject("moreLikeThisResponse"); buf.append(""); buf.append(escapeXml(query)); @@ -200,13 +188,9 @@ public class XmlApiManager extends BaseApiManager implements WebApiManager { buf.append(""); for (final Map document : documentItems) { buf.append(""); - for (final Map.Entry entry : document - .entrySet()) { + for (final Map.Entry entry : document.entrySet()) { final String name = entry.getKey(); - if (StringUtil.isNotBlank(name) - && entry.getValue() != null - && ComponentUtil.getQueryHelper() - .isApiResponseField(name)) { + if (StringUtil.isNotBlank(name) && entry.getValue() != null && ComponentUtil.getQueryHelper().isApiResponseField(name)) { final String tagName = convertTagName(name); buf.append('<'); buf.append(tagName); @@ -228,8 +212,7 @@ public class XmlApiManager extends BaseApiManager implements WebApiManager { buf.append(""); - for (final Map.Entry entry : field - .getValueCountMap().entrySet()) { + for (final Map.Entry entry : field.getValueCountMap().entrySet()) { buf.append(""); @@ -242,8 +225,7 @@ public class XmlApiManager extends BaseApiManager implements WebApiManager { // facet query if (facetResponse.getQueryCountMap() != null) { buf.append(""); - for (final Map.Entry entry : facetResponse - .getQueryCountMap().entrySet()) { + for (final Map.Entry entry : facetResponse.getQueryCountMap().entrySet()) { buf.append(""); @@ -256,25 +238,19 @@ public class XmlApiManager extends BaseApiManager implements WebApiManager { } if (moreLikeThisResponse != null && !moreLikeThisResponse.isEmpty()) { buf.append(""); - for (final Map.Entry>> mltEntry : moreLikeThisResponse - .entrySet()) { + for (final Map.Entry>> mltEntry : moreLikeThisResponse.entrySet()) { buf.append(""); - for (final Map document : mltEntry - .getValue()) { + for (final Map document : mltEntry.getValue()) { buf.append(""); - for (final Map.Entry entry : document - .entrySet()) { - if (StringUtil.isNotBlank(entry.getKey()) - && entry.getValue() != null) { - final String tagName = convertTagName(entry - .getKey()); + for (final Map.Entry entry : document.entrySet()) { + if (StringUtil.isNotBlank(entry.getKey()) && entry.getValue() != null) { + final String tagName = convertTagName(entry.getKey()); buf.append('<'); buf.append(tagName); buf.append('>'); - buf.append(escapeXml(entry.getValue() - .toString())); + buf.append(escapeXml(entry.getValue().toString())); buf.append("'); @@ -301,19 +277,16 @@ public class XmlApiManager extends BaseApiManager implements WebApiManager { } private String convertTagName(final String name) { - final String tagName = StringUtil.decamelize(name).replaceAll("_", "-") - .toLowerCase(); + final String tagName = StringUtil.decamelize(name).replaceAll("_", "-").toLowerCase(); return tagName; } - protected void processLabelRequest(final HttpServletRequest request, - final HttpServletResponse response, final FilterChain chain) { + protected void processLabelRequest(final HttpServletRequest request, final HttpServletResponse response, final FilterChain chain) { int status = 0; String errMsg = StringUtil.EMPTY; final StringBuilder buf = new StringBuilder(255); try { - final List> labelTypeItems = ComponentUtil - .getLabelTypeHelper().getLabelTypeItemList(); + final List> labelTypeItems = ComponentUtil.getLabelTypeHelper().getLabelTypeItemList(); buf.append(""); buf.append(labelTypeItems.size()); buf.append(""); @@ -341,22 +314,17 @@ public class XmlApiManager extends BaseApiManager implements WebApiManager { writeXmlResponse(status, buf.toString(), errMsg); } - protected void processSuggestRequest(final HttpServletRequest request, - final HttpServletResponse response, final FilterChain chain) { + protected void processSuggestRequest(final HttpServletRequest request, final HttpServletResponse response, final FilterChain chain) { int status = 0; String errMsg = StringUtil.EMPTY; final StringBuilder buf = new StringBuilder(255); try { - chain.doFilter(new WebApiRequest(request, SUGGEST_API), - new WebApiResponse(response)); + chain.doFilter(new WebApiRequest(request, SUGGEST_API), new WebApiResponse(response)); WebApiUtil.validate(); - final Integer suggestRecordCount = WebApiUtil - .getObject("suggestRecordCount"); - final List suggestResultList = WebApiUtil - .getObject("suggestResultList"); - final List suggestFieldName = WebApiUtil - .getObject("suggestFieldName"); + final Integer suggestRecordCount = WebApiUtil.getObject("suggestRecordCount"); + final List suggestResultList = WebApiUtil.getObject("suggestResultList"); + final List suggestFieldName = WebApiUtil.getObject("suggestFieldName"); buf.append(""); buf.append(suggestRecordCount); @@ -366,13 +334,10 @@ public class XmlApiManager extends BaseApiManager implements WebApiManager { for (int i = 0; i < suggestResultList.size(); i++) { - final SuggestResponse suggestResponse = suggestResultList - .get(i); + final SuggestResponse suggestResponse = suggestResultList.get(i); - for (final Map.Entry> entry : suggestResponse - .entrySet()) { - final SuggestResponseList srList = (SuggestResponseList) entry - .getValue(); + for (final Map.Entry> entry : suggestResponse.entrySet()) { + final SuggestResponseList srList = (SuggestResponseList) entry.getValue(); final String fn = suggestFieldName.get(i); buf.append(""); buf.append(""); @@ -382,16 +347,13 @@ public class XmlApiManager extends BaseApiManager implements WebApiManager { buf.append(escapeXml(fn)); buf.append(""); buf.append(""); - buf.append(escapeXml(Integer.toString(srList - .getStartOffset()))); + buf.append(escapeXml(Integer.toString(srList.getStartOffset()))); buf.append(""); buf.append(""); - buf.append(escapeXml(Integer.toString(srList - .getEndOffset()))); + buf.append(escapeXml(Integer.toString(srList.getEndOffset()))); buf.append(""); buf.append(""); - buf.append(escapeXml(Integer.toString(srList - .getNumFound()))); + buf.append(escapeXml(Integer.toString(srList.getNumFound()))); buf.append(""); buf.append(""); for (final String value : srList) { @@ -421,22 +383,17 @@ public class XmlApiManager extends BaseApiManager implements WebApiManager { writeXmlResponse(status, buf.toString(), errMsg); } - protected void processSpellCheckRequest(final HttpServletRequest request, - final HttpServletResponse response, final FilterChain chain) { + protected void processSpellCheckRequest(final HttpServletRequest request, final HttpServletResponse response, final FilterChain chain) { int status = 0; String errMsg = StringUtil.EMPTY; final StringBuilder buf = new StringBuilder(255); try { - chain.doFilter(new WebApiRequest(request, SPELLCHECK_API), - new WebApiResponse(response)); + chain.doFilter(new WebApiRequest(request, SPELLCHECK_API), new WebApiResponse(response)); WebApiUtil.validate(); - final Integer spellCheckRecordCount = WebApiUtil - .getObject("spellCheckRecordCount"); - final List spellCheckResultList = WebApiUtil - .getObject("spellCheckResultList"); - final List spellCheckFieldName = WebApiUtil - .getObject("spellCheckFieldName"); + final Integer spellCheckRecordCount = WebApiUtil.getObject("spellCheckRecordCount"); + final List spellCheckResultList = WebApiUtil.getObject("spellCheckResultList"); + final List spellCheckFieldName = WebApiUtil.getObject("spellCheckFieldName"); buf.append(""); buf.append(spellCheckRecordCount); @@ -446,13 +403,10 @@ public class XmlApiManager extends BaseApiManager implements WebApiManager { for (int i = 0; i < spellCheckResultList.size(); i++) { - final SuggestResponse suggestResponse = spellCheckResultList - .get(i); + final SuggestResponse suggestResponse = spellCheckResultList.get(i); - for (final Map.Entry> entry : suggestResponse - .entrySet()) { - final SuggestResponseList srList = (SuggestResponseList) entry - .getValue(); + for (final Map.Entry> entry : suggestResponse.entrySet()) { + final SuggestResponseList srList = (SuggestResponseList) entry.getValue(); final String fn = spellCheckFieldName.get(i); buf.append(""); buf.append(""); @@ -462,16 +416,13 @@ public class XmlApiManager extends BaseApiManager implements WebApiManager { buf.append(escapeXml(fn)); buf.append(""); buf.append(""); - buf.append(escapeXml(Integer.toString(srList - .getStartOffset()))); + buf.append(escapeXml(Integer.toString(srList.getStartOffset()))); buf.append(""); buf.append(""); - buf.append(escapeXml(Integer.toString(srList - .getEndOffset()))); + buf.append(escapeXml(Integer.toString(srList.getEndOffset()))); buf.append(""); buf.append(""); - buf.append(escapeXml(Integer.toString(srList - .getNumFound()))); + buf.append(escapeXml(Integer.toString(srList.getNumFound()))); buf.append(""); buf.append(""); for (final String value : srList) { @@ -501,46 +452,33 @@ public class XmlApiManager extends BaseApiManager implements WebApiManager { writeXmlResponse(status, buf.toString(), errMsg); } - protected String processAnalysisRequest(final HttpServletRequest request, - final HttpServletResponse response, final FilterChain chain) { + protected String processAnalysisRequest(final HttpServletRequest request, final HttpServletResponse response, final FilterChain chain) { int status = 0; String errMsg = StringUtil.EMPTY; final StringBuilder buf = new StringBuilder(255); try { - chain.doFilter(new WebApiRequest(request, ANALYSIS_API), - new WebApiResponse(response)); + chain.doFilter(new WebApiRequest(request, ANALYSIS_API), new WebApiResponse(response)); WebApiUtil.validate(); - final FieldAnalysisResponse fieldAnalysis = WebApiUtil - .getObject("fieldAnalysis"); + final FieldAnalysisResponse fieldAnalysis = WebApiUtil.getObject("fieldAnalysis"); buf.append(""); buf.append(fieldAnalysis.size()); buf.append(""); if (fieldAnalysis.size() > 0) { buf.append(""); - for (final Map.Entry>>> fEntry : fieldAnalysis - .entrySet()) { + for (final Map.Entry>>> fEntry : fieldAnalysis.entrySet()) { - buf.append(""); - for (final Map.Entry>> aEntry : fEntry - .getValue().entrySet()) { - buf.append(""); - for (final Map dataMap : aEntry - .getValue()) { + buf.append(""); + for (final Map.Entry>> aEntry : fEntry.getValue().entrySet()) { + buf.append(""); + for (final Map dataMap : aEntry.getValue()) { buf.append(""); - for (final Map.Entry dEntry : dataMap - .entrySet()) { + for (final Map.Entry dEntry : dataMap.entrySet()) { final String key = dEntry.getKey(); final Object value = dEntry.getValue(); if (StringUtil.isNotBlank(key) && value != null) { - buf.append("") - .append(escapeXml(value)) + buf.append("").append(escapeXml(value)) .append(""); } } @@ -569,8 +507,7 @@ public class XmlApiManager extends BaseApiManager implements WebApiManager { return null; } - protected void writeXmlResponse(final int status, final String body, - final String errMsg) { + protected void writeXmlResponse(final int status, final String body, final String errMsg) { final StringBuilder buf = new StringBuilder(1000); buf.append(""); buf.append(""); @@ -604,14 +541,12 @@ public class XmlApiManager extends BaseApiManager implements WebApiManager { buf.append(""); for (final Map.Entry entry : ((Map) obj).entrySet()) { - buf.append("").append(escapeXml(entry.getKey())) - .append("") - .append(escapeXml(entry.getValue())).append(""); + buf.append("").append(escapeXml(entry.getKey())).append("").append(escapeXml(entry.getValue())) + .append(""); } buf.append(""); } else if (obj instanceof Date) { - final SimpleDateFormat sdf = new SimpleDateFormat( - CoreLibConstants.DATE_FORMAT_ISO_8601_EXTEND); + final SimpleDateFormat sdf = new SimpleDateFormat(CoreLibConstants.DATE_FORMAT_ISO_8601_EXTEND); buf.append(StringEscapeUtils.escapeXml(sdf.format(obj))); } else if (obj != null) { buf.append(StringEscapeUtils.escapeXml(obj.toString())); diff --git a/src/main/java/org/codelibs/fess/crud/CommonConstants.java b/src/main/java/org/codelibs/fess/crud/CommonConstants.java index 66dcfab0a..a38b9531f 100644 --- a/src/main/java/org/codelibs/fess/crud/CommonConstants.java +++ b/src/main/java/org/codelibs/fess/crud/CommonConstants.java @@ -33,9 +33,8 @@ public class CommonConstants { public static final String FALSE = "F"; - public static final String[] PAGER_CONVERSION_RULE = { "allRecordCount", - "pageSize", "currentPageNumber", "allPageCount", "existPrePage", - "existNextPage" }; + public static final String[] PAGER_CONVERSION_RULE = { "allRecordCount", "pageSize", "currentPageNumber", "allPageCount", + "existPrePage", "existNextPage" }; protected CommonConstants() { // nothing diff --git a/src/main/java/org/codelibs/fess/crud/CrudMessageException.java b/src/main/java/org/codelibs/fess/crud/CrudMessageException.java index 3c4168cc7..ea12012d6 100644 --- a/src/main/java/org/codelibs/fess/crud/CrudMessageException.java +++ b/src/main/java/org/codelibs/fess/crud/CrudMessageException.java @@ -56,15 +56,13 @@ public class CrudMessageException extends RuntimeException { this.args = args; } - public CrudMessageException(final String messageId, final String message, - final Throwable cause) { + public CrudMessageException(final String messageId, final String message, final Throwable cause) { super(message, cause); this.messageId = messageId; args = null; } - public CrudMessageException(final String messageId, final Object[] args, - final String message, final Throwable cause) { + public CrudMessageException(final String messageId, final Object[] args, final String message, final Throwable cause) { super(message, cause); this.messageId = messageId; this.args = args; @@ -76,8 +74,7 @@ public class CrudMessageException extends RuntimeException { args = null; } - public CrudMessageException(final String messageId, final Object[] args, - final String message) { + public CrudMessageException(final String messageId, final Object[] args, final String message) { super(message); this.messageId = messageId; this.args = args; @@ -89,8 +86,7 @@ public class CrudMessageException extends RuntimeException { args = null; } - public CrudMessageException(final String messageId, final Object[] args, - final Throwable cause) { + public CrudMessageException(final String messageId, final Object[] args, final Throwable cause) { super(cause); this.messageId = messageId; this.args = args; diff --git a/src/main/java/org/codelibs/fess/crud/action/admin/BsBoostDocumentRuleAction.java b/src/main/java/org/codelibs/fess/crud/action/admin/BsBoostDocumentRuleAction.java index 8cf4f9430..c80813dcf 100644 --- a/src/main/java/org/codelibs/fess/crud/action/admin/BsBoostDocumentRuleAction.java +++ b/src/main/java/org/codelibs/fess/crud/action/admin/BsBoostDocumentRuleAction.java @@ -43,8 +43,7 @@ public class BsBoostDocumentRuleAction implements Serializable { private static final long serialVersionUID = 1L; - private static final Log log = LogFactory - .getLog(BsBoostDocumentRuleAction.class); + private static final Log log = LogFactory.getLog(BsBoostDocumentRuleAction.class); // for list @@ -64,14 +63,12 @@ public class BsBoostDocumentRuleAction implements Serializable { protected String displayList(final boolean redirect) { // page navi - boostDocumentRuleItems = boostDocumentRuleService - .getBoostDocumentRuleList(boostDocumentRulePager); + boostDocumentRuleItems = boostDocumentRuleService.getBoostDocumentRuleList(boostDocumentRulePager); // restore from pager - Beans.copy(boostDocumentRulePager, boostDocumentRuleForm.searchParams) - .excludes(CommonConstants.PAGER_CONVERSION_RULE) + Beans.copy(boostDocumentRulePager, boostDocumentRuleForm.searchParams).excludes(CommonConstants.PAGER_CONVERSION_RULE) - .execute(); + .execute(); if (redirect) { return "index?redirect=true"; @@ -90,12 +87,10 @@ public class BsBoostDocumentRuleAction implements Serializable { // page navi if (StringUtil.isNotBlank(boostDocumentRuleForm.pageNumber)) { try { - boostDocumentRulePager.setCurrentPageNumber(Integer - .parseInt(boostDocumentRuleForm.pageNumber)); + boostDocumentRulePager.setCurrentPageNumber(Integer.parseInt(boostDocumentRuleForm.pageNumber)); } catch (final NumberFormatException e) { if (log.isDebugEnabled()) { - log.debug("Invalid value: " - + boostDocumentRuleForm.pageNumber, e); + log.debug("Invalid value: " + boostDocumentRuleForm.pageNumber, e); } } } @@ -105,10 +100,9 @@ public class BsBoostDocumentRuleAction implements Serializable { @Execute(validator = false, input = "error.jsp") public String search() { - Beans.copy(boostDocumentRuleForm.searchParams, boostDocumentRulePager) - .excludes(CommonConstants.PAGER_CONVERSION_RULE) + Beans.copy(boostDocumentRuleForm.searchParams, boostDocumentRulePager).excludes(CommonConstants.PAGER_CONVERSION_RULE) - .execute(); + .execute(); return displayList(false); } @@ -134,9 +128,8 @@ public class BsBoostDocumentRuleAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "confirmpage/{crudMode}/{id}") public String confirmpage() { if (boostDocumentRuleForm.crudMode != CommonConstants.CONFIRM_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.CONFIRM_MODE, - boostDocumentRuleForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE, + boostDocumentRuleForm.crudMode }); } loadBoostDocumentRule(); @@ -158,9 +151,8 @@ public class BsBoostDocumentRuleAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "editpage/{crudMode}/{id}") public String editpage() { if (boostDocumentRuleForm.crudMode != CommonConstants.EDIT_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.EDIT_MODE, - boostDocumentRuleForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE, + boostDocumentRuleForm.crudMode }); } loadBoostDocumentRule(); @@ -194,9 +186,8 @@ public class BsBoostDocumentRuleAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "deletepage/{crudMode}/{id}") public String deletepage() { if (boostDocumentRuleForm.crudMode != CommonConstants.DELETE_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - boostDocumentRuleForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, + boostDocumentRuleForm.crudMode }); } loadBoostDocumentRule(); @@ -231,8 +222,7 @@ public class BsBoostDocumentRuleAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_create_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_create_crud_table"); } } @@ -253,8 +243,7 @@ public class BsBoostDocumentRuleAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_update_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_update_crud_table"); } } @@ -262,20 +251,17 @@ public class BsBoostDocumentRuleAction implements Serializable { @Execute(validator = false, input = "error.jsp") public String delete() { if (boostDocumentRuleForm.crudMode != CommonConstants.DELETE_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - boostDocumentRuleForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, + boostDocumentRuleForm.crudMode }); } try { - final BoostDocumentRule boostDocumentRule = boostDocumentRuleService - .getBoostDocumentRule(createKeyMap()); + final BoostDocumentRule boostDocumentRule = boostDocumentRuleService.getBoostDocumentRule(createKeyMap()); if (boostDocumentRule == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { boostDocumentRuleForm.id }); + new Object[] { boostDocumentRuleForm.id }); } @@ -291,50 +277,43 @@ public class BsBoostDocumentRuleAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_delete_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_delete_crud_table"); } } protected void loadBoostDocumentRule() { - final BoostDocumentRule boostDocumentRule = boostDocumentRuleService - .getBoostDocumentRule(createKeyMap()); + final BoostDocumentRule boostDocumentRule = boostDocumentRuleService.getBoostDocumentRule(createKeyMap()); if (boostDocumentRule == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { boostDocumentRuleForm.id }); + new Object[] { boostDocumentRuleForm.id }); } - Beans.copy(boostDocumentRule, boostDocumentRuleForm) - .excludes("searchParams", "mode") + Beans.copy(boostDocumentRule, boostDocumentRuleForm).excludes("searchParams", "mode") - .execute(); + .execute(); } protected BoostDocumentRule createBoostDocumentRule() { BoostDocumentRule boostDocumentRule; if (boostDocumentRuleForm.crudMode == CommonConstants.EDIT_MODE) { - boostDocumentRule = boostDocumentRuleService - .getBoostDocumentRule(createKeyMap()); + boostDocumentRule = boostDocumentRuleService.getBoostDocumentRule(createKeyMap()); if (boostDocumentRule == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { boostDocumentRuleForm.id }); + new Object[] { boostDocumentRuleForm.id }); } } else { boostDocumentRule = new BoostDocumentRule(); } - Beans.copy(boostDocumentRuleForm, boostDocumentRule) - .excludes("searchParams", "mode") + Beans.copy(boostDocumentRuleForm, boostDocumentRule).excludes("searchParams", "mode") - .execute(); + .execute(); return boostDocumentRule; } diff --git a/src/main/java/org/codelibs/fess/crud/action/admin/BsCrawlingSessionAction.java b/src/main/java/org/codelibs/fess/crud/action/admin/BsCrawlingSessionAction.java index 41fc5c788..686d83ae4 100644 --- a/src/main/java/org/codelibs/fess/crud/action/admin/BsCrawlingSessionAction.java +++ b/src/main/java/org/codelibs/fess/crud/action/admin/BsCrawlingSessionAction.java @@ -43,8 +43,7 @@ public class BsCrawlingSessionAction implements Serializable { private static final long serialVersionUID = 1L; - private static final Log log = LogFactory - .getLog(BsCrawlingSessionAction.class); + private static final Log log = LogFactory.getLog(BsCrawlingSessionAction.class); // for list @@ -64,14 +63,12 @@ public class BsCrawlingSessionAction implements Serializable { protected String displayList(final boolean redirect) { // page navi - crawlingSessionItems = crawlingSessionService - .getCrawlingSessionList(crawlingSessionPager); + crawlingSessionItems = crawlingSessionService.getCrawlingSessionList(crawlingSessionPager); // restore from pager - Beans.copy(crawlingSessionPager, crawlingSessionForm.searchParams) - .excludes(CommonConstants.PAGER_CONVERSION_RULE) + Beans.copy(crawlingSessionPager, crawlingSessionForm.searchParams).excludes(CommonConstants.PAGER_CONVERSION_RULE) - .execute(); + .execute(); if (redirect) { return "index?redirect=true"; @@ -90,12 +87,10 @@ public class BsCrawlingSessionAction implements Serializable { // page navi if (StringUtil.isNotBlank(crawlingSessionForm.pageNumber)) { try { - crawlingSessionPager.setCurrentPageNumber(Integer - .parseInt(crawlingSessionForm.pageNumber)); + crawlingSessionPager.setCurrentPageNumber(Integer.parseInt(crawlingSessionForm.pageNumber)); } catch (final NumberFormatException e) { if (log.isDebugEnabled()) { - log.debug("Invalid value: " - + crawlingSessionForm.pageNumber, e); + log.debug("Invalid value: " + crawlingSessionForm.pageNumber, e); } } } @@ -105,10 +100,9 @@ public class BsCrawlingSessionAction implements Serializable { @Execute(validator = false, input = "error.jsp") public String search() { - Beans.copy(crawlingSessionForm.searchParams, crawlingSessionPager) - .excludes(CommonConstants.PAGER_CONVERSION_RULE) + Beans.copy(crawlingSessionForm.searchParams, crawlingSessionPager).excludes(CommonConstants.PAGER_CONVERSION_RULE) - .execute(); + .execute(); return displayList(false); } @@ -134,9 +128,8 @@ public class BsCrawlingSessionAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "confirmpage/{crudMode}/{id}") public String confirmpage() { if (crawlingSessionForm.crudMode != CommonConstants.CONFIRM_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.CONFIRM_MODE, - crawlingSessionForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE, + crawlingSessionForm.crudMode }); } loadCrawlingSession(); @@ -158,9 +151,8 @@ public class BsCrawlingSessionAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "editpage/{crudMode}/{id}") public String editpage() { if (crawlingSessionForm.crudMode != CommonConstants.EDIT_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.EDIT_MODE, - crawlingSessionForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE, + crawlingSessionForm.crudMode }); } loadCrawlingSession(); @@ -194,9 +186,8 @@ public class BsCrawlingSessionAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "deletepage/{crudMode}/{id}") public String deletepage() { if (crawlingSessionForm.crudMode != CommonConstants.DELETE_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - crawlingSessionForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, + crawlingSessionForm.crudMode }); } loadCrawlingSession(); @@ -231,8 +222,7 @@ public class BsCrawlingSessionAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_create_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_create_crud_table"); } } @@ -253,8 +243,7 @@ public class BsCrawlingSessionAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_update_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_update_crud_table"); } } @@ -262,20 +251,17 @@ public class BsCrawlingSessionAction implements Serializable { @Execute(validator = false, input = "error.jsp") public String delete() { if (crawlingSessionForm.crudMode != CommonConstants.DELETE_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - crawlingSessionForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, + crawlingSessionForm.crudMode }); } try { - final CrawlingSession crawlingSession = crawlingSessionService - .getCrawlingSession(createKeyMap()); + final CrawlingSession crawlingSession = crawlingSessionService.getCrawlingSession(createKeyMap()); if (crawlingSession == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { crawlingSessionForm.id }); + new Object[] { crawlingSessionForm.id }); } @@ -291,50 +277,43 @@ public class BsCrawlingSessionAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_delete_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_delete_crud_table"); } } protected void loadCrawlingSession() { - final CrawlingSession crawlingSession = crawlingSessionService - .getCrawlingSession(createKeyMap()); + final CrawlingSession crawlingSession = crawlingSessionService.getCrawlingSession(createKeyMap()); if (crawlingSession == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { crawlingSessionForm.id }); + new Object[] { crawlingSessionForm.id }); } - Beans.copy(crawlingSession, crawlingSessionForm) - .excludes("searchParams", "mode") + Beans.copy(crawlingSession, crawlingSessionForm).excludes("searchParams", "mode") - .execute(); + .execute(); } protected CrawlingSession createCrawlingSession() { CrawlingSession crawlingSession; if (crawlingSessionForm.crudMode == CommonConstants.EDIT_MODE) { - crawlingSession = crawlingSessionService - .getCrawlingSession(createKeyMap()); + crawlingSession = crawlingSessionService.getCrawlingSession(createKeyMap()); if (crawlingSession == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { crawlingSessionForm.id }); + new Object[] { crawlingSessionForm.id }); } } else { crawlingSession = new CrawlingSession(); } - Beans.copy(crawlingSessionForm, crawlingSession) - .excludes("searchParams", "mode") + Beans.copy(crawlingSessionForm, crawlingSession).excludes("searchParams", "mode") - .execute(); + .execute(); return crawlingSession; } diff --git a/src/main/java/org/codelibs/fess/crud/action/admin/BsDataCrawlingConfigAction.java b/src/main/java/org/codelibs/fess/crud/action/admin/BsDataCrawlingConfigAction.java index 1504fdb56..df1a13034 100644 --- a/src/main/java/org/codelibs/fess/crud/action/admin/BsDataCrawlingConfigAction.java +++ b/src/main/java/org/codelibs/fess/crud/action/admin/BsDataCrawlingConfigAction.java @@ -43,8 +43,7 @@ public class BsDataCrawlingConfigAction implements Serializable { private static final long serialVersionUID = 1L; - private static final Log log = LogFactory - .getLog(BsDataCrawlingConfigAction.class); + private static final Log log = LogFactory.getLog(BsDataCrawlingConfigAction.class); // for list @@ -64,14 +63,12 @@ public class BsDataCrawlingConfigAction implements Serializable { protected String displayList(final boolean redirect) { // page navi - dataCrawlingConfigItems = dataCrawlingConfigService - .getDataCrawlingConfigList(dataCrawlingConfigPager); + dataCrawlingConfigItems = dataCrawlingConfigService.getDataCrawlingConfigList(dataCrawlingConfigPager); // restore from pager - Beans.copy(dataCrawlingConfigPager, dataCrawlingConfigForm.searchParams) - .excludes(CommonConstants.PAGER_CONVERSION_RULE) + Beans.copy(dataCrawlingConfigPager, dataCrawlingConfigForm.searchParams).excludes(CommonConstants.PAGER_CONVERSION_RULE) - .execute(); + .execute(); if (redirect) { return "index?redirect=true"; @@ -90,12 +87,10 @@ public class BsDataCrawlingConfigAction implements Serializable { // page navi if (StringUtil.isNotBlank(dataCrawlingConfigForm.pageNumber)) { try { - dataCrawlingConfigPager.setCurrentPageNumber(Integer - .parseInt(dataCrawlingConfigForm.pageNumber)); + dataCrawlingConfigPager.setCurrentPageNumber(Integer.parseInt(dataCrawlingConfigForm.pageNumber)); } catch (final NumberFormatException e) { if (log.isDebugEnabled()) { - log.debug("Invalid value: " - + dataCrawlingConfigForm.pageNumber, e); + log.debug("Invalid value: " + dataCrawlingConfigForm.pageNumber, e); } } } @@ -105,10 +100,9 @@ public class BsDataCrawlingConfigAction implements Serializable { @Execute(validator = false, input = "error.jsp") public String search() { - Beans.copy(dataCrawlingConfigForm.searchParams, dataCrawlingConfigPager) - .excludes(CommonConstants.PAGER_CONVERSION_RULE) + Beans.copy(dataCrawlingConfigForm.searchParams, dataCrawlingConfigPager).excludes(CommonConstants.PAGER_CONVERSION_RULE) - .execute(); + .execute(); return displayList(false); } @@ -134,9 +128,8 @@ public class BsDataCrawlingConfigAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "confirmpage/{crudMode}/{id}") public String confirmpage() { if (dataCrawlingConfigForm.crudMode != CommonConstants.CONFIRM_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.CONFIRM_MODE, - dataCrawlingConfigForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE, + dataCrawlingConfigForm.crudMode }); } loadDataCrawlingConfig(); @@ -158,9 +151,8 @@ public class BsDataCrawlingConfigAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "editpage/{crudMode}/{id}") public String editpage() { if (dataCrawlingConfigForm.crudMode != CommonConstants.EDIT_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.EDIT_MODE, - dataCrawlingConfigForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE, + dataCrawlingConfigForm.crudMode }); } loadDataCrawlingConfig(); @@ -194,9 +186,8 @@ public class BsDataCrawlingConfigAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "deletepage/{crudMode}/{id}") public String deletepage() { if (dataCrawlingConfigForm.crudMode != CommonConstants.DELETE_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - dataCrawlingConfigForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, + dataCrawlingConfigForm.crudMode }); } loadDataCrawlingConfig(); @@ -231,8 +222,7 @@ public class BsDataCrawlingConfigAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_create_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_create_crud_table"); } } @@ -253,8 +243,7 @@ public class BsDataCrawlingConfigAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_update_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_update_crud_table"); } } @@ -262,20 +251,17 @@ public class BsDataCrawlingConfigAction implements Serializable { @Execute(validator = false, input = "error.jsp") public String delete() { if (dataCrawlingConfigForm.crudMode != CommonConstants.DELETE_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - dataCrawlingConfigForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, + dataCrawlingConfigForm.crudMode }); } try { - final DataCrawlingConfig dataCrawlingConfig = dataCrawlingConfigService - .getDataCrawlingConfig(createKeyMap()); + final DataCrawlingConfig dataCrawlingConfig = dataCrawlingConfigService.getDataCrawlingConfig(createKeyMap()); if (dataCrawlingConfig == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { dataCrawlingConfigForm.id }); + new Object[] { dataCrawlingConfigForm.id }); } @@ -291,50 +277,43 @@ public class BsDataCrawlingConfigAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_delete_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_delete_crud_table"); } } protected void loadDataCrawlingConfig() { - final DataCrawlingConfig dataCrawlingConfig = dataCrawlingConfigService - .getDataCrawlingConfig(createKeyMap()); + final DataCrawlingConfig dataCrawlingConfig = dataCrawlingConfigService.getDataCrawlingConfig(createKeyMap()); if (dataCrawlingConfig == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { dataCrawlingConfigForm.id }); + new Object[] { dataCrawlingConfigForm.id }); } - Beans.copy(dataCrawlingConfig, dataCrawlingConfigForm) - .excludes("searchParams", "mode") + Beans.copy(dataCrawlingConfig, dataCrawlingConfigForm).excludes("searchParams", "mode") - .execute(); + .execute(); } protected DataCrawlingConfig createDataCrawlingConfig() { DataCrawlingConfig dataCrawlingConfig; if (dataCrawlingConfigForm.crudMode == CommonConstants.EDIT_MODE) { - dataCrawlingConfig = dataCrawlingConfigService - .getDataCrawlingConfig(createKeyMap()); + dataCrawlingConfig = dataCrawlingConfigService.getDataCrawlingConfig(createKeyMap()); if (dataCrawlingConfig == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { dataCrawlingConfigForm.id }); + new Object[] { dataCrawlingConfigForm.id }); } } else { dataCrawlingConfig = new DataCrawlingConfig(); } - Beans.copy(dataCrawlingConfigForm, dataCrawlingConfig) - .excludes("searchParams", "mode") + Beans.copy(dataCrawlingConfigForm, dataCrawlingConfig).excludes("searchParams", "mode") - .execute(); + .execute(); return dataCrawlingConfig; } diff --git a/src/main/java/org/codelibs/fess/crud/action/admin/BsFailureUrlAction.java b/src/main/java/org/codelibs/fess/crud/action/admin/BsFailureUrlAction.java index c6b04439e..7967929f2 100644 --- a/src/main/java/org/codelibs/fess/crud/action/admin/BsFailureUrlAction.java +++ b/src/main/java/org/codelibs/fess/crud/action/admin/BsFailureUrlAction.java @@ -66,10 +66,9 @@ public class BsFailureUrlAction implements Serializable { failureUrlItems = failureUrlService.getFailureUrlList(failureUrlPager); // restore from pager - Beans.copy(failureUrlPager, failureUrlForm.searchParams) - .excludes(CommonConstants.PAGER_CONVERSION_RULE) + Beans.copy(failureUrlPager, failureUrlForm.searchParams).excludes(CommonConstants.PAGER_CONVERSION_RULE) - .execute(); + .execute(); if (redirect) { return "index?redirect=true"; @@ -88,8 +87,7 @@ public class BsFailureUrlAction implements Serializable { // page navi if (StringUtil.isNotBlank(failureUrlForm.pageNumber)) { try { - failureUrlPager.setCurrentPageNumber(Integer - .parseInt(failureUrlForm.pageNumber)); + failureUrlPager.setCurrentPageNumber(Integer.parseInt(failureUrlForm.pageNumber)); } catch (final NumberFormatException e) { if (log.isDebugEnabled()) { log.debug("Invalid value: " + failureUrlForm.pageNumber, e); @@ -102,10 +100,9 @@ public class BsFailureUrlAction implements Serializable { @Execute(validator = false, input = "error.jsp") public String search() { - Beans.copy(failureUrlForm.searchParams, failureUrlPager) - .excludes(CommonConstants.PAGER_CONVERSION_RULE) + Beans.copy(failureUrlForm.searchParams, failureUrlPager).excludes(CommonConstants.PAGER_CONVERSION_RULE) - .execute(); + .execute(); return displayList(false); } @@ -131,9 +128,8 @@ public class BsFailureUrlAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "confirmpage/{crudMode}/{id}") public String confirmpage() { if (failureUrlForm.crudMode != CommonConstants.CONFIRM_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.CONFIRM_MODE, - failureUrlForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE, + failureUrlForm.crudMode }); } loadFailureUrl(); @@ -156,8 +152,7 @@ public class BsFailureUrlAction implements Serializable { public String editpage() { if (failureUrlForm.crudMode != CommonConstants.EDIT_MODE) { throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.EDIT_MODE, - failureUrlForm.crudMode }); + new Object[] { CommonConstants.EDIT_MODE, failureUrlForm.crudMode }); } loadFailureUrl(); @@ -191,9 +186,8 @@ public class BsFailureUrlAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "deletepage/{crudMode}/{id}") public String deletepage() { if (failureUrlForm.crudMode != CommonConstants.DELETE_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - failureUrlForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, + failureUrlForm.crudMode }); } loadFailureUrl(); @@ -228,8 +222,7 @@ public class BsFailureUrlAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_create_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_create_crud_table"); } } @@ -250,8 +243,7 @@ public class BsFailureUrlAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_update_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_update_crud_table"); } } @@ -259,20 +251,17 @@ public class BsFailureUrlAction implements Serializable { @Execute(validator = false, input = "error.jsp") public String delete() { if (failureUrlForm.crudMode != CommonConstants.DELETE_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - failureUrlForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, + failureUrlForm.crudMode }); } try { - final FailureUrl failureUrl = failureUrlService - .getFailureUrl(createKeyMap()); + final FailureUrl failureUrl = failureUrlService.getFailureUrl(createKeyMap()); if (failureUrl == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { failureUrlForm.id }); + new Object[] { failureUrlForm.id }); } @@ -288,21 +277,18 @@ public class BsFailureUrlAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_delete_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_delete_crud_table"); } } protected void loadFailureUrl() { - final FailureUrl failureUrl = failureUrlService - .getFailureUrl(createKeyMap()); + final FailureUrl failureUrl = failureUrlService.getFailureUrl(createKeyMap()); if (failureUrl == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { failureUrlForm.id }); + new Object[] { failureUrlForm.id }); } @@ -317,10 +303,9 @@ public class BsFailureUrlAction implements Serializable { failureUrl = failureUrlService.getFailureUrl(createKeyMap()); if (failureUrl == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { failureUrlForm.id }); + new Object[] { failureUrlForm.id }); } } else { diff --git a/src/main/java/org/codelibs/fess/crud/action/admin/BsFavoriteLogAction.java b/src/main/java/org/codelibs/fess/crud/action/admin/BsFavoriteLogAction.java index 9bc8b3474..eb7ebab2f 100644 --- a/src/main/java/org/codelibs/fess/crud/action/admin/BsFavoriteLogAction.java +++ b/src/main/java/org/codelibs/fess/crud/action/admin/BsFavoriteLogAction.java @@ -63,14 +63,12 @@ public class BsFavoriteLogAction implements Serializable { protected String displayList(final boolean redirect) { // page navi - favoriteLogItems = favoriteLogService - .getFavoriteLogList(favoriteLogPager); + favoriteLogItems = favoriteLogService.getFavoriteLogList(favoriteLogPager); // restore from pager - Beans.copy(favoriteLogPager, favoriteLogForm.searchParams) - .excludes(CommonConstants.PAGER_CONVERSION_RULE) + Beans.copy(favoriteLogPager, favoriteLogForm.searchParams).excludes(CommonConstants.PAGER_CONVERSION_RULE) - .execute(); + .execute(); if (redirect) { return "index?redirect=true"; @@ -89,8 +87,7 @@ public class BsFavoriteLogAction implements Serializable { // page navi if (StringUtil.isNotBlank(favoriteLogForm.pageNumber)) { try { - favoriteLogPager.setCurrentPageNumber(Integer - .parseInt(favoriteLogForm.pageNumber)); + favoriteLogPager.setCurrentPageNumber(Integer.parseInt(favoriteLogForm.pageNumber)); } catch (final NumberFormatException e) { if (log.isDebugEnabled()) { log.debug("Invalid value: " + favoriteLogForm.pageNumber, e); @@ -103,10 +100,9 @@ public class BsFavoriteLogAction implements Serializable { @Execute(validator = false, input = "error.jsp") public String search() { - Beans.copy(favoriteLogForm.searchParams, favoriteLogPager) - .excludes(CommonConstants.PAGER_CONVERSION_RULE) + Beans.copy(favoriteLogForm.searchParams, favoriteLogPager).excludes(CommonConstants.PAGER_CONVERSION_RULE) - .execute(); + .execute(); return displayList(false); } @@ -132,9 +128,8 @@ public class BsFavoriteLogAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "confirmpage/{crudMode}/{id}") public String confirmpage() { if (favoriteLogForm.crudMode != CommonConstants.CONFIRM_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.CONFIRM_MODE, - favoriteLogForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE, + favoriteLogForm.crudMode }); } loadFavoriteLog(); @@ -156,9 +151,8 @@ public class BsFavoriteLogAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "editpage/{crudMode}/{id}") public String editpage() { if (favoriteLogForm.crudMode != CommonConstants.EDIT_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.EDIT_MODE, - favoriteLogForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE, + favoriteLogForm.crudMode }); } loadFavoriteLog(); @@ -192,9 +186,8 @@ public class BsFavoriteLogAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "deletepage/{crudMode}/{id}") public String deletepage() { if (favoriteLogForm.crudMode != CommonConstants.DELETE_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - favoriteLogForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, + favoriteLogForm.crudMode }); } loadFavoriteLog(); @@ -229,8 +222,7 @@ public class BsFavoriteLogAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_create_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_create_crud_table"); } } @@ -251,8 +243,7 @@ public class BsFavoriteLogAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_update_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_update_crud_table"); } } @@ -260,20 +251,17 @@ public class BsFavoriteLogAction implements Serializable { @Execute(validator = false, input = "error.jsp") public String delete() { if (favoriteLogForm.crudMode != CommonConstants.DELETE_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - favoriteLogForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, + favoriteLogForm.crudMode }); } try { - final FavoriteLog favoriteLog = favoriteLogService - .getFavoriteLog(createKeyMap()); + final FavoriteLog favoriteLog = favoriteLogService.getFavoriteLog(createKeyMap()); if (favoriteLog == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { favoriteLogForm.id }); + new Object[] { favoriteLogForm.id }); } @@ -289,28 +277,24 @@ public class BsFavoriteLogAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_delete_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_delete_crud_table"); } } protected void loadFavoriteLog() { - final FavoriteLog favoriteLog = favoriteLogService - .getFavoriteLog(createKeyMap()); + final FavoriteLog favoriteLog = favoriteLogService.getFavoriteLog(createKeyMap()); if (favoriteLog == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { favoriteLogForm.id }); + new Object[] { favoriteLogForm.id }); } - Beans.copy(favoriteLog, favoriteLogForm) - .excludes("searchParams", "mode") + Beans.copy(favoriteLog, favoriteLogForm).excludes("searchParams", "mode") - .execute(); + .execute(); } protected FavoriteLog createFavoriteLog() { @@ -319,19 +303,17 @@ public class BsFavoriteLogAction implements Serializable { favoriteLog = favoriteLogService.getFavoriteLog(createKeyMap()); if (favoriteLog == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { favoriteLogForm.id }); + new Object[] { favoriteLogForm.id }); } } else { favoriteLog = new FavoriteLog(); } - Beans.copy(favoriteLogForm, favoriteLog) - .excludes("searchParams", "mode") + Beans.copy(favoriteLogForm, favoriteLog).excludes("searchParams", "mode") - .execute(); + .execute(); return favoriteLog; } diff --git a/src/main/java/org/codelibs/fess/crud/action/admin/BsFileAuthenticationAction.java b/src/main/java/org/codelibs/fess/crud/action/admin/BsFileAuthenticationAction.java index 7f33ebf9b..33cd7fe06 100644 --- a/src/main/java/org/codelibs/fess/crud/action/admin/BsFileAuthenticationAction.java +++ b/src/main/java/org/codelibs/fess/crud/action/admin/BsFileAuthenticationAction.java @@ -43,8 +43,7 @@ public class BsFileAuthenticationAction implements Serializable { private static final long serialVersionUID = 1L; - private static final Log log = LogFactory - .getLog(BsFileAuthenticationAction.class); + private static final Log log = LogFactory.getLog(BsFileAuthenticationAction.class); // for list @@ -64,14 +63,12 @@ public class BsFileAuthenticationAction implements Serializable { protected String displayList(final boolean redirect) { // page navi - fileAuthenticationItems = fileAuthenticationService - .getFileAuthenticationList(fileAuthenticationPager); + fileAuthenticationItems = fileAuthenticationService.getFileAuthenticationList(fileAuthenticationPager); // restore from pager - Beans.copy(fileAuthenticationPager, fileAuthenticationForm.searchParams) - .excludes(CommonConstants.PAGER_CONVERSION_RULE) + Beans.copy(fileAuthenticationPager, fileAuthenticationForm.searchParams).excludes(CommonConstants.PAGER_CONVERSION_RULE) - .execute(); + .execute(); if (redirect) { return "index?redirect=true"; @@ -90,12 +87,10 @@ public class BsFileAuthenticationAction implements Serializable { // page navi if (StringUtil.isNotBlank(fileAuthenticationForm.pageNumber)) { try { - fileAuthenticationPager.setCurrentPageNumber(Integer - .parseInt(fileAuthenticationForm.pageNumber)); + fileAuthenticationPager.setCurrentPageNumber(Integer.parseInt(fileAuthenticationForm.pageNumber)); } catch (final NumberFormatException e) { if (log.isDebugEnabled()) { - log.debug("Invalid value: " - + fileAuthenticationForm.pageNumber, e); + log.debug("Invalid value: " + fileAuthenticationForm.pageNumber, e); } } } @@ -105,10 +100,9 @@ public class BsFileAuthenticationAction implements Serializable { @Execute(validator = false, input = "error.jsp") public String search() { - Beans.copy(fileAuthenticationForm.searchParams, fileAuthenticationPager) - .excludes(CommonConstants.PAGER_CONVERSION_RULE) + Beans.copy(fileAuthenticationForm.searchParams, fileAuthenticationPager).excludes(CommonConstants.PAGER_CONVERSION_RULE) - .execute(); + .execute(); return displayList(false); } @@ -134,9 +128,8 @@ public class BsFileAuthenticationAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "confirmpage/{crudMode}/{id}") public String confirmpage() { if (fileAuthenticationForm.crudMode != CommonConstants.CONFIRM_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.CONFIRM_MODE, - fileAuthenticationForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE, + fileAuthenticationForm.crudMode }); } loadFileAuthentication(); @@ -158,9 +151,8 @@ public class BsFileAuthenticationAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "editpage/{crudMode}/{id}") public String editpage() { if (fileAuthenticationForm.crudMode != CommonConstants.EDIT_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.EDIT_MODE, - fileAuthenticationForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE, + fileAuthenticationForm.crudMode }); } loadFileAuthentication(); @@ -194,9 +186,8 @@ public class BsFileAuthenticationAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "deletepage/{crudMode}/{id}") public String deletepage() { if (fileAuthenticationForm.crudMode != CommonConstants.DELETE_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - fileAuthenticationForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, + fileAuthenticationForm.crudMode }); } loadFileAuthentication(); @@ -231,8 +222,7 @@ public class BsFileAuthenticationAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_create_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_create_crud_table"); } } @@ -253,8 +243,7 @@ public class BsFileAuthenticationAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_update_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_update_crud_table"); } } @@ -262,20 +251,17 @@ public class BsFileAuthenticationAction implements Serializable { @Execute(validator = false, input = "error.jsp") public String delete() { if (fileAuthenticationForm.crudMode != CommonConstants.DELETE_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - fileAuthenticationForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, + fileAuthenticationForm.crudMode }); } try { - final FileAuthentication fileAuthentication = fileAuthenticationService - .getFileAuthentication(createKeyMap()); + final FileAuthentication fileAuthentication = fileAuthenticationService.getFileAuthentication(createKeyMap()); if (fileAuthentication == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { fileAuthenticationForm.id }); + new Object[] { fileAuthenticationForm.id }); } @@ -291,50 +277,43 @@ public class BsFileAuthenticationAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_delete_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_delete_crud_table"); } } protected void loadFileAuthentication() { - final FileAuthentication fileAuthentication = fileAuthenticationService - .getFileAuthentication(createKeyMap()); + final FileAuthentication fileAuthentication = fileAuthenticationService.getFileAuthentication(createKeyMap()); if (fileAuthentication == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { fileAuthenticationForm.id }); + new Object[] { fileAuthenticationForm.id }); } - Beans.copy(fileAuthentication, fileAuthenticationForm) - .excludes("searchParams", "mode") + Beans.copy(fileAuthentication, fileAuthenticationForm).excludes("searchParams", "mode") - .execute(); + .execute(); } protected FileAuthentication createFileAuthentication() { FileAuthentication fileAuthentication; if (fileAuthenticationForm.crudMode == CommonConstants.EDIT_MODE) { - fileAuthentication = fileAuthenticationService - .getFileAuthentication(createKeyMap()); + fileAuthentication = fileAuthenticationService.getFileAuthentication(createKeyMap()); if (fileAuthentication == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { fileAuthenticationForm.id }); + new Object[] { fileAuthenticationForm.id }); } } else { fileAuthentication = new FileAuthentication(); } - Beans.copy(fileAuthenticationForm, fileAuthentication) - .excludes("searchParams", "mode") + Beans.copy(fileAuthenticationForm, fileAuthentication).excludes("searchParams", "mode") - .execute(); + .execute(); return fileAuthentication; } diff --git a/src/main/java/org/codelibs/fess/crud/action/admin/BsFileCrawlingConfigAction.java b/src/main/java/org/codelibs/fess/crud/action/admin/BsFileCrawlingConfigAction.java index 0dd5fa898..917bf8b69 100644 --- a/src/main/java/org/codelibs/fess/crud/action/admin/BsFileCrawlingConfigAction.java +++ b/src/main/java/org/codelibs/fess/crud/action/admin/BsFileCrawlingConfigAction.java @@ -43,8 +43,7 @@ public class BsFileCrawlingConfigAction implements Serializable { private static final long serialVersionUID = 1L; - private static final Log log = LogFactory - .getLog(BsFileCrawlingConfigAction.class); + private static final Log log = LogFactory.getLog(BsFileCrawlingConfigAction.class); // for list @@ -64,14 +63,12 @@ public class BsFileCrawlingConfigAction implements Serializable { protected String displayList(final boolean redirect) { // page navi - fileCrawlingConfigItems = fileCrawlingConfigService - .getFileCrawlingConfigList(fileCrawlingConfigPager); + fileCrawlingConfigItems = fileCrawlingConfigService.getFileCrawlingConfigList(fileCrawlingConfigPager); // restore from pager - Beans.copy(fileCrawlingConfigPager, fileCrawlingConfigForm.searchParams) - .excludes(CommonConstants.PAGER_CONVERSION_RULE) + Beans.copy(fileCrawlingConfigPager, fileCrawlingConfigForm.searchParams).excludes(CommonConstants.PAGER_CONVERSION_RULE) - .execute(); + .execute(); if (redirect) { return "index?redirect=true"; @@ -90,12 +87,10 @@ public class BsFileCrawlingConfigAction implements Serializable { // page navi if (StringUtil.isNotBlank(fileCrawlingConfigForm.pageNumber)) { try { - fileCrawlingConfigPager.setCurrentPageNumber(Integer - .parseInt(fileCrawlingConfigForm.pageNumber)); + fileCrawlingConfigPager.setCurrentPageNumber(Integer.parseInt(fileCrawlingConfigForm.pageNumber)); } catch (final NumberFormatException e) { if (log.isDebugEnabled()) { - log.debug("Invalid value: " - + fileCrawlingConfigForm.pageNumber, e); + log.debug("Invalid value: " + fileCrawlingConfigForm.pageNumber, e); } } } @@ -105,10 +100,9 @@ public class BsFileCrawlingConfigAction implements Serializable { @Execute(validator = false, input = "error.jsp") public String search() { - Beans.copy(fileCrawlingConfigForm.searchParams, fileCrawlingConfigPager) - .excludes(CommonConstants.PAGER_CONVERSION_RULE) + Beans.copy(fileCrawlingConfigForm.searchParams, fileCrawlingConfigPager).excludes(CommonConstants.PAGER_CONVERSION_RULE) - .execute(); + .execute(); return displayList(false); } @@ -134,9 +128,8 @@ public class BsFileCrawlingConfigAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "confirmpage/{crudMode}/{id}") public String confirmpage() { if (fileCrawlingConfigForm.crudMode != CommonConstants.CONFIRM_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.CONFIRM_MODE, - fileCrawlingConfigForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE, + fileCrawlingConfigForm.crudMode }); } loadFileCrawlingConfig(); @@ -158,9 +151,8 @@ public class BsFileCrawlingConfigAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "editpage/{crudMode}/{id}") public String editpage() { if (fileCrawlingConfigForm.crudMode != CommonConstants.EDIT_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.EDIT_MODE, - fileCrawlingConfigForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE, + fileCrawlingConfigForm.crudMode }); } loadFileCrawlingConfig(); @@ -194,9 +186,8 @@ public class BsFileCrawlingConfigAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "deletepage/{crudMode}/{id}") public String deletepage() { if (fileCrawlingConfigForm.crudMode != CommonConstants.DELETE_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - fileCrawlingConfigForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, + fileCrawlingConfigForm.crudMode }); } loadFileCrawlingConfig(); @@ -231,8 +222,7 @@ public class BsFileCrawlingConfigAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_create_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_create_crud_table"); } } @@ -253,8 +243,7 @@ public class BsFileCrawlingConfigAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_update_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_update_crud_table"); } } @@ -262,20 +251,17 @@ public class BsFileCrawlingConfigAction implements Serializable { @Execute(validator = false, input = "error.jsp") public String delete() { if (fileCrawlingConfigForm.crudMode != CommonConstants.DELETE_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - fileCrawlingConfigForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, + fileCrawlingConfigForm.crudMode }); } try { - final FileCrawlingConfig fileCrawlingConfig = fileCrawlingConfigService - .getFileCrawlingConfig(createKeyMap()); + final FileCrawlingConfig fileCrawlingConfig = fileCrawlingConfigService.getFileCrawlingConfig(createKeyMap()); if (fileCrawlingConfig == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { fileCrawlingConfigForm.id }); + new Object[] { fileCrawlingConfigForm.id }); } @@ -291,50 +277,43 @@ public class BsFileCrawlingConfigAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_delete_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_delete_crud_table"); } } protected void loadFileCrawlingConfig() { - final FileCrawlingConfig fileCrawlingConfig = fileCrawlingConfigService - .getFileCrawlingConfig(createKeyMap()); + final FileCrawlingConfig fileCrawlingConfig = fileCrawlingConfigService.getFileCrawlingConfig(createKeyMap()); if (fileCrawlingConfig == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { fileCrawlingConfigForm.id }); + new Object[] { fileCrawlingConfigForm.id }); } - Beans.copy(fileCrawlingConfig, fileCrawlingConfigForm) - .excludes("searchParams", "mode") + Beans.copy(fileCrawlingConfig, fileCrawlingConfigForm).excludes("searchParams", "mode") - .execute(); + .execute(); } protected FileCrawlingConfig createFileCrawlingConfig() { FileCrawlingConfig fileCrawlingConfig; if (fileCrawlingConfigForm.crudMode == CommonConstants.EDIT_MODE) { - fileCrawlingConfig = fileCrawlingConfigService - .getFileCrawlingConfig(createKeyMap()); + fileCrawlingConfig = fileCrawlingConfigService.getFileCrawlingConfig(createKeyMap()); if (fileCrawlingConfig == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { fileCrawlingConfigForm.id }); + new Object[] { fileCrawlingConfigForm.id }); } } else { fileCrawlingConfig = new FileCrawlingConfig(); } - Beans.copy(fileCrawlingConfigForm, fileCrawlingConfig) - .excludes("searchParams", "mode") + Beans.copy(fileCrawlingConfigForm, fileCrawlingConfig).excludes("searchParams", "mode") - .execute(); + .execute(); return fileCrawlingConfig; } diff --git a/src/main/java/org/codelibs/fess/crud/action/admin/BsJobLogAction.java b/src/main/java/org/codelibs/fess/crud/action/admin/BsJobLogAction.java index 2432f3c41..936c4d751 100644 --- a/src/main/java/org/codelibs/fess/crud/action/admin/BsJobLogAction.java +++ b/src/main/java/org/codelibs/fess/crud/action/admin/BsJobLogAction.java @@ -66,10 +66,9 @@ public class BsJobLogAction implements Serializable { jobLogItems = jobLogService.getJobLogList(jobLogPager); // restore from pager - Beans.copy(jobLogPager, jobLogForm.searchParams) - .excludes(CommonConstants.PAGER_CONVERSION_RULE) + Beans.copy(jobLogPager, jobLogForm.searchParams).excludes(CommonConstants.PAGER_CONVERSION_RULE) - .execute(); + .execute(); if (redirect) { return "index?redirect=true"; @@ -88,8 +87,7 @@ public class BsJobLogAction implements Serializable { // page navi if (StringUtil.isNotBlank(jobLogForm.pageNumber)) { try { - jobLogPager.setCurrentPageNumber(Integer - .parseInt(jobLogForm.pageNumber)); + jobLogPager.setCurrentPageNumber(Integer.parseInt(jobLogForm.pageNumber)); } catch (final NumberFormatException e) { if (log.isDebugEnabled()) { log.debug("Invalid value: " + jobLogForm.pageNumber, e); @@ -102,10 +100,9 @@ public class BsJobLogAction implements Serializable { @Execute(validator = false, input = "error.jsp") public String search() { - Beans.copy(jobLogForm.searchParams, jobLogPager) - .excludes(CommonConstants.PAGER_CONVERSION_RULE) + Beans.copy(jobLogForm.searchParams, jobLogPager).excludes(CommonConstants.PAGER_CONVERSION_RULE) - .execute(); + .execute(); return displayList(false); } @@ -132,8 +129,7 @@ public class BsJobLogAction implements Serializable { public String confirmpage() { if (jobLogForm.crudMode != CommonConstants.CONFIRM_MODE) { throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.CONFIRM_MODE, - jobLogForm.crudMode }); + new Object[] { CommonConstants.CONFIRM_MODE, jobLogForm.crudMode }); } loadJobLog(); @@ -155,9 +151,7 @@ public class BsJobLogAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "editpage/{crudMode}/{id}") public String editpage() { if (jobLogForm.crudMode != CommonConstants.EDIT_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.EDIT_MODE, - jobLogForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE, jobLogForm.crudMode }); } loadJobLog(); @@ -191,9 +185,7 @@ public class BsJobLogAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "deletepage/{crudMode}/{id}") public String deletepage() { if (jobLogForm.crudMode != CommonConstants.DELETE_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - jobLogForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, jobLogForm.crudMode }); } loadJobLog(); @@ -228,8 +220,7 @@ public class BsJobLogAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_create_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_create_crud_table"); } } @@ -250,8 +241,7 @@ public class BsJobLogAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_update_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_update_crud_table"); } } @@ -259,19 +249,16 @@ public class BsJobLogAction implements Serializable { @Execute(validator = false, input = "error.jsp") public String delete() { if (jobLogForm.crudMode != CommonConstants.DELETE_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - jobLogForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, jobLogForm.crudMode }); } try { final JobLog jobLog = jobLogService.getJobLog(createKeyMap()); if (jobLog == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { jobLogForm.id }); + new Object[] { jobLogForm.id }); } @@ -287,8 +274,7 @@ public class BsJobLogAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_delete_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_delete_crud_table"); } } @@ -297,10 +283,9 @@ public class BsJobLogAction implements Serializable { final JobLog jobLog = jobLogService.getJobLog(createKeyMap()); if (jobLog == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { jobLogForm.id }); + new Object[] { jobLogForm.id }); } @@ -315,10 +300,9 @@ public class BsJobLogAction implements Serializable { jobLog = jobLogService.getJobLog(createKeyMap()); if (jobLog == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { jobLogForm.id }); + new Object[] { jobLogForm.id }); } } else { diff --git a/src/main/java/org/codelibs/fess/crud/action/admin/BsKeyMatchAction.java b/src/main/java/org/codelibs/fess/crud/action/admin/BsKeyMatchAction.java index f86e6151e..3e457b3af 100644 --- a/src/main/java/org/codelibs/fess/crud/action/admin/BsKeyMatchAction.java +++ b/src/main/java/org/codelibs/fess/crud/action/admin/BsKeyMatchAction.java @@ -66,10 +66,9 @@ public class BsKeyMatchAction implements Serializable { keyMatchItems = keyMatchService.getKeyMatchList(keyMatchPager); // restore from pager - Beans.copy(keyMatchPager, keyMatchForm.searchParams) - .excludes(CommonConstants.PAGER_CONVERSION_RULE) + Beans.copy(keyMatchPager, keyMatchForm.searchParams).excludes(CommonConstants.PAGER_CONVERSION_RULE) - .execute(); + .execute(); if (redirect) { return "index?redirect=true"; @@ -88,8 +87,7 @@ public class BsKeyMatchAction implements Serializable { // page navi if (StringUtil.isNotBlank(keyMatchForm.pageNumber)) { try { - keyMatchPager.setCurrentPageNumber(Integer - .parseInt(keyMatchForm.pageNumber)); + keyMatchPager.setCurrentPageNumber(Integer.parseInt(keyMatchForm.pageNumber)); } catch (final NumberFormatException e) { if (log.isDebugEnabled()) { log.debug("Invalid value: " + keyMatchForm.pageNumber, e); @@ -102,10 +100,9 @@ public class BsKeyMatchAction implements Serializable { @Execute(validator = false, input = "error.jsp") public String search() { - Beans.copy(keyMatchForm.searchParams, keyMatchPager) - .excludes(CommonConstants.PAGER_CONVERSION_RULE) + Beans.copy(keyMatchForm.searchParams, keyMatchPager).excludes(CommonConstants.PAGER_CONVERSION_RULE) - .execute(); + .execute(); return displayList(false); } @@ -131,9 +128,8 @@ public class BsKeyMatchAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "confirmpage/{crudMode}/{id}") public String confirmpage() { if (keyMatchForm.crudMode != CommonConstants.CONFIRM_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.CONFIRM_MODE, - keyMatchForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE, + keyMatchForm.crudMode }); } loadKeyMatch(); @@ -155,9 +151,7 @@ public class BsKeyMatchAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "editpage/{crudMode}/{id}") public String editpage() { if (keyMatchForm.crudMode != CommonConstants.EDIT_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.EDIT_MODE, - keyMatchForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE, keyMatchForm.crudMode }); } loadKeyMatch(); @@ -192,8 +186,7 @@ public class BsKeyMatchAction implements Serializable { public String deletepage() { if (keyMatchForm.crudMode != CommonConstants.DELETE_MODE) { throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - keyMatchForm.crudMode }); + new Object[] { CommonConstants.DELETE_MODE, keyMatchForm.crudMode }); } loadKeyMatch(); @@ -228,8 +221,7 @@ public class BsKeyMatchAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_create_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_create_crud_table"); } } @@ -250,8 +242,7 @@ public class BsKeyMatchAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_update_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_update_crud_table"); } } @@ -260,19 +251,16 @@ public class BsKeyMatchAction implements Serializable { public String delete() { if (keyMatchForm.crudMode != CommonConstants.DELETE_MODE) { throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - keyMatchForm.crudMode }); + new Object[] { CommonConstants.DELETE_MODE, keyMatchForm.crudMode }); } try { - final KeyMatch keyMatch = keyMatchService - .getKeyMatch(createKeyMap()); + final KeyMatch keyMatch = keyMatchService.getKeyMatch(createKeyMap()); if (keyMatch == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { keyMatchForm.id }); + new Object[] { keyMatchForm.id }); } @@ -288,8 +276,7 @@ public class BsKeyMatchAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_delete_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_delete_crud_table"); } } @@ -298,10 +285,9 @@ public class BsKeyMatchAction implements Serializable { final KeyMatch keyMatch = keyMatchService.getKeyMatch(createKeyMap()); if (keyMatch == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { keyMatchForm.id }); + new Object[] { keyMatchForm.id }); } @@ -316,10 +302,9 @@ public class BsKeyMatchAction implements Serializable { keyMatch = keyMatchService.getKeyMatch(createKeyMap()); if (keyMatch == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { keyMatchForm.id }); + new Object[] { keyMatchForm.id }); } } else { diff --git a/src/main/java/org/codelibs/fess/crud/action/admin/BsLabelTypeAction.java b/src/main/java/org/codelibs/fess/crud/action/admin/BsLabelTypeAction.java index b12690684..2b46b1028 100644 --- a/src/main/java/org/codelibs/fess/crud/action/admin/BsLabelTypeAction.java +++ b/src/main/java/org/codelibs/fess/crud/action/admin/BsLabelTypeAction.java @@ -66,10 +66,9 @@ public class BsLabelTypeAction implements Serializable { labelTypeItems = labelTypeService.getLabelTypeList(labelTypePager); // restore from pager - Beans.copy(labelTypePager, labelTypeForm.searchParams) - .excludes(CommonConstants.PAGER_CONVERSION_RULE) + Beans.copy(labelTypePager, labelTypeForm.searchParams).excludes(CommonConstants.PAGER_CONVERSION_RULE) - .execute(); + .execute(); if (redirect) { return "index?redirect=true"; @@ -88,8 +87,7 @@ public class BsLabelTypeAction implements Serializable { // page navi if (StringUtil.isNotBlank(labelTypeForm.pageNumber)) { try { - labelTypePager.setCurrentPageNumber(Integer - .parseInt(labelTypeForm.pageNumber)); + labelTypePager.setCurrentPageNumber(Integer.parseInt(labelTypeForm.pageNumber)); } catch (final NumberFormatException e) { if (log.isDebugEnabled()) { log.debug("Invalid value: " + labelTypeForm.pageNumber, e); @@ -102,10 +100,9 @@ public class BsLabelTypeAction implements Serializable { @Execute(validator = false, input = "error.jsp") public String search() { - Beans.copy(labelTypeForm.searchParams, labelTypePager) - .excludes(CommonConstants.PAGER_CONVERSION_RULE) + Beans.copy(labelTypeForm.searchParams, labelTypePager).excludes(CommonConstants.PAGER_CONVERSION_RULE) - .execute(); + .execute(); return displayList(false); } @@ -131,9 +128,8 @@ public class BsLabelTypeAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "confirmpage/{crudMode}/{id}") public String confirmpage() { if (labelTypeForm.crudMode != CommonConstants.CONFIRM_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.CONFIRM_MODE, - labelTypeForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE, + labelTypeForm.crudMode }); } loadLabelType(); @@ -156,8 +152,7 @@ public class BsLabelTypeAction implements Serializable { public String editpage() { if (labelTypeForm.crudMode != CommonConstants.EDIT_MODE) { throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.EDIT_MODE, - labelTypeForm.crudMode }); + new Object[] { CommonConstants.EDIT_MODE, labelTypeForm.crudMode }); } loadLabelType(); @@ -191,9 +186,8 @@ public class BsLabelTypeAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "deletepage/{crudMode}/{id}") public String deletepage() { if (labelTypeForm.crudMode != CommonConstants.DELETE_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - labelTypeForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, + labelTypeForm.crudMode }); } loadLabelType(); @@ -228,8 +222,7 @@ public class BsLabelTypeAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_create_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_create_crud_table"); } } @@ -250,8 +243,7 @@ public class BsLabelTypeAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_update_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_update_crud_table"); } } @@ -259,20 +251,17 @@ public class BsLabelTypeAction implements Serializable { @Execute(validator = false, input = "error.jsp") public String delete() { if (labelTypeForm.crudMode != CommonConstants.DELETE_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - labelTypeForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, + labelTypeForm.crudMode }); } try { - final LabelType labelType = labelTypeService - .getLabelType(createKeyMap()); + final LabelType labelType = labelTypeService.getLabelType(createKeyMap()); if (labelType == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { labelTypeForm.id }); + new Object[] { labelTypeForm.id }); } @@ -288,21 +277,18 @@ public class BsLabelTypeAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_delete_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_delete_crud_table"); } } protected void loadLabelType() { - final LabelType labelType = labelTypeService - .getLabelType(createKeyMap()); + final LabelType labelType = labelTypeService.getLabelType(createKeyMap()); if (labelType == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { labelTypeForm.id }); + new Object[] { labelTypeForm.id }); } @@ -317,10 +303,9 @@ public class BsLabelTypeAction implements Serializable { labelType = labelTypeService.getLabelType(createKeyMap()); if (labelType == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { labelTypeForm.id }); + new Object[] { labelTypeForm.id }); } } else { diff --git a/src/main/java/org/codelibs/fess/crud/action/admin/BsOverlappingHostAction.java b/src/main/java/org/codelibs/fess/crud/action/admin/BsOverlappingHostAction.java index aabf808b4..fb9a70e5a 100644 --- a/src/main/java/org/codelibs/fess/crud/action/admin/BsOverlappingHostAction.java +++ b/src/main/java/org/codelibs/fess/crud/action/admin/BsOverlappingHostAction.java @@ -43,8 +43,7 @@ public class BsOverlappingHostAction implements Serializable { private static final long serialVersionUID = 1L; - private static final Log log = LogFactory - .getLog(BsOverlappingHostAction.class); + private static final Log log = LogFactory.getLog(BsOverlappingHostAction.class); // for list @@ -64,14 +63,12 @@ public class BsOverlappingHostAction implements Serializable { protected String displayList(final boolean redirect) { // page navi - overlappingHostItems = overlappingHostService - .getOverlappingHostList(overlappingHostPager); + overlappingHostItems = overlappingHostService.getOverlappingHostList(overlappingHostPager); // restore from pager - Beans.copy(overlappingHostPager, overlappingHostForm.searchParams) - .excludes(CommonConstants.PAGER_CONVERSION_RULE) + Beans.copy(overlappingHostPager, overlappingHostForm.searchParams).excludes(CommonConstants.PAGER_CONVERSION_RULE) - .execute(); + .execute(); if (redirect) { return "index?redirect=true"; @@ -90,12 +87,10 @@ public class BsOverlappingHostAction implements Serializable { // page navi if (StringUtil.isNotBlank(overlappingHostForm.pageNumber)) { try { - overlappingHostPager.setCurrentPageNumber(Integer - .parseInt(overlappingHostForm.pageNumber)); + overlappingHostPager.setCurrentPageNumber(Integer.parseInt(overlappingHostForm.pageNumber)); } catch (final NumberFormatException e) { if (log.isDebugEnabled()) { - log.debug("Invalid value: " - + overlappingHostForm.pageNumber, e); + log.debug("Invalid value: " + overlappingHostForm.pageNumber, e); } } } @@ -105,10 +100,9 @@ public class BsOverlappingHostAction implements Serializable { @Execute(validator = false, input = "error.jsp") public String search() { - Beans.copy(overlappingHostForm.searchParams, overlappingHostPager) - .excludes(CommonConstants.PAGER_CONVERSION_RULE) + Beans.copy(overlappingHostForm.searchParams, overlappingHostPager).excludes(CommonConstants.PAGER_CONVERSION_RULE) - .execute(); + .execute(); return displayList(false); } @@ -134,9 +128,8 @@ public class BsOverlappingHostAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "confirmpage/{crudMode}/{id}") public String confirmpage() { if (overlappingHostForm.crudMode != CommonConstants.CONFIRM_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.CONFIRM_MODE, - overlappingHostForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE, + overlappingHostForm.crudMode }); } loadOverlappingHost(); @@ -158,9 +151,8 @@ public class BsOverlappingHostAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "editpage/{crudMode}/{id}") public String editpage() { if (overlappingHostForm.crudMode != CommonConstants.EDIT_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.EDIT_MODE, - overlappingHostForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE, + overlappingHostForm.crudMode }); } loadOverlappingHost(); @@ -194,9 +186,8 @@ public class BsOverlappingHostAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "deletepage/{crudMode}/{id}") public String deletepage() { if (overlappingHostForm.crudMode != CommonConstants.DELETE_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - overlappingHostForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, + overlappingHostForm.crudMode }); } loadOverlappingHost(); @@ -231,8 +222,7 @@ public class BsOverlappingHostAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_create_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_create_crud_table"); } } @@ -253,8 +243,7 @@ public class BsOverlappingHostAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_update_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_update_crud_table"); } } @@ -262,20 +251,17 @@ public class BsOverlappingHostAction implements Serializable { @Execute(validator = false, input = "error.jsp") public String delete() { if (overlappingHostForm.crudMode != CommonConstants.DELETE_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - overlappingHostForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, + overlappingHostForm.crudMode }); } try { - final OverlappingHost overlappingHost = overlappingHostService - .getOverlappingHost(createKeyMap()); + final OverlappingHost overlappingHost = overlappingHostService.getOverlappingHost(createKeyMap()); if (overlappingHost == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { overlappingHostForm.id }); + new Object[] { overlappingHostForm.id }); } @@ -291,50 +277,43 @@ public class BsOverlappingHostAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_delete_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_delete_crud_table"); } } protected void loadOverlappingHost() { - final OverlappingHost overlappingHost = overlappingHostService - .getOverlappingHost(createKeyMap()); + final OverlappingHost overlappingHost = overlappingHostService.getOverlappingHost(createKeyMap()); if (overlappingHost == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { overlappingHostForm.id }); + new Object[] { overlappingHostForm.id }); } - Beans.copy(overlappingHost, overlappingHostForm) - .excludes("searchParams", "mode") + Beans.copy(overlappingHost, overlappingHostForm).excludes("searchParams", "mode") - .execute(); + .execute(); } protected OverlappingHost createOverlappingHost() { OverlappingHost overlappingHost; if (overlappingHostForm.crudMode == CommonConstants.EDIT_MODE) { - overlappingHost = overlappingHostService - .getOverlappingHost(createKeyMap()); + overlappingHost = overlappingHostService.getOverlappingHost(createKeyMap()); if (overlappingHost == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { overlappingHostForm.id }); + new Object[] { overlappingHostForm.id }); } } else { overlappingHost = new OverlappingHost(); } - Beans.copy(overlappingHostForm, overlappingHost) - .excludes("searchParams", "mode") + Beans.copy(overlappingHostForm, overlappingHost).excludes("searchParams", "mode") - .execute(); + .execute(); return overlappingHost; } diff --git a/src/main/java/org/codelibs/fess/crud/action/admin/BsPathMappingAction.java b/src/main/java/org/codelibs/fess/crud/action/admin/BsPathMappingAction.java index 2599f4543..5fc6eb339 100644 --- a/src/main/java/org/codelibs/fess/crud/action/admin/BsPathMappingAction.java +++ b/src/main/java/org/codelibs/fess/crud/action/admin/BsPathMappingAction.java @@ -63,14 +63,12 @@ public class BsPathMappingAction implements Serializable { protected String displayList(final boolean redirect) { // page navi - pathMappingItems = pathMappingService - .getPathMappingList(pathMappingPager); + pathMappingItems = pathMappingService.getPathMappingList(pathMappingPager); // restore from pager - Beans.copy(pathMappingPager, pathMappingForm.searchParams) - .excludes(CommonConstants.PAGER_CONVERSION_RULE) + Beans.copy(pathMappingPager, pathMappingForm.searchParams).excludes(CommonConstants.PAGER_CONVERSION_RULE) - .execute(); + .execute(); if (redirect) { return "index?redirect=true"; @@ -89,8 +87,7 @@ public class BsPathMappingAction implements Serializable { // page navi if (StringUtil.isNotBlank(pathMappingForm.pageNumber)) { try { - pathMappingPager.setCurrentPageNumber(Integer - .parseInt(pathMappingForm.pageNumber)); + pathMappingPager.setCurrentPageNumber(Integer.parseInt(pathMappingForm.pageNumber)); } catch (final NumberFormatException e) { if (log.isDebugEnabled()) { log.debug("Invalid value: " + pathMappingForm.pageNumber, e); @@ -103,10 +100,9 @@ public class BsPathMappingAction implements Serializable { @Execute(validator = false, input = "error.jsp") public String search() { - Beans.copy(pathMappingForm.searchParams, pathMappingPager) - .excludes(CommonConstants.PAGER_CONVERSION_RULE) + Beans.copy(pathMappingForm.searchParams, pathMappingPager).excludes(CommonConstants.PAGER_CONVERSION_RULE) - .execute(); + .execute(); return displayList(false); } @@ -132,9 +128,8 @@ public class BsPathMappingAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "confirmpage/{crudMode}/{id}") public String confirmpage() { if (pathMappingForm.crudMode != CommonConstants.CONFIRM_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.CONFIRM_MODE, - pathMappingForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE, + pathMappingForm.crudMode }); } loadPathMapping(); @@ -156,9 +151,8 @@ public class BsPathMappingAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "editpage/{crudMode}/{id}") public String editpage() { if (pathMappingForm.crudMode != CommonConstants.EDIT_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.EDIT_MODE, - pathMappingForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE, + pathMappingForm.crudMode }); } loadPathMapping(); @@ -192,9 +186,8 @@ public class BsPathMappingAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "deletepage/{crudMode}/{id}") public String deletepage() { if (pathMappingForm.crudMode != CommonConstants.DELETE_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - pathMappingForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, + pathMappingForm.crudMode }); } loadPathMapping(); @@ -229,8 +222,7 @@ public class BsPathMappingAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_create_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_create_crud_table"); } } @@ -251,8 +243,7 @@ public class BsPathMappingAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_update_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_update_crud_table"); } } @@ -260,20 +251,17 @@ public class BsPathMappingAction implements Serializable { @Execute(validator = false, input = "error.jsp") public String delete() { if (pathMappingForm.crudMode != CommonConstants.DELETE_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - pathMappingForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, + pathMappingForm.crudMode }); } try { - final PathMapping pathMapping = pathMappingService - .getPathMapping(createKeyMap()); + final PathMapping pathMapping = pathMappingService.getPathMapping(createKeyMap()); if (pathMapping == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { pathMappingForm.id }); + new Object[] { pathMappingForm.id }); } @@ -289,28 +277,24 @@ public class BsPathMappingAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_delete_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_delete_crud_table"); } } protected void loadPathMapping() { - final PathMapping pathMapping = pathMappingService - .getPathMapping(createKeyMap()); + final PathMapping pathMapping = pathMappingService.getPathMapping(createKeyMap()); if (pathMapping == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { pathMappingForm.id }); + new Object[] { pathMappingForm.id }); } - Beans.copy(pathMapping, pathMappingForm) - .excludes("searchParams", "mode") + Beans.copy(pathMapping, pathMappingForm).excludes("searchParams", "mode") - .execute(); + .execute(); } protected PathMapping createPathMapping() { @@ -319,19 +303,17 @@ public class BsPathMappingAction implements Serializable { pathMapping = pathMappingService.getPathMapping(createKeyMap()); if (pathMapping == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { pathMappingForm.id }); + new Object[] { pathMappingForm.id }); } } else { pathMapping = new PathMapping(); } - Beans.copy(pathMappingForm, pathMapping) - .excludes("searchParams", "mode") + Beans.copy(pathMappingForm, pathMapping).excludes("searchParams", "mode") - .execute(); + .execute(); return pathMapping; } diff --git a/src/main/java/org/codelibs/fess/crud/action/admin/BsRequestHeaderAction.java b/src/main/java/org/codelibs/fess/crud/action/admin/BsRequestHeaderAction.java index a5f0a5128..ebfe0961a 100644 --- a/src/main/java/org/codelibs/fess/crud/action/admin/BsRequestHeaderAction.java +++ b/src/main/java/org/codelibs/fess/crud/action/admin/BsRequestHeaderAction.java @@ -43,8 +43,7 @@ public class BsRequestHeaderAction implements Serializable { private static final long serialVersionUID = 1L; - private static final Log log = LogFactory - .getLog(BsRequestHeaderAction.class); + private static final Log log = LogFactory.getLog(BsRequestHeaderAction.class); // for list @@ -64,14 +63,12 @@ public class BsRequestHeaderAction implements Serializable { protected String displayList(final boolean redirect) { // page navi - requestHeaderItems = requestHeaderService - .getRequestHeaderList(requestHeaderPager); + requestHeaderItems = requestHeaderService.getRequestHeaderList(requestHeaderPager); // restore from pager - Beans.copy(requestHeaderPager, requestHeaderForm.searchParams) - .excludes(CommonConstants.PAGER_CONVERSION_RULE) + Beans.copy(requestHeaderPager, requestHeaderForm.searchParams).excludes(CommonConstants.PAGER_CONVERSION_RULE) - .execute(); + .execute(); if (redirect) { return "index?redirect=true"; @@ -90,12 +87,10 @@ public class BsRequestHeaderAction implements Serializable { // page navi if (StringUtil.isNotBlank(requestHeaderForm.pageNumber)) { try { - requestHeaderPager.setCurrentPageNumber(Integer - .parseInt(requestHeaderForm.pageNumber)); + requestHeaderPager.setCurrentPageNumber(Integer.parseInt(requestHeaderForm.pageNumber)); } catch (final NumberFormatException e) { if (log.isDebugEnabled()) { - log.debug("Invalid value: " + requestHeaderForm.pageNumber, - e); + log.debug("Invalid value: " + requestHeaderForm.pageNumber, e); } } } @@ -105,10 +100,9 @@ public class BsRequestHeaderAction implements Serializable { @Execute(validator = false, input = "error.jsp") public String search() { - Beans.copy(requestHeaderForm.searchParams, requestHeaderPager) - .excludes(CommonConstants.PAGER_CONVERSION_RULE) + Beans.copy(requestHeaderForm.searchParams, requestHeaderPager).excludes(CommonConstants.PAGER_CONVERSION_RULE) - .execute(); + .execute(); return displayList(false); } @@ -134,9 +128,8 @@ public class BsRequestHeaderAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "confirmpage/{crudMode}/{id}") public String confirmpage() { if (requestHeaderForm.crudMode != CommonConstants.CONFIRM_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.CONFIRM_MODE, - requestHeaderForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE, + requestHeaderForm.crudMode }); } loadRequestHeader(); @@ -158,9 +151,8 @@ public class BsRequestHeaderAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "editpage/{crudMode}/{id}") public String editpage() { if (requestHeaderForm.crudMode != CommonConstants.EDIT_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.EDIT_MODE, - requestHeaderForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE, + requestHeaderForm.crudMode }); } loadRequestHeader(); @@ -194,9 +186,8 @@ public class BsRequestHeaderAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "deletepage/{crudMode}/{id}") public String deletepage() { if (requestHeaderForm.crudMode != CommonConstants.DELETE_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - requestHeaderForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, + requestHeaderForm.crudMode }); } loadRequestHeader(); @@ -231,8 +222,7 @@ public class BsRequestHeaderAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_create_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_create_crud_table"); } } @@ -253,8 +243,7 @@ public class BsRequestHeaderAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_update_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_update_crud_table"); } } @@ -262,20 +251,17 @@ public class BsRequestHeaderAction implements Serializable { @Execute(validator = false, input = "error.jsp") public String delete() { if (requestHeaderForm.crudMode != CommonConstants.DELETE_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - requestHeaderForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, + requestHeaderForm.crudMode }); } try { - final RequestHeader requestHeader = requestHeaderService - .getRequestHeader(createKeyMap()); + final RequestHeader requestHeader = requestHeaderService.getRequestHeader(createKeyMap()); if (requestHeader == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { requestHeaderForm.id }); + new Object[] { requestHeaderForm.id }); } @@ -291,50 +277,43 @@ public class BsRequestHeaderAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_delete_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_delete_crud_table"); } } protected void loadRequestHeader() { - final RequestHeader requestHeader = requestHeaderService - .getRequestHeader(createKeyMap()); + final RequestHeader requestHeader = requestHeaderService.getRequestHeader(createKeyMap()); if (requestHeader == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { requestHeaderForm.id }); + new Object[] { requestHeaderForm.id }); } - Beans.copy(requestHeader, requestHeaderForm) - .excludes("searchParams", "mode") + Beans.copy(requestHeader, requestHeaderForm).excludes("searchParams", "mode") - .execute(); + .execute(); } protected RequestHeader createRequestHeader() { RequestHeader requestHeader; if (requestHeaderForm.crudMode == CommonConstants.EDIT_MODE) { - requestHeader = requestHeaderService - .getRequestHeader(createKeyMap()); + requestHeader = requestHeaderService.getRequestHeader(createKeyMap()); if (requestHeader == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { requestHeaderForm.id }); + new Object[] { requestHeaderForm.id }); } } else { requestHeader = new RequestHeader(); } - Beans.copy(requestHeaderForm, requestHeader) - .excludes("searchParams", "mode") + Beans.copy(requestHeaderForm, requestHeader).excludes("searchParams", "mode") - .execute(); + .execute(); return requestHeader; } diff --git a/src/main/java/org/codelibs/fess/crud/action/admin/BsRoleTypeAction.java b/src/main/java/org/codelibs/fess/crud/action/admin/BsRoleTypeAction.java index dda93edbc..682cc600c 100644 --- a/src/main/java/org/codelibs/fess/crud/action/admin/BsRoleTypeAction.java +++ b/src/main/java/org/codelibs/fess/crud/action/admin/BsRoleTypeAction.java @@ -66,10 +66,9 @@ public class BsRoleTypeAction implements Serializable { roleTypeItems = roleTypeService.getRoleTypeList(roleTypePager); // restore from pager - Beans.copy(roleTypePager, roleTypeForm.searchParams) - .excludes(CommonConstants.PAGER_CONVERSION_RULE) + Beans.copy(roleTypePager, roleTypeForm.searchParams).excludes(CommonConstants.PAGER_CONVERSION_RULE) - .execute(); + .execute(); if (redirect) { return "index?redirect=true"; @@ -88,8 +87,7 @@ public class BsRoleTypeAction implements Serializable { // page navi if (StringUtil.isNotBlank(roleTypeForm.pageNumber)) { try { - roleTypePager.setCurrentPageNumber(Integer - .parseInt(roleTypeForm.pageNumber)); + roleTypePager.setCurrentPageNumber(Integer.parseInt(roleTypeForm.pageNumber)); } catch (final NumberFormatException e) { if (log.isDebugEnabled()) { log.debug("Invalid value: " + roleTypeForm.pageNumber, e); @@ -102,10 +100,9 @@ public class BsRoleTypeAction implements Serializable { @Execute(validator = false, input = "error.jsp") public String search() { - Beans.copy(roleTypeForm.searchParams, roleTypePager) - .excludes(CommonConstants.PAGER_CONVERSION_RULE) + Beans.copy(roleTypeForm.searchParams, roleTypePager).excludes(CommonConstants.PAGER_CONVERSION_RULE) - .execute(); + .execute(); return displayList(false); } @@ -131,9 +128,8 @@ public class BsRoleTypeAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "confirmpage/{crudMode}/{id}") public String confirmpage() { if (roleTypeForm.crudMode != CommonConstants.CONFIRM_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.CONFIRM_MODE, - roleTypeForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE, + roleTypeForm.crudMode }); } loadRoleType(); @@ -155,9 +151,7 @@ public class BsRoleTypeAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "editpage/{crudMode}/{id}") public String editpage() { if (roleTypeForm.crudMode != CommonConstants.EDIT_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.EDIT_MODE, - roleTypeForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE, roleTypeForm.crudMode }); } loadRoleType(); @@ -192,8 +186,7 @@ public class BsRoleTypeAction implements Serializable { public String deletepage() { if (roleTypeForm.crudMode != CommonConstants.DELETE_MODE) { throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - roleTypeForm.crudMode }); + new Object[] { CommonConstants.DELETE_MODE, roleTypeForm.crudMode }); } loadRoleType(); @@ -228,8 +221,7 @@ public class BsRoleTypeAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_create_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_create_crud_table"); } } @@ -250,8 +242,7 @@ public class BsRoleTypeAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_update_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_update_crud_table"); } } @@ -260,19 +251,16 @@ public class BsRoleTypeAction implements Serializable { public String delete() { if (roleTypeForm.crudMode != CommonConstants.DELETE_MODE) { throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - roleTypeForm.crudMode }); + new Object[] { CommonConstants.DELETE_MODE, roleTypeForm.crudMode }); } try { - final RoleType roleType = roleTypeService - .getRoleType(createKeyMap()); + final RoleType roleType = roleTypeService.getRoleType(createKeyMap()); if (roleType == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { roleTypeForm.id }); + new Object[] { roleTypeForm.id }); } @@ -288,8 +276,7 @@ public class BsRoleTypeAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_delete_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_delete_crud_table"); } } @@ -298,10 +285,9 @@ public class BsRoleTypeAction implements Serializable { final RoleType roleType = roleTypeService.getRoleType(createKeyMap()); if (roleType == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { roleTypeForm.id }); + new Object[] { roleTypeForm.id }); } @@ -316,10 +302,9 @@ public class BsRoleTypeAction implements Serializable { roleType = roleTypeService.getRoleType(createKeyMap()); if (roleType == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { roleTypeForm.id }); + new Object[] { roleTypeForm.id }); } } else { diff --git a/src/main/java/org/codelibs/fess/crud/action/admin/BsScheduledJobAction.java b/src/main/java/org/codelibs/fess/crud/action/admin/BsScheduledJobAction.java index d89d914f6..75e4e880e 100644 --- a/src/main/java/org/codelibs/fess/crud/action/admin/BsScheduledJobAction.java +++ b/src/main/java/org/codelibs/fess/crud/action/admin/BsScheduledJobAction.java @@ -43,8 +43,7 @@ public class BsScheduledJobAction implements Serializable { private static final long serialVersionUID = 1L; - private static final Log log = LogFactory - .getLog(BsScheduledJobAction.class); + private static final Log log = LogFactory.getLog(BsScheduledJobAction.class); // for list @@ -64,14 +63,12 @@ public class BsScheduledJobAction implements Serializable { protected String displayList(final boolean redirect) { // page navi - scheduledJobItems = scheduledJobService - .getScheduledJobList(scheduledJobPager); + scheduledJobItems = scheduledJobService.getScheduledJobList(scheduledJobPager); // restore from pager - Beans.copy(scheduledJobPager, scheduledJobForm.searchParams) - .excludes(CommonConstants.PAGER_CONVERSION_RULE) + Beans.copy(scheduledJobPager, scheduledJobForm.searchParams).excludes(CommonConstants.PAGER_CONVERSION_RULE) - .execute(); + .execute(); if (redirect) { return "index?redirect=true"; @@ -90,12 +87,10 @@ public class BsScheduledJobAction implements Serializable { // page navi if (StringUtil.isNotBlank(scheduledJobForm.pageNumber)) { try { - scheduledJobPager.setCurrentPageNumber(Integer - .parseInt(scheduledJobForm.pageNumber)); + scheduledJobPager.setCurrentPageNumber(Integer.parseInt(scheduledJobForm.pageNumber)); } catch (final NumberFormatException e) { if (log.isDebugEnabled()) { - log.debug("Invalid value: " + scheduledJobForm.pageNumber, - e); + log.debug("Invalid value: " + scheduledJobForm.pageNumber, e); } } } @@ -105,10 +100,9 @@ public class BsScheduledJobAction implements Serializable { @Execute(validator = false, input = "error.jsp") public String search() { - Beans.copy(scheduledJobForm.searchParams, scheduledJobPager) - .excludes(CommonConstants.PAGER_CONVERSION_RULE) + Beans.copy(scheduledJobForm.searchParams, scheduledJobPager).excludes(CommonConstants.PAGER_CONVERSION_RULE) - .execute(); + .execute(); return displayList(false); } @@ -134,9 +128,8 @@ public class BsScheduledJobAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "confirmpage/{crudMode}/{id}") public String confirmpage() { if (scheduledJobForm.crudMode != CommonConstants.CONFIRM_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.CONFIRM_MODE, - scheduledJobForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE, + scheduledJobForm.crudMode }); } loadScheduledJob(); @@ -158,9 +151,8 @@ public class BsScheduledJobAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "editpage/{crudMode}/{id}") public String editpage() { if (scheduledJobForm.crudMode != CommonConstants.EDIT_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.EDIT_MODE, - scheduledJobForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE, + scheduledJobForm.crudMode }); } loadScheduledJob(); @@ -194,9 +186,8 @@ public class BsScheduledJobAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "deletepage/{crudMode}/{id}") public String deletepage() { if (scheduledJobForm.crudMode != CommonConstants.DELETE_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - scheduledJobForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, + scheduledJobForm.crudMode }); } loadScheduledJob(); @@ -231,8 +222,7 @@ public class BsScheduledJobAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_create_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_create_crud_table"); } } @@ -253,8 +243,7 @@ public class BsScheduledJobAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_update_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_update_crud_table"); } } @@ -262,20 +251,17 @@ public class BsScheduledJobAction implements Serializable { @Execute(validator = false, input = "error.jsp") public String delete() { if (scheduledJobForm.crudMode != CommonConstants.DELETE_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - scheduledJobForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, + scheduledJobForm.crudMode }); } try { - final ScheduledJob scheduledJob = scheduledJobService - .getScheduledJob(createKeyMap()); + final ScheduledJob scheduledJob = scheduledJobService.getScheduledJob(createKeyMap()); if (scheduledJob == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { scheduledJobForm.id }); + new Object[] { scheduledJobForm.id }); } @@ -291,28 +277,24 @@ public class BsScheduledJobAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_delete_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_delete_crud_table"); } } protected void loadScheduledJob() { - final ScheduledJob scheduledJob = scheduledJobService - .getScheduledJob(createKeyMap()); + final ScheduledJob scheduledJob = scheduledJobService.getScheduledJob(createKeyMap()); if (scheduledJob == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { scheduledJobForm.id }); + new Object[] { scheduledJobForm.id }); } - Beans.copy(scheduledJob, scheduledJobForm) - .excludes("searchParams", "mode") + Beans.copy(scheduledJob, scheduledJobForm).excludes("searchParams", "mode") - .execute(); + .execute(); } protected ScheduledJob createScheduledJob() { @@ -321,19 +303,17 @@ public class BsScheduledJobAction implements Serializable { scheduledJob = scheduledJobService.getScheduledJob(createKeyMap()); if (scheduledJob == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { scheduledJobForm.id }); + new Object[] { scheduledJobForm.id }); } } else { scheduledJob = new ScheduledJob(); } - Beans.copy(scheduledJobForm, scheduledJob) - .excludes("searchParams", "mode") + Beans.copy(scheduledJobForm, scheduledJob).excludes("searchParams", "mode") - .execute(); + .execute(); return scheduledJob; } diff --git a/src/main/java/org/codelibs/fess/crud/action/admin/BsSearchLogAction.java b/src/main/java/org/codelibs/fess/crud/action/admin/BsSearchLogAction.java index 84cbbd743..7790eb00e 100644 --- a/src/main/java/org/codelibs/fess/crud/action/admin/BsSearchLogAction.java +++ b/src/main/java/org/codelibs/fess/crud/action/admin/BsSearchLogAction.java @@ -66,10 +66,9 @@ public class BsSearchLogAction implements Serializable { searchLogItems = searchLogService.getSearchLogList(searchLogPager); // restore from pager - Beans.copy(searchLogPager, searchLogForm.searchParams) - .excludes(CommonConstants.PAGER_CONVERSION_RULE) + Beans.copy(searchLogPager, searchLogForm.searchParams).excludes(CommonConstants.PAGER_CONVERSION_RULE) - .execute(); + .execute(); if (redirect) { return "index?redirect=true"; @@ -88,8 +87,7 @@ public class BsSearchLogAction implements Serializable { // page navi if (StringUtil.isNotBlank(searchLogForm.pageNumber)) { try { - searchLogPager.setCurrentPageNumber(Integer - .parseInt(searchLogForm.pageNumber)); + searchLogPager.setCurrentPageNumber(Integer.parseInt(searchLogForm.pageNumber)); } catch (final NumberFormatException e) { if (log.isDebugEnabled()) { log.debug("Invalid value: " + searchLogForm.pageNumber, e); @@ -102,10 +100,9 @@ public class BsSearchLogAction implements Serializable { @Execute(validator = false, input = "error.jsp") public String search() { - Beans.copy(searchLogForm.searchParams, searchLogPager) - .excludes(CommonConstants.PAGER_CONVERSION_RULE) + Beans.copy(searchLogForm.searchParams, searchLogPager).excludes(CommonConstants.PAGER_CONVERSION_RULE) - .execute(); + .execute(); return displayList(false); } @@ -131,9 +128,8 @@ public class BsSearchLogAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "confirmpage/{crudMode}/{id}") public String confirmpage() { if (searchLogForm.crudMode != CommonConstants.CONFIRM_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.CONFIRM_MODE, - searchLogForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE, + searchLogForm.crudMode }); } loadSearchLog(); @@ -156,8 +152,7 @@ public class BsSearchLogAction implements Serializable { public String editpage() { if (searchLogForm.crudMode != CommonConstants.EDIT_MODE) { throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.EDIT_MODE, - searchLogForm.crudMode }); + new Object[] { CommonConstants.EDIT_MODE, searchLogForm.crudMode }); } loadSearchLog(); @@ -191,9 +186,8 @@ public class BsSearchLogAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "deletepage/{crudMode}/{id}") public String deletepage() { if (searchLogForm.crudMode != CommonConstants.DELETE_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - searchLogForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, + searchLogForm.crudMode }); } loadSearchLog(); @@ -228,8 +222,7 @@ public class BsSearchLogAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_create_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_create_crud_table"); } } @@ -250,8 +243,7 @@ public class BsSearchLogAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_update_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_update_crud_table"); } } @@ -259,20 +251,17 @@ public class BsSearchLogAction implements Serializable { @Execute(validator = false, input = "error.jsp") public String delete() { if (searchLogForm.crudMode != CommonConstants.DELETE_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - searchLogForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, + searchLogForm.crudMode }); } try { - final SearchLog searchLog = searchLogService - .getSearchLog(createKeyMap()); + final SearchLog searchLog = searchLogService.getSearchLog(createKeyMap()); if (searchLog == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { searchLogForm.id }); + new Object[] { searchLogForm.id }); } @@ -288,21 +277,18 @@ public class BsSearchLogAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_delete_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_delete_crud_table"); } } protected void loadSearchLog() { - final SearchLog searchLog = searchLogService - .getSearchLog(createKeyMap()); + final SearchLog searchLog = searchLogService.getSearchLog(createKeyMap()); if (searchLog == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { searchLogForm.id }); + new Object[] { searchLogForm.id }); } @@ -317,10 +303,9 @@ public class BsSearchLogAction implements Serializable { searchLog = searchLogService.getSearchLog(createKeyMap()); if (searchLog == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { searchLogForm.id }); + new Object[] { searchLogForm.id }); } } else { diff --git a/src/main/java/org/codelibs/fess/crud/action/admin/BsSuggestBadWordAction.java b/src/main/java/org/codelibs/fess/crud/action/admin/BsSuggestBadWordAction.java index 9e9b8ff9e..650621437 100644 --- a/src/main/java/org/codelibs/fess/crud/action/admin/BsSuggestBadWordAction.java +++ b/src/main/java/org/codelibs/fess/crud/action/admin/BsSuggestBadWordAction.java @@ -43,8 +43,7 @@ public class BsSuggestBadWordAction implements Serializable { private static final long serialVersionUID = 1L; - private static final Log log = LogFactory - .getLog(BsSuggestBadWordAction.class); + private static final Log log = LogFactory.getLog(BsSuggestBadWordAction.class); // for list @@ -64,14 +63,12 @@ public class BsSuggestBadWordAction implements Serializable { protected String displayList(final boolean redirect) { // page navi - suggestBadWordItems = suggestBadWordService - .getSuggestBadWordList(suggestBadWordPager); + suggestBadWordItems = suggestBadWordService.getSuggestBadWordList(suggestBadWordPager); // restore from pager - Beans.copy(suggestBadWordPager, suggestBadWordForm.searchParams) - .excludes(CommonConstants.PAGER_CONVERSION_RULE) + Beans.copy(suggestBadWordPager, suggestBadWordForm.searchParams).excludes(CommonConstants.PAGER_CONVERSION_RULE) - .execute(); + .execute(); if (redirect) { return "index?redirect=true"; @@ -90,13 +87,10 @@ public class BsSuggestBadWordAction implements Serializable { // page navi if (StringUtil.isNotBlank(suggestBadWordForm.pageNumber)) { try { - suggestBadWordPager.setCurrentPageNumber(Integer - .parseInt(suggestBadWordForm.pageNumber)); + suggestBadWordPager.setCurrentPageNumber(Integer.parseInt(suggestBadWordForm.pageNumber)); } catch (final NumberFormatException e) { if (log.isDebugEnabled()) { - log.debug( - "Invalid value: " + suggestBadWordForm.pageNumber, - e); + log.debug("Invalid value: " + suggestBadWordForm.pageNumber, e); } } } @@ -106,10 +100,9 @@ public class BsSuggestBadWordAction implements Serializable { @Execute(validator = false, input = "error.jsp") public String search() { - Beans.copy(suggestBadWordForm.searchParams, suggestBadWordPager) - .excludes(CommonConstants.PAGER_CONVERSION_RULE) + Beans.copy(suggestBadWordForm.searchParams, suggestBadWordPager).excludes(CommonConstants.PAGER_CONVERSION_RULE) - .execute(); + .execute(); return displayList(false); } @@ -135,9 +128,8 @@ public class BsSuggestBadWordAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "confirmpage/{crudMode}/{id}") public String confirmpage() { if (suggestBadWordForm.crudMode != CommonConstants.CONFIRM_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.CONFIRM_MODE, - suggestBadWordForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE, + suggestBadWordForm.crudMode }); } loadSuggestBadWord(); @@ -159,9 +151,8 @@ public class BsSuggestBadWordAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "editpage/{crudMode}/{id}") public String editpage() { if (suggestBadWordForm.crudMode != CommonConstants.EDIT_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.EDIT_MODE, - suggestBadWordForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE, + suggestBadWordForm.crudMode }); } loadSuggestBadWord(); @@ -195,9 +186,8 @@ public class BsSuggestBadWordAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "deletepage/{crudMode}/{id}") public String deletepage() { if (suggestBadWordForm.crudMode != CommonConstants.DELETE_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - suggestBadWordForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, + suggestBadWordForm.crudMode }); } loadSuggestBadWord(); @@ -232,8 +222,7 @@ public class BsSuggestBadWordAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_create_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_create_crud_table"); } } @@ -254,8 +243,7 @@ public class BsSuggestBadWordAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_update_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_update_crud_table"); } } @@ -263,20 +251,17 @@ public class BsSuggestBadWordAction implements Serializable { @Execute(validator = false, input = "error.jsp") public String delete() { if (suggestBadWordForm.crudMode != CommonConstants.DELETE_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - suggestBadWordForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, + suggestBadWordForm.crudMode }); } try { - final SuggestBadWord suggestBadWord = suggestBadWordService - .getSuggestBadWord(createKeyMap()); + final SuggestBadWord suggestBadWord = suggestBadWordService.getSuggestBadWord(createKeyMap()); if (suggestBadWord == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { suggestBadWordForm.id }); + new Object[] { suggestBadWordForm.id }); } @@ -292,50 +277,43 @@ public class BsSuggestBadWordAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_delete_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_delete_crud_table"); } } protected void loadSuggestBadWord() { - final SuggestBadWord suggestBadWord = suggestBadWordService - .getSuggestBadWord(createKeyMap()); + final SuggestBadWord suggestBadWord = suggestBadWordService.getSuggestBadWord(createKeyMap()); if (suggestBadWord == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { suggestBadWordForm.id }); + new Object[] { suggestBadWordForm.id }); } - Beans.copy(suggestBadWord, suggestBadWordForm) - .excludes("searchParams", "mode") + Beans.copy(suggestBadWord, suggestBadWordForm).excludes("searchParams", "mode") - .execute(); + .execute(); } protected SuggestBadWord createSuggestBadWord() { SuggestBadWord suggestBadWord; if (suggestBadWordForm.crudMode == CommonConstants.EDIT_MODE) { - suggestBadWord = suggestBadWordService - .getSuggestBadWord(createKeyMap()); + suggestBadWord = suggestBadWordService.getSuggestBadWord(createKeyMap()); if (suggestBadWord == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { suggestBadWordForm.id }); + new Object[] { suggestBadWordForm.id }); } } else { suggestBadWord = new SuggestBadWord(); } - Beans.copy(suggestBadWordForm, suggestBadWord) - .excludes("searchParams", "mode") + Beans.copy(suggestBadWordForm, suggestBadWord).excludes("searchParams", "mode") - .execute(); + .execute(); return suggestBadWord; } diff --git a/src/main/java/org/codelibs/fess/crud/action/admin/BsSuggestElevateWordAction.java b/src/main/java/org/codelibs/fess/crud/action/admin/BsSuggestElevateWordAction.java index 8bc7f4f08..089444128 100644 --- a/src/main/java/org/codelibs/fess/crud/action/admin/BsSuggestElevateWordAction.java +++ b/src/main/java/org/codelibs/fess/crud/action/admin/BsSuggestElevateWordAction.java @@ -43,8 +43,7 @@ public class BsSuggestElevateWordAction implements Serializable { private static final long serialVersionUID = 1L; - private static final Log log = LogFactory - .getLog(BsSuggestElevateWordAction.class); + private static final Log log = LogFactory.getLog(BsSuggestElevateWordAction.class); // for list @@ -64,14 +63,12 @@ public class BsSuggestElevateWordAction implements Serializable { protected String displayList(final boolean redirect) { // page navi - suggestElevateWordItems = suggestElevateWordService - .getSuggestElevateWordList(suggestElevateWordPager); + suggestElevateWordItems = suggestElevateWordService.getSuggestElevateWordList(suggestElevateWordPager); // restore from pager - Beans.copy(suggestElevateWordPager, suggestElevateWordForm.searchParams) - .excludes(CommonConstants.PAGER_CONVERSION_RULE) + Beans.copy(suggestElevateWordPager, suggestElevateWordForm.searchParams).excludes(CommonConstants.PAGER_CONVERSION_RULE) - .execute(); + .execute(); if (redirect) { return "index?redirect=true"; @@ -90,12 +87,10 @@ public class BsSuggestElevateWordAction implements Serializable { // page navi if (StringUtil.isNotBlank(suggestElevateWordForm.pageNumber)) { try { - suggestElevateWordPager.setCurrentPageNumber(Integer - .parseInt(suggestElevateWordForm.pageNumber)); + suggestElevateWordPager.setCurrentPageNumber(Integer.parseInt(suggestElevateWordForm.pageNumber)); } catch (final NumberFormatException e) { if (log.isDebugEnabled()) { - log.debug("Invalid value: " - + suggestElevateWordForm.pageNumber, e); + log.debug("Invalid value: " + suggestElevateWordForm.pageNumber, e); } } } @@ -105,10 +100,9 @@ public class BsSuggestElevateWordAction implements Serializable { @Execute(validator = false, input = "error.jsp") public String search() { - Beans.copy(suggestElevateWordForm.searchParams, suggestElevateWordPager) - .excludes(CommonConstants.PAGER_CONVERSION_RULE) + Beans.copy(suggestElevateWordForm.searchParams, suggestElevateWordPager).excludes(CommonConstants.PAGER_CONVERSION_RULE) - .execute(); + .execute(); return displayList(false); } @@ -134,9 +128,8 @@ public class BsSuggestElevateWordAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "confirmpage/{crudMode}/{id}") public String confirmpage() { if (suggestElevateWordForm.crudMode != CommonConstants.CONFIRM_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.CONFIRM_MODE, - suggestElevateWordForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE, + suggestElevateWordForm.crudMode }); } loadSuggestElevateWord(); @@ -158,9 +151,8 @@ public class BsSuggestElevateWordAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "editpage/{crudMode}/{id}") public String editpage() { if (suggestElevateWordForm.crudMode != CommonConstants.EDIT_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.EDIT_MODE, - suggestElevateWordForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE, + suggestElevateWordForm.crudMode }); } loadSuggestElevateWord(); @@ -194,9 +186,8 @@ public class BsSuggestElevateWordAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "deletepage/{crudMode}/{id}") public String deletepage() { if (suggestElevateWordForm.crudMode != CommonConstants.DELETE_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - suggestElevateWordForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, + suggestElevateWordForm.crudMode }); } loadSuggestElevateWord(); @@ -231,8 +222,7 @@ public class BsSuggestElevateWordAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_create_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_create_crud_table"); } } @@ -253,8 +243,7 @@ public class BsSuggestElevateWordAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_update_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_update_crud_table"); } } @@ -262,20 +251,17 @@ public class BsSuggestElevateWordAction implements Serializable { @Execute(validator = false, input = "error.jsp") public String delete() { if (suggestElevateWordForm.crudMode != CommonConstants.DELETE_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - suggestElevateWordForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, + suggestElevateWordForm.crudMode }); } try { - final SuggestElevateWord suggestElevateWord = suggestElevateWordService - .getSuggestElevateWord(createKeyMap()); + final SuggestElevateWord suggestElevateWord = suggestElevateWordService.getSuggestElevateWord(createKeyMap()); if (suggestElevateWord == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { suggestElevateWordForm.id }); + new Object[] { suggestElevateWordForm.id }); } @@ -291,50 +277,43 @@ public class BsSuggestElevateWordAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_delete_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_delete_crud_table"); } } protected void loadSuggestElevateWord() { - final SuggestElevateWord suggestElevateWord = suggestElevateWordService - .getSuggestElevateWord(createKeyMap()); + final SuggestElevateWord suggestElevateWord = suggestElevateWordService.getSuggestElevateWord(createKeyMap()); if (suggestElevateWord == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { suggestElevateWordForm.id }); + new Object[] { suggestElevateWordForm.id }); } - Beans.copy(suggestElevateWord, suggestElevateWordForm) - .excludes("searchParams", "mode") + Beans.copy(suggestElevateWord, suggestElevateWordForm).excludes("searchParams", "mode") - .execute(); + .execute(); } protected SuggestElevateWord createSuggestElevateWord() { SuggestElevateWord suggestElevateWord; if (suggestElevateWordForm.crudMode == CommonConstants.EDIT_MODE) { - suggestElevateWord = suggestElevateWordService - .getSuggestElevateWord(createKeyMap()); + suggestElevateWord = suggestElevateWordService.getSuggestElevateWord(createKeyMap()); if (suggestElevateWord == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { suggestElevateWordForm.id }); + new Object[] { suggestElevateWordForm.id }); } } else { suggestElevateWord = new SuggestElevateWord(); } - Beans.copy(suggestElevateWordForm, suggestElevateWord) - .excludes("searchParams", "mode") + Beans.copy(suggestElevateWordForm, suggestElevateWord).excludes("searchParams", "mode") - .execute(); + .execute(); return suggestElevateWord; } diff --git a/src/main/java/org/codelibs/fess/crud/action/admin/BsUserInfoAction.java b/src/main/java/org/codelibs/fess/crud/action/admin/BsUserInfoAction.java index df81dbe27..76d9c46f3 100644 --- a/src/main/java/org/codelibs/fess/crud/action/admin/BsUserInfoAction.java +++ b/src/main/java/org/codelibs/fess/crud/action/admin/BsUserInfoAction.java @@ -67,10 +67,9 @@ public class BsUserInfoAction implements Serializable { userInfoItems = userInfoService.getUserInfoList(userInfoPager); // restore from pager - Beans.copy(userInfoPager, userInfoForm.searchParams) - .excludes(CommonConstants.PAGER_CONVERSION_RULE) + Beans.copy(userInfoPager, userInfoForm.searchParams).excludes(CommonConstants.PAGER_CONVERSION_RULE) - .execute(); + .execute(); if (redirect) { return "index?redirect=true"; @@ -89,8 +88,7 @@ public class BsUserInfoAction implements Serializable { // page navi if (StringUtil.isNotBlank(userInfoForm.pageNumber)) { try { - userInfoPager.setCurrentPageNumber(Integer - .parseInt(userInfoForm.pageNumber)); + userInfoPager.setCurrentPageNumber(Integer.parseInt(userInfoForm.pageNumber)); } catch (final NumberFormatException e) { if (log.isDebugEnabled()) { log.debug("Invalid value: " + userInfoForm.pageNumber, e); @@ -103,10 +101,9 @@ public class BsUserInfoAction implements Serializable { @Execute(validator = false, input = "error.jsp") public String search() { - Beans.copy(userInfoForm.searchParams, userInfoPager) - .excludes(CommonConstants.PAGER_CONVERSION_RULE) + Beans.copy(userInfoForm.searchParams, userInfoPager).excludes(CommonConstants.PAGER_CONVERSION_RULE) - .execute(); + .execute(); return displayList(false); } @@ -132,9 +129,8 @@ public class BsUserInfoAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "confirmpage/{crudMode}/{id}") public String confirmpage() { if (userInfoForm.crudMode != CommonConstants.CONFIRM_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.CONFIRM_MODE, - userInfoForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE, + userInfoForm.crudMode }); } loadUserInfo(); @@ -156,9 +152,7 @@ public class BsUserInfoAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "editpage/{crudMode}/{id}") public String editpage() { if (userInfoForm.crudMode != CommonConstants.EDIT_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.EDIT_MODE, - userInfoForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE, userInfoForm.crudMode }); } loadUserInfo(); @@ -193,8 +187,7 @@ public class BsUserInfoAction implements Serializable { public String deletepage() { if (userInfoForm.crudMode != CommonConstants.DELETE_MODE) { throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - userInfoForm.crudMode }); + new Object[] { CommonConstants.DELETE_MODE, userInfoForm.crudMode }); } loadUserInfo(); @@ -229,8 +222,7 @@ public class BsUserInfoAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_create_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_create_crud_table"); } } @@ -251,8 +243,7 @@ public class BsUserInfoAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_update_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_update_crud_table"); } } @@ -261,19 +252,16 @@ public class BsUserInfoAction implements Serializable { public String delete() { if (userInfoForm.crudMode != CommonConstants.DELETE_MODE) { throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - userInfoForm.crudMode }); + new Object[] { CommonConstants.DELETE_MODE, userInfoForm.crudMode }); } try { - final UserInfo userInfo = userInfoService - .getUserInfo(createKeyMap()); + final UserInfo userInfo = userInfoService.getUserInfo(createKeyMap()); if (userInfo == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { userInfoForm.id }); + new Object[] { userInfoForm.id }); } @@ -289,8 +277,7 @@ public class BsUserInfoAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_delete_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_delete_crud_table"); } } @@ -299,18 +286,15 @@ public class BsUserInfoAction implements Serializable { final UserInfo userInfo = userInfoService.getUserInfo(createKeyMap()); if (userInfo == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { userInfoForm.id }); + new Object[] { userInfoForm.id }); } - Beans.copy(userInfo, userInfoForm) - .excludes("searchParams", "mode") + Beans.copy(userInfo, userInfoForm).excludes("searchParams", "mode") - .timestampConverter(Constants.DEFAULT_DATETIME_FORMAT, - "createdTime", "updatedTime").execute(); + .timestampConverter(Constants.DEFAULT_DATETIME_FORMAT, "createdTime", "updatedTime").execute(); } protected UserInfo createUserInfo() { @@ -319,20 +303,17 @@ public class BsUserInfoAction implements Serializable { userInfo = userInfoService.getUserInfo(createKeyMap()); if (userInfo == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { userInfoForm.id }); + new Object[] { userInfoForm.id }); } } else { userInfo = new UserInfo(); } - Beans.copy(userInfoForm, userInfo) - .excludes("searchParams", "mode") + Beans.copy(userInfoForm, userInfo).excludes("searchParams", "mode") - .timestampConverter(Constants.DEFAULT_DATETIME_FORMAT, - "createdTime", "updatedTime").execute(); + .timestampConverter(Constants.DEFAULT_DATETIME_FORMAT, "createdTime", "updatedTime").execute(); return userInfo; } diff --git a/src/main/java/org/codelibs/fess/crud/action/admin/BsWebAuthenticationAction.java b/src/main/java/org/codelibs/fess/crud/action/admin/BsWebAuthenticationAction.java index c78f986aa..65f446692 100644 --- a/src/main/java/org/codelibs/fess/crud/action/admin/BsWebAuthenticationAction.java +++ b/src/main/java/org/codelibs/fess/crud/action/admin/BsWebAuthenticationAction.java @@ -43,8 +43,7 @@ public class BsWebAuthenticationAction implements Serializable { private static final long serialVersionUID = 1L; - private static final Log log = LogFactory - .getLog(BsWebAuthenticationAction.class); + private static final Log log = LogFactory.getLog(BsWebAuthenticationAction.class); // for list @@ -64,14 +63,12 @@ public class BsWebAuthenticationAction implements Serializable { protected String displayList(final boolean redirect) { // page navi - webAuthenticationItems = webAuthenticationService - .getWebAuthenticationList(webAuthenticationPager); + webAuthenticationItems = webAuthenticationService.getWebAuthenticationList(webAuthenticationPager); // restore from pager - Beans.copy(webAuthenticationPager, webAuthenticationForm.searchParams) - .excludes(CommonConstants.PAGER_CONVERSION_RULE) + Beans.copy(webAuthenticationPager, webAuthenticationForm.searchParams).excludes(CommonConstants.PAGER_CONVERSION_RULE) - .execute(); + .execute(); if (redirect) { return "index?redirect=true"; @@ -90,12 +87,10 @@ public class BsWebAuthenticationAction implements Serializable { // page navi if (StringUtil.isNotBlank(webAuthenticationForm.pageNumber)) { try { - webAuthenticationPager.setCurrentPageNumber(Integer - .parseInt(webAuthenticationForm.pageNumber)); + webAuthenticationPager.setCurrentPageNumber(Integer.parseInt(webAuthenticationForm.pageNumber)); } catch (final NumberFormatException e) { if (log.isDebugEnabled()) { - log.debug("Invalid value: " - + webAuthenticationForm.pageNumber, e); + log.debug("Invalid value: " + webAuthenticationForm.pageNumber, e); } } } @@ -105,10 +100,9 @@ public class BsWebAuthenticationAction implements Serializable { @Execute(validator = false, input = "error.jsp") public String search() { - Beans.copy(webAuthenticationForm.searchParams, webAuthenticationPager) - .excludes(CommonConstants.PAGER_CONVERSION_RULE) + Beans.copy(webAuthenticationForm.searchParams, webAuthenticationPager).excludes(CommonConstants.PAGER_CONVERSION_RULE) - .execute(); + .execute(); return displayList(false); } @@ -134,9 +128,8 @@ public class BsWebAuthenticationAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "confirmpage/{crudMode}/{id}") public String confirmpage() { if (webAuthenticationForm.crudMode != CommonConstants.CONFIRM_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.CONFIRM_MODE, - webAuthenticationForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE, + webAuthenticationForm.crudMode }); } loadWebAuthentication(); @@ -158,9 +151,8 @@ public class BsWebAuthenticationAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "editpage/{crudMode}/{id}") public String editpage() { if (webAuthenticationForm.crudMode != CommonConstants.EDIT_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.EDIT_MODE, - webAuthenticationForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE, + webAuthenticationForm.crudMode }); } loadWebAuthentication(); @@ -194,9 +186,8 @@ public class BsWebAuthenticationAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "deletepage/{crudMode}/{id}") public String deletepage() { if (webAuthenticationForm.crudMode != CommonConstants.DELETE_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - webAuthenticationForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, + webAuthenticationForm.crudMode }); } loadWebAuthentication(); @@ -231,8 +222,7 @@ public class BsWebAuthenticationAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_create_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_create_crud_table"); } } @@ -253,8 +243,7 @@ public class BsWebAuthenticationAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_update_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_update_crud_table"); } } @@ -262,20 +251,17 @@ public class BsWebAuthenticationAction implements Serializable { @Execute(validator = false, input = "error.jsp") public String delete() { if (webAuthenticationForm.crudMode != CommonConstants.DELETE_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - webAuthenticationForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, + webAuthenticationForm.crudMode }); } try { - final WebAuthentication webAuthentication = webAuthenticationService - .getWebAuthentication(createKeyMap()); + final WebAuthentication webAuthentication = webAuthenticationService.getWebAuthentication(createKeyMap()); if (webAuthentication == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { webAuthenticationForm.id }); + new Object[] { webAuthenticationForm.id }); } @@ -291,50 +277,43 @@ public class BsWebAuthenticationAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_delete_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_delete_crud_table"); } } protected void loadWebAuthentication() { - final WebAuthentication webAuthentication = webAuthenticationService - .getWebAuthentication(createKeyMap()); + final WebAuthentication webAuthentication = webAuthenticationService.getWebAuthentication(createKeyMap()); if (webAuthentication == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { webAuthenticationForm.id }); + new Object[] { webAuthenticationForm.id }); } - Beans.copy(webAuthentication, webAuthenticationForm) - .excludes("searchParams", "mode") + Beans.copy(webAuthentication, webAuthenticationForm).excludes("searchParams", "mode") - .execute(); + .execute(); } protected WebAuthentication createWebAuthentication() { WebAuthentication webAuthentication; if (webAuthenticationForm.crudMode == CommonConstants.EDIT_MODE) { - webAuthentication = webAuthenticationService - .getWebAuthentication(createKeyMap()); + webAuthentication = webAuthenticationService.getWebAuthentication(createKeyMap()); if (webAuthentication == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { webAuthenticationForm.id }); + new Object[] { webAuthenticationForm.id }); } } else { webAuthentication = new WebAuthentication(); } - Beans.copy(webAuthenticationForm, webAuthentication) - .excludes("searchParams", "mode") + Beans.copy(webAuthenticationForm, webAuthentication).excludes("searchParams", "mode") - .execute(); + .execute(); return webAuthentication; } diff --git a/src/main/java/org/codelibs/fess/crud/action/admin/BsWebCrawlingConfigAction.java b/src/main/java/org/codelibs/fess/crud/action/admin/BsWebCrawlingConfigAction.java index b80bd0c12..16db04b57 100644 --- a/src/main/java/org/codelibs/fess/crud/action/admin/BsWebCrawlingConfigAction.java +++ b/src/main/java/org/codelibs/fess/crud/action/admin/BsWebCrawlingConfigAction.java @@ -43,8 +43,7 @@ public class BsWebCrawlingConfigAction implements Serializable { private static final long serialVersionUID = 1L; - private static final Log log = LogFactory - .getLog(BsWebCrawlingConfigAction.class); + private static final Log log = LogFactory.getLog(BsWebCrawlingConfigAction.class); // for list @@ -64,14 +63,12 @@ public class BsWebCrawlingConfigAction implements Serializable { protected String displayList(final boolean redirect) { // page navi - webCrawlingConfigItems = webCrawlingConfigService - .getWebCrawlingConfigList(webCrawlingConfigPager); + webCrawlingConfigItems = webCrawlingConfigService.getWebCrawlingConfigList(webCrawlingConfigPager); // restore from pager - Beans.copy(webCrawlingConfigPager, webCrawlingConfigForm.searchParams) - .excludes(CommonConstants.PAGER_CONVERSION_RULE) + Beans.copy(webCrawlingConfigPager, webCrawlingConfigForm.searchParams).excludes(CommonConstants.PAGER_CONVERSION_RULE) - .execute(); + .execute(); if (redirect) { return "index?redirect=true"; @@ -90,12 +87,10 @@ public class BsWebCrawlingConfigAction implements Serializable { // page navi if (StringUtil.isNotBlank(webCrawlingConfigForm.pageNumber)) { try { - webCrawlingConfigPager.setCurrentPageNumber(Integer - .parseInt(webCrawlingConfigForm.pageNumber)); + webCrawlingConfigPager.setCurrentPageNumber(Integer.parseInt(webCrawlingConfigForm.pageNumber)); } catch (final NumberFormatException e) { if (log.isDebugEnabled()) { - log.debug("Invalid value: " - + webCrawlingConfigForm.pageNumber, e); + log.debug("Invalid value: " + webCrawlingConfigForm.pageNumber, e); } } } @@ -105,10 +100,9 @@ public class BsWebCrawlingConfigAction implements Serializable { @Execute(validator = false, input = "error.jsp") public String search() { - Beans.copy(webCrawlingConfigForm.searchParams, webCrawlingConfigPager) - .excludes(CommonConstants.PAGER_CONVERSION_RULE) + Beans.copy(webCrawlingConfigForm.searchParams, webCrawlingConfigPager).excludes(CommonConstants.PAGER_CONVERSION_RULE) - .execute(); + .execute(); return displayList(false); } @@ -134,9 +128,8 @@ public class BsWebCrawlingConfigAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "confirmpage/{crudMode}/{id}") public String confirmpage() { if (webCrawlingConfigForm.crudMode != CommonConstants.CONFIRM_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.CONFIRM_MODE, - webCrawlingConfigForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE, + webCrawlingConfigForm.crudMode }); } loadWebCrawlingConfig(); @@ -158,9 +151,8 @@ public class BsWebCrawlingConfigAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "editpage/{crudMode}/{id}") public String editpage() { if (webCrawlingConfigForm.crudMode != CommonConstants.EDIT_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.EDIT_MODE, - webCrawlingConfigForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE, + webCrawlingConfigForm.crudMode }); } loadWebCrawlingConfig(); @@ -194,9 +186,8 @@ public class BsWebCrawlingConfigAction implements Serializable { @Execute(validator = false, input = "error.jsp", urlPattern = "deletepage/{crudMode}/{id}") public String deletepage() { if (webCrawlingConfigForm.crudMode != CommonConstants.DELETE_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - webCrawlingConfigForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, + webCrawlingConfigForm.crudMode }); } loadWebCrawlingConfig(); @@ -231,8 +222,7 @@ public class BsWebCrawlingConfigAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_create_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_create_crud_table"); } } @@ -253,8 +243,7 @@ public class BsWebCrawlingConfigAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_update_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_update_crud_table"); } } @@ -262,20 +251,17 @@ public class BsWebCrawlingConfigAction implements Serializable { @Execute(validator = false, input = "error.jsp") public String delete() { if (webCrawlingConfigForm.crudMode != CommonConstants.DELETE_MODE) { - throw new ActionMessagesException("errors.crud_invalid_mode", - new Object[] { CommonConstants.DELETE_MODE, - webCrawlingConfigForm.crudMode }); + throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE, + webCrawlingConfigForm.crudMode }); } try { - final WebCrawlingConfig webCrawlingConfig = webCrawlingConfigService - .getWebCrawlingConfig(createKeyMap()); + final WebCrawlingConfig webCrawlingConfig = webCrawlingConfigService.getWebCrawlingConfig(createKeyMap()); if (webCrawlingConfig == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { webCrawlingConfigForm.id }); + new Object[] { webCrawlingConfigForm.id }); } @@ -291,50 +277,43 @@ public class BsWebCrawlingConfigAction implements Serializable { throw new ActionMessagesException(e.getMessageId(), e.getArgs()); } catch (final Exception e) { log.error(e.getMessage(), e); - throw new ActionMessagesException( - "errors.crud_failed_to_delete_crud_table"); + throw new ActionMessagesException("errors.crud_failed_to_delete_crud_table"); } } protected void loadWebCrawlingConfig() { - final WebCrawlingConfig webCrawlingConfig = webCrawlingConfigService - .getWebCrawlingConfig(createKeyMap()); + final WebCrawlingConfig webCrawlingConfig = webCrawlingConfigService.getWebCrawlingConfig(createKeyMap()); if (webCrawlingConfig == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { webCrawlingConfigForm.id }); + new Object[] { webCrawlingConfigForm.id }); } - Beans.copy(webCrawlingConfig, webCrawlingConfigForm) - .excludes("searchParams", "mode") + Beans.copy(webCrawlingConfig, webCrawlingConfigForm).excludes("searchParams", "mode") - .execute(); + .execute(); } protected WebCrawlingConfig createWebCrawlingConfig() { WebCrawlingConfig webCrawlingConfig; if (webCrawlingConfigForm.crudMode == CommonConstants.EDIT_MODE) { - webCrawlingConfig = webCrawlingConfigService - .getWebCrawlingConfig(createKeyMap()); + webCrawlingConfig = webCrawlingConfigService.getWebCrawlingConfig(createKeyMap()); if (webCrawlingConfig == null) { // throw an exception - throw new ActionMessagesException( - "errors.crud_could_not_find_crud_table", + throw new ActionMessagesException("errors.crud_could_not_find_crud_table", - new Object[] { webCrawlingConfigForm.id }); + new Object[] { webCrawlingConfigForm.id }); } } else { webCrawlingConfig = new WebCrawlingConfig(); } - Beans.copy(webCrawlingConfigForm, webCrawlingConfig) - .excludes("searchParams", "mode") + Beans.copy(webCrawlingConfigForm, webCrawlingConfig).excludes("searchParams", "mode") - .execute(); + .execute(); return webCrawlingConfig; } diff --git a/src/main/java/org/codelibs/fess/crud/service/BsBoostDocumentRuleService.java b/src/main/java/org/codelibs/fess/crud/service/BsBoostDocumentRuleService.java index c33d92d74..8abf9d4d9 100644 --- a/src/main/java/org/codelibs/fess/crud/service/BsBoostDocumentRuleService.java +++ b/src/main/java/org/codelibs/fess/crud/service/BsBoostDocumentRuleService.java @@ -39,33 +39,27 @@ public abstract class BsBoostDocumentRuleService { super(); } - public List getBoostDocumentRuleList( - final BoostDocumentRulePager boostDocumentRulePager) { + public List getBoostDocumentRuleList(final BoostDocumentRulePager boostDocumentRulePager) { - final PagingResultBean boostDocumentRuleList = boostDocumentRuleBhv - .selectPage(cb -> { - cb.paging(boostDocumentRulePager.getPageSize(), - boostDocumentRulePager.getCurrentPageNumber()); - setupListCondition(cb, boostDocumentRulePager); - }); + final PagingResultBean boostDocumentRuleList = boostDocumentRuleBhv.selectPage(cb -> { + cb.paging(boostDocumentRulePager.getPageSize(), boostDocumentRulePager.getCurrentPageNumber()); + setupListCondition(cb, boostDocumentRulePager); + }); // update pager - Beans.copy(boostDocumentRuleList, boostDocumentRulePager) - .includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); - boostDocumentRulePager.setPageNumberList(boostDocumentRuleList - .pageRange(op -> { - op.rangeSize(5); - }).createPageNumberList()); + Beans.copy(boostDocumentRuleList, boostDocumentRulePager).includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); + boostDocumentRulePager.setPageNumberList(boostDocumentRuleList.pageRange(op -> { + op.rangeSize(5); + }).createPageNumberList()); return boostDocumentRuleList; } public BoostDocumentRule getBoostDocumentRule(final Map keys) { - final BoostDocumentRule boostDocumentRule = boostDocumentRuleBhv - .selectEntity(cb -> { - cb.query().setId_Equal(Long.parseLong(keys.get("id"))); - setupEntityCondition(cb, keys); - }).orElse(null);//TODO + final BoostDocumentRule boostDocumentRule = boostDocumentRuleBhv.selectEntity(cb -> { + cb.query().setId_Equal(Long.parseLong(keys.get("id"))); + setupEntityCondition(cb, keys); + }).orElse(null);//TODO if (boostDocumentRule == null) { // TODO exception? return null; @@ -74,24 +68,21 @@ public abstract class BsBoostDocumentRuleService { return boostDocumentRule; } - public void store(final BoostDocumentRule boostDocumentRule) - throws CrudMessageException { + public void store(final BoostDocumentRule boostDocumentRule) throws CrudMessageException { setupStoreCondition(boostDocumentRule); boostDocumentRuleBhv.insertOrUpdate(boostDocumentRule); } - public void delete(final BoostDocumentRule boostDocumentRule) - throws CrudMessageException { + public void delete(final BoostDocumentRule boostDocumentRule) throws CrudMessageException { setupDeleteCondition(boostDocumentRule); boostDocumentRuleBhv.delete(boostDocumentRule); } - protected void setupListCondition(final BoostDocumentRuleCB cb, - final BoostDocumentRulePager boostDocumentRulePager) { + protected void setupListCondition(final BoostDocumentRuleCB cb, final BoostDocumentRulePager boostDocumentRulePager) { if (boostDocumentRulePager.id != null) { cb.query().setId_Equal(Long.parseLong(boostDocumentRulePager.id)); @@ -99,14 +90,12 @@ public abstract class BsBoostDocumentRuleService { // TODO Long, Integer, String supported only. } - protected void setupEntityCondition(final BoostDocumentRuleCB cb, - final Map keys) { + protected void setupEntityCondition(final BoostDocumentRuleCB cb, final Map keys) { } protected void setupStoreCondition(final BoostDocumentRule boostDocumentRule) { } - protected void setupDeleteCondition( - final BoostDocumentRule boostDocumentRule) { + protected void setupDeleteCondition(final BoostDocumentRule boostDocumentRule) { } } \ No newline at end of file diff --git a/src/main/java/org/codelibs/fess/crud/service/BsCrawlingSessionService.java b/src/main/java/org/codelibs/fess/crud/service/BsCrawlingSessionService.java index f3316c21f..3c2773956 100644 --- a/src/main/java/org/codelibs/fess/crud/service/BsCrawlingSessionService.java +++ b/src/main/java/org/codelibs/fess/crud/service/BsCrawlingSessionService.java @@ -39,33 +39,27 @@ public abstract class BsCrawlingSessionService { super(); } - public List getCrawlingSessionList( - final CrawlingSessionPager crawlingSessionPager) { + public List getCrawlingSessionList(final CrawlingSessionPager crawlingSessionPager) { - final PagingResultBean crawlingSessionList = crawlingSessionBhv - .selectPage(cb -> { - cb.paging(crawlingSessionPager.getPageSize(), - crawlingSessionPager.getCurrentPageNumber()); - setupListCondition(cb, crawlingSessionPager); - }); + final PagingResultBean crawlingSessionList = crawlingSessionBhv.selectPage(cb -> { + cb.paging(crawlingSessionPager.getPageSize(), crawlingSessionPager.getCurrentPageNumber()); + setupListCondition(cb, crawlingSessionPager); + }); // update pager - Beans.copy(crawlingSessionList, crawlingSessionPager) - .includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); - crawlingSessionPager.setPageNumberList(crawlingSessionList.pageRange( - op -> { - op.rangeSize(5); - }).createPageNumberList()); + Beans.copy(crawlingSessionList, crawlingSessionPager).includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); + crawlingSessionPager.setPageNumberList(crawlingSessionList.pageRange(op -> { + op.rangeSize(5); + }).createPageNumberList()); return crawlingSessionList; } public CrawlingSession getCrawlingSession(final Map keys) { - final CrawlingSession crawlingSession = crawlingSessionBhv - .selectEntity(cb -> { - cb.query().setId_Equal(Long.parseLong(keys.get("id"))); - setupEntityCondition(cb, keys); - }).orElse(null);//TODO + final CrawlingSession crawlingSession = crawlingSessionBhv.selectEntity(cb -> { + cb.query().setId_Equal(Long.parseLong(keys.get("id"))); + setupEntityCondition(cb, keys); + }).orElse(null);//TODO if (crawlingSession == null) { // TODO exception? return null; @@ -74,24 +68,21 @@ public abstract class BsCrawlingSessionService { return crawlingSession; } - public void store(final CrawlingSession crawlingSession) - throws CrudMessageException { + public void store(final CrawlingSession crawlingSession) throws CrudMessageException { setupStoreCondition(crawlingSession); crawlingSessionBhv.insertOrUpdate(crawlingSession); } - public void delete(final CrawlingSession crawlingSession) - throws CrudMessageException { + public void delete(final CrawlingSession crawlingSession) throws CrudMessageException { setupDeleteCondition(crawlingSession); crawlingSessionBhv.delete(crawlingSession); } - protected void setupListCondition(final CrawlingSessionCB cb, - final CrawlingSessionPager crawlingSessionPager) { + protected void setupListCondition(final CrawlingSessionCB cb, final CrawlingSessionPager crawlingSessionPager) { if (crawlingSessionPager.id != null) { cb.query().setId_Equal(Long.parseLong(crawlingSessionPager.id)); @@ -99,8 +90,7 @@ public abstract class BsCrawlingSessionService { // TODO Long, Integer, String supported only. } - protected void setupEntityCondition(final CrawlingSessionCB cb, - final Map keys) { + protected void setupEntityCondition(final CrawlingSessionCB cb, final Map keys) { } protected void setupStoreCondition(final CrawlingSession crawlingSession) { diff --git a/src/main/java/org/codelibs/fess/crud/service/BsDataCrawlingConfigService.java b/src/main/java/org/codelibs/fess/crud/service/BsDataCrawlingConfigService.java index 5ad6db673..82f5a6a26 100644 --- a/src/main/java/org/codelibs/fess/crud/service/BsDataCrawlingConfigService.java +++ b/src/main/java/org/codelibs/fess/crud/service/BsDataCrawlingConfigService.java @@ -39,35 +39,28 @@ public abstract class BsDataCrawlingConfigService { super(); } - public List getDataCrawlingConfigList( - final DataCrawlingConfigPager dataCrawlingConfigPager) { + public List getDataCrawlingConfigList(final DataCrawlingConfigPager dataCrawlingConfigPager) { - final PagingResultBean dataCrawlingConfigList = dataCrawlingConfigBhv - .selectPage(cb -> { - cb.paging(dataCrawlingConfigPager.getPageSize(), - dataCrawlingConfigPager.getCurrentPageNumber()); + final PagingResultBean dataCrawlingConfigList = dataCrawlingConfigBhv.selectPage(cb -> { + cb.paging(dataCrawlingConfigPager.getPageSize(), dataCrawlingConfigPager.getCurrentPageNumber()); - setupListCondition(cb, dataCrawlingConfigPager); - }); + setupListCondition(cb, dataCrawlingConfigPager); + }); // update pager - Beans.copy(dataCrawlingConfigList, dataCrawlingConfigPager) - .includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); - dataCrawlingConfigPager.setPageNumberList(dataCrawlingConfigList - .pageRange(op -> { - op.rangeSize(5); - }).createPageNumberList()); + Beans.copy(dataCrawlingConfigList, dataCrawlingConfigPager).includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); + dataCrawlingConfigPager.setPageNumberList(dataCrawlingConfigList.pageRange(op -> { + op.rangeSize(5); + }).createPageNumberList()); return dataCrawlingConfigList; } - public DataCrawlingConfig getDataCrawlingConfig( - final Map keys) { - final DataCrawlingConfig dataCrawlingConfig = dataCrawlingConfigBhv - .selectEntity(cb -> { - cb.query().setId_Equal(Long.parseLong(keys.get("id"))); - setupEntityCondition(cb, keys); - }).orElse(null);//TODO + public DataCrawlingConfig getDataCrawlingConfig(final Map keys) { + final DataCrawlingConfig dataCrawlingConfig = dataCrawlingConfigBhv.selectEntity(cb -> { + cb.query().setId_Equal(Long.parseLong(keys.get("id"))); + setupEntityCondition(cb, keys); + }).orElse(null);//TODO if (dataCrawlingConfig == null) { // TODO exception? return null; @@ -76,24 +69,21 @@ public abstract class BsDataCrawlingConfigService { return dataCrawlingConfig; } - public void store(final DataCrawlingConfig dataCrawlingConfig) - throws CrudMessageException { + public void store(final DataCrawlingConfig dataCrawlingConfig) throws CrudMessageException { setupStoreCondition(dataCrawlingConfig); dataCrawlingConfigBhv.insertOrUpdate(dataCrawlingConfig); } - public void delete(final DataCrawlingConfig dataCrawlingConfig) - throws CrudMessageException { + public void delete(final DataCrawlingConfig dataCrawlingConfig) throws CrudMessageException { setupDeleteCondition(dataCrawlingConfig); dataCrawlingConfigBhv.delete(dataCrawlingConfig); } - protected void setupListCondition(final DataCrawlingConfigCB cb, - final DataCrawlingConfigPager dataCrawlingConfigPager) { + protected void setupListCondition(final DataCrawlingConfigCB cb, final DataCrawlingConfigPager dataCrawlingConfigPager) { if (dataCrawlingConfigPager.id != null) { cb.query().setId_Equal(Long.parseLong(dataCrawlingConfigPager.id)); @@ -101,15 +91,12 @@ public abstract class BsDataCrawlingConfigService { // TODO Long, Integer, String supported only. } - protected void setupEntityCondition(final DataCrawlingConfigCB cb, - final Map keys) { + protected void setupEntityCondition(final DataCrawlingConfigCB cb, final Map keys) { } - protected void setupStoreCondition( - final DataCrawlingConfig dataCrawlingConfig) { + protected void setupStoreCondition(final DataCrawlingConfig dataCrawlingConfig) { } - protected void setupDeleteCondition( - final DataCrawlingConfig dataCrawlingConfig) { + protected void setupDeleteCondition(final DataCrawlingConfig dataCrawlingConfig) { } } \ No newline at end of file diff --git a/src/main/java/org/codelibs/fess/crud/service/BsFailureUrlService.java b/src/main/java/org/codelibs/fess/crud/service/BsFailureUrlService.java index 8b3b383bc..5d1786342 100644 --- a/src/main/java/org/codelibs/fess/crud/service/BsFailureUrlService.java +++ b/src/main/java/org/codelibs/fess/crud/service/BsFailureUrlService.java @@ -39,19 +39,15 @@ public abstract class BsFailureUrlService { super(); } - public List getFailureUrlList( - final FailureUrlPager failureUrlPager) { + public List getFailureUrlList(final FailureUrlPager failureUrlPager) { - final PagingResultBean failureUrlList = failureUrlBhv - .selectPage(cb -> { - cb.paging(failureUrlPager.getPageSize(), - failureUrlPager.getCurrentPageNumber()); - setupListCondition(cb, failureUrlPager); - }); + final PagingResultBean failureUrlList = failureUrlBhv.selectPage(cb -> { + cb.paging(failureUrlPager.getPageSize(), failureUrlPager.getCurrentPageNumber()); + setupListCondition(cb, failureUrlPager); + }); // update pager - Beans.copy(failureUrlList, failureUrlPager) - .includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); + Beans.copy(failureUrlList, failureUrlPager).includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); failureUrlPager.setPageNumberList(failureUrlList.pageRange(op -> { op.rangeSize(5); }).createPageNumberList()); @@ -86,8 +82,7 @@ public abstract class BsFailureUrlService { } - protected void setupListCondition(final FailureUrlCB cb, - final FailureUrlPager failureUrlPager) { + protected void setupListCondition(final FailureUrlCB cb, final FailureUrlPager failureUrlPager) { if (failureUrlPager.id != null) { cb.query().setId_Equal(Long.parseLong(failureUrlPager.id)); @@ -95,8 +90,7 @@ public abstract class BsFailureUrlService { // TODO Long, Integer, String supported only. } - protected void setupEntityCondition(final FailureUrlCB cb, - final Map keys) { + protected void setupEntityCondition(final FailureUrlCB cb, final Map keys) { } protected void setupStoreCondition(final FailureUrl failureUrl) { diff --git a/src/main/java/org/codelibs/fess/crud/service/BsFavoriteLogService.java b/src/main/java/org/codelibs/fess/crud/service/BsFavoriteLogService.java index 6e45b3657..214c02829 100644 --- a/src/main/java/org/codelibs/fess/crud/service/BsFavoriteLogService.java +++ b/src/main/java/org/codelibs/fess/crud/service/BsFavoriteLogService.java @@ -39,19 +39,15 @@ public abstract class BsFavoriteLogService { super(); } - public List getFavoriteLogList( - final FavoriteLogPager favoriteLogPager) { + public List getFavoriteLogList(final FavoriteLogPager favoriteLogPager) { - final PagingResultBean favoriteLogList = favoriteLogBhv - .selectPage(cb -> { - cb.paging(favoriteLogPager.getPageSize(), - favoriteLogPager.getCurrentPageNumber()); - setupListCondition(cb, favoriteLogPager); - }); + final PagingResultBean favoriteLogList = favoriteLogBhv.selectPage(cb -> { + cb.paging(favoriteLogPager.getPageSize(), favoriteLogPager.getCurrentPageNumber()); + setupListCondition(cb, favoriteLogPager); + }); // update pager - Beans.copy(favoriteLogList, favoriteLogPager) - .includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); + Beans.copy(favoriteLogList, favoriteLogPager).includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); favoriteLogPager.setPageNumberList(favoriteLogList.pageRange(op -> { op.rangeSize(5); }).createPageNumberList()); @@ -72,24 +68,21 @@ public abstract class BsFavoriteLogService { return favoriteLog; } - public void store(final FavoriteLog favoriteLog) - throws CrudMessageException { + public void store(final FavoriteLog favoriteLog) throws CrudMessageException { setupStoreCondition(favoriteLog); favoriteLogBhv.insertOrUpdate(favoriteLog); } - public void delete(final FavoriteLog favoriteLog) - throws CrudMessageException { + public void delete(final FavoriteLog favoriteLog) throws CrudMessageException { setupDeleteCondition(favoriteLog); favoriteLogBhv.delete(favoriteLog); } - protected void setupListCondition(final FavoriteLogCB cb, - final FavoriteLogPager favoriteLogPager) { + protected void setupListCondition(final FavoriteLogCB cb, final FavoriteLogPager favoriteLogPager) { if (favoriteLogPager.id != null) { cb.query().setId_Equal(Long.parseLong(favoriteLogPager.id)); @@ -97,8 +90,7 @@ public abstract class BsFavoriteLogService { // TODO Long, Integer, String supported only. } - protected void setupEntityCondition(final FavoriteLogCB cb, - final Map keys) { + protected void setupEntityCondition(final FavoriteLogCB cb, final Map keys) { } protected void setupStoreCondition(final FavoriteLog favoriteLog) { diff --git a/src/main/java/org/codelibs/fess/crud/service/BsFileAuthenticationService.java b/src/main/java/org/codelibs/fess/crud/service/BsFileAuthenticationService.java index acf0ed571..7ef5bec5e 100644 --- a/src/main/java/org/codelibs/fess/crud/service/BsFileAuthenticationService.java +++ b/src/main/java/org/codelibs/fess/crud/service/BsFileAuthenticationService.java @@ -39,34 +39,27 @@ public abstract class BsFileAuthenticationService { super(); } - public List getFileAuthenticationList( - final FileAuthenticationPager fileAuthenticationPager) { + public List getFileAuthenticationList(final FileAuthenticationPager fileAuthenticationPager) { - final PagingResultBean fileAuthenticationList = fileAuthenticationBhv - .selectPage(cb -> { - cb.paging(fileAuthenticationPager.getPageSize(), - fileAuthenticationPager.getCurrentPageNumber()); - setupListCondition(cb, fileAuthenticationPager); - }); + final PagingResultBean fileAuthenticationList = fileAuthenticationBhv.selectPage(cb -> { + cb.paging(fileAuthenticationPager.getPageSize(), fileAuthenticationPager.getCurrentPageNumber()); + setupListCondition(cb, fileAuthenticationPager); + }); // update pager - Beans.copy(fileAuthenticationList, fileAuthenticationPager) - .includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); - fileAuthenticationPager.setPageNumberList(fileAuthenticationList - .pageRange(op -> { - op.rangeSize(5); - }).createPageNumberList()); + Beans.copy(fileAuthenticationList, fileAuthenticationPager).includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); + fileAuthenticationPager.setPageNumberList(fileAuthenticationList.pageRange(op -> { + op.rangeSize(5); + }).createPageNumberList()); return fileAuthenticationList; } - public FileAuthentication getFileAuthentication( - final Map keys) { - final FileAuthentication fileAuthentication = fileAuthenticationBhv - .selectEntity(cb -> { - cb.query().setId_Equal(Long.parseLong(keys.get("id"))); - setupEntityCondition(cb, keys); - }).orElse(null);//TODO + public FileAuthentication getFileAuthentication(final Map keys) { + final FileAuthentication fileAuthentication = fileAuthenticationBhv.selectEntity(cb -> { + cb.query().setId_Equal(Long.parseLong(keys.get("id"))); + setupEntityCondition(cb, keys); + }).orElse(null);//TODO if (fileAuthentication == null) { // TODO exception? return null; @@ -75,24 +68,21 @@ public abstract class BsFileAuthenticationService { return fileAuthentication; } - public void store(final FileAuthentication fileAuthentication) - throws CrudMessageException { + public void store(final FileAuthentication fileAuthentication) throws CrudMessageException { setupStoreCondition(fileAuthentication); fileAuthenticationBhv.insertOrUpdate(fileAuthentication); } - public void delete(final FileAuthentication fileAuthentication) - throws CrudMessageException { + public void delete(final FileAuthentication fileAuthentication) throws CrudMessageException { setupDeleteCondition(fileAuthentication); fileAuthenticationBhv.delete(fileAuthentication); } - protected void setupListCondition(final FileAuthenticationCB cb, - final FileAuthenticationPager fileAuthenticationPager) { + protected void setupListCondition(final FileAuthenticationCB cb, final FileAuthenticationPager fileAuthenticationPager) { if (fileAuthenticationPager.id != null) { cb.query().setId_Equal(Long.parseLong(fileAuthenticationPager.id)); @@ -100,15 +90,12 @@ public abstract class BsFileAuthenticationService { // TODO Long, Integer, String supported only. } - protected void setupEntityCondition(final FileAuthenticationCB cb, - final Map keys) { + protected void setupEntityCondition(final FileAuthenticationCB cb, final Map keys) { } - protected void setupStoreCondition( - final FileAuthentication fileAuthentication) { + protected void setupStoreCondition(final FileAuthentication fileAuthentication) { } - protected void setupDeleteCondition( - final FileAuthentication fileAuthentication) { + protected void setupDeleteCondition(final FileAuthentication fileAuthentication) { } } \ No newline at end of file diff --git a/src/main/java/org/codelibs/fess/crud/service/BsFileCrawlingConfigService.java b/src/main/java/org/codelibs/fess/crud/service/BsFileCrawlingConfigService.java index 71227e2c7..5910972f6 100644 --- a/src/main/java/org/codelibs/fess/crud/service/BsFileCrawlingConfigService.java +++ b/src/main/java/org/codelibs/fess/crud/service/BsFileCrawlingConfigService.java @@ -39,34 +39,27 @@ public abstract class BsFileCrawlingConfigService { super(); } - public List getFileCrawlingConfigList( - final FileCrawlingConfigPager fileCrawlingConfigPager) { + public List getFileCrawlingConfigList(final FileCrawlingConfigPager fileCrawlingConfigPager) { - final PagingResultBean fileCrawlingConfigList = fileCrawlingConfigBhv - .selectPage(cb -> { - cb.paging(fileCrawlingConfigPager.getPageSize(), - fileCrawlingConfigPager.getCurrentPageNumber()); - setupListCondition(cb, fileCrawlingConfigPager); - }); + final PagingResultBean fileCrawlingConfigList = fileCrawlingConfigBhv.selectPage(cb -> { + cb.paging(fileCrawlingConfigPager.getPageSize(), fileCrawlingConfigPager.getCurrentPageNumber()); + setupListCondition(cb, fileCrawlingConfigPager); + }); // update pager - Beans.copy(fileCrawlingConfigList, fileCrawlingConfigPager) - .includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); - fileCrawlingConfigPager.setPageNumberList(fileCrawlingConfigList - .pageRange(op -> { - op.rangeSize(5); - }).createPageNumberList()); + Beans.copy(fileCrawlingConfigList, fileCrawlingConfigPager).includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); + fileCrawlingConfigPager.setPageNumberList(fileCrawlingConfigList.pageRange(op -> { + op.rangeSize(5); + }).createPageNumberList()); return fileCrawlingConfigList; } - public FileCrawlingConfig getFileCrawlingConfig( - final Map keys) { - final FileCrawlingConfig fileCrawlingConfig = fileCrawlingConfigBhv - .selectEntity(cb -> { - cb.query().setId_Equal(Long.parseLong(keys.get("id"))); - setupEntityCondition(cb, keys); - }).orElse(null);//TODO + public FileCrawlingConfig getFileCrawlingConfig(final Map keys) { + final FileCrawlingConfig fileCrawlingConfig = fileCrawlingConfigBhv.selectEntity(cb -> { + cb.query().setId_Equal(Long.parseLong(keys.get("id"))); + setupEntityCondition(cb, keys); + }).orElse(null);//TODO if (fileCrawlingConfig == null) { // TODO exception? return null; @@ -75,24 +68,21 @@ public abstract class BsFileCrawlingConfigService { return fileCrawlingConfig; } - public void store(final FileCrawlingConfig fileCrawlingConfig) - throws CrudMessageException { + public void store(final FileCrawlingConfig fileCrawlingConfig) throws CrudMessageException { setupStoreCondition(fileCrawlingConfig); fileCrawlingConfigBhv.insertOrUpdate(fileCrawlingConfig); } - public void delete(final FileCrawlingConfig fileCrawlingConfig) - throws CrudMessageException { + public void delete(final FileCrawlingConfig fileCrawlingConfig) throws CrudMessageException { setupDeleteCondition(fileCrawlingConfig); fileCrawlingConfigBhv.delete(fileCrawlingConfig); } - protected void setupListCondition(final FileCrawlingConfigCB cb, - final FileCrawlingConfigPager fileCrawlingConfigPager) { + protected void setupListCondition(final FileCrawlingConfigCB cb, final FileCrawlingConfigPager fileCrawlingConfigPager) { if (fileCrawlingConfigPager.id != null) { cb.query().setId_Equal(Long.parseLong(fileCrawlingConfigPager.id)); @@ -100,15 +90,12 @@ public abstract class BsFileCrawlingConfigService { // TODO Long, Integer, String supported only. } - protected void setupEntityCondition(final FileCrawlingConfigCB cb, - final Map keys) { + protected void setupEntityCondition(final FileCrawlingConfigCB cb, final Map keys) { } - protected void setupStoreCondition( - final FileCrawlingConfig fileCrawlingConfig) { + protected void setupStoreCondition(final FileCrawlingConfig fileCrawlingConfig) { } - protected void setupDeleteCondition( - final FileCrawlingConfig fileCrawlingConfig) { + protected void setupDeleteCondition(final FileCrawlingConfig fileCrawlingConfig) { } } \ No newline at end of file diff --git a/src/main/java/org/codelibs/fess/crud/service/BsJobLogService.java b/src/main/java/org/codelibs/fess/crud/service/BsJobLogService.java index 35095c33c..be86917f5 100644 --- a/src/main/java/org/codelibs/fess/crud/service/BsJobLogService.java +++ b/src/main/java/org/codelibs/fess/crud/service/BsJobLogService.java @@ -41,16 +41,13 @@ public abstract class BsJobLogService { public List getJobLogList(final JobLogPager jobLogPager) { - final PagingResultBean jobLogList = jobLogBhv - .selectPage(cb -> { - cb.paging(jobLogPager.getPageSize(), - jobLogPager.getCurrentPageNumber()); - setupListCondition(cb, jobLogPager); - }); + final PagingResultBean jobLogList = jobLogBhv.selectPage(cb -> { + cb.paging(jobLogPager.getPageSize(), jobLogPager.getCurrentPageNumber()); + setupListCondition(cb, jobLogPager); + }); // update pager - Beans.copy(jobLogList, jobLogPager) - .includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); + Beans.copy(jobLogList, jobLogPager).includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); jobLogPager.setPageNumberList(jobLogList.pageRange(op -> { op.rangeSize(5); }).createPageNumberList()); @@ -85,8 +82,7 @@ public abstract class BsJobLogService { } - protected void setupListCondition(final JobLogCB cb, - final JobLogPager jobLogPager) { + protected void setupListCondition(final JobLogCB cb, final JobLogPager jobLogPager) { if (jobLogPager.id != null) { cb.query().setId_Equal(Long.parseLong(jobLogPager.id)); @@ -94,8 +90,7 @@ public abstract class BsJobLogService { // TODO Long, Integer, String supported only. } - protected void setupEntityCondition(final JobLogCB cb, - final Map keys) { + protected void setupEntityCondition(final JobLogCB cb, final Map keys) { } protected void setupStoreCondition(final JobLog jobLog) { diff --git a/src/main/java/org/codelibs/fess/crud/service/BsKeyMatchService.java b/src/main/java/org/codelibs/fess/crud/service/BsKeyMatchService.java index e46b261a6..bff71d547 100644 --- a/src/main/java/org/codelibs/fess/crud/service/BsKeyMatchService.java +++ b/src/main/java/org/codelibs/fess/crud/service/BsKeyMatchService.java @@ -41,16 +41,13 @@ public abstract class BsKeyMatchService { public List getKeyMatchList(final KeyMatchPager keyMatchPager) { - final PagingResultBean keyMatchList = keyMatchBhv - .selectPage(cb -> { - cb.paging(keyMatchPager.getPageSize(), - keyMatchPager.getCurrentPageNumber()); - setupListCondition(cb, keyMatchPager); - }); + final PagingResultBean keyMatchList = keyMatchBhv.selectPage(cb -> { + cb.paging(keyMatchPager.getPageSize(), keyMatchPager.getCurrentPageNumber()); + setupListCondition(cb, keyMatchPager); + }); // update pager - Beans.copy(keyMatchList, keyMatchPager) - .includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); + Beans.copy(keyMatchList, keyMatchPager).includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); keyMatchPager.setPageNumberList(keyMatchList.pageRange(op -> { op.rangeSize(5); }).createPageNumberList()); @@ -85,8 +82,7 @@ public abstract class BsKeyMatchService { } - protected void setupListCondition(final KeyMatchCB cb, - final KeyMatchPager keyMatchPager) { + protected void setupListCondition(final KeyMatchCB cb, final KeyMatchPager keyMatchPager) { if (keyMatchPager.id != null) { cb.query().setId_Equal(Long.parseLong(keyMatchPager.id)); @@ -94,8 +90,7 @@ public abstract class BsKeyMatchService { // TODO Long, Integer, String supported only. } - protected void setupEntityCondition(final KeyMatchCB cb, - final Map keys) { + protected void setupEntityCondition(final KeyMatchCB cb, final Map keys) { } protected void setupStoreCondition(final KeyMatch keyMatch) { diff --git a/src/main/java/org/codelibs/fess/crud/service/BsLabelTypeService.java b/src/main/java/org/codelibs/fess/crud/service/BsLabelTypeService.java index 6888a49cd..98668de1b 100644 --- a/src/main/java/org/codelibs/fess/crud/service/BsLabelTypeService.java +++ b/src/main/java/org/codelibs/fess/crud/service/BsLabelTypeService.java @@ -41,16 +41,13 @@ public abstract class BsLabelTypeService { public List getLabelTypeList(final LabelTypePager labelTypePager) { - final PagingResultBean labelTypeList = labelTypeBhv - .selectPage(cb -> { - cb.paging(labelTypePager.getPageSize(), - labelTypePager.getCurrentPageNumber()); - setupListCondition(cb, labelTypePager); - }); + final PagingResultBean labelTypeList = labelTypeBhv.selectPage(cb -> { + cb.paging(labelTypePager.getPageSize(), labelTypePager.getCurrentPageNumber()); + setupListCondition(cb, labelTypePager); + }); // update pager - Beans.copy(labelTypeList, labelTypePager) - .includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); + Beans.copy(labelTypeList, labelTypePager).includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); labelTypePager.setPageNumberList(labelTypeList.pageRange(op -> { op.rangeSize(5); }).createPageNumberList()); @@ -85,8 +82,7 @@ public abstract class BsLabelTypeService { } - protected void setupListCondition(final LabelTypeCB cb, - final LabelTypePager labelTypePager) { + protected void setupListCondition(final LabelTypeCB cb, final LabelTypePager labelTypePager) { if (labelTypePager.id != null) { cb.query().setId_Equal(Long.parseLong(labelTypePager.id)); @@ -94,8 +90,7 @@ public abstract class BsLabelTypeService { // TODO Long, Integer, String supported only. } - protected void setupEntityCondition(final LabelTypeCB cb, - final Map keys) { + protected void setupEntityCondition(final LabelTypeCB cb, final Map keys) { } protected void setupStoreCondition(final LabelType labelType) { diff --git a/src/main/java/org/codelibs/fess/crud/service/BsOverlappingHostService.java b/src/main/java/org/codelibs/fess/crud/service/BsOverlappingHostService.java index 44a193cf7..d61a8a96b 100644 --- a/src/main/java/org/codelibs/fess/crud/service/BsOverlappingHostService.java +++ b/src/main/java/org/codelibs/fess/crud/service/BsOverlappingHostService.java @@ -39,33 +39,27 @@ public abstract class BsOverlappingHostService { super(); } - public List getOverlappingHostList( - final OverlappingHostPager overlappingHostPager) { + public List getOverlappingHostList(final OverlappingHostPager overlappingHostPager) { - final PagingResultBean overlappingHostList = overlappingHostBhv - .selectPage(cb -> { - cb.paging(overlappingHostPager.getPageSize(), - overlappingHostPager.getCurrentPageNumber()); - setupListCondition(cb, overlappingHostPager); - }); + final PagingResultBean overlappingHostList = overlappingHostBhv.selectPage(cb -> { + cb.paging(overlappingHostPager.getPageSize(), overlappingHostPager.getCurrentPageNumber()); + setupListCondition(cb, overlappingHostPager); + }); // update pager - Beans.copy(overlappingHostList, overlappingHostPager) - .includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); - overlappingHostPager.setPageNumberList(overlappingHostList.pageRange( - op -> { - op.rangeSize(5); - }).createPageNumberList()); + Beans.copy(overlappingHostList, overlappingHostPager).includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); + overlappingHostPager.setPageNumberList(overlappingHostList.pageRange(op -> { + op.rangeSize(5); + }).createPageNumberList()); return overlappingHostList; } public OverlappingHost getOverlappingHost(final Map keys) { - final OverlappingHost overlappingHost = overlappingHostBhv - .selectEntity(cb -> { - cb.query().setId_Equal(Long.parseLong(keys.get("id"))); - setupEntityCondition(cb, keys); - }).orElse(null);//TODO + final OverlappingHost overlappingHost = overlappingHostBhv.selectEntity(cb -> { + cb.query().setId_Equal(Long.parseLong(keys.get("id"))); + setupEntityCondition(cb, keys); + }).orElse(null);//TODO if (overlappingHost == null) { // TODO exception? return null; @@ -74,24 +68,21 @@ public abstract class BsOverlappingHostService { return overlappingHost; } - public void store(final OverlappingHost overlappingHost) - throws CrudMessageException { + public void store(final OverlappingHost overlappingHost) throws CrudMessageException { setupStoreCondition(overlappingHost); overlappingHostBhv.insertOrUpdate(overlappingHost); } - public void delete(final OverlappingHost overlappingHost) - throws CrudMessageException { + public void delete(final OverlappingHost overlappingHost) throws CrudMessageException { setupDeleteCondition(overlappingHost); overlappingHostBhv.delete(overlappingHost); } - protected void setupListCondition(final OverlappingHostCB cb, - final OverlappingHostPager overlappingHostPager) { + protected void setupListCondition(final OverlappingHostCB cb, final OverlappingHostPager overlappingHostPager) { if (overlappingHostPager.id != null) { cb.query().setId_Equal(Long.parseLong(overlappingHostPager.id)); @@ -99,8 +90,7 @@ public abstract class BsOverlappingHostService { // TODO Long, Integer, String supported only. } - protected void setupEntityCondition(final OverlappingHostCB cb, - final Map keys) { + protected void setupEntityCondition(final OverlappingHostCB cb, final Map keys) { } protected void setupStoreCondition(final OverlappingHost overlappingHost) { diff --git a/src/main/java/org/codelibs/fess/crud/service/BsPathMappingService.java b/src/main/java/org/codelibs/fess/crud/service/BsPathMappingService.java index 7ba72e952..463f61384 100644 --- a/src/main/java/org/codelibs/fess/crud/service/BsPathMappingService.java +++ b/src/main/java/org/codelibs/fess/crud/service/BsPathMappingService.java @@ -39,19 +39,15 @@ public abstract class BsPathMappingService { super(); } - public List getPathMappingList( - final PathMappingPager pathMappingPager) { + public List getPathMappingList(final PathMappingPager pathMappingPager) { - final PagingResultBean pathMappingList = pathMappingBhv - .selectPage(cb -> { - cb.paging(pathMappingPager.getPageSize(), - pathMappingPager.getCurrentPageNumber()); - setupListCondition(cb, pathMappingPager); - }); + final PagingResultBean pathMappingList = pathMappingBhv.selectPage(cb -> { + cb.paging(pathMappingPager.getPageSize(), pathMappingPager.getCurrentPageNumber()); + setupListCondition(cb, pathMappingPager); + }); // update pager - Beans.copy(pathMappingList, pathMappingPager) - .includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); + Beans.copy(pathMappingList, pathMappingPager).includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); pathMappingPager.setPageNumberList(pathMappingList.pageRange(op -> { op.rangeSize(5); }).createPageNumberList()); @@ -72,24 +68,21 @@ public abstract class BsPathMappingService { return pathMapping; } - public void store(final PathMapping pathMapping) - throws CrudMessageException { + public void store(final PathMapping pathMapping) throws CrudMessageException { setupStoreCondition(pathMapping); pathMappingBhv.insertOrUpdate(pathMapping); } - public void delete(final PathMapping pathMapping) - throws CrudMessageException { + public void delete(final PathMapping pathMapping) throws CrudMessageException { setupDeleteCondition(pathMapping); pathMappingBhv.delete(pathMapping); } - protected void setupListCondition(final PathMappingCB cb, - final PathMappingPager pathMappingPager) { + protected void setupListCondition(final PathMappingCB cb, final PathMappingPager pathMappingPager) { if (pathMappingPager.id != null) { cb.query().setId_Equal(Long.parseLong(pathMappingPager.id)); @@ -97,8 +90,7 @@ public abstract class BsPathMappingService { // TODO Long, Integer, String supported only. } - protected void setupEntityCondition(final PathMappingCB cb, - final Map keys) { + protected void setupEntityCondition(final PathMappingCB cb, final Map keys) { } protected void setupStoreCondition(final PathMapping pathMapping) { diff --git a/src/main/java/org/codelibs/fess/crud/service/BsRequestHeaderService.java b/src/main/java/org/codelibs/fess/crud/service/BsRequestHeaderService.java index fc20521ca..95614be4c 100644 --- a/src/main/java/org/codelibs/fess/crud/service/BsRequestHeaderService.java +++ b/src/main/java/org/codelibs/fess/crud/service/BsRequestHeaderService.java @@ -39,33 +39,27 @@ public abstract class BsRequestHeaderService { super(); } - public List getRequestHeaderList( - final RequestHeaderPager requestHeaderPager) { + public List getRequestHeaderList(final RequestHeaderPager requestHeaderPager) { - final PagingResultBean requestHeaderList = requestHeaderBhv - .selectPage(cb -> { - cb.paging(requestHeaderPager.getPageSize(), - requestHeaderPager.getCurrentPageNumber()); - setupListCondition(cb, requestHeaderPager); - }); + final PagingResultBean requestHeaderList = requestHeaderBhv.selectPage(cb -> { + cb.paging(requestHeaderPager.getPageSize(), requestHeaderPager.getCurrentPageNumber()); + setupListCondition(cb, requestHeaderPager); + }); // update pager - Beans.copy(requestHeaderList, requestHeaderPager) - .includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); - requestHeaderPager.setPageNumberList(requestHeaderList.pageRange( - op -> { - op.rangeSize(5); - }).createPageNumberList()); + Beans.copy(requestHeaderList, requestHeaderPager).includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); + requestHeaderPager.setPageNumberList(requestHeaderList.pageRange(op -> { + op.rangeSize(5); + }).createPageNumberList()); return requestHeaderList; } public RequestHeader getRequestHeader(final Map keys) { - final RequestHeader requestHeader = requestHeaderBhv.selectEntity( - cb -> { - cb.query().setId_Equal(Long.parseLong(keys.get("id"))); - setupEntityCondition(cb, keys); - }).orElse(null);//TODO + final RequestHeader requestHeader = requestHeaderBhv.selectEntity(cb -> { + cb.query().setId_Equal(Long.parseLong(keys.get("id"))); + setupEntityCondition(cb, keys); + }).orElse(null);//TODO if (requestHeader == null) { // TODO exception? return null; @@ -74,24 +68,21 @@ public abstract class BsRequestHeaderService { return requestHeader; } - public void store(final RequestHeader requestHeader) - throws CrudMessageException { + public void store(final RequestHeader requestHeader) throws CrudMessageException { setupStoreCondition(requestHeader); requestHeaderBhv.insertOrUpdate(requestHeader); } - public void delete(final RequestHeader requestHeader) - throws CrudMessageException { + public void delete(final RequestHeader requestHeader) throws CrudMessageException { setupDeleteCondition(requestHeader); requestHeaderBhv.delete(requestHeader); } - protected void setupListCondition(final RequestHeaderCB cb, - final RequestHeaderPager requestHeaderPager) { + protected void setupListCondition(final RequestHeaderCB cb, final RequestHeaderPager requestHeaderPager) { if (requestHeaderPager.id != null) { cb.query().setId_Equal(Long.parseLong(requestHeaderPager.id)); @@ -99,8 +90,7 @@ public abstract class BsRequestHeaderService { // TODO Long, Integer, String supported only. } - protected void setupEntityCondition(final RequestHeaderCB cb, - final Map keys) { + protected void setupEntityCondition(final RequestHeaderCB cb, final Map keys) { } protected void setupStoreCondition(final RequestHeader requestHeader) { diff --git a/src/main/java/org/codelibs/fess/crud/service/BsRoleTypeService.java b/src/main/java/org/codelibs/fess/crud/service/BsRoleTypeService.java index a887177b0..78961ef53 100644 --- a/src/main/java/org/codelibs/fess/crud/service/BsRoleTypeService.java +++ b/src/main/java/org/codelibs/fess/crud/service/BsRoleTypeService.java @@ -41,16 +41,13 @@ public abstract class BsRoleTypeService { public List getRoleTypeList(final RoleTypePager roleTypePager) { - final PagingResultBean roleTypeList = roleTypeBhv - .selectPage(cb -> { - cb.paging(roleTypePager.getPageSize(), - roleTypePager.getCurrentPageNumber()); - setupListCondition(cb, roleTypePager); - }); + final PagingResultBean roleTypeList = roleTypeBhv.selectPage(cb -> { + cb.paging(roleTypePager.getPageSize(), roleTypePager.getCurrentPageNumber()); + setupListCondition(cb, roleTypePager); + }); // update pager - Beans.copy(roleTypeList, roleTypePager) - .includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); + Beans.copy(roleTypeList, roleTypePager).includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); roleTypePager.setPageNumberList(roleTypeList.pageRange(op -> { op.rangeSize(5); }).createPageNumberList()); @@ -85,8 +82,7 @@ public abstract class BsRoleTypeService { } - protected void setupListCondition(final RoleTypeCB cb, - final RoleTypePager roleTypePager) { + protected void setupListCondition(final RoleTypeCB cb, final RoleTypePager roleTypePager) { if (roleTypePager.id != null) { cb.query().setId_Equal(Long.parseLong(roleTypePager.id)); @@ -94,8 +90,7 @@ public abstract class BsRoleTypeService { // TODO Long, Integer, String supported only. } - protected void setupEntityCondition(final RoleTypeCB cb, - final Map keys) { + protected void setupEntityCondition(final RoleTypeCB cb, final Map keys) { } protected void setupStoreCondition(final RoleType roleType) { diff --git a/src/main/java/org/codelibs/fess/crud/service/BsScheduledJobService.java b/src/main/java/org/codelibs/fess/crud/service/BsScheduledJobService.java index 654341ef4..1404d9eab 100644 --- a/src/main/java/org/codelibs/fess/crud/service/BsScheduledJobService.java +++ b/src/main/java/org/codelibs/fess/crud/service/BsScheduledJobService.java @@ -39,19 +39,15 @@ public abstract class BsScheduledJobService { super(); } - public List getScheduledJobList( - final ScheduledJobPager scheduledJobPager) { + public List getScheduledJobList(final ScheduledJobPager scheduledJobPager) { - final PagingResultBean scheduledJobList = scheduledJobBhv - .selectPage(cb -> { - cb.paging(scheduledJobPager.getPageSize(), - scheduledJobPager.getCurrentPageNumber()); - setupListCondition(cb, scheduledJobPager); - }); + final PagingResultBean scheduledJobList = scheduledJobBhv.selectPage(cb -> { + cb.paging(scheduledJobPager.getPageSize(), scheduledJobPager.getCurrentPageNumber()); + setupListCondition(cb, scheduledJobPager); + }); // update pager - Beans.copy(scheduledJobList, scheduledJobPager) - .includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); + Beans.copy(scheduledJobList, scheduledJobPager).includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); scheduledJobPager.setPageNumberList(scheduledJobList.pageRange(op -> { op.rangeSize(5); }).createPageNumberList()); @@ -72,24 +68,21 @@ public abstract class BsScheduledJobService { return scheduledJob; } - public void store(final ScheduledJob scheduledJob) - throws CrudMessageException { + public void store(final ScheduledJob scheduledJob) throws CrudMessageException { setupStoreCondition(scheduledJob); scheduledJobBhv.insertOrUpdate(scheduledJob); } - public void delete(final ScheduledJob scheduledJob) - throws CrudMessageException { + public void delete(final ScheduledJob scheduledJob) throws CrudMessageException { setupDeleteCondition(scheduledJob); scheduledJobBhv.delete(scheduledJob); } - protected void setupListCondition(final ScheduledJobCB cb, - final ScheduledJobPager scheduledJobPager) { + protected void setupListCondition(final ScheduledJobCB cb, final ScheduledJobPager scheduledJobPager) { if (scheduledJobPager.id != null) { cb.query().setId_Equal(Long.parseLong(scheduledJobPager.id)); @@ -97,8 +90,7 @@ public abstract class BsScheduledJobService { // TODO Long, Integer, String supported only. } - protected void setupEntityCondition(final ScheduledJobCB cb, - final Map keys) { + protected void setupEntityCondition(final ScheduledJobCB cb, final Map keys) { } protected void setupStoreCondition(final ScheduledJob scheduledJob) { diff --git a/src/main/java/org/codelibs/fess/crud/service/BsSearchLogService.java b/src/main/java/org/codelibs/fess/crud/service/BsSearchLogService.java index 3007e2c6b..d69b1d29c 100644 --- a/src/main/java/org/codelibs/fess/crud/service/BsSearchLogService.java +++ b/src/main/java/org/codelibs/fess/crud/service/BsSearchLogService.java @@ -41,16 +41,13 @@ public abstract class BsSearchLogService { public List getSearchLogList(final SearchLogPager searchLogPager) { - final PagingResultBean searchLogList = searchLogBhv - .selectPage(cb -> { - cb.paging(searchLogPager.getPageSize(), - searchLogPager.getCurrentPageNumber()); - setupListCondition(cb, searchLogPager); - }); + final PagingResultBean searchLogList = searchLogBhv.selectPage(cb -> { + cb.paging(searchLogPager.getPageSize(), searchLogPager.getCurrentPageNumber()); + setupListCondition(cb, searchLogPager); + }); // update pager - Beans.copy(searchLogList, searchLogPager) - .includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); + Beans.copy(searchLogList, searchLogPager).includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); searchLogPager.setPageNumberList(searchLogList.pageRange(op -> { op.rangeSize(5); }).createPageNumberList()); @@ -85,8 +82,7 @@ public abstract class BsSearchLogService { } - protected void setupListCondition(final SearchLogCB cb, - final SearchLogPager searchLogPager) { + protected void setupListCondition(final SearchLogCB cb, final SearchLogPager searchLogPager) { if (searchLogPager.id != null) { cb.query().setId_Equal(Long.parseLong(searchLogPager.id)); @@ -94,8 +90,7 @@ public abstract class BsSearchLogService { // TODO Long, Integer, String supported only. } - protected void setupEntityCondition(final SearchLogCB cb, - final Map keys) { + protected void setupEntityCondition(final SearchLogCB cb, final Map keys) { } protected void setupStoreCondition(final SearchLog searchLog) { diff --git a/src/main/java/org/codelibs/fess/crud/service/BsSuggestBadWordService.java b/src/main/java/org/codelibs/fess/crud/service/BsSuggestBadWordService.java index 938c65d7c..88f8435d5 100644 --- a/src/main/java/org/codelibs/fess/crud/service/BsSuggestBadWordService.java +++ b/src/main/java/org/codelibs/fess/crud/service/BsSuggestBadWordService.java @@ -39,33 +39,27 @@ public abstract class BsSuggestBadWordService { super(); } - public List getSuggestBadWordList( - final SuggestBadWordPager suggestBadWordPager) { + public List getSuggestBadWordList(final SuggestBadWordPager suggestBadWordPager) { - final PagingResultBean suggestBadWordList = suggestBadWordBhv - .selectPage(cb -> { - cb.paging(suggestBadWordPager.getPageSize(), - suggestBadWordPager.getCurrentPageNumber()); - setupListCondition(cb, suggestBadWordPager); - }); + final PagingResultBean suggestBadWordList = suggestBadWordBhv.selectPage(cb -> { + cb.paging(suggestBadWordPager.getPageSize(), suggestBadWordPager.getCurrentPageNumber()); + setupListCondition(cb, suggestBadWordPager); + }); // update pager - Beans.copy(suggestBadWordList, suggestBadWordPager) - .includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); - suggestBadWordPager.setPageNumberList(suggestBadWordList.pageRange( - op -> { - op.rangeSize(5); - }).createPageNumberList()); + Beans.copy(suggestBadWordList, suggestBadWordPager).includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); + suggestBadWordPager.setPageNumberList(suggestBadWordList.pageRange(op -> { + op.rangeSize(5); + }).createPageNumberList()); return suggestBadWordList; } public SuggestBadWord getSuggestBadWord(final Map keys) { - final SuggestBadWord suggestBadWord = suggestBadWordBhv.selectEntity( - cb -> { - cb.query().setId_Equal(Long.parseLong(keys.get("id"))); - setupEntityCondition(cb, keys); - }).orElse(null);//TODO + final SuggestBadWord suggestBadWord = suggestBadWordBhv.selectEntity(cb -> { + cb.query().setId_Equal(Long.parseLong(keys.get("id"))); + setupEntityCondition(cb, keys); + }).orElse(null);//TODO if (suggestBadWord == null) { // TODO exception? return null; @@ -74,24 +68,21 @@ public abstract class BsSuggestBadWordService { return suggestBadWord; } - public void store(final SuggestBadWord suggestBadWord) - throws CrudMessageException { + public void store(final SuggestBadWord suggestBadWord) throws CrudMessageException { setupStoreCondition(suggestBadWord); suggestBadWordBhv.insertOrUpdate(suggestBadWord); } - public void delete(final SuggestBadWord suggestBadWord) - throws CrudMessageException { + public void delete(final SuggestBadWord suggestBadWord) throws CrudMessageException { setupDeleteCondition(suggestBadWord); suggestBadWordBhv.delete(suggestBadWord); } - protected void setupListCondition(final SuggestBadWordCB cb, - final SuggestBadWordPager suggestBadWordPager) { + protected void setupListCondition(final SuggestBadWordCB cb, final SuggestBadWordPager suggestBadWordPager) { if (suggestBadWordPager.id != null) { cb.query().setId_Equal(Long.parseLong(suggestBadWordPager.id)); @@ -99,8 +90,7 @@ public abstract class BsSuggestBadWordService { // TODO Long, Integer, String supported only. } - protected void setupEntityCondition(final SuggestBadWordCB cb, - final Map keys) { + protected void setupEntityCondition(final SuggestBadWordCB cb, final Map keys) { } protected void setupStoreCondition(final SuggestBadWord suggestBadWord) { diff --git a/src/main/java/org/codelibs/fess/crud/service/BsSuggestElevateWordService.java b/src/main/java/org/codelibs/fess/crud/service/BsSuggestElevateWordService.java index a957ba5cf..9f5658f10 100644 --- a/src/main/java/org/codelibs/fess/crud/service/BsSuggestElevateWordService.java +++ b/src/main/java/org/codelibs/fess/crud/service/BsSuggestElevateWordService.java @@ -39,34 +39,27 @@ public abstract class BsSuggestElevateWordService { super(); } - public List getSuggestElevateWordList( - final SuggestElevateWordPager suggestElevateWordPager) { + public List getSuggestElevateWordList(final SuggestElevateWordPager suggestElevateWordPager) { - final PagingResultBean suggestElevateWordList = suggestElevateWordBhv - .selectPage(cb -> { - cb.paging(suggestElevateWordPager.getPageSize(), - suggestElevateWordPager.getCurrentPageNumber()); - setupListCondition(cb, suggestElevateWordPager); - }); + final PagingResultBean suggestElevateWordList = suggestElevateWordBhv.selectPage(cb -> { + cb.paging(suggestElevateWordPager.getPageSize(), suggestElevateWordPager.getCurrentPageNumber()); + setupListCondition(cb, suggestElevateWordPager); + }); // update pager - Beans.copy(suggestElevateWordList, suggestElevateWordPager) - .includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); - suggestElevateWordPager.setPageNumberList(suggestElevateWordList - .pageRange(op -> { - op.rangeSize(5); - }).createPageNumberList()); + Beans.copy(suggestElevateWordList, suggestElevateWordPager).includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); + suggestElevateWordPager.setPageNumberList(suggestElevateWordList.pageRange(op -> { + op.rangeSize(5); + }).createPageNumberList()); return suggestElevateWordList; } - public SuggestElevateWord getSuggestElevateWord( - final Map keys) { - final SuggestElevateWord suggestElevateWord = suggestElevateWordBhv - .selectEntity(cb -> { - cb.query().setId_Equal(Long.parseLong(keys.get("id"))); - setupEntityCondition(cb, keys); - }).orElse(null);//TODO + public SuggestElevateWord getSuggestElevateWord(final Map keys) { + final SuggestElevateWord suggestElevateWord = suggestElevateWordBhv.selectEntity(cb -> { + cb.query().setId_Equal(Long.parseLong(keys.get("id"))); + setupEntityCondition(cb, keys); + }).orElse(null);//TODO if (suggestElevateWord == null) { // TODO exception? return null; @@ -75,24 +68,21 @@ public abstract class BsSuggestElevateWordService { return suggestElevateWord; } - public void store(final SuggestElevateWord suggestElevateWord) - throws CrudMessageException { + public void store(final SuggestElevateWord suggestElevateWord) throws CrudMessageException { setupStoreCondition(suggestElevateWord); suggestElevateWordBhv.insertOrUpdate(suggestElevateWord); } - public void delete(final SuggestElevateWord suggestElevateWord) - throws CrudMessageException { + public void delete(final SuggestElevateWord suggestElevateWord) throws CrudMessageException { setupDeleteCondition(suggestElevateWord); suggestElevateWordBhv.delete(suggestElevateWord); } - protected void setupListCondition(final SuggestElevateWordCB cb, - final SuggestElevateWordPager suggestElevateWordPager) { + protected void setupListCondition(final SuggestElevateWordCB cb, final SuggestElevateWordPager suggestElevateWordPager) { if (suggestElevateWordPager.id != null) { cb.query().setId_Equal(Long.parseLong(suggestElevateWordPager.id)); @@ -100,15 +90,12 @@ public abstract class BsSuggestElevateWordService { // TODO Long, Integer, String supported only. } - protected void setupEntityCondition(final SuggestElevateWordCB cb, - final Map keys) { + protected void setupEntityCondition(final SuggestElevateWordCB cb, final Map keys) { } - protected void setupStoreCondition( - final SuggestElevateWord suggestElevateWord) { + protected void setupStoreCondition(final SuggestElevateWord suggestElevateWord) { } - protected void setupDeleteCondition( - final SuggestElevateWord suggestElevateWord) { + protected void setupDeleteCondition(final SuggestElevateWord suggestElevateWord) { } } \ No newline at end of file diff --git a/src/main/java/org/codelibs/fess/crud/service/BsUserInfoService.java b/src/main/java/org/codelibs/fess/crud/service/BsUserInfoService.java index 9d8830e0a..7c501cae2 100644 --- a/src/main/java/org/codelibs/fess/crud/service/BsUserInfoService.java +++ b/src/main/java/org/codelibs/fess/crud/service/BsUserInfoService.java @@ -41,16 +41,13 @@ public abstract class BsUserInfoService { public List getUserInfoList(final UserInfoPager userInfoPager) { - final PagingResultBean userInfoList = userInfoBhv - .selectPage(cb -> { - cb.paging(userInfoPager.getPageSize(), - userInfoPager.getCurrentPageNumber()); - setupListCondition(cb, userInfoPager); - }); + final PagingResultBean userInfoList = userInfoBhv.selectPage(cb -> { + cb.paging(userInfoPager.getPageSize(), userInfoPager.getCurrentPageNumber()); + setupListCondition(cb, userInfoPager); + }); // update pager - Beans.copy(userInfoList, userInfoPager) - .includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); + Beans.copy(userInfoList, userInfoPager).includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); userInfoPager.setPageNumberList(userInfoList.pageRange(op -> { op.rangeSize(5); }).createPageNumberList()); @@ -85,8 +82,7 @@ public abstract class BsUserInfoService { } - protected void setupListCondition(final UserInfoCB cb, - final UserInfoPager userInfoPager) { + protected void setupListCondition(final UserInfoCB cb, final UserInfoPager userInfoPager) { if (userInfoPager.id != null) { cb.query().setId_Equal(Long.parseLong(userInfoPager.id)); @@ -94,8 +90,7 @@ public abstract class BsUserInfoService { // TODO Long, Integer, String supported only. } - protected void setupEntityCondition(final UserInfoCB cb, - final Map keys) { + protected void setupEntityCondition(final UserInfoCB cb, final Map keys) { } protected void setupStoreCondition(final UserInfo userInfo) { diff --git a/src/main/java/org/codelibs/fess/crud/service/BsWebAuthenticationService.java b/src/main/java/org/codelibs/fess/crud/service/BsWebAuthenticationService.java index 81f641342..696c60edb 100644 --- a/src/main/java/org/codelibs/fess/crud/service/BsWebAuthenticationService.java +++ b/src/main/java/org/codelibs/fess/crud/service/BsWebAuthenticationService.java @@ -39,33 +39,27 @@ public abstract class BsWebAuthenticationService { super(); } - public List getWebAuthenticationList( - final WebAuthenticationPager webAuthenticationPager) { + public List getWebAuthenticationList(final WebAuthenticationPager webAuthenticationPager) { - final PagingResultBean webAuthenticationList = webAuthenticationBhv - .selectPage(cb -> { - cb.paging(webAuthenticationPager.getPageSize(), - webAuthenticationPager.getCurrentPageNumber()); - setupListCondition(cb, webAuthenticationPager); - }); + final PagingResultBean webAuthenticationList = webAuthenticationBhv.selectPage(cb -> { + cb.paging(webAuthenticationPager.getPageSize(), webAuthenticationPager.getCurrentPageNumber()); + setupListCondition(cb, webAuthenticationPager); + }); // update pager - Beans.copy(webAuthenticationList, webAuthenticationPager) - .includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); - webAuthenticationPager.setPageNumberList(webAuthenticationList - .pageRange(op -> { - op.rangeSize(5); - }).createPageNumberList()); + Beans.copy(webAuthenticationList, webAuthenticationPager).includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); + webAuthenticationPager.setPageNumberList(webAuthenticationList.pageRange(op -> { + op.rangeSize(5); + }).createPageNumberList()); return webAuthenticationList; } public WebAuthentication getWebAuthentication(final Map keys) { - final WebAuthentication webAuthentication = webAuthenticationBhv - .selectEntity(cb -> { - cb.query().setId_Equal(Long.parseLong(keys.get("id"))); - setupEntityCondition(cb, keys); - }).orElse(null);//TODO + final WebAuthentication webAuthentication = webAuthenticationBhv.selectEntity(cb -> { + cb.query().setId_Equal(Long.parseLong(keys.get("id"))); + setupEntityCondition(cb, keys); + }).orElse(null);//TODO if (webAuthentication == null) { // TODO exception? return null; @@ -74,24 +68,21 @@ public abstract class BsWebAuthenticationService { return webAuthentication; } - public void store(final WebAuthentication webAuthentication) - throws CrudMessageException { + public void store(final WebAuthentication webAuthentication) throws CrudMessageException { setupStoreCondition(webAuthentication); webAuthenticationBhv.insertOrUpdate(webAuthentication); } - public void delete(final WebAuthentication webAuthentication) - throws CrudMessageException { + public void delete(final WebAuthentication webAuthentication) throws CrudMessageException { setupDeleteCondition(webAuthentication); webAuthenticationBhv.delete(webAuthentication); } - protected void setupListCondition(final WebAuthenticationCB cb, - final WebAuthenticationPager webAuthenticationPager) { + protected void setupListCondition(final WebAuthenticationCB cb, final WebAuthenticationPager webAuthenticationPager) { if (webAuthenticationPager.id != null) { cb.query().setId_Equal(Long.parseLong(webAuthenticationPager.id)); @@ -99,14 +90,12 @@ public abstract class BsWebAuthenticationService { // TODO Long, Integer, String supported only. } - protected void setupEntityCondition(final WebAuthenticationCB cb, - final Map keys) { + protected void setupEntityCondition(final WebAuthenticationCB cb, final Map keys) { } protected void setupStoreCondition(final WebAuthentication webAuthentication) { } - protected void setupDeleteCondition( - final WebAuthentication webAuthentication) { + protected void setupDeleteCondition(final WebAuthentication webAuthentication) { } } \ No newline at end of file diff --git a/src/main/java/org/codelibs/fess/crud/service/BsWebCrawlingConfigService.java b/src/main/java/org/codelibs/fess/crud/service/BsWebCrawlingConfigService.java index fd1e61684..c6a2595ce 100644 --- a/src/main/java/org/codelibs/fess/crud/service/BsWebCrawlingConfigService.java +++ b/src/main/java/org/codelibs/fess/crud/service/BsWebCrawlingConfigService.java @@ -39,33 +39,27 @@ public abstract class BsWebCrawlingConfigService { super(); } - public List getWebCrawlingConfigList( - final WebCrawlingConfigPager webCrawlingConfigPager) { + public List getWebCrawlingConfigList(final WebCrawlingConfigPager webCrawlingConfigPager) { - final PagingResultBean webCrawlingConfigList = webCrawlingConfigBhv - .selectPage(cb -> { - cb.paging(webCrawlingConfigPager.getPageSize(), - webCrawlingConfigPager.getCurrentPageNumber()); - setupListCondition(cb, webCrawlingConfigPager); - }); + final PagingResultBean webCrawlingConfigList = webCrawlingConfigBhv.selectPage(cb -> { + cb.paging(webCrawlingConfigPager.getPageSize(), webCrawlingConfigPager.getCurrentPageNumber()); + setupListCondition(cb, webCrawlingConfigPager); + }); // update pager - Beans.copy(webCrawlingConfigList, webCrawlingConfigPager) - .includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); - webCrawlingConfigPager.setPageNumberList(webCrawlingConfigList - .pageRange(op -> { - op.rangeSize(5); - }).createPageNumberList()); + Beans.copy(webCrawlingConfigList, webCrawlingConfigPager).includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); + webCrawlingConfigPager.setPageNumberList(webCrawlingConfigList.pageRange(op -> { + op.rangeSize(5); + }).createPageNumberList()); return webCrawlingConfigList; } public WebCrawlingConfig getWebCrawlingConfig(final Map keys) { - final WebCrawlingConfig webCrawlingConfig = webCrawlingConfigBhv - .selectEntity(cb -> { - cb.query().setId_Equal(Long.parseLong(keys.get("id"))); - setupEntityCondition(cb, keys); - }).orElse(null);//TODO + final WebCrawlingConfig webCrawlingConfig = webCrawlingConfigBhv.selectEntity(cb -> { + cb.query().setId_Equal(Long.parseLong(keys.get("id"))); + setupEntityCondition(cb, keys); + }).orElse(null);//TODO if (webCrawlingConfig == null) { // TODO exception? return null; @@ -74,24 +68,21 @@ public abstract class BsWebCrawlingConfigService { return webCrawlingConfig; } - public void store(final WebCrawlingConfig webCrawlingConfig) - throws CrudMessageException { + public void store(final WebCrawlingConfig webCrawlingConfig) throws CrudMessageException { setupStoreCondition(webCrawlingConfig); webCrawlingConfigBhv.insertOrUpdate(webCrawlingConfig); } - public void delete(final WebCrawlingConfig webCrawlingConfig) - throws CrudMessageException { + public void delete(final WebCrawlingConfig webCrawlingConfig) throws CrudMessageException { setupDeleteCondition(webCrawlingConfig); webCrawlingConfigBhv.delete(webCrawlingConfig); } - protected void setupListCondition(final WebCrawlingConfigCB cb, - final WebCrawlingConfigPager webCrawlingConfigPager) { + protected void setupListCondition(final WebCrawlingConfigCB cb, final WebCrawlingConfigPager webCrawlingConfigPager) { if (webCrawlingConfigPager.id != null) { cb.query().setId_Equal(Long.parseLong(webCrawlingConfigPager.id)); @@ -99,14 +90,12 @@ public abstract class BsWebCrawlingConfigService { // TODO Long, Integer, String supported only. } - protected void setupEntityCondition(final WebCrawlingConfigCB cb, - final Map keys) { + protected void setupEntityCondition(final WebCrawlingConfigCB cb, final Map keys) { } protected void setupStoreCondition(final WebCrawlingConfig webCrawlingConfig) { } - protected void setupDeleteCondition( - final WebCrawlingConfig webCrawlingConfig) { + protected void setupDeleteCondition(final WebCrawlingConfig webCrawlingConfig) { } } \ No newline at end of file diff --git a/src/main/java/org/codelibs/fess/crud/util/SAStrutsUtil.java b/src/main/java/org/codelibs/fess/crud/util/SAStrutsUtil.java index 367ed7615..82fde7f96 100644 --- a/src/main/java/org/codelibs/fess/crud/util/SAStrutsUtil.java +++ b/src/main/java/org/codelibs/fess/crud/util/SAStrutsUtil.java @@ -32,8 +32,7 @@ public class SAStrutsUtil { addMessage(RequestUtil.getRequest(), key); } - public static void addMessage(final HttpServletRequest request, - final String key) { + public static void addMessage(final HttpServletRequest request, final String key) { final ActionMessages msgs = new ActionMessages(); msgs.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(key)); ActionMessagesUtil.saveMessages(request, msgs); @@ -43,8 +42,7 @@ public class SAStrutsUtil { addMessage(RequestUtil.getRequest(), key, values); } - public static void addMessage(final HttpServletRequest request, - final String key, final Object... values) { + public static void addMessage(final HttpServletRequest request, final String key, final Object... values) { final ActionMessages msgs = new ActionMessages(); msgs.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(key, values)); ActionMessagesUtil.saveMessages(request, msgs); @@ -54,20 +52,17 @@ public class SAStrutsUtil { addSessionMessage(RequestUtil.getRequest(), key); } - public static void addSessionMessage(final HttpServletRequest request, - final String key) { + public static void addSessionMessage(final HttpServletRequest request, final String key) { final ActionMessages msgs = new ActionMessages(); msgs.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(key)); ActionMessagesUtil.saveMessages(request.getSession(), msgs); } - public static void addSessionMessage(final String key, - final Object... values) { + public static void addSessionMessage(final String key, final Object... values) { addSessionMessage(RequestUtil.getRequest(), key, values); } - public static void addSessionMessage(final HttpServletRequest request, - final String key, final Object... values) { + public static void addSessionMessage(final HttpServletRequest request, final String key, final Object... values) { final ActionMessages msgs = new ActionMessages(); msgs.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(key, values)); ActionMessagesUtil.saveMessages(request.getSession(), msgs); diff --git a/src/main/java/org/codelibs/fess/db/exbhv/DataConfigToLabelTypeMappingBhv.java b/src/main/java/org/codelibs/fess/db/exbhv/DataConfigToLabelTypeMappingBhv.java index 675078969..1286d1d42 100644 --- a/src/main/java/org/codelibs/fess/db/exbhv/DataConfigToLabelTypeMappingBhv.java +++ b/src/main/java/org/codelibs/fess/db/exbhv/DataConfigToLabelTypeMappingBhv.java @@ -26,6 +26,5 @@ import org.codelibs.fess.db.bsbhv.BsDataConfigToLabelTypeMappingBhv; *

* @author DBFlute(AutoGenerator) */ -public class DataConfigToLabelTypeMappingBhv extends - BsDataConfigToLabelTypeMappingBhv { +public class DataConfigToLabelTypeMappingBhv extends BsDataConfigToLabelTypeMappingBhv { } diff --git a/src/main/java/org/codelibs/fess/db/exbhv/DataConfigToRoleTypeMappingBhv.java b/src/main/java/org/codelibs/fess/db/exbhv/DataConfigToRoleTypeMappingBhv.java index 79ced2b2b..da8f904e0 100644 --- a/src/main/java/org/codelibs/fess/db/exbhv/DataConfigToRoleTypeMappingBhv.java +++ b/src/main/java/org/codelibs/fess/db/exbhv/DataConfigToRoleTypeMappingBhv.java @@ -26,6 +26,5 @@ import org.codelibs.fess.db.bsbhv.BsDataConfigToRoleTypeMappingBhv; *

* @author DBFlute(AutoGenerator) */ -public class DataConfigToRoleTypeMappingBhv extends - BsDataConfigToRoleTypeMappingBhv { +public class DataConfigToRoleTypeMappingBhv extends BsDataConfigToRoleTypeMappingBhv { } diff --git a/src/main/java/org/codelibs/fess/db/exbhv/FileConfigToLabelTypeMappingBhv.java b/src/main/java/org/codelibs/fess/db/exbhv/FileConfigToLabelTypeMappingBhv.java index 596db9707..a4f406c71 100644 --- a/src/main/java/org/codelibs/fess/db/exbhv/FileConfigToLabelTypeMappingBhv.java +++ b/src/main/java/org/codelibs/fess/db/exbhv/FileConfigToLabelTypeMappingBhv.java @@ -26,6 +26,5 @@ import org.codelibs.fess.db.bsbhv.BsFileConfigToLabelTypeMappingBhv; *

* @author DBFlute(AutoGenerator) */ -public class FileConfigToLabelTypeMappingBhv extends - BsFileConfigToLabelTypeMappingBhv { +public class FileConfigToLabelTypeMappingBhv extends BsFileConfigToLabelTypeMappingBhv { } diff --git a/src/main/java/org/codelibs/fess/db/exbhv/FileConfigToRoleTypeMappingBhv.java b/src/main/java/org/codelibs/fess/db/exbhv/FileConfigToRoleTypeMappingBhv.java index f2616cf7b..21b9863cf 100644 --- a/src/main/java/org/codelibs/fess/db/exbhv/FileConfigToRoleTypeMappingBhv.java +++ b/src/main/java/org/codelibs/fess/db/exbhv/FileConfigToRoleTypeMappingBhv.java @@ -26,6 +26,5 @@ import org.codelibs.fess.db.bsbhv.BsFileConfigToRoleTypeMappingBhv; *

* @author DBFlute(AutoGenerator) */ -public class FileConfigToRoleTypeMappingBhv extends - BsFileConfigToRoleTypeMappingBhv { +public class FileConfigToRoleTypeMappingBhv extends BsFileConfigToRoleTypeMappingBhv { } diff --git a/src/main/java/org/codelibs/fess/db/exbhv/LabelTypeToRoleTypeMappingBhv.java b/src/main/java/org/codelibs/fess/db/exbhv/LabelTypeToRoleTypeMappingBhv.java index f7289c32e..433940378 100644 --- a/src/main/java/org/codelibs/fess/db/exbhv/LabelTypeToRoleTypeMappingBhv.java +++ b/src/main/java/org/codelibs/fess/db/exbhv/LabelTypeToRoleTypeMappingBhv.java @@ -26,6 +26,5 @@ import org.codelibs.fess.db.bsbhv.BsLabelTypeToRoleTypeMappingBhv; *

* @author DBFlute(AutoGenerator) */ -public class LabelTypeToRoleTypeMappingBhv extends - BsLabelTypeToRoleTypeMappingBhv { +public class LabelTypeToRoleTypeMappingBhv extends BsLabelTypeToRoleTypeMappingBhv { } diff --git a/src/main/java/org/codelibs/fess/db/exbhv/WebConfigToLabelTypeMappingBhv.java b/src/main/java/org/codelibs/fess/db/exbhv/WebConfigToLabelTypeMappingBhv.java index a0f0f4cdc..62e5293f8 100644 --- a/src/main/java/org/codelibs/fess/db/exbhv/WebConfigToLabelTypeMappingBhv.java +++ b/src/main/java/org/codelibs/fess/db/exbhv/WebConfigToLabelTypeMappingBhv.java @@ -26,6 +26,5 @@ import org.codelibs.fess.db.bsbhv.BsWebConfigToLabelTypeMappingBhv; *

* @author DBFlute(AutoGenerator) */ -public class WebConfigToLabelTypeMappingBhv extends - BsWebConfigToLabelTypeMappingBhv { +public class WebConfigToLabelTypeMappingBhv extends BsWebConfigToLabelTypeMappingBhv { } diff --git a/src/main/java/org/codelibs/fess/db/exbhv/WebConfigToRoleTypeMappingBhv.java b/src/main/java/org/codelibs/fess/db/exbhv/WebConfigToRoleTypeMappingBhv.java index 5a1914b7a..d84dc6844 100644 --- a/src/main/java/org/codelibs/fess/db/exbhv/WebConfigToRoleTypeMappingBhv.java +++ b/src/main/java/org/codelibs/fess/db/exbhv/WebConfigToRoleTypeMappingBhv.java @@ -26,6 +26,5 @@ import org.codelibs.fess.db.bsbhv.BsWebConfigToRoleTypeMappingBhv; *

* @author DBFlute(AutoGenerator) */ -public class WebConfigToRoleTypeMappingBhv extends - BsWebConfigToRoleTypeMappingBhv { +public class WebConfigToRoleTypeMappingBhv extends BsWebConfigToRoleTypeMappingBhv { } diff --git a/src/main/java/org/codelibs/fess/db/exentity/ClickLog.java b/src/main/java/org/codelibs/fess/db/exentity/ClickLog.java index 57f0d398f..f938daf69 100644 --- a/src/main/java/org/codelibs/fess/db/exentity/ClickLog.java +++ b/src/main/java/org/codelibs/fess/db/exentity/ClickLog.java @@ -60,8 +60,7 @@ public class ClickLog extends BsClickLog { } public String getRequestedTimeForList() { - final SimpleDateFormat sdf = new SimpleDateFormat( - Constants.DEFAULT_DATETIME_FORMAT); + final SimpleDateFormat sdf = new SimpleDateFormat(Constants.DEFAULT_DATETIME_FORMAT); if (getRequestedTime() != null) { return sdf.format(getRequestedTime()); } @@ -86,10 +85,8 @@ public class ClickLog extends BsClickLog { @Override public String toString() { - return "ClickLog [queryRequestedTime=" + queryRequestedTime - + ", userSessionId=" + userSessionId + ", docId=" + docId - + ", clickCount=" + clickCount + ", _id=" + _id - + ", _searchId=" + _searchId + ", _url=" + _url - + ", _requestedTime=" + _requestedTime + "]"; + return "ClickLog [queryRequestedTime=" + queryRequestedTime + ", userSessionId=" + userSessionId + ", docId=" + docId + + ", clickCount=" + clickCount + ", _id=" + _id + ", _searchId=" + _searchId + ", _url=" + _url + ", _requestedTime=" + + _requestedTime + "]"; } } diff --git a/src/main/java/org/codelibs/fess/db/exentity/CrawlingSessionInfo.java b/src/main/java/org/codelibs/fess/db/exentity/CrawlingSessionInfo.java index a4de8202f..bb40a361f 100644 --- a/src/main/java/org/codelibs/fess/db/exentity/CrawlingSessionInfo.java +++ b/src/main/java/org/codelibs/fess/db/exentity/CrawlingSessionInfo.java @@ -40,8 +40,7 @@ public class CrawlingSessionInfo extends BsCrawlingSessionInfo { public String getKeyMsg() { final Locale locale = RequestUtil.getRequest().getLocale(); - final String message = MessageResourcesUtil.getMessage(locale, - "labels.crawling_session_" + getKey()); + final String message = MessageResourcesUtil.getMessage(locale, "labels.crawling_session_" + getKey()); if (message == null || message.startsWith("???")) { return getKey(); } diff --git a/src/main/java/org/codelibs/fess/db/exentity/DataConfigToLabelTypeMapping.java b/src/main/java/org/codelibs/fess/db/exentity/DataConfigToLabelTypeMapping.java index 47a6dcdac..56f66bc3d 100644 --- a/src/main/java/org/codelibs/fess/db/exentity/DataConfigToLabelTypeMapping.java +++ b/src/main/java/org/codelibs/fess/db/exentity/DataConfigToLabelTypeMapping.java @@ -26,8 +26,7 @@ import org.codelibs.fess.db.bsentity.BsDataConfigToLabelTypeMapping; *

* @author DBFlute(AutoGenerator) */ -public class DataConfigToLabelTypeMapping extends - BsDataConfigToLabelTypeMapping { +public class DataConfigToLabelTypeMapping extends BsDataConfigToLabelTypeMapping { /** Serial version UID. (Default) */ private static final long serialVersionUID = 1L; diff --git a/src/main/java/org/codelibs/fess/db/exentity/DataCrawlingConfig.java b/src/main/java/org/codelibs/fess/db/exentity/DataCrawlingConfig.java index 67a471bf2..be1cfafcd 100644 --- a/src/main/java/org/codelibs/fess/db/exentity/DataCrawlingConfig.java +++ b/src/main/java/org/codelibs/fess/db/exentity/DataCrawlingConfig.java @@ -54,14 +54,12 @@ import org.slf4j.LoggerFactory; *

* @author DBFlute(AutoGenerator) */ -public class DataCrawlingConfig extends BsDataCrawlingConfig implements - CrawlingConfig { +public class DataCrawlingConfig extends BsDataCrawlingConfig implements CrawlingConfig { /** Serial version UID. (Default) */ private static final long serialVersionUID = 1L; - private static final Logger logger = LoggerFactory - .getLogger(DataCrawlingConfig.class); + private static final Logger logger = LoggerFactory.getLogger(DataCrawlingConfig.class); private static final String S2ROBOT_WEB_HEADER_PREFIX = "s2robot.web.header."; @@ -156,8 +154,7 @@ public class DataCrawlingConfig extends BsDataCrawlingConfig implements if (value != null) { try { _boost = new BigDecimal(value); - } catch (final Exception e) { - } + } catch (final Exception e) {} } } @@ -187,8 +184,7 @@ public class DataCrawlingConfig extends BsDataCrawlingConfig implements } @Override - public void initializeClientFactory( - final S2RobotClientFactory robotClientFactory) { + public void initializeClientFactory(final S2RobotClientFactory robotClientFactory) { final Map paramMap = getHandlerParameterMap(); final Map factoryParamMap = new HashMap(); @@ -198,9 +194,7 @@ public class DataCrawlingConfig extends BsDataCrawlingConfig implements for (final Map.Entry entry : paramMap.entrySet()) { final String key = entry.getKey(); if (key.startsWith(S2ROBOT_PARAM_PREFIX)) { - factoryParamMap.put( - key.substring(S2ROBOT_PARAM_PREFIX.length()), - entry.getValue()); + factoryParamMap.put(key.substring(S2ROBOT_PARAM_PREFIX.length()), entry.getValue()); } } @@ -216,18 +210,12 @@ public class DataCrawlingConfig extends BsDataCrawlingConfig implements final String[] webAuthNames = webAuthStr.split(","); final List basicAuthList = new ArrayList(); for (final String webAuthName : webAuthNames) { - final String scheme = paramMap.get(S2ROBOT_WEB_AUTH + "." - + webAuthName + ".scheme"); - final String hostname = paramMap.get(S2ROBOT_WEB_AUTH + "." - + webAuthName + ".host"); - final String port = paramMap.get(S2ROBOT_WEB_AUTH + "." - + webAuthName + ".port"); - final String realm = paramMap.get(S2ROBOT_WEB_AUTH + "." - + webAuthName + ".realm"); - final String username = paramMap.get(S2ROBOT_WEB_AUTH + "." - + webAuthName + ".username"); - final String password = paramMap.get(S2ROBOT_WEB_AUTH + "." - + webAuthName + ".password"); + final String scheme = paramMap.get(S2ROBOT_WEB_AUTH + "." + webAuthName + ".scheme"); + final String hostname = paramMap.get(S2ROBOT_WEB_AUTH + "." + webAuthName + ".host"); + final String port = paramMap.get(S2ROBOT_WEB_AUTH + "." + webAuthName + ".port"); + final String realm = paramMap.get(S2ROBOT_WEB_AUTH + "." + webAuthName + ".realm"); + final String username = paramMap.get(S2ROBOT_WEB_AUTH + "." + webAuthName + ".username"); + final String password = paramMap.get(S2ROBOT_WEB_AUTH + "." + webAuthName + ".password"); if (StringUtil.isEmpty(username)) { logger.warn("username is empty. webAuth:" + webAuthName); @@ -262,8 +250,7 @@ public class DataCrawlingConfig extends BsDataCrawlingConfig implements } String s = scheme; - if (StringUtil.isBlank(scheme) - || Constants.NTLM.equals(scheme)) { + if (StringUtil.isBlank(scheme) || Constants.NTLM.equals(scheme)) { s = AuthScope.ANY_SCHEME; } authScope = new AuthScope(hostname, p, r, s); @@ -271,47 +258,34 @@ public class DataCrawlingConfig extends BsDataCrawlingConfig implements Credentials credentials; if (Constants.NTLM.equals(scheme)) { - final String workstation = paramMap.get(S2ROBOT_WEB_AUTH - + "." + webAuthName + ".workstation"); - final String domain = paramMap.get(S2ROBOT_WEB_AUTH + "." - + webAuthName + ".domain"); - credentials = new NTCredentials(username, - password == null ? StringUtil.EMPTY : password, - workstation == null ? StringUtil.EMPTY - : workstation, - domain == null ? StringUtil.EMPTY : domain); + final String workstation = paramMap.get(S2ROBOT_WEB_AUTH + "." + webAuthName + ".workstation"); + final String domain = paramMap.get(S2ROBOT_WEB_AUTH + "." + webAuthName + ".domain"); + credentials = + new NTCredentials(username, password == null ? StringUtil.EMPTY : password, + workstation == null ? StringUtil.EMPTY : workstation, domain == null ? StringUtil.EMPTY : domain); } else { - credentials = new UsernamePasswordCredentials(username, - password == null ? StringUtil.EMPTY : password); + credentials = new UsernamePasswordCredentials(username, password == null ? StringUtil.EMPTY : password); } - basicAuthList.add(new AuthenticationImpl(authScope, - credentials, authScheme)); + basicAuthList.add(new AuthenticationImpl(authScope, credentials, authScheme)); } factoryParamMap.put(HcHttpClient.BASIC_AUTHENTICATIONS_PROPERTY, - basicAuthList.toArray(new Authentication[basicAuthList - .size()])); + basicAuthList.toArray(new Authentication[basicAuthList.size()])); } // request header final List rhList = new ArrayList(); int count = 1; - String headerName = paramMap.get(S2ROBOT_WEB_HEADER_PREFIX + count - + ".name"); + String headerName = paramMap.get(S2ROBOT_WEB_HEADER_PREFIX + count + ".name"); while (StringUtil.isNotBlank(headerName)) { - final String headerValue = paramMap.get(S2ROBOT_WEB_HEADER_PREFIX - + count + ".value"); - rhList.add(new org.codelibs.robot.client.http.RequestHeader( - headerName, headerValue)); + final String headerValue = paramMap.get(S2ROBOT_WEB_HEADER_PREFIX + count + ".value"); + rhList.add(new org.codelibs.robot.client.http.RequestHeader(headerName, headerValue)); count++; - headerName = paramMap.get(S2ROBOT_WEB_HEADER_PREFIX + count - + ".name"); + headerName = paramMap.get(S2ROBOT_WEB_HEADER_PREFIX + count + ".name"); } if (!rhList.isEmpty()) { - factoryParamMap - .put(HcHttpClient.REQUERT_HEADERS_PROPERTY, - rhList.toArray(new org.codelibs.robot.client.http.RequestHeader[rhList - .size()])); + factoryParamMap.put(HcHttpClient.REQUERT_HEADERS_PROPERTY, + rhList.toArray(new org.codelibs.robot.client.http.RequestHeader[rhList.size()])); } // file auth @@ -320,29 +294,21 @@ public class DataCrawlingConfig extends BsDataCrawlingConfig implements final String[] fileAuthNames = fileAuthStr.split(","); final List smbAuthList = new ArrayList(); for (final String fileAuthName : fileAuthNames) { - final String scheme = paramMap.get(S2ROBOT_FILE_AUTH + "." - + fileAuthName + ".scheme"); + final String scheme = paramMap.get(S2ROBOT_FILE_AUTH + "." + fileAuthName + ".scheme"); if (Constants.SAMBA.equals(scheme)) { - final String domain = paramMap.get(S2ROBOT_FILE_AUTH + "." - + fileAuthName + ".domain"); - final String hostname = paramMap.get(S2ROBOT_FILE_AUTH - + "." + fileAuthName + ".host"); - final String port = paramMap.get(S2ROBOT_FILE_AUTH + "." - + fileAuthName + ".port"); - final String username = paramMap.get(S2ROBOT_FILE_AUTH - + "." + fileAuthName + ".username"); - final String password = paramMap.get(S2ROBOT_FILE_AUTH - + "." + fileAuthName + ".password"); + final String domain = paramMap.get(S2ROBOT_FILE_AUTH + "." + fileAuthName + ".domain"); + final String hostname = paramMap.get(S2ROBOT_FILE_AUTH + "." + fileAuthName + ".host"); + final String port = paramMap.get(S2ROBOT_FILE_AUTH + "." + fileAuthName + ".port"); + final String username = paramMap.get(S2ROBOT_FILE_AUTH + "." + fileAuthName + ".username"); + final String password = paramMap.get(S2ROBOT_FILE_AUTH + "." + fileAuthName + ".password"); if (StringUtil.isEmpty(username)) { - logger.warn("username is empty. fileAuth:" - + fileAuthName); + logger.warn("username is empty. fileAuth:" + fileAuthName); continue; } final SmbAuthentication smbAuth = new SmbAuthentication(); - smbAuth.setDomain(domain == null ? StringUtil.EMPTY - : domain); + smbAuth.setDomain(domain == null ? StringUtil.EMPTY : domain); smbAuth.setServer(hostname); if (StringUtil.isNotBlank(port)) { try { @@ -352,15 +318,12 @@ public class DataCrawlingConfig extends BsDataCrawlingConfig implements } } smbAuth.setUsername(username); - smbAuth.setPassword(password == null ? StringUtil.EMPTY - : password); + smbAuth.setPassword(password == null ? StringUtil.EMPTY : password); smbAuthList.add(smbAuth); } } if (!smbAuthList.isEmpty()) { - factoryParamMap.put(SmbClient.SMB_AUTHENTICATIONS_PROPERTY, - smbAuthList.toArray(new SmbAuthentication[smbAuthList - .size()])); + factoryParamMap.put(SmbClient.SMB_AUTHENTICATIONS_PROPERTY, smbAuthList.toArray(new SmbAuthentication[smbAuthList.size()])); } } diff --git a/src/main/java/org/codelibs/fess/db/exentity/FailureUrl.java b/src/main/java/org/codelibs/fess/db/exentity/FailureUrl.java index 936f5f797..3c0490255 100644 --- a/src/main/java/org/codelibs/fess/db/exentity/FailureUrl.java +++ b/src/main/java/org/codelibs/fess/db/exentity/FailureUrl.java @@ -37,8 +37,7 @@ public class FailureUrl extends BsFailureUrl { private static final long serialVersionUID = 1L; public String getLastAccessTimeForList() { - final SimpleDateFormat sdf = new SimpleDateFormat( - Constants.DEFAULT_DATETIME_FORMAT); + final SimpleDateFormat sdf = new SimpleDateFormat(Constants.DEFAULT_DATETIME_FORMAT); if (getLastAccessTime() != null) { return sdf.format(getLastAccessTime()); } @@ -46,8 +45,7 @@ public class FailureUrl extends BsFailureUrl { } public String getWebConfigName() { - final CrawlingConfig crawlingConfig = ComponentUtil - .getCrawlingConfigHelper().getCrawlingConfig(getConfigId()); + final CrawlingConfig crawlingConfig = ComponentUtil.getCrawlingConfigHelper().getCrawlingConfig(getConfigId()); if (crawlingConfig != null) { return crawlingConfig.getName(); } @@ -55,8 +53,7 @@ public class FailureUrl extends BsFailureUrl { } public String getFileConfigName() { - final CrawlingConfig crawlingConfig = ComponentUtil - .getCrawlingConfigHelper().getCrawlingConfig(getConfigId()); + final CrawlingConfig crawlingConfig = ComponentUtil.getCrawlingConfigHelper().getCrawlingConfig(getConfigId()); if (crawlingConfig != null) { return crawlingConfig.getName(); } @@ -64,8 +61,7 @@ public class FailureUrl extends BsFailureUrl { } public String getDataConfigName() { - final CrawlingConfig crawlingConfig = ComponentUtil - .getCrawlingConfigHelper().getCrawlingConfig(getConfigId()); + final CrawlingConfig crawlingConfig = ComponentUtil.getCrawlingConfigHelper().getCrawlingConfig(getConfigId()); if (crawlingConfig != null) { return crawlingConfig.getName(); } diff --git a/src/main/java/org/codelibs/fess/db/exentity/FileConfigToLabelTypeMapping.java b/src/main/java/org/codelibs/fess/db/exentity/FileConfigToLabelTypeMapping.java index e443c5c56..bc4f5e974 100644 --- a/src/main/java/org/codelibs/fess/db/exentity/FileConfigToLabelTypeMapping.java +++ b/src/main/java/org/codelibs/fess/db/exentity/FileConfigToLabelTypeMapping.java @@ -26,8 +26,7 @@ import org.codelibs.fess.db.bsentity.BsFileConfigToLabelTypeMapping; *

* @author DBFlute(AutoGenerator) */ -public class FileConfigToLabelTypeMapping extends - BsFileConfigToLabelTypeMapping { +public class FileConfigToLabelTypeMapping extends BsFileConfigToLabelTypeMapping { /** Serial version UID. (Default) */ private static final long serialVersionUID = 1L; diff --git a/src/main/java/org/codelibs/fess/db/exentity/FileCrawlingConfig.java b/src/main/java/org/codelibs/fess/db/exentity/FileCrawlingConfig.java index 9c5663278..1d8b5af62 100644 --- a/src/main/java/org/codelibs/fess/db/exentity/FileCrawlingConfig.java +++ b/src/main/java/org/codelibs/fess/db/exentity/FileCrawlingConfig.java @@ -44,8 +44,7 @@ import org.seasar.framework.container.SingletonS2Container; *

* @author DBFlute(AutoGenerator) */ -public class FileCrawlingConfig extends BsFileCrawlingConfig implements - CrawlingConfig { +public class FileCrawlingConfig extends BsFileCrawlingConfig implements CrawlingConfig { /** Serial version UID. (Default) */ private static final long serialVersionUID = 1L; @@ -126,8 +125,7 @@ public class FileCrawlingConfig extends BsFileCrawlingConfig implements initDocPathPattern(); } - if (includedDocPathPatterns.length == 0 - && excludedDocPathPatterns.length == 0) { + if (includedDocPathPatterns.length == 0 && excludedDocPathPatterns.length == 0) { return Constants.TRUE; } @@ -156,12 +154,10 @@ public class FileCrawlingConfig extends BsFileCrawlingConfig implements final String[] paths = getIncludedDocPaths().split("[\r\n]"); for (final String u : paths) { if (StringUtil.isNotBlank(u) && !u.trim().startsWith("#")) { - pathPatterList.add(Pattern.compile(systemHelper - .encodeUrlFilter(u.trim()))); + pathPatterList.add(Pattern.compile(systemHelper.encodeUrlFilter(u.trim()))); } } - includedDocPathPatterns = pathPatterList - .toArray(new Pattern[pathPatterList.size()]); + includedDocPathPatterns = pathPatterList.toArray(new Pattern[pathPatterList.size()]); } else { includedDocPathPatterns = new Pattern[0]; } @@ -173,12 +169,10 @@ public class FileCrawlingConfig extends BsFileCrawlingConfig implements final String[] paths = getExcludedDocPaths().split("[\r\n]"); for (final String u : paths) { if (StringUtil.isNotBlank(u) && !u.trim().startsWith("#")) { - pathPatterList.add(Pattern.compile(systemHelper - .encodeUrlFilter(u.trim()))); + pathPatterList.add(Pattern.compile(systemHelper.encodeUrlFilter(u.trim()))); } } - excludedDocPathPatterns = pathPatterList - .toArray(new Pattern[pathPatterList.size()]); + excludedDocPathPatterns = pathPatterList.toArray(new Pattern[pathPatterList.size()]); } else if (includedDocPathPatterns.length > 0) { excludedDocPathPatterns = new Pattern[] { Pattern.compile(".*") }; } else { @@ -198,8 +192,7 @@ public class FileCrawlingConfig extends BsFileCrawlingConfig implements if (value != null) { try { _boost = new BigDecimal(value); - } catch (final Exception e) { - } + } catch (final Exception e) {} } } @@ -210,8 +203,7 @@ public class FileCrawlingConfig extends BsFileCrawlingConfig implements @Override public void initializeClientFactory(final S2RobotClientFactory clientFactory) { - final FileAuthenticationService fileAuthenticationService = SingletonS2Container - .getComponent(FileAuthenticationService.class); + final FileAuthenticationService fileAuthenticationService = SingletonS2Container.getComponent(FileAuthenticationService.class); // Parameters final Map paramMap = new HashMap(); @@ -223,14 +215,12 @@ public class FileCrawlingConfig extends BsFileCrawlingConfig implements } // auth params - final List fileAuthList = fileAuthenticationService - .getFileAuthenticationList(getId()); + final List fileAuthList = fileAuthenticationService.getFileAuthenticationList(getId()); final List smbAuthList = new ArrayList(); for (final FileAuthentication fileAuth : fileAuthList) { if (Constants.SAMBA.equals(fileAuth.getProtocolScheme())) { final SmbAuthentication smbAuth = new SmbAuthentication(); - final Map map = ParameterUtil.parse(fileAuth - .getParameters()); + final Map map = ParameterUtil.parse(fileAuth.getParameters()); final String domain = map.get("domain"); smbAuth.setDomain(domain == null ? StringUtil.EMPTY : domain); smbAuth.setServer(fileAuth.getHostname()); @@ -240,16 +230,14 @@ public class FileCrawlingConfig extends BsFileCrawlingConfig implements smbAuthList.add(smbAuth); } } - paramMap.put(SmbClient.SMB_AUTHENTICATIONS_PROPERTY, - smbAuthList.toArray(new SmbAuthentication[smbAuthList.size()])); + paramMap.put(SmbClient.SMB_AUTHENTICATIONS_PROPERTY, smbAuthList.toArray(new SmbAuthentication[smbAuthList.size()])); } @Override public Map getConfigParameterMap(final ConfigName name) { if (configParameterMap == null) { - configParameterMap = ParameterUtil - .createConfigParameterMap(getConfigParameter()); + configParameterMap = ParameterUtil.createConfigParameterMap(getConfigParameter()); } final Map configMap = configParameterMap.get(name); diff --git a/src/main/java/org/codelibs/fess/db/exentity/KeyMatch.java b/src/main/java/org/codelibs/fess/db/exentity/KeyMatch.java index 78e2bcbbb..3829c9c8d 100644 --- a/src/main/java/org/codelibs/fess/db/exentity/KeyMatch.java +++ b/src/main/java/org/codelibs/fess/db/exentity/KeyMatch.java @@ -49,8 +49,7 @@ public class KeyMatch extends BsKeyMatch { if (value != null) { try { _boost = new BigDecimal(value); - } catch (final Exception e) { - } + } catch (final Exception e) {} } } } diff --git a/src/main/java/org/codelibs/fess/db/exentity/OverlappingHost.java b/src/main/java/org/codelibs/fess/db/exentity/OverlappingHost.java index 16ea91d5c..3aa3d8e86 100644 --- a/src/main/java/org/codelibs/fess/db/exentity/OverlappingHost.java +++ b/src/main/java/org/codelibs/fess/db/exentity/OverlappingHost.java @@ -32,10 +32,8 @@ public class OverlappingHost extends BsOverlappingHost { private static final long serialVersionUID = 1L; public String convert(final String url) { - final String targetStr = getOverlappingName() - .replaceAll("\\.", "\\\\."); - return url.replaceFirst("://" + targetStr + "$", - "://" + getRegularName()).replaceFirst( - "://" + targetStr + "([:/])", "://" + getRegularName() + "$1"); + final String targetStr = getOverlappingName().replaceAll("\\.", "\\\\."); + return url.replaceFirst("://" + targetStr + "$", "://" + getRegularName()).replaceFirst("://" + targetStr + "([:/])", + "://" + getRegularName() + "$1"); } } diff --git a/src/main/java/org/codelibs/fess/db/exentity/RequestHeader.java b/src/main/java/org/codelibs/fess/db/exentity/RequestHeader.java index 216c0dbfe..f676e56fe 100644 --- a/src/main/java/org/codelibs/fess/db/exentity/RequestHeader.java +++ b/src/main/java/org/codelibs/fess/db/exentity/RequestHeader.java @@ -32,7 +32,6 @@ public class RequestHeader extends BsRequestHeader { private static final long serialVersionUID = 1L; public org.codelibs.robot.client.http.RequestHeader getS2RobotRequestHeader() { - return new org.codelibs.robot.client.http.RequestHeader(getName(), - getValue()); + return new org.codelibs.robot.client.http.RequestHeader(getName(), getValue()); } } diff --git a/src/main/java/org/codelibs/fess/db/exentity/SearchLog.java b/src/main/java/org/codelibs/fess/db/exentity/SearchLog.java index 4e4f9d4b8..3ce85a943 100644 --- a/src/main/java/org/codelibs/fess/db/exentity/SearchLog.java +++ b/src/main/java/org/codelibs/fess/db/exentity/SearchLog.java @@ -36,8 +36,7 @@ public class SearchLog extends BsSearchLog { private static final long serialVersionUID = 1L; public String getRequestedTimeForList() { - final SimpleDateFormat sdf = new SimpleDateFormat( - Constants.DEFAULT_DATETIME_FORMAT); + final SimpleDateFormat sdf = new SimpleDateFormat(Constants.DEFAULT_DATETIME_FORMAT); if (getRequestedTime() != null) { return sdf.format(getRequestedTime()); } diff --git a/src/main/java/org/codelibs/fess/db/exentity/SuggestElevateWord.java b/src/main/java/org/codelibs/fess/db/exentity/SuggestElevateWord.java index ded53a775..5bd479e56 100644 --- a/src/main/java/org/codelibs/fess/db/exentity/SuggestElevateWord.java +++ b/src/main/java/org/codelibs/fess/db/exentity/SuggestElevateWord.java @@ -49,8 +49,7 @@ public class SuggestElevateWord extends BsSuggestElevateWord { if (value != null) { try { _boost = new BigDecimal(value); - } catch (final Exception e) { - } + } catch (final Exception e) {} } } } diff --git a/src/main/java/org/codelibs/fess/db/exentity/WebAuthentication.java b/src/main/java/org/codelibs/fess/db/exentity/WebAuthentication.java index 2cc916b10..d19e96066 100644 --- a/src/main/java/org/codelibs/fess/db/exentity/WebAuthentication.java +++ b/src/main/java/org/codelibs/fess/db/exentity/WebAuthentication.java @@ -49,8 +49,7 @@ public class WebAuthentication extends BsWebAuthentication { private static final long serialVersionUID = 1L; public Authentication getAuthentication() { - return new AuthenticationImpl(getAuthScope(), getCredentials(), - getAuthScheme()); + return new AuthenticationImpl(getAuthScope(), getCredentials(), getAuthScheme()); } private AuthScheme getAuthScheme() { @@ -95,17 +94,14 @@ public class WebAuthentication extends BsWebAuthentication { } if (Constants.NTLM.equals(getProtocolScheme())) { - final Map parameterMap = ParameterUtil - .parse(getParameters()); + final Map parameterMap = ParameterUtil.parse(getParameters()); final String workstation = parameterMap.get("workstation"); final String domain = parameterMap.get("domain"); - return new NTCredentials(getUsername(), getPassword(), - workstation == null ? StringUtil.EMPTY : workstation, + return new NTCredentials(getUsername(), getPassword(), workstation == null ? StringUtil.EMPTY : workstation, domain == null ? StringUtil.EMPTY : domain); } - return new UsernamePasswordCredentials(getUsername(), - getPassword() == null ? StringUtil.EMPTY : getPassword()); + return new UsernamePasswordCredentials(getUsername(), getPassword() == null ? StringUtil.EMPTY : getPassword()); } } diff --git a/src/main/java/org/codelibs/fess/db/exentity/WebCrawlingConfig.java b/src/main/java/org/codelibs/fess/db/exentity/WebCrawlingConfig.java index 25b38a937..45cf2116a 100644 --- a/src/main/java/org/codelibs/fess/db/exentity/WebCrawlingConfig.java +++ b/src/main/java/org/codelibs/fess/db/exentity/WebCrawlingConfig.java @@ -43,8 +43,7 @@ import org.seasar.framework.container.SingletonS2Container; *

* @author DBFlute(AutoGenerator) */ -public class WebCrawlingConfig extends BsWebCrawlingConfig implements - CrawlingConfig { +public class WebCrawlingConfig extends BsWebCrawlingConfig implements CrawlingConfig { /** Serial version UID. (Default) */ private static final long serialVersionUID = 1L; @@ -131,8 +130,7 @@ public class WebCrawlingConfig extends BsWebCrawlingConfig implements initDocUrlPattern(); } - if (includedDocUrlPatterns.length == 0 - && excludedDocUrlPatterns.length == 0) { + if (includedDocUrlPatterns.length == 0 && excludedDocUrlPatterns.length == 0) { return Constants.TRUE; } @@ -162,8 +160,7 @@ public class WebCrawlingConfig extends BsWebCrawlingConfig implements urlPatterList.add(Pattern.compile(u.trim())); } } - includedDocUrlPatterns = urlPatterList - .toArray(new Pattern[urlPatterList.size()]); + includedDocUrlPatterns = urlPatterList.toArray(new Pattern[urlPatterList.size()]); } else { includedDocUrlPatterns = new Pattern[0]; } @@ -178,8 +175,7 @@ public class WebCrawlingConfig extends BsWebCrawlingConfig implements urlPatterList.add(Pattern.compile(u.trim())); } } - excludedDocUrlPatterns = urlPatterList - .toArray(new Pattern[urlPatterList.size()]); + excludedDocUrlPatterns = urlPatterList.toArray(new Pattern[urlPatterList.size()]); } else if (includedDocUrlPatterns.length > 0) { excludedDocUrlPatterns = new Pattern[] { Pattern.compile(".*") }; } else { @@ -199,8 +195,7 @@ public class WebCrawlingConfig extends BsWebCrawlingConfig implements if (value != null) { try { _boost = new BigDecimal(value); - } catch (final Exception e) { - } + } catch (final Exception e) {} } } @@ -211,10 +206,8 @@ public class WebCrawlingConfig extends BsWebCrawlingConfig implements @Override public void initializeClientFactory(final S2RobotClientFactory clientFactory) { - final WebAuthenticationService webAuthenticationService = SingletonS2Container - .getComponent(WebAuthenticationService.class); - final RequestHeaderService requestHeaderService = SingletonS2Container - .getComponent(RequestHeaderService.class); + final WebAuthenticationService webAuthenticationService = SingletonS2Container.getComponent(WebAuthenticationService.class); + final RequestHeaderService requestHeaderService = SingletonS2Container.getComponent(RequestHeaderService.class); // HttpClient Parameters final Map paramMap = new HashMap(); @@ -230,34 +223,27 @@ public class WebCrawlingConfig extends BsWebCrawlingConfig implements paramMap.put(HcHttpClient.USER_AGENT_PROPERTY, userAgent); } - final List webAuthList = webAuthenticationService - .getWebAuthenticationList(getId()); + final List webAuthList = webAuthenticationService.getWebAuthenticationList(getId()); final List basicAuthList = new ArrayList(); for (final WebAuthentication webAuth : webAuthList) { basicAuthList.add(webAuth.getAuthentication()); } - paramMap.put(HcHttpClient.BASIC_AUTHENTICATIONS_PROPERTY, - basicAuthList.toArray(new Authentication[basicAuthList.size()])); + paramMap.put(HcHttpClient.BASIC_AUTHENTICATIONS_PROPERTY, basicAuthList.toArray(new Authentication[basicAuthList.size()])); // request header - final List requestHeaderList = requestHeaderService - .getRequestHeaderList(getId()); + final List requestHeaderList = requestHeaderService.getRequestHeaderList(getId()); final List rhList = new ArrayList(); for (final RequestHeader requestHeader : requestHeaderList) { rhList.add(requestHeader.getS2RobotRequestHeader()); } - paramMap.put( - HcHttpClient.REQUERT_HEADERS_PROPERTY, - rhList.toArray(new org.codelibs.robot.client.http.RequestHeader[rhList - .size()])); + paramMap.put(HcHttpClient.REQUERT_HEADERS_PROPERTY, rhList.toArray(new org.codelibs.robot.client.http.RequestHeader[rhList.size()])); } @Override public Map getConfigParameterMap(final ConfigName name) { if (configParameterMap == null) { - configParameterMap = ParameterUtil - .createConfigParameterMap(getConfigParameter()); + configParameterMap = ParameterUtil.createConfigParameterMap(getConfigParameter()); } final Map configMap = configParameterMap.get(name); diff --git a/src/main/java/org/codelibs/fess/dict/DictionaryFile.java b/src/main/java/org/codelibs/fess/dict/DictionaryFile.java index 858ab6c64..8e5bf2fed 100644 --- a/src/main/java/org/codelibs/fess/dict/DictionaryFile.java +++ b/src/main/java/org/codelibs/fess/dict/DictionaryFile.java @@ -60,8 +60,7 @@ public abstract class DictionaryFile { protected int pageRangeSize; - public PagingList(final List list, final int offset, final int size, - final int allRecordCount) { + public PagingList(final List list, final int offset, final int size, final int allRecordCount) { this.parent = list; this.allRecordCount = allRecordCount; pageSize = size; diff --git a/src/main/java/org/codelibs/fess/dict/DictionaryLocator.java b/src/main/java/org/codelibs/fess/dict/DictionaryLocator.java index 7b492a047..b5b3873ec 100644 --- a/src/main/java/org/codelibs/fess/dict/DictionaryLocator.java +++ b/src/main/java/org/codelibs/fess/dict/DictionaryLocator.java @@ -28,33 +28,29 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public abstract class DictionaryLocator { - private static final Logger logger = LoggerFactory - .getLogger(DictionaryLocator.class); + private static final Logger logger = LoggerFactory.getLogger(DictionaryLocator.class); protected List searchPathList = new ArrayList(); public abstract List> find(); - protected File[] findFiles(final String path, final String filenamePrefix, - final List excludedSet) { + protected File[] findFiles(final String path, final String filenamePrefix, final List excludedSet) { final File directory = new File(path); if (logger.isDebugEnabled()) { logger.debug("Load files from " + directory.getAbsolutePath()); } - final Collection files = FileUtils.listFiles(directory, - new AbstractFileFilter() { - @Override - public boolean accept(final File dir, final String name) { - return name.startsWith(filenamePrefix); - } - }, new AbstractFileFilter() { - @Override - public boolean accept(final File dir, final String name) { - return excludedSet == null - || !excludedSet.contains(name); - } - }); + final Collection files = FileUtils.listFiles(directory, new AbstractFileFilter() { + @Override + public boolean accept(final File dir, final String name) { + return name.startsWith(filenamePrefix); + } + }, new AbstractFileFilter() { + @Override + public boolean accept(final File dir, final String name) { + return excludedSet == null || !excludedSet.contains(name); + } + }); if (logger.isDebugEnabled()) { logger.debug("Dictionary files: " + files); diff --git a/src/main/java/org/codelibs/fess/dict/DictionaryManager.java b/src/main/java/org/codelibs/fess/dict/DictionaryManager.java index 06b548d78..6bcbc3029 100644 --- a/src/main/java/org/codelibs/fess/dict/DictionaryManager.java +++ b/src/main/java/org/codelibs/fess/dict/DictionaryManager.java @@ -33,8 +33,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class DictionaryManager { - private static final Logger logger = LoggerFactory - .getLogger(DictionaryManager.class); + private static final Logger logger = LoggerFactory.getLogger(DictionaryManager.class); protected Map> dicFileMap; @@ -52,8 +51,7 @@ public class DictionaryManager { public void init() { // start final WatcherTarget watcherTarget = new WatcherTarget(); - watcherTargetTask = TimeoutManager.getInstance().addTimeoutTarget( - watcherTarget, watcherTimeout, true); + watcherTargetTask = TimeoutManager.getInstance().addTimeoutTarget(watcherTarget, watcherTimeout, true); } @DestroyMethod @@ -66,16 +64,13 @@ public class DictionaryManager { public DictionaryFile[] getDictionaryFiles() { final Map> fileMap = getDictionaryFileMap(); - final Collection> values = fileMap - .values(); + final Collection> values = fileMap.values(); @SuppressWarnings("unchecked") - final DictionaryFile[] list = new DictionaryFile[values - .size()]; + final DictionaryFile[] list = new DictionaryFile[values.size()]; return values.toArray(list); } - public DictionaryFile getDictionaryFile( - final String id) { + public DictionaryFile getDictionaryFile(final String id) { if (StringUtil.isBlank(id)) { return null; } @@ -93,8 +88,7 @@ public class DictionaryManager { final Map> newFileMap = new LinkedHashMap<>(); for (final DictionaryLocator locator : locatorList) { - for (final DictionaryFile dictFile : locator - .find()) { + for (final DictionaryFile dictFile : locator.find()) { final String id = UUID.randomUUID().toString(); dictFile.setId(id); newFileMap.put(id, dictFile); @@ -114,8 +108,7 @@ public class DictionaryManager { @Override public void expired() { synchronized (DictionaryManager.this) { - if (lifetime <= System.currentTimeMillis() - && dicFileMap != null) { + if (lifetime <= System.currentTimeMillis() && dicFileMap != null) { dicFileMap = null; if (logger.isDebugEnabled()) { logger.debug("Clear dictionary cache: " + dicFileMap); diff --git a/src/main/java/org/codelibs/fess/dict/synonym/SynonymFile.java b/src/main/java/org/codelibs/fess/dict/synonym/SynonymFile.java index 28c710761..5e5de22d3 100644 --- a/src/main/java/org/codelibs/fess/dict/synonym/SynonymFile.java +++ b/src/main/java/org/codelibs/fess/dict/synonym/SynonymFile.java @@ -71,16 +71,13 @@ public class SynonymFile extends DictionaryFile { } @Override - public synchronized PagingList selectList(final int offset, - final int size) { + public synchronized PagingList selectList(final int offset, final int size) { if (synonymItemList == null) { reload(null); } if (offset >= synonymItemList.size() || offset < 0) { - return new PagingList( - Collections. emptyList(), offset, size, - synonymItemList.size()); + return new PagingList(Collections. emptyList(), offset, size, synonymItemList.size()); } int toIndex = offset + size; @@ -88,8 +85,7 @@ public class SynonymFile extends DictionaryFile { toIndex = synonymItemList.size(); } - return new PagingList(synonymItemList.subList(offset, - toIndex), offset, size, synonymItemList.size()); + return new PagingList(synonymItemList.subList(offset, toIndex), offset, size, synonymItemList.size()); } @Override @@ -97,20 +93,17 @@ public class SynonymFile extends DictionaryFile { final SynonymItem synonymItem = item; BufferedWriter bw = null; try { - bw = new BufferedWriter(new OutputStreamWriter( - new FileOutputStream(file, true), Constants.UTF_8)); + bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file, true), Constants.UTF_8)); bw.newLine(); bw.write(synonymItem.toLineString()); bw.flush(); long nextId = 1; if (!synonymItemList.isEmpty()) { - final SynonymItem lastItem = synonymItemList - .get(synonymItemList.size() - 1); + final SynonymItem lastItem = synonymItemList.get(synonymItemList.size() - 1); nextId = lastItem.getId() + 1; } - synonymItemList.add(new SynonymItem(nextId, synonymItem - .getNewInputs(), synonymItem.getNewOutputs())); + synonymItemList.add(new SynonymItem(nextId, synonymItem.getNewInputs(), synonymItem.getNewOutputs())); } catch (final IOException e) { throw new DictionaryException("Failed to write: " + item, e); } finally { @@ -151,8 +144,7 @@ public class SynonymFile extends DictionaryFile { final List itemList = new ArrayList(); BufferedReader reader = null; try { - reader = new BufferedReader(new InputStreamReader( - new FileInputStream(file), Constants.UTF_8)); + reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), Constants.UTF_8)); long id = 0; String line = null; while ((line = reader.readLine()) != null) { @@ -169,8 +161,7 @@ public class SynonymFile extends DictionaryFile { final List sides = split(line, "=>"); if (sides.size() > 1) { // explicit mapping if (sides.size() != 2) { - throw new DictionaryException( - "more than one explicit mapping specified on the same line"); + throw new DictionaryException("more than one explicit mapping specified on the same line"); } final List inputStrings = split(sides.get(0), ","); inputs = new String[inputStrings.size()]; @@ -186,8 +177,7 @@ public class SynonymFile extends DictionaryFile { if (inputs.length > 0 && outputs.length > 0) { id++; - final SynonymItem item = new SynonymItem(id, inputs, - outputs); + final SynonymItem item = new SynonymItem(id, inputs, outputs); if (updater != null) { final SynonymItem newItem = updater.write(item); if (newItem != null) { @@ -208,8 +198,7 @@ public class SynonymFile extends DictionaryFile { if (inputs.length > 0) { id++; - final SynonymItem item = new SynonymItem(id, inputs, - inputs); + final SynonymItem item = new SynonymItem(id, inputs, inputs); if (updater != null) { final SynonymItem newItem = updater.write(item); if (newItem != null) { @@ -228,8 +217,7 @@ public class SynonymFile extends DictionaryFile { } synonymItemList = itemList; } catch (final IOException e) { - throw new DictionaryException("Failed to parse " - + file.getAbsolutePath(), e); + throw new DictionaryException("Failed to parse " + file.getAbsolutePath(), e); } finally { IOUtils.closeQuietly(reader); } @@ -300,14 +288,12 @@ public class SynonymFile extends DictionaryFile { protected SynonymUpdater(final File file, final SynonymItem newItem) { try { newFile = File.createTempFile(SYNONYM, ".txt"); - writer = new BufferedWriter(new OutputStreamWriter( - new FileOutputStream(newFile), Constants.UTF_8)); + writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(newFile), Constants.UTF_8)); } catch (final IOException e) { if (newFile != null) { newFile.delete(); } - throw new DictionaryException( - "Failed to write a synonym file.", e); + throw new DictionaryException("Failed to write a synonym file.", e); } oldFile = file; item = newItem; @@ -322,9 +308,7 @@ public class SynonymFile extends DictionaryFile { // update writer.write(item.toLineString()); writer.write(Constants.LINE_SEPARATOR); - return new SynonymItem(item.getId(), - item.getNewInputs(), - item.getNewOutputs()); + return new SynonymItem(item.getId(), item.getNewInputs(), item.getNewOutputs()); } else { return null; } @@ -333,9 +317,7 @@ public class SynonymFile extends DictionaryFile { item.setNewOutputs(null); } } else { - throw new DictionaryException( - "Synonym file was updated: old=" + oldItem - + " : new=" + item); + throw new DictionaryException("Synonym file was updated: old=" + oldItem + " : new=" + item); } } else { writer.write(oldItem.toLineString()); @@ -343,8 +325,7 @@ public class SynonymFile extends DictionaryFile { return oldItem; } } catch (final IOException e) { - throw new DictionaryException("Failed to write: " + oldItem - + " -> " + item, e); + throw new DictionaryException("Failed to write: " + oldItem + " -> " + item, e); } } @@ -374,9 +355,8 @@ public class SynonymFile extends DictionaryFile { FileUtils.copyFile(newFile, oldFile); newFile.delete(); } catch (final IOException e) { - throw new DictionaryException("Failed to replace " - + oldFile.getAbsolutePath() + " with " - + newFile.getAbsolutePath(), e); + throw new DictionaryException("Failed to replace " + oldFile.getAbsolutePath() + " with " + newFile.getAbsolutePath(), + e); } } else { newFile.delete(); @@ -399,7 +379,6 @@ public class SynonymFile extends DictionaryFile { @Override public String toString() { - return "SynonymFile [file=" + file + ", synonymItemList=" - + synonymItemList + ", id=" + id + "]"; + return "SynonymFile [file=" + file + ", synonymItemList=" + synonymItemList + ", id=" + id + "]"; } } diff --git a/src/main/java/org/codelibs/fess/dict/synonym/SynonymItem.java b/src/main/java/org/codelibs/fess/dict/synonym/SynonymItem.java index 33dce5591..6133d384b 100644 --- a/src/main/java/org/codelibs/fess/dict/synonym/SynonymItem.java +++ b/src/main/java/org/codelibs/fess/dict/synonym/SynonymItem.java @@ -30,8 +30,7 @@ public class SynonymItem extends DictionaryItem { private String[] newOutputs; - public SynonymItem(final long id, final String[] inputs, - final String[] outputs) { + public SynonymItem(final long id, final String[] inputs, final String[] outputs) { this.id = id; this.inputs = inputs; this.outputs = outputs; @@ -128,10 +127,8 @@ public class SynonymItem extends DictionaryItem { @Override public String toString() { - return "SynonymItem [id=" + id + ", inputs=" + Arrays.toString(inputs) - + ", outputs=" + Arrays.toString(outputs) + ", newInputs=" - + Arrays.toString(newInputs) + ", newOutputs=" - + Arrays.toString(newOutputs) + "]"; + return "SynonymItem [id=" + id + ", inputs=" + Arrays.toString(inputs) + ", outputs=" + Arrays.toString(outputs) + ", newInputs=" + + Arrays.toString(newInputs) + ", newOutputs=" + Arrays.toString(newOutputs) + "]"; } public String toLineString() { @@ -139,15 +136,13 @@ public class SynonymItem extends DictionaryItem { if (Arrays.equals(newInputs, newOutputs)) { return StringUtils.join(newInputs, ","); } else { - return StringUtils.join(newInputs, ",") + "=>" - + StringUtils.join(newOutputs, ","); + return StringUtils.join(newInputs, ",") + "=>" + StringUtils.join(newOutputs, ","); } } else { if (Arrays.equals(inputs, outputs)) { return StringUtils.join(inputs, ","); } else { - return StringUtils.join(inputs, ",") + "=>" - + StringUtils.join(outputs, ","); + return StringUtils.join(inputs, ",") + "=>" + StringUtils.join(outputs, ","); } } } diff --git a/src/main/java/org/codelibs/fess/dict/synonym/SynonymLocator.java b/src/main/java/org/codelibs/fess/dict/synonym/SynonymLocator.java index 04cde5a68..e6f959325 100644 --- a/src/main/java/org/codelibs/fess/dict/synonym/SynonymLocator.java +++ b/src/main/java/org/codelibs/fess/dict/synonym/SynonymLocator.java @@ -29,8 +29,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class SynonymLocator extends DictionaryLocator { - private static final Logger logger = LoggerFactory - .getLogger(SynonymLocator.class); + private static final Logger logger = LoggerFactory.getLogger(SynonymLocator.class); public String synonymFilePrefix = "synonym"; @@ -43,8 +42,7 @@ public class SynonymLocator extends DictionaryLocator { if (logger.isInfoEnabled()) { logger.info("Synonym Files from " + path); } - final File[] files = findFiles(path, synonymFilePrefix, - excludedSynonymList); + final File[] files = findFiles(path, synonymFilePrefix, excludedSynonymList); for (final File file : files) { if (logger.isInfoEnabled()) { logger.info("Synonym File: " + file.getAbsolutePath()); @@ -52,15 +50,12 @@ public class SynonymLocator extends DictionaryLocator { fileList.add(new SynonymFile(file)); } } - Collections.sort(fileList, - new Comparator>() { - @Override - public int compare( - final DictionaryFile o1, - final DictionaryFile o2) { - return o1.getName().compareTo(o2.getName()); - } - }); + Collections.sort(fileList, new Comparator>() { + @Override + public int compare(final DictionaryFile o1, final DictionaryFile o2) { + return o1.getName().compareTo(o2.getName()); + } + }); return fileList; } diff --git a/src/main/java/org/codelibs/fess/dict/userdict/UserDictFile.java b/src/main/java/org/codelibs/fess/dict/userdict/UserDictFile.java index 44e8274e8..0f5c86556 100644 --- a/src/main/java/org/codelibs/fess/dict/userdict/UserDictFile.java +++ b/src/main/java/org/codelibs/fess/dict/userdict/UserDictFile.java @@ -72,16 +72,13 @@ public class UserDictFile extends DictionaryFile { } @Override - public synchronized PagingList selectList(final int offset, - final int size) { + public synchronized PagingList selectList(final int offset, final int size) { if (userDictItemList == null) { reload(null); } if (offset >= userDictItemList.size() || offset < 0) { - return new PagingList( - Collections. emptyList(), offset, size, - userDictItemList.size()); + return new PagingList(Collections. emptyList(), offset, size, userDictItemList.size()); } int toIndex = offset + size; @@ -89,8 +86,7 @@ public class UserDictFile extends DictionaryFile { toIndex = userDictItemList.size(); } - return new PagingList(userDictItemList.subList(offset, - toIndex), offset, size, userDictItemList.size()); + return new PagingList(userDictItemList.subList(offset, toIndex), offset, size, userDictItemList.size()); } @Override @@ -98,21 +94,18 @@ public class UserDictFile extends DictionaryFile { final UserDictItem userDictItem = item; BufferedWriter bw = null; try { - bw = new BufferedWriter(new OutputStreamWriter( - new FileOutputStream(file, true), Constants.UTF_8)); + bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file, true), Constants.UTF_8)); bw.newLine(); bw.write(userDictItem.toLineString()); bw.flush(); long nextId = 1; if (!userDictItemList.isEmpty()) { - final UserDictItem lastItem = userDictItemList - .get(userDictItemList.size() - 1); + final UserDictItem lastItem = userDictItemList.get(userDictItemList.size() - 1); nextId = lastItem.getId() + 1; } - userDictItemList.add(new UserDictItem(nextId, userDictItem - .getNewToken(), userDictItem.getNewSegmentation(), - userDictItem.getNewReading(), userDictItem.getNewPos())); + userDictItemList.add(new UserDictItem(nextId, userDictItem.getNewToken(), userDictItem.getNewSegmentation(), userDictItem + .getNewReading(), userDictItem.getNewPos())); } catch (final IOException e) { throw new DictionaryException("Failed to write: " + item, e); } finally { @@ -152,8 +145,7 @@ public class UserDictFile extends DictionaryFile { final List itemList = new ArrayList(); BufferedReader reader = null; try { - reader = new BufferedReader(new InputStreamReader( - new FileInputStream(file), Constants.UTF_8)); + reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), Constants.UTF_8)); long id = 0; String line = null; while ((line = reader.readLine()) != null) { @@ -174,21 +166,20 @@ public class UserDictFile extends DictionaryFile { String reading = null; String pos = null; switch (values.length) { - case 4: - pos = values[3]; - case 3: - reading = values[2]; - case 2: - segmentation = values[1]; - case 1: - token = values[0]; - default: - break; + case 4: + pos = values[3]; + case 3: + reading = values[2]; + case 2: + segmentation = values[1]; + case 1: + token = values[0]; + default: + break; } id++; - final UserDictItem item = new UserDictItem(id, token, - segmentation, reading, pos); + final UserDictItem item = new UserDictItem(id, token, segmentation, reading, pos); if (updater != null) { final UserDictItem newItem = updater.write(item); if (newItem != null) { @@ -205,8 +196,7 @@ public class UserDictFile extends DictionaryFile { } userDictItemList = itemList; } catch (final IOException e) { - throw new DictionaryException("Failed to parse " - + file.getAbsolutePath(), e); + throw new DictionaryException("Failed to parse " + file.getAbsolutePath(), e); } finally { IOUtils.closeQuietly(reader); } @@ -227,14 +217,12 @@ public class UserDictFile extends DictionaryFile { protected UserDictUpdater(final File file, final UserDictItem newItem) { try { newFile = File.createTempFile(USERDICT, ".txt"); - writer = new BufferedWriter(new OutputStreamWriter( - new FileOutputStream(newFile), Constants.UTF_8)); + writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(newFile), Constants.UTF_8)); } catch (final IOException e) { if (newFile != null) { newFile.delete(); } - throw new DictionaryException( - "Failed to write a userDict file.", e); + throw new DictionaryException("Failed to write a userDict file.", e); } oldFile = file; item = newItem; @@ -249,10 +237,8 @@ public class UserDictFile extends DictionaryFile { // update writer.write(item.toLineString()); writer.write(Constants.LINE_SEPARATOR); - return new UserDictItem(item.getId(), - item.getNewToken(), - item.getNewSegmentation(), - item.getNewReading(), item.getNewPos()); + return new UserDictItem(item.getId(), item.getNewToken(), item.getNewSegmentation(), item.getNewReading(), + item.getNewPos()); } else { return null; } @@ -260,9 +246,7 @@ public class UserDictFile extends DictionaryFile { item.setNewToken(null); } } else { - throw new DictionaryException( - "UserDict file was updated: old=" + oldItem - + " : new=" + item); + throw new DictionaryException("UserDict file was updated: old=" + oldItem + " : new=" + item); } } else { writer.write(oldItem.toLineString()); @@ -270,8 +254,7 @@ public class UserDictFile extends DictionaryFile { return oldItem; } } catch (final IOException e) { - throw new DictionaryException("Failed to write: " + oldItem - + " -> " + item, e); + throw new DictionaryException("Failed to write: " + oldItem + " -> " + item, e); } } @@ -301,9 +284,8 @@ public class UserDictFile extends DictionaryFile { FileUtils.copyFile(newFile, oldFile); newFile.delete(); } catch (final IOException e) { - throw new DictionaryException("Failed to replace " - + oldFile.getAbsolutePath() + " with " - + newFile.getAbsolutePath(), e); + throw new DictionaryException("Failed to replace " + oldFile.getAbsolutePath() + " with " + newFile.getAbsolutePath(), + e); } } else { newFile.delete(); @@ -326,7 +308,6 @@ public class UserDictFile extends DictionaryFile { @Override public String toString() { - return "UserDictFile [file=" + file + ", userDictItemList=" - + userDictItemList + ", id=" + id + "]"; + return "UserDictFile [file=" + file + ", userDictItemList=" + userDictItemList + ", id=" + id + "]"; } } diff --git a/src/main/java/org/codelibs/fess/dict/userdict/UserDictItem.java b/src/main/java/org/codelibs/fess/dict/userdict/UserDictItem.java index 880f8e42e..6bf17aafa 100644 --- a/src/main/java/org/codelibs/fess/dict/userdict/UserDictItem.java +++ b/src/main/java/org/codelibs/fess/dict/userdict/UserDictItem.java @@ -35,8 +35,7 @@ public class UserDictItem extends DictionaryItem { private String newPos; - public UserDictItem(final long id, final String token, - final String segmentation, final String reading, final String pos) { + public UserDictItem(final long id, final String token, final String segmentation, final String reading, final String pos) { this.id = id; this.token = token; this.segmentation = segmentation; @@ -114,8 +113,7 @@ public class UserDictItem extends DictionaryItem { int result = 1; result = prime * result + (pos == null ? 0 : pos.hashCode()); result = prime * result + (reading == null ? 0 : reading.hashCode()); - result = prime * result - + (segmentation == null ? 0 : segmentation.hashCode()); + result = prime * result + (segmentation == null ? 0 : segmentation.hashCode()); result = prime * result + (token == null ? 0 : token.hashCode()); return result; } @@ -165,11 +163,8 @@ public class UserDictItem extends DictionaryItem { @Override public String toString() { - return "UserDictItem [token=" + token + ", segmentation=" - + segmentation + ", reading=" + reading + ", pos=" + pos - + ", newToken=" + newToken + ", newSegmentation=" - + newSegmentation + ", newReading=" + newReading + ", newPos=" - + newPos + "]"; + return "UserDictItem [token=" + token + ", segmentation=" + segmentation + ", reading=" + reading + ", pos=" + pos + ", newToken=" + + newToken + ", newSegmentation=" + newSegmentation + ", newReading=" + newReading + ", newPos=" + newPos + "]"; } public String toLineString() { diff --git a/src/main/java/org/codelibs/fess/dict/userdict/UserDictLocator.java b/src/main/java/org/codelibs/fess/dict/userdict/UserDictLocator.java index 464affe2f..623d520ca 100644 --- a/src/main/java/org/codelibs/fess/dict/userdict/UserDictLocator.java +++ b/src/main/java/org/codelibs/fess/dict/userdict/UserDictLocator.java @@ -29,8 +29,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class UserDictLocator extends DictionaryLocator { - private static final Logger logger = LoggerFactory - .getLogger(UserDictLocator.class); + private static final Logger logger = LoggerFactory.getLogger(UserDictLocator.class); public String userDictFilePrefix = "userdict"; @@ -43,8 +42,7 @@ public class UserDictLocator extends DictionaryLocator { if (logger.isInfoEnabled()) { logger.info("UserDict Files from " + path); } - final File[] files = findFiles(path, userDictFilePrefix, - excludedUserDictList); + final File[] files = findFiles(path, userDictFilePrefix, excludedUserDictList); for (final File file : files) { if (logger.isInfoEnabled()) { logger.info("UserDict File: " + file.getAbsolutePath()); @@ -52,15 +50,12 @@ public class UserDictLocator extends DictionaryLocator { fileList.add(new UserDictFile(file)); } } - Collections.sort(fileList, - new Comparator>() { - @Override - public int compare( - final DictionaryFile o1, - final DictionaryFile o2) { - return o1.getName().compareTo(o2.getName()); - } - }); + Collections.sort(fileList, new Comparator>() { + @Override + public int compare(final DictionaryFile o1, final DictionaryFile o2) { + return o1.getName().compareTo(o2.getName()); + } + }); return fileList; } diff --git a/src/main/java/org/codelibs/fess/ds/DataStore.java b/src/main/java/org/codelibs/fess/ds/DataStore.java index 0cb4c8953..3a4bb4b7d 100644 --- a/src/main/java/org/codelibs/fess/ds/DataStore.java +++ b/src/main/java/org/codelibs/fess/ds/DataStore.java @@ -22,8 +22,7 @@ import org.codelibs.fess.db.exentity.DataCrawlingConfig; public interface DataStore { - void store(DataCrawlingConfig config, IndexUpdateCallback callback, - Map initParamMap); + void store(DataCrawlingConfig config, IndexUpdateCallback callback, Map initParamMap); void stop(); diff --git a/src/main/java/org/codelibs/fess/ds/DataStoreCrawlingException.java b/src/main/java/org/codelibs/fess/ds/DataStoreCrawlingException.java index 40e777454..85e82dd45 100644 --- a/src/main/java/org/codelibs/fess/ds/DataStoreCrawlingException.java +++ b/src/main/java/org/codelibs/fess/ds/DataStoreCrawlingException.java @@ -24,8 +24,7 @@ public class DataStoreCrawlingException extends RobotCrawlAccessException { private final String url; - public DataStoreCrawlingException(final String url, final String message, - final Exception e) { + public DataStoreCrawlingException(final String url, final String message, final Exception e) { super(message, e); this.url = url; } diff --git a/src/main/java/org/codelibs/fess/ds/impl/AbstractDataStoreImpl.java b/src/main/java/org/codelibs/fess/ds/impl/AbstractDataStoreImpl.java index 095529ac3..b1218211b 100644 --- a/src/main/java/org/codelibs/fess/ds/impl/AbstractDataStoreImpl.java +++ b/src/main/java/org/codelibs/fess/ds/impl/AbstractDataStoreImpl.java @@ -37,8 +37,7 @@ import org.slf4j.LoggerFactory; public abstract class AbstractDataStoreImpl implements DataStore { - private static final Logger logger = LoggerFactory - .getLogger(AbstractDataStoreImpl.class); + private static final Logger logger = LoggerFactory.getLogger(AbstractDataStoreImpl.class); public String mimeType = "application/datastore"; @@ -50,17 +49,11 @@ public abstract class AbstractDataStoreImpl implements DataStore { } @Override - public void store(final DataCrawlingConfig config, - final IndexUpdateCallback callback, - final Map initParamMap) { - final Map configParamMap = config - .getHandlerParameterMap(); - final Map configScriptMap = config - .getHandlerScriptMap(); - final CrawlingSessionHelper crawlingSessionHelper = ComponentUtil - .getCrawlingSessionHelper(); - final LocalDateTime documentExpires = crawlingSessionHelper - .getDocumentExpires(); + public void store(final DataCrawlingConfig config, final IndexUpdateCallback callback, final Map initParamMap) { + final Map configParamMap = config.getHandlerParameterMap(); + final Map configScriptMap = config.getHandlerScriptMap(); + final CrawlingSessionHelper crawlingSessionHelper = ComponentUtil.getCrawlingSessionHelper(); + final LocalDateTime documentExpires = crawlingSessionHelper.getDocumentExpires(); final FieldHelper fieldHelper = ComponentUtil.getFieldHelper(); initParamMap.putAll(configParamMap); @@ -76,17 +69,14 @@ public abstract class AbstractDataStoreImpl implements DataStore { } // expires if (documentExpires != null) { - defaultDataMap.put(fieldHelper.expiresField, - FessFunctions.formatDate(documentExpires)); + defaultDataMap.put(fieldHelper.expiresField, FessFunctions.formatDate(documentExpires)); } // segment - defaultDataMap.put(fieldHelper.segmentField, - initParamMap.get(Constants.SESSION_ID)); + defaultDataMap.put(fieldHelper.segmentField, initParamMap.get(Constants.SESSION_ID)); // created defaultDataMap.put(fieldHelper.createdField, "NOW"); // boost - defaultDataMap - .put(fieldHelper.boostField, config.getBoost().toString()); + defaultDataMap.put(fieldHelper.boostField, config.getBoost().toString()); // label: labelType final List labelTypeList = new ArrayList(); for (final String labelType : config.getLabelTypeValues()) { @@ -117,8 +107,7 @@ public abstract class AbstractDataStoreImpl implements DataStore { } - protected Object convertValue(final String template, - final Map paramMap) { + protected Object convertValue(final String template, final Map paramMap) { if (StringUtil.isEmpty(template)) { return StringUtil.EMPTY; } @@ -152,11 +141,9 @@ public abstract class AbstractDataStoreImpl implements DataStore { protected void sleep(final long interval) { try { Thread.sleep(interval); - } catch (final Exception e) { - } + } catch (final Exception e) {} } - protected abstract void storeData(DataCrawlingConfig dataConfig, - IndexUpdateCallback callback, Map paramMap, + protected abstract void storeData(DataCrawlingConfig dataConfig, IndexUpdateCallback callback, Map paramMap, Map scriptMap, Map defaultDataMap); } diff --git a/src/main/java/org/codelibs/fess/ds/impl/CsvDataStoreImpl.java b/src/main/java/org/codelibs/fess/ds/impl/CsvDataStoreImpl.java index f91fb0b0d..68c6c9f3d 100644 --- a/src/main/java/org/codelibs/fess/ds/impl/CsvDataStoreImpl.java +++ b/src/main/java/org/codelibs/fess/ds/impl/CsvDataStoreImpl.java @@ -46,8 +46,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class CsvDataStoreImpl extends AbstractDataStoreImpl { - private static final Logger logger = LoggerFactory - .getLogger(CsvDataStoreImpl.class); + private static final Logger logger = LoggerFactory.getLogger(CsvDataStoreImpl.class); protected static final String ESCAPE_CHARACTER_PARAM = "escapeCharacter"; @@ -114,8 +113,7 @@ public class CsvDataStoreImpl extends AbstractDataStoreImpl { final String[] values = value.split(","); for (final String path : values) { final File file = new File(path); - if (file.isFile() - && isCsvFile(file.getParentFile(), file.getName())) { + if (file.isFile() && isCsvFile(file.getParentFile(), file.getName())) { fileList.add(file); } else { logger.warn(path + " is not found."); @@ -159,11 +157,8 @@ public class CsvDataStoreImpl extends AbstractDataStoreImpl { } @Override - protected void storeData(final DataCrawlingConfig dataConfig, - final IndexUpdateCallback callback, - final Map paramMap, - final Map scriptMap, - final Map defaultDataMap) { + protected void storeData(final DataCrawlingConfig dataConfig, final IndexUpdateCallback callback, final Map paramMap, + final Map scriptMap, final Map defaultDataMap) { final long readInterval = getReadInterval(paramMap); @@ -178,25 +173,18 @@ public class CsvDataStoreImpl extends AbstractDataStoreImpl { final CsvConfig csvConfig = buildCsvConfig(paramMap); for (final File csvFile : csvFileList) { - processCsv(dataConfig, callback, paramMap, scriptMap, - defaultDataMap, csvConfig, csvFile, readInterval, - csvFileEncoding, hasHeaderLine); + processCsv(dataConfig, callback, paramMap, scriptMap, defaultDataMap, csvConfig, csvFile, readInterval, csvFileEncoding, + hasHeaderLine); } } - protected void processCsv(final DataCrawlingConfig dataConfig, - final IndexUpdateCallback callback, - final Map paramMap, - final Map scriptMap, - final Map defaultDataMap, - final CsvConfig csvConfig, final File csvFile, - final long readInterval, final String csvFileEncoding, - final boolean hasHeaderLine) { + protected void processCsv(final DataCrawlingConfig dataConfig, final IndexUpdateCallback callback, final Map paramMap, + final Map scriptMap, final Map defaultDataMap, final CsvConfig csvConfig, final File csvFile, + final long readInterval, final String csvFileEncoding, final boolean hasHeaderLine) { logger.info("Loading " + csvFile.getAbsolutePath()); CsvReader csvReader = null; try { - csvReader = new CsvReader(new BufferedReader(new InputStreamReader( - new FileInputStream(csvFile), csvFileEncoding)), csvConfig); + csvReader = new CsvReader(new BufferedReader(new InputStreamReader(new FileInputStream(csvFile), csvFileEncoding)), csvConfig); List headerList = null; if (hasHeaderLine) { headerList = csvReader.readValues(); @@ -227,24 +215,20 @@ public class CsvDataStoreImpl extends AbstractDataStoreImpl { } if (logger.isDebugEnabled()) { - for (final Map.Entry entry : resultMap - .entrySet()) { + for (final Map.Entry entry : resultMap.entrySet()) { logger.debug(entry.getKey() + "=" + entry.getValue()); } } - for (final Map.Entry entry : scriptMap - .entrySet()) { - final Object convertValue = convertValue(entry.getValue(), - resultMap); + for (final Map.Entry entry : scriptMap.entrySet()) { + final Object convertValue = convertValue(entry.getValue(), resultMap); if (convertValue != null) { dataMap.put(entry.getKey(), convertValue); } } if (logger.isDebugEnabled()) { - for (final Map.Entry entry : dataMap - .entrySet()) { + for (final Map.Entry entry : dataMap.entrySet()) { logger.debug(entry.getKey() + "=" + entry.getValue()); } } @@ -254,8 +238,7 @@ public class CsvDataStoreImpl extends AbstractDataStoreImpl { } catch (final RobotCrawlAccessException e) { Throwable target = e; if (target instanceof RobotMultipleCrawlAccessException) { - final Throwable[] causes = ((RobotMultipleCrawlAccessException) target) - .getCauses(); + final Throwable[] causes = ((RobotMultipleCrawlAccessException) target).getCauses(); if (causes.length > 0) { target = causes[causes.length - 1]; } @@ -273,22 +256,17 @@ public class CsvDataStoreImpl extends AbstractDataStoreImpl { if (target instanceof DataStoreCrawlingException) { url = ((DataStoreCrawlingException) target).getUrl(); } else { - url = csvFile.getAbsolutePath() + ":" - + csvReader.getLineNumber(); + url = csvFile.getAbsolutePath() + ":" + csvReader.getLineNumber(); } - final FailureUrlService failureUrlService = SingletonS2Container - .getComponent(FailureUrlService.class); + final FailureUrlService failureUrlService = SingletonS2Container.getComponent(FailureUrlService.class); failureUrlService.store(dataConfig, errorName, url, target); logger.warn("Crawling Access Exception at : " + dataMap, e); } catch (final Exception e) { - final String url = csvFile.getAbsolutePath() + ":" - + csvReader.getLineNumber(); - final FailureUrlService failureUrlService = SingletonS2Container - .getComponent(FailureUrlService.class); - failureUrlService.store(dataConfig, e.getClass() - .getCanonicalName(), url, e); + final String url = csvFile.getAbsolutePath() + ":" + csvReader.getLineNumber(); + final FailureUrlService failureUrlService = SingletonS2Container.getComponent(FailureUrlService.class); + failureUrlService.store(dataConfig, e.getClass().getCanonicalName(), url, e); logger.warn("Crawling Access Exception at : " + dataMap, e); } @@ -298,8 +276,7 @@ public class CsvDataStoreImpl extends AbstractDataStoreImpl { } } } catch (final Exception e) { - throw new DataStoreException( - "Failed to crawl data when reading csv file.", e); + throw new DataStoreException("Failed to crawl data when reading csv file.", e); } finally { IOUtils.closeQuietly(csvReader); } @@ -314,8 +291,7 @@ public class CsvDataStoreImpl extends AbstractDataStoreImpl { try { csvConfig.setSeparator(value.charAt(0)); } catch (final Exception e) { - logger.warn("Failed to load " + SEPARATOR_CHARACTER_PARAM, - e); + logger.warn("Failed to load " + SEPARATOR_CHARACTER_PARAM, e); } } } @@ -387,26 +363,21 @@ public class CsvDataStoreImpl extends AbstractDataStoreImpl { if (StringUtil.isNotBlank(value)) { try { // 項目値前のホワイトスペースを除去します。 - csvConfig.setIgnoreLeadingWhitespaces(Boolean - .parseBoolean(value)); + csvConfig.setIgnoreLeadingWhitespaces(Boolean.parseBoolean(value)); } catch (final Exception e) { - logger.warn("Failed to load " - + IGNORE_LEADING_WHITESPACES_PARAM, e); + logger.warn("Failed to load " + IGNORE_LEADING_WHITESPACES_PARAM, e); } } } if (paramMap.containsKey(IGNORE_TRAILING_WHITESPACES_PARAM)) { - final String value = paramMap - .get(IGNORE_TRAILING_WHITESPACES_PARAM); + final String value = paramMap.get(IGNORE_TRAILING_WHITESPACES_PARAM); if (StringUtil.isNotBlank(value)) { try { // 項目値後のホワイトスペースを除去します。 - csvConfig.setIgnoreTrailingWhitespaces(Boolean - .parseBoolean(value)); + csvConfig.setIgnoreTrailingWhitespaces(Boolean.parseBoolean(value)); } catch (final Exception e) { - logger.warn("Failed to load " - + IGNORE_TRAILING_WHITESPACES_PARAM, e); + logger.warn("Failed to load " + IGNORE_TRAILING_WHITESPACES_PARAM, e); } } } diff --git a/src/main/java/org/codelibs/fess/ds/impl/DatabaseDataStoreImpl.java b/src/main/java/org/codelibs/fess/ds/impl/DatabaseDataStoreImpl.java index c6a136c20..091241106 100644 --- a/src/main/java/org/codelibs/fess/ds/impl/DatabaseDataStoreImpl.java +++ b/src/main/java/org/codelibs/fess/ds/impl/DatabaseDataStoreImpl.java @@ -36,8 +36,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class DatabaseDataStoreImpl extends AbstractDataStoreImpl { - private static final Logger logger = LoggerFactory - .getLogger(DatabaseDataStoreImpl.class); + private static final Logger logger = LoggerFactory.getLogger(DatabaseDataStoreImpl.class); private static final String SQL_PARAM = "sql"; @@ -78,11 +77,8 @@ public class DatabaseDataStoreImpl extends AbstractDataStoreImpl { } @Override - protected void storeData(final DataCrawlingConfig config, - final IndexUpdateCallback callback, - final Map paramMap, - final Map scriptMap, - final Map defaultDataMap) { + protected void storeData(final DataCrawlingConfig config, final IndexUpdateCallback callback, final Map paramMap, + final Map scriptMap, final Map defaultDataMap) { final long readInterval = getReadInterval(paramMap); @@ -107,10 +103,8 @@ public class DatabaseDataStoreImpl extends AbstractDataStoreImpl { while (rs.next() && loop && alive) { final Map dataMap = new HashMap(); dataMap.putAll(defaultDataMap); - for (final Map.Entry entry : scriptMap - .entrySet()) { - final Object convertValue = convertValue(entry.getValue(), - rs, paramMap); + for (final Map.Entry entry : scriptMap.entrySet()) { + final Object convertValue = convertValue(entry.getValue(), rs, paramMap); if (convertValue != null) { dataMap.put(entry.getKey(), convertValue); } @@ -156,17 +150,14 @@ public class DatabaseDataStoreImpl extends AbstractDataStoreImpl { } } - protected Object convertValue(final String template, final ResultSet rs, - final Map paramMap) { - return convertValue(template, new ResultSetParamMap(rs, - paramMap)); + protected Object convertValue(final String template, final ResultSet rs, final Map paramMap) { + return convertValue(template, new ResultSetParamMap(rs, paramMap)); } protected static class ResultSetParamMap implements Map { private final Map paramMap = new HashMap(); - public ResultSetParamMap(final ResultSet resultSet, - final Map paramMap) { + public ResultSetParamMap(final ResultSet resultSet, final Map paramMap) { this.paramMap.putAll(paramMap); try { @@ -178,9 +169,7 @@ public class DatabaseDataStoreImpl extends AbstractDataStoreImpl { final String value = resultSet.getString(i + 1); this.paramMap.put((K) label, (V) value); } catch (final SQLException e) { - logger.warn( - "Failed to parse data in a result set. The column is " - + (i + 1) + ".", e); + logger.warn("Failed to parse data in a result set. The column is " + (i + 1) + ".", e); } } } catch (final Exception e) { diff --git a/src/main/java/org/codelibs/fess/ds/impl/FileListDataStoreImpl.java b/src/main/java/org/codelibs/fess/ds/impl/FileListDataStoreImpl.java index 82d0bd90e..6ef5637a3 100644 --- a/src/main/java/org/codelibs/fess/ds/impl/FileListDataStoreImpl.java +++ b/src/main/java/org/codelibs/fess/ds/impl/FileListDataStoreImpl.java @@ -53,8 +53,7 @@ import org.slf4j.LoggerFactory; public class FileListDataStoreImpl extends CsvDataStoreImpl { - private static final Logger logger = LoggerFactory - .getLogger(FileListDataStoreImpl.class); + private static final Logger logger = LoggerFactory.getLogger(FileListDataStoreImpl.class); public boolean deleteProcessedFile = true; @@ -76,11 +75,9 @@ public class FileListDataStoreImpl extends CsvDataStoreImpl { protected CrawlingSessionHelper crawlingSessionHelper; - public Map parentEncodingMap = Collections - .synchronizedMap(new LruHashMap(1000)); + public Map parentEncodingMap = Collections.synchronizedMap(new LruHashMap(1000)); - public String[] ignoreFieldNames = new String[] { - Constants.INDEXING_TARGET, Constants.SESSION_ID }; + public String[] ignoreFieldNames = new String[] { Constants.INDEXING_TARGET, Constants.SESSION_ID }; @Override protected boolean isCsvFile(final File parentFile, final String filename) { @@ -93,12 +90,9 @@ public class FileListDataStoreImpl extends CsvDataStoreImpl { } @Override - public void store(final DataCrawlingConfig config, - final IndexUpdateCallback callback, - final Map initParamMap) { + public void store(final DataCrawlingConfig config, final IndexUpdateCallback callback, final Map initParamMap) { - robotClientFactory = SingletonS2Container - .getComponent(S2RobotClientFactory.class); + robotClientFactory = SingletonS2Container.getComponent(S2RobotClientFactory.class); config.initializeClientFactory(robotClientFactory); @@ -106,29 +100,19 @@ public class FileListDataStoreImpl extends CsvDataStoreImpl { } @Override - protected void storeData(final DataCrawlingConfig dataConfig, - final IndexUpdateCallback callback, - final Map paramMap, - final Map scriptMap, - final Map defaultDataMap) { + protected void storeData(final DataCrawlingConfig dataConfig, final IndexUpdateCallback callback, final Map paramMap, + final Map scriptMap, final Map defaultDataMap) { - super.storeData(dataConfig, new FileListIndexUpdateCallback(callback), - paramMap, scriptMap, defaultDataMap); + super.storeData(dataConfig, new FileListIndexUpdateCallback(callback), paramMap, scriptMap, defaultDataMap); } @Override - protected void processCsv(final DataCrawlingConfig dataConfig, - final IndexUpdateCallback callback, - final Map paramMap, - final Map scriptMap, - final Map defaultDataMap, - final CsvConfig csvConfig, final File csvFile, - final long readInterval, final String csvFileEncoding, - final boolean hasHeaderLine) { + protected void processCsv(final DataCrawlingConfig dataConfig, final IndexUpdateCallback callback, final Map paramMap, + final Map scriptMap, final Map defaultDataMap, final CsvConfig csvConfig, final File csvFile, + final long readInterval, final String csvFileEncoding, final boolean hasHeaderLine) { try { - super.processCsv(dataConfig, callback, paramMap, scriptMap, - defaultDataMap, csvConfig, csvFile, readInterval, - csvFileEncoding, hasHeaderLine); + super.processCsv(dataConfig, callback, paramMap, scriptMap, defaultDataMap, csvConfig, csvFile, readInterval, csvFileEncoding, + hasHeaderLine); // delete csv file if (deleteProcessedFile && !csvFile.delete()) { @@ -136,14 +120,10 @@ public class FileListDataStoreImpl extends CsvDataStoreImpl { } } catch (final DataStoreException e) { if (ignoreDataStoreException) { - logger.error("Failed to process " + csvFile.getAbsolutePath(), - e); + logger.error("Failed to process " + csvFile.getAbsolutePath(), e); // rename csv file, or delete it if failed - if (!csvFile.renameTo(new File(csvFile.getParent(), csvFile - .getName() + ".txt")) - && !csvFile.delete()) { - logger.warn("Failed to delete {}", - csvFile.getAbsolutePath()); + if (!csvFile.renameTo(new File(csvFile.getParent(), csvFile.getName() + ".txt")) && !csvFile.delete()) { + logger.warn("Failed to delete {}", csvFile.getAbsolutePath()); } } else { throw e; @@ -156,8 +136,7 @@ public class FileListDataStoreImpl extends CsvDataStoreImpl { protected List deleteIdList = new ArrayList(); - protected FileListIndexUpdateCallback( - final IndexUpdateCallback indexUpdateCallback) { + protected FileListIndexUpdateCallback(final IndexUpdateCallback indexUpdateCallback) { this.indexUpdateCallback = indexUpdateCallback; } @@ -166,8 +145,7 @@ public class FileListDataStoreImpl extends CsvDataStoreImpl { public boolean store(final Map dataMap) { final Object eventType = dataMap.remove(eventTypeField); - if (createEventName.equals(eventType) - || modifyEventName.equals(eventType)) { + if (createEventName.equals(eventType) || modifyEventName.equals(eventType)) { // updated file return addDocument(dataMap); } else if (deleteEventName.equals(eventType)) { @@ -183,56 +161,44 @@ public class FileListDataStoreImpl extends CsvDataStoreImpl { final FieldHelper fieldHelper = ComponentUtil.getFieldHelper(); synchronized (indexUpdateCallback) { // required check - if (!dataMap.containsKey(fieldHelper.urlField) - || dataMap.get(fieldHelper.urlField) == null) { + if (!dataMap.containsKey(fieldHelper.urlField) || dataMap.get(fieldHelper.urlField) == null) { logger.warn("Could not add a doc. Invalid data: " + dataMap); return false; } final String url = dataMap.get(fieldHelper.urlField).toString(); try { - final S2RobotClient client = robotClientFactory - .getClient(url); + final S2RobotClient client = robotClientFactory.getClient(url); if (client == null) { logger.warn("S2RobotClient is null. Data: " + dataMap); return false; } final long startTime = System.currentTimeMillis(); - final ResponseData responseData = client - .execute(RequestDataBuilder.newRequestData().get() - .url(url).build()); - responseData.setExecutionTime(System.currentTimeMillis() - - startTime); - responseData.setSessionId((String) dataMap - .get(Constants.SESSION_ID)); + final ResponseData responseData = client.execute(RequestDataBuilder.newRequestData().get().url(url).build()); + responseData.setExecutionTime(System.currentTimeMillis() - startTime); + responseData.setSessionId((String) dataMap.get(Constants.SESSION_ID)); - final RuleManager ruleManager = SingletonS2Container - .getComponent(RuleManager.class); + final RuleManager ruleManager = SingletonS2Container.getComponent(RuleManager.class); final Rule rule = ruleManager.getRule(responseData); if (rule == null) { logger.warn("No url rule. Data: " + dataMap); return false; } else { responseData.setRuleId(rule.getRuleId()); - final ResponseProcessor responseProcessor = rule - .getResponseProcessor(); + final ResponseProcessor responseProcessor = rule.getResponseProcessor(); if (responseProcessor instanceof DefaultResponseProcessor) { - final Transformer transformer = ((DefaultResponseProcessor) responseProcessor) - .getTransformer(); - final ResultData resultData = transformer - .transform(responseData); + final Transformer transformer = ((DefaultResponseProcessor) responseProcessor).getTransformer(); + final ResultData resultData = transformer.transform(responseData); final byte[] data = resultData.getData(); if (data != null) { try { @SuppressWarnings("unchecked") - final Map responseDataMap = (Map) SerializeUtil - .fromBinaryToObject(data); + final Map responseDataMap = + (Map) SerializeUtil.fromBinaryToObject(data); dataMap.putAll(responseDataMap); } catch (final Exception e) { - throw new RobotSystemException( - "Could not create an instance from bytes.", - e); + throw new RobotSystemException("Could not create an instance from bytes.", e); } } @@ -243,14 +209,13 @@ public class FileListDataStoreImpl extends CsvDataStoreImpl { return indexUpdateCallback.store(dataMap); } else { - logger.warn("The response processor is not DefaultResponseProcessor. responseProcessor: " - + responseProcessor + ", Data: " + dataMap); + logger.warn("The response processor is not DefaultResponseProcessor. responseProcessor: " + responseProcessor + + ", Data: " + dataMap); return false; } } } catch (final Exception e) { - throw new DataStoreCrawlingException(url, "Failed to add: " - + dataMap, e); + throw new DataStoreCrawlingException(url, "Failed to add: " + dataMap, e); } } } @@ -264,8 +229,7 @@ public class FileListDataStoreImpl extends CsvDataStoreImpl { final FieldHelper fieldHelper = ComponentUtil.getFieldHelper(); // required check - if (!dataMap.containsKey(fieldHelper.urlField) - || dataMap.get(fieldHelper.urlField) == null) { + if (!dataMap.containsKey(fieldHelper.urlField) || dataMap.get(fieldHelper.urlField) == null) { logger.warn("Could not delete a doc. Invalid data: " + dataMap); return false; } @@ -274,11 +238,9 @@ public class FileListDataStoreImpl extends CsvDataStoreImpl { deleteIdList.add(crawlingSessionHelper.generateId(dataMap)); if (deleteIdList.size() >= maxDeleteDocumentCacheSize) { - final IndexingHelper indexingHelper = ComponentUtil - .getIndexingHelper(); + final IndexingHelper indexingHelper = ComponentUtil.getIndexingHelper(); for (final String id : deleteIdList) { - indexingHelper.deleteDocument( - indexUpdateCallback.getSolrGroup(), id); + indexingHelper.deleteDocument(indexUpdateCallback.getSolrGroup(), id); } if (logger.isDebugEnabled()) { logger.debug("Deleted " + deleteIdList); @@ -313,11 +275,9 @@ public class FileListDataStoreImpl extends CsvDataStoreImpl { @Override public void commit() { if (!deleteIdList.isEmpty()) { - final IndexingHelper indexingHelper = ComponentUtil - .getIndexingHelper(); + final IndexingHelper indexingHelper = ComponentUtil.getIndexingHelper(); for (final String id : deleteIdList) { - indexingHelper.deleteDocument( - indexUpdateCallback.getSolrGroup(), id); + indexingHelper.deleteDocument(indexUpdateCallback.getSolrGroup(), id); } if (logger.isDebugEnabled()) { logger.debug("Deleted " + deleteIdList); diff --git a/src/main/java/org/codelibs/fess/ds/impl/IndexUpdateCallbackImpl.java b/src/main/java/org/codelibs/fess/ds/impl/IndexUpdateCallbackImpl.java index b522103de..51b617a9c 100644 --- a/src/main/java/org/codelibs/fess/ds/impl/IndexUpdateCallbackImpl.java +++ b/src/main/java/org/codelibs/fess/ds/impl/IndexUpdateCallbackImpl.java @@ -36,8 +36,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class IndexUpdateCallbackImpl implements IndexUpdateCallback { - private static final Logger logger = LoggerFactory - .getLogger(IndexUpdateCallbackImpl.class); + private static final Logger logger = LoggerFactory.getLogger(IndexUpdateCallbackImpl.class); protected SolrGroup solrGroup; @@ -80,18 +79,14 @@ public class IndexUpdateCallbackImpl implements IndexUpdateCallback { } final IndexingHelper indexingHelper = ComponentUtil.getIndexingHelper(); - final CrawlingSessionHelper crawlingSessionHelper = ComponentUtil - .getCrawlingSessionHelper(); - dataMap.put(fieldHelper.idField, - crawlingSessionHelper.generateId(dataMap)); + final CrawlingSessionHelper crawlingSessionHelper = ComponentUtil.getCrawlingSessionHelper(); + dataMap.put(fieldHelper.idField, crawlingSessionHelper.generateId(dataMap)); final SolrInputDocument doc = createSolrDocument(dataMap); docList.add(doc); if (logger.isDebugEnabled()) { - logger.debug("Added the document. " - + "The number of a document cache is " + docList.size() - + "."); + logger.debug("Added the document. " + "The number of a document cache is " + docList.size() + "."); } if (docList.size() >= maxDocumentCacheSize) { @@ -106,28 +101,24 @@ public class IndexUpdateCallbackImpl implements IndexUpdateCallback { commitDocuments(); } if (logger.isDebugEnabled()) { - logger.debug("The number of an added document is " - + documentSize.get() + "."); + logger.debug("The number of an added document is " + documentSize.get() + "."); } executeTime += System.currentTimeMillis() - startTime; return true; } - protected SolrInputDocument createSolrDocument( - final Map dataMap) { + protected SolrInputDocument createSolrDocument(final Map dataMap) { final String url = dataMap.get(fieldHelper.urlField).toString(); final SolrInputDocument doc = new SolrInputDocument(); for (final Map.Entry entry : dataMap.entrySet()) { if (fieldHelper.boostField.equals(entry.getKey())) { // boost - final float documentBoost = Float.valueOf(entry.getValue() - .toString()); + final float documentBoost = Float.valueOf(entry.getValue().toString()); doc.setDocumentBoost(documentBoost); if (logger.isDebugEnabled()) { - logger.debug("Set a document boost (" + documentBoost - + ")."); + logger.debug("Set a document boost (" + documentBoost + ")."); } } doc.addField(entry.getKey(), entry.getValue()); @@ -143,8 +134,7 @@ public class IndexUpdateCallbackImpl implements IndexUpdateCallback { if (!dataMap.containsKey(fieldHelper.docIdField)) { final SystemHelper systemHelper = ComponentUtil.getSystemHelper(); - doc.addField(fieldHelper.docIdField, - systemHelper.generateDocId(dataMap)); + doc.addField(fieldHelper.docIdField, systemHelper.generateDocId(dataMap)); } return doc; @@ -153,8 +143,7 @@ public class IndexUpdateCallbackImpl implements IndexUpdateCallback { @Override public void commit() { if (!docList.isEmpty()) { - final IndexingHelper indexingHelper = ComponentUtil - .getIndexingHelper(); + final IndexingHelper indexingHelper = ComponentUtil.getIndexingHelper(); indexingHelper.sendDocuments(solrGroup, docList); } commitDocuments(); @@ -169,15 +158,12 @@ public class IndexUpdateCallbackImpl implements IndexUpdateCallback { solrGroup.commit(true, true, false, true); } if (logger.isInfoEnabled()) { - logger.info("Committed documents. The execution time is " - + (System.currentTimeMillis() - execTime) + "ms."); + logger.info("Committed documents. The execution time is " + (System.currentTimeMillis() - execTime) + "ms."); } } - protected void addClickCountField(final SolrInputDocument doc, - final String url, final String clickCountField) { - final SearchLogHelper searchLogHelper = ComponentUtil - .getSearchLogHelper(); + protected void addClickCountField(final SolrInputDocument doc, final String url, final String clickCountField) { + final SearchLogHelper searchLogHelper = ComponentUtil.getSearchLogHelper(); final int count = searchLogHelper.getClickCount(url); doc.addField(clickCountField, count); if (logger.isDebugEnabled()) { @@ -185,10 +171,8 @@ public class IndexUpdateCallbackImpl implements IndexUpdateCallback { } } - protected void addFavoriteCountField(final SolrInputDocument doc, - final String url, final String favoriteCountField) { - final SearchLogHelper searchLogHelper = ComponentUtil - .getSearchLogHelper(); + protected void addFavoriteCountField(final SolrInputDocument doc, final String url, final String favoriteCountField) { + final SearchLogHelper searchLogHelper = ComponentUtil.getSearchLogHelper(); final long count = searchLogHelper.getFavoriteCount(url); doc.addField(favoriteCountField, count); if (logger.isDebugEnabled()) { diff --git a/src/main/java/org/codelibs/fess/entity/FacetInfo.java b/src/main/java/org/codelibs/fess/entity/FacetInfo.java index 9c4523aeb..f39076eb6 100644 --- a/src/main/java/org/codelibs/fess/entity/FacetInfo.java +++ b/src/main/java/org/codelibs/fess/entity/FacetInfo.java @@ -45,9 +45,7 @@ public class FacetInfo { @Override public String toString() { - return "FacetInfo [field=" + Arrays.toString(field) + ", query=" - + Arrays.toString(query) + ", prefix=" + prefix + ", limit=" - + limit + ", minCount=" + minCount + ", sort=" + sort - + ", missing=" + missing + "]"; + return "FacetInfo [field=" + Arrays.toString(field) + ", query=" + Arrays.toString(query) + ", prefix=" + prefix + ", limit=" + + limit + ", minCount=" + minCount + ", sort=" + sort + ", missing=" + missing + "]"; } } diff --git a/src/main/java/org/codelibs/fess/entity/FacetQueryView.java b/src/main/java/org/codelibs/fess/entity/FacetQueryView.java index e55069ac4..047e3a3e7 100644 --- a/src/main/java/org/codelibs/fess/entity/FacetQueryView.java +++ b/src/main/java/org/codelibs/fess/entity/FacetQueryView.java @@ -42,8 +42,7 @@ public class FacetQueryView { @Override public String toString() { - return "FacetQueryView [title=" + title + ", queryMap=" + queryMap - + "]"; + return "FacetQueryView [title=" + title + ", queryMap=" + queryMap + "]"; } } diff --git a/src/main/java/org/codelibs/fess/entity/FieldAnalysisResponse.java b/src/main/java/org/codelibs/fess/entity/FieldAnalysisResponse.java index cd83d725c..dcb5a4f1e 100644 --- a/src/main/java/org/codelibs/fess/entity/FieldAnalysisResponse.java +++ b/src/main/java/org/codelibs/fess/entity/FieldAnalysisResponse.java @@ -24,21 +24,18 @@ import java.util.Map; import org.apache.solr.common.util.NamedList; import org.apache.solr.common.util.SimpleOrderedMap; -public class FieldAnalysisResponse extends - LinkedHashMap>>> { +public class FieldAnalysisResponse extends LinkedHashMap>>> { private static final long serialVersionUID = 1L; protected long execTime; public FieldAnalysisResponse(final NamedList response) { - final NamedList fnList = getNamedList( - getNamedList(response, "analysis"), "field_names"); + final NamedList fnList = getNamedList(getNamedList(response, "analysis"), "field_names"); if (fnList != null) { for (int i = 0; i < fnList.size(); i++) { final String fieldName = fnList.getName(i); - final NamedList analysisList = getNamedList( - fnList.getVal(i), "index"); + final NamedList analysisList = getNamedList(fnList.getVal(i), "index"); final Map>> analysisMap = new LinkedHashMap>>(); put(fieldName, analysisMap); @@ -56,17 +53,14 @@ public class FieldAnalysisResponse extends } } - private List> getDataMap( - final List analysisDataList) { + private List> getDataMap(final List analysisDataList) { final List> dataMapList = new ArrayList>(); for (final Object dataList : analysisDataList) { if (dataList instanceof SimpleOrderedMap) { final Map dataMap = new LinkedHashMap(); for (int k = 0; k < ((SimpleOrderedMap) dataList).size(); k++) { - final String dataName = ((SimpleOrderedMap) dataList) - .getName(k); - final Object dataObj = ((SimpleOrderedMap) dataList) - .getVal(k); + final String dataName = ((SimpleOrderedMap) dataList).getName(k); + final Object dataObj = ((SimpleOrderedMap) dataList).getVal(k); dataMap.put(dataName, dataObj); } dataMapList.add(dataMap); diff --git a/src/main/java/org/codelibs/fess/entity/GeoInfo.java b/src/main/java/org/codelibs/fess/entity/GeoInfo.java index 6cef60830..80d7cf465 100644 --- a/src/main/java/org/codelibs/fess/entity/GeoInfo.java +++ b/src/main/java/org/codelibs/fess/entity/GeoInfo.java @@ -39,8 +39,7 @@ public class GeoInfo { if (!isInit) { isInit = true; - if (StringUtil.isBlank(latitude) || StringUtil.isBlank(longitude) - || StringUtil.isBlank(distance)) { + if (StringUtil.isBlank(latitude) || StringUtil.isBlank(longitude) || StringUtil.isBlank(distance)) { latitude = null; longitude = null; distance = null; @@ -88,20 +87,16 @@ public class GeoInfo { public boolean isAvailable() { init(); - return StringUtil.isNotBlank(latitude) - && StringUtil.isNotBlank(longitude) - && StringUtil.isNotBlank(distance); + return StringUtil.isNotBlank(latitude) && StringUtil.isNotBlank(longitude) && StringUtil.isNotBlank(distance); } public String toGeoQueryString() { init(); - return "{!geofilt pt=" + latitude + "," + longitude - + " sfield=location d=" + distance + "}"; + return "{!geofilt pt=" + latitude + "," + longitude + " sfield=location d=" + distance + "}"; } @Override public String toString() { - return "GeoInfo [latitude=" + latitude + ", longitude=" + longitude - + ", distance=" + distance + ", isInit=" + isInit + "]"; + return "GeoInfo [latitude=" + latitude + ", longitude=" + longitude + ", distance=" + distance + ", isInit=" + isInit + "]"; } } diff --git a/src/main/java/org/codelibs/fess/entity/LoginInfo.java b/src/main/java/org/codelibs/fess/entity/LoginInfo.java index 207366123..26dc48078 100644 --- a/src/main/java/org/codelibs/fess/entity/LoginInfo.java +++ b/src/main/java/org/codelibs/fess/entity/LoginInfo.java @@ -34,8 +34,7 @@ public class LoginInfo extends UserInfo { } public boolean isAdministrator() { - for (final String role : ComponentUtil.getSystemHelper() - .getAdminRoleSet()) { + for (final String role : ComponentUtil.getSystemHelper().getAdminRoleSet()) { if (isUserInRole(role)) { return true; } diff --git a/src/main/java/org/codelibs/fess/entity/MoreLikeThisInfo.java b/src/main/java/org/codelibs/fess/entity/MoreLikeThisInfo.java index ea903131b..5418e2af5 100644 --- a/src/main/java/org/codelibs/fess/entity/MoreLikeThisInfo.java +++ b/src/main/java/org/codelibs/fess/entity/MoreLikeThisInfo.java @@ -30,7 +30,6 @@ public class MoreLikeThisInfo { @Override public String toString() { - return "MoreLikeThisInfo [field=" + Arrays.toString(field) + ", count=" - + count + "]"; + return "MoreLikeThisInfo [field=" + Arrays.toString(field) + ", count=" + count + "]"; } } diff --git a/src/main/java/org/codelibs/fess/entity/PingResponse.java b/src/main/java/org/codelibs/fess/entity/PingResponse.java index 179e3d489..d3de0bef5 100644 --- a/src/main/java/org/codelibs/fess/entity/PingResponse.java +++ b/src/main/java/org/codelibs/fess/entity/PingResponse.java @@ -34,8 +34,7 @@ public class PingResponse { if (status != 0) { status = 1; } - targetList.add(new Target(status, response.getRequestUrl(), - response.getElapsedTime(), response.getQTime())); + targetList.add(new Target(status, response.getRequestUrl(), response.getElapsedTime(), response.getQTime())); } targets = targetList.toArray(new Target[targetList.size()]); } @@ -50,8 +49,7 @@ public class PingResponse { private final int queryTime; - public Target(final int status, final String url, - final long elapsedTime, final int qTime) { + public Target(final int status, final String url, final long elapsedTime, final int qTime) { this.status = status; this.url = url; searchTime = elapsedTime; diff --git a/src/main/java/org/codelibs/fess/entity/SearchQuery.java b/src/main/java/org/codelibs/fess/entity/SearchQuery.java index 70c62ac31..192287108 100644 --- a/src/main/java/org/codelibs/fess/entity/SearchQuery.java +++ b/src/main/java/org/codelibs/fess/entity/SearchQuery.java @@ -51,8 +51,7 @@ public class SearchQuery { } public void addSortField(final String field, final String order) { - if (StringUtil.isNotBlank(field) - && (Constants.ASC.equals(order) || Constants.DESC.equals(order))) { + if (StringUtil.isNotBlank(field) && (Constants.ASC.equals(order) || Constants.DESC.equals(order))) { final SortField sortField = new SortField(); sortField.setField(field); sortField.setOrder(order); @@ -126,8 +125,7 @@ public class SearchQuery { @Override public String toString() { - return "SearchQuery [query=" + query + ", filterQueryList=" - + filterQueryList + ", sortFieldList=" + sortFieldList + return "SearchQuery [query=" + query + ", filterQueryList=" + filterQueryList + ", sortFieldList=" + sortFieldList + ", minimumShouldMatch=" + minimumShouldMatch + "]"; } } diff --git a/src/main/java/org/codelibs/fess/exec/Crawler.java b/src/main/java/org/codelibs/fess/exec/Crawler.java index fc670fe5b..5484608e4 100644 --- a/src/main/java/org/codelibs/fess/exec/Crawler.java +++ b/src/main/java/org/codelibs/fess/exec/Crawler.java @@ -207,21 +207,16 @@ public class Crawler implements Serializable { int exitCode; try { - final ServletContext servletContext = new MockServletContextImpl( - "/fess"); - final HttpServletRequest request = new MockHttpServletRequestImpl( - servletContext, "/crawler"); - final HttpServletResponse response = new MockHttpServletResponseImpl( - request); + final ServletContext servletContext = new MockServletContextImpl("/fess"); + final HttpServletRequest request = new MockHttpServletRequestImpl(servletContext, "/crawler"); + final HttpServletResponse response = new MockHttpServletResponseImpl(request); final SingletonS2ContainerInitializer initializer = new SingletonS2ContainerInitializer(); initializer.setConfigPath("app.dicon"); initializer.setApplication(servletContext); initializer.initialize(); - final S2Container container = SingletonS2ContainerFactory - .getContainer(); - final ExternalContext externalContext = container - .getExternalContext(); + final S2Container container = SingletonS2ContainerFactory.getContainer(); + final ExternalContext externalContext = container.getExternalContext(); externalContext.setRequest(request); externalContext.setResponse(response); @@ -250,8 +245,7 @@ public class Crawler implements Serializable { } private static int process(final Options options) { - final Crawler crawler = SingletonS2Container - .getComponent(Crawler.class); + final Crawler crawler = SingletonS2Container.getComponent(Crawler.class); final DatabaseHelper databaseHelper = ComponentUtil.getDatabaseHelper(); databaseHelper.optimize(); @@ -262,20 +256,16 @@ public class Crawler implements Serializable { options.sessionId = sdf.format(new Date()); } - final CrawlingSessionHelper crawlingSessionHelper = ComponentUtil - .getCrawlingSessionHelper(); - final DynamicProperties crawlerProperties = ComponentUtil - .getCrawlerProperties(); + final CrawlingSessionHelper crawlingSessionHelper = ComponentUtil.getCrawlingSessionHelper(); + final DynamicProperties crawlerProperties = ComponentUtil.getCrawlerProperties(); if (StringUtil.isNotBlank(options.propertiesPath)) { crawlerProperties.reload(options.propertiesPath); } else { try { - final File propFile = File.createTempFile("crawler_", - ".properties"); + final File propFile = File.createTempFile("crawler_", ".properties"); if (propFile.delete() && logger.isDebugEnabled()) { - logger.debug("Deleted a temp file: " - + propFile.getAbsolutePath()); + logger.debug("Deleted a temp file: " + propFile.getAbsolutePath()); } crawlerProperties.reload(propFile.getAbsolutePath()); propFile.deleteOnExit(); // NOSONAR @@ -290,16 +280,13 @@ public class Crawler implements Serializable { if (StringUtil.isNotBlank(options.expires)) { dayForCleanupStr = options.expires; } else { - dayForCleanupStr = crawlerProperties.getProperty( - Constants.DAY_FOR_CLEANUP_PROPERTY, "1"); + dayForCleanupStr = crawlerProperties.getProperty(Constants.DAY_FOR_CLEANUP_PROPERTY, "1"); } int dayForCleanup = -1; try { dayForCleanup = Integer.parseInt(dayForCleanupStr); - } catch (final NumberFormatException e) { - } - crawlingSessionHelper.updateParams(options.sessionId, options.name, - dayForCleanup); + } catch (final NumberFormatException e) {} + crawlingSessionHelper.updateParams(options.sessionId, options.name, dayForCleanup); } catch (final Exception e) { logger.warn("Failed to store crawling information.", e); } @@ -314,8 +301,7 @@ public class Crawler implements Serializable { } databaseHelper.optimize(); - final Map infoMap = crawlingSessionHelper - .getInfoMap(options.sessionId); + final Map infoMap = crawlingSessionHelper.getInfoMap(options.sessionId); final StringBuilder buf = new StringBuilder(500); for (final Map.Entry entry : infoMap.entrySet()) { @@ -339,33 +325,28 @@ public class Crawler implements Serializable { } public void sendMail(final Map infoMap) { - final String toStrs = (String) crawlerProperties - .get(Constants.NOTIFICATION_TO_PROPERTY); + final String toStrs = (String) crawlerProperties.get(Constants.NOTIFICATION_TO_PROPERTY); if (StringUtil.isNotBlank(toStrs)) { final String[] toAddresses = toStrs.split(","); final Map dataMap = new HashMap(); for (final Map.Entry entry : infoMap.entrySet()) { - dataMap.put(StringUtil.decapitalize(entry.getKey()), - entry.getValue()); + dataMap.put(StringUtil.decapitalize(entry.getKey()), entry.getValue()); } if (Constants.T.equals(infoMap.get(Constants.CRAWLER_STATUS))) { dataMap.put("success", true); } try { - dataMap.put("hostname", InetAddress.getLocalHost() - .getHostAddress()); + dataMap.put("hostname", InetAddress.getLocalHost().getHostAddress()); } catch (final UnknownHostException e) { // ignore } - final FileTemplateLoader loader = new FileTemplateLoader(new File( - ResourceUtil.getMailTemplatePath(StringUtil.EMPTY))); + final FileTemplateLoader loader = new FileTemplateLoader(new File(ResourceUtil.getMailTemplatePath(StringUtil.EMPTY))); final Handlebars handlebars = new Handlebars(loader); try { - final Template template = handlebars - .compile(MAIL_TEMPLATE_NAME); + final Template template = handlebars.compile(MAIL_TEMPLATE_NAME); final Context hbsContext = Context.newContext(dataMap); final String body = template.apply(hbsContext); @@ -381,54 +362,45 @@ public class Crawler implements Serializable { logger.info("Starting Crawler.."); } - final PathMappingHelper pathMappingHelper = ComponentUtil - .getPathMappingHelper(); + final PathMappingHelper pathMappingHelper = ComponentUtil.getPathMappingHelper(); final long totalTime = System.currentTimeMillis(); - final CrawlingSessionHelper crawlingSessionHelper = ComponentUtil - .getCrawlingSessionHelper(); + final CrawlingSessionHelper crawlingSessionHelper = ComponentUtil.getCrawlingSessionHelper(); final FieldHelper fieldHelper = ComponentUtil.getFieldHelper(); boolean completed = false; int exitCode = Constants.EXIT_OK; try { - writeTimeToSessionInfo(crawlingSessionHelper, - Constants.CRAWLER_START_TIME); + writeTimeToSessionInfo(crawlingSessionHelper, Constants.CRAWLER_START_TIME); - final SolrGroup updateSolrGroup = solrGroupManager - .getSolrGroup(QueryType.ADD); + final SolrGroup updateSolrGroup = solrGroupManager.getSolrGroup(QueryType.ADD); if (!updateSolrGroup.isActive(QueryType.ADD)) { - throw new FessSystemException("SolrGroup " - + updateSolrGroup.getGroupName() + " is not available."); + throw new FessSystemException("SolrGroup " + updateSolrGroup.getGroupName() + " is not available."); } // setup path mapping final List ptList = new ArrayList(); ptList.add(CDef.ProcessType.Crawling); ptList.add(CDef.ProcessType.Both); - pathMappingHelper.setPathMappingList(options.sessionId, - pathMappingService.getPathMappingList(ptList)); + pathMappingHelper.setPathMappingList(options.sessionId, pathMappingService.getPathMappingList(ptList)); // overlapping host try { - final OverlappingHostHelper overlappingHostHelper = ComponentUtil - .getOverlappingHostHelper(); + final OverlappingHostHelper overlappingHostHelper = ComponentUtil.getOverlappingHostHelper(); overlappingHostHelper.init(); } catch (final Exception e) { logger.warn("Could not initialize overlappingHostHelper.", e); } // delete expired sessions - crawlingSessionService.deleteSessionIdsBefore(options.sessionId, - options.name, ComponentUtil.getSystemHelper() - .getCurrentTime()); + crawlingSessionService + .deleteSessionIdsBefore(options.sessionId, options.name, ComponentUtil.getSystemHelper().getCurrentTime()); final List webConfigIdList = options.getWebConfigIdList(); final List fileConfigIdList = options.getFileConfigIdList(); final List dataConfigIdList = options.getDataConfigIdList(); - final boolean runAll = webConfigIdList == null - && fileConfigIdList == null && dataConfigIdList == null; + final boolean runAll = webConfigIdList == null && fileConfigIdList == null && dataConfigIdList == null; Thread webFsCrawlerThread = null; Thread dataCrawlerThread = null; @@ -438,13 +410,9 @@ public class Crawler implements Serializable { @Override public void run() { // crawl web - writeTimeToSessionInfo(crawlingSessionHelper, - Constants.WEB_FS_CRAWLER_START_TIME); - webFsIndexHelper.crawl(options.sessionId, - webConfigIdList, fileConfigIdList, - updateSolrGroup); - writeTimeToSessionInfo(crawlingSessionHelper, - Constants.WEB_FS_CRAWLER_END_TIME); + writeTimeToSessionInfo(crawlingSessionHelper, Constants.WEB_FS_CRAWLER_START_TIME); + webFsIndexHelper.crawl(options.sessionId, webConfigIdList, fileConfigIdList, updateSolrGroup); + writeTimeToSessionInfo(crawlingSessionHelper, Constants.WEB_FS_CRAWLER_END_TIME); } }, WEB_FS_CRAWLING_PROCESS); webFsCrawlerThread.start(); @@ -455,12 +423,9 @@ public class Crawler implements Serializable { @Override public void run() { // crawl data system - writeTimeToSessionInfo(crawlingSessionHelper, - Constants.DATA_CRAWLER_START_TIME); - dataIndexHelper.crawl(options.sessionId, - dataConfigIdList, updateSolrGroup); - writeTimeToSessionInfo(crawlingSessionHelper, - Constants.DATA_CRAWLER_END_TIME); + writeTimeToSessionInfo(crawlingSessionHelper, Constants.DATA_CRAWLER_START_TIME); + dataIndexHelper.crawl(options.sessionId, dataConfigIdList, updateSolrGroup); + writeTimeToSessionInfo(crawlingSessionHelper, Constants.DATA_CRAWLER_END_TIME); } }, DATA_CRAWLING_PROCESS); dataCrawlerThread.start(); @@ -471,13 +436,11 @@ public class Crawler implements Serializable { // clean up try { - updateSolrGroup.deleteByQuery(fieldHelper.expiresField - + ":[* TO " + FessFunctions.formatDate(new Date()) + updateSolrGroup.deleteByQuery(fieldHelper.expiresField + ":[* TO " + FessFunctions.formatDate(new Date()) + "] NOT segment:" + options.sessionId); } catch (final Exception e) { if (logger.isWarnEnabled()) { - logger.warn("Could not delete expired sessions in " - + updateSolrGroup.getGroupName(), e); + logger.warn("Could not delete expired sessions in " + updateSolrGroup.getGroupName(), e); } exitCode = Constants.EXIT_FAIL; } @@ -492,8 +455,7 @@ public class Crawler implements Serializable { } } - final String serverRotationStr = crawlerProperties.getProperty( - Constants.SERVER_ROTATION_PROPERTY, Constants.FALSE); + final String serverRotationStr = crawlerProperties.getProperty(Constants.SERVER_ROTATION_PROPERTY, Constants.FALSE); if (Constants.TRUE.equalsIgnoreCase(serverRotationStr)) { // apply solrGroupManager.applyNewSolrGroup(); @@ -510,28 +472,21 @@ public class Crawler implements Serializable { return Constants.EXIT_FAIL; } finally { pathMappingHelper.removePathMappingList(options.sessionId); - crawlingSessionHelper.putToInfoMap(Constants.CRAWLER_STATUS, - completed ? Constants.T : Constants.F); - writeTimeToSessionInfo(crawlingSessionHelper, - Constants.CRAWLER_END_TIME); - crawlingSessionHelper.putToInfoMap(Constants.CRAWLER_EXEC_TIME, - Long.toString(System.currentTimeMillis() - totalTime)); + crawlingSessionHelper.putToInfoMap(Constants.CRAWLER_STATUS, completed ? Constants.T : Constants.F); + writeTimeToSessionInfo(crawlingSessionHelper, Constants.CRAWLER_END_TIME); + crawlingSessionHelper.putToInfoMap(Constants.CRAWLER_EXEC_TIME, Long.toString(System.currentTimeMillis() - totalTime)); } } - protected void optimize(final CrawlingSessionHelper crawlingSessionHelper, - final SolrGroup solrGroup) { - writeTimeToSessionInfo(crawlingSessionHelper, - Constants.OPTIMIZE_START_TIME); + protected void optimize(final CrawlingSessionHelper crawlingSessionHelper, final SolrGroup solrGroup) { + writeTimeToSessionInfo(crawlingSessionHelper, Constants.OPTIMIZE_START_TIME); long startTime = System.currentTimeMillis(); solrGroup.optimize(); startTime = System.currentTimeMillis() - startTime; - writeTimeToSessionInfo(crawlingSessionHelper, - Constants.OPTIMIZE_END_TIME); + writeTimeToSessionInfo(crawlingSessionHelper, Constants.OPTIMIZE_END_TIME); if (crawlingSessionHelper != null) { - crawlingSessionHelper.putToInfoMap(Constants.OPTIMIZE_EXEC_TIME, - Long.toString(startTime)); + crawlingSessionHelper.putToInfoMap(Constants.OPTIMIZE_EXEC_TIME, Long.toString(startTime)); } // update status @@ -547,17 +502,14 @@ public class Crawler implements Serializable { } } - protected void commit(final CrawlingSessionHelper crawlingSessionHelper, - final SolrGroup solrGroup) { - writeTimeToSessionInfo(crawlingSessionHelper, - Constants.COMMIT_START_TIME); + protected void commit(final CrawlingSessionHelper crawlingSessionHelper, final SolrGroup solrGroup) { + writeTimeToSessionInfo(crawlingSessionHelper, Constants.COMMIT_START_TIME); long startTime = System.currentTimeMillis(); solrGroup.commit(true, true, false, true); startTime = System.currentTimeMillis() - startTime; writeTimeToSessionInfo(crawlingSessionHelper, Constants.COMMIT_END_TIME); if (crawlingSessionHelper != null) { - crawlingSessionHelper.putToInfoMap(Constants.COMMIT_EXEC_TIME, - Long.toString(startTime)); + crawlingSessionHelper.putToInfoMap(Constants.COMMIT_EXEC_TIME, Long.toString(startTime)); } // update status @@ -573,13 +525,10 @@ public class Crawler implements Serializable { } } - private void writeTimeToSessionInfo( - final CrawlingSessionHelper crawlingSessionHelper, final String key) { + private void writeTimeToSessionInfo(final CrawlingSessionHelper crawlingSessionHelper, final String key) { if (crawlingSessionHelper != null) { - final SimpleDateFormat dateFormat = new SimpleDateFormat( - CoreLibConstants.DATE_FORMAT_ISO_8601_EXTEND); - crawlingSessionHelper.putToInfoMap(key, - dateFormat.format(new Date())); + final SimpleDateFormat dateFormat = new SimpleDateFormat(CoreLibConstants.DATE_FORMAT_ISO_8601_EXTEND); + crawlingSessionHelper.putToInfoMap(key, dateFormat.format(new Date())); } } @@ -588,8 +537,7 @@ public class Crawler implements Serializable { try { crawlerThread.join(); } catch (final Exception e) { - logger.info("Interrupted a crawling process: " - + crawlerThread.getName()); + logger.info("Interrupted a crawling process: " + crawlerThread.getName()); } } } diff --git a/src/main/java/org/codelibs/fess/filter/AdLoginInfoFilter.java b/src/main/java/org/codelibs/fess/filter/AdLoginInfoFilter.java index 62a901822..525cf8023 100644 --- a/src/main/java/org/codelibs/fess/filter/AdLoginInfoFilter.java +++ b/src/main/java/org/codelibs/fess/filter/AdLoginInfoFilter.java @@ -40,8 +40,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class AdLoginInfoFilter implements Filter { - private static final Logger logger = LoggerFactory - .getLogger(AdLoginInfoFilter.class); + private static final Logger logger = LoggerFactory.getLogger(AdLoginInfoFilter.class); private long updateInterval = 60 * 60 * 1000L; // 1h @@ -53,24 +52,21 @@ public class AdLoginInfoFilter implements Filter { @Override public void init(final FilterConfig filterConfig) throws ServletException { - redirectLoginError = "true".equalsIgnoreCase(filterConfig - .getInitParameter("redirectLoginError")); + redirectLoginError = "true".equalsIgnoreCase(filterConfig.getInitParameter("redirectLoginError")); final String value = filterConfig.getInitParameter("updateInterval"); if (value != null) { updateInterval = Long.parseLong(value); } - useTestUser = "true".equalsIgnoreCase(filterConfig - .getInitParameter("useTestUser")); + useTestUser = "true".equalsIgnoreCase(filterConfig.getInitParameter("useTestUser")); testUserName = filterConfig.getInitParameter("testUserName"); } @Override - public void doFilter(final ServletRequest request, - final ServletResponse response, final FilterChain chain) - throws IOException, ServletException { + public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain) throws IOException, + ServletException { if (request instanceof HttpServletRequest) { final HttpServletRequest httpRequest = (HttpServletRequest) request; final HttpSession session = httpRequest.getSession(); @@ -81,17 +77,14 @@ public class AdLoginInfoFilter implements Filter { } if (StringUtil.isEmpty(userId)) { - final String servletPath = ((HttpServletRequest) request) - .getServletPath(); + final String servletPath = ((HttpServletRequest) request).getServletPath(); if (redirectLoginError && "/index.do".equals(servletPath)) { - ((HttpServletResponse) response).sendRedirect(httpRequest - .getContextPath() + "error/badRequest"); + ((HttpServletResponse) response).sendRedirect(httpRequest.getContextPath() + "error/badRequest"); return; } } - LoginInfo loginInfo = (LoginInfo) session - .getAttribute(SSCConstants.USER_INFO); + LoginInfo loginInfo = (LoginInfo) session.getAttribute(SSCConstants.USER_INFO); if (loginInfo == null) { loginInfo = new LoginInfo(); loginInfo.setUsername(userId); diff --git a/src/main/java/org/codelibs/fess/filter/FessEncodingFilter.java b/src/main/java/org/codelibs/fess/filter/FessEncodingFilter.java index 4709d6628..4057efedc 100644 --- a/src/main/java/org/codelibs/fess/filter/FessEncodingFilter.java +++ b/src/main/java/org/codelibs/fess/filter/FessEncodingFilter.java @@ -73,9 +73,8 @@ public class FessEncodingFilter extends EncodingFilter { } @Override - public void doFilter(final ServletRequest request, - final ServletResponse response, final FilterChain chain) - throws IOException, ServletException { + public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain) throws IOException, + ServletException { final HttpServletRequest req = (HttpServletRequest) request; final String servletPath = req.getServletPath(); for (final Map.Entry entry : encodingMap.entrySet()) { @@ -84,8 +83,7 @@ public class FessEncodingFilter extends EncodingFilter { req.setCharacterEncoding(entry.getValue()); final StringBuilder locationBuf = new StringBuilder(1000); final String contextPath = servletContext.getContextPath(); - if (StringUtil.isNotBlank(contextPath) - && !"/".equals(contextPath)) { + if (StringUtil.isNotBlank(contextPath) && !"/".equals(contextPath)) { locationBuf.append(contextPath); } locationBuf.append('/'); @@ -93,10 +91,8 @@ public class FessEncodingFilter extends EncodingFilter { boolean append = false; final Map parameterMap = new HashMap<>(); parameterMap.putAll(req.getParameterMap()); - parameterMap.putAll(getParameterMapFromQueryString(req, - entry.getValue())); - for (final Map.Entry paramEntry : parameterMap - .entrySet()) { + parameterMap.putAll(getParameterMapFromQueryString(req, entry.getValue())); + for (final Map.Entry paramEntry : parameterMap.entrySet()) { final String[] values = paramEntry.getValue(); if (values == null) { continue; @@ -124,9 +120,7 @@ public class FessEncodingFilter extends EncodingFilter { super.doFilter(request, response, chain); } - protected Map getParameterMapFromQueryString( - final HttpServletRequest request, final String enc) - throws IOException { + protected Map getParameterMapFromQueryString(final HttpServletRequest request, final String enc) throws IOException { final String queryString = request.getQueryString(); if (StringUtil.isNotBlank(queryString)) { return parseQueryString(queryString, enc); @@ -135,16 +129,14 @@ public class FessEncodingFilter extends EncodingFilter { } } - protected Map parseQueryString(final String queryString, - final String enc) throws IOException { + protected Map parseQueryString(final String queryString, final String enc) throws IOException { final Map> paramListMap = new HashMap<>(); final String[] pairs = queryString.split("&"); try { for (final String pair : pairs) { final int pos = pair.indexOf('='); if (pos >= 0) { - final String key = urlCodec.decode(pair.substring(0, pos), - enc); + final String key = urlCodec.decode(pair.substring(0, pos), enc); List list = paramListMap.get(key); if (list == null) { list = new ArrayList<>(); @@ -169,10 +161,8 @@ public class FessEncodingFilter extends EncodingFilter { throw new IOException(e); } - final Map paramMap = new HashMap<>( - paramListMap.size()); - for (final Map.Entry> entry : paramListMap - .entrySet()) { + final Map paramMap = new HashMap<>(paramListMap.size()); + for (final Map.Entry> entry : paramListMap.entrySet()) { final List list = entry.getValue(); paramMap.put(entry.getKey(), list.toArray(new String[list.size()])); } diff --git a/src/main/java/org/codelibs/fess/filter/LoginInfoFilter.java b/src/main/java/org/codelibs/fess/filter/LoginInfoFilter.java index 24c4a88ec..972b874ec 100644 --- a/src/main/java/org/codelibs/fess/filter/LoginInfoFilter.java +++ b/src/main/java/org/codelibs/fess/filter/LoginInfoFilter.java @@ -47,13 +47,11 @@ public class LoginInfoFilter implements Filter { } @Override - public void doFilter(final ServletRequest request, - final ServletResponse response, final FilterChain chain) - throws IOException, ServletException { + public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain) throws IOException, + ServletException { final HttpServletRequest hRequest = (HttpServletRequest) request; final HttpSession session = hRequest.getSession(); - LoginInfo loginInfo = (LoginInfo) session - .getAttribute(SSCConstants.USER_INFO); + LoginInfo loginInfo = (LoginInfo) session.getAttribute(SSCConstants.USER_INFO); if (loginInfo == null) { loginInfo = new LoginInfo(); session.setAttribute(SSCConstants.USER_INFO, loginInfo); @@ -70,11 +68,9 @@ public class LoginInfoFilter implements Filter { chain.doFilter(request, response); } - private void updateRoleList(final HttpServletRequest hRequest, - final LoginInfo loginInfo) { + private void updateRoleList(final HttpServletRequest hRequest, final LoginInfo loginInfo) { final SystemHelper systemHelper = ComponentUtil.getSystemHelper(); - final Set authenticatedRoleList = systemHelper - .getAuthenticatedRoleSet(); + final Set authenticatedRoleList = systemHelper.getAuthenticatedRoleSet(); final Set roleSet = new HashSet<>(); for (final String role : authenticatedRoleList) { if (hRequest.isUserInRole(role)) { diff --git a/src/main/java/org/codelibs/fess/filter/WebApiFilter.java b/src/main/java/org/codelibs/fess/filter/WebApiFilter.java index 3150718dc..59314846b 100644 --- a/src/main/java/org/codelibs/fess/filter/WebApiFilter.java +++ b/src/main/java/org/codelibs/fess/filter/WebApiFilter.java @@ -44,18 +44,14 @@ public class WebApiFilter implements Filter { } @Override - public void doFilter(final ServletRequest request, - final ServletResponse response, final FilterChain chain) - throws IOException, ServletException { - final WebApiManagerFactory webApiManagerFactory = ComponentUtil - .getWebApiManagerFactory(); - final WebApiManager webApiManager = webApiManagerFactory - .get((HttpServletRequest) request); + public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain) throws IOException, + ServletException { + final WebApiManagerFactory webApiManagerFactory = ComponentUtil.getWebApiManagerFactory(); + final WebApiManager webApiManager = webApiManagerFactory.get((HttpServletRequest) request); if (webApiManager == null) { chain.doFilter(request, response); } else { - webApiManager.process((HttpServletRequest) request, - (HttpServletResponse) response, chain); + webApiManager.process((HttpServletRequest) request, (HttpServletResponse) response, chain); } } diff --git a/src/main/java/org/codelibs/fess/form/admin/BoostDocumentRuleForm.java b/src/main/java/org/codelibs/fess/form/admin/BoostDocumentRuleForm.java index c511bc03e..33440f5c1 100644 --- a/src/main/java/org/codelibs/fess/form/admin/BoostDocumentRuleForm.java +++ b/src/main/java/org/codelibs/fess/form/admin/BoostDocumentRuleForm.java @@ -20,8 +20,7 @@ import java.io.Serializable; import org.codelibs.fess.crud.form.admin.BsBoostDocumentRuleForm; -public class BoostDocumentRuleForm extends BsBoostDocumentRuleForm implements - Serializable { +public class BoostDocumentRuleForm extends BsBoostDocumentRuleForm implements Serializable { private static final long serialVersionUID = 1L; diff --git a/src/main/java/org/codelibs/fess/form/admin/CrawlingSessionForm.java b/src/main/java/org/codelibs/fess/form/admin/CrawlingSessionForm.java index 58dab6e0c..5ea8d6578 100644 --- a/src/main/java/org/codelibs/fess/form/admin/CrawlingSessionForm.java +++ b/src/main/java/org/codelibs/fess/form/admin/CrawlingSessionForm.java @@ -20,8 +20,7 @@ import java.io.Serializable; import org.codelibs.fess.crud.form.admin.BsCrawlingSessionForm; -public class CrawlingSessionForm extends BsCrawlingSessionForm implements - Serializable { +public class CrawlingSessionForm extends BsCrawlingSessionForm implements Serializable { private static final long serialVersionUID = 1L; diff --git a/src/main/java/org/codelibs/fess/form/admin/DataCrawlingConfigForm.java b/src/main/java/org/codelibs/fess/form/admin/DataCrawlingConfigForm.java index bbdb184e1..2bc7d3a88 100644 --- a/src/main/java/org/codelibs/fess/form/admin/DataCrawlingConfigForm.java +++ b/src/main/java/org/codelibs/fess/form/admin/DataCrawlingConfigForm.java @@ -23,8 +23,7 @@ import java.util.Date; import org.codelibs.fess.Constants; import org.codelibs.fess.crud.form.admin.BsDataCrawlingConfigForm; -public class DataCrawlingConfigForm extends BsDataCrawlingConfigForm implements - Serializable { +public class DataCrawlingConfigForm extends BsDataCrawlingConfigForm implements Serializable { private static final long serialVersionUID = 1L; @@ -38,8 +37,7 @@ public class DataCrawlingConfigForm extends BsDataCrawlingConfigForm implements sortOrder = "0"; // Temporary data createdBy = "system"; - final SimpleDateFormat sdf = new SimpleDateFormat( - Constants.DEFAULT_DATETIME_FORMAT); + final SimpleDateFormat sdf = new SimpleDateFormat(Constants.DEFAULT_DATETIME_FORMAT); createdTime = sdf.format(new Date()); } } diff --git a/src/main/java/org/codelibs/fess/form/admin/FileAuthenticationForm.java b/src/main/java/org/codelibs/fess/form/admin/FileAuthenticationForm.java index 3bef877fb..057f0e358 100644 --- a/src/main/java/org/codelibs/fess/form/admin/FileAuthenticationForm.java +++ b/src/main/java/org/codelibs/fess/form/admin/FileAuthenticationForm.java @@ -23,8 +23,7 @@ import java.util.Date; import org.codelibs.fess.Constants; import org.codelibs.fess.crud.form.admin.BsFileAuthenticationForm; -public class FileAuthenticationForm extends BsFileAuthenticationForm implements - Serializable { +public class FileAuthenticationForm extends BsFileAuthenticationForm implements Serializable { private static final long serialVersionUID = 1L; @@ -32,8 +31,7 @@ public class FileAuthenticationForm extends BsFileAuthenticationForm implements public void initialize() { super.initialize(); createdBy = "system"; - final SimpleDateFormat sdf = new SimpleDateFormat( - Constants.DEFAULT_DATETIME_FORMAT); + final SimpleDateFormat sdf = new SimpleDateFormat(Constants.DEFAULT_DATETIME_FORMAT); createdTime = sdf.format(new Date()); } } diff --git a/src/main/java/org/codelibs/fess/form/admin/FileCrawlingConfigForm.java b/src/main/java/org/codelibs/fess/form/admin/FileCrawlingConfigForm.java index 043ab0ff3..4bbde90b2 100644 --- a/src/main/java/org/codelibs/fess/form/admin/FileCrawlingConfigForm.java +++ b/src/main/java/org/codelibs/fess/form/admin/FileCrawlingConfigForm.java @@ -23,8 +23,7 @@ import java.util.Date; import org.codelibs.fess.Constants; import org.codelibs.fess.crud.form.admin.BsFileCrawlingConfigForm; -public class FileCrawlingConfigForm extends BsFileCrawlingConfigForm implements - Serializable { +public class FileCrawlingConfigForm extends BsFileCrawlingConfigForm implements Serializable { private static final long serialVersionUID = 1L; @@ -40,8 +39,7 @@ public class FileCrawlingConfigForm extends BsFileCrawlingConfigForm implements intervalTime = Integer.toString(Constants.DEFAULT_INTERVAL_TIME_FOR_FS); // Temporary data createdBy = "system"; - final SimpleDateFormat sdf = new SimpleDateFormat( - Constants.DEFAULT_DATETIME_FORMAT); + final SimpleDateFormat sdf = new SimpleDateFormat(Constants.DEFAULT_DATETIME_FORMAT); createdTime = sdf.format(new Date()); } } diff --git a/src/main/java/org/codelibs/fess/form/admin/LabelTypeForm.java b/src/main/java/org/codelibs/fess/form/admin/LabelTypeForm.java index ced3a3eb3..9034caaa2 100644 --- a/src/main/java/org/codelibs/fess/form/admin/LabelTypeForm.java +++ b/src/main/java/org/codelibs/fess/form/admin/LabelTypeForm.java @@ -35,8 +35,7 @@ public class LabelTypeForm extends BsLabelTypeForm implements Serializable { sortOrder = "0"; // Temporary data createdBy = "system"; - final SimpleDateFormat sdf = new SimpleDateFormat( - Constants.DEFAULT_DATETIME_FORMAT); + final SimpleDateFormat sdf = new SimpleDateFormat(Constants.DEFAULT_DATETIME_FORMAT); createdTime = sdf.format(new Date()); } } diff --git a/src/main/java/org/codelibs/fess/form/admin/OverlappingHostForm.java b/src/main/java/org/codelibs/fess/form/admin/OverlappingHostForm.java index 49b36a10b..2ea79bc05 100644 --- a/src/main/java/org/codelibs/fess/form/admin/OverlappingHostForm.java +++ b/src/main/java/org/codelibs/fess/form/admin/OverlappingHostForm.java @@ -23,8 +23,7 @@ import java.util.Date; import org.codelibs.fess.Constants; import org.codelibs.fess.crud.form.admin.BsOverlappingHostForm; -public class OverlappingHostForm extends BsOverlappingHostForm implements - Serializable { +public class OverlappingHostForm extends BsOverlappingHostForm implements Serializable { private static final long serialVersionUID = 1L; @@ -34,8 +33,7 @@ public class OverlappingHostForm extends BsOverlappingHostForm implements sortOrder = "0"; // Temporary data createdBy = "system"; - final SimpleDateFormat sdf = new SimpleDateFormat( - Constants.DEFAULT_DATETIME_FORMAT); + final SimpleDateFormat sdf = new SimpleDateFormat(Constants.DEFAULT_DATETIME_FORMAT); createdTime = sdf.format(new Date()); } } diff --git a/src/main/java/org/codelibs/fess/form/admin/PathMappingForm.java b/src/main/java/org/codelibs/fess/form/admin/PathMappingForm.java index 73deb5de8..cc5a450fe 100644 --- a/src/main/java/org/codelibs/fess/form/admin/PathMappingForm.java +++ b/src/main/java/org/codelibs/fess/form/admin/PathMappingForm.java @@ -33,8 +33,7 @@ public class PathMappingForm extends BsPathMappingForm implements Serializable { sortOrder = "0"; // Temporary data createdBy = "system"; - final SimpleDateFormat sdf = new SimpleDateFormat( - Constants.DEFAULT_DATETIME_FORMAT); + final SimpleDateFormat sdf = new SimpleDateFormat(Constants.DEFAULT_DATETIME_FORMAT); createdTime = sdf.format(new Date()); } } diff --git a/src/main/java/org/codelibs/fess/form/admin/RequestHeaderForm.java b/src/main/java/org/codelibs/fess/form/admin/RequestHeaderForm.java index c7a276f4b..1a3eae810 100644 --- a/src/main/java/org/codelibs/fess/form/admin/RequestHeaderForm.java +++ b/src/main/java/org/codelibs/fess/form/admin/RequestHeaderForm.java @@ -23,8 +23,7 @@ import java.util.Date; import org.codelibs.fess.Constants; import org.codelibs.fess.crud.form.admin.BsRequestHeaderForm; -public class RequestHeaderForm extends BsRequestHeaderForm implements - Serializable { +public class RequestHeaderForm extends BsRequestHeaderForm implements Serializable { private static final long serialVersionUID = 1L; @@ -32,8 +31,7 @@ public class RequestHeaderForm extends BsRequestHeaderForm implements public void initialize() { super.initialize(); createdBy = "system"; - final SimpleDateFormat sdf = new SimpleDateFormat( - Constants.DEFAULT_DATETIME_FORMAT); + final SimpleDateFormat sdf = new SimpleDateFormat(Constants.DEFAULT_DATETIME_FORMAT); createdTime = sdf.format(new Date()); } } diff --git a/src/main/java/org/codelibs/fess/form/admin/RoleTypeForm.java b/src/main/java/org/codelibs/fess/form/admin/RoleTypeForm.java index eb98c04c2..749829587 100644 --- a/src/main/java/org/codelibs/fess/form/admin/RoleTypeForm.java +++ b/src/main/java/org/codelibs/fess/form/admin/RoleTypeForm.java @@ -33,8 +33,7 @@ public class RoleTypeForm extends BsRoleTypeForm implements Serializable { sortOrder = "0"; // Temporary data createdBy = "system"; - final SimpleDateFormat sdf = new SimpleDateFormat( - Constants.DEFAULT_DATETIME_FORMAT); + final SimpleDateFormat sdf = new SimpleDateFormat(Constants.DEFAULT_DATETIME_FORMAT); createdTime = sdf.format(new Date()); } } diff --git a/src/main/java/org/codelibs/fess/form/admin/ScheduledJobForm.java b/src/main/java/org/codelibs/fess/form/admin/ScheduledJobForm.java index b3ecb91fa..d0310b1c2 100644 --- a/src/main/java/org/codelibs/fess/form/admin/ScheduledJobForm.java +++ b/src/main/java/org/codelibs/fess/form/admin/ScheduledJobForm.java @@ -23,8 +23,7 @@ import java.util.Date; import org.codelibs.fess.Constants; import org.codelibs.fess.crud.form.admin.BsScheduledJobForm; -public class ScheduledJobForm extends BsScheduledJobForm implements - Serializable { +public class ScheduledJobForm extends BsScheduledJobForm implements Serializable { private static final long serialVersionUID = 1L; @@ -38,8 +37,7 @@ public class ScheduledJobForm extends BsScheduledJobForm implements sortOrder = "0"; // Temporary data createdBy = "system"; - final SimpleDateFormat sdf = new SimpleDateFormat( - Constants.DEFAULT_DATETIME_FORMAT); + final SimpleDateFormat sdf = new SimpleDateFormat(Constants.DEFAULT_DATETIME_FORMAT); createdTime = sdf.format(new Date()); } } diff --git a/src/main/java/org/codelibs/fess/form/admin/SuggestBadWordForm.java b/src/main/java/org/codelibs/fess/form/admin/SuggestBadWordForm.java index 339008e43..54465a7e8 100644 --- a/src/main/java/org/codelibs/fess/form/admin/SuggestBadWordForm.java +++ b/src/main/java/org/codelibs/fess/form/admin/SuggestBadWordForm.java @@ -22,8 +22,7 @@ import org.apache.struts.upload.FormFile; import org.codelibs.fess.crud.form.admin.BsSuggestBadWordForm; import org.seasar.struts.annotation.Required; -public class SuggestBadWordForm extends BsSuggestBadWordForm implements - Serializable { +public class SuggestBadWordForm extends BsSuggestBadWordForm implements Serializable { private static final long serialVersionUID = 1L; diff --git a/src/main/java/org/codelibs/fess/form/admin/SuggestElevateWordForm.java b/src/main/java/org/codelibs/fess/form/admin/SuggestElevateWordForm.java index 813d9eec2..d281c6703 100644 --- a/src/main/java/org/codelibs/fess/form/admin/SuggestElevateWordForm.java +++ b/src/main/java/org/codelibs/fess/form/admin/SuggestElevateWordForm.java @@ -22,8 +22,7 @@ import org.apache.struts.upload.FormFile; import org.codelibs.fess.crud.form.admin.BsSuggestElevateWordForm; import org.seasar.struts.annotation.Required; -public class SuggestElevateWordForm extends BsSuggestElevateWordForm implements - Serializable { +public class SuggestElevateWordForm extends BsSuggestElevateWordForm implements Serializable { private static final long serialVersionUID = 1L; diff --git a/src/main/java/org/codelibs/fess/form/admin/WebAuthenticationForm.java b/src/main/java/org/codelibs/fess/form/admin/WebAuthenticationForm.java index 351db3c2e..91c25d326 100644 --- a/src/main/java/org/codelibs/fess/form/admin/WebAuthenticationForm.java +++ b/src/main/java/org/codelibs/fess/form/admin/WebAuthenticationForm.java @@ -23,8 +23,7 @@ import java.util.Date; import org.codelibs.fess.Constants; import org.codelibs.fess.crud.form.admin.BsWebAuthenticationForm; -public class WebAuthenticationForm extends BsWebAuthenticationForm implements - Serializable { +public class WebAuthenticationForm extends BsWebAuthenticationForm implements Serializable { private static final long serialVersionUID = 1L; @@ -32,8 +31,7 @@ public class WebAuthenticationForm extends BsWebAuthenticationForm implements public void initialize() { super.initialize(); createdBy = "system"; - final SimpleDateFormat sdf = new SimpleDateFormat( - Constants.DEFAULT_DATETIME_FORMAT); + final SimpleDateFormat sdf = new SimpleDateFormat(Constants.DEFAULT_DATETIME_FORMAT); createdTime = sdf.format(new Date()); } } diff --git a/src/main/java/org/codelibs/fess/form/admin/WebCrawlingConfigForm.java b/src/main/java/org/codelibs/fess/form/admin/WebCrawlingConfigForm.java index f45dc633b..4fc5ed93b 100644 --- a/src/main/java/org/codelibs/fess/form/admin/WebCrawlingConfigForm.java +++ b/src/main/java/org/codelibs/fess/form/admin/WebCrawlingConfigForm.java @@ -25,8 +25,7 @@ import org.codelibs.fess.Constants; import org.codelibs.fess.crud.form.admin.BsWebCrawlingConfigForm; import org.codelibs.fess.util.ComponentUtil; -public class WebCrawlingConfigForm extends BsWebCrawlingConfigForm implements - Serializable { +public class WebCrawlingConfigForm extends BsWebCrawlingConfigForm implements Serializable { private static final long serialVersionUID = 1L; @@ -43,12 +42,10 @@ public class WebCrawlingConfigForm extends BsWebCrawlingConfigForm implements userAgent = "Fess Robot/1.0"; } numOfThread = Integer.toString(Constants.DEFAULT_NUM_OF_THREAD_FOR_WEB); - intervalTime = Integer - .toString(Constants.DEFAULT_INTERVAL_TIME_FOR_WEB); + intervalTime = Integer.toString(Constants.DEFAULT_INTERVAL_TIME_FOR_WEB); // Temporary data createdBy = "system"; - final SimpleDateFormat sdf = new SimpleDateFormat( - Constants.DEFAULT_DATETIME_FORMAT); + final SimpleDateFormat sdf = new SimpleDateFormat(Constants.DEFAULT_DATETIME_FORMAT); createdTime = sdf.format(new Date()); } diff --git a/src/main/java/org/codelibs/fess/helper/AdRoleHelper.java b/src/main/java/org/codelibs/fess/helper/AdRoleHelper.java index d5825651a..e483c5800 100644 --- a/src/main/java/org/codelibs/fess/helper/AdRoleHelper.java +++ b/src/main/java/org/codelibs/fess/helper/AdRoleHelper.java @@ -33,8 +33,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class AdRoleHelper { - private static final Logger logger = LoggerFactory - .getLogger(AdRoleHelper.class); + private static final Logger logger = LoggerFactory.getLogger(AdRoleHelper.class); public String domain; @@ -61,8 +60,7 @@ public class AdRoleHelper { name = name.replace(".", ",dc="); //search - final NamingEnumeration rslt = ctx.search(name, - filter, controls); + final NamingEnumeration rslt = ctx.search(name, filter, controls); while (rslt.hasMoreElements()) { final SearchResult srcrslt = rslt.next(); final Attributes attrs = srcrslt.getAttributes(); diff --git a/src/main/java/org/codelibs/fess/helper/CrawlingConfigHelper.java b/src/main/java/org/codelibs/fess/helper/CrawlingConfigHelper.java index 94747e828..f75b5bfdf 100644 --- a/src/main/java/org/codelibs/fess/helper/CrawlingConfigHelper.java +++ b/src/main/java/org/codelibs/fess/helper/CrawlingConfigHelper.java @@ -54,8 +54,7 @@ public class CrawlingConfigHelper implements Serializable { private static final long serialVersionUID = 1L; - private static final Logger logger = LoggerFactory - .getLogger(CrawlingConfigHelper.class); + private static final Logger logger = LoggerFactory.getLogger(CrawlingConfigHelper.class); protected final Map crawlingConfigMap = new ConcurrentHashMap(); @@ -99,25 +98,21 @@ public class CrawlingConfigHelper implements Serializable { return null; } switch (configType) { - case WEB: - final WebCrawlingConfigService webCrawlingConfigService = SingletonS2Container - .getComponent(WebCrawlingConfigService.class); - return webCrawlingConfigService.getWebCrawlingConfig(id); - case FILE: - final FileCrawlingConfigService fileCrawlingConfigService = SingletonS2Container - .getComponent(FileCrawlingConfigService.class); - return fileCrawlingConfigService.getFileCrawlingConfig(id); - case DATA: - final DataCrawlingConfigService dataCrawlingConfigService = SingletonS2Container - .getComponent(DataCrawlingConfigService.class); - return dataCrawlingConfigService.getDataCrawlingConfig(id); - default: - return null; + case WEB: + final WebCrawlingConfigService webCrawlingConfigService = SingletonS2Container.getComponent(WebCrawlingConfigService.class); + return webCrawlingConfigService.getWebCrawlingConfig(id); + case FILE: + final FileCrawlingConfigService fileCrawlingConfigService = SingletonS2Container.getComponent(FileCrawlingConfigService.class); + return fileCrawlingConfigService.getFileCrawlingConfig(id); + case DATA: + final DataCrawlingConfigService dataCrawlingConfigService = SingletonS2Container.getComponent(DataCrawlingConfigService.class); + return dataCrawlingConfigService.getDataCrawlingConfig(id); + default: + return null; } } - public synchronized String store(final String sessionId, - final CrawlingConfig crawlingConfig) { + public synchronized String store(final String sessionId, final CrawlingConfig crawlingConfig) { final String sessionCountId = sessionId + "-" + count; crawlingConfigMap.put(sessionCountId, crawlingConfig); count++; @@ -148,39 +143,29 @@ public class CrawlingConfigHelper implements Serializable { final ConfigType configType = getConfigType(configId); CrawlingConfig config = null; if (logger.isDebugEnabled()) { - logger.debug("configType: " + configType + ", configId: " - + configId); + logger.debug("configType: " + configType + ", configId: " + configId); } if (ConfigType.WEB == configType) { - final WebCrawlingConfigService webCrawlingConfigService = SingletonS2Container - .getComponent(WebCrawlingConfigService.class); - config = webCrawlingConfigService - .getWebCrawlingConfig(getId(configId)); + final WebCrawlingConfigService webCrawlingConfigService = SingletonS2Container.getComponent(WebCrawlingConfigService.class); + config = webCrawlingConfigService.getWebCrawlingConfig(getId(configId)); } else if (ConfigType.FILE == configType) { - final FileCrawlingConfigService fileCrawlingConfigService = SingletonS2Container - .getComponent(FileCrawlingConfigService.class); - config = fileCrawlingConfigService - .getFileCrawlingConfig(getId(configId)); + final FileCrawlingConfigService fileCrawlingConfigService = SingletonS2Container.getComponent(FileCrawlingConfigService.class); + config = fileCrawlingConfigService.getFileCrawlingConfig(getId(configId)); } else if (ConfigType.DATA == configType) { - final DataCrawlingConfigService dataCrawlingConfigService = SingletonS2Container - .getComponent(DataCrawlingConfigService.class); - config = dataCrawlingConfigService - .getDataCrawlingConfig(getId(configId)); + final DataCrawlingConfigService dataCrawlingConfigService = SingletonS2Container.getComponent(DataCrawlingConfigService.class); + config = dataCrawlingConfigService.getDataCrawlingConfig(getId(configId)); } if (config == null) { throw new FessSystemException("No crawlingConfig: " + configIdObj); } final String url = (String) doc.get(fieldHelper.urlField); - final S2RobotClientFactory robotClientFactory = SingletonS2Container - .getComponent(S2RobotClientFactory.class); + final S2RobotClientFactory robotClientFactory = SingletonS2Container.getComponent(S2RobotClientFactory.class); config.initializeClientFactory(robotClientFactory); final S2RobotClient client = robotClientFactory.getClient(url); if (client == null) { - throw new FessSystemException("No S2RobotClient: " + configIdObj - + ", url: " + url); + throw new FessSystemException("No S2RobotClient: " + configIdObj + ", url: " + url); } - final ResponseData responseData = client.execute(RequestDataBuilder - .newRequestData().get().url(url).build()); + final ResponseData responseData = client.execute(RequestDataBuilder.newRequestData().get().url(url).build()); final HttpServletResponse response = ResponseUtil.getResponse(); writeFileName(response, responseData); writeContentType(response, responseData); @@ -194,9 +179,7 @@ public class CrawlingConfigHelper implements Serializable { os.flush(); } catch (final IOException e) { if (!"ClientAbortException".equals(e.getClass().getSimpleName())) { - throw new FessSystemException( - "Failed to write a content. configId: " + configIdObj - + ", url: " + url, e); + throw new FessSystemException("Failed to write a content. configId: " + configIdObj + ", url: " + url, e); } } finally { IOUtils.closeQuietly(is); @@ -207,17 +190,14 @@ public class CrawlingConfigHelper implements Serializable { } } - protected void writeNoCache(final HttpServletResponse response, - final ResponseData responseData) { + protected void writeNoCache(final HttpServletResponse response, final ResponseData responseData) { response.setHeader("Pragma", "no-cache"); response.setHeader("Cache-Control", "no-cache"); response.setHeader("Expires", "Thu, 01 Dec 1994 16:00:00 GMT"); } - protected void writeFileName(final HttpServletResponse response, - final ResponseData responseData) { - final UserAgentHelper userAgentHelper = ComponentUtil - .getUserAgentHelper(); + protected void writeFileName(final HttpServletResponse response, final ResponseData responseData) { + final UserAgentHelper userAgentHelper = ComponentUtil.getUserAgentHelper(); final UserAgentType userAgentType = userAgentHelper.getUserAgentType(); String charset = responseData.getCharSet(); if (charset == null) { @@ -234,47 +214,33 @@ public class CrawlingConfigHelper implements Serializable { } if (logger.isDebugEnabled()) { - logger.debug("userAgentType: " + userAgentType + ", charset: " - + charset + ", name: " + name); + logger.debug("userAgentType: " + userAgentType + ", charset: " + charset + ", name: " + name); } switch (userAgentType) { - case IE: - response.setHeader( - "Content-Disposition", - "attachment; filename=\"" - + URLEncoder.encode(name, Constants.UTF_8) - + "\""); - break; - case OPERA: - response.setHeader( - "Content-Disposition", - "attachment; filename*=utf-8'ja'" - + URLEncoder.encode(name, Constants.UTF_8)); - break; - case SAFARI: - response.setHeader("Content-Disposition", - "attachment; filename=\"" + name + "\""); - break; - case CHROME: - case FIREFOX: - case OTHER: - default: - response.setHeader( - "Content-Disposition", - "attachment; filename=\"=?utf-8?B?" - + Base64Util.encode(name - .getBytes(Constants.UTF_8)) - + "?=\""); - break; + case IE: + response.setHeader("Content-Disposition", "attachment; filename=\"" + URLEncoder.encode(name, Constants.UTF_8) + "\""); + break; + case OPERA: + response.setHeader("Content-Disposition", "attachment; filename*=utf-8'ja'" + URLEncoder.encode(name, Constants.UTF_8)); + break; + case SAFARI: + response.setHeader("Content-Disposition", "attachment; filename=\"" + name + "\""); + break; + case CHROME: + case FIREFOX: + case OTHER: + default: + response.setHeader("Content-Disposition", + "attachment; filename=\"=?utf-8?B?" + Base64Util.encode(name.getBytes(Constants.UTF_8)) + "?=\""); + break; } } catch (final Exception e) { logger.warn("Failed to write a filename: " + responseData, e); } } - protected void writeContentType(final HttpServletResponse response, - final ResponseData responseData) { + protected void writeContentType(final HttpServletResponse response, final ResponseData responseData) { final String mimeType = responseData.getMimeType(); if (logger.isDebugEnabled()) { logger.debug("mimeType: " + mimeType); diff --git a/src/main/java/org/codelibs/fess/helper/CrawlingSessionHelper.java b/src/main/java/org/codelibs/fess/helper/CrawlingSessionHelper.java index e1c5b29b1..decb3e402 100644 --- a/src/main/java/org/codelibs/fess/helper/CrawlingSessionHelper.java +++ b/src/main/java/org/codelibs/fess/helper/CrawlingSessionHelper.java @@ -42,8 +42,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class CrawlingSessionHelper implements Serializable { - private static final Logger logger = LoggerFactory - .getLogger(CrawlingSessionHelper.class); + private static final Logger logger = LoggerFactory.getLogger(CrawlingSessionHelper.class); public static final String FACET_COUNT_KEY = "count"; @@ -66,8 +65,7 @@ public class CrawlingSessionHelper implements Serializable { } public synchronized void store(final String sessionId, final boolean create) { - CrawlingSession crawlingSession = create ? null - : getCrawlingSessionService().getLast(sessionId); + CrawlingSession crawlingSession = create ? null : getCrawlingSessionService().getLast(sessionId); if (crawlingSession == null) { crawlingSession = new CrawlingSession(sessionId); try { @@ -81,8 +79,7 @@ public class CrawlingSessionHelper implements Serializable { final List crawlingSessionInfoList = new ArrayList(); for (final Map.Entry entry : infoMap.entrySet()) { final CrawlingSessionInfo crawlingSessionInfo = new CrawlingSessionInfo(); - crawlingSessionInfo.setCrawlingSessionId(crawlingSession - .getId()); + crawlingSessionInfo.setCrawlingSessionId(crawlingSession.getId()); crawlingSessionInfo.setKey(entry.getKey()); crawlingSessionInfo.setValue(entry.getValue()); crawlingSessionInfoList.add(crawlingSessionInfo); @@ -95,16 +92,13 @@ public class CrawlingSessionHelper implements Serializable { public synchronized void putToInfoMap(final String key, final String value) { if (infoMap == null) { - infoMap = Collections - .synchronizedMap(new LinkedHashMap()); + infoMap = Collections.synchronizedMap(new LinkedHashMap()); } infoMap.put(key, value); } - public void updateParams(final String sessionId, final String name, - final int dayForCleanup) { - final CrawlingSession crawlingSession = getCrawlingSessionService() - .getLast(sessionId); + public void updateParams(final String sessionId, final String name, final int dayForCleanup) { + final CrawlingSession crawlingSession = getCrawlingSessionService().getLast(sessionId); if (crawlingSession == null) { logger.warn("No crawling session: " + sessionId); return; @@ -132,18 +126,15 @@ public class CrawlingSessionHelper implements Serializable { } protected LocalDateTime getExpiredTime(final int days) { - final LocalDateTime now = ComponentUtil.getSystemHelper() - .getCurrentTime(); + final LocalDateTime now = ComponentUtil.getSystemHelper().getCurrentTime(); return now.plusDays(days); } public Map getInfoMap(final String sessionId) { - final List crawlingSessionInfoList = getCrawlingSessionService() - .getLastCrawlingSessionInfoList(sessionId); + final List crawlingSessionInfoList = getCrawlingSessionService().getLastCrawlingSessionInfoList(sessionId); final Map map = new HashMap(); for (final CrawlingSessionInfo crawlingSessionInfo : crawlingSessionInfoList) { - map.put(crawlingSessionInfo.getKey(), - crawlingSessionInfo.getValue()); + map.put(crawlingSessionInfo.getKey(), crawlingSessionInfo.getValue()); } return map; } @@ -152,13 +143,11 @@ public class CrawlingSessionHelper implements Serializable { final FieldHelper fieldHelper = ComponentUtil.getFieldHelper(); final String url = (String) dataMap.get(fieldHelper.urlField); @SuppressWarnings("unchecked") - final List roleTypeList = (List) dataMap - .get(fieldHelper.roleField); + final List roleTypeList = (List) dataMap.get(fieldHelper.roleField); return generateId(url, roleTypeList); } - public List> getSessionIdList( - final SolrGroup serverGroup) { + public List> getSessionIdList(final SolrGroup serverGroup) { final List> sessionIdList = new ArrayList>(); final FieldHelper fieldHelper = ComponentUtil.getFieldHelper(); @@ -174,8 +163,7 @@ public class CrawlingSessionHelper implements Serializable { final List facetEntries = facet.getValues(); if (facetEntries != null) { for (final FacetField.Count fcount : facetEntries) { - final Map map = new HashMap( - 2); + final Map map = new HashMap(2); map.put(fieldHelper.segmentField, fcount.getName()); map.put(FACET_COUNT_KEY, Long.toString(fcount.getCount())); sessionIdList.add(map); diff --git a/src/main/java/org/codelibs/fess/helper/DataIndexHelper.java b/src/main/java/org/codelibs/fess/helper/DataIndexHelper.java index b37cf42fc..28e413644 100644 --- a/src/main/java/org/codelibs/fess/helper/DataIndexHelper.java +++ b/src/main/java/org/codelibs/fess/helper/DataIndexHelper.java @@ -44,8 +44,7 @@ public class DataIndexHelper implements Serializable { private static final long serialVersionUID = 1L; - private static final Logger logger = LoggerFactory - .getLogger(DataIndexHelper.class); + private static final Logger logger = LoggerFactory.getLogger(DataIndexHelper.class); @Resource protected DynamicProperties crawlerProperties; @@ -60,12 +59,10 @@ public class DataIndexHelper implements Serializable { public int crawlerPriority = Thread.NORM_PRIORITY; - private final List dataCrawlingThreadList = Collections - .synchronizedList(new ArrayList()); + private final List dataCrawlingThreadList = Collections.synchronizedList(new ArrayList()); public void crawl(final String sessionId, final SolrGroup solrGroup) { - final List configList = dataCrawlingConfigService - .getAllDataCrawlingConfigList(); + final List configList = dataCrawlingConfigService.getAllDataCrawlingConfigList(); if (configList.isEmpty()) { // nothing @@ -78,10 +75,8 @@ public class DataIndexHelper implements Serializable { crawl(sessionId, solrGroup, configList); } - public void crawl(final String sessionId, final List configIdList, - final SolrGroup solrGroup) { - final List configList = dataCrawlingConfigService - .getDataCrawlingConfigListByIds(configIdList); + public void crawl(final String sessionId, final List configIdList, final SolrGroup solrGroup) { + final List configList = dataCrawlingConfigService.getDataCrawlingConfigListByIds(configIdList); if (configList.isEmpty()) { // nothing @@ -94,11 +89,9 @@ public class DataIndexHelper implements Serializable { crawl(sessionId, solrGroup, configList); } - protected void crawl(final String sessionId, final SolrGroup solrGroup, - final List configList) { + protected void crawl(final String sessionId, final SolrGroup solrGroup, final List configList) { int multiprocessCrawlingCount = 5; - String value = crawlerProperties.getProperty( - Constants.CRAWLING_THREAD_COUNT_PROPERTY, "5"); + String value = crawlerProperties.getProperty(Constants.CRAWLING_THREAD_COUNT_PROPERTY, "5"); try { multiprocessCrawlingCount = Integer.parseInt(value); } catch (final NumberFormatException e) { @@ -106,9 +99,7 @@ public class DataIndexHelper implements Serializable { } long commitPerCount = Constants.DEFAULT_COMMIT_PER_COUNT; - value = crawlerProperties.getProperty( - Constants.COMMIT_PER_COUNT_PROPERTY, - Long.toString(Constants.DEFAULT_COMMIT_PER_COUNT)); + value = crawlerProperties.getProperty(Constants.COMMIT_PER_COUNT_PROPERTY, Long.toString(Constants.DEFAULT_COMMIT_PER_COUNT)); try { commitPerCount = Long.parseLong(value); } catch (final NumberFormatException e) { @@ -117,8 +108,7 @@ public class DataIndexHelper implements Serializable { final long startTime = System.currentTimeMillis(); - final IndexUpdateCallback indexUpdateCallback = SingletonS2Container - .getComponent(IndexUpdateCallback.class); + final IndexUpdateCallback indexUpdateCallback = SingletonS2Container.getComponent(IndexUpdateCallback.class); indexUpdateCallback.setSolrGroup(solrGroup); indexUpdateCallback.setCommitPerCount(commitPerCount); @@ -127,15 +117,13 @@ public class DataIndexHelper implements Serializable { dataCrawlingThreadList.clear(); final List dataCrawlingThreadStatusList = new ArrayList(); for (final DataCrawlingConfig dataCrawlingConfig : configList) { - final String sid = crawlingConfigHelper.store(sessionId, - dataCrawlingConfig); + final String sid = crawlingConfigHelper.store(sessionId, dataCrawlingConfig); sessionIdList.add(sid); initParamMap.put(Constants.SESSION_ID, sessionId); initParamMap.put(Constants.CRAWLING_SESSION_ID, sid); - final DataCrawlingThread dataCrawlingThread = new DataCrawlingThread( - dataCrawlingConfig, indexUpdateCallback, initParamMap); + final DataCrawlingThread dataCrawlingThread = new DataCrawlingThread(dataCrawlingConfig, indexUpdateCallback, initParamMap); dataCrawlingThread.setPriority(crawlerPriority); dataCrawlingThread.setName(sid); dataCrawlingThread.setDaemon(true); @@ -161,8 +149,7 @@ public class DataIndexHelper implements Serializable { if (activeCrawlerNum < multiprocessCrawlingCount) { // start crawling dataCrawlingThreadList.get(startedCrawlerNum).start(); - dataCrawlingThreadStatusList.set(startedCrawlerNum, - Constants.RUNNING); + dataCrawlingThreadStatusList.set(startedCrawlerNum, Constants.RUNNING); startedCrawlerNum++; activeCrawlerNum++; try { @@ -175,9 +162,7 @@ public class DataIndexHelper implements Serializable { // check status for (int i = 0; i < startedCrawlerNum; i++) { - if (!dataCrawlingThreadList.get(i).isRunning() - && dataCrawlingThreadStatusList.get(i).equals( - Constants.RUNNING)) { + if (!dataCrawlingThreadList.get(i).isRunning() && dataCrawlingThreadStatusList.get(i).equals(Constants.RUNNING)) { dataCrawlingThreadList.get(i).awaitTermination(); dataCrawlingThreadStatusList.set(i, Constants.DONE); activeCrawlerNum--; @@ -194,11 +179,8 @@ public class DataIndexHelper implements Serializable { while (!finishedAll) { finishedAll = true; for (int i = 0; i < dataCrawlingThreadList.size(); i++) { - dataCrawlingThreadList.get(i).awaitTermination( - crawlingExecutionInterval); - if (!dataCrawlingThreadList.get(i).isRunning() - && dataCrawlingThreadStatusList.get(i).equals( - Constants.RUNNING)) { + dataCrawlingThreadList.get(i).awaitTermination(crawlingExecutionInterval); + if (!dataCrawlingThreadList.get(i).isRunning() && dataCrawlingThreadStatusList.get(i).equals(Constants.RUNNING)) { dataCrawlingThreadStatusList.set(i, Constants.DONE); } if (!dataCrawlingThreadStatusList.get(i).equals(Constants.DONE)) { @@ -212,20 +194,16 @@ public class DataIndexHelper implements Serializable { indexUpdateCallback.commit(); // put cralwing info - final CrawlingSessionHelper crawlingSessionHelper = ComponentUtil - .getCrawlingSessionHelper(); + final CrawlingSessionHelper crawlingSessionHelper = ComponentUtil.getCrawlingSessionHelper(); final long execTime = System.currentTimeMillis() - startTime; - crawlingSessionHelper.putToInfoMap(Constants.DATA_CRAWLING_EXEC_TIME, - Long.toString(execTime)); + crawlingSessionHelper.putToInfoMap(Constants.DATA_CRAWLING_EXEC_TIME, Long.toString(execTime)); if (logger.isInfoEnabled()) { logger.info("[EXEC TIME] crawling time: " + execTime + "ms"); } - crawlingSessionHelper.putToInfoMap(Constants.DATA_INDEX_EXEC_TIME, - Long.toString(indexUpdateCallback.getExecuteTime())); - crawlingSessionHelper.putToInfoMap(Constants.DATA_INDEX_SIZE, - Long.toString(indexUpdateCallback.getDocumentSize())); + crawlingSessionHelper.putToInfoMap(Constants.DATA_INDEX_EXEC_TIME, Long.toString(indexUpdateCallback.getExecuteTime())); + crawlingSessionHelper.putToInfoMap(Constants.DATA_INDEX_SIZE, Long.toString(indexUpdateCallback.getDocumentSize())); for (final String sid : sessionIdList) { // remove config @@ -248,9 +226,7 @@ public class DataIndexHelper implements Serializable { private DataStore dataStore; - protected DataCrawlingThread( - final DataCrawlingConfig dataCrawlingConfig, - final IndexUpdateCallback indexUpdateCallback, + protected DataCrawlingThread(final DataCrawlingConfig dataCrawlingConfig, final IndexUpdateCallback indexUpdateCallback, final Map initParamMap) { this.dataCrawlingConfig = dataCrawlingConfig; this.indexUpdateCallback = indexUpdateCallback; @@ -260,20 +236,15 @@ public class DataIndexHelper implements Serializable { @Override public void run() { running = true; - final DataStoreFactory dataStoreFactory = ComponentUtil - .getDataStoreFactory(); - dataStore = dataStoreFactory.getDataStore(dataCrawlingConfig - .getHandlerName()); + final DataStoreFactory dataStoreFactory = ComponentUtil.getDataStoreFactory(); + dataStore = dataStoreFactory.getDataStore(dataCrawlingConfig.getHandlerName()); if (dataStore == null) { - logger.error("DataStore(" + dataCrawlingConfig.getHandlerName() - + ") is not found."); + logger.error("DataStore(" + dataCrawlingConfig.getHandlerName() + ") is not found."); } else { try { - dataStore.store(dataCrawlingConfig, indexUpdateCallback, - initParamMap); + dataStore.store(dataCrawlingConfig, indexUpdateCallback, initParamMap); } catch (final Exception e) { - logger.error("Failed to process a data crawling: " - + dataCrawlingConfig.getName(), e); + logger.error("Failed to process a data crawling: " + dataCrawlingConfig.getName(), e); } finally { deleteOldDocs(); } @@ -290,18 +261,14 @@ public class DataIndexHelper implements Serializable { } final FieldHelper fieldHelper = ComponentUtil.getFieldHelper(); final StringBuilder buf = new StringBuilder(100); - buf.append(fieldHelper.configIdField).append(':') - .append(dataCrawlingConfig.getConfigId()); + buf.append(fieldHelper.configIdField).append(':').append(dataCrawlingConfig.getConfigId()); buf.append(" NOT "); - buf.append(fieldHelper.segmentField).append(':') - .append(ClientUtils.escapeQueryChars(sessionId)); + buf.append(fieldHelper.segmentField).append(':').append(ClientUtils.escapeQueryChars(sessionId)); try { - indexUpdateCallback.getSolrGroup() - .deleteByQuery(buf.toString()); + indexUpdateCallback.getSolrGroup().deleteByQuery(buf.toString()); } catch (final Exception e) { - logger.error("Could not delete old docs at " - + dataCrawlingConfig, e); + logger.error("Could not delete old docs at " + dataCrawlingConfig, e); } } @@ -326,15 +293,13 @@ public class DataIndexHelper implements Serializable { public void awaitTermination() { try { join(); - } catch (final InterruptedException e) { - } + } catch (final InterruptedException e) {} } public void awaitTermination(final long mills) { try { join(mills); - } catch (final InterruptedException e) { - } + } catch (final InterruptedException e) {} } } } diff --git a/src/main/java/org/codelibs/fess/helper/DocumentHelper.java b/src/main/java/org/codelibs/fess/helper/DocumentHelper.java index 458e2b60e..f6fcbb3ff 100644 --- a/src/main/java/org/codelibs/fess/helper/DocumentHelper.java +++ b/src/main/java/org/codelibs/fess/helper/DocumentHelper.java @@ -33,14 +33,11 @@ public class DocumentHelper { @Resource protected SolrGroupManager solrGroupManager; - public void update(final String docId, final String fieldName, - final long num) { + public void update(final String docId, final String fieldName, final long num) { - final SolrGroup solrGroup = solrGroupManager - .getSolrGroup(QueryType.ADD); + final SolrGroup solrGroup = solrGroupManager.getSolrGroup(QueryType.ADD); if (!solrGroup.isActive(QueryType.ADD)) { - throw new FessSystemException("SolrGroup " - + solrGroup.getGroupName() + " is not available."); + throw new FessSystemException("SolrGroup " + solrGroup.getGroupName() + " is not available."); } final SolrInputDocument doc = new SolrInputDocument(); diff --git a/src/main/java/org/codelibs/fess/helper/HotSearchWordHelper.java b/src/main/java/org/codelibs/fess/helper/HotSearchWordHelper.java index 9cc934706..597d42562 100644 --- a/src/main/java/org/codelibs/fess/helper/HotSearchWordHelper.java +++ b/src/main/java/org/codelibs/fess/helper/HotSearchWordHelper.java @@ -44,21 +44,15 @@ public class HotSearchWordHelper { @InitMethod public void init() { - final LocalDateTime now = ComponentUtil.getSystemHelper() - .getCurrentTime(); - cacheMap.put(Range.ONE_DAY, - getHotSearchWordListByFromDate(now.minusDays(1))); - cacheMap.put(Range.ONE_WEEK, - getHotSearchWordListByFromDate(now.minusWeeks(1))); - cacheMap.put(Range.ONE_MONTH, - getHotSearchWordListByFromDate(now.minusMonths(1))); - cacheMap.put(Range.ONE_YEAR, - getHotSearchWordListByFromDate(now.minusYears(1))); + final LocalDateTime now = ComponentUtil.getSystemHelper().getCurrentTime(); + cacheMap.put(Range.ONE_DAY, getHotSearchWordListByFromDate(now.minusDays(1))); + cacheMap.put(Range.ONE_WEEK, getHotSearchWordListByFromDate(now.minusWeeks(1))); + cacheMap.put(Range.ONE_MONTH, getHotSearchWordListByFromDate(now.minusMonths(1))); + cacheMap.put(Range.ONE_YEAR, getHotSearchWordListByFromDate(now.minusYears(1))); cacheMap.put(Range.ENTIRE, getHotSearchWordListByFromDate(null)); } - protected List getHotSearchWordListByFromDate( - final LocalDateTime fromDate) { + protected List getHotSearchWordListByFromDate(final LocalDateTime fromDate) { final HotSearchWordPmb pmb = new HotSearchWordPmb(); if (fromDate != null) { diff --git a/src/main/java/org/codelibs/fess/helper/IndexingHelper.java b/src/main/java/org/codelibs/fess/helper/IndexingHelper.java index 10459d55e..258914c2f 100644 --- a/src/main/java/org/codelibs/fess/helper/IndexingHelper.java +++ b/src/main/java/org/codelibs/fess/helper/IndexingHelper.java @@ -32,8 +32,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class IndexingHelper { - private static final Logger logger = LoggerFactory - .getLogger(IndexingHelper.class); + private static final Logger logger = LoggerFactory.getLogger(IndexingHelper.class); public int maxRetryCount = 5; @@ -41,26 +40,22 @@ public class IndexingHelper { public long requestInterval = 500; - public void sendDocuments(final SolrGroup solrGroup, - final List docList) { + public void sendDocuments(final SolrGroup solrGroup, final List docList) { final long execTime = System.currentTimeMillis(); if (logger.isDebugEnabled()) { - logger.debug("Sending " + docList.size() - + " documents to a server."); + logger.debug("Sending " + docList.size() + " documents to a server."); } synchronized (solrGroup) { deleteOldDocuments(solrGroup, docList); solrGroup.add(docList); } if (logger.isInfoEnabled()) { - logger.info("Sent " + docList.size() + " docs (Solr: " - + (System.currentTimeMillis() - execTime) + "ms)"); + logger.info("Sent " + docList.size() + " docs (Solr: " + (System.currentTimeMillis() - execTime) + "ms)"); } docList.clear(); } - private void deleteOldDocuments(final SolrGroup solrGroup, - final List docList) { + private void deleteOldDocuments(final SolrGroup solrGroup, final List docList) { final FieldHelper fieldHelper = ComponentUtil.getFieldHelper(); final List docIdList = new ArrayList(); @@ -72,31 +67,27 @@ public class IndexingHelper { continue; } - final Object configIdValue = inputDoc - .getFieldValue(fieldHelper.configIdField); + final Object configIdValue = inputDoc.getFieldValue(fieldHelper.configIdField); if (configIdValue == null) { continue; } q.setLength(0); q.append(fieldHelper.urlField).append(":\""); - q.append(ClientUtils.escapeQueryChars((String) inputDoc - .getFieldValue(fieldHelper.urlField))); + q.append(ClientUtils.escapeQueryChars((String) inputDoc.getFieldValue(fieldHelper.urlField))); q.append('"'); fq.setLength(0); fq.append(fieldHelper.configIdField).append(':'); fq.append(configIdValue.toString()); - final SolrDocumentList docs = getSolrDocumentList(solrGroup, - fq.toString(), q.toString(), new String[] { - fieldHelper.idField, fieldHelper.docIdField }); + final SolrDocumentList docs = + getSolrDocumentList(solrGroup, fq.toString(), q.toString(), + new String[] { fieldHelper.idField, fieldHelper.docIdField }); for (final SolrDocument doc : docs) { - final Object oldIdValue = doc - .getFieldValue(fieldHelper.idField); + final Object oldIdValue = doc.getFieldValue(fieldHelper.idField); if (!idValue.equals(oldIdValue) && oldIdValue != null) { - final Object oldDocIdValue = doc - .getFieldValue(fieldHelper.docIdField); + final Object oldDocIdValue = doc.getFieldValue(fieldHelper.docIdField); if (oldDocIdValue != null) { docIdList.add(oldDocIdValue.toString()); } @@ -111,13 +102,11 @@ public class IndexingHelper { } } - public SolrDocumentList getSolrDocumentList(final SolrGroup solrGroup, - final String fq, final String q, final String[] fields) { + public SolrDocumentList getSolrDocumentList(final SolrGroup solrGroup, final String fq, final String q, final String[] fields) { return getSolrDocumentList(solrGroup, fq, q, fields, defaultRowSize); } - protected SolrDocumentList getSolrDocumentList(final SolrGroup solrGroup, - final String fq, final String q, final String[] fields, + protected SolrDocumentList getSolrDocumentList(final SolrGroup solrGroup, final String fq, final String q, final String[] fields, final int row) { final SolrQuery sq = new SolrQuery(); if (fq != null) { @@ -132,8 +121,7 @@ public class IndexingHelper { if (docList.getNumFound() <= row) { return docList; } - return getSolrDocumentList(solrGroup, fq, q, fields, - (int) docList.getNumFound()); + return getSolrDocumentList(solrGroup, fq, q, fields, (int) docList.getNumFound()); } public void deleteDocument(final SolrGroup solrGroup, final String id) { @@ -143,39 +131,32 @@ public class IndexingHelper { for (int i = 0; i < maxRetryCount; i++) { boolean done = true; try { - for (final UpdateResponse response : solrGroup - .deleteByQuery(query)) { + for (final UpdateResponse response : solrGroup.deleteByQuery(query)) { if (response.getStatus() != 0) { logger.warn("Failed to delete: " + response); done = false; } } } catch (final Exception e) { - logger.warn("Could not delete a document from Solr." - + " It might be busy. " + "Retrying.. id:" + id - + ", cause: " + e.getMessage()); + logger.warn("Could not delete a document from Solr." + " It might be busy. " + "Retrying.. id:" + id + ", cause: " + + e.getMessage()); done = false; } if (done) { if (logger.isDebugEnabled()) { - logger.info("Deleted 1 doc (Solr: " - + (System.currentTimeMillis() - start) - + "ms) => id:" + id); + logger.info("Deleted 1 doc (Solr: " + (System.currentTimeMillis() - start) + "ms) => id:" + id); } else { - logger.info("Deleted 1 doc (Solr: " - + (System.currentTimeMillis() - start) + "ms)"); + logger.info("Deleted 1 doc (Solr: " + (System.currentTimeMillis() - start) + "ms)"); } return; } try { Thread.sleep(requestInterval); - } catch (final InterruptedException e) { - } + } catch (final InterruptedException e) {} } } - public void deleteDocumentsByDocId(final SolrGroup solrGroup, - final List docIdList) { + public void deleteDocumentsByDocId(final SolrGroup solrGroup, final List docIdList) { final long start = System.currentTimeMillis(); final FieldHelper fieldHelper = ComponentUtil.getFieldHelper(); final StringBuilder buf = new StringBuilder(500); @@ -189,39 +170,33 @@ public class IndexingHelper { for (int i = 0; i < maxRetryCount; i++) { boolean done = true; try { - for (final UpdateResponse response : solrGroup - .deleteByQuery(query)) { + for (final UpdateResponse response : solrGroup.deleteByQuery(query)) { if (response.getStatus() != 0) { logger.warn("Failed to delete: " + response); done = false; } } } catch (final Exception e) { - logger.warn("Could not delete a document from Solr." - + " It might be busy. " + "Retrying.. id:" + docIdList - + ", cause: " + e.getMessage()); + logger.warn("Could not delete a document from Solr." + " It might be busy. " + "Retrying.. id:" + docIdList + ", cause: " + + e.getMessage()); done = false; } if (done) { if (logger.isDebugEnabled()) { - logger.info("Deleted " + docIdList.size() + " docs (Solr: " - + (System.currentTimeMillis() - start) - + "ms) => docId:" + docIdList); + logger.info("Deleted " + docIdList.size() + " docs (Solr: " + (System.currentTimeMillis() - start) + "ms) => docId:" + + docIdList); } else { - logger.info("Deleted " + docIdList.size() + " docs (Solr: " - + (System.currentTimeMillis() - start) + "ms)"); + logger.info("Deleted " + docIdList.size() + " docs (Solr: " + (System.currentTimeMillis() - start) + "ms)"); } return; } try { Thread.sleep(requestInterval); - } catch (final InterruptedException e) { - } + } catch (final InterruptedException e) {} } } - public SolrDocument getSolrDocument(final SolrGroup solrGroup, - final String id, final String[] fields) { + public SolrDocument getSolrDocument(final SolrGroup solrGroup, final String id, final String[] fields) { final FieldHelper fieldHelper = ComponentUtil.getFieldHelper(); final SolrQuery solrQuery = new SolrQuery(); @@ -250,8 +225,7 @@ public class IndexingHelper { return docList.get(0); } - public SolrDocumentList getSolrDocumentListByPrefixId( - final SolrGroup solrGroup, final String id, final String[] fields) { + public SolrDocumentList getSolrDocumentListByPrefixId(final SolrGroup solrGroup, final String id, final String[] fields) { final FieldHelper fieldHelper = ComponentUtil.getFieldHelper(); final SolrQuery solrQuery = new SolrQuery(); final StringBuilder queryBuf = new StringBuilder(500); @@ -272,11 +246,9 @@ public class IndexingHelper { return docList; } - public void deleteChildSolrDocument(final SolrGroup solrGroup, - final String id) { + public void deleteChildSolrDocument(final SolrGroup solrGroup, final String id) { final FieldHelper fieldHelper = ComponentUtil.getFieldHelper(); - final String query = "{!raw f=" + fieldHelper.parentIdField + " v=\"" - + id + "\"}"; + final String query = "{!raw f=" + fieldHelper.parentIdField + " v=\"" + id + "\"}"; for (final UpdateResponse response : solrGroup.deleteByQuery(query)) { if (response.getStatus() != 0) { logger.warn("Failed to delete: " + response); @@ -284,28 +256,22 @@ public class IndexingHelper { } } - public SolrDocumentList getChildSolrDocumentList(final SolrGroup solrGroup, - final String id, final String[] fields) { + public SolrDocumentList getChildSolrDocumentList(final SolrGroup solrGroup, final String id, final String[] fields) { return getChildSolrDocumentList(solrGroup, id, fields, defaultRowSize); } - protected SolrDocumentList getChildSolrDocumentList( - final SolrGroup solrGroup, final String id, final String[] fields, - final int row) { + protected SolrDocumentList getChildSolrDocumentList(final SolrGroup solrGroup, final String id, final String[] fields, final int row) { final FieldHelper fieldHelper = ComponentUtil.getFieldHelper(); final SolrQuery solrQuery = new SolrQuery(); - solrQuery.setQuery("{!raw f=" + fieldHelper.parentIdField + " v=\"" - + id + "\"}"); + solrQuery.setQuery("{!raw f=" + fieldHelper.parentIdField + " v=\"" + id + "\"}"); if (fields != null) { solrQuery.setFields(fields); } solrQuery.setRows(row); - final SolrDocumentList docList = solrGroup.query(solrQuery) - .getResults(); + final SolrDocumentList docList = solrGroup.query(solrQuery).getResults(); if (docList.getNumFound() <= row) { return docList; } - return getChildSolrDocumentList(solrGroup, id, fields, - (int) docList.getNumFound()); + return getChildSolrDocumentList(solrGroup, id, fields, (int) docList.getNumFound()); } } \ No newline at end of file diff --git a/src/main/java/org/codelibs/fess/helper/IntervalControlHelper.java b/src/main/java/org/codelibs/fess/helper/IntervalControlHelper.java index de73e55a5..27a4eddc8 100644 --- a/src/main/java/org/codelibs/fess/helper/IntervalControlHelper.java +++ b/src/main/java/org/codelibs/fess/helper/IntervalControlHelper.java @@ -33,8 +33,7 @@ public class IntervalControlHelper { while (!crawlerRunning) { try { Thread.sleep(crawlerWaitMillis); - } catch (final InterruptedException e) { - } + } catch (final InterruptedException e) {} } } @@ -43,8 +42,7 @@ public class IntervalControlHelper { if (delay > 0) { try { Thread.sleep(delay); - } catch (final InterruptedException e) { - } + } catch (final InterruptedException e) {} } } @@ -70,8 +68,7 @@ public class IntervalControlHelper { return cal; } - public void addIntervalRule(final String from, final String to, - final String days, final long delay) { + public void addIntervalRule(final String from, final String to, final String days, final long delay) { ruleList.add(new IntervalRule(from, to, days, delay)); } @@ -98,8 +95,7 @@ public class IntervalControlHelper { protected boolean reverse; - public IntervalRule(final String from, final String to, - final String days, final long delay) { + public IntervalRule(final String from, final String to, final String days, final long delay) { final int[] fints = parseTime(from); fromHours = fints[0]; fromMinutes = fints[1]; @@ -111,8 +107,7 @@ public class IntervalControlHelper { for (final String value : values) { try { list.add(Integer.parseInt(value.trim())); - } catch (final NumberFormatException e) { - } + } catch (final NumberFormatException e) {} } this.days = new int[list.size()]; for (int i = 0; i < list.size(); i++) { @@ -126,20 +121,16 @@ public class IntervalControlHelper { return delay; } - public boolean isTarget(final int hours, final int minutes, - final int day) { + public boolean isTarget(final int hours, final int minutes, final int day) { if (reverse) { - if (compareTime(hours, minutes, toHours, toMinutes) >= 0 - && isInDays(day + 1)) { + if (compareTime(hours, minutes, toHours, toMinutes) >= 0 && isInDays(day + 1)) { return true; - } else if (compareTime(fromHours, fromMinutes, hours, minutes) >= 0 - && isInDays(day)) { + } else if (compareTime(fromHours, fromMinutes, hours, minutes) >= 0 && isInDays(day)) { return true; } return false; } else { - return compareTime(fromHours, fromMinutes, hours, minutes) >= 0 - && compareTime(hours, minutes, toHours, toMinutes) >= 0 + return compareTime(fromHours, fromMinutes, hours, minutes) >= 0 && compareTime(hours, minutes, toHours, toMinutes) >= 0 && isInDays(day); } } @@ -162,8 +153,7 @@ public class IntervalControlHelper { return false; } - protected int compareTime(final int h1, final int m1, final int h2, - final int m2) { + protected int compareTime(final int h1, final int m1, final int h2, final int m2) { if (h1 < h2) { return 1; } else if (h1 == h2) { diff --git a/src/main/java/org/codelibs/fess/helper/JobHelper.java b/src/main/java/org/codelibs/fess/helper/JobHelper.java index a17604ad7..6127f0bc5 100644 --- a/src/main/java/org/codelibs/fess/helper/JobHelper.java +++ b/src/main/java/org/codelibs/fess/helper/JobHelper.java @@ -32,8 +32,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class JobHelper { - private static final Logger logger = LoggerFactory - .getLogger(JobHelper.class); + private static final Logger logger = LoggerFactory.getLogger(JobHelper.class); private final ConcurrentHashMap runningProcessMap = new ConcurrentHashMap<>(); @@ -46,14 +45,12 @@ public class JobHelper { } } - public JobProcess startCrawlerProcess(final String sessionId, - final ProcessBuilder processBuilder) { + public JobProcess startCrawlerProcess(final String sessionId, final ProcessBuilder processBuilder) { destroyCrawlerProcess(sessionId); JobProcess jobProcess; try { jobProcess = new JobProcess(processBuilder.start()); - destroyCrawlerProcess(runningProcessMap.putIfAbsent(sessionId, - jobProcess)); + destroyCrawlerProcess(runningProcessMap.putIfAbsent(sessionId, jobProcess)); return jobProcess; } catch (final IOException e) { throw new FessSystemException("Crawler Process terminated.", e); @@ -75,8 +72,7 @@ public class JobHelper { try { ist.interrupt(); } catch (final Exception e) { - logger.warn("Could not interrupt a thread of an input stream.", - e); + logger.warn("Could not interrupt a thread of an input stream.", e); } final CountDownLatch latch = new CountDownLatch(1); @@ -87,20 +83,17 @@ public class JobHelper { try { IOUtils.closeQuietly(process.getInputStream()); } catch (final Exception e) { - logger.warn("Could not close a process input stream.", - e); + logger.warn("Could not close a process input stream.", e); } try { IOUtils.closeQuietly(process.getErrorStream()); } catch (final Exception e) { - logger.warn("Could not close a process error stream.", - e); + logger.warn("Could not close a process error stream.", e); } try { IOUtils.closeQuietly(process.getOutputStream()); } catch (final Exception e) { - logger.warn("Could not close a process output stream.", - e); + logger.warn("Could not close a process output stream.", e); } latch.countDown(); } @@ -123,8 +116,7 @@ public class JobHelper { return runningProcessMap.keySet(); } - public JobExecutor startJobExecutoer(final Long id, - final JobExecutor jobExecutor) { + public JobExecutor startJobExecutoer(final Long id, final JobExecutor jobExecutor) { return runningJobExecutorMap.putIfAbsent(id, jobExecutor); } diff --git a/src/main/java/org/codelibs/fess/helper/KeyMatchHelper.java b/src/main/java/org/codelibs/fess/helper/KeyMatchHelper.java index d1bd47ca0..99947d74e 100644 --- a/src/main/java/org/codelibs/fess/helper/KeyMatchHelper.java +++ b/src/main/java/org/codelibs/fess/helper/KeyMatchHelper.java @@ -31,8 +31,7 @@ import org.seasar.framework.container.SingletonS2Container; import org.seasar.framework.container.annotation.tiger.InitMethod; public class KeyMatchHelper { - protected volatile Map keyMatchQueryMap = Collections - .emptyMap(); + protected volatile Map keyMatchQueryMap = Collections.emptyMap(); protected ThreadLocal> searchWordList = new ThreadLocal<>(); @@ -54,24 +53,20 @@ public class KeyMatchHelper { protected void reload(final long interval) { final FieldHelper fieldHelper = ComponentUtil.getFieldHelper(); - final KeyMatchService keyMatchService = SingletonS2Container - .getComponent(KeyMatchService.class); + final KeyMatchService keyMatchService = SingletonS2Container.getComponent(KeyMatchService.class); final List list = keyMatchService.getAvailableKeyMatchList(); - final Map keyMatchQueryMap = new HashMap( - list.size()); + final Map keyMatchQueryMap = new HashMap(list.size()); for (final KeyMatch keyMatch : list) { final List> documentList = getDocumentList(keyMatch); final List docIdList = new ArrayList(); for (final Map map : documentList) { final String docId = (String) map.get(fieldHelper.docIdField); if (StringUtil.isNotBlank(docId)) { - docIdList.add(fieldHelper.docIdField + ":" + docId + "^" - + keyMatch.getBoost()); + docIdList.add(fieldHelper.docIdField + ":" + docId + "^" + keyMatch.getBoost()); } } if (!docIdList.isEmpty()) { - keyMatchQueryMap.put(keyMatch.getTerm(), - docIdList.toArray(new String[docIdList.size()])); + keyMatchQueryMap.put(keyMatch.getTerm(), docIdList.toArray(new String[docIdList.size()])); } if (reloadInterval > 0) { @@ -88,9 +83,8 @@ public class KeyMatchHelper { protected List> getDocumentList(final KeyMatch keyMatch) { final SearchService searchService = ComponentUtil.getSearchService(); final FieldHelper fieldHelper = ComponentUtil.getFieldHelper(); - final List> documentList = searchService - .getDocumentList(keyMatch.getQuery(), 0, keyMatch.getMaxSize(), - null, null, null, + final List> documentList = + searchService.getDocumentList(keyMatch.getQuery(), 0, keyMatch.getMaxSize(), null, null, null, new String[] { fieldHelper.docIdField }, null, false); return documentList; } diff --git a/src/main/java/org/codelibs/fess/helper/LabelTypeHelper.java b/src/main/java/org/codelibs/fess/helper/LabelTypeHelper.java index 539e59f00..53a85ca52 100644 --- a/src/main/java/org/codelibs/fess/helper/LabelTypeHelper.java +++ b/src/main/java/org/codelibs/fess/helper/LabelTypeHelper.java @@ -38,8 +38,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class LabelTypeHelper implements Serializable { - private static final Logger logger = LoggerFactory - .getLogger(LabelTypeHelper.class); + private static final Logger logger = LoggerFactory.getLogger(LabelTypeHelper.class); private static final long serialVersionUID = 1L; @@ -56,8 +55,7 @@ public class LabelTypeHelper implements Serializable { @InitMethod public void init() { - final List labelTypeList = getLabelTypeService() - .getLabelTypeListWithRoles(); + final List labelTypeList = getLabelTypeService().getLabelTypeListWithRoles(); buildLabelTypeItems(labelTypeList); } @@ -95,8 +93,7 @@ public class LabelTypeHelper implements Serializable { for (final LabelTypeItem item : labelTypeItemList) { for (final String roleValue : roleSet) { if (item.getRoleValueList().contains(roleValue)) { - final Map map = new HashMap( - 2); + final Map map = new HashMap(2); map.put(Constants.ITEM_LABEL, item.getLabel()); map.put(Constants.ITEM_VALUE, item.getValue()); itemList.add(map); @@ -113,28 +110,17 @@ public class LabelTypeHelper implements Serializable { if (labelTypePatternList == null) { synchronized (this) { if (labelTypePatternList == null) { - final List labelTypeList = getLabelTypeService() - .getLabelTypeList(); + final List labelTypeList = getLabelTypeService().getLabelTypeList(); final List list = new ArrayList(); for (final LabelType labelType : labelTypeList) { - final String includedPaths = labelType - .getIncludedPaths(); - final String excludedPaths = labelType - .getExcludedPaths(); - if (StringUtil.isNotBlank(includedPaths) - || StringUtil.isNotBlank(excludedPaths)) { + final String includedPaths = labelType.getIncludedPaths(); + final String excludedPaths = labelType.getExcludedPaths(); + if (StringUtil.isNotBlank(includedPaths) || StringUtil.isNotBlank(excludedPaths)) { try { - list.add(new LabelTypePattern(labelType - .getValue(), includedPaths, - excludedPaths)); + list.add(new LabelTypePattern(labelType.getValue(), includedPaths, excludedPaths)); } catch (final Exception e) { - logger.warn( - "Failed to create a matching pattern of a label: " - + labelType.getValue() - + ", includedPaths:" - + includedPaths - + ", excludedPaths:" - + excludedPaths, e); + logger.warn("Failed to create a matching pattern of a label: " + labelType.getValue() + ", includedPaths:" + + includedPaths + ", excludedPaths:" + excludedPaths, e); } } } @@ -196,8 +182,7 @@ public class LabelTypeHelper implements Serializable { private Pattern excludedPaths; - public LabelTypePattern(final String value, final String includedPaths, - final String excludedPaths) { + public LabelTypePattern(final String value, final String includedPaths, final String excludedPaths) { this.value = value; if (StringUtil.isNotBlank(includedPaths)) { @@ -236,8 +221,7 @@ public class LabelTypeHelper implements Serializable { public boolean match(final String path) { if (includedPaths != null) { if (includedPaths.matcher(path).matches()) { - if (excludedPaths != null - && excludedPaths.matcher(path).matches()) { + if (excludedPaths != null && excludedPaths.matcher(path).matches()) { return false; } return true; diff --git a/src/main/java/org/codelibs/fess/helper/MailHelper.java b/src/main/java/org/codelibs/fess/helper/MailHelper.java index d6fad038c..98749a46b 100644 --- a/src/main/java/org/codelibs/fess/helper/MailHelper.java +++ b/src/main/java/org/codelibs/fess/helper/MailHelper.java @@ -45,8 +45,7 @@ public class MailHelper implements Serializable { props.put(key, value); } - public void send(final String[] toAddresses, final String subject, - final String text) { + public void send(final String[] toAddresses, final String subject, final String text) { if (toAddresses == null || toAddresses.length == 0) { throw new FessSystemException("TO address is empty."); } @@ -73,8 +72,7 @@ public class MailHelper implements Serializable { Transport.send(msg); } catch (final MessagingException e) { - throw new FessSystemException("Failed to send " - + Arrays.toString(toAddresses), e); + throw new FessSystemException("Failed to send " + Arrays.toString(toAddresses), e); } } diff --git a/src/main/java/org/codelibs/fess/helper/OpenSearchHelper.java b/src/main/java/org/codelibs/fess/helper/OpenSearchHelper.java index 7a5a2d7f9..43e448ff0 100644 --- a/src/main/java/org/codelibs/fess/helper/OpenSearchHelper.java +++ b/src/main/java/org/codelibs/fess/helper/OpenSearchHelper.java @@ -53,8 +53,7 @@ public class OpenSearchHelper { @InitMethod public void init() { if (StringUtil.isNotBlank(osddPath)) { - final String path = ServletContextUtil.getServletContext() - .getRealPath(osddPath); + final String path = ServletContextUtil.getServletContext().getRealPath(osddPath); osddFile = new File(path); if (!osddFile.isFile()) { osddFile = null; @@ -80,8 +79,7 @@ public class OpenSearchHelper { os = response.getOutputStream(); os.write(FileUtil.getBytes(osddFile)); } catch (final IOException e) { - throw new FessSystemException( - "Failed to write OpenSearch response.", e); + throw new FessSystemException("Failed to write OpenSearch response.", e); } finally { IOUtils.closeQuietly(os); } diff --git a/src/main/java/org/codelibs/fess/helper/OverlappingHostHelper.java b/src/main/java/org/codelibs/fess/helper/OverlappingHostHelper.java index 5969abd6d..49ecc3599 100644 --- a/src/main/java/org/codelibs/fess/helper/OverlappingHostHelper.java +++ b/src/main/java/org/codelibs/fess/helper/OverlappingHostHelper.java @@ -36,14 +36,11 @@ public class OverlappingHostHelper implements Serializable { if (overlappingHostList == null) { overlappingHostList = new ArrayList(); } - final OverlappingHostService overlappingHostService = SingletonS2Container - .getComponent(OverlappingHostService.class); - overlappingHostList.addAll(overlappingHostService - .getOverlappingHostList()); + final OverlappingHostService overlappingHostService = SingletonS2Container.getComponent(OverlappingHostService.class); + overlappingHostList.addAll(overlappingHostService.getOverlappingHostList()); } - public void setOverlappingHostList( - final List overlappingHostList) { + public void setOverlappingHostList(final List overlappingHostList) { this.overlappingHostList = overlappingHostList; } diff --git a/src/main/java/org/codelibs/fess/helper/PathMappingHelper.java b/src/main/java/org/codelibs/fess/helper/PathMappingHelper.java index eab86948f..1b5a14fc3 100644 --- a/src/main/java/org/codelibs/fess/helper/PathMappingHelper.java +++ b/src/main/java/org/codelibs/fess/helper/PathMappingHelper.java @@ -35,8 +35,7 @@ public class PathMappingHelper implements Serializable { private static final long serialVersionUID = 1L; - private static final Logger logger = LoggerFactory - .getLogger(PathMappingHelper.class); + private static final Logger logger = LoggerFactory.getLogger(PathMappingHelper.class); private final Map> pathMappingMap = new HashMap>(); @@ -49,8 +48,7 @@ public class PathMappingHelper implements Serializable { ptList.add(CDef.ProcessType.Both); try { - final PathMappingBhv pathMappingBhv = SingletonS2Container - .getComponent(PathMappingBhv.class); + final PathMappingBhv pathMappingBhv = SingletonS2Container.getComponent(PathMappingBhv.class); cachedPathMappingList = pathMappingBhv.selectList(cb -> { cb.query().setDeletedBy_IsNull(); cb.query().addOrderBy_SortOrder_Asc(); @@ -61,8 +59,7 @@ public class PathMappingHelper implements Serializable { } } - public void setPathMappingList(final String sessionId, - final List pathMappingList) { + public void setPathMappingList(final String sessionId, final List pathMappingList) { if (sessionId != null) { if (pathMappingList != null) { pathMappingMap.put(sessionId, pathMappingList); @@ -101,8 +98,7 @@ public class PathMappingHelper implements Serializable { } String result = text; for (final PathMapping pathMapping : cachedPathMappingList) { - result = result.replaceAll("(\"[^\"]*)" + pathMapping.getRegex() - + "([^\"]*\")", "$1" + pathMapping.getReplacement() + "$2"); + result = result.replaceAll("(\"[^\"]*)" + pathMapping.getRegex() + "([^\"]*\")", "$1" + pathMapping.getReplacement() + "$2"); } return result; } @@ -118,8 +114,7 @@ public class PathMappingHelper implements Serializable { return replaceUrl(cachedPathMappingList, url); } - private String replaceUrl(final List pathMappingList, - final String url) { + private String replaceUrl(final List pathMappingList, final String url) { String newUrl = url; for (final PathMapping pathMapping : pathMappingList) { final Matcher matcher = pathMapping.getMatcher(newUrl); diff --git a/src/main/java/org/codelibs/fess/helper/QueryHelper.java b/src/main/java/org/codelibs/fess/helper/QueryHelper.java index e150d2001..3d8262b9a 100644 --- a/src/main/java/org/codelibs/fess/helper/QueryHelper.java +++ b/src/main/java/org/codelibs/fess/helper/QueryHelper.java @@ -166,67 +166,50 @@ public class QueryHelper implements Serializable { @InitMethod public void init() { if (responseFields == null) { - responseFields = new String[] { SCORE_FIELD, fieldHelper.idField, - fieldHelper.docIdField, fieldHelper.boostField, - fieldHelper.contentLengthField, fieldHelper.hostField, - fieldHelper.siteField, fieldHelper.lastModifiedField, - fieldHelper.mimetypeField, fieldHelper.filetypeField, - fieldHelper.createdField, fieldHelper.titleField, - fieldHelper.digestField, fieldHelper.urlField, - fieldHelper.clickCountField, - fieldHelper.favoriteCountField, fieldHelper.configIdField, - fieldHelper.langField, fieldHelper.hasCacheField }; + responseFields = + new String[] { SCORE_FIELD, fieldHelper.idField, fieldHelper.docIdField, fieldHelper.boostField, + fieldHelper.contentLengthField, fieldHelper.hostField, fieldHelper.siteField, fieldHelper.lastModifiedField, + fieldHelper.mimetypeField, fieldHelper.filetypeField, fieldHelper.createdField, fieldHelper.titleField, + fieldHelper.digestField, fieldHelper.urlField, fieldHelper.clickCountField, fieldHelper.favoriteCountField, + fieldHelper.configIdField, fieldHelper.langField, fieldHelper.hasCacheField }; } if (cacheResponseFields == null) { - cacheResponseFields = new String[] { SCORE_FIELD, - fieldHelper.idField, fieldHelper.docIdField, - fieldHelper.boostField, fieldHelper.contentLengthField, - fieldHelper.hostField, fieldHelper.siteField, - fieldHelper.lastModifiedField, fieldHelper.mimetypeField, - fieldHelper.filetypeField, fieldHelper.createdField, - fieldHelper.titleField, fieldHelper.digestField, - fieldHelper.urlField, fieldHelper.clickCountField, - fieldHelper.favoriteCountField, fieldHelper.configIdField, - fieldHelper.langField, fieldHelper.cacheField }; + cacheResponseFields = + new String[] { SCORE_FIELD, fieldHelper.idField, fieldHelper.docIdField, fieldHelper.boostField, + fieldHelper.contentLengthField, fieldHelper.hostField, fieldHelper.siteField, fieldHelper.lastModifiedField, + fieldHelper.mimetypeField, fieldHelper.filetypeField, fieldHelper.createdField, fieldHelper.titleField, + fieldHelper.digestField, fieldHelper.urlField, fieldHelper.clickCountField, fieldHelper.favoriteCountField, + fieldHelper.configIdField, fieldHelper.langField, fieldHelper.cacheField }; } if (responseDocValuesFields == null) { - responseDocValuesFields = new String[] { - fieldHelper.clickCountField, fieldHelper.favoriteCountField }; + responseDocValuesFields = new String[] { fieldHelper.clickCountField, fieldHelper.favoriteCountField }; } if (highlightingFields == null) { highlightingFields = new String[] { fieldHelper.contentField }; } if (searchFields == null) { - searchFields = new String[] { INURL_FIELD, fieldHelper.urlField, - fieldHelper.docIdField, fieldHelper.hostField, - fieldHelper.titleField, fieldHelper.contentField, - fieldHelper.contentLengthField, - fieldHelper.lastModifiedField, fieldHelper.mimetypeField, - fieldHelper.filetypeField, fieldHelper.labelField, - fieldHelper.segmentField, fieldHelper.clickCountField, - fieldHelper.favoriteCountField, fieldHelper.langField }; + searchFields = + new String[] { INURL_FIELD, fieldHelper.urlField, fieldHelper.docIdField, fieldHelper.hostField, + fieldHelper.titleField, fieldHelper.contentField, fieldHelper.contentLengthField, + fieldHelper.lastModifiedField, fieldHelper.mimetypeField, fieldHelper.filetypeField, fieldHelper.labelField, + fieldHelper.segmentField, fieldHelper.clickCountField, fieldHelper.favoriteCountField, fieldHelper.langField }; } if (facetFields == null) { - facetFields = new String[] { fieldHelper.urlField, - fieldHelper.hostField, fieldHelper.titleField, - fieldHelper.contentField, fieldHelper.contentLengthField, - fieldHelper.lastModifiedField, fieldHelper.mimetypeField, - fieldHelper.filetypeField, fieldHelper.labelField, - fieldHelper.segmentField }; + facetFields = + new String[] { fieldHelper.urlField, fieldHelper.hostField, fieldHelper.titleField, fieldHelper.contentField, + fieldHelper.contentLengthField, fieldHelper.lastModifiedField, fieldHelper.mimetypeField, + fieldHelper.filetypeField, fieldHelper.labelField, fieldHelper.segmentField }; } if (supportedSortFields == null) { - supportedSortFields = new String[] { fieldHelper.createdField, - fieldHelper.contentLengthField, - fieldHelper.lastModifiedField, fieldHelper.clickCountField, - fieldHelper.favoriteCountField }; + supportedSortFields = + new String[] { fieldHelper.createdField, fieldHelper.contentLengthField, fieldHelper.lastModifiedField, + fieldHelper.clickCountField, fieldHelper.favoriteCountField }; } if (supportedMltFields == null) { - supportedMltFields = new String[] { fieldHelper.contentField, - "content_ja" }; + supportedMltFields = new String[] { fieldHelper.contentField, "content_ja" }; } if (supportedAnalysisFields == null) { - supportedAnalysisFields = new String[] { fieldHelper.contentField, - "content_ja" }; + supportedAnalysisFields = new String[] { fieldHelper.contentField, "content_ja" }; } } @@ -237,8 +220,7 @@ public class QueryHelper implements Serializable { */ public SearchQuery build(final String query, final boolean envCondition) { String q; - if (envCondition && additionalQuery != null - && StringUtil.isNotBlank(query)) { + if (envCondition && additionalQuery != null && StringUtil.isNotBlank(query)) { q = query + " " + additionalQuery; } else { q = query; @@ -254,12 +236,10 @@ public class QueryHelper implements Serializable { } if (keyMatchHelper != null) { - final List docIdQueryList = keyMatchHelper - .getDocIdQueryList(); + final List docIdQueryList = keyMatchHelper.getDocIdQueryList(); if (docIdQueryList != null && searchQuery.queryExists()) { final String originalQuery = searchQuery.getQuery(); - final StringBuilder queryBuf = new StringBuilder( - originalQuery.length() + 100); + final StringBuilder queryBuf = new StringBuilder(originalQuery.length() + 100); queryBuf.append(originalQuery); for (final String docIdQuery : docIdQueryList) { queryBuf.append(_OR_); @@ -275,8 +255,7 @@ public class QueryHelper implements Serializable { // add query final String sq = searchQuery.getQuery(); final StringBuilder queryBuf = new StringBuilder(255); - final boolean hasQueries = sq.contains(_AND_) - || sq.contains(_OR_); + final boolean hasQueries = sq.contains(_AND_) || sq.contains(_OR_); if (hasQueries) { queryBuf.append('('); } @@ -324,8 +303,7 @@ public class QueryHelper implements Serializable { final Map> fieldLogMap = new HashMap>(); final SearchQuery searchQuery = new SearchQuery(); - final String q = buildQuery(query, sortFieldMap, highLightQueryList, - fieldLogMap); + final String q = buildQuery(query, sortFieldMap, highLightQueryList, fieldLogMap); String solrQuery; if (q == null || "()".equals(q)) { solrQuery = StringUtil.EMPTY; @@ -343,9 +321,7 @@ public class QueryHelper implements Serializable { // set queries to request for HighLight final HttpServletRequest request = RequestUtil.getRequest(); if (request != null) { - request.setAttribute(Constants.HIGHLIGHT_QUERIES, - highLightQueryList.toArray(new String[highLightQueryList - .size()])); + request.setAttribute(Constants.HIGHLIGHT_QUERIES, highLightQueryList.toArray(new String[highLightQueryList.size()])); request.setAttribute(Constants.FIELD_LOGS, fieldLogMap); } return searchQuery; @@ -380,12 +356,9 @@ public class QueryHelper implements Serializable { } - protected String buildQuery(final String query, - final Map sortFieldMap, - final List highLightQueryList, + protected String buildQuery(final String query, final Map sortFieldMap, final List highLightQueryList, final Map> fieldLogMap) { - final List queryPartList = splitQuery(query, sortFieldMap, - highLightQueryList, fieldLogMap); + final List queryPartList = splitQuery(query, sortFieldMap, highLightQueryList, fieldLogMap); if (queryPartList == null || queryPartList.isEmpty()) { return null; } @@ -411,8 +384,7 @@ public class QueryHelper implements Serializable { // check prefix for (final String field : searchFields) { String prefix = field + ":"; - if (value.startsWith(prefix) - && value.length() != prefix.length()) { + if (value.startsWith(prefix) && value.length() != prefix.length()) { if (queryBuf.length() > 0 && !notOperatorFlag) { queryBuf.append(operator); } @@ -429,8 +401,7 @@ public class QueryHelper implements Serializable { if (isInUrl) { buf.append('*'); } - appendQueryValue(buf, targetWord, isInUrl ? false - : useBigram); + appendQueryValue(buf, targetWord, isInUrl ? false : useBigram); if (isInUrl) { buf.append('*'); } @@ -442,8 +413,7 @@ public class QueryHelper implements Serializable { if (isInUrl) { queryBuf.append('*'); } - appendQueryValue(queryBuf, targetWord, isInUrl ? false - : useBigram); + appendQueryValue(queryBuf, targetWord, isInUrl ? false : useBigram); if (isInUrl) { queryBuf.append('*'); } @@ -465,19 +435,15 @@ public class QueryHelper implements Serializable { } // sort - if (value.startsWith(sortPrefix) - && value.length() != sortPrefix.length()) { - final String[] sortFieldPairs = value.substring( - sortPrefix.length()).split(","); + if (value.startsWith(sortPrefix) && value.length() != sortPrefix.length()) { + final String[] sortFieldPairs = value.substring(sortPrefix.length()).split(","); for (final String sortFieldPairStr : sortFieldPairs) { - final String[] sortFieldPair = sortFieldPairStr - .split("\\."); + final String[] sortFieldPair = sortFieldPairStr.split("\\."); if (isSupportedSortField(sortFieldPair[0])) { if (sortFieldPair.length == 1) { sortFieldMap.put(sortFieldPair[0], Constants.ASC); } else { - sortFieldMap - .put(sortFieldPair[0], sortFieldPair[1]); + sortFieldMap.put(sortFieldPair[0], sortFieldPair[1]); } } } @@ -502,8 +468,7 @@ public class QueryHelper implements Serializable { highLightQueryList.add(value); if (fieldLogMap != null) { - addFieldLogValue(fieldLogMap, fieldHelper.contentField, - NOT_ + value); + addFieldLogValue(fieldLogMap, fieldHelper.contentField, NOT_ + value); } } else { // content @@ -517,8 +482,7 @@ public class QueryHelper implements Serializable { highLightQueryList.add(value); if (fieldLogMap != null) { - addFieldLogValue(fieldLogMap, fieldHelper.contentField, - value); + addFieldLogValue(fieldLogMap, fieldHelper.contentField, value); } if (keyMatchHelper != null) { @@ -557,8 +521,7 @@ public class QueryHelper implements Serializable { return searchQueryBuf.toString(); } - private void addFieldLogValue(final Map> fieldLogMap, - final String field, final String targetWord) { + private void addFieldLogValue(final Map> fieldLogMap, final String field, final String targetWord) { List logList = fieldLogMap.get(field); if (logList == null) { logList = new ArrayList(); @@ -567,8 +530,7 @@ public class QueryHelper implements Serializable { logList.add(targetWord); } - protected void appendQueryValue(final StringBuilder buf, - final String query, final boolean useBigram) { + protected void appendQueryValue(final StringBuilder buf, final String query, final boolean useBigram) { // check reserved boolean reserved = false; for (final String element : Constants.RESERVED) { @@ -585,8 +547,7 @@ public class QueryHelper implements Serializable { } String value = query; - if (useBigram && value.length() == 1 - && !StringUtils.isAsciiPrintable(value)) { + if (useBigram && value.length() == 1 && !StringUtils.isAsciiPrintable(value)) { // if using bigram, add ? value = value + '?'; } @@ -655,8 +616,7 @@ public class QueryHelper implements Serializable { if (proximityValue == null) { buf.append(QueryUtil.escapeValue(value)); } else { - buf.append('"').append(QueryUtil.escapeValue(value)) - .append('"'); + buf.append('"').append(QueryUtil.escapeValue(value)).append('"'); } } @@ -669,17 +629,13 @@ public class QueryHelper implements Serializable { } } - protected void appendRangeQueryValue(final StringBuilder buf, - final String value, final char prefix, final char suffix) { - final String[] split = value.substring(1, value.length() - 1).split( - _TO_); + protected void appendRangeQueryValue(final StringBuilder buf, final String value, final char prefix, final char suffix) { + final String[] split = value.substring(1, value.length() - 1).split(_TO_); if (split.length == 2 && split[0].length() > 0 && split[1].length() > 0) { final String value1 = split[0].trim(); final String value2 = split[1].trim(); if ("*".equals(value1) && "*".equals(value2)) { - throw new InvalidQueryException( - "errors.invalid_query_str_range", "Invalid range: " - + value); + throw new InvalidQueryException("errors.invalid_query_str_range", "Invalid range: " + value); } buf.append(prefix); buf.append(QueryUtil.escapeRangeValue(value1)); @@ -687,8 +643,7 @@ public class QueryHelper implements Serializable { buf.append(QueryUtil.escapeRangeValue(value2)); buf.append(suffix); } else { - throw new InvalidQueryException("errors.invalid_query_str_range", - "Invalid range: " + value); + throw new InvalidQueryException("errors.invalid_query_str_range", "Invalid range: " + value); } } @@ -701,9 +656,7 @@ public class QueryHelper implements Serializable { return false; } - protected List splitQuery(final String query, - final Map sortFieldMap, - final List highLightQueryList, + protected List splitQuery(final String query, final Map sortFieldMap, final List highLightQueryList, final Map> fieldLogMap) { final List valueList = new ArrayList(); StringBuilder buf = new StringBuilder(); @@ -714,77 +667,72 @@ public class QueryHelper implements Serializable { char oldChar = 0; for (int i = 0; i < query.length(); i++) { final char c = query.charAt(i); - if (oldChar == '\\' - && (c == '"' || c == '(' || c == '{' || c == '[')) { + if (oldChar == '\\' && (c == '"' || c == '(' || c == '{' || c == '[')) { buf.append(c); } else { if (oldChar == '\\') { buf.append('\\'); } switch (c) { - case '(': + case '(': + buf.append(c); + if (!quoted && squareBracket == 0 && curlyBracket == 0) { + parenthesis++; + } + break; + case ')': + buf.append(c); + if (!quoted && squareBracket == 0 && curlyBracket == 0) { + parenthesis--; + } + break; + case '[': + buf.append(c); + if (!quoted && parenthesis == 0 && curlyBracket == 0) { + squareBracket++; + } + break; + case ']': + buf.append(c); + if (!quoted && parenthesis == 0 && curlyBracket == 0) { + squareBracket--; + } + break; + case '{': + buf.append(c); + if (!quoted && parenthesis == 0 && squareBracket == 0) { + curlyBracket++; + } + break; + case '}': + buf.append(c); + if (!quoted && parenthesis == 0 && squareBracket == 0) { + curlyBracket--; + } + break; + case '"': + if (parenthesis == 0 && curlyBracket == 0 && squareBracket == 0) { + quoted ^= true; + } else { buf.append(c); - if (!quoted && squareBracket == 0 && curlyBracket == 0) { - parenthesis++; - } - break; - case ')': + } + break; + case '\\': + break; + case ' ': + case '\u3000': + if (quoted || curlyBracket > 0 || squareBracket > 0 || parenthesis > 0) { buf.append(c); - if (!quoted && squareBracket == 0 && curlyBracket == 0) { - parenthesis--; + } else { + if (buf.length() > 0) { + addQueryPart(buf.toString(), valueList, sortFieldMap, highLightQueryList, fieldLogMap); } - break; - case '[': - buf.append(c); - if (!quoted && parenthesis == 0 && curlyBracket == 0) { - squareBracket++; - } - break; - case ']': - buf.append(c); - if (!quoted && parenthesis == 0 && curlyBracket == 0) { - squareBracket--; - } - break; - case '{': - buf.append(c); - if (!quoted && parenthesis == 0 && squareBracket == 0) { - curlyBracket++; - } - break; - case '}': - buf.append(c); - if (!quoted && parenthesis == 0 && squareBracket == 0) { - curlyBracket--; - } - break; - case '"': - if (parenthesis == 0 && curlyBracket == 0 - && squareBracket == 0) { - quoted ^= true; - } else { - buf.append(c); - } - break; - case '\\': - break; - case ' ': - case '\u3000': - if (quoted || curlyBracket > 0 || squareBracket > 0 - || parenthesis > 0) { - buf.append(c); - } else { - if (buf.length() > 0) { - addQueryPart(buf.toString(), valueList, - sortFieldMap, highLightQueryList, - fieldLogMap); - } - buf = new StringBuilder(); - } - break; - default: - buf.append(c); - break; + buf = new StringBuilder(); + } + break; + default: + buf.append(c); + break; } } oldChar = c; @@ -793,39 +741,28 @@ public class QueryHelper implements Serializable { buf.append('\\'); } if (quoted) { - throw new InvalidQueryException("errors.invalid_query_quoted", - "Invalid quoted: " + query); + throw new InvalidQueryException("errors.invalid_query_quoted", "Invalid quoted: " + query); } else if (curlyBracket > 0) { - throw new InvalidQueryException( - "errors.invalid_query_curly_bracket", - "Invalid curly bracket: " + query); + throw new InvalidQueryException("errors.invalid_query_curly_bracket", "Invalid curly bracket: " + query); } else if (squareBracket > 0) { - throw new InvalidQueryException( - "errors.invalid_query_square_bracket", - "Invalid square bracket: " + query); + throw new InvalidQueryException("errors.invalid_query_square_bracket", "Invalid square bracket: " + query); } else if (parenthesis > 0) { - throw new InvalidQueryException("errors.invalid_query_parenthesis", - "Invalid parenthesis: " + query); + throw new InvalidQueryException("errors.invalid_query_parenthesis", "Invalid parenthesis: " + query); } if (buf.length() > 0) { - addQueryPart(buf.toString(), valueList, sortFieldMap, - highLightQueryList, fieldLogMap); + addQueryPart(buf.toString(), valueList, sortFieldMap, highLightQueryList, fieldLogMap); } return valueList; } - private void addQueryPart(final String str, - final List valueList, - final Map sortFieldMap, - final List highLightQueryList, - final Map> fieldLogMap) { + private void addQueryPart(final String str, final List valueList, final Map sortFieldMap, + final List highLightQueryList, final Map> fieldLogMap) { if (str.startsWith("[") || str.startsWith("{")) { valueList.add(new QueryPart(str.trim())); } else if (str.startsWith("(") && str.endsWith(")") && str.length() > 2) { final String q = str.substring(1, str.length() - 1); if (sortFieldMap != null && highLightQueryList != null) { - final String innerQuery = buildQuery(q, sortFieldMap, - highLightQueryList, fieldLogMap); + final String innerQuery = buildQuery(q, sortFieldMap, highLightQueryList, fieldLogMap); if (StringUtil.isNotBlank(innerQuery)) { valueList.add(new QueryPart("(" + innerQuery + ")", true)); } @@ -866,8 +803,7 @@ public class QueryHelper implements Serializable { } protected String buildFacetQueryInternal(final String query) { - final List queryPartList = splitQuery(query, null, null, - null); + final List queryPartList = splitQuery(query, null, null, null); if (queryPartList.isEmpty()) { return StringUtil.EMPTY; } @@ -893,8 +829,7 @@ public class QueryHelper implements Serializable { // check prefix for (final String field : facetFields) { final String prefix = field + ":"; - if (value.startsWith(prefix) - && value.length() != prefix.length()) { + if (value.startsWith(prefix) && value.length() != prefix.length()) { if (queryBuf.length() > 0) { queryBuf.append(operator); } @@ -917,8 +852,7 @@ public class QueryHelper implements Serializable { } // sort - if (value.startsWith(sortPrefix) - && value.length() != sortPrefix.length()) { + if (value.startsWith(sortPrefix) && value.length() != sortPrefix.length()) { // skip continue; } @@ -980,8 +914,7 @@ public class QueryHelper implements Serializable { return searchQueryBuf.toString(); } - protected void buildContentQueryWithLang(final StringBuilder buf, - final String value, final String queryLanguage) { + protected void buildContentQueryWithLang(final StringBuilder buf, final String value, final String queryLanguage) { buf.append('('); buf.append(fieldHelper.titleField).append(':'); appendQueryValue(buf, value, useBigram); @@ -1002,8 +935,7 @@ public class QueryHelper implements Serializable { } protected String getQueryLanguage() { - final String[] supportedLanguages = systemHelper - .getSupportedLanguages(); + final String[] supportedLanguages = systemHelper.getSupportedLanguages(); if (supportedLanguages.length == 0) { return null; } @@ -1075,9 +1007,7 @@ public class QueryHelper implements Serializable { if (StringUtil.isNotBlank(cq)) { buf.append(' '); char split = 0; - final List partList = splitQuery( - cq.indexOf('"') >= 0 ? cq : "\"" + cq + "\"", null, - null, null); + final List partList = splitQuery(cq.indexOf('"') >= 0 ? cq : "\"" + cq + "\"", null, null, null); for (final QueryPart part : partList) { if (split == 0) { split = ' '; @@ -1098,10 +1028,8 @@ public class QueryHelper implements Serializable { for (final String oq : oqs) { if (StringUtil.isNotBlank(oq)) { buf.append(' '); - final List partList = splitQuery(oq, null, null, - null); - final boolean append = partList.size() > 1 - && optionMap.size() > 1; + final List partList = splitQuery(oq, null, null, null); + final boolean append = partList.size() > 1 && optionMap.size() > 1; if (append) { buf.append('('); } @@ -1135,8 +1063,7 @@ public class QueryHelper implements Serializable { if (StringUtil.isNotBlank(nq)) { buf.append(' '); String split = StringUtil.EMPTY; - final List partList = splitQuery(nq, null, null, - null); + final List partList = splitQuery(nq, null, null, null); for (final QueryPart part : partList) { buf.append(split); if (split.length() == 0) { @@ -1200,8 +1127,7 @@ public class QueryHelper implements Serializable { return responseDocValuesFields; } - public void setResponseDocValuesFields( - final String[] responseDocValuesFields) { + public void setResponseDocValuesFields(final String[] responseDocValuesFields) { this.responseDocValuesFields = responseDocValuesFields; } @@ -1394,9 +1320,7 @@ public class QueryHelper implements Serializable { public void addDefaultSortField(final String fieldName, final String order) { final SortField sortField = new SortField(); sortField.setField(fieldName); - sortField - .setOrder(Constants.ASC.equalsIgnoreCase(order) ? Constants.ASC - : Constants.DESC); + sortField.setOrder(Constants.ASC.equalsIgnoreCase(order) ? Constants.ASC : Constants.DESC); defaultSortFieldList.add(sortField); } @@ -1405,8 +1329,7 @@ public class QueryHelper implements Serializable { } public SortField[] getDefaultSortFields() { - return defaultSortFieldList.toArray(new SortField[defaultSortFieldList - .size()]); + return defaultSortFieldList.toArray(new SortField[defaultSortFieldList.size()]); } public void setHighlightingPrefix(final String highlightingPrefix) { @@ -1485,8 +1408,7 @@ public class QueryHelper implements Serializable { return defaultMoreLikeThisInfo; } - public void setDefaultMoreLikeThisInfo( - final MoreLikeThisInfo defaultMoreLikeThisInfo) { + public void setDefaultMoreLikeThisInfo(final MoreLikeThisInfo defaultMoreLikeThisInfo) { this.defaultMoreLikeThisInfo = defaultMoreLikeThisInfo; } @@ -1513,16 +1435,13 @@ public class QueryHelper implements Serializable { final HttpServletRequest request = RequestUtil.getRequest(); final Map queryParamMap = new HashMap(); - for (final Map.Entry entry : additionalQueryParamMap - .entrySet()) { + for (final Map.Entry entry : additionalQueryParamMap.entrySet()) { final String[] values = entry.getValue(); final String[] newValues = new String[values.length]; for (int i = 0; i < values.length; i++) { final String value = values[i]; - if (value.length() > 1 && value.charAt(0) == '$' - && request != null) { - final String param = request.getParameter(value - .substring(1)); + if (value.length() > 1 && value.charAt(0) == '$' && request != null) { + final String param = request.getParameter(value.substring(1)); if (StringUtil.isNotBlank(param)) { newValues[i] = param; } else { @@ -1554,8 +1473,7 @@ public class QueryHelper implements Serializable { protected String getDefaultOperator() { final HttpServletRequest request = RequestUtil.getRequest(); if (request != null) { - final String defaultOperator = (String) request - .getAttribute(Constants.DEFAULT_OPERATOR); + final String defaultOperator = (String) request.getAttribute(Constants.DEFAULT_OPERATOR); if (AND.equalsIgnoreCase(defaultOperator)) { return _AND_; } else if (OR.equalsIgnoreCase(defaultOperator)) { @@ -1565,10 +1483,8 @@ public class QueryHelper implements Serializable { return DEFAULT_OPERATOR; } - protected void appendFieldBoostValue(final StringBuilder buf, - final String field, final String value) { - if (fieldBoostMap.containsKey(field) && value.indexOf('^') == -1 - && value.indexOf('~') == -1) { + protected void appendFieldBoostValue(final StringBuilder buf, final String field, final String value) { + if (fieldBoostMap.containsKey(field) && value.indexOf('^') == -1 && value.indexOf('~') == -1) { buf.append('^').append(fieldBoostMap.get(field)); } } diff --git a/src/main/java/org/codelibs/fess/helper/RobotLogHelper.java b/src/main/java/org/codelibs/fess/helper/RobotLogHelper.java index 0dc53d742..093181534 100644 --- a/src/main/java/org/codelibs/fess/helper/RobotLogHelper.java +++ b/src/main/java/org/codelibs/fess/helper/RobotLogHelper.java @@ -36,39 +36,37 @@ public class RobotLogHelper extends LogHelperImpl { public void log(final LogType key, final Object... objs) { try { switch (key) { - case CRAWLING_ACCESS_EXCEPTION: { - final S2RobotContext robotContext = (S2RobotContext) objs[0]; - final UrlQueue urlQueue = (UrlQueue) objs[1]; - Throwable e = (Throwable) objs[2]; - if (e instanceof RobotMultipleCrawlAccessException) { - final Throwable[] causes = ((RobotMultipleCrawlAccessException) e) - .getCauses(); - if (causes.length > 0) { - e = causes[causes.length - 1]; - } + case CRAWLING_ACCESS_EXCEPTION: { + final S2RobotContext robotContext = (S2RobotContext) objs[0]; + final UrlQueue urlQueue = (UrlQueue) objs[1]; + Throwable e = (Throwable) objs[2]; + if (e instanceof RobotMultipleCrawlAccessException) { + final Throwable[] causes = ((RobotMultipleCrawlAccessException) e).getCauses(); + if (causes.length > 0) { + e = causes[causes.length - 1]; } - - String errorName; - final Throwable cause = e.getCause(); - if (cause != null) { - errorName = cause.getClass().getCanonicalName(); - } else { - errorName = e.getClass().getCanonicalName(); - } - storeFailureUrl(robotContext, urlQueue, errorName, e); - break; } - case CRAWLING_EXCETPION: { - final S2RobotContext robotContext = (S2RobotContext) objs[0]; - final UrlQueue urlQueue = (UrlQueue) objs[1]; - final Throwable e = (Throwable) objs[2]; - storeFailureUrl(robotContext, urlQueue, e.getClass() - .getCanonicalName(), e); - break; + String errorName; + final Throwable cause = e.getCause(); + if (cause != null) { + errorName = cause.getClass().getCanonicalName(); + } else { + errorName = e.getClass().getCanonicalName(); } - default: - break; + storeFailureUrl(robotContext, urlQueue, errorName, e); + break; + } + case CRAWLING_EXCETPION: { + final S2RobotContext robotContext = (S2RobotContext) objs[0]; + final UrlQueue urlQueue = (UrlQueue) objs[1]; + final Throwable e = (Throwable) objs[2]; + + storeFailureUrl(robotContext, urlQueue, e.getClass().getCanonicalName(), e); + break; + } + default: + break; } } catch (final Exception e) { logger.warn("Failed to store a failure url.", e); @@ -77,15 +75,12 @@ public class RobotLogHelper extends LogHelperImpl { super.log(key, objs); } - private void storeFailureUrl(final S2RobotContext robotContext, - final UrlQueue urlQueue, final String errorName, final Throwable e) { + private void storeFailureUrl(final S2RobotContext robotContext, final UrlQueue urlQueue, final String errorName, final Throwable e) { - final CrawlingConfig crawlingConfig = getCrawlingConfig(robotContext - .getSessionId()); + final CrawlingConfig crawlingConfig = getCrawlingConfig(robotContext.getSessionId()); final String url = urlQueue.getUrl(); - final FailureUrlService failureUrlService = SingletonS2Container - .getComponent(FailureUrlService.class); + final FailureUrlService failureUrlService = SingletonS2Container.getComponent(FailureUrlService.class); failureUrlService.store(crawlingConfig, errorName, url, e); } diff --git a/src/main/java/org/codelibs/fess/helper/SearchLogHelper.java b/src/main/java/org/codelibs/fess/helper/SearchLogHelper.java index 35ea444d8..a7c70f784 100644 --- a/src/main/java/org/codelibs/fess/helper/SearchLogHelper.java +++ b/src/main/java/org/codelibs/fess/helper/SearchLogHelper.java @@ -84,20 +84,17 @@ public abstract class SearchLogHelper { } public int getClickCount(final String url) { - final ClickLogBhv clickLogBhv = SingletonS2Container - .getComponent(ClickLogBhv.class); + final ClickLogBhv clickLogBhv = SingletonS2Container.getComponent(ClickLogBhv.class); return clickLogBhv.selectCount(cb -> { cb.query().setUrl_Equal(url); }); } public long getFavoriteCount(final String url) { - final FavoriteLogBhv favoriteLogBhv = SingletonS2Container - .getComponent(FavoriteLogBhv.class); + final FavoriteLogBhv favoriteLogBhv = SingletonS2Container.getComponent(FavoriteLogBhv.class); final FavoriteUrlCountPmb pmb = new FavoriteUrlCountPmb(); pmb.setUrl(url); - final ListResultBean list = favoriteLogBhv - .outsideSql().selectList(pmb); + final ListResultBean list = favoriteLogBhv.outsideSql().selectList(pmb); long count = 0; if (!list.isEmpty()) { diff --git a/src/main/java/org/codelibs/fess/helper/SuggestHelper.java b/src/main/java/org/codelibs/fess/helper/SuggestHelper.java index 8462ed88d..41220856c 100644 --- a/src/main/java/org/codelibs/fess/helper/SuggestHelper.java +++ b/src/main/java/org/codelibs/fess/helper/SuggestHelper.java @@ -41,8 +41,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class SuggestHelper { - private static final Logger logger = LoggerFactory - .getLogger(SuggestHelper.class); + private static final Logger logger = LoggerFactory.getLogger(SuggestHelper.class); @Resource protected SearchService searchService; @@ -91,10 +90,9 @@ public class SuggestHelper { public void storeAllElevateWords() { suggestService.deleteAllElevateWords(); - final List list = suggestElevateWordBhv - .selectList(cb -> { - cb.query().setDeletedBy_IsNull(); - }); + final List list = suggestElevateWordBhv.selectList(cb -> { + cb.query().setDeletedBy_IsNull(); + }); for (final SuggestElevateWord suggestElevateWord : list) { final String word = suggestElevateWord.getSuggestWord(); final String reading = suggestElevateWord.getReading(); @@ -107,18 +105,15 @@ public class SuggestHelper { suggestService.commit(); } - public void addElevateWord(final String word, final String reading, - final String labels, final String roles, final long boost) { + public void addElevateWord(final String word, final String reading, final String labels, final String roles, final long boost) { addElevateWord(word, reading, labels, roles, boost, true); } - public void addElevateWord(final String word, final String reading, - final String labels, final String roles, final long boost, + public void addElevateWord(final String word, final String reading, final String labels, final String roles, final long boost, final boolean commit) { - final List badWordList = suggestBadWordBhv - .selectList(badWordCB -> { - badWordCB.query().setSuggestWord_Equal(word); - }); + final List badWordList = suggestBadWordBhv.selectList(badWordCB -> { + badWordCB.query().setSuggestWord_Equal(word); + }); if (badWordList.size() > 0) { return; } @@ -138,8 +133,7 @@ public class SuggestHelper { } } - suggestService - .addElevateWord(word, reading, labelList, roleList, boost); + suggestService.addElevateWord(word, reading, labelList, roleList, boost); if (commit) { suggestService.commit(); @@ -165,9 +159,7 @@ public class SuggestHelper { cb.query().setDeletedBy_IsNull(); }); - final File dir = new File(System.getProperty("catalina.home").replace( - "¥", "/") - + "/" + badwordFileDir); + final File dir = new File(System.getProperty("catalina.home").replace("¥", "/") + "/" + badwordFileDir); if (!dir.exists() || !dir.isDirectory()) { logger.warn(dir.getAbsolutePath() + " does not exist."); return; diff --git a/src/main/java/org/codelibs/fess/helper/SystemHelper.java b/src/main/java/org/codelibs/fess/helper/SystemHelper.java index 756dbc4fe..a275426af 100644 --- a/src/main/java/org/codelibs/fess/helper/SystemHelper.java +++ b/src/main/java/org/codelibs/fess/helper/SystemHelper.java @@ -65,18 +65,14 @@ public class SystemHelper implements Serializable { private static final long serialVersionUID = 1L; - private static final Logger logger = LoggerFactory - .getLogger(SystemHelper.class); + private static final Logger logger = LoggerFactory.getLogger(SystemHelper.class); private final Set adminRoleSet = new HashSet<>(); - private String[] crawlerJavaOptions = new String[] { - "-Djava.awt.headless=true", "-server", "-Xmx512m", - "-XX:MaxPermSize=128m", "-XX:-UseGCOverheadLimit", - "-XX:+UseConcMarkSweepGC", "-XX:CMSInitiatingOccupancyFraction=75", - "-XX:+CMSIncrementalMode", "-XX:+CMSIncrementalPacing", - "-XX:CMSIncrementalDutyCycleMin=0", "-XX:+UseParNewGC", - "-XX:+UseStringCache", "-XX:+UseTLAB", "-XX:+DisableExplicitGC" }; + private String[] crawlerJavaOptions = new String[] { "-Djava.awt.headless=true", "-server", "-Xmx512m", "-XX:MaxPermSize=128m", + "-XX:-UseGCOverheadLimit", "-XX:+UseConcMarkSweepGC", "-XX:CMSInitiatingOccupancyFraction=75", "-XX:+CMSIncrementalMode", + "-XX:+CMSIncrementalPacing", "-XX:CMSIncrementalDutyCycleMin=0", "-XX:+UseParNewGC", "-XX:+UseStringCache", "-XX:+UseTLAB", + "-XX:+DisableExplicitGC" }; private String logFilePath = System.getProperty("fess.log.file"); @@ -88,9 +84,7 @@ public class SystemHelper implements Serializable { private boolean useOwnTmpDir = true; - private String baseHelpLink = "http://fess.codelibs.org/{lang}/" - + Constants.MAJOR_VERSION + "." + Constants.MINOR_VERSION - + "/admin/"; + private String baseHelpLink = "http://fess.codelibs.org/{lang}/" + Constants.MAJOR_VERSION + "." + Constants.MINOR_VERSION + "/admin/"; private String[] supportedHelpLangs = new String[] { "ja" }; @@ -100,8 +94,7 @@ public class SystemHelper implements Serializable { private String[] supportedUploadedCssExtentions = new String[] { "css" }; - private String[] supportedUploadedMediaExtentions = new String[] { "jpg", - "jpeg", "gif", "png", "swf" }; + private String[] supportedUploadedMediaExtentions = new String[] { "jpg", "jpeg", "gif", "png", "swf" }; private String jarDir = "/jar/"; @@ -117,10 +110,8 @@ public class SystemHelper implements Serializable { private final AtomicBoolean forceStop = new AtomicBoolean(false); - protected String[] supportedLanguages = new String[] { "ar", "bg", "ca", - "da", "de", "el", "en", "es", "eu", "fa", "fi", "fr", "ga", "gl", - "hi", "hu", "hy", "id", "it", "ja", "lv", "ko", "nl", "no", "pt", - "ro", "ru", "sv", "th", "tr", "zh_CN", "zh_TW", "zh" }; + protected String[] supportedLanguages = new String[] { "ar", "bg", "ca", "da", "de", "el", "en", "es", "eu", "fa", "fi", "fr", "ga", + "gl", "hi", "hu", "hy", "id", "it", "ja", "lv", "ko", "nl", "no", "pt", "ro", "ru", "sv", "th", "tr", "zh_CN", "zh_TW", "zh" }; protected LoadingCache>> langItemsCache; @@ -129,82 +120,67 @@ public class SystemHelper implements Serializable { final File[] files = ResourceUtil.getJarFiles(launcherFileNamePrefix); if (files.length > 0) { final String fileName = files[0].getName(); - final String jarPath = ServletContextUtil.getServletContext() - .getRealPath(jarDir); - final File[] jarFiles = new File(jarPath) - .listFiles(new FilenameFilter() { - @Override - public boolean accept(final File dir, final String name) { - return name.startsWith(launcherFileNamePrefix); - } - }); + final String jarPath = ServletContextUtil.getServletContext().getRealPath(jarDir); + final File[] jarFiles = new File(jarPath).listFiles(new FilenameFilter() { + @Override + public boolean accept(final File dir, final String name) { + return name.startsWith(launcherFileNamePrefix); + } + }); if (jarFiles != null) { for (final File jarFile : jarFiles) { if (jarFile.exists() && !jarFile.delete()) { - logger.warn("Could not delete " - + jarFile.getAbsolutePath()); + logger.warn("Could not delete " + jarFile.getAbsolutePath()); } } } final File launcherJarFile = new File(jarPath, fileName); final File parentLauncherJarFile = launcherJarFile.getParentFile(); - if (!parentLauncherJarFile.exists() - && !parentLauncherJarFile.mkdirs()) { - logger.warn("Could not create " - + parentLauncherJarFile.getAbsolutePath()); + if (!parentLauncherJarFile.exists() && !parentLauncherJarFile.mkdirs()) { + logger.warn("Could not create " + parentLauncherJarFile.getAbsolutePath()); } FileUtil.copy(files[0], launcherJarFile); launcherJarPath = jarDir + fileName; launcherJnlpPath = launcherJarPath.replace(".jar", ".jnlp"); - final File launcherJnlpFile = new File(launcherJarFile - .getAbsolutePath().replace(".jar", ".jnlp")); - final File jnlpTemplateFile = new File( - ResourceUtil.getOrigPath("jnlp/fess-launcher.jnlp")); + final File launcherJnlpFile = new File(launcherJarFile.getAbsolutePath().replace(".jar", ".jnlp")); + final File jnlpTemplateFile = new File(ResourceUtil.getOrigPath("jnlp/fess-launcher.jnlp")); if (!jnlpTemplateFile.isFile()) { - throw new FessSystemException( - jnlpTemplateFile.getAbsolutePath() + " is not found."); + throw new FessSystemException(jnlpTemplateFile.getAbsolutePath() + " is not found."); } try { - String content = new String( - FileUtil.getBytes(jnlpTemplateFile), Constants.UTF_8); + String content = new String(FileUtil.getBytes(jnlpTemplateFile), Constants.UTF_8); content = content.replace("${launcherJarFile}", fileName); - FileUtil.write(launcherJnlpFile.getAbsolutePath(), - content.getBytes(Constants.UTF_8)); + FileUtil.write(launcherJnlpFile.getAbsolutePath(), content.getBytes(Constants.UTF_8)); } catch (final UnsupportedEncodingException e) { - throw new FessSystemException("Could not write " - + jnlpTemplateFile.getAbsolutePath(), e); + throw new FessSystemException("Could not write " + jnlpTemplateFile.getAbsolutePath(), e); } } - langItemsCache = CacheBuilder.newBuilder().maximumSize(20) - .expireAfterAccess(1, TimeUnit.HOURS) - .build(new CacheLoader>>() { - @Override - public List> load(final String key) - throws Exception { - final ULocale uLocale = new ULocale(key); - final Locale displayLocale = uLocale.toLocale(); - final List> langItems = new ArrayList<>( - supportedLanguages.length); - final String msg = MessageResourcesUtil.getMessage( - displayLocale, "labels.allLanguages"); - final Map defaultMap = new HashMap<>(2); - defaultMap.put(Constants.ITEM_LABEL, msg); - defaultMap.put(Constants.ITEM_VALUE, "all"); - langItems.add(defaultMap); + langItemsCache = + CacheBuilder.newBuilder().maximumSize(20).expireAfterAccess(1, TimeUnit.HOURS) + .build(new CacheLoader>>() { + @Override + public List> load(final String key) throws Exception { + final ULocale uLocale = new ULocale(key); + final Locale displayLocale = uLocale.toLocale(); + final List> langItems = new ArrayList<>(supportedLanguages.length); + final String msg = MessageResourcesUtil.getMessage(displayLocale, "labels.allLanguages"); + final Map defaultMap = new HashMap<>(2); + defaultMap.put(Constants.ITEM_LABEL, msg); + defaultMap.put(Constants.ITEM_VALUE, "all"); + langItems.add(defaultMap); - for (final String lang : supportedLanguages) { - final Locale locale = LocaleUtils.toLocale(lang); - final String label = locale - .getDisplayName(displayLocale); - final Map map = new HashMap<>(2); - map.put(Constants.ITEM_LABEL, label); - map.put(Constants.ITEM_VALUE, lang); - langItems.add(map); - } - return langItems; - } - }); + for (final String lang : supportedLanguages) { + final Locale locale = LocaleUtils.toLocale(lang); + final String label = locale.getDisplayName(displayLocale); + final Map map = new HashMap<>(2); + map.put(Constants.ITEM_LABEL, label); + map.put(Constants.ITEM_VALUE, lang); + langItems.add(map); + } + return langItems; + } + }); } public String getUsername() { @@ -236,12 +212,10 @@ public class SystemHelper implements Serializable { final StringBuilder buf = new StringBuilder(); for (int i = 0; i < path.length(); i++) { final char c = path.charAt(i); - if (CharUtil.isUrlChar(c) || c == '^' || c == '{' || c == '}' - || c == '|' || c == '\\') { + if (CharUtil.isUrlChar(c) || c == '^' || c == '{' || c == '}' || c == '|' || c == '\\') { buf.append(c); } else { - buf.append(URLEncoder.encode(String.valueOf(c), - filterPathEncoding)); + buf.append(URLEncoder.encode(String.valueOf(c), filterPathEncoding)); } } return buf.toString(); @@ -281,12 +255,10 @@ public class SystemHelper implements Serializable { } public Set getAuthenticatedRoleSet() { - final RoleTypeService roleTypeService = SingletonS2Container - .getComponent(RoleTypeService.class); + final RoleTypeService roleTypeService = SingletonS2Container.getComponent(RoleTypeService.class); final List roleTypeList = roleTypeService.getRoleTypeList(); - final Set roleList = new HashSet<>(roleTypeList.size() - + adminRoleSet.size()); + final Set roleList = new HashSet<>(roleTypeList.size() + adminRoleSet.size()); for (final RoleType roleType : roleTypeList) { roleList.add(roleType.getValue()); } @@ -381,8 +353,7 @@ public class SystemHelper implements Serializable { return supportedUploadedJSExtentions; } - public void setSupportedUploadedJSExtentions( - final String[] supportedUploadedJSExtentions) { + public void setSupportedUploadedJSExtentions(final String[] supportedUploadedJSExtentions) { this.supportedUploadedJSExtentions = supportedUploadedJSExtentions; } @@ -390,8 +361,7 @@ public class SystemHelper implements Serializable { return supportedUploadedCssExtentions; } - public void setSupportedUploadedCssExtentions( - final String[] supportedUploadedCssExtentions) { + public void setSupportedUploadedCssExtentions(final String[] supportedUploadedCssExtentions) { this.supportedUploadedCssExtentions = supportedUploadedCssExtentions; } @@ -399,8 +369,7 @@ public class SystemHelper implements Serializable { return supportedUploadedMediaExtentions; } - public void setSupportedUploadedMediaExtentions( - final String[] supportedUploadedMediaExtentions) { + public void setSupportedUploadedMediaExtentions(final String[] supportedUploadedMediaExtentions) { this.supportedUploadedMediaExtentions = supportedUploadedMediaExtentions; } @@ -436,8 +405,7 @@ public class SystemHelper implements Serializable { this.maxTextLength = maxTextLength; } - public void updateStatus(final SolrGroup solrGroup, - final QueryType queryType) { + public void updateStatus(final SolrGroup solrGroup, final QueryType queryType) { final StatusPolicy statusPolicy = solrGroup.getStatusPolicy(); for (final String serverName : solrGroup.getServerNames()) { statusPolicy.activate(queryType, serverName); @@ -466,12 +434,10 @@ public class SystemHelper implements Serializable { return null; } - final String localeName = value.trim().toLowerCase(Locale.ENGLISH) - .replace("-", "_"); + final String localeName = value.trim().toLowerCase(Locale.ENGLISH).replace("-", "_"); for (final String supportedLang : supportedLanguages) { - if (localeName - .startsWith(supportedLang.toLowerCase(Locale.ENGLISH))) { + if (localeName.startsWith(supportedLang.toLowerCase(Locale.ENGLISH))) { return supportedLang; } } @@ -483,10 +449,8 @@ public class SystemHelper implements Serializable { final String localeStr = locale.toString(); return langItemsCache.get(localeStr); } catch (final ExecutionException e) { - final List> langItems = new ArrayList<>( - supportedLanguages.length); - final String msg = MessageResourcesUtil.getMessage(locale, - "labels.allLanguages"); + final List> langItems = new ArrayList<>(supportedLanguages.length); + final String msg = MessageResourcesUtil.getMessage(locale, "labels.allLanguages"); final Map defaultMap = new HashMap<>(2); defaultMap.put(Constants.ITEM_LABEL, msg); defaultMap.put(Constants.ITEM_VALUE, "all"); diff --git a/src/main/java/org/codelibs/fess/helper/UserAgentHelper.java b/src/main/java/org/codelibs/fess/helper/UserAgentHelper.java index 0d62bf8bd..60e53eb5c 100644 --- a/src/main/java/org/codelibs/fess/helper/UserAgentHelper.java +++ b/src/main/java/org/codelibs/fess/helper/UserAgentHelper.java @@ -27,13 +27,11 @@ public class UserAgentHelper { public UserAgentType getUserAgentType() { final HttpServletRequest request = RequestUtil.getRequest(); - UserAgentType uaType = (UserAgentType) request - .getAttribute(USER_AGENT_TYPE); + UserAgentType uaType = (UserAgentType) request.getAttribute(USER_AGENT_TYPE); if (uaType == null) { final String userAgent = request.getHeader(USER_AGENT); if (userAgent != null) { - if (userAgent.indexOf("MSIE") >= 0 - || userAgent.indexOf("Trident") >= 0) { + if (userAgent.indexOf("MSIE") >= 0 || userAgent.indexOf("Trident") >= 0) { uaType = UserAgentType.IE; } else if (userAgent.indexOf("Firefox") >= 0) { uaType = UserAgentType.FIREFOX; diff --git a/src/main/java/org/codelibs/fess/helper/ViewHelper.java b/src/main/java/org/codelibs/fess/helper/ViewHelper.java index 64c0f0ad9..2f617689d 100644 --- a/src/main/java/org/codelibs/fess/helper/ViewHelper.java +++ b/src/main/java/org/codelibs/fess/helper/ViewHelper.java @@ -64,8 +64,7 @@ public class ViewHelper implements Serializable { private static final long serialVersionUID = 1L; - private static final Logger logger = LoggerFactory - .getLogger(ViewHelper.class); + private static final Logger logger = LoggerFactory.getLogger(ViewHelper.class); @Resource protected PathMappingHelper pathMappingHelper; @@ -146,8 +145,7 @@ public class ViewHelper implements Serializable { public String getContentDescription(final Map document) { final HttpServletRequest request = RequestUtil.getRequest(); - final String[] queries = request == null ? StringUtil.EMPTY_STRINGS - : (String[]) request.getAttribute(Constants.HIGHLIGHT_QUERIES); + final String[] queries = request == null ? StringUtil.EMPTY_STRINGS : (String[]) request.getAttribute(Constants.HIGHLIGHT_QUERIES); final int size = descriptionLength; for (final String field : highlightingFields) { @@ -156,8 +154,7 @@ public class ViewHelper implements Serializable { if (useSolrHighlight) { return escapeHighlight(text); } else { - return highlight(S2Functions.h(StringUtils.abbreviate( - removeSolrHighlightTag(text), size)), queries); + return highlight(S2Functions.h(StringUtils.abbreviate(removeSolrHighlightTag(text), size)), queries); } } } @@ -166,27 +163,23 @@ public class ViewHelper implements Serializable { } protected String escapeHighlight(final String text) { - return S2Functions.h(text) - .replaceAll(escapedSolrHighlightPre, solrHighlightTagPre) + return S2Functions.h(text).replaceAll(escapedSolrHighlightPre, solrHighlightTagPre) .replaceAll(escapedSolrHighlightPost, solrHighlightTagPost); } protected String removeSolrHighlightTag(final String str) { - return str.replaceAll(solrHighlightTagPre, StringUtil.EMPTY) - .replaceAll(solrHighlightTagPost, StringUtil.EMPTY); + return str.replaceAll(solrHighlightTagPre, StringUtil.EMPTY).replaceAll(solrHighlightTagPost, StringUtil.EMPTY); } protected String highlight(final String content, final String[] queries) { - if (StringUtil.isBlank(content) || queries == null - || queries.length == 0) { + if (StringUtil.isBlank(content) || queries == null || queries.length == 0) { return content; } String newContent = content; for (final String query : queries) { - newContent = Pattern - .compile(Pattern.quote(query), Pattern.CASE_INSENSITIVE) - .matcher(newContent) - .replaceAll(highlightTagPre + query + highlightTagPost); + newContent = + Pattern.compile(Pattern.quote(query), Pattern.CASE_INSENSITIVE).matcher(newContent) + .replaceAll(highlightTagPre + query + highlightTagPost); } return newContent; } @@ -216,8 +209,7 @@ public class ViewHelper implements Serializable { buf.append(c); } else { try { - buf.append(URLEncoder.encode(String.valueOf(c), - urlLinkEncoding)); + buf.append(URLEncoder.encode(String.valueOf(c), urlLinkEncoding)); } catch (final UnsupportedEncodingException e) { // NOP } @@ -231,70 +223,48 @@ public class ViewHelper implements Serializable { final UserAgentType ua = userAgentHelper.getUserAgentType(); switch (ua) { - case IE: - if (isLocalFile) { - url = url.replaceFirst("file:/+", crawlerProperties - .getProperty("file.protocol.winlocal.ie", - "file://")); - } else { - url = url.replaceFirst("file:/+", crawlerProperties - .getProperty("file.protocol.ie", "file://")); - } - break; - case FIREFOX: - if (isLocalFile) { - url = url.replaceFirst("file:/+", crawlerProperties - .getProperty("file.protocol.winlocal.firefox", - "file://")); - } else { - url = url.replaceFirst("file:/+", crawlerProperties - .getProperty("file.protocol.firefox", - "file://///")); - } - break; - case CHROME: - if (isLocalFile) { - url = url.replaceFirst("file:/+", crawlerProperties - .getProperty("file.protocol.winlocal.chrome", - "file://")); - } else { - url = url - .replaceFirst("file:/+", crawlerProperties - .getProperty("file.protocol.chrome", - "file://")); - } - break; - case SAFARI: - if (isLocalFile) { - url = url.replaceFirst("file:/+", crawlerProperties - .getProperty("file.protocol.winlocal.safari", - "file://")); - } else { - url = url.replaceFirst("file:/+", crawlerProperties - .getProperty("file.protocol.safari", - "file:////")); - } - break; - case OPERA: - if (isLocalFile) { - url = url.replaceFirst("file:/+", crawlerProperties - .getProperty("file.protocol.winlocal.opera", - "file://")); - } else { - url = url.replaceFirst("file:/+", crawlerProperties - .getProperty("file.protocol.opera", "file://")); - } - break; - default: - if (isLocalFile) { - url = url.replaceFirst("file:/+", crawlerProperties - .getProperty("file.protocol.winlocal.other", - "file://")); - } else { - url = url.replaceFirst("file:/+", crawlerProperties - .getProperty("file.protocol.other", "file://")); - } - break; + case IE: + if (isLocalFile) { + url = url.replaceFirst("file:/+", crawlerProperties.getProperty("file.protocol.winlocal.ie", "file://")); + } else { + url = url.replaceFirst("file:/+", crawlerProperties.getProperty("file.protocol.ie", "file://")); + } + break; + case FIREFOX: + if (isLocalFile) { + url = url.replaceFirst("file:/+", crawlerProperties.getProperty("file.protocol.winlocal.firefox", "file://")); + } else { + url = url.replaceFirst("file:/+", crawlerProperties.getProperty("file.protocol.firefox", "file://///")); + } + break; + case CHROME: + if (isLocalFile) { + url = url.replaceFirst("file:/+", crawlerProperties.getProperty("file.protocol.winlocal.chrome", "file://")); + } else { + url = url.replaceFirst("file:/+", crawlerProperties.getProperty("file.protocol.chrome", "file://")); + } + break; + case SAFARI: + if (isLocalFile) { + url = url.replaceFirst("file:/+", crawlerProperties.getProperty("file.protocol.winlocal.safari", "file://")); + } else { + url = url.replaceFirst("file:/+", crawlerProperties.getProperty("file.protocol.safari", "file:////")); + } + break; + case OPERA: + if (isLocalFile) { + url = url.replaceFirst("file:/+", crawlerProperties.getProperty("file.protocol.winlocal.opera", "file://")); + } else { + url = url.replaceFirst("file:/+", crawlerProperties.getProperty("file.protocol.opera", "file://")); + } + break; + default: + if (isLocalFile) { + url = url.replaceFirst("file:/+", crawlerProperties.getProperty("file.protocol.winlocal.other", "file://")); + } else { + url = url.replaceFirst("file:/+", crawlerProperties.getProperty("file.protocol.other", "file://")); + } + break; } if (encodeUrlLink) { @@ -302,12 +272,9 @@ public class ViewHelper implements Serializable { } else { url = url.replace("+", "%2B"); try { - return URLDecoder.decode( - appendQueryParameter(document, url), - urlLinkEncoding); + return URLDecoder.decode(appendQueryParameter(document, url), urlLinkEncoding); } catch (final Exception e) { - throw new FessSystemException("Unsupported encoding: " - + urlLinkEncoding, e); + throw new FessSystemException("Unsupported encoding: " + urlLinkEncoding, e); } } } @@ -315,13 +282,10 @@ public class ViewHelper implements Serializable { return appendQueryParameter(document, url); } - protected String appendQueryParameter(final Map document, - final String url) { - if (Constants.TRUE.equals(crawlerProperties - .get(Constants.APPEND_QUERY_PARAMETER_PROPERTY))) { + protected String appendQueryParameter(final Map document, final String url) { + if (Constants.TRUE.equals(crawlerProperties.get(Constants.APPEND_QUERY_PARAMETER_PROPERTY))) { final FieldHelper fieldHelper = ComponentUtil.getFieldHelper(); - final String mimetype = getString(document, - fieldHelper.mimetypeField); + final String mimetype = getString(document, fieldHelper.mimetypeField); if (StringUtil.isNotBlank(mimetype)) { if ("application/pdf".equals(mimetype)) { return appendPDFSearchWord(url); @@ -335,8 +299,7 @@ public class ViewHelper implements Serializable { } protected String appendPDFSearchWord(final String url) { - final String[] queries = (String[]) RequestUtil.getRequest() - .getAttribute(Constants.HIGHLIGHT_QUERIES); + final String[] queries = (String[]) RequestUtil.getRequest().getAttribute(Constants.HIGHLIGHT_QUERIES); if (queries != null) { final StringBuilder buf = new StringBuilder(url.length() + 100); buf.append(url).append("#search=%22"); @@ -390,8 +353,7 @@ public class ViewHelper implements Serializable { return "index.jsp"; } - private String getLocalizedPagePath(final String page, final String lang, - final String country) { + private String getLocalizedPagePath(final String page, final String lang, final String country) { final StringBuilder buf = new StringBuilder(100); buf.append("/WEB-INF/view/").append(page); if (StringUtil.isNotBlank(lang)) { @@ -405,17 +367,14 @@ public class ViewHelper implements Serializable { } private boolean existsPage(final String path) { - final String realPath = ServletContextUtil.getServletContext() - .getRealPath(path); + final String realPath = ServletContextUtil.getServletContext().getRealPath(path); final File file = new File(realPath); return file.isFile(); } - public String createCacheContent(final Map doc, - final String[] queries) { + public String createCacheContent(final Map doc, final String[] queries) { final FieldHelper fieldHelper = ComponentUtil.getFieldHelper(); - final FileTemplateLoader loader = new FileTemplateLoader(new File( - ResourceUtil.getViewTemplatePath(StringUtil.EMPTY))); + final FileTemplateLoader loader = new FileTemplateLoader(new File(ResourceUtil.getViewTemplatePath(StringUtil.EMPTY))); final Handlebars handlebars = new Handlebars(loader); Locale locale = RequestUtil.getRequest().getLocale(); @@ -424,20 +383,16 @@ public class ViewHelper implements Serializable { } String url = (String) doc.get("urlLink"); if (url == null) { - url = MessageResourcesUtil.getMessage(locale, - "labels.search_unknown"); + url = MessageResourcesUtil.getMessage(locale, "labels.search_unknown"); } Object created = doc.get(fieldHelper.createdField); if (created instanceof Date) { - final SimpleDateFormat sdf = new SimpleDateFormat( - CoreLibConstants.DATE_FORMAT_ISO_8601_EXTEND); + final SimpleDateFormat sdf = new SimpleDateFormat(CoreLibConstants.DATE_FORMAT_ISO_8601_EXTEND); created = sdf.format((Date) created); } else { - created = MessageResourcesUtil.getMessage(locale, - "labels.search_unknown"); + created = MessageResourcesUtil.getMessage(locale, "labels.search_unknown"); } - doc.put("cacheMsg", MessageResourcesUtil.getMessage(locale, - "labels.search_cache_msg", url, created)); + doc.put("cacheMsg", MessageResourcesUtil.getMessage(locale, "labels.search_cache_msg", url, created)); doc.put("queries", queries); @@ -465,8 +420,7 @@ public class ViewHelper implements Serializable { return null; } - protected String replaceHighlightQueries(final String cache, - final String[] queries) { + protected String replaceHighlightQueries(final String cache, final String[] queries) { final StringBuffer buf = new StringBuffer(cache.length() + 100); final StringBuffer segBuf = new StringBuffer(1000); final Pattern p = Pattern.compile("<[^>]+>"); @@ -482,9 +436,7 @@ public class ViewHelper implements Serializable { m.appendReplacement(segBuf, StringUtil.EMPTY); String segment = segBuf.toString(); for (int i = 0; i < queries.length; i++) { - segment = Pattern - .compile(regexQueries[i], Pattern.CASE_INSENSITIVE) - .matcher(segment).replaceAll(hlQueries[i]); + segment = Pattern.compile(regexQueries[i], Pattern.CASE_INSENSITIVE).matcher(segment).replaceAll(hlQueries[i]); } buf.append(segment); buf.append(m.group(0)); @@ -493,9 +445,7 @@ public class ViewHelper implements Serializable { m.appendTail(segBuf); String segment = segBuf.toString(); for (int i = 0; i < queries.length; i++) { - segment = Pattern - .compile(regexQueries[i], Pattern.CASE_INSENSITIVE) - .matcher(segment).replaceAll(hlQueries[i]); + segment = Pattern.compile(regexQueries[i], Pattern.CASE_INSENSITIVE).matcher(segment).replaceAll(hlQueries[i]); } buf.append(segment); return buf.toString(); @@ -504,9 +454,7 @@ public class ViewHelper implements Serializable { public Object getSitePath(final Map docMap) { final Object urlLink = docMap.get("urlLink"); if (urlLink != null) { - return StringUtils.abbreviate( - urlLink.toString().replaceFirst("^[a-zA-Z0-9]*:/?/*", ""), - sitePathLength); + return StringUtils.abbreviate(urlLink.toString().replaceFirst("^[a-zA-Z0-9]*:/?/*", ""), sitePathLength); } return null; } diff --git a/src/main/java/org/codelibs/fess/helper/WebFsIndexHelper.java b/src/main/java/org/codelibs/fess/helper/WebFsIndexHelper.java index 08baaffd3..856e27f83 100644 --- a/src/main/java/org/codelibs/fess/helper/WebFsIndexHelper.java +++ b/src/main/java/org/codelibs/fess/helper/WebFsIndexHelper.java @@ -51,8 +51,7 @@ public class WebFsIndexHelper implements Serializable { private static final long serialVersionUID = 1L; - private static final Logger logger = LoggerFactory - .getLogger(WebFsIndexHelper.class); + private static final Logger logger = LoggerFactory.getLogger(WebFsIndexHelper.class); @Resource protected DynamicProperties crawlerProperties; @@ -83,14 +82,11 @@ public class WebFsIndexHelper implements Serializable { public int crawlerPriority = Thread.NORM_PRIORITY; - private final List s2RobotList = Collections - .synchronizedList(new ArrayList()); + private final List s2RobotList = Collections.synchronizedList(new ArrayList()); public void crawl(final String sessionId, final SolrGroup solrGroup) { - final List webConfigList = webCrawlingConfigService - .getAllWebCrawlingConfigList(); - final List fileConfigList = fileCrawlingConfigService - .getAllFileCrawlingConfigList(); + final List webConfigList = webCrawlingConfigService.getAllWebCrawlingConfigList(); + final List fileConfigList = fileCrawlingConfigService.getAllFileCrawlingConfigList(); if (webConfigList.isEmpty() && fileConfigList.isEmpty()) { // nothing @@ -103,21 +99,17 @@ public class WebFsIndexHelper implements Serializable { crawl(sessionId, solrGroup, webConfigList, fileConfigList); } - public void crawl(final String sessionId, final List webConfigIdList, - final List fileConfigIdList, final SolrGroup solrGroup) { - final boolean runAll = webConfigIdList == null - && fileConfigIdList == null; + public void crawl(final String sessionId, final List webConfigIdList, final List fileConfigIdList, final SolrGroup solrGroup) { + final boolean runAll = webConfigIdList == null && fileConfigIdList == null; final List webConfigList; if (runAll || webConfigIdList != null) { - webConfigList = webCrawlingConfigService - .getWebCrawlingConfigListByIds(webConfigIdList); + webConfigList = webCrawlingConfigService.getWebCrawlingConfigListByIds(webConfigIdList); } else { webConfigList = Collections.emptyList(); } final List fileConfigList; if (runAll || fileConfigIdList != null) { - fileConfigList = fileCrawlingConfigService - .getFileCrawlingConfigListByIds(fileConfigIdList); + fileConfigList = fileCrawlingConfigService.getFileCrawlingConfigListByIds(fileConfigIdList); } else { fileConfigList = Collections.emptyList(); } @@ -133,12 +125,10 @@ public class WebFsIndexHelper implements Serializable { crawl(sessionId, solrGroup, webConfigList, fileConfigList); } - protected void crawl(final String sessionId, final SolrGroup solrGroup, - final List webConfigList, + protected void crawl(final String sessionId, final SolrGroup solrGroup, final List webConfigList, final List fileConfigList) { int multiprocessCrawlingCount = 5; - String value = crawlerProperties.getProperty( - Constants.CRAWLING_THREAD_COUNT_PROPERTY, "5"); + String value = crawlerProperties.getProperty(Constants.CRAWLING_THREAD_COUNT_PROPERTY, "5"); try { multiprocessCrawlingCount = Integer.parseInt(value); } catch (final NumberFormatException e) { @@ -146,9 +136,7 @@ public class WebFsIndexHelper implements Serializable { } long commitPerCount = Constants.DEFAULT_COMMIT_PER_COUNT; - value = crawlerProperties.getProperty( - Constants.COMMIT_PER_COUNT_PROPERTY, - Long.toString(Constants.DEFAULT_COMMIT_PER_COUNT)); + value = crawlerProperties.getProperty(Constants.COMMIT_PER_COUNT_PROPERTY, Long.toString(Constants.DEFAULT_COMMIT_PER_COUNT)); try { commitPerCount = Long.parseLong(value); } catch (final NumberFormatException e) { @@ -164,12 +152,10 @@ public class WebFsIndexHelper implements Serializable { final List s2RobotStatusList = new ArrayList(); // Web for (final WebCrawlingConfig webCrawlingConfig : webConfigList) { - final String sid = crawlingConfigHelper.store(sessionId, - webCrawlingConfig); + final String sid = crawlingConfigHelper.store(sessionId, webCrawlingConfig); // create s2robot - final S2Robot s2Robot = SingletonS2Container - .getComponent(S2Robot.class); + final S2Robot s2Robot = SingletonS2Container.getComponent(S2Robot.class); s2Robot.setSessionId(sid); sessionIdList.add(sid); @@ -180,35 +166,32 @@ public class WebFsIndexHelper implements Serializable { } // interval time - final int intervalTime = webCrawlingConfig.getIntervalTime() != null ? webCrawlingConfig - .getIntervalTime() - : Constants.DEFAULT_INTERVAL_TIME_FOR_WEB; - ((FessIntervalController) s2Robot.getIntervalController()) - .setDelayMillisForWaitingNewUrl(intervalTime); + final int intervalTime = + webCrawlingConfig.getIntervalTime() != null ? webCrawlingConfig.getIntervalTime() + : Constants.DEFAULT_INTERVAL_TIME_FOR_WEB; + ((FessIntervalController) s2Robot.getIntervalController()).setDelayMillisForWaitingNewUrl(intervalTime); - final String includedUrlsStr = webCrawlingConfig.getIncludedUrls() != null ? webCrawlingConfig - .getIncludedUrls() : StringUtil.EMPTY; - final String excludedUrlsStr = webCrawlingConfig.getExcludedUrls() != null ? webCrawlingConfig - .getExcludedUrls() : StringUtil.EMPTY; + final String includedUrlsStr = + webCrawlingConfig.getIncludedUrls() != null ? webCrawlingConfig.getIncludedUrls() : StringUtil.EMPTY; + final String excludedUrlsStr = + webCrawlingConfig.getExcludedUrls() != null ? webCrawlingConfig.getExcludedUrls() : StringUtil.EMPTY; // num of threads final S2RobotContext robotContext = s2Robot.getRobotContext(); - final int numOfThread = webCrawlingConfig.getNumOfThread() != null ? webCrawlingConfig - .getNumOfThread() : Constants.DEFAULT_NUM_OF_THREAD_FOR_WEB; + final int numOfThread = + webCrawlingConfig.getNumOfThread() != null ? webCrawlingConfig.getNumOfThread() + : Constants.DEFAULT_NUM_OF_THREAD_FOR_WEB; robotContext.setNumOfThread(numOfThread); // depth - final int depth = webCrawlingConfig.getDepth() != null ? webCrawlingConfig - .getDepth() : -1; + final int depth = webCrawlingConfig.getDepth() != null ? webCrawlingConfig.getDepth() : -1; robotContext.setMaxDepth(depth); // max count - final long maxCount = webCrawlingConfig.getMaxAccessCount() != null ? webCrawlingConfig - .getMaxAccessCount() : maxAccessCount; + final long maxCount = webCrawlingConfig.getMaxAccessCount() != null ? webCrawlingConfig.getMaxAccessCount() : maxAccessCount; robotContext.setMaxAccessCount(maxCount); - webCrawlingConfig.initializeClientFactory(s2Robot - .getClientFactory()); + webCrawlingConfig.initializeClientFactory(s2Robot.getClientFactory()); // set urls final String[] urls = urlsStr.split("[\r\n]"); @@ -253,16 +236,14 @@ public class WebFsIndexHelper implements Serializable { } // failure url - final List excludedUrlList = failureUrlService - .getExcludedUrlList(webCrawlingConfig.getConfigId()); + final List excludedUrlList = failureUrlService.getExcludedUrlList(webCrawlingConfig.getConfigId()); if (excludedUrlList != null) { for (final String u : excludedUrlList) { if (StringUtil.isNotBlank(u)) { final String urlValue = u.trim(); s2Robot.addExcludeFilter(urlValue); if (logger.isInfoEnabled()) { - logger.info("Excluded URL from failures: " - + urlValue); + logger.info("Excluded URL from failures: " + urlValue); } } } @@ -281,12 +262,10 @@ public class WebFsIndexHelper implements Serializable { // File for (final FileCrawlingConfig fileCrawlingConfig : fileConfigList) { - final String sid = crawlingConfigHelper.store(sessionId, - fileCrawlingConfig); + final String sid = crawlingConfigHelper.store(sessionId, fileCrawlingConfig); // create s2robot - final S2Robot s2Robot = SingletonS2Container - .getComponent(S2Robot.class); + final S2Robot s2Robot = SingletonS2Container.getComponent(S2Robot.class); s2Robot.setSessionId(sid); sessionIdList.add(sid); @@ -296,36 +275,32 @@ public class WebFsIndexHelper implements Serializable { break; } - final int intervalTime = fileCrawlingConfig.getIntervalTime() != null ? fileCrawlingConfig - .getIntervalTime() : Constants.DEFAULT_INTERVAL_TIME_FOR_FS; - ((FessIntervalController) s2Robot.getIntervalController()) - .setDelayMillisForWaitingNewUrl(intervalTime); + final int intervalTime = + fileCrawlingConfig.getIntervalTime() != null ? fileCrawlingConfig.getIntervalTime() + : Constants.DEFAULT_INTERVAL_TIME_FOR_FS; + ((FessIntervalController) s2Robot.getIntervalController()).setDelayMillisForWaitingNewUrl(intervalTime); - final String includedPathsStr = fileCrawlingConfig - .getIncludedPaths() != null ? fileCrawlingConfig - .getIncludedPaths() : StringUtil.EMPTY; - final String excludedPathsStr = fileCrawlingConfig - .getExcludedPaths() != null ? fileCrawlingConfig - .getExcludedPaths() : StringUtil.EMPTY; + final String includedPathsStr = + fileCrawlingConfig.getIncludedPaths() != null ? fileCrawlingConfig.getIncludedPaths() : StringUtil.EMPTY; + final String excludedPathsStr = + fileCrawlingConfig.getExcludedPaths() != null ? fileCrawlingConfig.getExcludedPaths() : StringUtil.EMPTY; // num of threads final S2RobotContext robotContext = s2Robot.getRobotContext(); - final int numOfThread = fileCrawlingConfig.getNumOfThread() != null ? fileCrawlingConfig - .getNumOfThread() : Constants.DEFAULT_NUM_OF_THREAD_FOR_FS; + final int numOfThread = + fileCrawlingConfig.getNumOfThread() != null ? fileCrawlingConfig.getNumOfThread() + : Constants.DEFAULT_NUM_OF_THREAD_FOR_FS; robotContext.setNumOfThread(numOfThread); // depth - final int depth = fileCrawlingConfig.getDepth() != null ? fileCrawlingConfig - .getDepth() : -1; + final int depth = fileCrawlingConfig.getDepth() != null ? fileCrawlingConfig.getDepth() : -1; robotContext.setMaxDepth(depth); // max count - final long maxCount = fileCrawlingConfig.getMaxAccessCount() != null ? fileCrawlingConfig - .getMaxAccessCount() : maxAccessCount; + final long maxCount = fileCrawlingConfig.getMaxAccessCount() != null ? fileCrawlingConfig.getMaxAccessCount() : maxAccessCount; robotContext.setMaxAccessCount(maxCount); - fileCrawlingConfig.initializeClientFactory(s2Robot - .getClientFactory()); + fileCrawlingConfig.initializeClientFactory(s2Robot.getClientFactory()); // set paths final String[] paths = pathsStr.split("[\r\n]"); @@ -397,16 +372,14 @@ public class WebFsIndexHelper implements Serializable { } // failure url - final List excludedUrlList = failureUrlService - .getExcludedUrlList(fileCrawlingConfig.getConfigId()); + final List excludedUrlList = failureUrlService.getExcludedUrlList(fileCrawlingConfig.getConfigId()); if (excludedUrlList != null) { for (final String u : excludedUrlList) { if (StringUtil.isNotBlank(u)) { final String urlValue = u.trim(); s2Robot.addExcludeFilter(urlValue); if (logger.isInfoEnabled()) { - logger.info("Excluded Path from failures: " - + urlValue); + logger.info("Excluded Path from failures: " + urlValue); } } } @@ -432,11 +405,8 @@ public class WebFsIndexHelper implements Serializable { indexUpdater.setDaemon(true); indexUpdater.setCommitPerCount(commitPerCount); indexUpdater.setS2RobotList(s2RobotList); - for (final BoostDocumentRule rule : boostDocumentRuleService - .getAvailableBoostDocumentRuleList()) { - indexUpdater - .addBoostDocumentRule(new org.codelibs.fess.solr.BoostDocumentRule( - rule)); + for (final BoostDocumentRule rule : boostDocumentRuleService.getAvailableBoostDocumentRuleList()) { + indexUpdater.addBoostDocumentRule(new org.codelibs.fess.solr.BoostDocumentRule(rule)); } indexUpdater.start(); @@ -467,12 +437,10 @@ public class WebFsIndexHelper implements Serializable { // check status for (int i = 0; i < startedCrawlerNum; i++) { - if (!s2RobotList.get(i).getRobotContext().isRunning() - && s2RobotStatusList.get(i).equals(Constants.RUNNING)) { + if (!s2RobotList.get(i).getRobotContext().isRunning() && s2RobotStatusList.get(i).equals(Constants.RUNNING)) { s2RobotList.get(i).awaitTermination(); s2RobotStatusList.set(i, Constants.DONE); - final String sid = s2RobotList.get(i).getRobotContext() - .getSessionId(); + final String sid = s2RobotList.get(i).getRobotContext().getSessionId(); indexUpdater.addFinishedSessionId(sid); activeCrawlerNum--; } @@ -489,11 +457,9 @@ public class WebFsIndexHelper implements Serializable { finishedAll = true; for (int i = 0; i < s2RobotList.size(); i++) { s2RobotList.get(i).awaitTermination(crawlingExecutionInterval); - if (!s2RobotList.get(i).getRobotContext().isRunning() - && !s2RobotStatusList.get(i).equals(Constants.DONE)) { + if (!s2RobotList.get(i).getRobotContext().isRunning() && !s2RobotStatusList.get(i).equals(Constants.DONE)) { s2RobotStatusList.set(i, Constants.DONE); - final String sid = s2RobotList.get(i).getRobotContext() - .getSessionId(); + final String sid = s2RobotList.get(i).getRobotContext().getSessionId(); indexUpdater.addFinishedSessionId(sid); } if (!s2RobotStatusList.get(i).equals(Constants.DONE)) { @@ -505,12 +471,10 @@ public class WebFsIndexHelper implements Serializable { s2RobotStatusList.clear(); // put cralwing info - final CrawlingSessionHelper crawlingSessionHelper = ComponentUtil - .getCrawlingSessionHelper(); + final CrawlingSessionHelper crawlingSessionHelper = ComponentUtil.getCrawlingSessionHelper(); final long execTime = System.currentTimeMillis() - startTime; - crawlingSessionHelper.putToInfoMap(Constants.WEB_FS_CRAWLING_EXEC_TIME, - Long.toString(execTime)); + crawlingSessionHelper.putToInfoMap(Constants.WEB_FS_CRAWLING_EXEC_TIME, Long.toString(execTime)); if (logger.isInfoEnabled()) { logger.info("[EXEC TIME] crawling time: " + execTime + "ms"); } @@ -522,10 +486,8 @@ public class WebFsIndexHelper implements Serializable { logger.warn("Interrupted index update.", e); } - crawlingSessionHelper.putToInfoMap(Constants.WEB_FS_INDEX_EXEC_TIME, - Long.toString(indexUpdater.getExecuteTime())); - crawlingSessionHelper.putToInfoMap(Constants.WEB_FS_INDEX_SIZE, - Long.toString(indexUpdater.getDocumentSize())); + crawlingSessionHelper.putToInfoMap(Constants.WEB_FS_INDEX_EXEC_TIME, Long.toString(indexUpdater.getExecuteTime())); + crawlingSessionHelper.putToInfoMap(Constants.WEB_FS_INDEX_SIZE, Long.toString(indexUpdater.getDocumentSize())); for (final String sid : sessionIdList) { // remove config @@ -533,18 +495,15 @@ public class WebFsIndexHelper implements Serializable { } // clear url filter - final UrlFilterService urlFilterService = SingletonS2Container - .getComponent(UrlFilterService.class); + final UrlFilterService urlFilterService = SingletonS2Container.getComponent(UrlFilterService.class); urlFilterService.deleteAll(); // clear queue - final UrlQueueService urlQueueService = SingletonS2Container - .getComponent(UrlQueueService.class); + final UrlQueueService urlQueueService = SingletonS2Container.getComponent(UrlQueueService.class); urlQueueService.deleteAll(); // clear - final DataService dataService = SingletonS2Container - .getComponent(DataService.class); + final DataService dataService = SingletonS2Container.getComponent(DataService.class); dataService.deleteAll(); } diff --git a/src/main/java/org/codelibs/fess/helper/impl/CookieUserInfoHelperImpl.java b/src/main/java/org/codelibs/fess/helper/impl/CookieUserInfoHelperImpl.java index 44a3278aa..d4fc3fda2 100644 --- a/src/main/java/org/codelibs/fess/helper/impl/CookieUserInfoHelperImpl.java +++ b/src/main/java/org/codelibs/fess/helper/impl/CookieUserInfoHelperImpl.java @@ -117,8 +117,7 @@ public class CookieUserInfoHelperImpl implements UserInfoHelper { } @Override - public String generateQueryId(final String query, - final List> documentItems) { + public String generateQueryId(final String query, final List> documentItems) { final HttpSession session = RequestUtil.getRequest().getSession(false); if (session != null) { final FieldHelper fieldHelper = ComponentUtil.getFieldHelper(); @@ -135,8 +134,7 @@ public class CookieUserInfoHelperImpl implements UserInfoHelper { if (!docIdList.isEmpty()) { final Map resultDocIdsCache = getResultDocIdsCache(session); - resultDocIdsCache.put(queryId, - docIdList.toArray(new String[docIdList.size()])); + resultDocIdsCache.put(queryId, docIdList.toArray(new String[docIdList.size()])); return queryId; } } @@ -158,13 +156,10 @@ public class CookieUserInfoHelperImpl implements UserInfoHelper { private Map getResultDocIdsCache(final HttpSession session) { @SuppressWarnings("unchecked") - Map resultDocIdsCache = (Map) session - .getAttribute(Constants.RESULT_DOC_ID_CACHE); + Map resultDocIdsCache = (Map) session.getAttribute(Constants.RESULT_DOC_ID_CACHE); if (resultDocIdsCache == null) { - resultDocIdsCache = new LruHashMap( - resultDocIdsCacheSize); - session.setAttribute(Constants.RESULT_DOC_ID_CACHE, - resultDocIdsCache); + resultDocIdsCache = new LruHashMap(resultDocIdsCacheSize); + session.setAttribute(Constants.RESULT_DOC_ID_CACHE, resultDocIdsCache); } return resultDocIdsCache; } diff --git a/src/main/java/org/codelibs/fess/helper/impl/H2DatabaseHelperImpl.java b/src/main/java/org/codelibs/fess/helper/impl/H2DatabaseHelperImpl.java index 80824471e..f39690342 100644 --- a/src/main/java/org/codelibs/fess/helper/impl/H2DatabaseHelperImpl.java +++ b/src/main/java/org/codelibs/fess/helper/impl/H2DatabaseHelperImpl.java @@ -25,8 +25,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class H2DatabaseHelperImpl implements DatabaseHelper { - private static final Logger logger = LoggerFactory - .getLogger(H2DatabaseHelperImpl.class); + private static final Logger logger = LoggerFactory.getLogger(H2DatabaseHelperImpl.class); public String databaseName = "robot"; @@ -51,8 +50,7 @@ public class H2DatabaseHelperImpl implements DatabaseHelper { RunScript.execute(url, user, password, sqlFilePath, null, false); } catch (final Exception e) { if (printLogOnError) { - logger.error("Failed to optimize H2 Database: " + databasePath - + "/" + databaseName, e); + logger.error("Failed to optimize H2 Database: " + databasePath + "/" + databaseName, e); } } } diff --git a/src/main/java/org/codelibs/fess/helper/impl/RoleQueryHelperImpl.java b/src/main/java/org/codelibs/fess/helper/impl/RoleQueryHelperImpl.java index b3efc973e..7854d6b89 100644 --- a/src/main/java/org/codelibs/fess/helper/impl/RoleQueryHelperImpl.java +++ b/src/main/java/org/codelibs/fess/helper/impl/RoleQueryHelperImpl.java @@ -50,8 +50,7 @@ public class RoleQueryHelperImpl implements RoleQueryHelper, Serializable { private static final long serialVersionUID = 1L; - private static final Logger logger = LoggerFactory - .getLogger(RoleQueryHelperImpl.class); + private static final Logger logger = LoggerFactory.getLogger(RoleQueryHelperImpl.class); public CachedCipher cipher; @@ -109,8 +108,7 @@ public class RoleQueryHelperImpl implements RoleQueryHelper, Serializable { if (request != null) { final HttpSession session = request.getSession(false); if (session != null) { - final LoginInfo loginInfo = (LoginInfo) session - .getAttribute(SSCConstants.USER_INFO); + final LoginInfo loginInfo = (LoginInfo) session.getAttribute(SSCConstants.USER_INFO); if (loginInfo != null) { roleList.addAll(loginInfo.getRoleSet()); } @@ -175,8 +173,7 @@ public class RoleQueryHelperImpl implements RoleQueryHelper, Serializable { return Collections.emptySet(); } - protected Set buildByCookieNameMapping( - final HttpServletRequest request) { + protected Set buildByCookieNameMapping(final HttpServletRequest request) { final Set roleNameSet = new HashSet<>(); final Cookie[] cookies = request.getCookies(); @@ -189,16 +186,14 @@ public class RoleQueryHelperImpl implements RoleQueryHelper, Serializable { return roleNameSet; } - protected void addRoleFromCookieMapping(final Set roleNameList, - final Cookie cookie) { + protected void addRoleFromCookieMapping(final Set roleNameList, final Cookie cookie) { final String roleName = cookieNameMap.get(cookie.getName()); if (StringUtil.isNotBlank(roleName)) { roleNameList.add(roleName); } } - protected Set decodedRoleList(final String value, - final boolean encrypted) { + protected Set decodedRoleList(final String value, final boolean encrypted) { String rolesStr = value; if (encrypted && cipher != null) { rolesStr = cipher.decryptoText(rolesStr); @@ -226,8 +221,7 @@ public class RoleQueryHelperImpl implements RoleQueryHelper, Serializable { return roleSet; } - public void addCookieNameMapping(final String cookieName, - final String roleName) { + public void addCookieNameMapping(final String cookieName, final String roleName) { if (cookieNameMap == null) { cookieNameMap = new HashMap(); } diff --git a/src/main/java/org/codelibs/fess/helper/impl/SearchLogHelperImpl.java b/src/main/java/org/codelibs/fess/helper/impl/SearchLogHelperImpl.java index af5967ac4..d155c743a 100644 --- a/src/main/java/org/codelibs/fess/helper/impl/SearchLogHelperImpl.java +++ b/src/main/java/org/codelibs/fess/helper/impl/SearchLogHelperImpl.java @@ -52,12 +52,10 @@ public class SearchLogHelperImpl extends SearchLogHelper { final long current = System.currentTimeMillis(); final Long time = userInfoCache.get(userCode); if (time == null || current - time.longValue() > userCheckInterval) { - final UserInfoService userInfoService = SingletonS2Container - .getComponent(UserInfoService.class); + final UserInfoService userInfoService = SingletonS2Container.getComponent(UserInfoService.class); UserInfo userInfo = userInfoService.getUserInfo(userCode); if (userInfo == null) { - final LocalDateTime now = ComponentUtil.getSystemHelper() - .getCurrentTime(); + final LocalDateTime now = ComponentUtil.getSystemHelper().getCurrentTime(); userInfo = new UserInfo(); userInfo.setCode(userCode); userInfo.setCreatedTime(now); @@ -71,8 +69,7 @@ public class SearchLogHelperImpl extends SearchLogHelper { @Override protected void processSearchLogQueue(final Queue queue) { final List searchLogList = new ArrayList(); - final String value = crawlerProperties.getProperty( - Constants.PURGE_BY_BOTS_PROPERTY, StringUtil.EMPTY); + final String value = crawlerProperties.getProperty(Constants.PURGE_BY_BOTS_PROPERTY, StringUtil.EMPTY); String[] botNames; if (StringUtil.isBlank(value)) { botNames = StringUtil.EMPTY_STRINGS; @@ -80,24 +77,20 @@ public class SearchLogHelperImpl extends SearchLogHelper { botNames = value.split(","); } - final boolean suggestAvailable = Constants.TRUE - .equals(crawlerProperties.getProperty( - Constants.SUGGEST_SEARCH_LOG_PROPERTY, Constants.TRUE)); - final String dayForCleanupStr = crawlerProperties.getProperty( - Constants.PURGE_SUGGEST_SEARCH_LOG_DAY_PROPERTY, "30"); + final boolean suggestAvailable = + Constants.TRUE.equals(crawlerProperties.getProperty(Constants.SUGGEST_SEARCH_LOG_PROPERTY, Constants.TRUE)); + final String dayForCleanupStr = crawlerProperties.getProperty(Constants.PURGE_SUGGEST_SEARCH_LOG_DAY_PROPERTY, "30"); int dayForCleanup = -1; try { dayForCleanup = Integer.parseInt(dayForCleanupStr); - } catch (final NumberFormatException e) { - } + } catch (final NumberFormatException e) {} boolean addedSuggest = false; final Map userInfoMap = new HashMap(); for (final SearchLog searchLog : queue) { boolean add = true; for (final String botName : botNames) { - if (searchLog.getUserAgent() != null - && searchLog.getUserAgent().indexOf(botName) >= 0) { + if (searchLog.getUserAgent() != null && searchLog.getUserAgent().indexOf(botName) >= 0) { add = false; break; } @@ -115,12 +108,10 @@ public class SearchLogHelperImpl extends SearchLogHelper { searchLogList.add(searchLog); if (suggestAvailable && searchLog.getHitCount() > 0) { - final List searchFieldLogList = searchLog - .getSearchFieldLogList(); + final List searchFieldLogList = searchLog.getSearchFieldLogList(); for (final SearchFieldLog searchFieldLog : searchFieldLogList) { if ("solrQuery".equals(searchFieldLog.getName())) { - suggestService.addSolrParams( - searchFieldLog.getValue(), dayForCleanup); + suggestService.addSolrParams(searchFieldLog.getValue(), dayForCleanup); addedSuggest = true; } } @@ -132,19 +123,16 @@ public class SearchLogHelperImpl extends SearchLogHelper { } if (!userInfoMap.isEmpty()) { - final List insertList = new ArrayList( - userInfoMap.values()); + final List insertList = new ArrayList(userInfoMap.values()); final List updateList = new ArrayList(); - final UserInfoBhv userInfoBhv = SingletonS2Container - .getComponent(UserInfoBhv.class); + final UserInfoBhv userInfoBhv = SingletonS2Container.getComponent(UserInfoBhv.class); final List list = userInfoBhv.selectList(cb -> { cb.query().setCode_InScope(userInfoMap.keySet()); }); for (final UserInfo userInfo : list) { final String code = userInfo.getCode(); final UserInfo entity = userInfoMap.get(code); - FessBeans.copy(userInfo, entity).includes("id", "createdTime") - .execute(); + FessBeans.copy(userInfo, entity).includes("id", "createdTime").execute(); updateList.add(entity); insertList.remove(entity); } @@ -160,8 +148,7 @@ public class SearchLogHelperImpl extends SearchLogHelper { } if (!searchLogList.isEmpty()) { - final SearchLogService searchLogService = SingletonS2Container - .getComponent(SearchLogService.class); + final SearchLogService searchLogService = SingletonS2Container.getComponent(SearchLogService.class); searchLogService.store(searchLogList); } } @@ -172,15 +159,11 @@ public class SearchLogHelperImpl extends SearchLogHelper { final List clickLogList = new ArrayList(); for (final ClickLog clickLog : queue) { try { - final SearchLogBhv searchLogBhv = SingletonS2Container - .getComponent(SearchLogBhv.class); - final SearchLog entity = searchLogBhv.selectEntity( - cb -> { - cb.query().setRequestedTime_Equal( - clickLog.getQueryRequestedTime()); - cb.query().setUserSessionId_Equal( - clickLog.getUserSessionId()); - }).orElse(null);//TODO + final SearchLogBhv searchLogBhv = SingletonS2Container.getComponent(SearchLogBhv.class); + final SearchLog entity = searchLogBhv.selectEntity(cb -> { + cb.query().setRequestedTime_Equal(clickLog.getQueryRequestedTime()); + cb.query().setUserSessionId_Equal(clickLog.getUserSessionId()); + }).orElse(null);//TODO if (entity != null) { clickLog.setSearchId(entity.getId()); clickLogList.add(clickLog); @@ -203,8 +186,7 @@ public class SearchLogHelperImpl extends SearchLogHelper { } if (!clickLogList.isEmpty()) { try { - final ClickLogBhv clickLogBhv = SingletonS2Container - .getComponent(ClickLogBhv.class); + final ClickLogBhv clickLogBhv = SingletonS2Container.getComponent(ClickLogBhv.class); clickLogBhv.batchInsert(clickLogList); } catch (final Exception e) { logger.warn("Failed to insert: " + clickLogList, e); @@ -215,11 +197,9 @@ public class SearchLogHelperImpl extends SearchLogHelper { final FieldHelper fieldHelper = ComponentUtil.getFieldHelper(); for (final Map.Entry entry : clickCountMap.entrySet()) { try { - documentHelper.update(entry.getKey(), - fieldHelper.clickCountField, entry.getValue() + 1); + documentHelper.update(entry.getKey(), fieldHelper.clickCountField, entry.getValue() + 1); } catch (final Exception e) { - logger.warn("Failed to update a clickCount(" + entry.getValue() - + ") for " + entry.getKey(), e); + logger.warn("Failed to update a clickCount(" + entry.getValue() + ") for " + entry.getKey(), e); } } } diff --git a/src/main/java/org/codelibs/fess/helper/impl/TomcatManagementHelperImpl.java b/src/main/java/org/codelibs/fess/helper/impl/TomcatManagementHelperImpl.java index f16501ece..a0e9ce830 100644 --- a/src/main/java/org/codelibs/fess/helper/impl/TomcatManagementHelperImpl.java +++ b/src/main/java/org/codelibs/fess/helper/impl/TomcatManagementHelperImpl.java @@ -39,15 +39,13 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class TomcatManagementHelperImpl implements WebManagementHelper { - private static final Logger logger = LoggerFactory - .getLogger(TomcatManagementHelperImpl.class); + private static final Logger logger = LoggerFactory.getLogger(TomcatManagementHelperImpl.class); protected Map solrInstanceMap = new LinkedHashMap(); public void addSolrInstance(final SolrInstance solrInstance) { if (!solrInstance.isValid()) { - throw new FessTomcatManagerException("SolrInstance is invalid: " - + solrInstance); + throw new FessTomcatManagerException("SolrInstance is invalid: " + solrInstance); } solrInstanceMap.put(solrInstance.name, solrInstance); } @@ -80,8 +78,7 @@ public class TomcatManagementHelperImpl implements WebManagementHelper { try { return solrInstance.status(); } catch (final Exception e) { - logger.error("System error on a solr instance (" + name + ").", - e); + logger.error("System error on a solr instance (" + name + ").", e); return "error"; } } @@ -97,8 +94,7 @@ public class TomcatManagementHelperImpl implements WebManagementHelper { if (solrInstance != null) { solrInstance.start(); } else { - throw new FessTomcatManagerException("Solr instance (" + name - + ") is not found."); + throw new FessTomcatManagerException("Solr instance (" + name + ") is not found."); } } @@ -111,8 +107,7 @@ public class TomcatManagementHelperImpl implements WebManagementHelper { if (solrInstance != null) { solrInstance.stop(); } else { - throw new FessTomcatManagerException("Solr instance (" + name - + ") is not found."); + throw new FessTomcatManagerException("Solr instance (" + name + ") is not found."); } } @@ -125,8 +120,7 @@ public class TomcatManagementHelperImpl implements WebManagementHelper { if (solrInstance != null) { solrInstance.reload(); } else { - throw new FessTomcatManagerException("Solr instance (" + name - + ") is not found."); + throw new FessTomcatManagerException("Solr instance (" + name + ") is not found."); } } @@ -153,9 +147,7 @@ public class TomcatManagementHelperImpl implements WebManagementHelper { buf.append(contextPath); final String responseBody = getResponseBody(buf.toString()); if (!responseBody.trim().startsWith("OK")) { - throw new FessTomcatManagerException( - "Failed to start a solr instance. The reponse is \n" - + responseBody); + throw new FessTomcatManagerException("Failed to start a solr instance. The reponse is \n" + responseBody); } } @@ -169,9 +161,7 @@ public class TomcatManagementHelperImpl implements WebManagementHelper { buf.append(contextPath); final String responseBody = getResponseBody(buf.toString()); if (!responseBody.trim().startsWith("OK")) { - throw new FessTomcatManagerException( - "Failed to start a solr instance. The reponse is \n" - + responseBody); + throw new FessTomcatManagerException("Failed to start a solr instance. The reponse is \n" + responseBody); } } @@ -185,9 +175,7 @@ public class TomcatManagementHelperImpl implements WebManagementHelper { buf.append(contextPath); final String responseBody = getResponseBody(buf.toString()); if (!responseBody.trim().startsWith("OK")) { - throw new FessTomcatManagerException( - "Failed to start a solr instance. The reponse is \n" - + responseBody); + throw new FessTomcatManagerException("Failed to start a solr instance. The reponse is \n" + responseBody); } } @@ -200,9 +188,7 @@ public class TomcatManagementHelperImpl implements WebManagementHelper { buf.append("list"); final String responseBody = getResponseBody(buf.toString()); if (!responseBody.trim().startsWith("OK")) { - throw new FessTomcatManagerException( - "Failed to start a solr instance. The reponse is \n" - + responseBody); + throw new FessTomcatManagerException("Failed to start a solr instance. The reponse is \n" + responseBody); } final String[] lines = responseBody.split("\n"); @@ -222,14 +208,12 @@ public class TomcatManagementHelperImpl implements WebManagementHelper { final DefaultHttpClient client = new DefaultHttpClient(); if (username != null && password != null) { - final Credentials defaultcreds = new UsernamePasswordCredentials( - username, password); + final Credentials defaultcreds = new UsernamePasswordCredentials(username, password); if (schema == null) { schema = Constants.BASIC; } - client.getCredentialsProvider().setCredentials( - new AuthScope(AuthScope.ANY_HOST, -1, - AuthScope.ANY_REALM, schema), defaultcreds); + client.getCredentialsProvider().setCredentials(new AuthScope(AuthScope.ANY_HOST, -1, AuthScope.ANY_REALM, schema), + defaultcreds); } // Create a method instance. @@ -241,32 +225,27 @@ public class TomcatManagementHelperImpl implements WebManagementHelper { final int statusCode = response.getStatusLine().getStatusCode(); if (statusCode != HttpStatus.SC_OK) { - throw new FessTomcatManagerException("Could not access " - + url + ". HTTP Status is " + statusCode + "."); + throw new FessTomcatManagerException("Could not access " + url + ". HTTP Status is " + statusCode + "."); } final HttpEntity entity = response.getEntity(); if (entity != null) { // Read the response body. - final String value = new String( - InputStreamUtil.getBytes(entity.getContent()), - Constants.UTF_8); + final String value = new String(InputStreamUtil.getBytes(entity.getContent()), Constants.UTF_8); // Release the connection. entity.consumeContent(); return value; } throw new FessTomcatManagerException("No response from " + url); } catch (final IOException e) { - throw new FessTomcatManagerException("Fatal transport error: " - + url, e); + throw new FessTomcatManagerException("Fatal transport error: " + url, e); } finally { client.getConnectionManager().shutdown(); } } public boolean isValid() { - if (StringUtil.isBlank(name) || StringUtil.isBlank(managerUrl) - || StringUtil.isBlank(contextPath)) { + if (StringUtil.isBlank(name) || StringUtil.isBlank(managerUrl) || StringUtil.isBlank(contextPath)) { return false; } return true; @@ -289,8 +268,7 @@ public class TomcatManagementHelperImpl implements WebManagementHelper { private static final long serialVersionUID = 1L; - public FessTomcatManagerException(final String message, - final Throwable cause) { + public FessTomcatManagerException(final String message, final Throwable cause) { super(message, cause); } diff --git a/src/main/java/org/codelibs/fess/interceptor/FessActionMessagesThrowsInterceptor.java b/src/main/java/org/codelibs/fess/interceptor/FessActionMessagesThrowsInterceptor.java index 9cfaf882f..02951eb32 100644 --- a/src/main/java/org/codelibs/fess/interceptor/FessActionMessagesThrowsInterceptor.java +++ b/src/main/java/org/codelibs/fess/interceptor/FessActionMessagesThrowsInterceptor.java @@ -22,14 +22,12 @@ import org.seasar.struts.interceptor.ActionMessagesThrowsInterceptor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class FessActionMessagesThrowsInterceptor extends - ActionMessagesThrowsInterceptor { +public class FessActionMessagesThrowsInterceptor extends ActionMessagesThrowsInterceptor { private static final long serialVersionUID = 1L; private static final String SYSTEM_ERROR_JSP = "/error/system.jsp"; - private static final Logger logger = LoggerFactory - .getLogger(FessActionMessagesThrowsInterceptor.class); + private static final Logger logger = LoggerFactory.getLogger(FessActionMessagesThrowsInterceptor.class); @Override public Object invoke(final MethodInvocation invocation) throws Throwable { diff --git a/src/main/java/org/codelibs/fess/interval/FessIntervalController.java b/src/main/java/org/codelibs/fess/interval/FessIntervalController.java index 889bfbb96..388e63055 100644 --- a/src/main/java/org/codelibs/fess/interval/FessIntervalController.java +++ b/src/main/java/org/codelibs/fess/interval/FessIntervalController.java @@ -26,8 +26,7 @@ public class FessIntervalController extends DefaultIntervalController { return delayMillisAfterProcessing; } - public void setDelayMillisAfterProcessing( - final long delayMillisAfterProcessing) { + public void setDelayMillisAfterProcessing(final long delayMillisAfterProcessing) { this.delayMillisAfterProcessing = delayMillisAfterProcessing; } @@ -35,8 +34,7 @@ public class FessIntervalController extends DefaultIntervalController { return delayMillisAtNoUrlInQueue; } - public void setDelayMillisAtNoUrlInQueue( - final long delayMillisAtNoUrlInQueue) { + public void setDelayMillisAtNoUrlInQueue(final long delayMillisAtNoUrlInQueue) { this.delayMillisAtNoUrlInQueue = delayMillisAtNoUrlInQueue; } @@ -44,8 +42,7 @@ public class FessIntervalController extends DefaultIntervalController { return delayMillisBeforeProcessing; } - public void setDelayMillisBeforeProcessing( - final long delayMillisBeforeProcessing) { + public void setDelayMillisBeforeProcessing(final long delayMillisBeforeProcessing) { this.delayMillisBeforeProcessing = delayMillisBeforeProcessing; } @@ -53,20 +50,17 @@ public class FessIntervalController extends DefaultIntervalController { return delayMillisForWaitingNewUrl; } - public void setDelayMillisForWaitingNewUrl( - final long delayMillisForWaitingNewUrl) { + public void setDelayMillisForWaitingNewUrl(final long delayMillisForWaitingNewUrl) { this.delayMillisForWaitingNewUrl = delayMillisForWaitingNewUrl; } @Override protected void delayForWaitingNewUrl() { try { - final IntervalControlHelper intervalControlHelper = ComponentUtil - .getIntervalControlHelper(); + final IntervalControlHelper intervalControlHelper = ComponentUtil.getIntervalControlHelper(); intervalControlHelper.checkCrawlerStatus(); intervalControlHelper.delayByRules(); - } catch (final Exception e) { - } + } catch (final Exception e) {} super.delayForWaitingNewUrl(); } diff --git a/src/main/java/org/codelibs/fess/job/AggregateLogJob.java b/src/main/java/org/codelibs/fess/job/AggregateLogJob.java index 9ed227c1b..783031abd 100644 --- a/src/main/java/org/codelibs/fess/job/AggregateLogJob.java +++ b/src/main/java/org/codelibs/fess/job/AggregateLogJob.java @@ -23,12 +23,10 @@ import org.slf4j.LoggerFactory; public class AggregateLogJob { - private static final Logger logger = LoggerFactory - .getLogger(AggregateLogJob.class); + private static final Logger logger = LoggerFactory.getLogger(AggregateLogJob.class); public String execute() { - final SearchLogHelper searchLogHelper = ComponentUtil - .getSearchLogHelper(); + final SearchLogHelper searchLogHelper = ComponentUtil.getSearchLogHelper(); final StringBuilder resultBuf = new StringBuilder(); diff --git a/src/main/java/org/codelibs/fess/job/CrawlJob.java b/src/main/java/org/codelibs/fess/job/CrawlJob.java index 65ca62c79..77e7d8076 100644 --- a/src/main/java/org/codelibs/fess/job/CrawlJob.java +++ b/src/main/java/org/codelibs/fess/job/CrawlJob.java @@ -42,8 +42,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class CrawlJob { - private static final Logger logger = LoggerFactory - .getLogger(CrawlJob.class); + private static final Logger logger = LoggerFactory.getLogger(CrawlJob.class); protected JobExecutor jobExecutor; @@ -112,8 +111,7 @@ public class CrawlJob { return this; } - public void retryToDeleteTempDir(final int retryCount, - final long retryInterval) { + public void retryToDeleteTempDir(final int retryCount, final long retryInterval) { retryCountToDeleteTempDir = retryCount; retryIntervalToDeleteTempDir = retryInterval; } @@ -124,8 +122,7 @@ public class CrawlJob { return execute(); } - public String execute(final JobExecutor jobExecutor, - final String[] webConfigIds, final String[] fileConfigIds, + public String execute(final JobExecutor jobExecutor, final String[] webConfigIds, final String[] fileConfigIds, final String[] dataConfigIds, final String operation) { jobExecutor(jobExecutor); operation(Constants.COMMIT); @@ -136,10 +133,8 @@ public class CrawlJob { } - public String execute(final JobExecutor jobExecutor, - final String sessionId, final String[] webConfigIds, - final String[] fileConfigIds, final String[] dataConfigIds, - final String operation) { + public String execute(final JobExecutor jobExecutor, final String sessionId, final String[] webConfigIds, final String[] fileConfigIds, + final String[] dataConfigIds, final String operation) { jobExecutor(jobExecutor); operation(Constants.COMMIT); webConfigIds(webConfigIds); @@ -151,8 +146,7 @@ public class CrawlJob { public String execute() { final StringBuilder resultBuf = new StringBuilder(); - final boolean runAll = webConfigIds == null && fileConfigIds == null - && dataConfigIds == null; + final boolean runAll = webConfigIds == null && fileConfigIds == null && dataConfigIds == null; if (sessionId == null) { // create session id final SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); @@ -203,8 +197,7 @@ public class CrawlJob { jobExecutor.addShutdownListener(new ShutdownListener() { @Override public void onShutdown() { - ComponentUtil.getJobHelper().destroyCrawlerProcess( - sessionId); + ComponentUtil.getJobHelper().destroyCrawlerProcess(sessionId); } }); } @@ -225,8 +218,7 @@ public class CrawlJob { protected void executeCrawler() { final List crawlerCmdList = new ArrayList(); final String cpSeparator = SystemUtils.IS_OS_WINDOWS ? ";" : ":"; - final ServletContext servletContext = SingletonS2Container - .getComponent(ServletContext.class); + final ServletContext servletContext = SingletonS2Container.getComponent(ServletContext.class); final SystemHelper systemHelper = ComponentUtil.getSystemHelper(); final JobHelper jobHelper = ComponentUtil.getJobHelper(); @@ -247,12 +239,10 @@ public class CrawlJob { buf.append(File.separator); buf.append("classes"); // WEB-INF/lib - appendJarFile(cpSeparator, servletContext, buf, "/WEB-INF/lib", - "WEB-INF" + File.separator + "lib" + File.separator); + appendJarFile(cpSeparator, servletContext, buf, "/WEB-INF/lib", "WEB-INF" + File.separator + "lib" + File.separator); // WEB-INF/cmd/lib - appendJarFile(cpSeparator, servletContext, buf, "/WEB-INF/cmd/lib", - "WEB-INF" + File.separator + "cmd" + File.separator + "lib" - + File.separator); + appendJarFile(cpSeparator, servletContext, buf, "/WEB-INF/cmd/lib", "WEB-INF" + File.separator + "cmd" + File.separator + "lib" + + File.separator); crawlerCmdList.add(buf.toString()); crawlerCmdList.add("-Dfess.crawler.process=true"); @@ -273,8 +263,7 @@ public class CrawlJob { if (StringUtil.isNotBlank(tmpDir)) { ownTmpDir = new File(tmpDir, "fessTmpDir_" + sessionId); if (ownTmpDir.mkdirs()) { - crawlerCmdList.add("-Djava.io.tmpdir=" - + ownTmpDir.getAbsolutePath()); + crawlerCmdList.add("-Djava.io.tmpdir=" + ownTmpDir.getAbsolutePath()); } else { ownTmpDir = null; } @@ -312,8 +301,7 @@ public class CrawlJob { final File baseDir = new File(servletContext.getRealPath("/")); if (logger.isInfoEnabled()) { - logger.info("Crawler: \nDirectory=" + baseDir + "\nOptions=" - + crawlerCmdList); + logger.info("Crawler: \nDirectory=" + baseDir + "\nOptions=" + crawlerCmdList); } final ProcessBuilder pb = new ProcessBuilder(crawlerCmdList); @@ -321,8 +309,7 @@ public class CrawlJob { pb.redirectErrorStream(true); try { - final JobProcess jobProcess = jobHelper.startCrawlerProcess( - sessionId, pb); + final JobProcess jobProcess = jobHelper.startCrawlerProcess(sessionId, pb); final InputStreamThread it = jobProcess.getInputStreamThread(); it.start(); @@ -334,12 +321,10 @@ public class CrawlJob { final int exitValue = currentProcess.exitValue(); if (logger.isInfoEnabled()) { - logger.info("Crawler: Exit Code=" + exitValue - + " - Crawler Process Output:\n" + it.getOutput()); + logger.info("Crawler: Exit Code=" + exitValue + " - Crawler Process Output:\n" + it.getOutput()); } if (exitValue != 0) { - throw new FessSystemException("Exit Code: " + exitValue - + "\nOutput:\n" + it.getOutput()); + throw new FessSystemException("Exit Code: " + exitValue + "\nOutput:\n" + it.getOutput()); } } catch (final FessSystemException e) { throw e; @@ -370,12 +355,10 @@ public class CrawlJob { // ignore } } - logger.warn("Could not delete a temp dir: " - + ownTmpDir.getAbsolutePath()); + logger.warn("Could not delete a temp dir: " + ownTmpDir.getAbsolutePath()); } - protected void appendJarFile(final String cpSeparator, - final ServletContext servletContext, final StringBuilder buf, + protected void appendJarFile(final String cpSeparator, final ServletContext servletContext, final StringBuilder buf, final String libDirPath, final String basePath) { final File libDir = new File(servletContext.getRealPath(libDirPath)); final File[] jarFiles = libDir.listFiles(new FilenameFilter() { diff --git a/src/main/java/org/codelibs/fess/job/JobScheduler.java b/src/main/java/org/codelibs/fess/job/JobScheduler.java index 76afb9b47..f03e10400 100644 --- a/src/main/java/org/codelibs/fess/job/JobScheduler.java +++ b/src/main/java/org/codelibs/fess/job/JobScheduler.java @@ -44,8 +44,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class JobScheduler { - private static final Logger logger = LoggerFactory - .getLogger(JobScheduler.class); + private static final Logger logger = LoggerFactory.getLogger(JobScheduler.class); private static final String TRIGGER_ID_PREFIX = "trigger"; @@ -92,8 +91,7 @@ public class JobScheduler { } if (!Constants.T.equals(scheduledJob.getAvailable())) { - logger.info("Inactive Job " + scheduledJob.getId() + ":" - + scheduledJob.getName()); + logger.info("Inactive Job " + scheduledJob.getId() + ":" + scheduledJob.getName()); try { unregister(scheduledJob); } catch (final Exception e) { @@ -104,8 +102,7 @@ public class JobScheduler { final String target = scheduledJob.getTarget(); if (!isTarget(target)) { - logger.info("Ignore Job " + scheduledJob.getId() + ":" - + scheduledJob.getName() + " because of not target: " + logger.info("Ignore Job " + scheduledJob.getId() + ":" + scheduledJob.getName() + " because of not target: " + scheduledJob.getTarget()); return; } @@ -122,22 +119,18 @@ public class JobScheduler { final JobDataMap jobDataMap = new JobDataMap(); jobDataMap.put(Constants.SCHEDULED_JOB, scheduledJob); jobDataMap.put(Constants.JOB_EXECUTOR_TYPE, scriptType); - final JobDetail jobDetail = newJob(jobClass).withIdentity(jobId) - .usingJobData(jobDataMap).build(); + final JobDetail jobDetail = newJob(jobClass).withIdentity(jobId).usingJobData(jobDataMap).build(); - final Trigger trigger = newTrigger().withIdentity(triggerId) - .withSchedule(cronSchedule(scheduledJob.getCronExpression())) - .startNow().build(); + final Trigger trigger = + newTrigger().withIdentity(triggerId).withSchedule(cronSchedule(scheduledJob.getCronExpression())).startNow().build(); try { scheduler.scheduleJob(jobDetail, trigger); } catch (final SchedulerException e) { - throw new ScheduledJobException("Failed to add Job: " - + scheduledJob, e); + throw new ScheduledJobException("Failed to add Job: " + scheduledJob, e); } - logger.info("Starting Job " + scheduledJob.getId() + ":" - + scheduledJob.getName()); + logger.info("Starting Job " + scheduledJob.getId() + ":" + scheduledJob.getName()); } @@ -146,8 +139,7 @@ public class JobScheduler { try { scheduler.deleteJob(jobKey(jobId)); } catch (final SchedulerException e) { - throw new ScheduledJobException("Failed to delete Job: " - + scheduledJob, e); + throw new ScheduledJobException("Failed to delete Job: " + scheduledJob, e); } } @@ -159,8 +151,7 @@ public class JobScheduler { final String[] targets = target.split(","); for (String name : targets) { name = name.trim(); - if (Constants.DEFAULT_JOB_TARGET.equals(name) - || targetList.contains(name)) { + if (Constants.DEFAULT_JOB_TARGET.equals(name) || targetList.contains(name)) { return true; } } diff --git a/src/main/java/org/codelibs/fess/job/PurgeLogJob.java b/src/main/java/org/codelibs/fess/job/PurgeLogJob.java index 041a89703..508bf7566 100644 --- a/src/main/java/org/codelibs/fess/job/PurgeLogJob.java +++ b/src/main/java/org/codelibs/fess/job/PurgeLogJob.java @@ -29,27 +29,20 @@ import org.slf4j.LoggerFactory; public class PurgeLogJob { - private static final Logger logger = LoggerFactory - .getLogger(PurgeLogJob.class); + private static final Logger logger = LoggerFactory.getLogger(PurgeLogJob.class); public String execute() { - final CrawlingSessionService crawlingSessionService = SingletonS2Container - .getComponent(CrawlingSessionService.class); - final SearchLogService searchLogService = SingletonS2Container - .getComponent(SearchLogService.class); - final JobLogService jobLogService = SingletonS2Container - .getComponent(JobLogService.class); - final UserInfoService userInfoService = SingletonS2Container - .getComponent(UserInfoService.class); - final DynamicProperties crawlerProperties = ComponentUtil - .getCrawlerProperties(); + final CrawlingSessionService crawlingSessionService = SingletonS2Container.getComponent(CrawlingSessionService.class); + final SearchLogService searchLogService = SingletonS2Container.getComponent(SearchLogService.class); + final JobLogService jobLogService = SingletonS2Container.getComponent(JobLogService.class); + final UserInfoService userInfoService = SingletonS2Container.getComponent(UserInfoService.class); + final DynamicProperties crawlerProperties = ComponentUtil.getCrawlerProperties(); final StringBuilder resultBuf = new StringBuilder(); // purge crawling sessions try { - crawlingSessionService.deleteBefore(ComponentUtil.getSystemHelper() - .getCurrentTime()); + crawlingSessionService.deleteBefore(ComponentUtil.getSystemHelper().getCurrentTime()); } catch (final Exception e) { logger.error("Failed to purge crawling sessions.", e); resultBuf.append(e.getMessage()).append("\n"); @@ -57,9 +50,7 @@ public class PurgeLogJob { // purge search logs try { - final String value = crawlerProperties.getProperty( - Constants.PURGE_SEARCH_LOG_DAY_PROPERTY, - Constants.DEFAULT_PURGE_DAY); + final String value = crawlerProperties.getProperty(Constants.PURGE_SEARCH_LOG_DAY_PROPERTY, Constants.DEFAULT_PURGE_DAY); final int days = Integer.parseInt(value); searchLogService.deleteBefore(days); } catch (final Exception e) { @@ -69,9 +60,7 @@ public class PurgeLogJob { // purge job logs try { - final String value = crawlerProperties.getProperty( - Constants.PURGE_JOB_LOG_DAY_PROPERTY, - Constants.DEFAULT_PURGE_DAY); + final String value = crawlerProperties.getProperty(Constants.PURGE_JOB_LOG_DAY_PROPERTY, Constants.DEFAULT_PURGE_DAY); final int days = Integer.parseInt(value); jobLogService.deleteBefore(days); } catch (final Exception e) { @@ -81,9 +70,7 @@ public class PurgeLogJob { // purge user info try { - final String value = crawlerProperties.getProperty( - Constants.PURGE_USER_INFO_DAY_PROPERTY, - Constants.DEFAULT_PURGE_DAY); + final String value = crawlerProperties.getProperty(Constants.PURGE_USER_INFO_DAY_PROPERTY, Constants.DEFAULT_PURGE_DAY); final int days = Integer.parseInt(value); userInfoService.deleteBefore(days); } catch (final Exception e) { diff --git a/src/main/java/org/codelibs/fess/job/TriggeredJob.java b/src/main/java/org/codelibs/fess/job/TriggeredJob.java index 6e838dd41..bd51b868c 100644 --- a/src/main/java/org/codelibs/fess/job/TriggeredJob.java +++ b/src/main/java/org/codelibs/fess/job/TriggeredJob.java @@ -32,15 +32,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class TriggeredJob implements Job { - private static final Logger logger = LoggerFactory - .getLogger(TriggeredJob.class); + private static final Logger logger = LoggerFactory.getLogger(TriggeredJob.class); @Override - public void execute(final JobExecutionContext context) - throws JobExecutionException { + public void execute(final JobExecutionContext context) throws JobExecutionException { final JobDataMap data = context.getMergedJobDataMap(); - final ScheduledJob scheduledJob = (ScheduledJob) data - .get(Constants.SCHEDULED_JOB); + final ScheduledJob scheduledJob = (ScheduledJob) data.get(Constants.SCHEDULED_JOB); execute(scheduledJob); } @@ -53,8 +50,7 @@ public class TriggeredJob implements Job { final String script = scheduledJob.getScriptData(); final Long id = scheduledJob.getId(); final String jobId = Constants.JOB_ID_PREFIX + id; - final JobExecutor jobExecutor = ComponentUtil - .getJobExecutor(scriptType); + final JobExecutor jobExecutor = ComponentUtil.getJobExecutor(scriptType); if (jobExecutor == null) { throw new ScheduledJobException("No jobExecutor: " + scriptType); } @@ -72,10 +68,8 @@ public class TriggeredJob implements Job { } if (logger.isDebugEnabled()) { - logger.debug("Starting Job " + jobId + ". scriptType: " - + scriptType + ", script: " + script); - } else if (scheduledJob.isLoggingEnabled() - && logger.isInfoEnabled()) { + logger.debug("Starting Job " + jobId + ". scriptType: " + scriptType + ", script: " + script); + } else if (scheduledJob.isLoggingEnabled() && logger.isInfoEnabled()) { logger.info("Starting Job " + jobId + "."); } @@ -86,8 +80,7 @@ public class TriggeredJob implements Job { } } else { if (scheduledJob.isLoggingEnabled() && logger.isInfoEnabled()) { - logger.info("Finished Job " + jobId - + ". The return value is:\n" + ret); + logger.info("Finished Job " + jobId + ". The return value is:\n" + ret); } jobLog.setScriptResult(ret.toString()); } @@ -95,8 +88,7 @@ public class TriggeredJob implements Job { } catch (final Throwable t) { // NOPMD logger.error("Failed to execute " + jobId + ": " + script, t); jobLog.setJobStatus(Constants.FAIL); - jobLog.setScriptResult(systemHelper.abbreviateLongText(t - .getLocalizedMessage())); + jobLog.setScriptResult(systemHelper.abbreviateLongText(t.getLocalizedMessage())); } finally { jobHelper.finishJobExecutoer(id); jobLog.setEndTime(ComponentUtil.getSystemHelper().getCurrentTime()); @@ -110,8 +102,7 @@ public class TriggeredJob implements Job { } private void storeJobLog(final JobLog jobLog) { - final JobLogService jobLogService = SingletonS2Container - .getComponent(JobLogService.class); + final JobLogService jobLogService = SingletonS2Container.getComponent(JobLogService.class); jobLogService.store(jobLog); } diff --git a/src/main/java/org/codelibs/fess/job/UpdateHotWordJob.java b/src/main/java/org/codelibs/fess/job/UpdateHotWordJob.java index e5d8a7881..2ede05d16 100644 --- a/src/main/java/org/codelibs/fess/job/UpdateHotWordJob.java +++ b/src/main/java/org/codelibs/fess/job/UpdateHotWordJob.java @@ -23,12 +23,10 @@ import org.slf4j.LoggerFactory; public class UpdateHotWordJob { - private static final Logger logger = LoggerFactory - .getLogger(UpdateHotWordJob.class); + private static final Logger logger = LoggerFactory.getLogger(UpdateHotWordJob.class); public String execute() { - final HotSearchWordHelper hotSearchWordHelper = ComponentUtil - .getHotSearchWordHelper(); + final HotSearchWordHelper hotSearchWordHelper = ComponentUtil.getHotSearchWordHelper(); final StringBuilder resultBuf = new StringBuilder(); diff --git a/src/main/java/org/codelibs/fess/job/UpdateStatsJob.java b/src/main/java/org/codelibs/fess/job/UpdateStatsJob.java index 313f1d5b2..3f9fc784e 100644 --- a/src/main/java/org/codelibs/fess/job/UpdateStatsJob.java +++ b/src/main/java/org/codelibs/fess/job/UpdateStatsJob.java @@ -24,12 +24,10 @@ import org.slf4j.LoggerFactory; public class UpdateStatsJob { - private static final Logger logger = LoggerFactory - .getLogger(UpdateStatsJob.class); + private static final Logger logger = LoggerFactory.getLogger(UpdateStatsJob.class); public String execute() { - final SearchFieldLogService searchFieldLogService = SingletonS2Container - .getComponent(SearchFieldLogService.class); + final SearchFieldLogService searchFieldLogService = SingletonS2Container.getComponent(SearchFieldLogService.class); final StringBuilder resultBuf = new StringBuilder(); diff --git a/src/main/java/org/codelibs/fess/job/impl/GroovyExecutor.java b/src/main/java/org/codelibs/fess/job/impl/GroovyExecutor.java index 4c674544b..8cc2922bc 100644 --- a/src/main/java/org/codelibs/fess/job/impl/GroovyExecutor.java +++ b/src/main/java/org/codelibs/fess/job/impl/GroovyExecutor.java @@ -27,8 +27,7 @@ public class GroovyExecutor extends JobExecutor { @Override public Object execute(final String script) { final Binding binding = new Binding(); - binding.setVariable("container", - SingletonS2ContainerFactory.getContainer()); + binding.setVariable("container", SingletonS2ContainerFactory.getContainer()); binding.setVariable("executor", this); final GroovyShell shell = new GroovyShell(binding); diff --git a/src/main/java/org/codelibs/fess/pager/StatsPager.java b/src/main/java/org/codelibs/fess/pager/StatsPager.java index deabc84a3..adabebac3 100644 --- a/src/main/java/org/codelibs/fess/pager/StatsPager.java +++ b/src/main/java/org/codelibs/fess/pager/StatsPager.java @@ -80,18 +80,15 @@ public class StatsPager implements Serializable { if (StringUtil.isBlank(startHour)) { startHour = null; startMin = null; - final DateTimeFormatter formatter = DateTimeFormatter - .ofPattern(DATE_TIME_FORMAT); + final DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATE_TIME_FORMAT); return LocalDateTime.parse(startDate + " 00:00", formatter); } else { if (StringUtil.isBlank(startMin)) { startMin = "0"; } - final DateTimeFormatter formatter = DateTimeFormatter - .ofPattern(DATE_TIME_FORMAT); - return LocalDateTime.parse(startDate + " " + startHour + ":" - + startMin, formatter); + final DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATE_TIME_FORMAT); + return LocalDateTime.parse(startDate + " " + startHour + ":" + startMin, formatter); } } catch (final DateTimeParseException e) { resetStartDate(); @@ -114,18 +111,15 @@ public class StatsPager implements Serializable { if (StringUtil.isBlank(endHour)) { endHour = null; endMin = null; - final DateTimeFormatter formatter = DateTimeFormatter - .ofPattern(DATE_TIME_FORMAT); + final DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATE_TIME_FORMAT); return LocalDateTime.parse(endDate + " 00:00", formatter); } else { if (StringUtil.isBlank(endMin)) { endMin = "0"; } - final DateTimeFormatter formatter = DateTimeFormatter - .ofPattern(DATE_TIME_FORMAT); - return LocalDateTime.parse(endDate + " " + endHour + ":" - + endMin, formatter); + final DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATE_TIME_FORMAT); + return LocalDateTime.parse(endDate + " " + endHour + ":" + endMin, formatter); } } catch (final DateTimeParseException e) { resetEndDate(); diff --git a/src/main/java/org/codelibs/fess/robot/FessS2RobotThread.java b/src/main/java/org/codelibs/fess/robot/FessS2RobotThread.java index 754019a86..a7d1c56ce 100644 --- a/src/main/java/org/codelibs/fess/robot/FessS2RobotThread.java +++ b/src/main/java/org/codelibs/fess/robot/FessS2RobotThread.java @@ -56,42 +56,30 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class FessS2RobotThread extends S2RobotThread { - private static final Logger logger = LoggerFactory - .getLogger(FessS2RobotThread.class); + private static final Logger logger = LoggerFactory.getLogger(FessS2RobotThread.class); @Override - protected boolean isContentUpdated(final S2RobotClient client, - final UrlQueue urlQueue) { - final DynamicProperties crawlerProperties = ComponentUtil - .getCrawlerProperties(); - if (crawlerProperties.getProperty(Constants.DIFF_CRAWLING_PROPERTY, - Constants.TRUE).equals(Constants.TRUE)) { + protected boolean isContentUpdated(final S2RobotClient client, final UrlQueue urlQueue) { + final DynamicProperties crawlerProperties = ComponentUtil.getCrawlerProperties(); + if (crawlerProperties.getProperty(Constants.DIFF_CRAWLING_PROPERTY, Constants.TRUE).equals(Constants.TRUE)) { log(logHelper, LogType.CHECK_LAST_MODIFIED, robotContext, urlQueue); final long startTime = System.currentTimeMillis(); - final CrawlingConfigHelper crawlingConfigHelper = ComponentUtil - .getCrawlingConfigHelper(); - final CrawlingSessionHelper crawlingSessionHelper = ComponentUtil - .getCrawlingSessionHelper(); + final CrawlingConfigHelper crawlingConfigHelper = ComponentUtil.getCrawlingConfigHelper(); + final CrawlingSessionHelper crawlingSessionHelper = ComponentUtil.getCrawlingSessionHelper(); final FieldHelper fieldHelper = ComponentUtil.getFieldHelper(); final SambaHelper sambaHelper = ComponentUtil.getSambaHelper(); - final IndexingHelper indexingHelper = ComponentUtil - .getIndexingHelper(); - final SolrGroupManager solrGroupManager = ComponentUtil - .getSolrGroupManager(); - final boolean useAclAsRole = crawlerProperties.getProperty( - Constants.USE_ACL_AS_ROLE, Constants.FALSE).equals( - Constants.TRUE); + final IndexingHelper indexingHelper = ComponentUtil.getIndexingHelper(); + final SolrGroupManager solrGroupManager = ComponentUtil.getSolrGroupManager(); + final boolean useAclAsRole = crawlerProperties.getProperty(Constants.USE_ACL_AS_ROLE, Constants.FALSE).equals(Constants.TRUE); - final SolrGroup solrGroup = solrGroupManager - .getSolrGroup(QueryType.ADD); + final SolrGroup solrGroup = solrGroupManager.getSolrGroup(QueryType.ADD); final String url = urlQueue.getUrl(); ResponseData responseData = null; try { - final CrawlingConfig crawlingConfig = crawlingConfigHelper - .get(robotContext.getSessionId()); + final CrawlingConfig crawlingConfig = crawlingConfigHelper.get(robotContext.getSessionId()); final Map dataMap = new HashMap(); dataMap.put(fieldHelper.urlField, url); final List roleTypeList = new ArrayList(); @@ -100,78 +88,60 @@ public class FessS2RobotThread extends S2RobotThread { } if (useAclAsRole && url.startsWith("smb://")) { // head method - responseData = client.execute(RequestDataBuilder - .newRequestData().head().url(url).build()); + responseData = client.execute(RequestDataBuilder.newRequestData().head().url(url).build()); if (responseData == null) { return true; } - final ACE[] aces = (ACE[]) responseData.getMetaDataMap() - .get(SmbClient.SMB_ACCESS_CONTROL_ENTRIES); + final ACE[] aces = (ACE[]) responseData.getMetaDataMap().get(SmbClient.SMB_ACCESS_CONTROL_ENTRIES); if (aces != null) { for (final ACE item : aces) { final SID sid = item.getSID(); roleTypeList.add(sambaHelper.getAccountId(sid)); } if (logger.isDebugEnabled()) { - logger.debug("smbUrl:" + responseData.getUrl() - + " roleType:" + roleTypeList.toString()); + logger.debug("smbUrl:" + responseData.getUrl() + " roleType:" + roleTypeList.toString()); } } } dataMap.put(fieldHelper.roleField, roleTypeList); final String id = crawlingSessionHelper.generateId(dataMap); - final SolrDocument solrDocument = indexingHelper - .getSolrDocument(solrGroup, id, new String[] { - fieldHelper.idField, - fieldHelper.lastModifiedField, - fieldHelper.anchorField, - fieldHelper.segmentField, - fieldHelper.expiresField, - fieldHelper.clickCountField, + final SolrDocument solrDocument = + indexingHelper.getSolrDocument(solrGroup, id, new String[] { fieldHelper.idField, fieldHelper.lastModifiedField, + fieldHelper.anchorField, fieldHelper.segmentField, fieldHelper.expiresField, fieldHelper.clickCountField, fieldHelper.favoriteCountField }); if (solrDocument == null) { - storeChildUrlsToQueue(urlQueue, - getChildUrlSet(solrGroup, id)); + storeChildUrlsToQueue(urlQueue, getChildUrlSet(solrGroup, id)); return true; } - final Date expires = (Date) solrDocument - .get(fieldHelper.expiresField); - if (expires != null - && expires.getTime() < System.currentTimeMillis()) { - final Object idValue = solrDocument - .getFieldValue(fieldHelper.idField); + final Date expires = (Date) solrDocument.get(fieldHelper.expiresField); + if (expires != null && expires.getTime() < System.currentTimeMillis()) { + final Object idValue = solrDocument.getFieldValue(fieldHelper.idField); if (idValue != null) { - indexingHelper.deleteDocument(solrGroup, - idValue.toString()); + indexingHelper.deleteDocument(solrGroup, idValue.toString()); } return true; } - final Date lastModified = (Date) solrDocument - .get(fieldHelper.lastModifiedField); + final Date lastModified = (Date) solrDocument.get(fieldHelper.lastModifiedField); if (lastModified == null) { return true; } - final Integer clickCount = (Integer) solrDocument - .get(fieldHelper.clickCountField); + final Integer clickCount = (Integer) solrDocument.get(fieldHelper.clickCountField); if (clickCount != null) { - final SearchLogHelper searchLogHelper = ComponentUtil - .getSearchLogHelper(); + final SearchLogHelper searchLogHelper = ComponentUtil.getSearchLogHelper(); final int count = searchLogHelper.getClickCount(url); if (count != clickCount.intValue()) { return true; } } - final Integer favoriteCount = (Integer) solrDocument - .get(fieldHelper.favoriteCountField); + final Integer favoriteCount = (Integer) solrDocument.get(fieldHelper.favoriteCountField); if (favoriteCount != null) { - final SearchLogHelper searchLogHelper = ComponentUtil - .getSearchLogHelper(); + final SearchLogHelper searchLogHelper = ComponentUtil.getSearchLogHelper(); final long count = searchLogHelper.getFavoriteCount(url); if (count != favoriteCount.longValue()) { return true; @@ -180,8 +150,7 @@ public class FessS2RobotThread extends S2RobotThread { if (responseData == null) { // head method - responseData = client.execute(RequestDataBuilder - .newRequestData().head().url(url).build()); + responseData = client.execute(RequestDataBuilder.newRequestData().head().url(url).build()); if (responseData == null) { return true; } @@ -189,29 +158,22 @@ public class FessS2RobotThread extends S2RobotThread { final int httpStatusCode = responseData.getHttpStatusCode(); if (httpStatusCode == 404) { - storeChildUrlsToQueue(urlQueue, - getAnchorSet(solrDocument - .get(fieldHelper.anchorField))); + storeChildUrlsToQueue(urlQueue, getAnchorSet(solrDocument.get(fieldHelper.anchorField))); indexingHelper.deleteDocument(solrGroup, id); return false; } else if (responseData.getLastModified() == null) { return true; - } else if (responseData.getLastModified().getTime() <= lastModified - .getTime() && httpStatusCode == 200) { + } else if (responseData.getLastModified().getTime() <= lastModified.getTime() && httpStatusCode == 200) { log(logHelper, LogType.NOT_MODIFIED, robotContext, urlQueue); - responseData.setExecutionTime(System.currentTimeMillis() - - startTime); + responseData.setExecutionTime(System.currentTimeMillis() - startTime); responseData.setParentUrl(urlQueue.getParentUrl()); responseData.setSessionId(robotContext.getSessionId()); - responseData - .setHttpStatusCode(org.codelibs.robot.Constants.NOT_MODIFIED_STATUS); + responseData.setHttpStatusCode(org.codelibs.robot.Constants.NOT_MODIFIED_STATUS); processResponse(urlQueue, responseData); - storeChildUrlsToQueue(urlQueue, - getAnchorSet(solrDocument - .get(fieldHelper.anchorField))); + storeChildUrlsToQueue(urlQueue, getAnchorSet(solrDocument.get(fieldHelper.anchorField))); return false; } @@ -224,14 +186,11 @@ public class FessS2RobotThread extends S2RobotThread { return true; } - protected void storeChildUrlsToQueue(final UrlQueue urlQueue, - final Set childUrlSet) { + protected void storeChildUrlsToQueue(final UrlQueue urlQueue, final Set childUrlSet) { if (childUrlSet != null) { synchronized (robotContext.getAccessCountLock()) { // add an url - storeChildUrls(childUrlSet, urlQueue.getUrl(), - urlQueue.getDepth() != null ? urlQueue.getDepth() + 1 - : 1); + storeChildUrls(childUrlSet, urlQueue.getUrl(), urlQueue.getDepth() != null ? urlQueue.getDepth() + 1 : 1); } } } @@ -254,19 +213,15 @@ public class FessS2RobotThread extends S2RobotThread { final Set childUrlSet = new LinkedHashSet<>(); for (final String anchor : anchorList) { - childUrlSet.add(RequestDataBuilder.newRequestData().get() - .url(anchor).build()); + childUrlSet.add(RequestDataBuilder.newRequestData().get().url(anchor).build()); } return childUrlSet; } - protected Set getChildUrlSet(final SolrGroup solrGroup, - final String id) { + protected Set getChildUrlSet(final SolrGroup solrGroup, final String id) { final FieldHelper fieldHelper = ComponentUtil.getFieldHelper(); final IndexingHelper indexingHelper = ComponentUtil.getIndexingHelper(); - final SolrDocumentList docList = indexingHelper - .getChildSolrDocumentList(solrGroup, id, - new String[] { fieldHelper.urlField }); + final SolrDocumentList docList = indexingHelper.getChildSolrDocumentList(solrGroup, id, new String[] { fieldHelper.urlField }); if (docList.isEmpty()) { return null; } @@ -277,8 +232,7 @@ public class FessS2RobotThread extends S2RobotThread { for (final SolrDocument doc : docList) { final Object obj = doc.get(fieldHelper.urlField); if (obj != null) { - urlSet.add(RequestDataBuilder.newRequestData().get() - .url(obj.toString()).build()); + urlSet.add(RequestDataBuilder.newRequestData().get().url(obj.toString()).build()); } } return urlSet; diff --git a/src/main/java/org/codelibs/fess/screenshot/ScreenShotManager.java b/src/main/java/org/codelibs/fess/screenshot/ScreenShotManager.java index 4307cbfee..4b769fa12 100644 --- a/src/main/java/org/codelibs/fess/screenshot/ScreenShotManager.java +++ b/src/main/java/org/codelibs/fess/screenshot/ScreenShotManager.java @@ -43,8 +43,7 @@ import org.slf4j.LoggerFactory; public class ScreenShotManager { private static final String DEFAULT_SCREENSHOT_DIR = "/WEB-INF/screenshots"; - private static final Logger logger = LoggerFactory - .getLogger(ScreenShotManager.class); + private static final Logger logger = LoggerFactory.getLogger(ScreenShotManager.class); @Resource protected ServletContext application; @@ -81,8 +80,7 @@ public class ScreenShotManager { } } if (!baseDir.isDirectory()) { - throw new FessSystemException("Not found: " - + baseDir.getAbsolutePath()); + throw new FessSystemException("Not found: " + baseDir.getAbsolutePath()); } if (logger.isDebugEnabled()) { @@ -119,10 +117,8 @@ public class ScreenShotManager { if (generator.isTarget(docMap)) { final String url = (String) docMap.get(fieldHelper.urlField); final String path = getImageFilename(docMap); - if (!screenShotTaskQueue.offer(new ScreenShotTask(url, - new File(baseDir, path), generator))) { - logger.warn("Failed to offer a screenshot task: " + url - + " -> " + path); + if (!screenShotTaskQueue.offer(new ScreenShotTask(url, new File(baseDir, path), generator))) { + logger.warn("Failed to offer a screenshot task: " + url + " -> " + path); } break; } @@ -143,21 +139,17 @@ public class ScreenShotManager { return buf.toString(); } - public void storeRequest(final String queryId, - final List> documentItems) { + public void storeRequest(final String queryId, final List> documentItems) { final FieldHelper fieldHelper = ComponentUtil.getFieldHelper(); - final Map dataMap = new HashMap( - documentItems.size()); + final Map dataMap = new HashMap(documentItems.size()); for (final Map docMap : documentItems) { final String docid = (String) docMap.get(fieldHelper.docIdField); final String screenShotPath = getImageFilename(docMap); - if (StringUtil.isNotBlank(docid) - && StringUtil.isNotBlank(screenShotPath)) { + if (StringUtil.isNotBlank(docid) && StringUtil.isNotBlank(screenShotPath)) { dataMap.put(docid, screenShotPath); } } - final Map> screenShotPathCache = getScreenShotPathCache(RequestUtil - .getRequest().getSession()); + final Map> screenShotPathCache = getScreenShotPathCache(RequestUtil.getRequest().getSession()); screenShotPathCache.put(queryId, dataMap); } @@ -165,8 +157,7 @@ public class ScreenShotManager { final HttpSession session = RequestUtil.getRequest().getSession(false); if (session != null) { final Map> screenShotPathCache = getScreenShotPathCache(session); - final Map dataMap = screenShotPathCache - .get(queryId); + final Map dataMap = screenShotPathCache.get(queryId); if (dataMap != null) { final String path = dataMap.get(docId); final File file = new File(baseDir, path); @@ -178,16 +169,13 @@ public class ScreenShotManager { return null; } - private Map> getScreenShotPathCache( - final HttpSession session) { + private Map> getScreenShotPathCache(final HttpSession session) { @SuppressWarnings("unchecked") - Map> screenShotPathCache = (Map>) session - .getAttribute(Constants.SCREEN_SHOT_PATH_CACHE); + Map> screenShotPathCache = + (Map>) session.getAttribute(Constants.SCREEN_SHOT_PATH_CACHE); if (screenShotPathCache == null) { - screenShotPathCache = new LruHashMap>( - screenShotPathCacheSize); - session.setAttribute(Constants.SCREEN_SHOT_PATH_CACHE, - screenShotPathCache); + screenShotPathCache = new LruHashMap>(screenShotPathCacheSize); + session.setAttribute(Constants.SCREEN_SHOT_PATH_CACHE, screenShotPathCache); } return screenShotPathCache; } @@ -203,8 +191,7 @@ public class ScreenShotManager { ScreenShotGenerator generator; - protected ScreenShotTask(final String url, final File outputFile, - final ScreenShotGenerator generator) { + protected ScreenShotTask(final String url, final File outputFile, final ScreenShotGenerator generator) { this.url = url; this.outputFile = outputFile; this.generator = generator; @@ -218,8 +205,7 @@ public class ScreenShotManager { public int hashCode() { final int prime = 31; int result = 1; - result = prime * result - + (outputFile == null ? 0 : outputFile.hashCode()); + result = prime * result + (outputFile == null ? 0 : outputFile.hashCode()); result = prime * result + (url == null ? 0 : url.hashCode()); return result; } diff --git a/src/main/java/org/codelibs/fess/screenshot/impl/BaseScreenShotGenerator.java b/src/main/java/org/codelibs/fess/screenshot/impl/BaseScreenShotGenerator.java index 42ca9594a..6ae30c6d6 100644 --- a/src/main/java/org/codelibs/fess/screenshot/impl/BaseScreenShotGenerator.java +++ b/src/main/java/org/codelibs/fess/screenshot/impl/BaseScreenShotGenerator.java @@ -41,8 +41,7 @@ public abstract class BaseScreenShotGenerator implements ScreenShotGenerator { public boolean isTarget(final Map docMap) { for (final Map.Entry entry : conditionMap.entrySet()) { final Object value = docMap.get(entry.getKey()); - if (value instanceof String - && !((String) value).matches(entry.getValue())) { + if (value instanceof String && !((String) value).matches(entry.getValue())) { return false; } } diff --git a/src/main/java/org/codelibs/fess/screenshot/impl/CommandGenerator.java b/src/main/java/org/codelibs/fess/screenshot/impl/CommandGenerator.java index b4ca6b29d..7bbb46ceb 100644 --- a/src/main/java/org/codelibs/fess/screenshot/impl/CommandGenerator.java +++ b/src/main/java/org/codelibs/fess/screenshot/impl/CommandGenerator.java @@ -34,8 +34,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class CommandGenerator extends BaseScreenShotGenerator { - private static final Logger logger = LoggerFactory - .getLogger(CommandGenerator.class); + private static final Logger logger = LoggerFactory.getLogger(CommandGenerator.class); @Binding(bindingType = BindingType.MUST) public List commandList; @@ -51,8 +50,7 @@ public class CommandGenerator extends BaseScreenShotGenerator { if (baseDir == null) { baseDir = new File(application.getRealPath("/")); } - destoryTimer = new Timer("CommandGeneratorDestoryTimer-" - + System.currentTimeMillis(), true); + destoryTimer = new Timer("CommandGeneratorDestoryTimer-" + System.currentTimeMillis(), true); } @DestroyMethod @@ -69,8 +67,7 @@ public class CommandGenerator extends BaseScreenShotGenerator { if (outputFile.exists()) { if (logger.isDebugEnabled()) { - logger.debug("The screenshot file exists: " - + outputFile.getAbsolutePath()); + logger.debug("The screenshot file exists: " + outputFile.getAbsolutePath()); } return; } @@ -87,8 +84,7 @@ public class CommandGenerator extends BaseScreenShotGenerator { final String outputPath = outputFile.getAbsolutePath(); final List cmdList = new ArrayList(); for (final String value : commandList) { - cmdList.add(value.replace("${url}", url).replace("${outputFile}", - outputPath)); + cmdList.add(value.replace("${url}", url).replace("${outputFile}", outputPath)); } ProcessBuilder pb = null; @@ -113,8 +109,7 @@ public class CommandGenerator extends BaseScreenShotGenerator { String line; BufferedReader br = null; try { - br = new BufferedReader(new InputStreamReader( - p.getInputStream(), Charset.defaultCharset())); + br = new BufferedReader(new InputStreamReader(p.getInputStream(), Charset.defaultCharset())); while ((line = br.readLine()) != null) { if (logger.isDebugEnabled()) { logger.debug(line); @@ -154,8 +149,7 @@ public class CommandGenerator extends BaseScreenShotGenerator { private final List commandList; - protected ProcessDestroyer(final Process p, - final List commandList) { + protected ProcessDestroyer(final Process p, final List commandList) { this.p = p; this.commandList = commandList; } diff --git a/src/main/java/org/codelibs/fess/screenshot/impl/WebDriverGenerator.java b/src/main/java/org/codelibs/fess/screenshot/impl/WebDriverGenerator.java index 449b5dfe0..8b2d930ba 100644 --- a/src/main/java/org/codelibs/fess/screenshot/impl/WebDriverGenerator.java +++ b/src/main/java/org/codelibs/fess/screenshot/impl/WebDriverGenerator.java @@ -36,8 +36,7 @@ import org.slf4j.LoggerFactory; public class WebDriverGenerator extends BaseScreenShotGenerator { - private static final Logger logger = LoggerFactory - .getLogger(WebDriverGenerator.class); + private static final Logger logger = LoggerFactory.getLogger(WebDriverGenerator.class); public WebDriver webDriver; @@ -54,8 +53,7 @@ public class WebDriverGenerator extends BaseScreenShotGenerator { if (webDriver == null) { webDriver = new PhantomJSDriver(); } - webDriver.manage().window() - .setSize(new Dimension(windowWidth, windowHeight)); + webDriver.manage().window().setSize(new Dimension(windowWidth, windowHeight)); } @DestroyMethod @@ -71,8 +69,7 @@ public class WebDriverGenerator extends BaseScreenShotGenerator { if (outputFile.exists()) { if (logger.isDebugEnabled()) { - logger.debug("The screenshot file exists: " - + outputFile.getAbsolutePath()); + logger.debug("The screenshot file exists: " + outputFile.getAbsolutePath()); } return; } @@ -88,26 +85,20 @@ public class WebDriverGenerator extends BaseScreenShotGenerator { if (webDriver instanceof TakesScreenshot) { webDriver.get(url); - final File screenshot = ((TakesScreenshot) webDriver) - .getScreenshotAs(OutputType.FILE); + final File screenshot = ((TakesScreenshot) webDriver).getScreenshotAs(OutputType.FILE); convert(screenshot, outputFile); } else { - logger.warn("WebDriver is not instance of TakesScreenshot: " - + webDriver); + logger.warn("WebDriver is not instance of TakesScreenshot: " + webDriver); } } protected void convert(final File inputFile, final File outputFile) { try { final BufferedImage image = loadImage(inputFile); - final int screenShotHeight = screenShotWidth * image.getHeight() - / windowWidth; - final BufferedImage screenShotImage = new BufferedImage( - screenShotWidth, screenShotHeight, image.getType()); - screenShotImage.getGraphics().drawImage( - image.getScaledInstance(screenShotWidth, screenShotHeight, - Image.SCALE_AREA_AVERAGING), 0, 0, screenShotWidth, - screenShotHeight, null); + final int screenShotHeight = screenShotWidth * image.getHeight() / windowWidth; + final BufferedImage screenShotImage = new BufferedImage(screenShotWidth, screenShotHeight, image.getType()); + screenShotImage.getGraphics().drawImage(image.getScaledInstance(screenShotWidth, screenShotHeight, Image.SCALE_AREA_AVERAGING), + 0, 0, screenShotWidth, screenShotHeight, null); ImageIO.write(screenShotImage, imageFormatName, outputFile); } catch (final Exception e) { diff --git a/src/main/java/org/codelibs/fess/service/BoostDocumentRuleService.java b/src/main/java/org/codelibs/fess/service/BoostDocumentRuleService.java index 93f7ac3ad..a421bbfbb 100644 --- a/src/main/java/org/codelibs/fess/service/BoostDocumentRuleService.java +++ b/src/main/java/org/codelibs/fess/service/BoostDocumentRuleService.java @@ -25,14 +25,12 @@ import org.codelibs.fess.db.cbean.BoostDocumentRuleCB; import org.codelibs.fess.db.exentity.BoostDocumentRule; import org.codelibs.fess.pager.BoostDocumentRulePager; -public class BoostDocumentRuleService extends BsBoostDocumentRuleService - implements Serializable { +public class BoostDocumentRuleService extends BsBoostDocumentRuleService implements Serializable { private static final long serialVersionUID = 1L; @Override - protected void setupListCondition(final BoostDocumentRuleCB cb, - final BoostDocumentRulePager boostDocumentRulePager) { + protected void setupListCondition(final BoostDocumentRuleCB cb, final BoostDocumentRulePager boostDocumentRulePager) { super.setupListCondition(cb, boostDocumentRulePager); // setup condition @@ -44,8 +42,7 @@ public class BoostDocumentRuleService extends BsBoostDocumentRuleService } @Override - protected void setupEntityCondition(final BoostDocumentRuleCB cb, - final Map keys) { + protected void setupEntityCondition(final BoostDocumentRuleCB cb, final Map keys) { super.setupEntityCondition(cb, keys); // setup condition @@ -61,8 +58,7 @@ public class BoostDocumentRuleService extends BsBoostDocumentRuleService } @Override - protected void setupDeleteCondition( - final BoostDocumentRule boostDocumentRule) { + protected void setupDeleteCondition(final BoostDocumentRule boostDocumentRule) { super.setupDeleteCondition(boostDocumentRule); // setup condition diff --git a/src/main/java/org/codelibs/fess/service/ClickLogService.java b/src/main/java/org/codelibs/fess/service/ClickLogService.java index 5700d93b8..a59e744ad 100644 --- a/src/main/java/org/codelibs/fess/service/ClickLogService.java +++ b/src/main/java/org/codelibs/fess/service/ClickLogService.java @@ -55,8 +55,7 @@ public class ClickLogService implements Serializable { public void importCsv(final Reader reader) { final CsvReader csvReader = new CsvReader(reader, new CsvConfig()); - final DateTimeFormatter formatter = DateTimeFormatter - .ofPattern(CoreLibConstants.DATE_FORMAT_ISO_8601_EXTEND); + final DateTimeFormatter formatter = DateTimeFormatter.ofPattern(CoreLibConstants.DATE_FORMAT_ISO_8601_EXTEND); try { List list; csvReader.readValues(); // ignore header @@ -64,22 +63,16 @@ public class ClickLogService implements Serializable { try { final String dateStr = list.get(3); final String userSessionId = list.get(4); - final SearchLog searchLog = searchLogBhv.selectEntity( - cb -> { - cb.query() - .setRequestedTime_Equal( - LocalDateTime.parse(dateStr, - formatter)); - cb.query() - .setUserSessionId_Equal(userSessionId); - }).orElse(null);//TODO + final SearchLog searchLog = searchLogBhv.selectEntity(cb -> { + cb.query().setRequestedTime_Equal(LocalDateTime.parse(dateStr, formatter)); + cb.query().setUserSessionId_Equal(userSessionId); + }).orElse(null);//TODO if (searchLog != null) { final ClickLog entity = new ClickLog(); entity.setId(Long.parseLong(list.get(0))); entity.setSearchId(searchLog.getId()); entity.setUrl(list.get(1)); - entity.setRequestedTime(LocalDateTime.parse( - list.get(2), formatter)); + entity.setRequestedTime(LocalDateTime.parse(list.get(2), formatter)); clickLogBhv.insert(entity); } else { log.warn("The search log is not found: " + list); @@ -106,8 +99,7 @@ public class ClickLogService implements Serializable { list.add("QueryRequestedTime"); list.add("UserSessionId"); csvWriter.writeValues(list); - final DateTimeFormatter formatter = DateTimeFormatter - .ofPattern(CoreLibConstants.DATE_FORMAT_ISO_8601_EXTEND); + final DateTimeFormatter formatter = DateTimeFormatter.ofPattern(CoreLibConstants.DATE_FORMAT_ISO_8601_EXTEND); clickLogBhv.selectCursor(cb -> { cb.setupSelect_SearchLog(); cb.specify().specifySearchLog().columnUserSessionId(); @@ -130,8 +122,7 @@ public class ClickLogService implements Serializable { } } - private void addToList(final List list, - final Object value) { + private void addToList(final List list, final Object value) { if (value == null) { list.add(StringUtil.EMPTY); } else if (value instanceof LocalDateTime) { diff --git a/src/main/java/org/codelibs/fess/service/CrawlingSessionService.java b/src/main/java/org/codelibs/fess/service/CrawlingSessionService.java index 095e972e6..4e5ddfa16 100644 --- a/src/main/java/org/codelibs/fess/service/CrawlingSessionService.java +++ b/src/main/java/org/codelibs/fess/service/CrawlingSessionService.java @@ -48,26 +48,22 @@ import org.codelibs.fess.util.ComponentUtil; import org.dbflute.bhv.readable.EntityRowHandler; import org.dbflute.cbean.result.ListResultBean; -public class CrawlingSessionService extends BsCrawlingSessionService implements - Serializable { +public class CrawlingSessionService extends BsCrawlingSessionService implements Serializable { private static final long serialVersionUID = 1L; - private static final Log log = LogFactory - .getLog(CrawlingSessionService.class); + private static final Log log = LogFactory.getLog(CrawlingSessionService.class); @Resource protected CrawlingSessionInfoBhv crawlingSessionInfoBhv; @Override - protected void setupListCondition(final CrawlingSessionCB cb, - final CrawlingSessionPager crawlingSessionPager) { + protected void setupListCondition(final CrawlingSessionCB cb, final CrawlingSessionPager crawlingSessionPager) { super.setupListCondition(cb, crawlingSessionPager); if (StringUtil.isNotBlank(crawlingSessionPager.sessionId)) { - cb.query().setSessionId_LikeSearch(crawlingSessionPager.sessionId, - op -> { - op.likeContain(); - }); + cb.query().setSessionId_LikeSearch(crawlingSessionPager.sessionId, op -> { + op.likeContain(); + }); } cb.query().addOrderBy_CreatedTime_Desc(); } @@ -77,8 +73,7 @@ public class CrawlingSessionService extends BsCrawlingSessionService implements if (crawlingSession == null) { throw new FessSystemException("Crawling Session is null."); } - final LocalDateTime now = ComponentUtil.getSystemHelper() - .getCurrentTime(); + final LocalDateTime now = ComponentUtil.getSystemHelper().getCurrentTime(); if (crawlingSession.getCreatedTime() == null) { crawlingSession.setCreatedTime(now); } @@ -93,32 +88,28 @@ public class CrawlingSessionService extends BsCrawlingSessionService implements }); } - public void deleteSessionIdsBefore(final String activeSessionId, - final String name, final LocalDateTime date) { - final List crawlingSessionList = crawlingSessionBhv - .selectList(cb -> { - cb.query().setExpiredTime_LessEqual(date); - if (StringUtil.isNotBlank(name)) { - cb.query().setName_Equal(name); - } - if (activeSessionId != null) { - cb.query().setSessionId_NotEqual(activeSessionId); - } - cb.specify().columnId(); - }); + public void deleteSessionIdsBefore(final String activeSessionId, final String name, final LocalDateTime date) { + final List crawlingSessionList = crawlingSessionBhv.selectList(cb -> { + cb.query().setExpiredTime_LessEqual(date); + if (StringUtil.isNotBlank(name)) { + cb.query().setName_Equal(name); + } + if (activeSessionId != null) { + cb.query().setSessionId_NotEqual(activeSessionId); + } + cb.specify().columnId(); + }); if (!crawlingSessionList.isEmpty()) { final List crawlingSessionIdList = new ArrayList(); for (final CrawlingSession cs : crawlingSessionList) { crawlingSessionIdList.add(cs.getId()); } - crawlingSessionInfoBhv.varyingQueryDelete( - cb2 -> { - cb2.query().setCrawlingSessionId_InScope( - crawlingSessionIdList); - }, op -> { - op.allowNonQueryDelete(); - }); + crawlingSessionInfoBhv.varyingQueryDelete(cb2 -> { + cb2.query().setCrawlingSessionId_InScope(crawlingSessionIdList); + }, op -> { + op.allowNonQueryDelete(); + }); crawlingSessionBhv.batchDelete(crawlingSessionList); } @@ -130,14 +121,12 @@ public class CrawlingSessionService extends BsCrawlingSessionService implements }).orElse(null);//TODO } - public void storeInfo( - final List crawlingSessionInfoList) { + public void storeInfo(final List crawlingSessionInfoList) { if (crawlingSessionInfoList == null) { throw new FessSystemException("Crawling Session Info is null."); } - final LocalDateTime now = ComponentUtil.getSystemHelper() - .getCurrentTime(); + final LocalDateTime now = ComponentUtil.getSystemHelper().getCurrentTime(); for (final CrawlingSessionInfo crawlingSessionInfo : crawlingSessionInfoList) { if (crawlingSessionInfo.getCreatedTime() == null) { crawlingSessionInfo.setCreatedTime(now); @@ -153,8 +142,7 @@ public class CrawlingSessionService extends BsCrawlingSessionService implements }); } - public List getLastCrawlingSessionInfoList( - final String sessionId) { + public List getLastCrawlingSessionInfoList(final String sessionId) { final CrawlingSession crawlingSession = getLast(sessionId); if (crawlingSession == null) { return Collections.emptyList(); @@ -166,15 +154,13 @@ public class CrawlingSessionService extends BsCrawlingSessionService implements } public void deleteOldSessions(final Set activeSessionId) { - crawlingSessionInfoBhv.varyingQueryDelete( - cb1 -> { - if (!activeSessionId.isEmpty()) { - cb1.query().queryCrawlingSession() - .setSessionId_NotInScope(activeSessionId); - } - }, op -> { - op.allowNonQueryDelete(); - }); + crawlingSessionInfoBhv.varyingQueryDelete(cb1 -> { + if (!activeSessionId.isEmpty()) { + cb1.query().queryCrawlingSession().setSessionId_NotInScope(activeSessionId); + } + }, op -> { + op.allowNonQueryDelete(); + }); crawlingSessionBhv.varyingQueryDelete(cb2 -> { if (!activeSessionId.isEmpty()) { cb2.query().setSessionId_NotInScope(activeSessionId); @@ -186,24 +172,21 @@ public class CrawlingSessionService extends BsCrawlingSessionService implements public void importCsv(final Reader reader) { final CsvReader csvReader = new CsvReader(reader, new CsvConfig()); - final DateTimeFormatter formatter = DateTimeFormatter - .ofPattern(CoreLibConstants.DATE_FORMAT_ISO_8601_EXTEND); + final DateTimeFormatter formatter = DateTimeFormatter.ofPattern(CoreLibConstants.DATE_FORMAT_ISO_8601_EXTEND); try { List list; csvReader.readValues(); // ignore header while ((list = csvReader.readValues()) != null) { try { final String sessionId = list.get(0); - CrawlingSession crawlingSession = crawlingSessionBhv - .selectEntity(cb -> { - cb.query().setSessionId_Equal(sessionId); - cb.specify().columnSessionId(); - }).orElse(null);//TODO + CrawlingSession crawlingSession = crawlingSessionBhv.selectEntity(cb -> { + cb.query().setSessionId_Equal(sessionId); + cb.specify().columnSessionId(); + }).orElse(null);//TODO if (crawlingSession == null) { crawlingSession = new CrawlingSession(); crawlingSession.setSessionId(list.get(0)); - crawlingSession.setCreatedTime(LocalDateTime.parse( - list.get(1), formatter)); + crawlingSession.setCreatedTime(LocalDateTime.parse(list.get(1), formatter)); crawlingSessionBhv.insert(crawlingSession); } @@ -211,8 +194,7 @@ public class CrawlingSessionService extends BsCrawlingSessionService implements entity.setCrawlingSessionId(crawlingSession.getId()); entity.setKey(list.get(2)); entity.setValue(list.get(3)); - entity.setCreatedTime(LocalDateTime.parse(list.get(4), - formatter)); + entity.setCreatedTime(LocalDateTime.parse(list.get(4), formatter)); crawlingSessionInfoBhv.insert(entity); } catch (final Exception e) { log.warn("Failed to read a click log: " + list, e); @@ -237,8 +219,7 @@ public class CrawlingSessionService extends BsCrawlingSessionService implements list.add("Value"); list.add("CreatedTime"); csvWriter.writeValues(list); - final DateTimeFormatter formatter = DateTimeFormatter - .ofPattern(CoreLibConstants.DATE_FORMAT_ISO_8601_EXTEND); + final DateTimeFormatter formatter = DateTimeFormatter.ofPattern(CoreLibConstants.DATE_FORMAT_ISO_8601_EXTEND); crawlingSessionInfoBhv.selectCursor(cb -> { cb.setupSelect_CrawlingSession(); }, new EntityRowHandler() { @@ -260,13 +241,11 @@ public class CrawlingSessionService extends BsCrawlingSessionService implements try { csvWriter.writeValues(list); } catch (final IOException e) { - log.warn("Failed to write a crawling session info: " - + entity, e); + log.warn("Failed to write a crawling session info: " + entity, e); } } - private void addToList(final List list, - final Object value) { + private void addToList(final List list, final Object value) { if (value == null) { list.add(StringUtil.EMPTY); } else if (value instanceof LocalDateTime) { @@ -297,12 +276,11 @@ public class CrawlingSessionService extends BsCrawlingSessionService implements } public CrawlingSession getLast(final String sessionId) { - final ListResultBean list = crawlingSessionBhv - .selectList(cb -> { - cb.query().setSessionId_Equal(sessionId); - cb.query().addOrderBy_CreatedTime_Desc(); - cb.fetchFirst(1); - }); + final ListResultBean list = crawlingSessionBhv.selectList(cb -> { + cb.query().setSessionId_Equal(sessionId); + cb.query().addOrderBy_CreatedTime_Desc(); + cb.fetchFirst(1); + }); if (list.isEmpty()) { return null; } diff --git a/src/main/java/org/codelibs/fess/service/DataCrawlingConfigService.java b/src/main/java/org/codelibs/fess/service/DataCrawlingConfigService.java index dba960719..bfb82a16b 100644 --- a/src/main/java/org/codelibs/fess/service/DataCrawlingConfigService.java +++ b/src/main/java/org/codelibs/fess/service/DataCrawlingConfigService.java @@ -33,8 +33,7 @@ import org.codelibs.fess.db.exentity.DataConfigToRoleTypeMapping; import org.codelibs.fess.db.exentity.DataCrawlingConfig; import org.codelibs.fess.pager.DataCrawlingConfigPager; -public class DataCrawlingConfigService extends BsDataCrawlingConfigService - implements Serializable { +public class DataCrawlingConfigService extends BsDataCrawlingConfigService implements Serializable { private static final long serialVersionUID = 1L; @@ -48,8 +47,7 @@ public class DataCrawlingConfigService extends BsDataCrawlingConfigService return getAllDataCrawlingConfigList(true, true, true, null); } - public List getDataCrawlingConfigListByIds( - final List idList) { + public List getDataCrawlingConfigListByIds(final List idList) { if (idList == null) { return getAllDataCrawlingConfigList(); } else { @@ -57,19 +55,17 @@ public class DataCrawlingConfigService extends BsDataCrawlingConfigService } } - public List getAllDataCrawlingConfigList( - final boolean withLabelType, final boolean withRoleType, + public List getAllDataCrawlingConfigList(final boolean withLabelType, final boolean withRoleType, final boolean available, final List idList) { - final List list = dataCrawlingConfigBhv - .selectList(cb -> { - cb.query().setDeletedBy_IsNull(); - if (available) { - cb.query().setAvailable_Equal(Constants.T); - } - if (idList != null) { - cb.query().setId_InScope(idList); - } - }); + final List list = dataCrawlingConfigBhv.selectList(cb -> { + cb.query().setDeletedBy_IsNull(); + if (available) { + cb.query().setAvailable_Equal(Constants.T); + } + if (idList != null) { + cb.query().setId_InScope(idList); + } + }); if (withRoleType) { dataCrawlingConfigBhv.loadDataConfigToRoleTypeMapping(list, cb -> { cb.setupSelect_RoleType(); @@ -78,58 +74,45 @@ public class DataCrawlingConfigService extends BsDataCrawlingConfigService }); } if (withLabelType) { - dataCrawlingConfigBhv.loadDataConfigToLabelTypeMapping(list, - cb -> { - cb.setupSelect_LabelType(); - cb.query().queryLabelType().setDeletedBy_IsNull(); - cb.query().queryLabelType().addOrderBy_SortOrder_Asc(); - }); + dataCrawlingConfigBhv.loadDataConfigToLabelTypeMapping(list, cb -> { + cb.setupSelect_LabelType(); + cb.query().queryLabelType().setDeletedBy_IsNull(); + cb.query().queryLabelType().addOrderBy_SortOrder_Asc(); + }); } return list; } @Override - public DataCrawlingConfig getDataCrawlingConfig( - final Map keys) { - final DataCrawlingConfig dataCrawlingConfig = super - .getDataCrawlingConfig(keys); + public DataCrawlingConfig getDataCrawlingConfig(final Map keys) { + final DataCrawlingConfig dataCrawlingConfig = super.getDataCrawlingConfig(keys); if (dataCrawlingConfig != null) { - final List fctrtmList = dataConfigToRoleTypeMappingBhv - .selectList(fctrtmCb -> { - fctrtmCb.query().setDataConfigId_Equal( - dataCrawlingConfig.getId()); - fctrtmCb.query().queryRoleType().setDeletedBy_IsNull(); - fctrtmCb.query().queryDataCrawlingConfig() - .setDeletedBy_IsNull(); - }); + final List fctrtmList = dataConfigToRoleTypeMappingBhv.selectList(fctrtmCb -> { + fctrtmCb.query().setDataConfigId_Equal(dataCrawlingConfig.getId()); + fctrtmCb.query().queryRoleType().setDeletedBy_IsNull(); + fctrtmCb.query().queryDataCrawlingConfig().setDeletedBy_IsNull(); + }); if (!fctrtmList.isEmpty()) { - final List roleTypeIds = new ArrayList( - fctrtmList.size()); + final List roleTypeIds = new ArrayList(fctrtmList.size()); for (final DataConfigToRoleTypeMapping mapping : fctrtmList) { roleTypeIds.add(Long.toString(mapping.getRoleTypeId())); } - dataCrawlingConfig.setRoleTypeIds(roleTypeIds - .toArray(new String[roleTypeIds.size()])); + dataCrawlingConfig.setRoleTypeIds(roleTypeIds.toArray(new String[roleTypeIds.size()])); } - final List fctltmList = dataConfigToLabelTypeMappingBhv - .selectList(fctltmCb -> { - fctltmCb.query().setDataConfigId_Equal( - dataCrawlingConfig.getId()); - fctltmCb.query().queryLabelType().setDeletedBy_IsNull(); - fctltmCb.query().queryDataCrawlingConfig() - .setDeletedBy_IsNull(); - }); + final List fctltmList = dataConfigToLabelTypeMappingBhv.selectList(fctltmCb -> { + fctltmCb.query().setDataConfigId_Equal(dataCrawlingConfig.getId()); + fctltmCb.query().queryLabelType().setDeletedBy_IsNull(); + fctltmCb.query().queryDataCrawlingConfig().setDeletedBy_IsNull(); + }); if (!fctltmList.isEmpty()) { - final List labelTypeIds = new ArrayList( - fctltmList.size()); + final List labelTypeIds = new ArrayList(fctltmList.size()); for (final DataConfigToLabelTypeMapping mapping : fctltmList) { labelTypeIds.add(Long.toString(mapping.getLabelTypeId())); } - dataCrawlingConfig.setLabelTypeIds(labelTypeIds - .toArray(new String[labelTypeIds.size()])); + dataCrawlingConfig.setLabelTypeIds(labelTypeIds.toArray(new String[labelTypeIds.size()])); } } @@ -169,11 +152,9 @@ public class DataCrawlingConfigService extends BsDataCrawlingConfigService } else { // Update if (labelTypeIds != null) { - final List fctltmList = dataConfigToLabelTypeMappingBhv - .selectList(fctltmCb -> { - fctltmCb.query() - .setDataConfigId_Equal(dataConfigId); - }); + final List fctltmList = dataConfigToLabelTypeMappingBhv.selectList(fctltmCb -> { + fctltmCb.query().setDataConfigId_Equal(dataConfigId); + }); final List newList = new ArrayList(); final List matchedList = new ArrayList(); for (final String id : labelTypeIds) { @@ -199,11 +180,9 @@ public class DataCrawlingConfigService extends BsDataCrawlingConfigService dataConfigToLabelTypeMappingBhv.batchDelete(fctltmList); } if (roleTypeIds != null) { - final List fctrtmList = dataConfigToRoleTypeMappingBhv - .selectList(fctrtmCb -> { - fctrtmCb.query() - .setDataConfigId_Equal(dataConfigId); - }); + final List fctrtmList = dataConfigToRoleTypeMappingBhv.selectList(fctrtmCb -> { + fctrtmCb.query().setDataConfigId_Equal(dataConfigId); + }); final List newList = new ArrayList(); final List matchedList = new ArrayList(); for (final String id : roleTypeIds) { @@ -232,8 +211,7 @@ public class DataCrawlingConfigService extends BsDataCrawlingConfigService } @Override - protected void setupListCondition(final DataCrawlingConfigCB cb, - final DataCrawlingConfigPager dataCrawlingConfigPager) { + protected void setupListCondition(final DataCrawlingConfigCB cb, final DataCrawlingConfigPager dataCrawlingConfigPager) { super.setupListCondition(cb, dataCrawlingConfigPager); // setup condition @@ -245,8 +223,7 @@ public class DataCrawlingConfigService extends BsDataCrawlingConfigService } @Override - protected void setupEntityCondition(final DataCrawlingConfigCB cb, - final Map keys) { + protected void setupEntityCondition(final DataCrawlingConfigCB cb, final Map keys) { super.setupEntityCondition(cb, keys); // setup condition @@ -255,8 +232,7 @@ public class DataCrawlingConfigService extends BsDataCrawlingConfigService } @Override - protected void setupStoreCondition( - final DataCrawlingConfig dataCrawlingConfig) { + protected void setupStoreCondition(final DataCrawlingConfig dataCrawlingConfig) { super.setupStoreCondition(dataCrawlingConfig); // setup condition @@ -264,8 +240,7 @@ public class DataCrawlingConfigService extends BsDataCrawlingConfigService } @Override - protected void setupDeleteCondition( - final DataCrawlingConfig dataCrawlingConfig) { + protected void setupDeleteCondition(final DataCrawlingConfig dataCrawlingConfig) { super.setupDeleteCondition(dataCrawlingConfig); // setup condition diff --git a/src/main/java/org/codelibs/fess/service/DatabaseService.java b/src/main/java/org/codelibs/fess/service/DatabaseService.java index 634ba5ce1..b03530a0c 100644 --- a/src/main/java/org/codelibs/fess/service/DatabaseService.java +++ b/src/main/java/org/codelibs/fess/service/DatabaseService.java @@ -97,8 +97,7 @@ public class DatabaseService { private static final String LIST_SUFFIX = "List"; - private static final Logger logger = LoggerFactory - .getLogger(DatabaseService.class); + private static final Logger logger = LoggerFactory.getLogger(DatabaseService.class); private static final String VERSION_KEY = "version"; @@ -251,135 +250,101 @@ public class DatabaseService { dataSet.put(VERSION_KEY, Constants.FESS_VERSION); // scheduledJob - dataSet.put(SCHEDULED_JOB_KEY + LIST_SUFFIX, - scheduledJobBhv.selectList(scheduledJobCB -> { - scheduledJobCB.query().setDeletedBy_IsNull(); - })); + dataSet.put(SCHEDULED_JOB_KEY + LIST_SUFFIX, scheduledJobBhv.selectList(scheduledJobCB -> { + scheduledJobCB.query().setDeletedBy_IsNull(); + })); // labelType - dataSet.put(LABEL_TYPE_KEY + LIST_SUFFIX, - labelTypeBhv.selectList(labelTypeCB -> { - labelTypeCB.query().setDeletedBy_IsNull(); - })); + dataSet.put(LABEL_TYPE_KEY + LIST_SUFFIX, labelTypeBhv.selectList(labelTypeCB -> { + labelTypeCB.query().setDeletedBy_IsNull(); + })); // roleType - dataSet.put(ROLE_TYPE_KEY + LIST_SUFFIX, - roleTypeBhv.selectList(roleTypeCB -> { - roleTypeCB.query().setDeletedBy_IsNull(); - })); + dataSet.put(ROLE_TYPE_KEY + LIST_SUFFIX, roleTypeBhv.selectList(roleTypeCB -> { + roleTypeCB.query().setDeletedBy_IsNull(); + })); // fileCrawlingConfig - dataSet.put(FILE_CRAWLING_CONFIG_KEY + LIST_SUFFIX, - fileCrawlingConfigBhv.selectList(fileCrawlingConfigCB -> { - fileCrawlingConfigCB.query().setDeletedBy_IsNull(); - })); + dataSet.put(FILE_CRAWLING_CONFIG_KEY + LIST_SUFFIX, fileCrawlingConfigBhv.selectList(fileCrawlingConfigCB -> { + fileCrawlingConfigCB.query().setDeletedBy_IsNull(); + })); // dataCrawlingConfig - dataSet.put(DATA_CRAWLING_CONFIG_KEY + LIST_SUFFIX, - dataCrawlingConfigBhv.selectList(dataCrawlingConfigCB -> { - dataCrawlingConfigCB.query().setDeletedBy_IsNull(); - })); + dataSet.put(DATA_CRAWLING_CONFIG_KEY + LIST_SUFFIX, dataCrawlingConfigBhv.selectList(dataCrawlingConfigCB -> { + dataCrawlingConfigCB.query().setDeletedBy_IsNull(); + })); // pathMapping - dataSet.put(PATH_MAPPING_KEY + LIST_SUFFIX, - pathMappingBhv.selectList(pathMappingCB -> { - pathMappingCB.query().setDeletedBy_IsNull(); - })); + dataSet.put(PATH_MAPPING_KEY + LIST_SUFFIX, pathMappingBhv.selectList(pathMappingCB -> { + pathMappingCB.query().setDeletedBy_IsNull(); + })); // overlappingHost - dataSet.put(OVERLAPPING_HOST_KEY + LIST_SUFFIX, - overlappingHostBhv.selectList(overlappingHostCB -> { - overlappingHostCB.query().setDeletedBy_IsNull(); - })); + dataSet.put(OVERLAPPING_HOST_KEY + LIST_SUFFIX, overlappingHostBhv.selectList(overlappingHostCB -> { + overlappingHostCB.query().setDeletedBy_IsNull(); + })); // webCrawlingConfig - dataSet.put(WEB_CRAWLING_CONFIG_KEY + LIST_SUFFIX, - webCrawlingConfigBhv.selectList(webCrawlingConfigCB -> { - webCrawlingConfigCB.query().setDeletedBy_IsNull(); - })); + dataSet.put(WEB_CRAWLING_CONFIG_KEY + LIST_SUFFIX, webCrawlingConfigBhv.selectList(webCrawlingConfigCB -> { + webCrawlingConfigCB.query().setDeletedBy_IsNull(); + })); // fileConfigToLabelTypeMapping dataSet.put(FILE_CONFIG_TO_LABEL_TYPE_MAPPING_KEY + LIST_SUFFIX, - fileConfigToLabelTypeMappingBhv - .selectList(fileConfigToLabelTypeMappingCB -> { - })); + fileConfigToLabelTypeMappingBhv.selectList(fileConfigToLabelTypeMappingCB -> {})); // dataConfigToLabelTypeMapping dataSet.put(DATA_CONFIG_TO_LABEL_TYPE_MAPPING_KEY + LIST_SUFFIX, - dataConfigToLabelTypeMappingBhv - .selectList(dataConfigToLabelTypeMappingCB -> { - })); + dataConfigToLabelTypeMappingBhv.selectList(dataConfigToLabelTypeMappingCB -> {})); // webConfigToLabelTypeMapping dataSet.put(WEB_CONFIG_TO_LABEL_TYPE_MAPPING_KEY + LIST_SUFFIX, - webConfigToLabelTypeMappingBhv - .selectList(webConfigToLabelTypeMappingCB -> { - })); + webConfigToLabelTypeMappingBhv.selectList(webConfigToLabelTypeMappingCB -> {})); // fileConfigToRoleTypeMapping dataSet.put(FILE_CONFIG_TO_ROLE_TYPE_MAPPING_KEY + LIST_SUFFIX, - fileConfigToRoleTypeMappingBhv - .selectList(fileConfigToRoleTypeMappingCB -> { - })); + fileConfigToRoleTypeMappingBhv.selectList(fileConfigToRoleTypeMappingCB -> {})); // dataConfigToRoleTypeMapping dataSet.put(DATA_CONFIG_TO_ROLE_TYPE_MAPPING_KEY + LIST_SUFFIX, - dataConfigToRoleTypeMappingBhv - .selectList(dataConfigToRoleTypeMappingCB -> { - })); + dataConfigToRoleTypeMappingBhv.selectList(dataConfigToRoleTypeMappingCB -> {})); // webConfigToRoleTypeMapping dataSet.put(WEB_CONFIG_TO_ROLE_TYPE_MAPPING_KEY + LIST_SUFFIX, - webConfigToRoleTypeMappingBhv - .selectList(webConfigToRoleTypeMappingCB -> { - })); + webConfigToRoleTypeMappingBhv.selectList(webConfigToRoleTypeMappingCB -> {})); // webConfigToRoleTypeMapping dataSet.put(LABEL_TYPE_TO_ROLE_TYPE_MAPPING_KEY + LIST_SUFFIX, - labelTypeToRoleTypeMappingBhv - .selectList(labelTypeToRoleTypeMappingCB -> { - })); + labelTypeToRoleTypeMappingBhv.selectList(labelTypeToRoleTypeMappingCB -> {})); // webAuthentication - dataSet.put(WEB_AUTHENTICATION_KEY + LIST_SUFFIX, - webAuthenticationBhv.selectList(webAuthenticationCB -> { - webAuthenticationCB.query().setDeletedBy_IsNull(); - })); + dataSet.put(WEB_AUTHENTICATION_KEY + LIST_SUFFIX, webAuthenticationBhv.selectList(webAuthenticationCB -> { + webAuthenticationCB.query().setDeletedBy_IsNull(); + })); // fileAuthentication - dataSet.put(FILE_AUTHENTICATION_KEY + LIST_SUFFIX, - fileAuthenticationBhv.selectList(fileAuthenticationCB -> { - fileAuthenticationCB.query().setDeletedBy_IsNull(); - })); + dataSet.put(FILE_AUTHENTICATION_KEY + LIST_SUFFIX, fileAuthenticationBhv.selectList(fileAuthenticationCB -> { + fileAuthenticationCB.query().setDeletedBy_IsNull(); + })); // requestHeader - dataSet.put(REQUEST_HEADER_KEY + LIST_SUFFIX, - requestHeaderBhv.selectList(requestHeaderCB -> { - requestHeaderCB.query().setDeletedBy_IsNull(); - })); + dataSet.put(REQUEST_HEADER_KEY + LIST_SUFFIX, requestHeaderBhv.selectList(requestHeaderCB -> { + requestHeaderCB.query().setDeletedBy_IsNull(); + })); // keyMatch - dataSet.put(KEY_MATCH_KEY + LIST_SUFFIX, - keyMatchBhv.selectList(keyMatchCB -> { - keyMatchCB.query().setDeletedBy_IsNull(); - })); + dataSet.put(KEY_MATCH_KEY + LIST_SUFFIX, keyMatchBhv.selectList(keyMatchCB -> { + keyMatchCB.query().setDeletedBy_IsNull(); + })); // boostDocumentRule - dataSet.put(BOOST_DOCUMENT_RULE_KEY + LIST_SUFFIX, - boostDocumentRuleBhv.selectList(boostDocumentRuleCB -> { - boostDocumentRuleCB.query().setDeletedBy_IsNull(); - })); + dataSet.put(BOOST_DOCUMENT_RULE_KEY + LIST_SUFFIX, boostDocumentRuleBhv.selectList(boostDocumentRuleCB -> { + boostDocumentRuleCB.query().setDeletedBy_IsNull(); + })); // suggestElevateWord - dataSet.put(SUGGEST_ELEVATE_WORD_KEY + LIST_SUFFIX, - suggestElevateWordBhv.selectList(suggestElevateWordCB -> { - suggestElevateWordCB.query().setDeletedBy_IsNull(); - })); + dataSet.put(SUGGEST_ELEVATE_WORD_KEY + LIST_SUFFIX, suggestElevateWordBhv.selectList(suggestElevateWordCB -> { + suggestElevateWordCB.query().setDeletedBy_IsNull(); + })); // suggestBadWord - dataSet.put(SUGGEST_BAD_WORD_KEY + LIST_SUFFIX, - suggestBadWordBhv.selectList(suggestBadWordCB -> { - suggestBadWordCB.query().setDeletedBy_IsNull(); - })); + dataSet.put(SUGGEST_BAD_WORD_KEY + LIST_SUFFIX, suggestBadWordBhv.selectList(suggestBadWordCB -> { + suggestBadWordCB.query().setDeletedBy_IsNull(); + })); // crawlerProperties final Map crawlerPropertyMap = new HashMap(); - for (final Map.Entry entry : crawlerProperties - .entrySet()) { + for (final Map.Entry entry : crawlerProperties.entrySet()) { try { - crawlerPropertyMap.put(entry.getKey().toString(), entry - .getValue().toString()); + crawlerPropertyMap.put(entry.getKey().toString(), entry.getValue().toString()); } catch (final Exception e) { - logger.warn("Invalid data. key: " + entry.getKey() - + ", value: " + entry.getValue(), e); + logger.warn("Invalid data. key: " + entry.getKey() + ", value: " + entry.getValue(), e); } } dataSet.put(CRAWLER_PROPERTIES_KEY, crawlerPropertyMap); try { - final XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream( - out)); - final PersistenceDelegate pd = encoder - .getPersistenceDelegate(Date.class); + final XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(out)); + final PersistenceDelegate pd = encoder.getPersistenceDelegate(Date.class); encoder.setPersistenceDelegate(Timestamp.class, pd); encoder.writeObject(dataSet); encoder.close(); @@ -396,8 +361,7 @@ public class DatabaseService { Map dataSet; try { - final XMLDecoder decoder = new XMLDecoder(new BufferedInputStream( - in)); + final XMLDecoder decoder = new XMLDecoder(new BufferedInputStream(in)); dataSet = (Map) decoder.readObject(); } catch (final Exception e) { throw new FessSystemException("Could not read a data set.", e); @@ -419,8 +383,7 @@ public class DatabaseService { protected Map dataSet; - protected DataImporter(final Map dataSet, - final boolean overwrite) { + protected DataImporter(final Map dataSet, final boolean overwrite) { this.dataSet = dataSet; this.overwrite = overwrite; } @@ -433,34 +396,30 @@ public class DatabaseService { try { userTransaction.begin(); - final List scheduledJobList = (List) dataSet - .get(SCHEDULED_JOB_KEY + LIST_SUFFIX); + final List scheduledJobList = (List) dataSet.get(SCHEDULED_JOB_KEY + LIST_SUFFIX); if (scheduledJobList != null) { for (ScheduledJob scheduledJob : scheduledJobList) { final Long id = scheduledJob.getId(); final String name = scheduledJob.getName(); - final ScheduledJob entity = scheduledJobBhv - .selectEntity(cb -> { - cb.query().setName_Equal(name); - cb.query().setDeletedBy_IsNull(); - }).orElse(null);//TODO + final ScheduledJob entity = scheduledJobBhv.selectEntity(cb -> { + cb.query().setName_Equal(name); + cb.query().setDeletedBy_IsNull(); + }).orElse(null);//TODO scheduledJob.setId(null); if (entity == null) { scheduledJobBhv.insert(scheduledJob); } else { if (overwrite) { scheduledJob.setVersionNo(null); - Beans.copy(scheduledJob, entity).excludesNull() - .execute(); + Beans.copy(scheduledJob, entity).excludesNull().execute(); scheduledJob = entity; scheduledJobBhv.update(scheduledJob); } else { scheduledJobBhv.insert(scheduledJob); } } - idMap.put(SCHEDULED_JOB_KEY + ":" + id.toString(), - scheduledJob.getId()); + idMap.put(SCHEDULED_JOB_KEY + ":" + id.toString(), scheduledJob.getId()); } } userTransaction.commit(); @@ -471,18 +430,16 @@ public class DatabaseService { try { userTransaction.begin(); - final List labelTypeList = (List) dataSet - .get(LABEL_TYPE_KEY + LIST_SUFFIX); + final List labelTypeList = (List) dataSet.get(LABEL_TYPE_KEY + LIST_SUFFIX); if (labelTypeList != null) { for (LabelType labelType : labelTypeList) { final Long id = labelType.getId(); final String value = labelType.getValue(); - final LabelType entity = labelTypeBhv.selectEntity( - cb -> { - cb.query().setValue_Equal(value); - cb.query().setDeletedBy_IsNull(); - }).orElse(null);//TODO + final LabelType entity = labelTypeBhv.selectEntity(cb -> { + cb.query().setValue_Equal(value); + cb.query().setDeletedBy_IsNull(); + }).orElse(null);//TODO labelType.setId(null); if (entity == null) { labelTypeBhv.insert(labelType); @@ -490,21 +447,18 @@ public class DatabaseService { // always overwrite // if (overwrite) { labelType.setVersionNo(null); - Beans.copy(labelType, entity).excludesNull() - .execute(); + Beans.copy(labelType, entity).excludesNull().execute(); labelType = entity; labelTypeBhv.update(labelType); // } else { // labelTypeBhv.insert(labelType); // } } - idMap.put(LABEL_TYPE_KEY + ":" + id.toString(), - labelType.getId()); + idMap.put(LABEL_TYPE_KEY + ":" + id.toString(), labelType.getId()); } } // restore labels - final LabelTypeHelper labelTypeHelper = ComponentUtil - .getLabelTypeHelper(); + final LabelTypeHelper labelTypeHelper = ComponentUtil.getLabelTypeHelper(); if (labelTypeHelper != null) { labelTypeHelper.init(); } @@ -516,18 +470,16 @@ public class DatabaseService { try { userTransaction.begin(); - final List roleTypeList = (List) dataSet - .get(ROLE_TYPE_KEY + LIST_SUFFIX); + final List roleTypeList = (List) dataSet.get(ROLE_TYPE_KEY + LIST_SUFFIX); if (roleTypeList != null) { for (RoleType roleType : roleTypeList) { final Long id = roleType.getId(); final String value = roleType.getValue(); - final RoleType entity = roleTypeBhv.selectEntity( - cb -> { - cb.query().setValue_Equal(value); - cb.query().setDeletedBy_IsNull(); - }).orElse(null);//TODO + final RoleType entity = roleTypeBhv.selectEntity(cb -> { + cb.query().setValue_Equal(value); + cb.query().setDeletedBy_IsNull(); + }).orElse(null);//TODO roleType.setId(null); if (entity == null) { roleTypeBhv.insert(roleType); @@ -535,16 +487,14 @@ public class DatabaseService { // always overwrite // if (overwrite) { roleType.setVersionNo(null); - Beans.copy(roleType, entity).excludesNull() - .execute(); + Beans.copy(roleType, entity).excludesNull().execute(); roleType = entity; roleTypeBhv.update(roleType); // } else { // roleTypeBhv.insert(roleType); // } } - idMap.put(ROLE_TYPE_KEY + ":" + id.toString(), - roleType.getId()); + idMap.put(ROLE_TYPE_KEY + ":" + id.toString(), roleType.getId()); } } userTransaction.commit(); @@ -555,36 +505,29 @@ public class DatabaseService { try { userTransaction.begin(); - final List crawlingSessionList = (List) dataSet - .get(CRAWLING_SESSION_KEY + LIST_SUFFIX); + final List crawlingSessionList = (List) dataSet.get(CRAWLING_SESSION_KEY + LIST_SUFFIX); if (crawlingSessionList != null) { for (CrawlingSession crawlingSession : crawlingSessionList) { final Long id = crawlingSession.getId(); final String sessionId = crawlingSession.getSessionId(); - final CrawlingSession entity = crawlingSessionBhv - .selectEntity(cb -> { - cb.query().setSessionId_Equal(sessionId); - }).orElse(null);//TODO + final CrawlingSession entity = crawlingSessionBhv.selectEntity(cb -> { + cb.query().setSessionId_Equal(sessionId); + }).orElse(null);//TODO crawlingSession.setId(null); if (entity == null) { crawlingSessionBhv.insert(crawlingSession); } else { - Beans.copy(crawlingSession, entity).excludesNull() - .execute(); + Beans.copy(crawlingSession, entity).excludesNull().execute(); crawlingSession = entity; crawlingSessionBhv.update(crawlingSession); - final Long crawlingSessionId = crawlingSession - .getId(); + final Long crawlingSessionId = crawlingSession.getId(); // delete info - crawlingSessionInfoBhv.varyingQueryDelete( - cb2 -> { - cb2.query().setCrawlingSessionId_Equal( - crawlingSessionId); - }, op -> op.allowNonQueryDelete()); + crawlingSessionInfoBhv.varyingQueryDelete(cb2 -> { + cb2.query().setCrawlingSessionId_Equal(crawlingSessionId); + }, op -> op.allowNonQueryDelete()); } - idMap.put(CRAWLING_SESSION_KEY + ":" + id.toString(), - crawlingSession.getId()); + idMap.put(CRAWLING_SESSION_KEY + ":" + id.toString(), crawlingSession.getId()); } } userTransaction.commit(); @@ -595,22 +538,17 @@ public class DatabaseService { try { userTransaction.begin(); - final List crawlingSessionInfoList = (List) dataSet - .get(CRAWLING_SESSION_INFO_KEY + LIST_SUFFIX); + final List crawlingSessionInfoList = + (List) dataSet.get(CRAWLING_SESSION_INFO_KEY + LIST_SUFFIX); if (crawlingSessionInfoList != null) { for (final CrawlingSessionInfo crawlingSessionInfo : crawlingSessionInfoList) { final Long id = crawlingSessionInfo.getId(); // relations - crawlingSessionInfo.setCrawlingSessionId(idMap - .get(CRAWLING_SESSION_KEY - + ":" - + crawlingSessionInfo - .getCrawlingSessionId())); + crawlingSessionInfo.setCrawlingSessionId(idMap.get(CRAWLING_SESSION_KEY + ":" + + crawlingSessionInfo.getCrawlingSessionId())); crawlingSessionInfo.setId(null); crawlingSessionInfoBhv.insert(crawlingSessionInfo); - idMap.put( - CRAWLING_SESSION_INFO_KEY + ":" + id.toString(), - crawlingSessionInfo.getId()); + idMap.put(CRAWLING_SESSION_INFO_KEY + ":" + id.toString(), crawlingSessionInfo.getId()); } } userTransaction.commit(); @@ -621,37 +559,31 @@ public class DatabaseService { try { userTransaction.begin(); - final List fileCrawlingConfigList = (List) dataSet - .get(FILE_CRAWLING_CONFIG_KEY + LIST_SUFFIX); + final List fileCrawlingConfigList = + (List) dataSet.get(FILE_CRAWLING_CONFIG_KEY + LIST_SUFFIX); if (fileCrawlingConfigList != null) { for (FileCrawlingConfig fileCrawlingConfig : fileCrawlingConfigList) { final Long id = fileCrawlingConfig.getId(); final String name = fileCrawlingConfig.getName(); - final FileCrawlingConfig entity = fileCrawlingConfigBhv - .selectEntity(cb -> { - cb.query().setName_Equal(name); - cb.query().setDeletedBy_IsNull(); - }).orElse(null);//TODO + final FileCrawlingConfig entity = fileCrawlingConfigBhv.selectEntity(cb -> { + cb.query().setName_Equal(name); + cb.query().setDeletedBy_IsNull(); + }).orElse(null);//TODO fileCrawlingConfig.setId(null); if (entity == null) { fileCrawlingConfigBhv.insert(fileCrawlingConfig); } else { if (overwrite) { fileCrawlingConfig.setVersionNo(null); - Beans.copy(fileCrawlingConfig, entity) - .excludesNull().execute(); + Beans.copy(fileCrawlingConfig, entity).excludesNull().execute(); fileCrawlingConfig = entity; - fileCrawlingConfigBhv - .update(fileCrawlingConfig); + fileCrawlingConfigBhv.update(fileCrawlingConfig); } else { - fileCrawlingConfigBhv - .insert(fileCrawlingConfig); + fileCrawlingConfigBhv.insert(fileCrawlingConfig); } } - idMap.put( - FILE_CRAWLING_CONFIG_KEY + ":" + id.toString(), - fileCrawlingConfig.getId()); + idMap.put(FILE_CRAWLING_CONFIG_KEY + ":" + id.toString(), fileCrawlingConfig.getId()); } } userTransaction.commit(); @@ -662,37 +594,31 @@ public class DatabaseService { try { userTransaction.begin(); - final List dataCrawlingConfigList = (List) dataSet - .get(DATA_CRAWLING_CONFIG_KEY + LIST_SUFFIX); + final List dataCrawlingConfigList = + (List) dataSet.get(DATA_CRAWLING_CONFIG_KEY + LIST_SUFFIX); if (dataCrawlingConfigList != null) { for (DataCrawlingConfig dataCrawlingConfig : dataCrawlingConfigList) { final Long id = dataCrawlingConfig.getId(); final String name = dataCrawlingConfig.getName(); - final DataCrawlingConfig entity = dataCrawlingConfigBhv - .selectEntity(cb -> { - cb.query().setName_Equal(name); - cb.query().setDeletedBy_IsNull(); - }).orElse(null);//TODO + final DataCrawlingConfig entity = dataCrawlingConfigBhv.selectEntity(cb -> { + cb.query().setName_Equal(name); + cb.query().setDeletedBy_IsNull(); + }).orElse(null);//TODO dataCrawlingConfig.setId(null); if (entity == null) { dataCrawlingConfigBhv.insert(dataCrawlingConfig); } else { if (overwrite) { dataCrawlingConfig.setVersionNo(null); - Beans.copy(dataCrawlingConfig, entity) - .excludesNull().execute(); + Beans.copy(dataCrawlingConfig, entity).excludesNull().execute(); dataCrawlingConfig = entity; - dataCrawlingConfigBhv - .update(dataCrawlingConfig); + dataCrawlingConfigBhv.update(dataCrawlingConfig); } else { - dataCrawlingConfigBhv - .insert(dataCrawlingConfig); + dataCrawlingConfigBhv.insert(dataCrawlingConfig); } } - idMap.put( - DATA_CRAWLING_CONFIG_KEY + ":" + id.toString(), - dataCrawlingConfig.getId()); + idMap.put(DATA_CRAWLING_CONFIG_KEY + ":" + id.toString(), dataCrawlingConfig.getId()); } } userTransaction.commit(); @@ -703,18 +629,16 @@ public class DatabaseService { try { userTransaction.begin(); - final List pathMappingList = (List) dataSet - .get(PATH_MAPPING_KEY + LIST_SUFFIX); + final List pathMappingList = (List) dataSet.get(PATH_MAPPING_KEY + LIST_SUFFIX); if (pathMappingList != null) { for (PathMapping pathMapping : pathMappingList) { final Long id = pathMapping.getId(); final String regex = pathMapping.getRegex(); - final PathMapping entity = pathMappingBhv.selectEntity( - cb -> { - cb.query().setRegex_Equal(regex); - cb.query().setDeletedBy_IsNull(); - }).orElse(null);//TODO + final PathMapping entity = pathMappingBhv.selectEntity(cb -> { + cb.query().setRegex_Equal(regex); + cb.query().setDeletedBy_IsNull(); + }).orElse(null);//TODO pathMapping.setId(null); if (pathMapping.getProcessType() == null) { pathMapping.setProcessType_Crawling(); @@ -724,16 +648,14 @@ public class DatabaseService { } else { if (overwrite) { pathMapping.setVersionNo(null); - Beans.copy(pathMapping, entity).excludesNull() - .execute(); + Beans.copy(pathMapping, entity).excludesNull().execute(); pathMapping = entity; pathMappingBhv.update(pathMapping); } else { pathMappingBhv.insert(pathMapping); } } - idMap.put(PATH_MAPPING_KEY + ":" + id.toString(), - pathMapping.getId()); + idMap.put(PATH_MAPPING_KEY + ":" + id.toString(), pathMapping.getId()); } } userTransaction.commit(); @@ -744,42 +666,32 @@ public class DatabaseService { try { userTransaction.begin(); - final List overlappingHostList = (List) dataSet - .get(OVERLAPPING_HOST_KEY + LIST_SUFFIX); + final List overlappingHostList = (List) dataSet.get(OVERLAPPING_HOST_KEY + LIST_SUFFIX); if (overlappingHostList != null) { for (OverlappingHost overlappingHost : overlappingHostList) { final Long id = overlappingHost.getId(); - final String regularName = overlappingHost - .getRegularName(); - final String overlappingName = overlappingHost - .getOverlappingName(); - final OverlappingHost entity = overlappingHostBhv - .selectEntity( - cb -> { - cb.query().setRegularName_Equal( - regularName); - cb.query() - .setOverlappingName_Equal( - overlappingName); - cb.query().setDeletedBy_IsNull(); - }).orElse(null);//TODO + final String regularName = overlappingHost.getRegularName(); + final String overlappingName = overlappingHost.getOverlappingName(); + final OverlappingHost entity = overlappingHostBhv.selectEntity(cb -> { + cb.query().setRegularName_Equal(regularName); + cb.query().setOverlappingName_Equal(overlappingName); + cb.query().setDeletedBy_IsNull(); + }).orElse(null);//TODO overlappingHost.setId(null); if (entity == null) { overlappingHostBhv.insert(overlappingHost); } else { if (overwrite) { overlappingHost.setVersionNo(null); - Beans.copy(overlappingHost, entity) - .excludesNull().execute(); + Beans.copy(overlappingHost, entity).excludesNull().execute(); overlappingHost = entity; overlappingHostBhv.update(overlappingHost); } else { overlappingHostBhv.insert(overlappingHost); } } - idMap.put(OVERLAPPING_HOST_KEY + ":" + id.toString(), - overlappingHost.getId()); + idMap.put(OVERLAPPING_HOST_KEY + ":" + id.toString(), overlappingHost.getId()); } } userTransaction.commit(); @@ -790,35 +702,31 @@ public class DatabaseService { try { userTransaction.begin(); - final List webCrawlingConfigList = (List) dataSet - .get(WEB_CRAWLING_CONFIG_KEY + LIST_SUFFIX); + final List webCrawlingConfigList = + (List) dataSet.get(WEB_CRAWLING_CONFIG_KEY + LIST_SUFFIX); if (webCrawlingConfigList != null) { for (WebCrawlingConfig webCrawlingConfig : webCrawlingConfigList) { final Long id = webCrawlingConfig.getId(); final String name = webCrawlingConfig.getName(); - final WebCrawlingConfig entity = webCrawlingConfigBhv - .selectEntity(cb -> { - cb.query().setName_Equal(name); - cb.query().setDeletedBy_IsNull(); - }).orElse(null);//TODO + final WebCrawlingConfig entity = webCrawlingConfigBhv.selectEntity(cb -> { + cb.query().setName_Equal(name); + cb.query().setDeletedBy_IsNull(); + }).orElse(null);//TODO webCrawlingConfig.setId(null); if (entity == null) { webCrawlingConfigBhv.insert(webCrawlingConfig); } else { if (overwrite) { webCrawlingConfig.setVersionNo(null); - Beans.copy(webCrawlingConfig, entity) - .excludesNull().execute(); + Beans.copy(webCrawlingConfig, entity).excludesNull().execute(); webCrawlingConfig = entity; webCrawlingConfigBhv.update(webCrawlingConfig); } else { webCrawlingConfigBhv.insert(webCrawlingConfig); } } - idMap.put( - WEB_CRAWLING_CONFIG_KEY + ":" + id.toString(), - webCrawlingConfig.getId()); + idMap.put(WEB_CRAWLING_CONFIG_KEY + ":" + id.toString(), webCrawlingConfig.getId()); } } userTransaction.commit(); @@ -829,48 +737,31 @@ public class DatabaseService { try { userTransaction.begin(); - final List fileConfigToLabelTypeMappingList = (List) dataSet - .get(FILE_CONFIG_TO_LABEL_TYPE_MAPPING_KEY - + LIST_SUFFIX); + final List fileConfigToLabelTypeMappingList = + (List) dataSet.get(FILE_CONFIG_TO_LABEL_TYPE_MAPPING_KEY + LIST_SUFFIX); if (fileConfigToLabelTypeMappingList != null) { for (FileConfigToLabelTypeMapping fileConfigToLabelTypeMapping : fileConfigToLabelTypeMappingList) { final Long id = fileConfigToLabelTypeMapping.getId(); - final Long labelTypeId = idMap - .get(LABEL_TYPE_KEY - + ":" - + fileConfigToLabelTypeMapping - .getLabelTypeId()); - final Long fileConfigId = idMap - .get(FILE_CRAWLING_CONFIG_KEY - + ":" - + fileConfigToLabelTypeMapping - .getFileConfigId()); + final Long labelTypeId = idMap.get(LABEL_TYPE_KEY + ":" + fileConfigToLabelTypeMapping.getLabelTypeId()); + final Long fileConfigId = + idMap.get(FILE_CRAWLING_CONFIG_KEY + ":" + fileConfigToLabelTypeMapping.getFileConfigId()); if (labelTypeId == null || fileConfigId == null) { // skip continue; } - final FileConfigToLabelTypeMapping entity = fileConfigToLabelTypeMappingBhv - .selectEntity( - cb -> { - cb.query().setLabelTypeId_Equal( - labelTypeId); - cb.query().setFileConfigId_Equal( - fileConfigId); - }).orElse(null);//TODO + final FileConfigToLabelTypeMapping entity = fileConfigToLabelTypeMappingBhv.selectEntity(cb -> { + cb.query().setLabelTypeId_Equal(labelTypeId); + cb.query().setFileConfigId_Equal(fileConfigId); + }).orElse(null);//TODO if (entity == null) { fileConfigToLabelTypeMapping = new FileConfigToLabelTypeMapping(); - fileConfigToLabelTypeMapping - .setLabelTypeId(labelTypeId); - fileConfigToLabelTypeMapping - .setFileConfigId(fileConfigId); - fileConfigToLabelTypeMappingBhv - .insert(fileConfigToLabelTypeMapping); + fileConfigToLabelTypeMapping.setLabelTypeId(labelTypeId); + fileConfigToLabelTypeMapping.setFileConfigId(fileConfigId); + fileConfigToLabelTypeMappingBhv.insert(fileConfigToLabelTypeMapping); } - idMap.put(FILE_CONFIG_TO_LABEL_TYPE_MAPPING_KEY + ":" - + id.toString(), - fileConfigToLabelTypeMapping.getId()); + idMap.put(FILE_CONFIG_TO_LABEL_TYPE_MAPPING_KEY + ":" + id.toString(), fileConfigToLabelTypeMapping.getId()); } } userTransaction.commit(); @@ -881,48 +772,31 @@ public class DatabaseService { try { userTransaction.begin(); - final List dataConfigToLabelTypeMappingList = (List) dataSet - .get(DATA_CONFIG_TO_LABEL_TYPE_MAPPING_KEY - + LIST_SUFFIX); + final List dataConfigToLabelTypeMappingList = + (List) dataSet.get(DATA_CONFIG_TO_LABEL_TYPE_MAPPING_KEY + LIST_SUFFIX); if (dataConfigToLabelTypeMappingList != null) { for (DataConfigToLabelTypeMapping dataConfigToLabelTypeMapping : dataConfigToLabelTypeMappingList) { final Long id = dataConfigToLabelTypeMapping.getId(); - final Long labelTypeId = idMap - .get(LABEL_TYPE_KEY - + ":" - + dataConfigToLabelTypeMapping - .getLabelTypeId()); - final Long dataConfigId = idMap - .get(DATA_CRAWLING_CONFIG_KEY - + ":" - + dataConfigToLabelTypeMapping - .getDataConfigId()); + final Long labelTypeId = idMap.get(LABEL_TYPE_KEY + ":" + dataConfigToLabelTypeMapping.getLabelTypeId()); + final Long dataConfigId = + idMap.get(DATA_CRAWLING_CONFIG_KEY + ":" + dataConfigToLabelTypeMapping.getDataConfigId()); if (labelTypeId == null || dataConfigId == null) { // skip continue; } - final DataConfigToLabelTypeMapping entity = dataConfigToLabelTypeMappingBhv - .selectEntity( - cb -> { - cb.query().setLabelTypeId_Equal( - labelTypeId); - cb.query().setDataConfigId_Equal( - dataConfigId); - }).orElse(null);//TODO + final DataConfigToLabelTypeMapping entity = dataConfigToLabelTypeMappingBhv.selectEntity(cb -> { + cb.query().setLabelTypeId_Equal(labelTypeId); + cb.query().setDataConfigId_Equal(dataConfigId); + }).orElse(null);//TODO if (entity == null) { dataConfigToLabelTypeMapping = new DataConfigToLabelTypeMapping(); - dataConfigToLabelTypeMapping - .setLabelTypeId(labelTypeId); - dataConfigToLabelTypeMapping - .setDataConfigId(dataConfigId); - dataConfigToLabelTypeMappingBhv - .insert(dataConfigToLabelTypeMapping); + dataConfigToLabelTypeMapping.setLabelTypeId(labelTypeId); + dataConfigToLabelTypeMapping.setDataConfigId(dataConfigId); + dataConfigToLabelTypeMappingBhv.insert(dataConfigToLabelTypeMapping); } - idMap.put(DATA_CONFIG_TO_LABEL_TYPE_MAPPING_KEY + ":" - + id.toString(), - dataConfigToLabelTypeMapping.getId()); + idMap.put(DATA_CONFIG_TO_LABEL_TYPE_MAPPING_KEY + ":" + id.toString(), dataConfigToLabelTypeMapping.getId()); } } userTransaction.commit(); @@ -933,44 +807,30 @@ public class DatabaseService { try { userTransaction.begin(); - final List webConfigToLabelTypeMappingList = (List) dataSet - .get(WEB_CONFIG_TO_LABEL_TYPE_MAPPING_KEY + LIST_SUFFIX); + final List webConfigToLabelTypeMappingList = + (List) dataSet.get(WEB_CONFIG_TO_LABEL_TYPE_MAPPING_KEY + LIST_SUFFIX); if (webConfigToLabelTypeMappingList != null) { for (WebConfigToLabelTypeMapping webConfigToLabelTypeMapping : webConfigToLabelTypeMappingList) { final Long id = webConfigToLabelTypeMapping.getId(); - final Long labelTypeId = idMap.get(LABEL_TYPE_KEY + ":" - + webConfigToLabelTypeMapping.getLabelTypeId()); - final Long webConfigId = idMap - .get(WEB_CRAWLING_CONFIG_KEY - + ":" - + webConfigToLabelTypeMapping - .getWebConfigId()); + final Long labelTypeId = idMap.get(LABEL_TYPE_KEY + ":" + webConfigToLabelTypeMapping.getLabelTypeId()); + final Long webConfigId = idMap.get(WEB_CRAWLING_CONFIG_KEY + ":" + webConfigToLabelTypeMapping.getWebConfigId()); if (labelTypeId == null || webConfigId == null) { // skip continue; } - final WebConfigToLabelTypeMapping entity = webConfigToLabelTypeMappingBhv - .selectEntity( - cb -> { - cb.query().setLabelTypeId_Equal( - labelTypeId); - cb.query().setWebConfigId_Equal( - webConfigId); - }).orElse(null);//TODO + final WebConfigToLabelTypeMapping entity = webConfigToLabelTypeMappingBhv.selectEntity(cb -> { + cb.query().setLabelTypeId_Equal(labelTypeId); + cb.query().setWebConfigId_Equal(webConfigId); + }).orElse(null);//TODO if (entity == null) { webConfigToLabelTypeMapping = new WebConfigToLabelTypeMapping(); - webConfigToLabelTypeMapping - .setLabelTypeId(labelTypeId); - webConfigToLabelTypeMapping - .setWebConfigId(webConfigId); - webConfigToLabelTypeMappingBhv - .insert(webConfigToLabelTypeMapping); + webConfigToLabelTypeMapping.setLabelTypeId(labelTypeId); + webConfigToLabelTypeMapping.setWebConfigId(webConfigId); + webConfigToLabelTypeMappingBhv.insert(webConfigToLabelTypeMapping); } - idMap.put(WEB_CONFIG_TO_LABEL_TYPE_MAPPING_KEY + ":" - + id.toString(), - webConfigToLabelTypeMapping.getId()); + idMap.put(WEB_CONFIG_TO_LABEL_TYPE_MAPPING_KEY + ":" + id.toString(), webConfigToLabelTypeMapping.getId()); } } userTransaction.commit(); @@ -981,44 +841,30 @@ public class DatabaseService { try { userTransaction.begin(); - final List fileConfigToRoleTypeMappingList = (List) dataSet - .get(FILE_CONFIG_TO_ROLE_TYPE_MAPPING_KEY + LIST_SUFFIX); + final List fileConfigToRoleTypeMappingList = + (List) dataSet.get(FILE_CONFIG_TO_ROLE_TYPE_MAPPING_KEY + LIST_SUFFIX); if (fileConfigToRoleTypeMappingList != null) { for (FileConfigToRoleTypeMapping fileConfigToRoleTypeMapping : fileConfigToRoleTypeMappingList) { final Long id = fileConfigToRoleTypeMapping.getId(); - final Long roleTypeId = idMap.get(ROLE_TYPE_KEY + ":" - + fileConfigToRoleTypeMapping.getRoleTypeId()); - final Long fileConfigId = idMap - .get(FILE_CRAWLING_CONFIG_KEY - + ":" - + fileConfigToRoleTypeMapping - .getFileConfigId()); + final Long roleTypeId = idMap.get(ROLE_TYPE_KEY + ":" + fileConfigToRoleTypeMapping.getRoleTypeId()); + final Long fileConfigId = idMap.get(FILE_CRAWLING_CONFIG_KEY + ":" + fileConfigToRoleTypeMapping.getFileConfigId()); if (roleTypeId == null || fileConfigId == null) { // skip continue; } - final FileConfigToRoleTypeMapping entity = fileConfigToRoleTypeMappingBhv - .selectEntity( - cb -> { - cb.query().setRoleTypeId_Equal( - roleTypeId); - cb.query().setFileConfigId_Equal( - fileConfigId); - }).orElse(null);//TODO + final FileConfigToRoleTypeMapping entity = fileConfigToRoleTypeMappingBhv.selectEntity(cb -> { + cb.query().setRoleTypeId_Equal(roleTypeId); + cb.query().setFileConfigId_Equal(fileConfigId); + }).orElse(null);//TODO if (entity == null) { fileConfigToRoleTypeMapping = new FileConfigToRoleTypeMapping(); - fileConfigToRoleTypeMapping - .setRoleTypeId(roleTypeId); - fileConfigToRoleTypeMapping - .setFileConfigId(fileConfigId); - fileConfigToRoleTypeMappingBhv - .insert(fileConfigToRoleTypeMapping); + fileConfigToRoleTypeMapping.setRoleTypeId(roleTypeId); + fileConfigToRoleTypeMapping.setFileConfigId(fileConfigId); + fileConfigToRoleTypeMappingBhv.insert(fileConfigToRoleTypeMapping); } - idMap.put(FILE_CONFIG_TO_ROLE_TYPE_MAPPING_KEY + ":" - + id.toString(), - fileConfigToRoleTypeMapping.getId()); + idMap.put(FILE_CONFIG_TO_ROLE_TYPE_MAPPING_KEY + ":" + id.toString(), fileConfigToRoleTypeMapping.getId()); } } userTransaction.commit(); @@ -1029,44 +875,30 @@ public class DatabaseService { try { userTransaction.begin(); - final List dataConfigToRoleTypeMappingList = (List) dataSet - .get(DATA_CONFIG_TO_ROLE_TYPE_MAPPING_KEY + LIST_SUFFIX); + final List dataConfigToRoleTypeMappingList = + (List) dataSet.get(DATA_CONFIG_TO_ROLE_TYPE_MAPPING_KEY + LIST_SUFFIX); if (dataConfigToRoleTypeMappingList != null) { for (DataConfigToRoleTypeMapping dataConfigToRoleTypeMapping : dataConfigToRoleTypeMappingList) { final Long id = dataConfigToRoleTypeMapping.getId(); - final Long roleTypeId = idMap.get(ROLE_TYPE_KEY + ":" - + dataConfigToRoleTypeMapping.getRoleTypeId()); - final Long dataConfigId = idMap - .get(DATA_CRAWLING_CONFIG_KEY - + ":" - + dataConfigToRoleTypeMapping - .getDataConfigId()); + final Long roleTypeId = idMap.get(ROLE_TYPE_KEY + ":" + dataConfigToRoleTypeMapping.getRoleTypeId()); + final Long dataConfigId = idMap.get(DATA_CRAWLING_CONFIG_KEY + ":" + dataConfigToRoleTypeMapping.getDataConfigId()); if (roleTypeId == null || dataConfigId == null) { // skip continue; } - final DataConfigToRoleTypeMapping entity = dataConfigToRoleTypeMappingBhv - .selectEntity( - cb -> { - cb.query().setRoleTypeId_Equal( - roleTypeId); - cb.query().setDataConfigId_Equal( - dataConfigId); - }).orElse(null);//TODO + final DataConfigToRoleTypeMapping entity = dataConfigToRoleTypeMappingBhv.selectEntity(cb -> { + cb.query().setRoleTypeId_Equal(roleTypeId); + cb.query().setDataConfigId_Equal(dataConfigId); + }).orElse(null);//TODO if (entity == null) { dataConfigToRoleTypeMapping = new DataConfigToRoleTypeMapping(); - dataConfigToRoleTypeMapping - .setRoleTypeId(roleTypeId); - dataConfigToRoleTypeMapping - .setDataConfigId(dataConfigId); - dataConfigToRoleTypeMappingBhv - .insert(dataConfigToRoleTypeMapping); + dataConfigToRoleTypeMapping.setRoleTypeId(roleTypeId); + dataConfigToRoleTypeMapping.setDataConfigId(dataConfigId); + dataConfigToRoleTypeMappingBhv.insert(dataConfigToRoleTypeMapping); } - idMap.put(DATA_CONFIG_TO_ROLE_TYPE_MAPPING_KEY + ":" - + id.toString(), - dataConfigToRoleTypeMapping.getId()); + idMap.put(DATA_CONFIG_TO_ROLE_TYPE_MAPPING_KEY + ":" + id.toString(), dataConfigToRoleTypeMapping.getId()); } } userTransaction.commit(); @@ -1077,44 +909,30 @@ public class DatabaseService { try { userTransaction.begin(); - final List webConfigToRoleTypeMappingList = (List) dataSet - .get(WEB_CONFIG_TO_ROLE_TYPE_MAPPING_KEY + LIST_SUFFIX); + final List webConfigToRoleTypeMappingList = + (List) dataSet.get(WEB_CONFIG_TO_ROLE_TYPE_MAPPING_KEY + LIST_SUFFIX); if (webConfigToRoleTypeMappingList != null) { for (WebConfigToRoleTypeMapping webConfigToRoleTypeMapping : webConfigToRoleTypeMappingList) { final Long id = webConfigToRoleTypeMapping.getId(); - final Long roleTypeId = idMap.get(ROLE_TYPE_KEY + ":" - + webConfigToRoleTypeMapping.getRoleTypeId()); - final Long webConfigId = idMap - .get(WEB_CRAWLING_CONFIG_KEY - + ":" - + webConfigToRoleTypeMapping - .getWebConfigId()); + final Long roleTypeId = idMap.get(ROLE_TYPE_KEY + ":" + webConfigToRoleTypeMapping.getRoleTypeId()); + final Long webConfigId = idMap.get(WEB_CRAWLING_CONFIG_KEY + ":" + webConfigToRoleTypeMapping.getWebConfigId()); if (roleTypeId == null || webConfigId == null) { // skip continue; } - final WebConfigToRoleTypeMapping entity = webConfigToRoleTypeMappingBhv - .selectEntity( - cb -> { - cb.query().setRoleTypeId_Equal( - roleTypeId); - cb.query().setWebConfigId_Equal( - webConfigId); - }).orElse(null);//TODO + final WebConfigToRoleTypeMapping entity = webConfigToRoleTypeMappingBhv.selectEntity(cb -> { + cb.query().setRoleTypeId_Equal(roleTypeId); + cb.query().setWebConfigId_Equal(webConfigId); + }).orElse(null);//TODO if (entity == null) { webConfigToRoleTypeMapping = new WebConfigToRoleTypeMapping(); - webConfigToRoleTypeMapping - .setRoleTypeId(roleTypeId); - webConfigToRoleTypeMapping - .setWebConfigId(webConfigId); - webConfigToRoleTypeMappingBhv - .insert(webConfigToRoleTypeMapping); + webConfigToRoleTypeMapping.setRoleTypeId(roleTypeId); + webConfigToRoleTypeMapping.setWebConfigId(webConfigId); + webConfigToRoleTypeMappingBhv.insert(webConfigToRoleTypeMapping); } - idMap.put(WEB_CONFIG_TO_ROLE_TYPE_MAPPING_KEY + ":" - + id.toString(), - webConfigToRoleTypeMapping.getId()); + idMap.put(WEB_CONFIG_TO_ROLE_TYPE_MAPPING_KEY + ":" + id.toString(), webConfigToRoleTypeMapping.getId()); } } userTransaction.commit(); @@ -1125,41 +943,30 @@ public class DatabaseService { try { userTransaction.begin(); - final List labelTypeToRoleTypeMappingList = (List) dataSet - .get(LABEL_TYPE_TO_ROLE_TYPE_MAPPING_KEY + LIST_SUFFIX); + final List labelTypeToRoleTypeMappingList = + (List) dataSet.get(LABEL_TYPE_TO_ROLE_TYPE_MAPPING_KEY + LIST_SUFFIX); if (labelTypeToRoleTypeMappingList != null) { for (LabelTypeToRoleTypeMapping labelTypeToRoleTypeMapping : labelTypeToRoleTypeMappingList) { final Long id = labelTypeToRoleTypeMapping.getId(); - final Long roleTypeId = idMap.get(ROLE_TYPE_KEY + ":" - + labelTypeToRoleTypeMapping.getRoleTypeId()); - final Long labelTypeId = idMap.get(LABEL_TYPE_KEY + ":" - + labelTypeToRoleTypeMapping.getLabelTypeId()); + final Long roleTypeId = idMap.get(ROLE_TYPE_KEY + ":" + labelTypeToRoleTypeMapping.getRoleTypeId()); + final Long labelTypeId = idMap.get(LABEL_TYPE_KEY + ":" + labelTypeToRoleTypeMapping.getLabelTypeId()); if (roleTypeId == null || labelTypeId == null) { // skip continue; } - final LabelTypeToRoleTypeMapping entity = labelTypeToRoleTypeMappingBhv - .selectEntity( - cb -> { - cb.query().setRoleTypeId_Equal( - roleTypeId); - cb.query().setLabelTypeId_Equal( - labelTypeId); - }).orElse(null);//TODO + final LabelTypeToRoleTypeMapping entity = labelTypeToRoleTypeMappingBhv.selectEntity(cb -> { + cb.query().setRoleTypeId_Equal(roleTypeId); + cb.query().setLabelTypeId_Equal(labelTypeId); + }).orElse(null);//TODO if (entity == null) { labelTypeToRoleTypeMapping = new LabelTypeToRoleTypeMapping(); - labelTypeToRoleTypeMapping - .setRoleTypeId(roleTypeId); - labelTypeToRoleTypeMapping - .setLabelTypeId(labelTypeId); - labelTypeToRoleTypeMappingBhv - .insert(labelTypeToRoleTypeMapping); + labelTypeToRoleTypeMapping.setRoleTypeId(roleTypeId); + labelTypeToRoleTypeMapping.setLabelTypeId(labelTypeId); + labelTypeToRoleTypeMappingBhv.insert(labelTypeToRoleTypeMapping); } - idMap.put(LABEL_TYPE_TO_ROLE_TYPE_MAPPING_KEY + ":" - + id.toString(), - labelTypeToRoleTypeMapping.getId()); + idMap.put(LABEL_TYPE_TO_ROLE_TYPE_MAPPING_KEY + ":" + id.toString(), labelTypeToRoleTypeMapping.getId()); } } userTransaction.commit(); @@ -1170,42 +977,28 @@ public class DatabaseService { try { userTransaction.begin(); - final List webAuthenticationList = (List) dataSet - .get(WEB_AUTHENTICATION_KEY + LIST_SUFFIX); + final List webAuthenticationList = + (List) dataSet.get(WEB_AUTHENTICATION_KEY + LIST_SUFFIX); if (webAuthenticationList != null) { for (WebAuthentication webAuthentication : webAuthenticationList) { final Long id = webAuthentication.getId(); - final Long webConfigId = idMap - .get(WEB_CRAWLING_CONFIG_KEY - + ":" - + webAuthentication - .getWebCrawlingConfigId()); + final Long webConfigId = idMap.get(WEB_CRAWLING_CONFIG_KEY + ":" + webAuthentication.getWebCrawlingConfigId()); if (webConfigId == null) { // skip continue; } WebAuthentication entity = null; - final List list = webAuthenticationBhv - .selectList(cb -> { - cb.query().setWebCrawlingConfigId_Equal( - webConfigId); - cb.query().setDeletedBy_IsNull(); - }); + final List list = webAuthenticationBhv.selectList(cb -> { + cb.query().setWebCrawlingConfigId_Equal(webConfigId); + cb.query().setDeletedBy_IsNull(); + }); for (final WebAuthentication e : list) { - if (StringUtil.equals( - webAuthentication.getAuthRealm(), - e.getAuthRealm()) - && StringUtil.equals( - webAuthentication.getHostname(), - e.getHostname()) - && StringUtil.equals(webAuthentication - .getProtocolScheme(), e - .getProtocolScheme()) - && equalusNumber( - webAuthentication.getPort(), - e.getPort())) { + if (StringUtil.equals(webAuthentication.getAuthRealm(), e.getAuthRealm()) + && StringUtil.equals(webAuthentication.getHostname(), e.getHostname()) + && StringUtil.equals(webAuthentication.getProtocolScheme(), e.getProtocolScheme()) + && equalusNumber(webAuthentication.getPort(), e.getPort())) { entity = e; } } @@ -1216,16 +1009,14 @@ public class DatabaseService { } else { if (overwrite) { webAuthentication.setVersionNo(null); - Beans.copy(webAuthentication, entity) - .excludesNull().execute(); + Beans.copy(webAuthentication, entity).excludesNull().execute(); webAuthentication = entity; webAuthenticationBhv.update(webAuthentication); } else { webAuthenticationBhv.insert(webAuthentication); } } - idMap.put(WEB_AUTHENTICATION_KEY + ":" + id.toString(), - webAuthentication.getId()); + idMap.put(WEB_AUTHENTICATION_KEY + ":" + id.toString(), webAuthentication.getId()); } } userTransaction.commit(); @@ -1236,63 +1027,45 @@ public class DatabaseService { try { userTransaction.begin(); - final List fileAuthenticationList = (List) dataSet - .get(FILE_AUTHENTICATION_KEY + LIST_SUFFIX); + final List fileAuthenticationList = + (List) dataSet.get(FILE_AUTHENTICATION_KEY + LIST_SUFFIX); if (fileAuthenticationList != null) { for (FileAuthentication fileAuthentication : fileAuthenticationList) { final Long id = fileAuthentication.getId(); - final Long fileConfigId = idMap - .get(FILE_CRAWLING_CONFIG_KEY - + ":" - + fileAuthentication - .getFileCrawlingConfigId()); + final Long fileConfigId = idMap.get(FILE_CRAWLING_CONFIG_KEY + ":" + fileAuthentication.getFileCrawlingConfigId()); if (fileConfigId == null) { // skip continue; } FileAuthentication entity = null; - final List list = fileAuthenticationBhv - .selectList(cb -> { - cb.query().setFileCrawlingConfigId_Equal( - fileConfigId); - cb.query().setDeletedBy_IsNull(); - }); + final List list = fileAuthenticationBhv.selectList(cb -> { + cb.query().setFileCrawlingConfigId_Equal(fileConfigId); + cb.query().setDeletedBy_IsNull(); + }); for (final FileAuthentication e : list) { - if (StringUtil.equals( - fileAuthentication.getHostname(), - e.getHostname()) - && StringUtil.equals(fileAuthentication - .getProtocolScheme(), e - .getProtocolScheme()) - && equalusNumber( - fileAuthentication.getPort(), - e.getPort())) { + if (StringUtil.equals(fileAuthentication.getHostname(), e.getHostname()) + && StringUtil.equals(fileAuthentication.getProtocolScheme(), e.getProtocolScheme()) + && equalusNumber(fileAuthentication.getPort(), e.getPort())) { entity = e; } } fileAuthentication.setId(null); - fileAuthentication - .setFileCrawlingConfigId(fileConfigId); + fileAuthentication.setFileCrawlingConfigId(fileConfigId); if (entity == null) { fileAuthenticationBhv.insert(fileAuthentication); } else { if (overwrite) { fileAuthentication.setVersionNo(null); - Beans.copy(fileAuthentication, entity) - .excludesNull().execute(); + Beans.copy(fileAuthentication, entity).excludesNull().execute(); fileAuthentication = entity; - fileAuthenticationBhv - .update(fileAuthentication); + fileAuthenticationBhv.update(fileAuthentication); } else { - fileAuthenticationBhv - .insert(fileAuthentication); + fileAuthenticationBhv.insert(fileAuthentication); } } - idMap.put( - FILE_AUTHENTICATION_KEY + ":" + id.toString(), - fileAuthentication.getId()); + idMap.put(FILE_AUTHENTICATION_KEY + ":" + id.toString(), fileAuthentication.getId()); } } userTransaction.commit(); @@ -1303,32 +1076,24 @@ public class DatabaseService { try { userTransaction.begin(); - final List requestHeaderList = (List) dataSet - .get(REQUEST_HEADER_KEY + LIST_SUFFIX); + final List requestHeaderList = (List) dataSet.get(REQUEST_HEADER_KEY + LIST_SUFFIX); if (requestHeaderList != null) { for (RequestHeader requestHeader : requestHeaderList) { final Long id = requestHeader.getId(); - final Long webConfigId = idMap - .get(WEB_CRAWLING_CONFIG_KEY - + ":" - + requestHeader - .getWebCrawlingConfigId()); + final Long webConfigId = idMap.get(WEB_CRAWLING_CONFIG_KEY + ":" + requestHeader.getWebCrawlingConfigId()); if (webConfigId == null) { // skip continue; } RequestHeader entity = null; - final List list = requestHeaderBhv - .selectList(cb -> { - cb.query().setWebCrawlingConfigId_Equal( - webConfigId); - cb.query().setDeletedBy_IsNull(); - }); + final List list = requestHeaderBhv.selectList(cb -> { + cb.query().setWebCrawlingConfigId_Equal(webConfigId); + cb.query().setDeletedBy_IsNull(); + }); for (final RequestHeader e : list) { - if (StringUtil.equals(requestHeader.getName(), - e.getName())) { + if (StringUtil.equals(requestHeader.getName(), e.getName())) { entity = e; } } @@ -1339,16 +1104,14 @@ public class DatabaseService { } else { if (overwrite) { requestHeader.setVersionNo(null); - Beans.copy(requestHeader, entity) - .excludesNull().execute(); + Beans.copy(requestHeader, entity).excludesNull().execute(); requestHeader = entity; requestHeaderBhv.update(requestHeader); } else { requestHeaderBhv.insert(requestHeader); } } - idMap.put(REQUEST_HEADER_KEY + ":" + id.toString(), - requestHeader.getId()); + idMap.put(REQUEST_HEADER_KEY + ":" + id.toString(), requestHeader.getId()); } } userTransaction.commit(); @@ -1359,33 +1122,29 @@ public class DatabaseService { try { userTransaction.begin(); - final List keyMatchList = (List) dataSet - .get(KEY_MATCH_KEY + LIST_SUFFIX); + final List keyMatchList = (List) dataSet.get(KEY_MATCH_KEY + LIST_SUFFIX); if (keyMatchList != null) { for (KeyMatch keyMatch : keyMatchList) { final Long id = keyMatch.getId(); final String term = keyMatch.getTerm(); - final KeyMatch entity = keyMatchBhv.selectEntity( - cb -> { - cb.query().setTerm_Equal(term); - }).orElse(null);//TODO + final KeyMatch entity = keyMatchBhv.selectEntity(cb -> { + cb.query().setTerm_Equal(term); + }).orElse(null);//TODO keyMatch.setId(null); if (entity == null) { keyMatchBhv.insert(keyMatch); } else { if (overwrite) { keyMatch.setVersionNo(null); - Beans.copy(keyMatch, entity).excludesNull() - .execute(); + Beans.copy(keyMatch, entity).excludesNull().execute(); keyMatch = entity; keyMatchBhv.update(keyMatch); } else { keyMatchBhv.insert(keyMatch); } } - idMap.put(KEY_MATCH_KEY + ":" + id.toString(), - keyMatch.getId()); + idMap.put(KEY_MATCH_KEY + ":" + id.toString(), keyMatch.getId()); } } userTransaction.commit(); @@ -1396,34 +1155,30 @@ public class DatabaseService { try { userTransaction.begin(); - final List boostDocumentRuleList = (List) dataSet - .get(BOOST_DOCUMENT_RULE_KEY + LIST_SUFFIX); + final List boostDocumentRuleList = + (List) dataSet.get(BOOST_DOCUMENT_RULE_KEY + LIST_SUFFIX); if (boostDocumentRuleList != null) { for (BoostDocumentRule boostDocumentRule : boostDocumentRuleList) { final Long id = boostDocumentRule.getId(); final String urlExpr = boostDocumentRule.getUrlExpr(); - final BoostDocumentRule entity = boostDocumentRuleBhv - .selectEntity(cb -> { - cb.query().setUrlExpr_Equal(urlExpr); - }).orElse(null);//TODO + final BoostDocumentRule entity = boostDocumentRuleBhv.selectEntity(cb -> { + cb.query().setUrlExpr_Equal(urlExpr); + }).orElse(null);//TODO boostDocumentRule.setId(null); if (entity == null) { boostDocumentRuleBhv.insert(boostDocumentRule); } else { if (overwrite) { boostDocumentRule.setVersionNo(null); - Beans.copy(boostDocumentRule, entity) - .excludesNull().execute(); + Beans.copy(boostDocumentRule, entity).excludesNull().execute(); boostDocumentRule = entity; boostDocumentRuleBhv.update(boostDocumentRule); } else { boostDocumentRuleBhv.insert(boostDocumentRule); } } - idMap.put( - BOOST_DOCUMENT_RULE_KEY + ":" + id.toString(), - boostDocumentRule.getId()); + idMap.put(BOOST_DOCUMENT_RULE_KEY + ":" + id.toString(), boostDocumentRule.getId()); } } userTransaction.commit(); @@ -1434,39 +1189,30 @@ public class DatabaseService { try { userTransaction.begin(); - final List suggestElevateWordList = (List) dataSet - .get(SUGGEST_ELEVATE_WORD_KEY + LIST_SUFFIX); + final List suggestElevateWordList = + (List) dataSet.get(SUGGEST_ELEVATE_WORD_KEY + LIST_SUFFIX); if (suggestElevateWordList != null) { for (SuggestElevateWord suggestElevateWord : suggestElevateWordList) { final Long id = suggestElevateWord.getId(); - final String suggestWord = suggestElevateWord - .getSuggestWord(); - final SuggestElevateWord entity = suggestElevateWordBhv - .selectEntity( - cb -> { - cb.query().setSuggestWord_Equal( - suggestWord); - }).orElse(null);//TODO + final String suggestWord = suggestElevateWord.getSuggestWord(); + final SuggestElevateWord entity = suggestElevateWordBhv.selectEntity(cb -> { + cb.query().setSuggestWord_Equal(suggestWord); + }).orElse(null);//TODO suggestElevateWord.setId(null); if (entity == null) { suggestElevateWordBhv.insert(suggestElevateWord); } else { if (overwrite) { suggestElevateWord.setVersionNo(null); - Beans.copy(suggestElevateWord, entity) - .excludesNull().execute(); + Beans.copy(suggestElevateWord, entity).excludesNull().execute(); suggestElevateWord = entity; - suggestElevateWordBhv - .update(suggestElevateWord); + suggestElevateWordBhv.update(suggestElevateWord); } else { - suggestElevateWordBhv - .insert(suggestElevateWord); + suggestElevateWordBhv.insert(suggestElevateWord); } } - idMap.put( - SUGGEST_ELEVATE_WORD_KEY + ":" + id.toString(), - suggestElevateWord.getId()); + idMap.put(SUGGEST_ELEVATE_WORD_KEY + ":" + id.toString(), suggestElevateWord.getId()); } } userTransaction.commit(); @@ -1477,36 +1223,29 @@ public class DatabaseService { try { userTransaction.begin(); - final List suggestNGWordList = (List) dataSet - .get(SUGGEST_BAD_WORD_KEY + LIST_SUFFIX); + final List suggestNGWordList = (List) dataSet.get(SUGGEST_BAD_WORD_KEY + LIST_SUFFIX); if (suggestNGWordList != null) { for (SuggestBadWord suggestBadWord : suggestNGWordList) { final Long id = suggestBadWord.getId(); - final String suggestWord = suggestBadWord - .getSuggestWord(); - final SuggestBadWord entity = suggestBadWordBhv - .selectEntity( - cb -> { - cb.query().setSuggestWord_Equal( - suggestWord); - }).orElse(null);//TODO + final String suggestWord = suggestBadWord.getSuggestWord(); + final SuggestBadWord entity = suggestBadWordBhv.selectEntity(cb -> { + cb.query().setSuggestWord_Equal(suggestWord); + }).orElse(null);//TODO suggestBadWord.setId(null); if (entity == null) { suggestBadWordBhv.insert(suggestBadWord); } else { if (overwrite) { suggestBadWord.setVersionNo(null); - Beans.copy(suggestBadWord, entity) - .excludesNull().execute(); + Beans.copy(suggestBadWord, entity).excludesNull().execute(); suggestBadWord = entity; suggestBadWordBhv.update(suggestBadWord); } else { suggestBadWordBhv.insert(suggestBadWord); } } - idMap.put(SUGGEST_BAD_WORD_KEY + ":" + id.toString(), - suggestBadWord.getId()); + idMap.put(SUGGEST_BAD_WORD_KEY + ":" + id.toString(), suggestBadWord.getId()); } } userTransaction.commit(); @@ -1516,10 +1255,8 @@ public class DatabaseService { // crawlerProperties try { - final Map crawlerPropertyMap = (Map) dataSet - .get(CRAWLER_PROPERTIES_KEY); - for (final Map.Entry entry : crawlerPropertyMap - .entrySet()) { + final Map crawlerPropertyMap = (Map) dataSet.get(CRAWLER_PROPERTIES_KEY); + for (final Map.Entry entry : crawlerPropertyMap.entrySet()) { final String value = entry.getValue(); if (StringUtil.isNotBlank(value)) { crawlerProperties.setProperty(entry.getKey(), value); @@ -1527,8 +1264,7 @@ public class DatabaseService { } crawlerProperties.store(); } catch (final Exception e) { - logger.warn("Failed to restore properties: " - + CRAWLER_PROPERTIES_KEY, e); + logger.warn("Failed to restore properties: " + CRAWLER_PROPERTIES_KEY, e); } } diff --git a/src/main/java/org/codelibs/fess/service/FailureUrlService.java b/src/main/java/org/codelibs/fess/service/FailureUrlService.java index eb403d75c..081d34068 100644 --- a/src/main/java/org/codelibs/fess/service/FailureUrlService.java +++ b/src/main/java/org/codelibs/fess/service/FailureUrlService.java @@ -41,8 +41,7 @@ import org.codelibs.fess.util.ComponentUtil; import org.dbflute.cbean.result.ListResultBean; import org.seasar.framework.container.SingletonS2Container; -public class FailureUrlService extends BsFailureUrlService implements - Serializable { +public class FailureUrlService extends BsFailureUrlService implements Serializable { private static final long serialVersionUID = 1L; @@ -50,8 +49,7 @@ public class FailureUrlService extends BsFailureUrlService implements protected DynamicProperties crawlerProperties; @Override - protected void setupListCondition(final FailureUrlCB cb, - final FailureUrlPager failureUrlPager) { + protected void setupListCondition(final FailureUrlCB cb, final FailureUrlPager failureUrlPager) { super.setupListCondition(cb, failureUrlPager); // setup condition @@ -61,8 +59,7 @@ public class FailureUrlService extends BsFailureUrlService implements } @Override - protected void setupEntityCondition(final FailureUrlCB cb, - final Map keys) { + protected void setupEntityCondition(final FailureUrlCB cb, final Map keys) { super.setupEntityCondition(cb, keys); // setup condition @@ -93,37 +90,30 @@ public class FailureUrlService extends BsFailureUrlService implements }); } - private void buildSearchCondition(final FailureUrlPager failureUrlPager, - final FailureUrlCB cb) { + private void buildSearchCondition(final FailureUrlPager failureUrlPager, final FailureUrlCB cb) { // search if (StringUtil.isNotBlank(failureUrlPager.url)) { - cb.query().setUrl_LikeSearch(failureUrlPager.url, - op -> op.likeContain()); + cb.query().setUrl_LikeSearch(failureUrlPager.url, op -> op.likeContain()); } if (StringUtil.isNotBlank(failureUrlPager.errorCountMax)) { - cb.query().setErrorCount_LessEqual( - Integer.parseInt(failureUrlPager.errorCountMax)); + cb.query().setErrorCount_LessEqual(Integer.parseInt(failureUrlPager.errorCountMax)); } if (StringUtil.isNotBlank(failureUrlPager.errorCountMin)) { - cb.query().setErrorCount_GreaterEqual( - Integer.parseInt(failureUrlPager.errorCountMin)); + cb.query().setErrorCount_GreaterEqual(Integer.parseInt(failureUrlPager.errorCountMin)); } if (StringUtil.isNotBlank(failureUrlPager.errorName)) { - cb.query().setErrorName_LikeSearch(failureUrlPager.errorName, - op -> op.likeContain()); + cb.query().setErrorName_LikeSearch(failureUrlPager.errorName, op -> op.likeContain()); } } public List getExcludedUrlList(final String configId) { - final String failureCountStr = crawlerProperties.getProperty( - Constants.FAILURE_COUNT_THRESHOLD_PROPERTY, - Constants.DEFAULT_FAILURE_COUNT); - final String ignoreFailureType = crawlerProperties.getProperty( - Constants.IGNORE_FAILURE_TYPE_PROPERTY, - Constants.DEFAULT_IGNORE_FAILURE_TYPE); + final String failureCountStr = + crawlerProperties.getProperty(Constants.FAILURE_COUNT_THRESHOLD_PROPERTY, Constants.DEFAULT_FAILURE_COUNT); + final String ignoreFailureType = + crawlerProperties.getProperty(Constants.IGNORE_FAILURE_TYPE_PROPERTY, Constants.DEFAULT_IGNORE_FAILURE_TYPE); int failureCount; try { failureCount = Integer.parseInt(failureCountStr); @@ -136,11 +126,10 @@ public class FailureUrlService extends BsFailureUrlService implements } final int count = failureCount; - final ListResultBean list = failureUrlBhv - .selectList(cb -> { - cb.query().setConfigId_Equal(configId); - cb.query().setErrorCount_GreaterEqual(count); - }); + final ListResultBean list = failureUrlBhv.selectList(cb -> { + cb.query().setConfigId_Equal(configId); + cb.query().setErrorCount_GreaterEqual(count); + }); if (list.isEmpty()) { return null; } @@ -168,10 +157,8 @@ public class FailureUrlService extends BsFailureUrlService implements }, op -> op.allowNonQueryDelete()); } - public void store(final CrawlingConfig crawlingConfig, - final String errorName, final String url, final Throwable e) { - final FailureUrlBhv failureUrlBhv = SingletonS2Container - .getComponent(FailureUrlBhv.class); + public void store(final CrawlingConfig crawlingConfig, final String errorName, final String url, final Throwable e) { + final FailureUrlBhv failureUrlBhv = SingletonS2Container.getComponent(FailureUrlBhv.class); FailureUrl failureUrl = failureUrlBhv.selectEntity(cb -> { cb.query().setUrl_Equal(url); if (crawlingConfig != null) { @@ -193,8 +180,7 @@ public class FailureUrlService extends BsFailureUrlService implements failureUrl.setErrorName(errorName); failureUrl.setErrorLog(StringUtils.abbreviate(getStackTrace(e), 4000)); - failureUrl.setLastAccessTime(ComponentUtil.getSystemHelper() - .getCurrentTime()); + failureUrl.setLastAccessTime(ComponentUtil.getSystemHelper().getCurrentTime()); failureUrl.setThreadName(Thread.currentThread().getName()); failureUrlBhv.insertOrUpdate(failureUrl); diff --git a/src/main/java/org/codelibs/fess/service/FavoriteLogService.java b/src/main/java/org/codelibs/fess/service/FavoriteLogService.java index 2be96297a..f84701c0b 100644 --- a/src/main/java/org/codelibs/fess/service/FavoriteLogService.java +++ b/src/main/java/org/codelibs/fess/service/FavoriteLogService.java @@ -50,8 +50,7 @@ import org.dbflute.cbean.result.ListResultBean; import com.ibm.icu.text.SimpleDateFormat; -public class FavoriteLogService extends BsFavoriteLogService implements - Serializable { +public class FavoriteLogService extends BsFavoriteLogService implements Serializable { private static final Log log = LogFactory.getLog(FavoriteLogService.class); private static final long serialVersionUID = 1L; @@ -60,8 +59,7 @@ public class FavoriteLogService extends BsFavoriteLogService implements protected UserInfoBhv userInfoBhv; @Override - protected void setupListCondition(final FavoriteLogCB cb, - final FavoriteLogPager favoriteLogPager) { + protected void setupListCondition(final FavoriteLogCB cb, final FavoriteLogPager favoriteLogPager) { super.setupListCondition(cb, favoriteLogPager); cb.setupSelect_UserInfo(); @@ -74,8 +72,7 @@ public class FavoriteLogService extends BsFavoriteLogService implements } @Override - protected void setupEntityCondition(final FavoriteLogCB cb, - final Map keys) { + protected void setupEntityCondition(final FavoriteLogCB cb, final Map keys) { super.setupEntityCondition(cb, keys); // setup condition @@ -107,8 +104,7 @@ public class FavoriteLogService extends BsFavoriteLogService implements final FavoriteLog favoriteLog = new FavoriteLog(); favoriteLog.setUserId(userInfo.getId()); favoriteLog.setUrl(url); - favoriteLog.setCreatedTime(ComponentUtil.getSystemHelper() - .getCurrentTime()); + favoriteLog.setCreatedTime(ComponentUtil.getSystemHelper().getCurrentTime()); favoriteLogBhv.insert(favoriteLog); return true; } @@ -116,8 +112,7 @@ public class FavoriteLogService extends BsFavoriteLogService implements return false; } - public List getUrlList(final String userCode, - final List urlList) { + public List getUrlList(final String userCode, final List urlList) { if (urlList.isEmpty()) { return urlList; } @@ -127,14 +122,12 @@ public class FavoriteLogService extends BsFavoriteLogService implements }).orElse(null);//TODO if (userInfo != null) { - final ListResultBean list = favoriteLogBhv - .selectList(cb2 -> { - cb2.query().setUserId_Equal(userInfo.getId()); - cb2.query().setUrl_InScope(urlList); - }); + final ListResultBean list = favoriteLogBhv.selectList(cb2 -> { + cb2.query().setUserId_Equal(userInfo.getId()); + cb2.query().setUrl_InScope(urlList); + }); if (!list.isEmpty()) { - final List newUrlList = new ArrayList( - list.size()); + final List newUrlList = new ArrayList(list.size()); for (final FavoriteLog favoriteLog : list) { newUrlList.add(favoriteLog.getUrl()); } @@ -151,8 +144,7 @@ public class FavoriteLogService extends BsFavoriteLogService implements }, op -> op.allowNonQueryDelete()); } - private void buildSearchCondition(final FavoriteLogPager favoriteLogPager, - final FavoriteLogCB cb) { + private void buildSearchCondition(final FavoriteLogPager favoriteLogPager, final FavoriteLogCB cb) { if (StringUtil.isNotBlank(favoriteLogPager.userCode)) { cb.setupSelect_UserInfo(); @@ -175,11 +167,9 @@ public class FavoriteLogService extends BsFavoriteLogService implements buf.append("00"); } - final DateTimeFormatter formatter = DateTimeFormatter - .ofPattern("yyyy-MM-dd+HH:mm"); + final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd+HH:mm"); try { - cb.query().setCreatedTime_GreaterEqual( - LocalDateTime.parse(buf.toString(), formatter)); + cb.query().setCreatedTime_GreaterEqual(LocalDateTime.parse(buf.toString(), formatter)); } catch (final DateTimeParseException e) { favoriteLogPager.startDate = null; favoriteLogPager.startHour = null; @@ -203,11 +193,9 @@ public class FavoriteLogService extends BsFavoriteLogService implements buf.append("00"); } - final DateTimeFormatter formatter = DateTimeFormatter - .ofPattern("yyyy-MM-dd+HH:mm"); + final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd+HH:mm"); try { - cb.query().setCreatedTime_LessThan( - LocalDateTime.parse(buf.toString(), formatter)); + cb.query().setCreatedTime_LessThan(LocalDateTime.parse(buf.toString(), formatter)); } catch (final DateTimeParseException e) { favoriteLogPager.endDate = null; favoriteLogPager.endHour = null; @@ -217,8 +205,7 @@ public class FavoriteLogService extends BsFavoriteLogService implements } - public void dump(final Writer writer, - final FavoriteLogPager favoriteLogPager) { + public void dump(final Writer writer, final FavoriteLogPager favoriteLogPager) { final CsvConfig cfg = new CsvConfig(',', '"', '"'); cfg.setEscapeDisabled(false); cfg.setQuoteDisabled(false); @@ -229,8 +216,7 @@ public class FavoriteLogService extends BsFavoriteLogService implements list.add("URL"); list.add("Date"); csvWriter.writeValues(list); - final SimpleDateFormat sdf = new SimpleDateFormat( - CoreLibConstants.DATE_FORMAT_ISO_8601_EXTEND); + final SimpleDateFormat sdf = new SimpleDateFormat(CoreLibConstants.DATE_FORMAT_ISO_8601_EXTEND); favoriteLogBhv.selectCursor(cb -> { if (favoriteLogPager != null) { buildSearchCondition(favoriteLogPager, cb); @@ -238,9 +224,7 @@ public class FavoriteLogService extends BsFavoriteLogService implements }, new EntityRowHandler() { @Override public void handle(final FavoriteLog entity) { - final UserInfo userInfo = userInfoBhv.selectEntity( - cb2 -> cb2.query().setId_Equal(entity.getId())) - .orElse(null);//TODO + final UserInfo userInfo = userInfoBhv.selectEntity(cb2 -> cb2.query().setId_Equal(entity.getId())).orElse(null);//TODO String userCode; if (userInfo == null) { userCode = StringUtil.EMPTY; @@ -259,8 +243,7 @@ public class FavoriteLogService extends BsFavoriteLogService implements } } - private void addToList(final List list, - final Object value) { + private void addToList(final List list, final Object value) { if (value == null) { list.add(StringUtil.EMPTY); } else if (value instanceof Timestamp) { diff --git a/src/main/java/org/codelibs/fess/service/FileAuthenticationService.java b/src/main/java/org/codelibs/fess/service/FileAuthenticationService.java index 218cd6eb1..d942314fc 100644 --- a/src/main/java/org/codelibs/fess/service/FileAuthenticationService.java +++ b/src/main/java/org/codelibs/fess/service/FileAuthenticationService.java @@ -25,14 +25,12 @@ import org.codelibs.fess.db.cbean.FileAuthenticationCB; import org.codelibs.fess.db.exentity.FileAuthentication; import org.codelibs.fess.pager.FileAuthenticationPager; -public class FileAuthenticationService extends BsFileAuthenticationService - implements Serializable { +public class FileAuthenticationService extends BsFileAuthenticationService implements Serializable { private static final long serialVersionUID = 1L; @Override - protected void setupListCondition(final FileAuthenticationCB cb, - final FileAuthenticationPager fileAuthenticationPager) { + protected void setupListCondition(final FileAuthenticationCB cb, final FileAuthenticationPager fileAuthenticationPager) { super.setupListCondition(cb, fileAuthenticationPager); // setup condition @@ -46,8 +44,7 @@ public class FileAuthenticationService extends BsFileAuthenticationService } @Override - protected void setupEntityCondition(final FileAuthenticationCB cb, - final Map keys) { + protected void setupEntityCondition(final FileAuthenticationCB cb, final Map keys) { super.setupEntityCondition(cb, keys); // setup condition @@ -56,8 +53,7 @@ public class FileAuthenticationService extends BsFileAuthenticationService } @Override - protected void setupStoreCondition( - final FileAuthentication fileAuthentication) { + protected void setupStoreCondition(final FileAuthentication fileAuthentication) { super.setupStoreCondition(fileAuthentication); // setup condition @@ -65,16 +61,14 @@ public class FileAuthenticationService extends BsFileAuthenticationService } @Override - protected void setupDeleteCondition( - final FileAuthentication fileAuthentication) { + protected void setupDeleteCondition(final FileAuthentication fileAuthentication) { super.setupDeleteCondition(fileAuthentication); // setup condition } - public List getFileAuthenticationList( - final Long fileCrawlingConfigId) { + public List getFileAuthenticationList(final Long fileCrawlingConfigId) { return fileAuthenticationBhv.selectList(cb -> { cb.query().setFileCrawlingConfigId_Equal(fileCrawlingConfigId); }); diff --git a/src/main/java/org/codelibs/fess/service/FileCrawlingConfigService.java b/src/main/java/org/codelibs/fess/service/FileCrawlingConfigService.java index a5ae54de8..90085ff1b 100644 --- a/src/main/java/org/codelibs/fess/service/FileCrawlingConfigService.java +++ b/src/main/java/org/codelibs/fess/service/FileCrawlingConfigService.java @@ -33,8 +33,7 @@ import org.codelibs.fess.db.exentity.FileConfigToRoleTypeMapping; import org.codelibs.fess.db.exentity.FileCrawlingConfig; import org.codelibs.fess.pager.FileCrawlingConfigPager; -public class FileCrawlingConfigService extends BsFileCrawlingConfigService - implements Serializable { +public class FileCrawlingConfigService extends BsFileCrawlingConfigService implements Serializable { private static final long serialVersionUID = 1L; @@ -48,8 +47,7 @@ public class FileCrawlingConfigService extends BsFileCrawlingConfigService return getAllFileCrawlingConfigList(true, true, true, null); } - public List getFileCrawlingConfigListByIds( - final List idList) { + public List getFileCrawlingConfigListByIds(final List idList) { if (idList == null) { return getAllFileCrawlingConfigList(); } else { @@ -57,19 +55,17 @@ public class FileCrawlingConfigService extends BsFileCrawlingConfigService } } - public List getAllFileCrawlingConfigList( - final boolean withLabelType, final boolean withRoleType, + public List getAllFileCrawlingConfigList(final boolean withLabelType, final boolean withRoleType, final boolean available, final List idList) { - final List list = fileCrawlingConfigBhv - .selectList(cb -> { - cb.query().setDeletedBy_IsNull(); - if (available) { - cb.query().setAvailable_Equal(Constants.T); - } - if (idList != null) { - cb.query().setId_InScope(idList); - } - }); + final List list = fileCrawlingConfigBhv.selectList(cb -> { + cb.query().setDeletedBy_IsNull(); + if (available) { + cb.query().setAvailable_Equal(Constants.T); + } + if (idList != null) { + cb.query().setId_InScope(idList); + } + }); if (withRoleType) { fileCrawlingConfigBhv.loadFileConfigToRoleTypeMapping(list, cb -> { cb.setupSelect_RoleType(); @@ -78,58 +74,45 @@ public class FileCrawlingConfigService extends BsFileCrawlingConfigService }); } if (withLabelType) { - fileCrawlingConfigBhv.loadFileConfigToLabelTypeMapping(list, - cb -> { - cb.setupSelect_LabelType(); - cb.query().queryLabelType().setDeletedBy_IsNull(); - cb.query().queryLabelType().addOrderBy_SortOrder_Asc(); - }); + fileCrawlingConfigBhv.loadFileConfigToLabelTypeMapping(list, cb -> { + cb.setupSelect_LabelType(); + cb.query().queryLabelType().setDeletedBy_IsNull(); + cb.query().queryLabelType().addOrderBy_SortOrder_Asc(); + }); } return list; } @Override - public FileCrawlingConfig getFileCrawlingConfig( - final Map keys) { - final FileCrawlingConfig fileCrawlingConfig = super - .getFileCrawlingConfig(keys); + public FileCrawlingConfig getFileCrawlingConfig(final Map keys) { + final FileCrawlingConfig fileCrawlingConfig = super.getFileCrawlingConfig(keys); if (fileCrawlingConfig != null) { - final List fctrtmList = fileConfigToRoleTypeMappingBhv - .selectList(fctrtmCb -> { - fctrtmCb.query().setFileConfigId_Equal( - fileCrawlingConfig.getId()); - fctrtmCb.query().queryRoleType().setDeletedBy_IsNull(); - fctrtmCb.query().queryFileCrawlingConfig() - .setDeletedBy_IsNull(); - }); + final List fctrtmList = fileConfigToRoleTypeMappingBhv.selectList(fctrtmCb -> { + fctrtmCb.query().setFileConfigId_Equal(fileCrawlingConfig.getId()); + fctrtmCb.query().queryRoleType().setDeletedBy_IsNull(); + fctrtmCb.query().queryFileCrawlingConfig().setDeletedBy_IsNull(); + }); if (!fctrtmList.isEmpty()) { - final List roleTypeIds = new ArrayList( - fctrtmList.size()); + final List roleTypeIds = new ArrayList(fctrtmList.size()); for (final FileConfigToRoleTypeMapping mapping : fctrtmList) { roleTypeIds.add(Long.toString(mapping.getRoleTypeId())); } - fileCrawlingConfig.setRoleTypeIds(roleTypeIds - .toArray(new String[roleTypeIds.size()])); + fileCrawlingConfig.setRoleTypeIds(roleTypeIds.toArray(new String[roleTypeIds.size()])); } - final List fctltmList = fileConfigToLabelTypeMappingBhv - .selectList(fctltmCb -> { - fctltmCb.query().setFileConfigId_Equal( - fileCrawlingConfig.getId()); - fctltmCb.query().queryLabelType().setDeletedBy_IsNull(); - fctltmCb.query().queryFileCrawlingConfig() - .setDeletedBy_IsNull(); - }); + final List fctltmList = fileConfigToLabelTypeMappingBhv.selectList(fctltmCb -> { + fctltmCb.query().setFileConfigId_Equal(fileCrawlingConfig.getId()); + fctltmCb.query().queryLabelType().setDeletedBy_IsNull(); + fctltmCb.query().queryFileCrawlingConfig().setDeletedBy_IsNull(); + }); if (!fctltmList.isEmpty()) { - final List labelTypeIds = new ArrayList( - fctltmList.size()); + final List labelTypeIds = new ArrayList(fctltmList.size()); for (final FileConfigToLabelTypeMapping mapping : fctltmList) { labelTypeIds.add(Long.toString(mapping.getLabelTypeId())); } - fileCrawlingConfig.setLabelTypeIds(labelTypeIds - .toArray(new String[labelTypeIds.size()])); + fileCrawlingConfig.setLabelTypeIds(labelTypeIds.toArray(new String[labelTypeIds.size()])); } } @@ -169,11 +152,9 @@ public class FileCrawlingConfigService extends BsFileCrawlingConfigService } else { // Update if (labelTypeIds != null) { - final List fctltmList = fileConfigToLabelTypeMappingBhv - .selectList(fctltmCb -> { - fctltmCb.query() - .setFileConfigId_Equal(fileConfigId); - }); + final List fctltmList = fileConfigToLabelTypeMappingBhv.selectList(fctltmCb -> { + fctltmCb.query().setFileConfigId_Equal(fileConfigId); + }); final List newList = new ArrayList(); final List matchedList = new ArrayList(); for (final String id : labelTypeIds) { @@ -199,11 +180,9 @@ public class FileCrawlingConfigService extends BsFileCrawlingConfigService fileConfigToLabelTypeMappingBhv.batchDelete(fctltmList); } if (roleTypeIds != null) { - final List fctrtmList = fileConfigToRoleTypeMappingBhv - .selectList(fctrtmCb -> { - fctrtmCb.query() - .setFileConfigId_Equal(fileConfigId); - }); + final List fctrtmList = fileConfigToRoleTypeMappingBhv.selectList(fctrtmCb -> { + fctrtmCb.query().setFileConfigId_Equal(fileConfigId); + }); final List newList = new ArrayList(); final List matchedList = new ArrayList(); for (final String id : roleTypeIds) { @@ -232,8 +211,7 @@ public class FileCrawlingConfigService extends BsFileCrawlingConfigService } @Override - protected void setupListCondition(final FileCrawlingConfigCB cb, - final FileCrawlingConfigPager fileCrawlingConfigPager) { + protected void setupListCondition(final FileCrawlingConfigCB cb, final FileCrawlingConfigPager fileCrawlingConfigPager) { super.setupListCondition(cb, fileCrawlingConfigPager); // setup condition @@ -245,8 +223,7 @@ public class FileCrawlingConfigService extends BsFileCrawlingConfigService } @Override - protected void setupEntityCondition(final FileCrawlingConfigCB cb, - final Map keys) { + protected void setupEntityCondition(final FileCrawlingConfigCB cb, final Map keys) { super.setupEntityCondition(cb, keys); // setup condition @@ -255,8 +232,7 @@ public class FileCrawlingConfigService extends BsFileCrawlingConfigService } @Override - protected void setupStoreCondition( - final FileCrawlingConfig fileCrawlingConfig) { + protected void setupStoreCondition(final FileCrawlingConfig fileCrawlingConfig) { super.setupStoreCondition(fileCrawlingConfig); // setup condition @@ -264,8 +240,7 @@ public class FileCrawlingConfigService extends BsFileCrawlingConfigService } @Override - protected void setupDeleteCondition( - final FileCrawlingConfig fileCrawlingConfig) { + protected void setupDeleteCondition(final FileCrawlingConfig fileCrawlingConfig) { super.setupDeleteCondition(fileCrawlingConfig); // setup condition diff --git a/src/main/java/org/codelibs/fess/service/JobLogService.java b/src/main/java/org/codelibs/fess/service/JobLogService.java index 9656c1bcb..be567fa9b 100644 --- a/src/main/java/org/codelibs/fess/service/JobLogService.java +++ b/src/main/java/org/codelibs/fess/service/JobLogService.java @@ -32,8 +32,7 @@ public class JobLogService extends BsJobLogService implements Serializable { private static final long serialVersionUID = 1L; @Override - protected void setupListCondition(final JobLogCB cb, - final JobLogPager jobLogPager) { + protected void setupListCondition(final JobLogCB cb, final JobLogPager jobLogPager) { super.setupListCondition(cb, jobLogPager); // setup condition @@ -45,8 +44,7 @@ public class JobLogService extends BsJobLogService implements Serializable { } @Override - protected void setupEntityCondition(final JobLogCB cb, - final Map keys) { + protected void setupEntityCondition(final JobLogCB cb, final Map keys) { super.setupEntityCondition(cb, keys); // setup condition @@ -70,8 +68,7 @@ public class JobLogService extends BsJobLogService implements Serializable { } public void deleteBefore(final int days) { - final LocalDateTime targetTime = ComponentUtil.getSystemHelper() - .getCurrentTime().minusDays(days); + final LocalDateTime targetTime = ComponentUtil.getSystemHelper().getCurrentTime().minusDays(days); jobLogBhv.varyingQueryDelete(cb -> { cb.query().setEndTime_LessThan(targetTime); }, op -> op.allowNonQueryDelete()); diff --git a/src/main/java/org/codelibs/fess/service/KeyMatchService.java b/src/main/java/org/codelibs/fess/service/KeyMatchService.java index f2edd743d..2a6ffead8 100644 --- a/src/main/java/org/codelibs/fess/service/KeyMatchService.java +++ b/src/main/java/org/codelibs/fess/service/KeyMatchService.java @@ -30,8 +30,7 @@ public class KeyMatchService extends BsKeyMatchService implements Serializable { private static final long serialVersionUID = 1L; @Override - protected void setupListCondition(final KeyMatchCB cb, - final KeyMatchPager keyMatchPager) { + protected void setupListCondition(final KeyMatchCB cb, final KeyMatchPager keyMatchPager) { super.setupListCondition(cb, keyMatchPager); // setup condition @@ -43,8 +42,7 @@ public class KeyMatchService extends BsKeyMatchService implements Serializable { } @Override - protected void setupEntityCondition(final KeyMatchCB cb, - final Map keys) { + protected void setupEntityCondition(final KeyMatchCB cb, final Map keys) { super.setupEntityCondition(cb, keys); // setup condition diff --git a/src/main/java/org/codelibs/fess/service/LabelTypeService.java b/src/main/java/org/codelibs/fess/service/LabelTypeService.java index f2442dec8..090b94605 100644 --- a/src/main/java/org/codelibs/fess/service/LabelTypeService.java +++ b/src/main/java/org/codelibs/fess/service/LabelTypeService.java @@ -33,8 +33,7 @@ import org.codelibs.fess.pager.LabelTypePager; import org.codelibs.fess.util.ComponentUtil; import org.dbflute.cbean.result.ListResultBean; -public class LabelTypeService extends BsLabelTypeService implements - Serializable { +public class LabelTypeService extends BsLabelTypeService implements Serializable { private static final long serialVersionUID = 1L; @@ -42,8 +41,7 @@ public class LabelTypeService extends BsLabelTypeService implements protected LabelTypeToRoleTypeMappingBhv labelTypeToRoleTypeMappingBhv; @Override - protected void setupListCondition(final LabelTypeCB cb, - final LabelTypePager labelTypePager) { + protected void setupListCondition(final LabelTypeCB cb, final LabelTypePager labelTypePager) { super.setupListCondition(cb, labelTypePager); // setup condition @@ -55,8 +53,7 @@ public class LabelTypeService extends BsLabelTypeService implements } @Override - protected void setupEntityCondition(final LabelTypeCB cb, - final Map keys) { + protected void setupEntityCondition(final LabelTypeCB cb, final Map keys) { super.setupEntityCondition(cb, keys); // setup condition @@ -89,12 +86,11 @@ public class LabelTypeService extends BsLabelTypeService implements } public List getLabelTypeListWithRoles() { - final ListResultBean labelTypeList = labelTypeBhv - .selectList(cb -> { - cb.query().setDeletedBy_IsNull(); - cb.query().addOrderBy_SortOrder_Asc(); - cb.query().addOrderBy_Name_Asc(); - }); + final ListResultBean labelTypeList = labelTypeBhv.selectList(cb -> { + cb.query().setDeletedBy_IsNull(); + cb.query().addOrderBy_SortOrder_Asc(); + cb.query().addOrderBy_Name_Asc(); + }); labelTypeBhv.loadLabelTypeToRoleTypeMapping(labelTypeList, cb -> { cb.setupSelect_RoleType(); @@ -125,10 +121,9 @@ public class LabelTypeService extends BsLabelTypeService implements } else { // Update if (roleTypeIds != null) { - final List list = labelTypeToRoleTypeMappingBhv - .selectList(lttrtmCb -> { - lttrtmCb.query().setLabelTypeId_Equal(labelTypeId); - }); + final List list = labelTypeToRoleTypeMappingBhv.selectList(lttrtmCb -> { + lttrtmCb.query().setLabelTypeId_Equal(labelTypeId); + }); final List newList = new ArrayList(); final List matchedList = new ArrayList(); for (final String id : roleTypeIds) { @@ -155,8 +150,7 @@ public class LabelTypeService extends BsLabelTypeService implements } } - final LabelTypeHelper labelTypeHelper = ComponentUtil - .getLabelTypeHelper(); + final LabelTypeHelper labelTypeHelper = ComponentUtil.getLabelTypeHelper(); if (labelTypeHelper != null) { labelTypeHelper.refresh(getLabelTypeListWithRoles()); } @@ -166,21 +160,17 @@ public class LabelTypeService extends BsLabelTypeService implements public LabelType getLabelType(final Map keys) { final LabelType labelType = super.getLabelType(keys); if (labelType != null) { - final List wctrtmList = labelTypeToRoleTypeMappingBhv - .selectList(wctrtmCb -> { - wctrtmCb.query() - .setLabelTypeId_Equal(labelType.getId()); - wctrtmCb.query().queryRoleType().setDeletedBy_IsNull(); - wctrtmCb.query().queryLabelType().setDeletedBy_IsNull(); - }); + final List wctrtmList = labelTypeToRoleTypeMappingBhv.selectList(wctrtmCb -> { + wctrtmCb.query().setLabelTypeId_Equal(labelType.getId()); + wctrtmCb.query().queryRoleType().setDeletedBy_IsNull(); + wctrtmCb.query().queryLabelType().setDeletedBy_IsNull(); + }); if (!wctrtmList.isEmpty()) { - final List roleTypeIds = new ArrayList( - wctrtmList.size()); + final List roleTypeIds = new ArrayList(wctrtmList.size()); for (final LabelTypeToRoleTypeMapping mapping : wctrtmList) { roleTypeIds.add(Long.toString(mapping.getRoleTypeId())); } - labelType.setRoleTypeIds(roleTypeIds - .toArray(new String[roleTypeIds.size()])); + labelType.setRoleTypeIds(roleTypeIds.toArray(new String[roleTypeIds.size()])); } } return labelType; diff --git a/src/main/java/org/codelibs/fess/service/OverlappingHostService.java b/src/main/java/org/codelibs/fess/service/OverlappingHostService.java index 7bbe688aa..171135cd6 100644 --- a/src/main/java/org/codelibs/fess/service/OverlappingHostService.java +++ b/src/main/java/org/codelibs/fess/service/OverlappingHostService.java @@ -25,8 +25,7 @@ import org.codelibs.fess.db.cbean.OverlappingHostCB; import org.codelibs.fess.db.exentity.OverlappingHost; import org.codelibs.fess.pager.OverlappingHostPager; -public class OverlappingHostService extends BsOverlappingHostService implements - Serializable { +public class OverlappingHostService extends BsOverlappingHostService implements Serializable { private static final long serialVersionUID = 1L; @@ -41,8 +40,7 @@ public class OverlappingHostService extends BsOverlappingHostService implements } @Override - protected void setupListCondition(final OverlappingHostCB cb, - final OverlappingHostPager overlappingHostPager) { + protected void setupListCondition(final OverlappingHostCB cb, final OverlappingHostPager overlappingHostPager) { super.setupListCondition(cb, overlappingHostPager); // setup condition @@ -54,8 +52,7 @@ public class OverlappingHostService extends BsOverlappingHostService implements } @Override - protected void setupEntityCondition(final OverlappingHostCB cb, - final Map keys) { + protected void setupEntityCondition(final OverlappingHostCB cb, final Map keys) { super.setupEntityCondition(cb, keys); // setup condition diff --git a/src/main/java/org/codelibs/fess/service/PathMappingService.java b/src/main/java/org/codelibs/fess/service/PathMappingService.java index 9580cfa10..1f7aee6da 100644 --- a/src/main/java/org/codelibs/fess/service/PathMappingService.java +++ b/src/main/java/org/codelibs/fess/service/PathMappingService.java @@ -27,13 +27,11 @@ import org.codelibs.fess.db.cbean.PathMappingCB; import org.codelibs.fess.db.exentity.PathMapping; import org.codelibs.fess.pager.PathMappingPager; -public class PathMappingService extends BsPathMappingService implements - Serializable { +public class PathMappingService extends BsPathMappingService implements Serializable { private static final long serialVersionUID = 1L; - public List getPathMappingList( - final Collection cdefList) { + public List getPathMappingList(final Collection cdefList) { return pathMappingBhv.selectList(cb -> { cb.query().setDeletedBy_IsNull(); @@ -43,8 +41,7 @@ public class PathMappingService extends BsPathMappingService implements } @Override - protected void setupListCondition(final PathMappingCB cb, - final PathMappingPager pathMappingPager) { + protected void setupListCondition(final PathMappingCB cb, final PathMappingPager pathMappingPager) { super.setupListCondition(cb, pathMappingPager); // setup condition @@ -56,8 +53,7 @@ public class PathMappingService extends BsPathMappingService implements } @Override - protected void setupEntityCondition(final PathMappingCB cb, - final Map keys) { + protected void setupEntityCondition(final PathMappingCB cb, final Map keys) { super.setupEntityCondition(cb, keys); // setup condition diff --git a/src/main/java/org/codelibs/fess/service/RequestHeaderService.java b/src/main/java/org/codelibs/fess/service/RequestHeaderService.java index 38fe8a233..92ffe0eaa 100644 --- a/src/main/java/org/codelibs/fess/service/RequestHeaderService.java +++ b/src/main/java/org/codelibs/fess/service/RequestHeaderService.java @@ -25,14 +25,12 @@ import org.codelibs.fess.db.cbean.RequestHeaderCB; import org.codelibs.fess.db.exentity.RequestHeader; import org.codelibs.fess.pager.RequestHeaderPager; -public class RequestHeaderService extends BsRequestHeaderService implements - Serializable { +public class RequestHeaderService extends BsRequestHeaderService implements Serializable { private static final long serialVersionUID = 1L; @Override - protected void setupListCondition(final RequestHeaderCB cb, - final RequestHeaderPager requestHeaderPager) { + protected void setupListCondition(final RequestHeaderCB cb, final RequestHeaderPager requestHeaderPager) { super.setupListCondition(cb, requestHeaderPager); // setup condition @@ -46,8 +44,7 @@ public class RequestHeaderService extends BsRequestHeaderService implements } @Override - protected void setupEntityCondition(final RequestHeaderCB cb, - final Map keys) { + protected void setupEntityCondition(final RequestHeaderCB cb, final Map keys) { super.setupEntityCondition(cb, keys); // setup condition @@ -71,8 +68,7 @@ public class RequestHeaderService extends BsRequestHeaderService implements } - public List getRequestHeaderList( - final Long webCrawlingConfigId) { + public List getRequestHeaderList(final Long webCrawlingConfigId) { return requestHeaderBhv.selectList(cb -> { cb.query().setWebCrawlingConfigId_Equal(webCrawlingConfigId); cb.query().setDeletedBy_IsNull(); diff --git a/src/main/java/org/codelibs/fess/service/RoleTypeService.java b/src/main/java/org/codelibs/fess/service/RoleTypeService.java index fb9a07bad..92e3cfb44 100644 --- a/src/main/java/org/codelibs/fess/service/RoleTypeService.java +++ b/src/main/java/org/codelibs/fess/service/RoleTypeService.java @@ -30,8 +30,7 @@ public class RoleTypeService extends BsRoleTypeService implements Serializable { private static final long serialVersionUID = 1L; @Override - protected void setupListCondition(final RoleTypeCB cb, - final RoleTypePager roleTypePager) { + protected void setupListCondition(final RoleTypeCB cb, final RoleTypePager roleTypePager) { super.setupListCondition(cb, roleTypePager); // setup condition @@ -43,8 +42,7 @@ public class RoleTypeService extends BsRoleTypeService implements Serializable { } @Override - protected void setupEntityCondition(final RoleTypeCB cb, - final Map keys) { + protected void setupEntityCondition(final RoleTypeCB cb, final Map keys) { super.setupEntityCondition(cb, keys); // setup condition diff --git a/src/main/java/org/codelibs/fess/service/ScheduledJobService.java b/src/main/java/org/codelibs/fess/service/ScheduledJobService.java index 871bcc364..780e21328 100644 --- a/src/main/java/org/codelibs/fess/service/ScheduledJobService.java +++ b/src/main/java/org/codelibs/fess/service/ScheduledJobService.java @@ -29,8 +29,7 @@ import org.codelibs.fess.db.exentity.ScheduledJob; import org.codelibs.fess.job.JobScheduler; import org.codelibs.fess.pager.ScheduledJobPager; -public class ScheduledJobService extends BsScheduledJobService implements - Serializable { +public class ScheduledJobService extends BsScheduledJobService implements Serializable { private static final long serialVersionUID = 1L; @@ -38,8 +37,7 @@ public class ScheduledJobService extends BsScheduledJobService implements protected JobScheduler jobScheduler; @Override - protected void setupListCondition(final ScheduledJobCB cb, - final ScheduledJobPager scheduledJobPager) { + protected void setupListCondition(final ScheduledJobCB cb, final ScheduledJobPager scheduledJobPager) { super.setupListCondition(cb, scheduledJobPager); // setup condition @@ -52,8 +50,7 @@ public class ScheduledJobService extends BsScheduledJobService implements } @Override - protected void setupEntityCondition(final ScheduledJobCB cb, - final Map keys) { + protected void setupEntityCondition(final ScheduledJobCB cb, final Map keys) { super.setupEntityCondition(cb, keys); // setup condition diff --git a/src/main/java/org/codelibs/fess/service/SearchFieldLogService.java b/src/main/java/org/codelibs/fess/service/SearchFieldLogService.java index e1b730f85..11ca30857 100644 --- a/src/main/java/org/codelibs/fess/service/SearchFieldLogService.java +++ b/src/main/java/org/codelibs/fess/service/SearchFieldLogService.java @@ -44,8 +44,7 @@ public class SearchFieldLogService implements Serializable { public void updateFieldLabels() { final GroupedFieldNamePmb pmb = new GroupedFieldNamePmb(); - final ListResultBean list = searchFieldLogBhv - .outsideSql().selectList(pmb); + final ListResultBean list = searchFieldLogBhv.outsideSql().selectList(pmb); final List groupedFieldNameList = new ArrayList(); for (final GroupedFieldName e : list) { final String name = e.getName(); @@ -53,8 +52,7 @@ public class SearchFieldLogService implements Serializable { groupedFieldNameList.add(name); } } - groupedFieldNames = groupedFieldNameList - .toArray(new String[groupedFieldNameList.size()]); + groupedFieldNames = groupedFieldNameList.toArray(new String[groupedFieldNameList.size()]); } public String[] getGroupedFieldNames() { diff --git a/src/main/java/org/codelibs/fess/service/SearchLogService.java b/src/main/java/org/codelibs/fess/service/SearchLogService.java index 63a8cd1dd..6d442d8a8 100644 --- a/src/main/java/org/codelibs/fess/service/SearchLogService.java +++ b/src/main/java/org/codelibs/fess/service/SearchLogService.java @@ -57,8 +57,7 @@ import org.dbflute.cbean.result.ListResultBean; import com.ibm.icu.text.SimpleDateFormat; -public class SearchLogService extends BsSearchLogService implements - Serializable { +public class SearchLogService extends BsSearchLogService implements Serializable { private static final Log log = LogFactory.getLog(SearchLogService.class); private static final long serialVersionUID = 1L; @@ -70,8 +69,7 @@ public class SearchLogService extends BsSearchLogService implements protected SearchFieldLogBhv searchFieldLogBhv; @Override - protected void setupListCondition(final SearchLogCB cb, - final SearchLogPager searchLogPager) { + protected void setupListCondition(final SearchLogCB cb, final SearchLogPager searchLogPager) { super.setupListCondition(cb, searchLogPager); cb.setupSelect_UserInfo(); @@ -127,8 +125,7 @@ public class SearchLogService extends BsSearchLogService implements } @Override - protected void setupEntityCondition(final SearchLogCB cb, - final Map keys) { + protected void setupEntityCondition(final SearchLogCB cb, final Map keys) { super.setupEntityCondition(cb, keys); // setup condition @@ -161,159 +158,138 @@ public class SearchLogService extends BsSearchLogService implements } public void deleteAll(final SearchLogPager searchLogPager) { - clickLogBhv.varyingQueryDelete( - cb2 -> { - if (StringUtil.isNotBlank(searchLogPager.searchWord)) { - cb2.query() - .querySearchLog() - .setSearchWord_LikeSearch( - searchLogPager.searchWord, - op -> op.likeContain()); - } + clickLogBhv.varyingQueryDelete(cb2 -> { + if (StringUtil.isNotBlank(searchLogPager.searchWord)) { + cb2.query().querySearchLog().setSearchWord_LikeSearch(searchLogPager.searchWord, op -> op.likeContain()); + } - if (StringUtil.isNotBlank(searchLogPager.startDate)) { - final StringBuilder buf = new StringBuilder(20); - buf.append(searchLogPager.startDate); - buf.append('+'); - if (StringUtil.isNotBlank(searchLogPager.startHour)) { - buf.append(searchLogPager.startHour); - } else { - buf.append("00"); - } - buf.append(':'); - if (StringUtil.isNotBlank(searchLogPager.startMin)) { - buf.append(searchLogPager.startMin); - } else { - buf.append("00"); - } + if (StringUtil.isNotBlank(searchLogPager.startDate)) { + final StringBuilder buf = new StringBuilder(20); + buf.append(searchLogPager.startDate); + buf.append('+'); + if (StringUtil.isNotBlank(searchLogPager.startHour)) { + buf.append(searchLogPager.startHour); + } else { + buf.append("00"); + } + buf.append(':'); + if (StringUtil.isNotBlank(searchLogPager.startMin)) { + buf.append(searchLogPager.startMin); + } else { + buf.append("00"); + } - final DateTimeFormatter formatter = DateTimeFormatter - .ofPattern("yyyy-MM-dd+HH:mm"); - try { - final LocalDateTime startDate = LocalDateTime - .parse(buf.toString(), formatter); - cb2.query().querySearchLog() - .setRequestedTime_GreaterEqual(startDate); - } catch (final DateTimeParseException e) { - searchLogPager.startDate = null; - searchLogPager.startHour = null; - searchLogPager.startMin = null; - } - } + final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd+HH:mm"); + try { + final LocalDateTime startDate = LocalDateTime.parse(buf.toString(), formatter); + cb2.query().querySearchLog().setRequestedTime_GreaterEqual(startDate); + } catch (final DateTimeParseException e) { + searchLogPager.startDate = null; + searchLogPager.startHour = null; + searchLogPager.startMin = null; + } + } - if (StringUtil.isNotBlank(searchLogPager.endDate)) { - final StringBuilder buf = new StringBuilder(20); - buf.append(searchLogPager.endDate); - buf.append('+'); - if (StringUtil.isNotBlank(searchLogPager.endHour)) { - buf.append(searchLogPager.endHour); - } else { - buf.append("00"); - } - buf.append(':'); - if (StringUtil.isNotBlank(searchLogPager.endMin)) { - buf.append(searchLogPager.endMin); - } else { - buf.append("00"); - } + if (StringUtil.isNotBlank(searchLogPager.endDate)) { + final StringBuilder buf = new StringBuilder(20); + buf.append(searchLogPager.endDate); + buf.append('+'); + if (StringUtil.isNotBlank(searchLogPager.endHour)) { + buf.append(searchLogPager.endHour); + } else { + buf.append("00"); + } + buf.append(':'); + if (StringUtil.isNotBlank(searchLogPager.endMin)) { + buf.append(searchLogPager.endMin); + } else { + buf.append("00"); + } - final DateTimeFormatter formatter = DateTimeFormatter - .ofPattern("yyyy-MM-dd+HH:mm"); - try { - final LocalDateTime endDate = LocalDateTime.parse( - buf.toString(), formatter); - cb2.query().querySearchLog() - .setRequestedTime_LessThan(endDate); - } catch (final DateTimeParseException e) { - searchLogPager.endDate = null; - searchLogPager.endHour = null; - searchLogPager.endMin = null; - } - } + final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd+HH:mm"); + try { + final LocalDateTime endDate = LocalDateTime.parse(buf.toString(), formatter); + cb2.query().querySearchLog().setRequestedTime_LessThan(endDate); + } catch (final DateTimeParseException e) { + searchLogPager.endDate = null; + searchLogPager.endHour = null; + searchLogPager.endMin = null; + } + } - if (StringUtil.isNotBlank(searchLogPager.startPage)) { - cb2.query().querySearchLog().setQueryOffset_Equal(0); - } - }, op -> op.allowNonQueryDelete()); - searchFieldLogBhv.varyingQueryDelete(cb2 -> { + if (StringUtil.isNotBlank(searchLogPager.startPage)) { + cb2.query().querySearchLog().setQueryOffset_Equal(0); + } }, op -> op.allowNonQueryDelete()); - searchLogBhv.varyingQueryDelete( - cb1 -> { - if (StringUtil.isNotBlank(searchLogPager.searchWord)) { - cb1.query().setSearchWord_LikeSearch( - searchLogPager.searchWord, - op -> op.likeContain()); - } + searchFieldLogBhv.varyingQueryDelete(cb2 -> {}, op -> op.allowNonQueryDelete()); + searchLogBhv.varyingQueryDelete(cb1 -> { + if (StringUtil.isNotBlank(searchLogPager.searchWord)) { + cb1.query().setSearchWord_LikeSearch(searchLogPager.searchWord, op -> op.likeContain()); + } - if (StringUtil.isNotBlank(searchLogPager.userCode)) { - cb1.setupSelect_UserInfo(); - cb1.query().queryUserInfo() - .setCode_Equal(searchLogPager.userCode); - } + if (StringUtil.isNotBlank(searchLogPager.userCode)) { + cb1.setupSelect_UserInfo(); + cb1.query().queryUserInfo().setCode_Equal(searchLogPager.userCode); + } - if (StringUtil.isNotBlank(searchLogPager.startDate)) { - final StringBuilder buf = new StringBuilder(20); - buf.append(searchLogPager.startDate); - buf.append('+'); - if (StringUtil.isNotBlank(searchLogPager.startHour)) { - buf.append(searchLogPager.startHour); - } else { - buf.append("00"); - } - buf.append(':'); - if (StringUtil.isNotBlank(searchLogPager.startMin)) { - buf.append(searchLogPager.startMin); - } else { - buf.append("00"); - } + if (StringUtil.isNotBlank(searchLogPager.startDate)) { + final StringBuilder buf = new StringBuilder(20); + buf.append(searchLogPager.startDate); + buf.append('+'); + if (StringUtil.isNotBlank(searchLogPager.startHour)) { + buf.append(searchLogPager.startHour); + } else { + buf.append("00"); + } + buf.append(':'); + if (StringUtil.isNotBlank(searchLogPager.startMin)) { + buf.append(searchLogPager.startMin); + } else { + buf.append("00"); + } - final DateTimeFormatter formatter = DateTimeFormatter - .ofPattern("yyyy-MM-dd+HH:mm"); - try { - final LocalDateTime startDate = LocalDateTime - .parse(buf.toString(), formatter); - cb1.query() - .setRequestedTime_GreaterEqual(startDate); - } catch (final DateTimeParseException e) { - searchLogPager.startDate = null; - searchLogPager.startHour = null; - searchLogPager.startMin = null; - } - } + final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd+HH:mm"); + try { + final LocalDateTime startDate = LocalDateTime.parse(buf.toString(), formatter); + cb1.query().setRequestedTime_GreaterEqual(startDate); + } catch (final DateTimeParseException e) { + searchLogPager.startDate = null; + searchLogPager.startHour = null; + searchLogPager.startMin = null; + } + } - if (StringUtil.isNotBlank(searchLogPager.endDate)) { - final StringBuilder buf = new StringBuilder(20); - buf.append(searchLogPager.endDate); - buf.append('+'); - if (StringUtil.isNotBlank(searchLogPager.endHour)) { - buf.append(searchLogPager.endHour); - } else { - buf.append("00"); - } - buf.append(':'); - if (StringUtil.isNotBlank(searchLogPager.endMin)) { - buf.append(searchLogPager.endMin); - } else { - buf.append("00"); - } + if (StringUtil.isNotBlank(searchLogPager.endDate)) { + final StringBuilder buf = new StringBuilder(20); + buf.append(searchLogPager.endDate); + buf.append('+'); + if (StringUtil.isNotBlank(searchLogPager.endHour)) { + buf.append(searchLogPager.endHour); + } else { + buf.append("00"); + } + buf.append(':'); + if (StringUtil.isNotBlank(searchLogPager.endMin)) { + buf.append(searchLogPager.endMin); + } else { + buf.append("00"); + } - final DateTimeFormatter formatter = DateTimeFormatter - .ofPattern("yyyy-MM-dd+HH:mm"); - try { - final LocalDateTime endDate = LocalDateTime.parse( - buf.toString(), formatter); - cb1.query().setRequestedTime_LessThan(endDate); - } catch (final DateTimeParseException e) { - searchLogPager.endDate = null; - searchLogPager.endHour = null; - searchLogPager.endMin = null; - } - } + final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd+HH:mm"); + try { + final LocalDateTime endDate = LocalDateTime.parse(buf.toString(), formatter); + cb1.query().setRequestedTime_LessThan(endDate); + } catch (final DateTimeParseException e) { + searchLogPager.endDate = null; + searchLogPager.endHour = null; + searchLogPager.endMin = null; + } + } - if (StringUtil.isNotBlank(searchLogPager.startPage)) { - cb1.query().setQueryOffset_Equal(0); - } - }, op -> op.allowNonQueryDelete()); + if (StringUtil.isNotBlank(searchLogPager.startPage)) { + cb1.query().setQueryOffset_Equal(0); + } + }, op -> op.allowNonQueryDelete()); } public void exportCsv(final Writer writer) { @@ -322,8 +298,7 @@ public class SearchLogService extends BsSearchLogService implements public void importCsv(final Reader reader) { final CsvReader csvReader = new CsvReader(reader, new CsvConfig()); - final DateTimeFormatter formatter = DateTimeFormatter - .ofPattern(CoreLibConstants.DATE_FORMAT_ISO_8601_EXTEND); + final DateTimeFormatter formatter = DateTimeFormatter.ofPattern(CoreLibConstants.DATE_FORMAT_ISO_8601_EXTEND); try { List list; csvReader.readValues(); // ignore header @@ -333,8 +308,7 @@ public class SearchLogService extends BsSearchLogService implements entity.setSearchWord(list.get(0)); entity.setSearchQuery(list.get(1)); entity.setSolrQuery(list.get(2)); - entity.setRequestedTime(LocalDateTime.parse(list.get(3), - formatter)); + entity.setRequestedTime(LocalDateTime.parse(list.get(3), formatter)); entity.setResponseTime(Integer.parseInt(list.get(4))); entity.setHitCount(Long.parseLong(list.get(5))); entity.setQueryOffset(Integer.parseInt(list.get(6))); @@ -343,8 +317,7 @@ public class SearchLogService extends BsSearchLogService implements entity.setReferer(list.get(9)); entity.setClientIp(list.get(10)); entity.setUserSessionId(list.get(11)); - entity.setAccessTypeAsAccessType(AccessType.valueOf(list - .get(12))); + entity.setAccessTypeAsAccessType(AccessType.valueOf(list.get(12))); if (list.size() >= 14) { final String jsonStr = list.get(13); @SuppressWarnings("rawtypes") @@ -352,8 +325,7 @@ public class SearchLogService extends BsSearchLogService implements for (final Object obj : objList) { @SuppressWarnings("rawtypes") final Map objMap = (Map) obj; - entity.addSearchFieldLogValue( - (String) objMap.get(Constants.ITEM_NAME), + entity.addSearchFieldLogValue((String) objMap.get(Constants.ITEM_NAME), (String) objMap.get(Constants.ITEM_VALUE)); } } @@ -389,8 +361,7 @@ public class SearchLogService extends BsSearchLogService implements list.add("AccessType"); list.add("Fields"); csvWriter.writeValues(list); - final SimpleDateFormat sdf = new SimpleDateFormat( - CoreLibConstants.DATE_FORMAT_ISO_8601_EXTEND); + final SimpleDateFormat sdf = new SimpleDateFormat(CoreLibConstants.DATE_FORMAT_ISO_8601_EXTEND); searchLogBhv.selectCursor(cb -> { if (searchLogPager != null) { buildSearchCondition(searchLogPager, cb); @@ -398,30 +369,23 @@ public class SearchLogService extends BsSearchLogService implements }, new EntityRowHandler() { @Override public void handle(final SearchLog entity) { - final ListResultBean fieldLogList = ComponentUtil - .getComponent(SearchFieldLogBhv.class).selectList( - cb2 -> { - cb2.query().setSearchId_Equal( - entity.getId()); - }); + final ListResultBean fieldLogList = + ComponentUtil.getComponent(SearchFieldLogBhv.class).selectList(cb2 -> { + cb2.query().setSearchId_Equal(entity.getId()); + }); String query = StringUtil.EMPTY; String solrQuery = StringUtil.EMPTY; - final List> jsonObjList = new ArrayList>( - fieldLogList.size()); + final List> jsonObjList = new ArrayList>(fieldLogList.size()); for (final SearchFieldLog fieldLog : fieldLogList) { final String name = fieldLog.getName(); - if (Constants.SEARCH_FIELD_LOG_SEARCH_QUERY - .equals(name)) { + if (Constants.SEARCH_FIELD_LOG_SEARCH_QUERY.equals(name)) { query = fieldLog.getValue(); - } else if (Constants.SEARCH_FIELD_LOG_SOLR_QUERY - .equals(name)) { + } else if (Constants.SEARCH_FIELD_LOG_SOLR_QUERY.equals(name)) { solrQuery = fieldLog.getValue(); } else { - final Map objMap = new HashMap( - 2); + final Map objMap = new HashMap(2); objMap.put(Constants.ITEM_NAME, fieldLog.getName()); - objMap.put(Constants.ITEM_VALUE, - fieldLog.getValue()); + objMap.put(Constants.ITEM_VALUE, fieldLog.getValue()); jsonObjList.add(objMap); } } @@ -448,8 +412,7 @@ public class SearchLogService extends BsSearchLogService implements } } - private void addToList(final List list, - final Object value) { + private void addToList(final List list, final Object value) { if (value == null) { list.add(StringUtil.EMPTY); } else if (value instanceof Timestamp) { @@ -465,21 +428,15 @@ public class SearchLogService extends BsSearchLogService implements } } - private void buildSearchCondition(final SearchLogPager searchLogPager, - final SearchLogCB cb) { + private void buildSearchCondition(final SearchLogPager searchLogPager, final SearchLogCB cb) { buildSearchCondition(searchLogPager, cb, null); } - private void buildSearchCondition(final SearchLogPager searchLogPager, - final SearchLogCB cb1, final ClickLogCB cb2) { + private void buildSearchCondition(final SearchLogPager searchLogPager, final SearchLogCB cb1, final ClickLogCB cb2) { if (StringUtil.isNotBlank(searchLogPager.searchWord)) { - cb1.query().setSearchWord_LikeSearch(searchLogPager.searchWord, - op -> op.likeContain()); + cb1.query().setSearchWord_LikeSearch(searchLogPager.searchWord, op -> op.likeContain()); if (cb2 != null) { - cb2.query() - .querySearchLog() - .setSearchWord_LikeSearch(searchLogPager.searchWord, - op -> op.likeContain()); + cb2.query().querySearchLog().setSearchWord_LikeSearch(searchLogPager.searchWord, op -> op.likeContain()); } } @@ -504,15 +461,12 @@ public class SearchLogService extends BsSearchLogService implements buf.append("00"); } - final DateTimeFormatter formatter = DateTimeFormatter - .ofPattern("yyyy-MM-dd+HH:mm"); + final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd+HH:mm"); try { - final LocalDateTime startDate = LocalDateTime.parse( - buf.toString(), formatter); + final LocalDateTime startDate = LocalDateTime.parse(buf.toString(), formatter); cb1.query().setRequestedTime_GreaterEqual(startDate); if (cb2 != null) { - cb2.query().querySearchLog() - .setRequestedTime_GreaterEqual(startDate); + cb2.query().querySearchLog().setRequestedTime_GreaterEqual(startDate); } } catch (final DateTimeParseException e) { searchLogPager.startDate = null; @@ -537,15 +491,12 @@ public class SearchLogService extends BsSearchLogService implements buf.append("00"); } - final DateTimeFormatter formatter = DateTimeFormatter - .ofPattern("yyyy-MM-dd+HH:mm"); + final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd+HH:mm"); try { - final LocalDateTime endDate = LocalDateTime.parse( - buf.toString(), formatter); + final LocalDateTime endDate = LocalDateTime.parse(buf.toString(), formatter); cb1.query().setRequestedTime_LessThan(endDate); if (cb2 != null) { - cb2.query().querySearchLog() - .setRequestedTime_LessThan(endDate); + cb2.query().querySearchLog().setRequestedTime_LessThan(endDate); } } catch (final DateTimeParseException e) { searchLogPager.endDate = null; @@ -576,42 +527,28 @@ public class SearchLogService extends BsSearchLogService implements } public void deleteBotsLog(final String[] bots) { - final LocalDateTime now = ComponentUtil.getSystemHelper() - .getCurrentTime(); + final LocalDateTime now = ComponentUtil.getSystemHelper().getCurrentTime(); for (final String value : bots) { final String userAgent = value.trim(); - clickLogBhv.varyingQueryDelete( - cb2 -> { - cb2.query().querySearchLog() - .setRequestedTime_LessThan(now); - cb2.query() - .querySearchLog() - .setUserAgent_LikeSearch(userAgent, - op -> op.likeContain()); - }, op -> op.allowNonQueryDelete()); - searchFieldLogBhv.varyingQueryDelete( - cb3 -> { - cb3.query().querySearchLog() - .setRequestedTime_LessThan(now); - cb3.query() - .querySearchLog() - .setUserAgent_LikeSearch(userAgent, - op -> op.likeContain()); - }, op -> op.allowNonQueryDelete()); - searchLogBhv.varyingQueryDelete( - cb1 -> { - cb1.query().setRequestedTime_LessThan(now); - cb1.query().setUserAgent_LikeSearch(userAgent, - op -> op.likeContain()); - }, op -> op.allowNonQueryDelete()); + clickLogBhv.varyingQueryDelete(cb2 -> { + cb2.query().querySearchLog().setRequestedTime_LessThan(now); + cb2.query().querySearchLog().setUserAgent_LikeSearch(userAgent, op -> op.likeContain()); + }, op -> op.allowNonQueryDelete()); + searchFieldLogBhv.varyingQueryDelete(cb3 -> { + cb3.query().querySearchLog().setRequestedTime_LessThan(now); + cb3.query().querySearchLog().setUserAgent_LikeSearch(userAgent, op -> op.likeContain()); + }, op -> op.allowNonQueryDelete()); + searchLogBhv.varyingQueryDelete(cb1 -> { + cb1.query().setRequestedTime_LessThan(now); + cb1.query().setUserAgent_LikeSearch(userAgent, op -> op.likeContain()); + }, op -> op.allowNonQueryDelete()); } } @Override public void store(final SearchLog searchLog) { super.store(searchLog); - final List searchFieldLogList = searchLog - .getSearchFieldLogList(); + final List searchFieldLogList = searchLog.getSearchFieldLogList(); if (!searchFieldLogList.isEmpty()) { final List fieldLogList = new ArrayList(); for (final SearchFieldLog fieldLog : searchFieldLogList) { @@ -626,8 +563,7 @@ public class SearchLogService extends BsSearchLogService implements for (final SearchLog searchLog : searchLogList) { searchLogBhv.insert(searchLog); final List fieldLogList = new ArrayList(); - for (final SearchFieldLog fieldLog : searchLog - .getSearchFieldLogList()) { + for (final SearchFieldLog fieldLog : searchLog.getSearchFieldLogList()) { fieldLog.setSearchId(searchLog.getId()); fieldLogList.add(fieldLog); } diff --git a/src/main/java/org/codelibs/fess/service/SearchService.java b/src/main/java/org/codelibs/fess/service/SearchService.java index cd21f45c0..b685ec82b 100644 --- a/src/main/java/org/codelibs/fess/service/SearchService.java +++ b/src/main/java/org/codelibs/fess/service/SearchService.java @@ -64,8 +64,7 @@ public class SearchService implements Serializable { protected RoleQueryHelper roleQueryHelper; public PingResponse ping() { - final SolrGroup solrGroup = solrGroupManager - .getSolrGroup(QueryType.QUERY); + final SolrGroup solrGroup = solrGroupManager.getSolrGroup(QueryType.QUERY); return new PingResponse(solrGroup.ping()); } @@ -73,18 +72,15 @@ public class SearchService implements Serializable { return getDocument(query, queryHelper.getResponseFields(), null); } - public Map getDocument(final String query, - final String[] responseFields, final String[] docValuesFields) { - final List> docList = getDocumentList(query, 0, 1, - null, null, null, responseFields, docValuesFields); + public Map getDocument(final String query, final String[] responseFields, final String[] docValuesFields) { + final List> docList = getDocumentList(query, 0, 1, null, null, null, responseFields, docValuesFields); if (!docList.isEmpty()) { return docList.get(0); } return null; } - public List> getDocumentListByDocIds( - final String[] docIds, final String[] responseFields, + public List> getDocumentListByDocIds(final String[] docIds, final String[] responseFields, final String[] docValuesFields, final int pageSize) { if (docIds == null || docIds.length == 0) { return Collections.emptyList(); @@ -97,32 +93,24 @@ public class SearchService implements Serializable { } buf.append(fieldHelper.docIdField + ":").append(docIds[i]); } - return getDocumentList(buf.toString(), 0, pageSize, null, null, null, - responseFields, docValuesFields); + return getDocumentList(buf.toString(), 0, pageSize, null, null, null, responseFields, docValuesFields); } - public List> getDocumentList(final String query, - final int start, final int rows, final FacetInfo facetInfo, - final GeoInfo geoInfo, final MoreLikeThisInfo mltInfo, - final String[] responseFields, final String[] docValuesFields) { - return getDocumentList(query, start, rows, facetInfo, geoInfo, mltInfo, - responseFields, docValuesFields, true); + public List> getDocumentList(final String query, final int start, final int rows, final FacetInfo facetInfo, + final GeoInfo geoInfo, final MoreLikeThisInfo mltInfo, final String[] responseFields, final String[] docValuesFields) { + return getDocumentList(query, start, rows, facetInfo, geoInfo, mltInfo, responseFields, docValuesFields, true); } - public List> getDocumentList(final String query, - final int start, final int rows, final FacetInfo facetInfo, - final GeoInfo geoInfo, final MoreLikeThisInfo mltInfo, - final String[] responseFields, final String[] docValuesFields, + public List> getDocumentList(final String query, final int start, final int rows, final FacetInfo facetInfo, + final GeoInfo geoInfo, final MoreLikeThisInfo mltInfo, final String[] responseFields, final String[] docValuesFields, final boolean forUser) { if (start > queryHelper.getMaxSearchResultOffset()) { - throw new ResultOffsetExceededException( - "The number of result size is exceeded."); + throw new ResultOffsetExceededException("The number of result size is exceeded."); } final long startTime = System.currentTimeMillis(); - final SolrGroup solrGroup = solrGroupManager - .getSolrGroup(QueryType.QUERY); + final SolrGroup solrGroup = solrGroupManager.getSolrGroup(QueryType.QUERY); QueryResponse queryResponse = null; final SolrQuery solrQuery = new SolrQuery(); @@ -137,8 +125,7 @@ public class SearchService implements Serializable { solrQuery.setRows(rows); solrQuery.set("mm", searchQuery.getMinimumShouldMatch()); solrQuery.set("defType", searchQuery.getDefType()); - for (final Map.Entry entry : queryHelper - .getQueryParamMap().entrySet()) { + for (final Map.Entry entry : queryHelper.getQueryParamMap().entrySet()) { solrQuery.set(entry.getKey(), entry.getValue()); } // filter query @@ -149,30 +136,21 @@ public class SearchService implements Serializable { final SortField[] sortFields = searchQuery.getSortFields(); if (sortFields.length != 0) { for (final SortField sortField : sortFields) { - solrQuery - .addSort( - sortField.getField(), - Constants.DESC.equals(sortField.getOrder()) ? SolrQuery.ORDER.desc - : SolrQuery.ORDER.asc); + solrQuery.addSort(sortField.getField(), Constants.DESC.equals(sortField.getOrder()) ? SolrQuery.ORDER.desc + : SolrQuery.ORDER.asc); } } else if (queryHelper.hasDefaultSortFields()) { - for (final SortField sortField : queryHelper - .getDefaultSortFields()) { - solrQuery - .addSort( - sortField.getField(), - Constants.DESC.equals(sortField.getOrder()) ? SolrQuery.ORDER.desc - : SolrQuery.ORDER.asc); + for (final SortField sortField : queryHelper.getDefaultSortFields()) { + solrQuery.addSort(sortField.getField(), Constants.DESC.equals(sortField.getOrder()) ? SolrQuery.ORDER.desc + : SolrQuery.ORDER.asc); } } // highlighting - if (queryHelper.getHighlightingFields() != null - && queryHelper.getHighlightingFields().length != 0) { + if (queryHelper.getHighlightingFields() != null && queryHelper.getHighlightingFields().length != 0) { for (final String hf : queryHelper.getHighlightingFields()) { solrQuery.addHighlightField(hf); } - solrQuery.setHighlightSnippets(queryHelper - .getHighlightSnippetSize()); + solrQuery.setHighlightSnippets(queryHelper.getHighlightSnippetSize()); } // shards if (queryHelper.getShards() != null) { @@ -181,8 +159,7 @@ public class SearchService implements Serializable { // geo if (geoInfo != null && geoInfo.isAvailable()) { solrQuery.addFilterQuery(geoInfo.toGeoQueryString()); - final String additionalGeoQuery = queryHelper - .getAdditionalGeoQuery(); + final String additionalGeoQuery = queryHelper.getAdditionalGeoQuery(); if (StringUtil.isNotBlank(additionalGeoQuery)) { solrQuery.addFilterQuery(additionalGeoQuery); } @@ -195,20 +172,17 @@ public class SearchService implements Serializable { if (queryHelper.isFacetField(f)) { solrQuery.addFacetField(f); } else { - throw new FessSolrQueryException("EFESS0002", - new Object[] { f }); + throw new FessSolrQueryException("EFESS0002", new Object[] { f }); } } } if (facetInfo.query != null) { for (final String fq : facetInfo.query) { - final String facetQuery = queryHelper - .buildFacetQuery(fq); + final String facetQuery = queryHelper.buildFacetQuery(fq); if (StringUtil.isNotBlank(facetQuery)) { solrQuery.addFacetQuery(facetQuery); } else { - throw new FessSolrQueryException("EFESS0003", - new Object[] { fq, facetQuery }); + throw new FessSolrQueryException("EFESS0003", new Object[] { fq, facetQuery }); } } } @@ -216,30 +190,25 @@ public class SearchService implements Serializable { solrQuery.setFacetLimit(Integer.parseInt(facetInfo.limit)); } if (facetInfo.minCount != null) { - solrQuery.setFacetMinCount(Integer - .parseInt(facetInfo.minCount)); + solrQuery.setFacetMinCount(Integer.parseInt(facetInfo.minCount)); } if (facetInfo.missing != null) { - solrQuery.setFacetMissing(Boolean - .parseBoolean(facetInfo.missing)); + solrQuery.setFacetMissing(Boolean.parseBoolean(facetInfo.missing)); } if (facetInfo.prefix != null) { solrQuery.setFacetPrefix(facetInfo.prefix); } - if (facetInfo.sort != null - && queryHelper.isFacetSortValue(facetInfo.sort)) { + if (facetInfo.sort != null && queryHelper.isFacetSortValue(facetInfo.sort)) { solrQuery.setFacetSort(facetInfo.sort); } } // mlt if (mltInfo != null) { - final String mltField = queryHelper - .getMoreLikeThisField(mltInfo.field); + final String mltField = queryHelper.getMoreLikeThisField(mltInfo.field); if (mltField != null) { solrQuery.set("mlt", true); if (mltInfo.count != null) { - solrQuery.set("mlt.count", - Integer.parseInt(mltInfo.count)); + solrQuery.set("mlt.count", Integer.parseInt(mltInfo.count)); } solrQuery.set("mlt.fl", mltField); } @@ -248,8 +217,7 @@ public class SearchService implements Serializable { if (queryHelper.getTimeAllowed() >= 0) { solrQuery.setTimeAllowed(queryHelper.getTimeAllowed()); } - final Set> paramSet = queryHelper - .getRequestParameterSet(); + final Set> paramSet = queryHelper.getRequestParameterSet(); if (!paramSet.isEmpty()) { for (final Map.Entry entry : paramSet) { solrQuery.set(entry.getKey(), entry.getValue()); @@ -266,8 +234,7 @@ public class SearchService implements Serializable { } final long execTime = System.currentTimeMillis() - startTime; - final QueryResponseList queryResponseList = ComponentUtil - .getQueryResponseList(); + final QueryResponseList queryResponseList = ComponentUtil.getQueryResponseList(); queryResponseList.init(queryResponse, rows); queryResponseList.setSearchQuery(q); queryResponseList.setSolrQuery(solrQuery.toString()); @@ -275,14 +242,12 @@ public class SearchService implements Serializable { return queryResponseList; } - public FieldAnalysisResponse getFieldAnalysisResponse( - final String[] fieldNames, final String fieldValue) { + public FieldAnalysisResponse getFieldAnalysisResponse(final String[] fieldNames, final String fieldValue) { final FieldAnalysisRequest request = new FieldAnalysisRequest(); for (final String fieldName : fieldNames) { if (!queryHelper.isAnalysisFieldName(fieldName)) { - throw new FessSolrQueryException("EFESS0001", - new Object[] { fieldName }); + throw new FessSolrQueryException("EFESS0001", new Object[] { fieldName }); } request.addFieldName(fieldName); } @@ -290,15 +255,13 @@ public class SearchService implements Serializable { final long startTime = System.currentTimeMillis(); - final SolrGroup solrGroup = solrGroupManager - .getSolrGroup(QueryType.REQUEST); + final SolrGroup solrGroup = solrGroupManager.getSolrGroup(QueryType.REQUEST); final NamedList response = solrGroup.request(request); final long execTime = System.currentTimeMillis() - startTime; - final FieldAnalysisResponse fieldAnalysisResponse = new FieldAnalysisResponse( - response); + final FieldAnalysisResponse fieldAnalysisResponse = new FieldAnalysisResponse(response); fieldAnalysisResponse.setExecTime(execTime); return fieldAnalysisResponse; } diff --git a/src/main/java/org/codelibs/fess/service/StatsService.java b/src/main/java/org/codelibs/fess/service/StatsService.java index 2db559409..f678cb6af 100644 --- a/src/main/java/org/codelibs/fess/service/StatsService.java +++ b/src/main/java/org/codelibs/fess/service/StatsService.java @@ -103,8 +103,7 @@ public class StatsService implements Serializable { return false; } - protected List> getSearchWordStatsList( - final StatsPager statsPager) { + protected List> getSearchWordStatsList(final StatsPager statsPager) { final SearchWordRankingPmb pmb = new SearchWordRankingPmb(); @@ -114,12 +113,10 @@ public class StatsService implements Serializable { pmb.setToRequestedTime(statsPager.getToRequestedTime()); final String path = BsSearchLogBhv.PATH_selectSearchWordRanking; - final PagingResultBean statsList = searchLogBhv - .outsideSql().selectPage(pmb); + final PagingResultBean statsList = searchLogBhv.outsideSql().selectPage(pmb); // update pager - Beans.copy(statsList, statsPager) - .includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); + Beans.copy(statsList, statsPager).includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); statsPager.setPageNumberList(statsList.pageRange(op -> { op.rangeSize(5); }).createPageNumberList()); @@ -134,8 +131,7 @@ public class StatsService implements Serializable { return mapList; } - protected List> getSearchQueryStatsList( - final StatsPager statsPager) { + protected List> getSearchQueryStatsList(final StatsPager statsPager) { final SearchQueryRankingPmb pmb = new SearchQueryRankingPmb(); @@ -145,12 +141,10 @@ public class StatsService implements Serializable { pmb.setToRequestedTime(statsPager.getToRequestedTime()); final String path = BsSearchLogBhv.PATH_selectSearchQueryRanking; - final PagingResultBean statsList = searchLogBhv - .outsideSql().selectPage(pmb); + final PagingResultBean statsList = searchLogBhv.outsideSql().selectPage(pmb); // update pager - Beans.copy(statsList, statsPager) - .includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); + Beans.copy(statsList, statsPager).includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); statsPager.setPageNumberList(statsList.pageRange(op -> { op.rangeSize(5); }).createPageNumberList()); @@ -165,8 +159,7 @@ public class StatsService implements Serializable { return mapList; } - protected List> getSolrQueryStatsList( - final StatsPager statsPager) { + protected List> getSolrQueryStatsList(final StatsPager statsPager) { final SolrQueryRankingPmb pmb = new SolrQueryRankingPmb(); @@ -176,12 +169,10 @@ public class StatsService implements Serializable { pmb.setToRequestedTime(statsPager.getToRequestedTime()); final String path = BsSearchLogBhv.PATH_selectSolrQueryRanking; - final PagingResultBean statsList = searchLogBhv - .outsideSql().selectPage(pmb); + final PagingResultBean statsList = searchLogBhv.outsideSql().selectPage(pmb); // update pager - Beans.copy(statsList, statsPager) - .includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); + Beans.copy(statsList, statsPager).includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); statsPager.setPageNumberList(statsList.pageRange(op -> { op.rangeSize(5); }).createPageNumberList()); @@ -196,8 +187,7 @@ public class StatsService implements Serializable { return mapList; } - protected List> getUserAgentStatsList( - final StatsPager statsPager) { + protected List> getUserAgentStatsList(final StatsPager statsPager) { final UserAgentRankingPmb pmb = new UserAgentRankingPmb(); @@ -207,12 +197,10 @@ public class StatsService implements Serializable { pmb.setToRequestedTime(statsPager.getToRequestedTime()); final String path = BsSearchLogBhv.PATH_selectUserAgentRanking; - final PagingResultBean statsList = searchLogBhv - .outsideSql().selectPage(pmb); + final PagingResultBean statsList = searchLogBhv.outsideSql().selectPage(pmb); // update pager - Beans.copy(statsList, statsPager) - .includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); + Beans.copy(statsList, statsPager).includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); statsPager.setPageNumberList(statsList.pageRange(op -> { op.rangeSize(5); }).createPageNumberList()); @@ -227,8 +215,7 @@ public class StatsService implements Serializable { return mapList; } - protected List> getRefererStatsList( - final StatsPager statsPager) { + protected List> getRefererStatsList(final StatsPager statsPager) { final RefererRankingPmb pmb = new RefererRankingPmb(); @@ -238,12 +225,10 @@ public class StatsService implements Serializable { pmb.setToRequestedTime(statsPager.getToRequestedTime()); final String path = BsSearchLogBhv.PATH_selectRefererRanking; - final PagingResultBean statsList = searchLogBhv - .outsideSql().selectPage(pmb); + final PagingResultBean statsList = searchLogBhv.outsideSql().selectPage(pmb); // update pager - Beans.copy(statsList, statsPager) - .includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); + Beans.copy(statsList, statsPager).includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); statsPager.setPageNumberList(statsList.pageRange(op -> { op.rangeSize(5); }).createPageNumberList()); @@ -258,8 +243,7 @@ public class StatsService implements Serializable { return mapList; } - protected List> getClientIpStatsList( - final StatsPager statsPager) { + protected List> getClientIpStatsList(final StatsPager statsPager) { final ClientIpRankingPmb pmb = new ClientIpRankingPmb(); @@ -269,12 +253,10 @@ public class StatsService implements Serializable { pmb.setToRequestedTime(statsPager.getToRequestedTime()); final String path = BsSearchLogBhv.PATH_selectClientIpRanking; - final PagingResultBean statsList = searchLogBhv - .outsideSql().selectPage(pmb); + final PagingResultBean statsList = searchLogBhv.outsideSql().selectPage(pmb); // update pager - Beans.copy(statsList, statsPager) - .includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); + Beans.copy(statsList, statsPager).includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); statsPager.setPageNumberList(statsList.pageRange(op -> { op.rangeSize(5); }).createPageNumberList()); @@ -289,8 +271,7 @@ public class StatsService implements Serializable { return mapList; } - protected List> getClickUrlStatsList( - final StatsPager statsPager) { + protected List> getClickUrlStatsList(final StatsPager statsPager) { final ClickUrlRankingPmb pmb = new ClickUrlRankingPmb(); @@ -300,12 +281,10 @@ public class StatsService implements Serializable { pmb.setToRequestedTime(statsPager.getToRequestedTime()); final String path = BsClickLogBhv.PATH_selectClickUrlRanking; - final PagingResultBean statsList = clicklogBhv - .outsideSql().selectPage(pmb); + final PagingResultBean statsList = clicklogBhv.outsideSql().selectPage(pmb); // update pager - Beans.copy(statsList, statsPager) - .includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); + Beans.copy(statsList, statsPager).includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); statsPager.setPageNumberList(statsList.pageRange(op -> { op.rangeSize(5); }).createPageNumberList()); @@ -320,8 +299,7 @@ public class StatsService implements Serializable { return mapList; } - protected List> getFavoriteUrlStatsList( - final StatsPager statsPager) { + protected List> getFavoriteUrlStatsList(final StatsPager statsPager) { final FavoriteUrlRankingPmb pmb = new FavoriteUrlRankingPmb(); @@ -331,12 +309,10 @@ public class StatsService implements Serializable { pmb.setToCreatedTime(statsPager.getToRequestedTime()); final String path = BsFavoriteLogBhv.PATH_selectFavoriteUrlRanking; - final PagingResultBean statsList = favoriteLogBhv - .outsideSql().selectPage(pmb); + final PagingResultBean statsList = favoriteLogBhv.outsideSql().selectPage(pmb); // update pager - Beans.copy(statsList, statsPager) - .includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); + Beans.copy(statsList, statsPager).includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); statsPager.setPageNumberList(statsList.pageRange(op -> { op.rangeSize(5); }).createPageNumberList()); @@ -351,8 +327,7 @@ public class StatsService implements Serializable { return mapList; } - protected List> getGroupedFieldStatsList( - final StatsPager statsPager) { + protected List> getGroupedFieldStatsList(final StatsPager statsPager) { final SearchFieldRankingPmb pmb = new SearchFieldRankingPmb(); @@ -363,12 +338,10 @@ public class StatsService implements Serializable { pmb.setToRequestedTime(statsPager.getToRequestedTime()); final String path = BsSearchLogBhv.PATH_selectSearchFieldRanking; - final PagingResultBean statsList = searchLogBhv - .outsideSql().selectPage(pmb); + final PagingResultBean statsList = searchLogBhv.outsideSql().selectPage(pmb); // update pager - Beans.copy(statsList, statsPager) - .includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); + Beans.copy(statsList, statsPager).includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); statsPager.setPageNumberList(statsList.pageRange(op -> { op.rangeSize(5); }).createPageNumberList()); diff --git a/src/main/java/org/codelibs/fess/service/SuggestBadWordService.java b/src/main/java/org/codelibs/fess/service/SuggestBadWordService.java index 3025fab8f..2e3acd7c8 100644 --- a/src/main/java/org/codelibs/fess/service/SuggestBadWordService.java +++ b/src/main/java/org/codelibs/fess/service/SuggestBadWordService.java @@ -39,19 +39,16 @@ import org.codelibs.fess.pager.SuggestBadWordPager; import org.codelibs.fess.util.ComponentUtil; import org.dbflute.bhv.readable.EntityRowHandler; -public class SuggestBadWordService extends BsSuggestBadWordService implements - Serializable { +public class SuggestBadWordService extends BsSuggestBadWordService implements Serializable { private static final String DELETE_PREFIX = "--"; private static final long serialVersionUID = 1L; - private static final Log log = LogFactory - .getLog(SuggestBadWordService.class); + private static final Log log = LogFactory.getLog(SuggestBadWordService.class); @Override - protected void setupListCondition(final SuggestBadWordCB cb, - final SuggestBadWordPager suggestBadWordPager) { + protected void setupListCondition(final SuggestBadWordCB cb, final SuggestBadWordPager suggestBadWordPager) { super.setupListCondition(cb, suggestBadWordPager); // setup condition @@ -63,8 +60,7 @@ public class SuggestBadWordService extends BsSuggestBadWordService implements } @Override - protected void setupEntityCondition(final SuggestBadWordCB cb, - final Map keys) { + protected void setupEntityCondition(final SuggestBadWordCB cb, final Map keys) { super.setupEntityCondition(cb, keys); // setup condition @@ -105,12 +101,10 @@ public class SuggestBadWordService extends BsSuggestBadWordService implements badWord = badWord.substring(2); } final String target = badWord; - SuggestBadWord suggestBadWord = suggestBadWordBhv - .selectEntity(cb -> { - cb.query().setSuggestWord_Equal(target); - }).orElse(null);//TODO - final LocalDateTime now = ComponentUtil.getSystemHelper() - .getCurrentTime(); + SuggestBadWord suggestBadWord = suggestBadWordBhv.selectEntity(cb -> { + cb.query().setSuggestWord_Equal(target); + }).orElse(null);//TODO + final LocalDateTime now = ComponentUtil.getSystemHelper().getCurrentTime(); if (isDelete) { suggestBadWord.setDeletedBy("system"); suggestBadWord.setDeletedTime(now); @@ -156,14 +150,11 @@ public class SuggestBadWordService extends BsSuggestBadWordService implements try { csvWriter.writeValues(list); } catch (final IOException e) { - log.warn( - "Failed to write a sugget bad word: " + entity, - e); + log.warn("Failed to write a sugget bad word: " + entity, e); } } - private void addToList(final List list, - final Object value) { + private void addToList(final List list, final Object value) { if (value == null) { list.add(StringUtil.EMPTY); } else { @@ -186,8 +177,7 @@ public class SuggestBadWordService extends BsSuggestBadWordService implements if (StringUtil.isBlank(item)) { return StringUtil.EMPTY; } - if (item.length() > 1 && item.charAt(0) == '"' - && item.charAt(item.length() - 1) == '"') { + if (item.length() > 1 && item.charAt(0) == '"' && item.charAt(item.length() - 1) == '"') { item = item.substring(1, item.length() - 1); } return item; diff --git a/src/main/java/org/codelibs/fess/service/SuggestElevateWordService.java b/src/main/java/org/codelibs/fess/service/SuggestElevateWordService.java index 8609169a9..06a6136e0 100644 --- a/src/main/java/org/codelibs/fess/service/SuggestElevateWordService.java +++ b/src/main/java/org/codelibs/fess/service/SuggestElevateWordService.java @@ -40,17 +40,14 @@ import org.codelibs.fess.pager.SuggestElevateWordPager; import org.codelibs.fess.util.ComponentUtil; import org.dbflute.bhv.readable.EntityRowHandler; -public class SuggestElevateWordService extends BsSuggestElevateWordService - implements Serializable { +public class SuggestElevateWordService extends BsSuggestElevateWordService implements Serializable { private static final long serialVersionUID = 1L; - private static final Log log = LogFactory - .getLog(SuggestElevateWordService.class); + private static final Log log = LogFactory.getLog(SuggestElevateWordService.class); @Override - protected void setupListCondition(final SuggestElevateWordCB cb, - final SuggestElevateWordPager suggestElevateWordPager) { + protected void setupListCondition(final SuggestElevateWordCB cb, final SuggestElevateWordPager suggestElevateWordPager) { super.setupListCondition(cb, suggestElevateWordPager); // setup condition @@ -62,8 +59,7 @@ public class SuggestElevateWordService extends BsSuggestElevateWordService } @Override - protected void setupEntityCondition(final SuggestElevateWordCB cb, - final Map keys) { + protected void setupEntityCondition(final SuggestElevateWordCB cb, final Map keys) { super.setupEntityCondition(cb, keys); // setup condition @@ -71,8 +67,7 @@ public class SuggestElevateWordService extends BsSuggestElevateWordService } @Override - protected void setupStoreCondition( - final SuggestElevateWord suggestElevateWord) { + protected void setupStoreCondition(final SuggestElevateWord suggestElevateWord) { super.setupStoreCondition(suggestElevateWord); // setup condition @@ -80,8 +75,7 @@ public class SuggestElevateWordService extends BsSuggestElevateWordService } @Override - protected void setupDeleteCondition( - final SuggestElevateWord suggestElevateWord) { + protected void setupDeleteCondition(final SuggestElevateWord suggestElevateWord) { super.setupDeleteCondition(suggestElevateWord); // setup condition @@ -102,42 +96,35 @@ public class SuggestElevateWordService extends BsSuggestElevateWordService try { final String role = getValue(list, 2); final String label = getValue(list, 3); - SuggestElevateWord suggestElevateWord = suggestElevateWordBhv - .selectEntity(cb -> { - cb.query().setSuggestWord_Equal(suggestWord); - if (StringUtil.isNotBlank(role)) { - cb.query().setTargetRole_Equal(role); - } - if (StringUtil.isNotBlank(label)) { - cb.query().setTargetLabel_Equal(label); - } - }).orElse(null);//TODO + SuggestElevateWord suggestElevateWord = suggestElevateWordBhv.selectEntity(cb -> { + cb.query().setSuggestWord_Equal(suggestWord); + if (StringUtil.isNotBlank(role)) { + cb.query().setTargetRole_Equal(role); + } + if (StringUtil.isNotBlank(label)) { + cb.query().setTargetLabel_Equal(label); + } + }).orElse(null);//TODO final String reading = getValue(list, 1); final String boost = getValue(list, 4); - final LocalDateTime now = ComponentUtil.getSystemHelper() - .getCurrentTime(); + final LocalDateTime now = ComponentUtil.getSystemHelper().getCurrentTime(); if (suggestElevateWord == null) { suggestElevateWord = new SuggestElevateWord(); suggestElevateWord.setSuggestWord(suggestWord); suggestElevateWord.setReading(reading); suggestElevateWord.setTargetRole(role); suggestElevateWord.setTargetLabel(label); - suggestElevateWord - .setBoost(StringUtil.isBlank(boost) ? BigDecimal.ONE - : new BigDecimal(boost)); + suggestElevateWord.setBoost(StringUtil.isBlank(boost) ? BigDecimal.ONE : new BigDecimal(boost)); suggestElevateWord.setCreatedBy("system"); suggestElevateWord.setCreatedTime(now); suggestElevateWordBhv.insert(suggestElevateWord); - } else if (StringUtil.isBlank(reading) - && StringUtil.isBlank(boost)) { + } else if (StringUtil.isBlank(reading) && StringUtil.isBlank(boost)) { suggestElevateWord.setDeletedBy("system"); suggestElevateWord.setDeletedTime(now); suggestElevateWordBhv.update(suggestElevateWord); } else { suggestElevateWord.setReading(reading); - suggestElevateWord - .setBoost(StringUtil.isBlank(boost) ? BigDecimal.ONE - : new BigDecimal(boost)); + suggestElevateWord.setBoost(StringUtil.isBlank(boost) ? BigDecimal.ONE : new BigDecimal(boost)); suggestElevateWord.setUpdatedBy("system"); suggestElevateWord.setUpdatedTime(now); suggestElevateWordBhv.update(suggestElevateWord); @@ -180,13 +167,11 @@ public class SuggestElevateWordService extends BsSuggestElevateWordService try { csvWriter.writeValues(list); } catch (final IOException e) { - log.warn("Failed to write a sugget elevate word: " - + entity, e); + log.warn("Failed to write a sugget elevate word: " + entity, e); } } - private void addToList(final List list, - final Object value) { + private void addToList(final List list, final Object value) { if (value == null) { list.add(StringUtil.EMPTY); } else { @@ -209,8 +194,7 @@ public class SuggestElevateWordService extends BsSuggestElevateWordService if (StringUtil.isBlank(item)) { return StringUtil.EMPTY; } - if (item.length() > 1 && item.charAt(0) == '"' - && item.charAt(item.length() - 1) == '"') { + if (item.length() > 1 && item.charAt(0) == '"' && item.charAt(item.length() - 1) == '"') { item = item.substring(1, item.length() - 1); } return item; diff --git a/src/main/java/org/codelibs/fess/service/SynonymService.java b/src/main/java/org/codelibs/fess/service/SynonymService.java index de5de0e05..f610aa55a 100644 --- a/src/main/java/org/codelibs/fess/service/SynonymService.java +++ b/src/main/java/org/codelibs/fess/service/SynonymService.java @@ -36,17 +36,14 @@ public class SynonymService { @Resource protected DictionaryManager dictionaryManager; - public List getSynonymList(final String dictId, - final SynonymPager synonymPager) { + public List getSynonymList(final String dictId, final SynonymPager synonymPager) { final SynonymFile synonymFile = getSynonymFile(dictId); final int pageSize = synonymPager.getPageSize(); - final PagingList synonymList = synonymFile.selectList( - (synonymPager.getCurrentPageNumber() - 1) * pageSize, pageSize); + final PagingList synonymList = synonymFile.selectList((synonymPager.getCurrentPageNumber() - 1) * pageSize, pageSize); // update pager - Beans.copy(synonymList, synonymPager) - .includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); + Beans.copy(synonymList, synonymPager).includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); synonymList.setPageRangeSize(5); synonymPager.setPageNumberList(synonymList.createPageNumberList()); @@ -55,16 +52,14 @@ public class SynonymService { } public SynonymFile getSynonymFile(final String dictId) { - final DictionaryFile dictionaryFile = dictionaryManager - .getDictionaryFile(dictId); + final DictionaryFile dictionaryFile = dictionaryManager.getDictionaryFile(dictId); if (dictionaryFile instanceof SynonymFile) { return (SynonymFile) dictionaryFile; } throw new DictionaryExpiredException(); } - public SynonymItem getSynonym(final String dictId, - final Map paramMap) { + public SynonymItem getSynonym(final String dictId, final Map paramMap) { final SynonymFile synonymFile = getSynonymFile(dictId); final String idStr = paramMap.get("id"); diff --git a/src/main/java/org/codelibs/fess/service/UserDictService.java b/src/main/java/org/codelibs/fess/service/UserDictService.java index 838a54a0f..e987d844a 100644 --- a/src/main/java/org/codelibs/fess/service/UserDictService.java +++ b/src/main/java/org/codelibs/fess/service/UserDictService.java @@ -36,18 +36,15 @@ public class UserDictService { @Resource protected DictionaryManager dictionaryManager; - public List getUserDictList(final String dictId, - final UserDictPager userDictPager) { + public List getUserDictList(final String dictId, final UserDictPager userDictPager) { final UserDictFile userDictFile = getUserDictFile(dictId); final int pageSize = userDictPager.getPageSize(); - final PagingList userDictList = userDictFile - .selectList((userDictPager.getCurrentPageNumber() - 1) - * pageSize, pageSize); + final PagingList userDictList = + userDictFile.selectList((userDictPager.getCurrentPageNumber() - 1) * pageSize, pageSize); // update pager - Beans.copy(userDictList, userDictPager) - .includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); + Beans.copy(userDictList, userDictPager).includes(CommonConstants.PAGER_CONVERSION_RULE).execute(); userDictList.setPageRangeSize(5); userDictPager.setPageNumberList(userDictList.createPageNumberList()); @@ -56,16 +53,14 @@ public class UserDictService { } public UserDictFile getUserDictFile(final String dictId) { - final DictionaryFile dictionaryFile = dictionaryManager - .getDictionaryFile(dictId); + final DictionaryFile dictionaryFile = dictionaryManager.getDictionaryFile(dictId); if (dictionaryFile instanceof UserDictFile) { return (UserDictFile) dictionaryFile; } throw new DictionaryExpiredException(); } - public UserDictItem getUserDict(final String dictId, - final Map paramMap) { + public UserDictItem getUserDict(final String dictId, final Map paramMap) { final UserDictFile userDictFile = getUserDictFile(dictId); final String idStr = paramMap.get("id"); diff --git a/src/main/java/org/codelibs/fess/service/UserInfoService.java b/src/main/java/org/codelibs/fess/service/UserInfoService.java index a67eef728..8d2fea66c 100644 --- a/src/main/java/org/codelibs/fess/service/UserInfoService.java +++ b/src/main/java/org/codelibs/fess/service/UserInfoService.java @@ -42,8 +42,7 @@ public class UserInfoService extends BsUserInfoService implements Serializable { protected FavoriteLogBhv favoriteLogBhv; @Override - protected void setupListCondition(final UserInfoCB cb, - final UserInfoPager userInfoPager) { + protected void setupListCondition(final UserInfoCB cb, final UserInfoPager userInfoPager) { // setup condition cb.query().addOrderBy_UpdatedTime_Desc(); @@ -54,8 +53,7 @@ public class UserInfoService extends BsUserInfoService implements Serializable { } @Override - protected void setupEntityCondition(final UserInfoCB cb, - final Map keys) { + protected void setupEntityCondition(final UserInfoCB cb, final Map keys) { super.setupEntityCondition(cb, keys); // setup condition @@ -101,93 +99,68 @@ public class UserInfoService extends BsUserInfoService implements Serializable { public void deleteBefore(final int days) { final UserInfoPager userInfoPager = new UserInfoPager(); - userInfoPager.updatedTimeBefore = ComponentUtil.getSystemHelper() - .getCurrentTime().minusDays(days); + userInfoPager.updatedTimeBefore = ComponentUtil.getSystemHelper().getCurrentTime().minusDays(days); deleteInternal(userInfoPager); } protected void deleteInternal(final UserInfoPager userInfoPager) { - final boolean hasCb = StringUtil.isNotBlank(userInfoPager.code) - || userInfoPager.updatedTimeBefore != null; + final boolean hasCb = StringUtil.isNotBlank(userInfoPager.code) || userInfoPager.updatedTimeBefore != null; if (hasCb) { final SearchLog searchLog = new SearchLog(); searchLog.setUserId(null); - searchLogBhv.queryUpdate( - searchLog, - cb1 -> { - if (StringUtil.isNotBlank(userInfoPager.code)) { - cb1.query().queryUserInfo() - .setCode_Equal(userInfoPager.code); - } - - if (userInfoPager.updatedTimeBefore != null) { - cb1.query() - .queryUserInfo() - .setUpdatedTime_LessEqual( - userInfoPager.updatedTimeBefore); - } - }); - - favoriteLogBhv.queryDelete(cb2 -> { + searchLogBhv.queryUpdate(searchLog, cb1 -> { if (StringUtil.isNotBlank(userInfoPager.code)) { - cb2.query().queryUserInfo() - .setCode_Equal(userInfoPager.code); + cb1.query().queryUserInfo().setCode_Equal(userInfoPager.code); } if (userInfoPager.updatedTimeBefore != null) { - cb2.query() - .queryUserInfo() - .setUpdatedTime_LessEqual( - userInfoPager.updatedTimeBefore); + cb1.query().queryUserInfo().setUpdatedTime_LessEqual(userInfoPager.updatedTimeBefore); + } + }); + + favoriteLogBhv.queryDelete(cb2 -> { + if (StringUtil.isNotBlank(userInfoPager.code)) { + cb2.query().queryUserInfo().setCode_Equal(userInfoPager.code); + } + + if (userInfoPager.updatedTimeBefore != null) { + cb2.query().queryUserInfo().setUpdatedTime_LessEqual(userInfoPager.updatedTimeBefore); } }); } else { final SearchLog searchLog = new SearchLog(); searchLog.setUserId(null); - searchLogBhv.varyingQueryUpdate( - searchLog, - cb1 -> { - if (StringUtil.isNotBlank(userInfoPager.code)) { - cb1.query().queryUserInfo() - .setCode_Equal(userInfoPager.code); - } + searchLogBhv.varyingQueryUpdate(searchLog, cb1 -> { + if (StringUtil.isNotBlank(userInfoPager.code)) { + cb1.query().queryUserInfo().setCode_Equal(userInfoPager.code); + } - if (userInfoPager.updatedTimeBefore != null) { - cb1.query() - .queryUserInfo() - .setUpdatedTime_LessEqual( - userInfoPager.updatedTimeBefore); - } - }, op -> op.allowNonQueryUpdate()); + if (userInfoPager.updatedTimeBefore != null) { + cb1.query().queryUserInfo().setUpdatedTime_LessEqual(userInfoPager.updatedTimeBefore); + } + }, op -> op.allowNonQueryUpdate()); - favoriteLogBhv.varyingQueryDelete( - cb2 -> { - if (StringUtil.isNotBlank(userInfoPager.code)) { - cb2.query().queryUserInfo() - .setCode_Equal(userInfoPager.code); - } + favoriteLogBhv.varyingQueryDelete(cb2 -> { + if (StringUtil.isNotBlank(userInfoPager.code)) { + cb2.query().queryUserInfo().setCode_Equal(userInfoPager.code); + } - if (userInfoPager.updatedTimeBefore != null) { - cb2.query() - .queryUserInfo() - .setUpdatedTime_LessEqual( - userInfoPager.updatedTimeBefore); - } - }, op -> op.allowNonQueryDelete()); + if (userInfoPager.updatedTimeBefore != null) { + cb2.query().queryUserInfo().setUpdatedTime_LessEqual(userInfoPager.updatedTimeBefore); + } + }, op -> op.allowNonQueryDelete()); } - userInfoBhv.varyingQueryDelete( - cb -> { - if (StringUtil.isNotBlank(userInfoPager.code)) { - cb.query().setCode_Equal(userInfoPager.code); - } + userInfoBhv.varyingQueryDelete(cb -> { + if (StringUtil.isNotBlank(userInfoPager.code)) { + cb.query().setCode_Equal(userInfoPager.code); + } - if (userInfoPager.updatedTimeBefore != null) { - cb.query().setUpdatedTime_LessEqual( - userInfoPager.updatedTimeBefore); - } - }, op -> op.allowNonQueryDelete()); + if (userInfoPager.updatedTimeBefore != null) { + cb.query().setUpdatedTime_LessEqual(userInfoPager.updatedTimeBefore); + } + }, op -> op.allowNonQueryDelete()); } } diff --git a/src/main/java/org/codelibs/fess/service/WebAuthenticationService.java b/src/main/java/org/codelibs/fess/service/WebAuthenticationService.java index 60d1eb25f..2e66e0d78 100644 --- a/src/main/java/org/codelibs/fess/service/WebAuthenticationService.java +++ b/src/main/java/org/codelibs/fess/service/WebAuthenticationService.java @@ -25,14 +25,12 @@ import org.codelibs.fess.db.cbean.WebAuthenticationCB; import org.codelibs.fess.db.exentity.WebAuthentication; import org.codelibs.fess.pager.WebAuthenticationPager; -public class WebAuthenticationService extends BsWebAuthenticationService - implements Serializable { +public class WebAuthenticationService extends BsWebAuthenticationService implements Serializable { private static final long serialVersionUID = 1L; @Override - protected void setupListCondition(final WebAuthenticationCB cb, - final WebAuthenticationPager webAuthenticationPager) { + protected void setupListCondition(final WebAuthenticationCB cb, final WebAuthenticationPager webAuthenticationPager) { super.setupListCondition(cb, webAuthenticationPager); // setup condition @@ -46,8 +44,7 @@ public class WebAuthenticationService extends BsWebAuthenticationService } @Override - protected void setupEntityCondition(final WebAuthenticationCB cb, - final Map keys) { + protected void setupEntityCondition(final WebAuthenticationCB cb, final Map keys) { super.setupEntityCondition(cb, keys); // setup condition @@ -64,16 +61,14 @@ public class WebAuthenticationService extends BsWebAuthenticationService } @Override - protected void setupDeleteCondition( - final WebAuthentication webAuthentication) { + protected void setupDeleteCondition(final WebAuthentication webAuthentication) { super.setupDeleteCondition(webAuthentication); // setup condition } - public List getWebAuthenticationList( - final Long webCrawlingConfigId) { + public List getWebAuthenticationList(final Long webCrawlingConfigId) { return webAuthenticationBhv.selectList(cb -> { cb.query().setWebCrawlingConfigId_Equal(webCrawlingConfigId); }); diff --git a/src/main/java/org/codelibs/fess/service/WebCrawlingConfigService.java b/src/main/java/org/codelibs/fess/service/WebCrawlingConfigService.java index a4b5a1bb1..63084cea8 100644 --- a/src/main/java/org/codelibs/fess/service/WebCrawlingConfigService.java +++ b/src/main/java/org/codelibs/fess/service/WebCrawlingConfigService.java @@ -33,8 +33,7 @@ import org.codelibs.fess.db.exentity.WebConfigToRoleTypeMapping; import org.codelibs.fess.db.exentity.WebCrawlingConfig; import org.codelibs.fess.pager.WebCrawlingConfigPager; -public class WebCrawlingConfigService extends BsWebCrawlingConfigService - implements Serializable { +public class WebCrawlingConfigService extends BsWebCrawlingConfigService implements Serializable { private static final long serialVersionUID = 1L; @@ -48,8 +47,7 @@ public class WebCrawlingConfigService extends BsWebCrawlingConfigService return getAllWebCrawlingConfigList(true, true, true, null); } - public List getWebCrawlingConfigListByIds( - final List idList) { + public List getWebCrawlingConfigListByIds(final List idList) { if (idList == null) { return getAllWebCrawlingConfigList(); } else { @@ -57,19 +55,17 @@ public class WebCrawlingConfigService extends BsWebCrawlingConfigService } } - public List getAllWebCrawlingConfigList( - final boolean withLabelType, final boolean withRoleType, + public List getAllWebCrawlingConfigList(final boolean withLabelType, final boolean withRoleType, final boolean available, final List idList) { - final List list = webCrawlingConfigBhv - .selectList(cb -> { - cb.query().setDeletedBy_IsNull(); - if (available) { - cb.query().setAvailable_Equal(Constants.T); - } - if (idList != null) { - cb.query().setId_InScope(idList); - } - }); + final List list = webCrawlingConfigBhv.selectList(cb -> { + cb.query().setDeletedBy_IsNull(); + if (available) { + cb.query().setAvailable_Equal(Constants.T); + } + if (idList != null) { + cb.query().setId_InScope(idList); + } + }); if (withLabelType) { webCrawlingConfigBhv.loadWebConfigToLabelTypeMapping(list, cb -> { cb.setupSelect_LabelType(); @@ -89,44 +85,33 @@ public class WebCrawlingConfigService extends BsWebCrawlingConfigService @Override public WebCrawlingConfig getWebCrawlingConfig(final Map keys) { - final WebCrawlingConfig webCrawlingConfig = super - .getWebCrawlingConfig(keys); + final WebCrawlingConfig webCrawlingConfig = super.getWebCrawlingConfig(keys); if (webCrawlingConfig != null) { - final List wctltmList = webConfigToLabelTypeMappingBhv - .selectList(wctltmCb -> { - wctltmCb.query().setWebConfigId_Equal( - webCrawlingConfig.getId()); - wctltmCb.query().queryLabelType().setDeletedBy_IsNull(); - wctltmCb.query().queryWebCrawlingConfig() - .setDeletedBy_IsNull(); - }); + final List wctltmList = webConfigToLabelTypeMappingBhv.selectList(wctltmCb -> { + wctltmCb.query().setWebConfigId_Equal(webCrawlingConfig.getId()); + wctltmCb.query().queryLabelType().setDeletedBy_IsNull(); + wctltmCb.query().queryWebCrawlingConfig().setDeletedBy_IsNull(); + }); if (!wctltmList.isEmpty()) { - final List labelTypeIds = new ArrayList( - wctltmList.size()); + final List labelTypeIds = new ArrayList(wctltmList.size()); for (final WebConfigToLabelTypeMapping mapping : wctltmList) { labelTypeIds.add(Long.toString(mapping.getLabelTypeId())); } - webCrawlingConfig.setLabelTypeIds(labelTypeIds - .toArray(new String[labelTypeIds.size()])); + webCrawlingConfig.setLabelTypeIds(labelTypeIds.toArray(new String[labelTypeIds.size()])); } - final List wctrtmList = webConfigToRoleTypeMappingBhv - .selectList(wctrtmCb -> { - wctrtmCb.query().setWebConfigId_Equal( - webCrawlingConfig.getId()); - wctrtmCb.query().queryRoleType().setDeletedBy_IsNull(); - wctrtmCb.query().queryWebCrawlingConfig() - .setDeletedBy_IsNull(); - }); + final List wctrtmList = webConfigToRoleTypeMappingBhv.selectList(wctrtmCb -> { + wctrtmCb.query().setWebConfigId_Equal(webCrawlingConfig.getId()); + wctrtmCb.query().queryRoleType().setDeletedBy_IsNull(); + wctrtmCb.query().queryWebCrawlingConfig().setDeletedBy_IsNull(); + }); if (!wctrtmList.isEmpty()) { - final List roleTypeIds = new ArrayList( - wctrtmList.size()); + final List roleTypeIds = new ArrayList(wctrtmList.size()); for (final WebConfigToRoleTypeMapping mapping : wctrtmList) { roleTypeIds.add(Long.toString(mapping.getRoleTypeId())); } - webCrawlingConfig.setRoleTypeIds(roleTypeIds - .toArray(new String[roleTypeIds.size()])); + webCrawlingConfig.setRoleTypeIds(roleTypeIds.toArray(new String[roleTypeIds.size()])); } } @@ -165,10 +150,9 @@ public class WebCrawlingConfigService extends BsWebCrawlingConfigService } else { // Update if (labelTypeIds != null) { - final List list = webConfigToLabelTypeMappingBhv - .selectList(wctltmCb -> { - wctltmCb.query().setWebConfigId_Equal(webConfigId); - }); + final List list = webConfigToLabelTypeMappingBhv.selectList(wctltmCb -> { + wctltmCb.query().setWebConfigId_Equal(webConfigId); + }); final List newList = new ArrayList(); final List matchedList = new ArrayList(); for (final String id : labelTypeIds) { @@ -194,10 +178,9 @@ public class WebCrawlingConfigService extends BsWebCrawlingConfigService webConfigToLabelTypeMappingBhv.batchDelete(list); } if (roleTypeIds != null) { - final List list = webConfigToRoleTypeMappingBhv - .selectList(wctrtmCb -> { - wctrtmCb.query().setWebConfigId_Equal(webConfigId); - }); + final List list = webConfigToRoleTypeMappingBhv.selectList(wctrtmCb -> { + wctrtmCb.query().setWebConfigId_Equal(webConfigId); + }); final List newList = new ArrayList(); final List matchedList = new ArrayList(); for (final String id : roleTypeIds) { @@ -226,8 +209,7 @@ public class WebCrawlingConfigService extends BsWebCrawlingConfigService } @Override - protected void setupListCondition(final WebCrawlingConfigCB cb, - final WebCrawlingConfigPager webCrawlingConfigPager) { + protected void setupListCondition(final WebCrawlingConfigCB cb, final WebCrawlingConfigPager webCrawlingConfigPager) { super.setupListCondition(cb, webCrawlingConfigPager); // setup condition @@ -240,8 +222,7 @@ public class WebCrawlingConfigService extends BsWebCrawlingConfigService } @Override - protected void setupEntityCondition(final WebCrawlingConfigCB cb, - final Map keys) { + protected void setupEntityCondition(final WebCrawlingConfigCB cb, final Map keys) { super.setupEntityCondition(cb, keys); // setup condition @@ -258,8 +239,7 @@ public class WebCrawlingConfigService extends BsWebCrawlingConfigService } @Override - protected void setupDeleteCondition( - final WebCrawlingConfig webCrawlingConfig) { + protected void setupDeleteCondition(final WebCrawlingConfig webCrawlingConfig) { super.setupDeleteCondition(webCrawlingConfig); // setup condition diff --git a/src/main/java/org/codelibs/fess/servlet/H2ConfigServlet.java b/src/main/java/org/codelibs/fess/servlet/H2ConfigServlet.java index 93375ae24..bf73b0909 100644 --- a/src/main/java/org/codelibs/fess/servlet/H2ConfigServlet.java +++ b/src/main/java/org/codelibs/fess/servlet/H2ConfigServlet.java @@ -29,8 +29,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class H2ConfigServlet extends HttpServlet { - private static final Logger logger = LoggerFactory - .getLogger(H2ConfigServlet.class); + private static final Logger logger = LoggerFactory.getLogger(H2ConfigServlet.class); private static final long serialVersionUID = 1L; @@ -77,8 +76,7 @@ public class H2ConfigServlet extends HttpServlet { if (logger.isInfoEnabled()) { logger.info("Starting H2 server..."); } - server = Server.createTcpServer( - argList.toArray(new String[argList.size()])).start(); + server = Server.createTcpServer(argList.toArray(new String[argList.size()])).start(); } catch (final Exception e) { throw new ServletException("Could not start Fess Config DB.", e); } diff --git a/src/main/java/org/codelibs/fess/servlet/Tomcat6ConfigServlet.java b/src/main/java/org/codelibs/fess/servlet/Tomcat6ConfigServlet.java index 379cba199..051bf762d 100644 --- a/src/main/java/org/codelibs/fess/servlet/Tomcat6ConfigServlet.java +++ b/src/main/java/org/codelibs/fess/servlet/Tomcat6ConfigServlet.java @@ -30,8 +30,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class Tomcat6ConfigServlet extends HttpServlet { - private static final Logger logger = LoggerFactory - .getLogger(Tomcat6ConfigServlet.class); + private static final Logger logger = LoggerFactory.getLogger(Tomcat6ConfigServlet.class); private static final long serialVersionUID = 1L; @@ -52,8 +51,7 @@ public class Tomcat6ConfigServlet extends HttpServlet { private void shutdownCommonsHttpClient() { try { - final Class clazz = Class - .forName("org.apache.commons.httpclient.MultiThreadedHttpConnectionManager"); + final Class clazz = Class.forName("org.apache.commons.httpclient.MultiThreadedHttpConnectionManager"); final Method method = clazz.getMethod("shutdownAll", null); method.invoke(null, null); } catch (final ClassNotFoundException e) { @@ -69,8 +67,7 @@ public class Tomcat6ConfigServlet extends HttpServlet { final ClassLoader cl = this.getClass().getClassLoader(); try { cl.getResource(null); - } catch (final Exception e) { - } + } catch (final Exception e) {} final List jvmThreadGroupList = new ArrayList(); jvmThreadGroupList.add("system"); @@ -99,8 +96,7 @@ public class Tomcat6ConfigServlet extends HttpServlet { } if (logger.isInfoEnabled()) { - logger.info("Interrupting a thread [" - + thread.getName() + "]..."); + logger.info("Interrupting a thread [" + thread.getName() + "]..."); } thread.interrupt(); @@ -111,8 +107,7 @@ public class Tomcat6ConfigServlet extends HttpServlet { } if (logger.isInfoEnabled()) { - logger.info("Stopping a thread [" + thread.getName() - + "]..."); + logger.info("Stopping a thread [" + thread.getName() + "]..."); } thread.stop(); } @@ -125,13 +120,11 @@ public class Tomcat6ConfigServlet extends HttpServlet { try { threadLocalsField = Thread.class.getDeclaredField("threadLocals"); threadLocalsField.setAccessible(true); - inheritableThreadLocalsField = Thread.class - .getDeclaredField("inheritableThreadLocals"); + inheritableThreadLocalsField = Thread.class.getDeclaredField("inheritableThreadLocals"); inheritableThreadLocalsField.setAccessible(true); // Make the underlying array of ThreadLoad.ThreadLocalMap.Entry objects // accessible - final Class tlmClass = Class - .forName("java.lang.ThreadLocal$ThreadLocalMap"); + final Class tlmClass = Class.forName("java.lang.ThreadLocal$ThreadLocalMap"); tableField = tlmClass.getDeclaredField("table"); tableField.setAccessible(true); } catch (final Exception e) { @@ -163,8 +156,7 @@ public class Tomcat6ConfigServlet extends HttpServlet { while (thread.isAlive() && count < 5) { try { Thread.sleep(100); - } catch (final InterruptedException e) { - } + } catch (final InterruptedException e) {} count++; } } @@ -195,13 +187,10 @@ public class Tomcat6ConfigServlet extends HttpServlet { return threads; } - private void clearThreadLocalMap(final ClassLoader cl, final Object map, - final Field internalTableField) throws NoSuchMethodException, - IllegalAccessException, NoSuchFieldException, - InvocationTargetException { + private void clearThreadLocalMap(final ClassLoader cl, final Object map, final Field internalTableField) throws NoSuchMethodException, + IllegalAccessException, NoSuchFieldException, InvocationTargetException { if (map != null) { - final Method mapRemove = map.getClass().getDeclaredMethod("remove", - ThreadLocal.class); + final Method mapRemove = map.getClass().getDeclaredMethod("remove", ThreadLocal.class); mapRemove.setAccessible(true); final Object[] table = (Object[]) internalTableField.get(map); if (table != null) { @@ -209,28 +198,23 @@ public class Tomcat6ConfigServlet extends HttpServlet { if (element != null) { boolean remove = false; // Check the key - final Field keyField = Reference.class - .getDeclaredField("referent"); + final Field keyField = Reference.class.getDeclaredField("referent"); keyField.setAccessible(true); final Object key = keyField.get(element); - if (cl.equals(key) || key != null - && cl == key.getClass().getClassLoader()) { + if (cl.equals(key) || key != null && cl == key.getClass().getClassLoader()) { remove = true; } // Check the value - final Field valueField = element.getClass() - .getDeclaredField("value"); + final Field valueField = element.getClass().getDeclaredField("value"); valueField.setAccessible(true); final Object value = valueField.get(element); - if (cl.equals(value) || value != null - && cl == value.getClass().getClassLoader()) { + if (cl.equals(value) || value != null && cl == value.getClass().getClassLoader()) { remove = true; } if (remove) { final Object entry = ((Reference) element).get(); if (logger.isInfoEnabled()) { - logger.info("Removing " + key.toString() - + " from a thread local..."); + logger.info("Removing " + key.toString() + " from a thread local..."); } mapRemove.invoke(map, entry); } diff --git a/src/main/java/org/codelibs/fess/servlet/Tomcat7ConfigServlet.java b/src/main/java/org/codelibs/fess/servlet/Tomcat7ConfigServlet.java index 01c7c6023..1cf4472ca 100644 --- a/src/main/java/org/codelibs/fess/servlet/Tomcat7ConfigServlet.java +++ b/src/main/java/org/codelibs/fess/servlet/Tomcat7ConfigServlet.java @@ -24,8 +24,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class Tomcat7ConfigServlet extends HttpServlet { - private static final Logger logger = LoggerFactory - .getLogger(Tomcat7ConfigServlet.class); + private static final Logger logger = LoggerFactory.getLogger(Tomcat7ConfigServlet.class); private static final long serialVersionUID = 1L; @@ -39,8 +38,7 @@ public class Tomcat7ConfigServlet extends HttpServlet { private void shutdownCommonsHttpClient() { try { - final Class clazz = Class - .forName("org.apache.commons.httpclient.MultiThreadedHttpConnectionManager"); + final Class clazz = Class.forName("org.apache.commons.httpclient.MultiThreadedHttpConnectionManager"); final Method method = clazz.getMethod("shutdownAll", null); method.invoke(null, null); } catch (final ClassNotFoundException e) { diff --git a/src/main/java/org/codelibs/fess/solr/BoostDocumentRule.java b/src/main/java/org/codelibs/fess/solr/BoostDocumentRule.java index c4b981978..52cf843c8 100644 --- a/src/main/java/org/codelibs/fess/solr/BoostDocumentRule.java +++ b/src/main/java/org/codelibs/fess/solr/BoostDocumentRule.java @@ -23,8 +23,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class BoostDocumentRule { - private static final Logger logger = LoggerFactory - .getLogger(BoostDocumentRule.class); + private static final Logger logger = LoggerFactory.getLogger(BoostDocumentRule.class); private String boostExpression = "0"; @@ -34,8 +33,7 @@ public class BoostDocumentRule { // nothing } - public BoostDocumentRule( - final org.codelibs.fess.db.exentity.BoostDocumentRule rule) { + public BoostDocumentRule(final org.codelibs.fess.db.exentity.BoostDocumentRule rule) { matchExpression = rule.getUrlExpr(); boostExpression = rule.getBoostExpr(); } diff --git a/src/main/java/org/codelibs/fess/solr/IndexUpdater.java b/src/main/java/org/codelibs/fess/solr/IndexUpdater.java index 123d54475..f45d3d45a 100644 --- a/src/main/java/org/codelibs/fess/solr/IndexUpdater.java +++ b/src/main/java/org/codelibs/fess/solr/IndexUpdater.java @@ -56,8 +56,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class IndexUpdater extends Thread { - private static final Logger logger = LoggerFactory - .getLogger(IndexUpdater.class); + private static final Logger logger = LoggerFactory.getLogger(IndexUpdater.class); protected List sessionIdList; @@ -172,8 +171,7 @@ public class IndexUpdater extends Thread { executeTime = 0; documentSize = 0; - final IntervalControlHelper intervalControlHelper = ComponentUtil - .getIntervalControlHelper(); + final IntervalControlHelper intervalControlHelper = ComponentUtil.getIntervalControlHelper(); try { final AccessResultCB cb = new AccessResultCB(); cb.setupSelect_AccessResultDataAsOne(); @@ -188,7 +186,8 @@ public class IndexUpdater extends Thread { final List docList = new ArrayList(); final List accessResultList = new ArrayList(); - final List accessResultDataList = new ArrayList(); + final List accessResultDataList = + new ArrayList(); long updateTime = System.currentTimeMillis(); int solrErrorCount = 0; @@ -230,11 +229,9 @@ public class IndexUpdater extends Thread { emptyListCount = 0; // reset } while (!arList.isEmpty()) { - processAccessResults(docList, accessResultList, - accessResultDataList, arList); + processAccessResults(docList, accessResultList, accessResultDataList, arList); - cleanupAccessResults(accessResultList, - accessResultDataList); + cleanupAccessResults(accessResultList, accessResultDataList); if (logger.isDebugEnabled()) { logger.debug("Getting documents in IndexUpdater queue."); @@ -247,9 +244,7 @@ public class IndexUpdater extends Thread { } synchronized (finishedSessionIdList) { - if (sessionIdListSize != 0 - && sessionIdListSize == finishedSessionIdList - .size()) { + if (sessionIdListSize != 0 && sessionIdListSize == finishedSessionIdList.size()) { cleanupFinishedSessionData(); } } @@ -267,16 +262,13 @@ public class IndexUpdater extends Thread { throw e; } solrErrorCount++; - logger.warn( - "Failed to access a solr group. Retry to access.. " - + solrErrorCount, e); + logger.warn("Failed to access a solr group. Retry to access.. " + solrErrorCount, e); } catch (final Exception e) { if (errorCount > maxErrorCount) { throw e; } errorCount++; - logger.warn("Failed to access data. Retry to access.. " - + errorCount, e); + logger.warn("Failed to access data. Retry to access.. " + errorCount, e); } finally { if (systemHelper.isForceStop()) { finishCrawling = true; @@ -288,9 +280,7 @@ public class IndexUpdater extends Thread { if (emptyListCount >= maxEmptyListCount) { if (logger.isInfoEnabled()) { - logger.info("Terminating indexUpdater. " - + "emptyListCount is over " + maxEmptyListCount - + "."); + logger.info("Terminating indexUpdater. " + "emptyListCount is over " + maxEmptyListCount + "."); } // terminate crawling finishCrawling = true; @@ -319,8 +309,7 @@ public class IndexUpdater extends Thread { } private void printThreadDump() { - for (final Map.Entry entry : Thread - .getAllStackTraces().entrySet()) { + for (final Map.Entry entry : Thread.getAllStackTraces().entrySet()) { logger.info("Thread: " + entry.getKey()); final StackTraceElement[] trace = entry.getValue(); for (final StackTraceElement element : trace) { @@ -329,11 +318,9 @@ public class IndexUpdater extends Thread { } } - private void processAccessResults( - final List docList, + private void processAccessResults(final List docList, final List accessResultList, - final List accessResultDataList, - final PagingResultBean arList) { + final List accessResultDataList, final PagingResultBean arList) { for (final AccessResult accessResult : arList) { if (logger.isDebugEnabled()) { logger.debug("Indexing " + accessResult.getUrl()); @@ -344,41 +331,33 @@ public class IndexUpdater extends Thread { if (accessResult.getHttpStatusCode() != 200) { // invalid page if (logger.isDebugEnabled()) { - logger.debug("Skipped. The response code is " - + accessResult.getHttpStatusCode() + "."); + logger.debug("Skipped. The response code is " + accessResult.getHttpStatusCode() + "."); } continue; } - final AccessResultData accessResultData = accessResult - .getAccessResultData(); + final AccessResultData accessResultData = accessResult.getAccessResultData(); if (accessResultData != null) { accessResult.setAccessResultData(null); - accessResultDataList - .add((org.codelibs.robot.db.exentity.AccessResultData) accessResultData); + accessResultDataList.add((org.codelibs.robot.db.exentity.AccessResultData) accessResultData); try { - final Transformer transformer = SingletonS2Container - .getComponent(accessResultData.getTransformerName()); + final Transformer transformer = SingletonS2Container.getComponent(accessResultData.getTransformerName()); if (transformer == null) { // no transformer - logger.warn("No transformer: " - + accessResultData.getTransformerName()); + logger.warn("No transformer: " + accessResultData.getTransformerName()); continue; } @SuppressWarnings("unchecked") - final Map map = (Map) transformer - .getData(accessResultData); + final Map map = (Map) transformer.getData(accessResultData); if (map.isEmpty()) { // no transformer logger.warn("No data: " + accessResult.getUrl()); continue; } - if (Constants.FALSE.equals(map - .get(Constants.INDEXING_TARGET))) { + if (Constants.FALSE.equals(map.get(Constants.INDEXING_TARGET))) { if (logger.isDebugEnabled()) { - logger.debug("Skipped. " - + "This document is not a index target. "); + logger.debug("Skipped. " + "This document is not a index target. "); } continue; } else { @@ -389,9 +368,7 @@ public class IndexUpdater extends Thread { docList.add(doc); if (logger.isDebugEnabled()) { - logger.debug("Added the document. " - + "The number of a document cache is " - + docList.size() + "."); + logger.debug("Added the document. " + "The number of a document cache is " + docList.size() + "."); } if (docList.size() >= maxDocumentCacheSize) { @@ -399,22 +376,19 @@ public class IndexUpdater extends Thread { } documentSize++; // commit - if (commitPerCount > 0 - && documentSize % commitPerCount == 0) { + if (commitPerCount > 0 && documentSize % commitPerCount == 0) { if (!docList.isEmpty()) { indexingHelper.sendDocuments(solrGroup, docList); } commitDocuments(); } if (logger.isDebugEnabled()) { - logger.debug("The number of an added document is " - + documentSize + "."); + logger.debug("The number of an added document is " + documentSize + "."); } } catch (final SolrLibException e) { throw e; } catch (final Exception e) { - logger.warn( - "Could not add a doc: " + accessResult.getUrl(), e); + logger.warn("Could not add a doc: " + accessResult.getUrl(), e); } } else { if (logger.isDebugEnabled()) { @@ -467,15 +441,13 @@ public class IndexUpdater extends Thread { } if (!map.containsKey(fieldHelper.docIdField)) { - doc.addField(fieldHelper.docIdField, - systemHelper.generateDocId(map)); + doc.addField(fieldHelper.docIdField, systemHelper.generateDocId(map)); } return doc; } - protected void addBoostValue(final Map map, - final float documentBoost, final SolrInputDocument doc) { + protected void addBoostValue(final Map map, final float documentBoost, final SolrInputDocument doc) { doc.addField(fieldHelper.boostField, documentBoost); doc.setDocumentBoost(documentBoost); if (logger.isDebugEnabled()) { @@ -483,8 +455,7 @@ public class IndexUpdater extends Thread { } } - protected void addClickCountField(final Map map, - final SolrInputDocument doc) { + protected void addClickCountField(final Map map, final SolrInputDocument doc) { final String url = (String) map.get(fieldHelper.urlField); if (StringUtil.isNotBlank(url)) { final int count = clickLogBhv.selectCount(cb -> { @@ -498,14 +469,12 @@ public class IndexUpdater extends Thread { } } - protected void addFavoriteCountField(final Map map, - final SolrInputDocument doc) { + protected void addFavoriteCountField(final Map map, final SolrInputDocument doc) { final String url = (String) map.get(fieldHelper.urlField); if (StringUtil.isNotBlank(url)) { final FavoriteUrlCountPmb pmb = new FavoriteUrlCountPmb(); pmb.setUrl(url); - final List list = favoriteLogBhv.outsideSql() - .selectList(pmb); + final List list = favoriteLogBhv.outsideSql().selectList(pmb); long count = 0; if (!list.isEmpty()) { @@ -520,8 +489,7 @@ public class IndexUpdater extends Thread { } } - private void cleanupAccessResults( - final List accessResultList, + private void cleanupAccessResults(final List accessResultList, final List accessResultDataList) { if (!accessResultList.isEmpty()) { final long execTime = System.currentTimeMillis(); @@ -529,9 +497,8 @@ public class IndexUpdater extends Thread { dataService.update(accessResultList); accessResultList.clear(); if (logger.isDebugEnabled()) { - logger.debug("Updated " + size - + " access results. The execution time is " - + (System.currentTimeMillis() - execTime) + "ms."); + logger.debug("Updated " + size + " access results. The execution time is " + (System.currentTimeMillis() - execTime) + + "ms."); } } @@ -542,39 +509,32 @@ public class IndexUpdater extends Thread { accessResultDataBhv.batchDelete(accessResultDataList); accessResultDataList.clear(); if (logger.isDebugEnabled()) { - logger.debug("Deleted " + size - + " access result data. The execution time is " - + (System.currentTimeMillis() - execTime) + "ms."); + logger.debug("Deleted " + size + " access result data. The execution time is " + (System.currentTimeMillis() - execTime) + + "ms."); } } } - private PagingResultBean getAccessResultList( - final AccessResultCB cb) { + private PagingResultBean getAccessResultList(final AccessResultCB cb) { final long execTime = System.currentTimeMillis(); - final PagingResultBean arList = accessResultBhv - .selectPage(cb); + final PagingResultBean arList = accessResultBhv.selectPage(cb); if (!arList.isEmpty()) { - for (final AccessResult ar : arList.toArray(new AccessResult[arList - .size()])) { + for (final AccessResult ar : arList.toArray(new AccessResult[arList.size()])) { if (ar.getCreateTime().getTime() > execTime - commitMarginTime) { arList.remove(ar); } } } if (logger.isInfoEnabled()) { - logger.info("Processing " + arList.size() + "/" - + arList.getAllRecordCount() + " docs (DB: " + logger.info("Processing " + arList.size() + "/" + arList.getAllRecordCount() + " docs (DB: " + (System.currentTimeMillis() - execTime) + "ms)"); } if (arList.getAllRecordCount() > unprocessedDocumentSize) { if (logger.isInfoEnabled()) { - logger.info("Stopped all crawler threads. " + " You have " - + arList.getAllRecordCount() + " (>" - + unprocessedDocumentSize + ") " + " unprocessed docs."); + logger.info("Stopped all crawler threads. " + " You have " + arList.getAllRecordCount() + " (>" + unprocessedDocumentSize + + ") " + " unprocessed docs."); } - final IntervalControlHelper intervalControlHelper = ComponentUtil - .getIntervalControlHelper(); + final IntervalControlHelper intervalControlHelper = ComponentUtil.getIntervalControlHelper(); intervalControlHelper.setCrawlerRunning(false); } return arList; @@ -590,17 +550,14 @@ public class IndexUpdater extends Thread { } deleteBySessionId(sessionId); if (logger.isDebugEnabled()) { - logger.debug("Deleted " + sessionId - + " documents. The execution time is " - + (System.currentTimeMillis() - execTime2) + "ms."); + logger.debug("Deleted " + sessionId + " documents. The execution time is " + (System.currentTimeMillis() - execTime2) + + "ms."); } } finishedSessionIdList.clear(); if (logger.isInfoEnabled()) { - logger.info("Deleted completed document data. " - + "The execution time is " - + (System.currentTimeMillis() - execTime) + "ms."); + logger.info("Deleted completed document data. " + "The execution time is " + (System.currentTimeMillis() - execTime) + "ms."); } } @@ -613,8 +570,7 @@ public class IndexUpdater extends Thread { solrGroup.commit(true, true, false, true); } if (logger.isInfoEnabled()) { - logger.info("Committed documents. The execution time is " - + (System.currentTimeMillis() - execTime) + "ms."); + logger.info("Committed documents. The execution time is " + (System.currentTimeMillis() - execTime) + "ms."); } } @@ -664,8 +620,7 @@ public class IndexUpdater extends Thread { } @Binding(bindingType = BindingType.MAY) - public static void setDefaultUncaughtExceptionHandler( - final UncaughtExceptionHandler eh) { + public static void setDefaultUncaughtExceptionHandler(final UncaughtExceptionHandler eh) { Thread.setDefaultUncaughtExceptionHandler(eh); } diff --git a/src/main/java/org/codelibs/fess/solr/policy/FessStatusPolicy.java b/src/main/java/org/codelibs/fess/solr/policy/FessStatusPolicy.java index 141dd7f19..a060b0de2 100644 --- a/src/main/java/org/codelibs/fess/solr/policy/FessStatusPolicy.java +++ b/src/main/java/org/codelibs/fess/solr/policy/FessStatusPolicy.java @@ -41,8 +41,7 @@ import com.github.jknack.handlebars.io.FileTemplateLoader; public class FessStatusPolicy extends StatusPolicyImpl { private static final String MAIL_TEMPLATE_NAME = "solr_status"; - private static final Logger logger = LoggerFactory - .getLogger(FessStatusPolicy.class); + private static final Logger logger = LoggerFactory.getLogger(FessStatusPolicy.class); public String activateSubject = "[FESS] Solr status changed"; @@ -50,10 +49,8 @@ public class FessStatusPolicy extends StatusPolicyImpl { @Override public void activate(final QueryType queryType, final String serverName) { - final String statusValue = solrGroupProperties - .getProperty(getStatusKey(serverName)); - final String indexValue = solrGroupProperties - .getProperty(getIndexKey(serverName)); + final String statusValue = solrGroupProperties.getProperty(getStatusKey(serverName)); + final String indexValue = solrGroupProperties.getProperty(getIndexKey(serverName)); final Map dataMap = new HashMap(); @@ -64,30 +61,28 @@ public class FessStatusPolicy extends StatusPolicyImpl { } switch (queryType) { - case COMMIT: - case OPTIMIZE: - case ROLLBACK: - if (StringUtil.isNotBlank(indexValue) - && UNFINISHED.equals(indexValue)) { - // index: UNFINISHED -> COMPLETED - dataMap.put("indexBefore", UNFINISHED.toUpperCase()); - dataMap.put("indexAfter", COMPLETED.toUpperCase()); - } - break; - case ADD: - case DELETE: - if (StringUtil.isNotBlank(indexValue) - && UNFINISHED.equals(indexValue)) { - // index: UNFINISHED -> READY - dataMap.put("indexBefore", UNFINISHED.toUpperCase()); - dataMap.put("indexAfter", READY.toUpperCase()); - } - break; - case PING: - case QUERY: - case REQUEST: - default: - break; + case COMMIT: + case OPTIMIZE: + case ROLLBACK: + if (StringUtil.isNotBlank(indexValue) && UNFINISHED.equals(indexValue)) { + // index: UNFINISHED -> COMPLETED + dataMap.put("indexBefore", UNFINISHED.toUpperCase()); + dataMap.put("indexAfter", COMPLETED.toUpperCase()); + } + break; + case ADD: + case DELETE: + if (StringUtil.isNotBlank(indexValue) && UNFINISHED.equals(indexValue)) { + // index: UNFINISHED -> READY + dataMap.put("indexBefore", UNFINISHED.toUpperCase()); + dataMap.put("indexAfter", READY.toUpperCase()); + } + break; + case PING: + case QUERY: + case REQUEST: + default: + break; } if (!dataMap.isEmpty()) { @@ -104,10 +99,8 @@ public class FessStatusPolicy extends StatusPolicyImpl { @Override public void deactivate(final QueryType queryType, final String serverName) { - final String statusValue = solrGroupProperties - .getProperty(getStatusKey(serverName)); - final String indexValue = solrGroupProperties - .getProperty(getIndexKey(serverName)); + final String statusValue = solrGroupProperties.getProperty(getStatusKey(serverName)); + final String indexValue = solrGroupProperties.getProperty(getIndexKey(serverName)); final Map dataMap = new HashMap(); @@ -118,24 +111,22 @@ public class FessStatusPolicy extends StatusPolicyImpl { } switch (queryType) { - case COMMIT: - case OPTIMIZE: - case ROLLBACK: - case ADD: - case DELETE: - if (StringUtil.isNotBlank(indexValue) - && !UNFINISHED.equals(indexValue)) { - // index: READY/COMPLETED -> UNFINISHED - dataMap.put("indexBefore", indexValue == null ? "UNKNOWN" - : indexValue.toUpperCase()); - dataMap.put("indexAfter", UNFINISHED.toUpperCase()); - } - break; - case PING: - case QUERY: - case REQUEST: - default: - break; + case COMMIT: + case OPTIMIZE: + case ROLLBACK: + case ADD: + case DELETE: + if (StringUtil.isNotBlank(indexValue) && !UNFINISHED.equals(indexValue)) { + // index: READY/COMPLETED -> UNFINISHED + dataMap.put("indexBefore", indexValue == null ? "UNKNOWN" : indexValue.toUpperCase()); + dataMap.put("indexAfter", UNFINISHED.toUpperCase()); + } + break; + case PING: + case QUERY: + case REQUEST: + default: + break; } if (!dataMap.isEmpty()) { @@ -151,8 +142,7 @@ public class FessStatusPolicy extends StatusPolicyImpl { } protected void send(final String subject, final Map dataMap) { - final DynamicProperties crawlerProperties = ComponentUtil - .getCrawlerProperties(); + final DynamicProperties crawlerProperties = ComponentUtil.getCrawlerProperties(); if (crawlerProperties == null) { logger.info("crawlerProperties is not found."); return; @@ -164,25 +154,21 @@ public class FessStatusPolicy extends StatusPolicyImpl { return; } - final String toStrs = (String) crawlerProperties - .get(Constants.NOTIFICATION_TO_PROPERTY); + final String toStrs = (String) crawlerProperties.get(Constants.NOTIFICATION_TO_PROPERTY); if (StringUtil.isNotBlank(toStrs)) { final String[] toAddresses = toStrs.split(","); try { - dataMap.put("hostname", InetAddress.getLocalHost() - .getHostAddress()); + dataMap.put("hostname", InetAddress.getLocalHost().getHostAddress()); } catch (final UnknownHostException e) { // ignore } - final FileTemplateLoader loader = new FileTemplateLoader(new File( - ResourceUtil.getMailTemplatePath(StringUtil.EMPTY))); + final FileTemplateLoader loader = new FileTemplateLoader(new File(ResourceUtil.getMailTemplatePath(StringUtil.EMPTY))); final Handlebars handlebars = new Handlebars(loader); try { - final Template template = handlebars - .compile(MAIL_TEMPLATE_NAME); + final Template template = handlebars.compile(MAIL_TEMPLATE_NAME); final Context hbsContext = Context.newContext(dataMap); final String body = template.apply(hbsContext); diff --git a/src/main/java/org/codelibs/fess/struts/action/FessRequestProcessor.java b/src/main/java/org/codelibs/fess/struts/action/FessRequestProcessor.java index c2f61a578..0bf143eaa 100644 --- a/src/main/java/org/codelibs/fess/struts/action/FessRequestProcessor.java +++ b/src/main/java/org/codelibs/fess/struts/action/FessRequestProcessor.java @@ -24,8 +24,7 @@ import org.dbflute.saflute.web.action.processor.ActionRequestProcessor; public class FessRequestProcessor extends ActionRequestProcessor { @Override @SuppressWarnings("unchecked") - protected void setMapProperty(final Map map, final String name, - final Object value) { + protected void setMapProperty(final Map map, final String name, final Object value) { if (value instanceof String[]) { if (map.get(SearchParamMap.CLASS_NAME) != null) { map.put(name, value); diff --git a/src/main/java/org/codelibs/fess/taglib/FessFunctions.java b/src/main/java/org/codelibs/fess/taglib/FessFunctions.java index 6c199aa86..d41d6b8c1 100644 --- a/src/main/java/org/codelibs/fess/taglib/FessFunctions.java +++ b/src/main/java/org/codelibs/fess/taglib/FessFunctions.java @@ -53,8 +53,7 @@ public class FessFunctions { public static Boolean labelExists(final String value) { @SuppressWarnings("unchecked") - final Map labelValueMap = (Map) RequestUtil - .getRequest().getAttribute(Constants.LABEL_VALUE_MAP); + final Map labelValueMap = (Map) RequestUtil.getRequest().getAttribute(Constants.LABEL_VALUE_MAP); if (labelValueMap != null) { return labelValueMap.get(value) != null; } @@ -63,8 +62,7 @@ public class FessFunctions { public static String label(final String value) { @SuppressWarnings("unchecked") - final Map labelValueMap = (Map) RequestUtil - .getRequest().getAttribute(Constants.LABEL_VALUE_MAP); + final Map labelValueMap = (Map) RequestUtil.getRequest().getAttribute(Constants.LABEL_VALUE_MAP); if (labelValueMap != null) { final String name = labelValueMap.get(value); if (name != null) { @@ -94,10 +92,8 @@ public class FessFunctions { range = Range.ENTIRE; } - final HotSearchWordHelper hotSearchWordHelper = ComponentUtil - .getHotSearchWordHelper(); - final List wordList = hotSearchWordHelper - .getHotSearchWordList(range); + final HotSearchWordHelper hotSearchWordHelper = ComponentUtil.getHotSearchWordHelper(); + final List wordList = hotSearchWordHelper.getHotSearchWordList(range); if (wordList.size() > size) { return wordList.subList(0, size); } @@ -124,18 +120,14 @@ public class FessFunctions { range = Range.ENTIRE; } - final HotSearchWordHelper hotSearchWordHelper = ComponentUtil - .getHotSearchWordHelper(); + final HotSearchWordHelper hotSearchWordHelper = ComponentUtil.getHotSearchWordHelper(); return hotSearchWordHelper.getHotSearchWordList(range).size(); } private static boolean isSupportHotSearchWord() { - final DynamicProperties crawlerProperties = ComponentUtil - .getCrawlerProperties(); + final DynamicProperties crawlerProperties = ComponentUtil.getCrawlerProperties(); return crawlerProperties != null - && Constants.TRUE.equals(crawlerProperties.getProperty( - Constants.WEB_API_HOT_SEARCH_WORD_PROPERTY, - Constants.TRUE)); + && Constants.TRUE.equals(crawlerProperties.getProperty(Constants.WEB_API_HOT_SEARCH_WORD_PROPERTY, Constants.TRUE)); } public static Date date(final Long value) { @@ -161,8 +153,7 @@ public class FessFunctions { } public static String formatDate(final LocalDateTime date) { - return date.format(DateTimeFormatter.ofPattern( - "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.ROOT)); + return date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.ROOT)); } public static String facetQuery() { diff --git a/src/main/java/org/codelibs/fess/transformer/AbstractFessFileTransformer.java b/src/main/java/org/codelibs/fess/transformer/AbstractFessFileTransformer.java index 76429ed27..c5681ab4e 100644 --- a/src/main/java/org/codelibs/fess/transformer/AbstractFessFileTransformer.java +++ b/src/main/java/org/codelibs/fess/transformer/AbstractFessFileTransformer.java @@ -67,8 +67,7 @@ import org.seasar.framework.util.SerializeUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public abstract class AbstractFessFileTransformer extends - AbstractFessXpathTransformer { +public abstract class AbstractFessFileTransformer extends AbstractFessXpathTransformer { private static final Logger logger = LoggerFactory // NOPMD .getLogger(AbstractFessFileTransformer.class); @@ -90,8 +89,7 @@ public abstract class AbstractFessFileTransformer extends public boolean enableCache = false; - public Map parentEncodingMap = Collections - .synchronizedMap(new LruHashMap(1000)); + public Map parentEncodingMap = Collections.synchronizedMap(new LruHashMap(1000)); protected Map metaContentMapping; @@ -106,8 +104,7 @@ public abstract class AbstractFessFileTransformer extends final Extractor extractor = getExtractor(responseData); final InputStream in = responseData.getResponseBody(); final Map params = new HashMap(); - params.put(TikaMetadataKeys.RESOURCE_NAME_KEY, - getResourceName(responseData)); + params.put(TikaMetadataKeys.RESOURCE_NAME_KEY, getResourceName(responseData)); final String mimeType = responseData.getMimeType(); params.put(HttpHeaders.CONTENT_TYPE, mimeType); params.put(HttpHeaders.CONTENT_ENCODING, responseData.getCharSet()); @@ -136,8 +133,7 @@ public abstract class AbstractFessFileTransformer extends if (StringUtil.isNotBlank(joinValue)) { contentMetaBuf.append(joinValue); if (metaContentMapping != null) { - final String solrField = metaContentMapping - .get(key); + final String solrField = metaContentMapping.get(key); if (StringUtil.isNotBlank(solrField)) { if (solrField.endsWith("_m")) { dataMap.put(solrField, values); @@ -150,8 +146,7 @@ public abstract class AbstractFessFileTransformer extends } } } catch (final Exception e) { - final RobotCrawlAccessException rcae = new RobotCrawlAccessException( - "Could not get a text from " + responseData.getUrl(), e); + final RobotCrawlAccessException rcae = new RobotCrawlAccessException("Could not get a text from " + responseData.getUrl(), e); rcae.setLogLevel(RobotCrawlAccessException.WARN); throw rcae; } finally { @@ -165,32 +160,22 @@ public abstract class AbstractFessFileTransformer extends final ResultData resultData = new ResultData(); resultData.setTransformerName(getName()); - final CrawlingSessionHelper crawlingSessionHelper = ComponentUtil - .getCrawlingSessionHelper(); - final String sessionId = crawlingSessionHelper - .getCanonicalSessionId(responseData.getSessionId()); - final LocalDateTime documentExpires = crawlingSessionHelper - .getDocumentExpires(); - final PathMappingHelper pathMappingHelper = ComponentUtil - .getPathMappingHelper(); + final CrawlingSessionHelper crawlingSessionHelper = ComponentUtil.getCrawlingSessionHelper(); + final String sessionId = crawlingSessionHelper.getCanonicalSessionId(responseData.getSessionId()); + final LocalDateTime documentExpires = crawlingSessionHelper.getDocumentExpires(); + final PathMappingHelper pathMappingHelper = ComponentUtil.getPathMappingHelper(); final SambaHelper sambaHelper = ComponentUtil.getSambaHelper(); - final DynamicProperties crawlerProperties = ComponentUtil - .getCrawlerProperties(); - final boolean useAclAsRole = crawlerProperties.getProperty( - Constants.USE_ACL_AS_ROLE, Constants.FALSE).equals( - Constants.TRUE); - final CrawlingConfigHelper crawlingConfigHelper = ComponentUtil - .getCrawlingConfigHelper(); - final CrawlingConfig crawlingConfig = crawlingConfigHelper - .get(responseData.getSessionId()); + final DynamicProperties crawlerProperties = ComponentUtil.getCrawlerProperties(); + final boolean useAclAsRole = crawlerProperties.getProperty(Constants.USE_ACL_AS_ROLE, Constants.FALSE).equals(Constants.TRUE); + final CrawlingConfigHelper crawlingConfigHelper = ComponentUtil.getCrawlingConfigHelper(); + final CrawlingConfig crawlingConfig = crawlingConfigHelper.get(responseData.getSessionId()); final FieldHelper fieldHelper = ComponentUtil.getFieldHelper(); final FileTypeHelper fileTypeHelper = ComponentUtil.getFileTypeHelper(); String url = responseData.getUrl(); final String indexingTarget = crawlingConfig.getIndexingTarget(url); url = pathMappingHelper.replaceUrl(sessionId, url); - final Map fieldConfigMap = crawlingConfig - .getConfigParameterMap(ConfigName.FIELD); + final Map fieldConfigMap = crawlingConfig.getConfigParameterMap(ConfigName.FIELD); String urlEncoding; final UrlQueue urlQueue = CrawlingParameterUtil.getUrlQueue(); @@ -207,8 +192,7 @@ public abstract class AbstractFessFileTransformer extends } // expires if (documentExpires != null) { - putResultDataBody(dataMap, fieldHelper.expiresField, - FessFunctions.formatDate(documentExpires)); + putResultDataBody(dataMap, fieldHelper.expiresField, FessFunctions.formatDate(documentExpires)); } // segment putResultDataBody(dataMap, fieldHelper.segmentField, sessionId); @@ -227,33 +211,24 @@ public abstract class AbstractFessFileTransformer extends if (StringUtil.isNotBlank(body)) { putResultDataBody(dataMap, fieldHelper.contentField, body); } else { - putResultDataBody(dataMap, fieldHelper.contentField, - StringUtil.EMPTY); + putResultDataBody(dataMap, fieldHelper.contentField, StringUtil.EMPTY); } - if (Constants.TRUE.equalsIgnoreCase(fieldConfigMap - .get(fieldHelper.cacheField)) || enableCache) { - final String cache = content.trim().replaceAll("[ \\t\\x0B\\f]+", - " "); + if (Constants.TRUE.equalsIgnoreCase(fieldConfigMap.get(fieldHelper.cacheField)) || enableCache) { + final String cache = content.trim().replaceAll("[ \\t\\x0B\\f]+", " "); // text cache putResultDataBody(dataMap, fieldHelper.cacheField, cache); - putResultDataBody(dataMap, fieldHelper.hasCacheField, - Constants.TRUE); + putResultDataBody(dataMap, fieldHelper.hasCacheField, Constants.TRUE); } // digest - putResultDataBody( - dataMap, - fieldHelper.digestField, - Constants.DIGEST_PREFIX - + abbreviate(normalizeContent(content), maxDigestLength)); + putResultDataBody(dataMap, fieldHelper.digestField, Constants.DIGEST_PREFIX + + abbreviate(normalizeContent(content), maxDigestLength)); // title if (!dataMap.containsKey(fieldHelper.titleField)) { if (url.endsWith("/")) { if (StringUtil.isNotBlank(content)) { - putResultDataBody(dataMap, fieldHelper.titleField, - abbreviate(body, maxTitleLength)); + putResultDataBody(dataMap, fieldHelper.titleField, abbreviate(body, maxTitleLength)); } else { - putResultDataBody(dataMap, fieldHelper.titleField, - noTitleLabel); + putResultDataBody(dataMap, fieldHelper.titleField, noTitleLabel); } } else { final String u = decodeUrlAsName(url, url.startsWith("file:")); @@ -261,16 +236,14 @@ public abstract class AbstractFessFileTransformer extends if (pos == -1) { putResultDataBody(dataMap, fieldHelper.titleField, u); } else { - putResultDataBody(dataMap, fieldHelper.titleField, - u.substring(pos + 1)); + putResultDataBody(dataMap, fieldHelper.titleField, u.substring(pos + 1)); } } } // host putResultDataBody(dataMap, fieldHelper.hostField, getHost(url)); // site - putResultDataBody(dataMap, fieldHelper.siteField, - getSite(url, urlEncoding)); + putResultDataBody(dataMap, fieldHelper.siteField, getSite(url, urlEncoding)); // url putResultDataBody(dataMap, fieldHelper.urlField, url); // created @@ -281,29 +254,24 @@ public abstract class AbstractFessFileTransformer extends putResultDataBody(dataMap, fieldHelper.mimetypeField, mimeType); if (fileTypeHelper != null) { // filetype - putResultDataBody(dataMap, fieldHelper.filetypeField, - fileTypeHelper.get(mimeType)); + putResultDataBody(dataMap, fieldHelper.filetypeField, fileTypeHelper.get(mimeType)); } // contentLength - putResultDataBody(dataMap, fieldHelper.contentLengthField, - Long.toString(responseData.getContentLength())); + putResultDataBody(dataMap, fieldHelper.contentLengthField, Long.toString(responseData.getContentLength())); // lastModified if (responseData.getLastModified() != null) { - putResultDataBody(dataMap, fieldHelper.lastModifiedField, - FessFunctions.formatDate(responseData.getLastModified())); + putResultDataBody(dataMap, fieldHelper.lastModifiedField, FessFunctions.formatDate(responseData.getLastModified())); } // indexingTarget putResultDataBody(dataMap, Constants.INDEXING_TARGET, indexingTarget); // boost - putResultDataBody(dataMap, fieldHelper.boostField, - crawlingConfig.getDocumentBoost()); + putResultDataBody(dataMap, fieldHelper.boostField, crawlingConfig.getDocumentBoost()); // label: labelType final Set labelTypeSet = new HashSet(); for (final String labelType : crawlingConfig.getLabelTypeValues()) { labelTypeSet.add(labelType); } - final LabelTypeHelper labelTypeHelper = ComponentUtil - .getLabelTypeHelper(); + final LabelTypeHelper labelTypeHelper = ComponentUtil.getLabelTypeHelper(); labelTypeSet.addAll(labelTypeHelper.getMatchedLabelValueSet(url)); putResultDataBody(dataMap, fieldHelper.labelField, labelTypeSet); // role: roleType @@ -312,16 +280,14 @@ public abstract class AbstractFessFileTransformer extends roleTypeList.add(roleType); } if (useAclAsRole && responseData.getUrl().startsWith("smb://")) { - final ACE[] aces = (ACE[]) responseData.getMetaDataMap().get( - SmbClient.SMB_ACCESS_CONTROL_ENTRIES); + final ACE[] aces = (ACE[]) responseData.getMetaDataMap().get(SmbClient.SMB_ACCESS_CONTROL_ENTRIES); if (aces != null) { for (final ACE item : aces) { final SID sid = item.getSID(); roleTypeList.add(sambaHelper.getAccountId(sid)); } if (logger.isDebugEnabled()) { - logger.debug("smbUrl:" + responseData.getUrl() - + " roleType:" + roleTypeList.toString()); + logger.debug("smbUrl:" + responseData.getUrl() + " roleType:" + roleTypeList.toString()); } } } @@ -329,44 +295,36 @@ public abstract class AbstractFessFileTransformer extends // TODO date // TODO lang // id - putResultDataBody(dataMap, fieldHelper.idField, - crawlingSessionHelper.generateId(dataMap)); + putResultDataBody(dataMap, fieldHelper.idField, crawlingSessionHelper.generateId(dataMap)); // parentId String parentUrl = responseData.getParentUrl(); if (StringUtil.isNotBlank(parentUrl)) { parentUrl = pathMappingHelper.replaceUrl(sessionId, parentUrl); putResultDataBody(dataMap, fieldHelper.urlField, parentUrl); - putResultDataBody(dataMap, fieldHelper.parentIdField, - crawlingSessionHelper.generateId(dataMap)); + putResultDataBody(dataMap, fieldHelper.parentIdField, crawlingSessionHelper.generateId(dataMap)); putResultDataBody(dataMap, fieldHelper.urlField, url); // set again } // from config - final Map scriptConfigMap = crawlingConfig - .getConfigParameterMap(ConfigName.SCRIPT); - final Map metaConfigMap = crawlingConfig - .getConfigParameterMap(ConfigName.META); + final Map scriptConfigMap = crawlingConfig.getConfigParameterMap(ConfigName.SCRIPT); + final Map metaConfigMap = crawlingConfig.getConfigParameterMap(ConfigName.META); for (final Map.Entry entry : metaConfigMap.entrySet()) { final String key = entry.getKey(); final String[] values = entry.getValue().split(","); for (final String value : values) { - putResultDataWithTemplate(dataMap, key, metaDataMap.get(value), - scriptConfigMap.get(key)); + putResultDataWithTemplate(dataMap, key, metaDataMap.get(value), scriptConfigMap.get(key)); } } - final Map valueConfigMap = crawlingConfig - .getConfigParameterMap(ConfigName.VALUE); + final Map valueConfigMap = crawlingConfig.getConfigParameterMap(ConfigName.VALUE); for (final Map.Entry entry : valueConfigMap.entrySet()) { final String key = entry.getKey(); - putResultDataWithTemplate(dataMap, key, entry.getValue(), - scriptConfigMap.get(key)); + putResultDataWithTemplate(dataMap, key, entry.getValue(), scriptConfigMap.get(key)); } try { resultData.setData(SerializeUtil.fromObjectToBinary(dataMap)); } catch (final Exception e) { - throw new RobotCrawlAccessException("Could not serialize object: " - + url, e); + throw new RobotCrawlAccessException("Could not serialize object: " + url, e); } resultData.setEncoding(charsetName); @@ -376,8 +334,7 @@ public abstract class AbstractFessFileTransformer extends protected String abbreviate(final String str, final int maxWidth) { String newStr = StringUtils.abbreviate(str, maxWidth); try { - if (newStr.getBytes(Constants.UTF_8).length > maxWidth - + abbreviationMarginLength) { + if (newStr.getBytes(Constants.UTF_8).length > maxWidth + abbreviationMarginLength) { newStr = StringUtils.abbreviate(str, maxWidth / 2); } } catch (final UnsupportedEncodingException e) { @@ -418,8 +375,7 @@ public abstract class AbstractFessFileTransformer extends final String parentUrl = urlQueue.getParentUrl(); if (StringUtil.isNotEmpty(parentUrl)) { final String sessionId = urlQueue.getSessionId(); - final String pageEnc = getParentEncoding(parentUrl, - sessionId); + final String pageEnc = getParentEncoding(parentUrl, sessionId); if (pageEnc != null) { enc = pageEnc; } else if (urlQueue.getEncoding() != null) { @@ -439,8 +395,7 @@ public abstract class AbstractFessFileTransformer extends } } - protected String getParentEncoding(final String parentUrl, - final String sessionId) { + protected String getParentEncoding(final String parentUrl, final String sessionId) { final String key = sessionId + ":" + parentUrl; String enc = parentEncodingMap.get(key); if (enc != null) { @@ -451,8 +406,7 @@ public abstract class AbstractFessFileTransformer extends cb.query().queryAccessResult().setSessionId_Equal(sessionId); cb.query().queryAccessResult().setUrl_Equal(parentUrl); cb.specify().columnEncoding(); - final AccessResultData accessResultData = SingletonS2Container - .getComponent(AccessResultDataBhv.class).selectEntity(cb); + final AccessResultData accessResultData = SingletonS2Container.getComponent(AccessResultDataBhv.class).selectEntity(cb); if (accessResultData != null && accessResultData.getEncoding() != null) { enc = accessResultData.getEncoding(); parentEncodingMap.put(key, enc); @@ -492,14 +446,12 @@ public abstract class AbstractFessFileTransformer extends if (url.startsWith("file:////")) { final String value = decodeUrlAsName(url.substring(9), true); - return StringUtils.abbreviate("\\\\" + value.replace('/', '\\'), - maxSiteLength); + return StringUtils.abbreviate("\\\\" + value.replace('/', '\\'), maxSiteLength); } else if (url.startsWith("file:")) { final String value = decodeUrlAsName(url.substring(5), true); if (value.length() > 2 && value.charAt(2) == ':') { // Windows - return StringUtils.abbreviate( - value.substring(1).replace('/', '\\'), maxSiteLength); + return StringUtils.abbreviate(value.substring(1).replace('/', '\\'), maxSiteLength); } else { // Unix return StringUtils.abbreviate(value, maxSiteLength); @@ -516,15 +468,13 @@ public abstract class AbstractFessFileTransformer extends try { return SerializeUtil.fromBinaryToObject(data); } catch (final Exception e) { - throw new RobotSystemException( - "Could not create an instanced from bytes.", e); + throw new RobotSystemException("Could not create an instanced from bytes.", e); } } return new HashMap(); } - public void addMetaContentMapping(final String metaname, - final String solrField) { + public void addMetaContentMapping(final String metaname, final String solrField) { if (metaContentMapping == null) { metaContentMapping = new HashMap(); } diff --git a/src/main/java/org/codelibs/fess/transformer/AbstractFessXpathTransformer.java b/src/main/java/org/codelibs/fess/transformer/AbstractFessXpathTransformer.java index 72c9306b1..5b83bd857 100644 --- a/src/main/java/org/codelibs/fess/transformer/AbstractFessXpathTransformer.java +++ b/src/main/java/org/codelibs/fess/transformer/AbstractFessXpathTransformer.java @@ -31,8 +31,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public abstract class AbstractFessXpathTransformer extends XpathTransformer { - private static final Logger logger = LoggerFactory - .getLogger(AbstractFessXpathTransformer.class); + private static final Logger logger = LoggerFactory.getLogger(AbstractFessXpathTransformer.class); public int maxSiteLength = 50; @@ -89,8 +88,7 @@ public abstract class AbstractFessXpathTransformer extends XpathTransformer { String enc; if (siteEncoding != null) { if (replaceSiteEncodingWhenEnglish) { - if ("ISO-8859-1".equalsIgnoreCase(encoding) - || "US-ASCII".equalsIgnoreCase(encoding)) { + if ("ISO-8859-1".equalsIgnoreCase(encoding) || "US-ASCII".equalsIgnoreCase(encoding)) { enc = siteEncoding; } else { enc = encoding; @@ -104,8 +102,7 @@ public abstract class AbstractFessXpathTransformer extends XpathTransformer { try { url = URLDecoder.decode(url, enc); - } catch (final Exception e) { - } + } catch (final Exception e) {} } return StringUtils.abbreviate(url, maxSiteLength); @@ -118,8 +115,7 @@ public abstract class AbstractFessXpathTransformer extends XpathTransformer { return content.replaceAll("\\s+", " "); } - protected void putResultDataBody(final Map dataMap, - final String key, final Object value) { + protected void putResultDataBody(final Map dataMap, final String key, final Object value) { final FieldHelper fieldHelper = ComponentUtil.getFieldHelper(); if (fieldHelper.urlField.equals(key)) { dataMap.put(key, value); @@ -130,15 +126,13 @@ public abstract class AbstractFessXpathTransformer extends XpathTransformer { final Object[] oldValues = (Object[]) oldValue; if (value.getClass().isArray()) { final Object[] newValues = (Object[]) value; - final Object[] values = Arrays.copyOf(oldValues, - oldValues.length + newValues.length); + final Object[] values = Arrays.copyOf(oldValues, oldValues.length + newValues.length); for (int i = 0; i < newValues.length; i++) { values[values.length - 1 + i] = newValues[i]; } dataMap.put(key, values); } else { - final Object[] values = Arrays.copyOf(oldValues, - oldValues.length + 1); + final Object[] values = Arrays.copyOf(oldValues, oldValues.length + 1); values[values.length - 1] = value; dataMap.put(key, values); } @@ -153,12 +147,10 @@ public abstract class AbstractFessXpathTransformer extends XpathTransformer { } } - protected void putResultDataWithTemplate(final Map dataMap, - final String key, final Object value, final String template) { + protected void putResultDataWithTemplate(final Map dataMap, final String key, final Object value, final String template) { Object target = value; if (template != null) { - final Map paramMap = new HashMap<>( - dataMap.size() + 1); + final Map paramMap = new HashMap<>(dataMap.size() + 1); paramMap.putAll(dataMap); paramMap.put("value", target); target = evaluateValue(template, paramMap); @@ -168,8 +160,7 @@ public abstract class AbstractFessXpathTransformer extends XpathTransformer { if (key.endsWith("_m")) { putResultDataBody(dataMap, key, target); } else { - putResultDataBody(dataMap, key, - Arrays.toString((Object[]) target)); + putResultDataBody(dataMap, key, Arrays.toString((Object[]) target)); } } else { if (key.endsWith("_m")) { @@ -181,8 +172,7 @@ public abstract class AbstractFessXpathTransformer extends XpathTransformer { } } - protected String evaluateValue(final String template, - final Map paramMap) { + protected String evaluateValue(final String template, final Map paramMap) { if (StringUtil.isEmpty(template)) { return StringUtil.EMPTY; } diff --git a/src/main/java/org/codelibs/fess/transformer/FessFileTransformer.java b/src/main/java/org/codelibs/fess/transformer/FessFileTransformer.java index 40e65892f..cb4032f15 100644 --- a/src/main/java/org/codelibs/fess/transformer/FessFileTransformer.java +++ b/src/main/java/org/codelibs/fess/transformer/FessFileTransformer.java @@ -25,21 +25,17 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class FessFileTransformer extends AbstractFessFileTransformer { - private static final Logger logger = LoggerFactory - .getLogger(FessFileTransformer.class); + private static final Logger logger = LoggerFactory.getLogger(FessFileTransformer.class); @Override protected Extractor getExtractor(final ResponseData responseData) { - final ExtractorFactory extractorFactory = ComponentUtil - .getExtractorFactory(); + final ExtractorFactory extractorFactory = ComponentUtil.getExtractorFactory(); if (extractorFactory == null) { throw new FessSystemException("Could not find extractorFactory."); } - final Extractor extractor = extractorFactory.getExtractor(responseData - .getMimeType()); + final Extractor extractor = extractorFactory.getExtractor(responseData.getMimeType()); if (logger.isDebugEnabled()) { - logger.debug("url=" + responseData.getUrl() + ", extractor=" - + extractor); + logger.debug("url=" + responseData.getUrl() + ", extractor=" + extractor); } return extractor; } diff --git a/src/main/java/org/codelibs/fess/transformer/FessTikaTransformer.java b/src/main/java/org/codelibs/fess/transformer/FessTikaTransformer.java index d19e8d652..a90c51a18 100644 --- a/src/main/java/org/codelibs/fess/transformer/FessTikaTransformer.java +++ b/src/main/java/org/codelibs/fess/transformer/FessTikaTransformer.java @@ -24,8 +24,7 @@ import org.seasar.framework.container.SingletonS2Container; public class FessTikaTransformer extends AbstractFessFileTransformer { @Override protected Extractor getExtractor(final ResponseData responseData) { - final Extractor extractor = SingletonS2Container - .getComponent("tikaExtractor"); + final Extractor extractor = SingletonS2Container.getComponent("tikaExtractor"); if (extractor == null) { throw new FessSystemException("Could not find tikaExtractor."); } diff --git a/src/main/java/org/codelibs/fess/transformer/FessXpathTransformer.java b/src/main/java/org/codelibs/fess/transformer/FessXpathTransformer.java index a8b02cfa8..1e4633341 100644 --- a/src/main/java/org/codelibs/fess/transformer/FessXpathTransformer.java +++ b/src/main/java/org/codelibs/fess/transformer/FessXpathTransformer.java @@ -71,8 +71,7 @@ import org.w3c.dom.NodeList; import org.xml.sax.InputSource; public class FessXpathTransformer extends AbstractFessXpathTransformer { - private static final Logger logger = LoggerFactory - .getLogger(FessXpathTransformer.class); + private static final Logger logger = LoggerFactory.getLogger(FessXpathTransformer.class); private static final int UTF8_BOM_SIZE = 3; @@ -99,10 +98,8 @@ public class FessXpathTransformer extends AbstractFessXpathTransformer { public Map convertUrlMap = new HashMap(); @Override - protected void storeData(final ResponseData responseData, - final ResultData resultData) { - final File tempFile = ResponseDataUtil - .createResponseBodyFile(responseData); + protected void storeData(final ResponseData responseData, final ResultData resultData) { + final File tempFile = ResponseDataUtil.createResponseBodyFile(responseData); try { final DOMParser parser = getDomParser(); BufferedInputStream bis = null; @@ -120,8 +117,7 @@ public class FessXpathTransformer extends AbstractFessXpathTransformer { } parser.parse(is); } catch (final Exception e) { - throw new RobotCrawlAccessException("Could not parse " - + responseData.getUrl(), e); + throw new RobotCrawlAccessException("Could not parse " + responseData.getUrl(), e); } finally { IOUtils.closeQuietly(bis); } @@ -129,43 +125,36 @@ public class FessXpathTransformer extends AbstractFessXpathTransformer { final Document document = parser.getDocument(); final Map dataMap = new HashMap(); - for (final Map.Entry entry : fieldRuleMap - .entrySet()) { + for (final Map.Entry entry : fieldRuleMap.entrySet()) { final String path = entry.getValue(); try { final XObject xObj = getXPathAPI().eval(document, path); final int type = xObj.getType(); switch (type) { - case XObject.CLASS_BOOLEAN: - final boolean b = xObj.bool(); - putResultDataBody(dataMap, entry.getKey(), - Boolean.toString(b)); - break; - case XObject.CLASS_NUMBER: - final double d = xObj.num(); - putResultDataBody(dataMap, entry.getKey(), - Double.toString(d)); - break; - case XObject.CLASS_STRING: - final String str = xObj.str(); - putResultDataBody(dataMap, entry.getKey(), str); - break; - case XObject.CLASS_NULL: - case XObject.CLASS_UNKNOWN: - case XObject.CLASS_NODESET: - case XObject.CLASS_RTREEFRAG: - case XObject.CLASS_UNRESOLVEDVARIABLE: - default: - final Node value = getXPathAPI().selectSingleNode( - document, entry.getValue()); - putResultDataBody(dataMap, entry.getKey(), - value != null ? value.getTextContent() - : null); - break; + case XObject.CLASS_BOOLEAN: + final boolean b = xObj.bool(); + putResultDataBody(dataMap, entry.getKey(), Boolean.toString(b)); + break; + case XObject.CLASS_NUMBER: + final double d = xObj.num(); + putResultDataBody(dataMap, entry.getKey(), Double.toString(d)); + break; + case XObject.CLASS_STRING: + final String str = xObj.str(); + putResultDataBody(dataMap, entry.getKey(), str); + break; + case XObject.CLASS_NULL: + case XObject.CLASS_UNKNOWN: + case XObject.CLASS_NODESET: + case XObject.CLASS_RTREEFRAG: + case XObject.CLASS_UNRESOLVEDVARIABLE: + default: + final Node value = getXPathAPI().selectSingleNode(document, entry.getValue()); + putResultDataBody(dataMap, entry.getKey(), value != null ? value.getTextContent() : null); + break; } } catch (final TransformerException e) { - logger.warn("Could not parse a value of " + entry.getKey() - + ":" + entry.getValue()); + logger.warn("Could not parse a value of " + entry.getKey() + ":" + entry.getValue()); } } @@ -184,9 +173,7 @@ public class FessXpathTransformer extends AbstractFessXpathTransformer { try { resultData.setData(SerializeUtil.fromObjectToBinary(dataMap)); } catch (final Exception e) { - throw new RobotCrawlAccessException( - "Could not serialize object: " + responseData.getUrl(), - e); + throw new RobotCrawlAccessException("Could not serialize object: " + responseData.getUrl(), e); } resultData.setEncoding(charsetName); } finally { @@ -196,32 +183,23 @@ public class FessXpathTransformer extends AbstractFessXpathTransformer { } } - protected void putAdditionalData(final Map dataMap, - final ResponseData responseData, final Document document) { + protected void putAdditionalData(final Map dataMap, final ResponseData responseData, final Document document) { // canonical if (StringUtil.isNotBlank(canonicalXpath)) { final String canonicalUrl = getCanonicalUrl(responseData, document); - if (canonicalUrl != null - && !canonicalUrl.equals(responseData.getUrl())) { + if (canonicalUrl != null && !canonicalUrl.equals(responseData.getUrl())) { final Set childUrlSet = new HashSet<>(); - childUrlSet.add(RequestDataBuilder.newRequestData().get() - .url(canonicalUrl).build()); + childUrlSet.add(RequestDataBuilder.newRequestData().get().url(canonicalUrl).build()); throw new ChildUrlsException(childUrlSet); } } - final CrawlingSessionHelper crawlingSessionHelper = ComponentUtil - .getCrawlingSessionHelper(); - final String sessionId = crawlingSessionHelper - .getCanonicalSessionId(responseData.getSessionId()); - final LocalDateTime documentExpires = crawlingSessionHelper - .getDocumentExpires(); - final PathMappingHelper pathMappingHelper = ComponentUtil - .getPathMappingHelper(); - final CrawlingConfigHelper crawlingConfigHelper = ComponentUtil - .getCrawlingConfigHelper(); - final CrawlingConfig crawlingConfig = crawlingConfigHelper - .get(responseData.getSessionId()); + final CrawlingSessionHelper crawlingSessionHelper = ComponentUtil.getCrawlingSessionHelper(); + final String sessionId = crawlingSessionHelper.getCanonicalSessionId(responseData.getSessionId()); + final LocalDateTime documentExpires = crawlingSessionHelper.getDocumentExpires(); + final PathMappingHelper pathMappingHelper = ComponentUtil.getPathMappingHelper(); + final CrawlingConfigHelper crawlingConfigHelper = ComponentUtil.getCrawlingConfigHelper(); + final CrawlingConfig crawlingConfig = crawlingConfigHelper.get(responseData.getSessionId()); final SystemHelper systemHelper = ComponentUtil.getSystemHelper(); final FieldHelper fieldHelper = ComponentUtil.getFieldHelper(); final FileTypeHelper fileTypeHelper = ComponentUtil.getFileTypeHelper(); @@ -229,8 +207,7 @@ public class FessXpathTransformer extends AbstractFessXpathTransformer { final String indexingTarget = crawlingConfig.getIndexingTarget(url); url = pathMappingHelper.replaceUrl(sessionId, url); - final Map fieldConfigMap = crawlingConfig - .getConfigParameterMap(ConfigName.FIELD); + final Map fieldConfigMap = crawlingConfig.getConfigParameterMap(ConfigName.FIELD); String urlEncoding; final UrlQueue urlQueue = CrawlingParameterUtil.getUrlQueue(); @@ -247,84 +224,67 @@ public class FessXpathTransformer extends AbstractFessXpathTransformer { } // expires if (documentExpires != null) { - putResultDataBody(dataMap, fieldHelper.expiresField, - FessFunctions.formatDate(documentExpires)); + putResultDataBody(dataMap, fieldHelper.expiresField, FessFunctions.formatDate(documentExpires)); } // lang - final String lang = systemHelper.normalizeLang(getSingleNodeValue( - document, langXpath, true)); + final String lang = systemHelper.normalizeLang(getSingleNodeValue(document, langXpath, true)); if (lang != null) { putResultDataBody(dataMap, fieldHelper.langField, lang); } // title // content - putResultDataBody(dataMap, fieldHelper.contentField, - getDocumentContent(responseData, document)); - if (Constants.TRUE.equalsIgnoreCase(fieldConfigMap - .get(fieldHelper.cacheField)) || enableCache) { + putResultDataBody(dataMap, fieldHelper.contentField, getDocumentContent(responseData, document)); + if (Constants.TRUE.equalsIgnoreCase(fieldConfigMap.get(fieldHelper.cacheField)) || enableCache) { String charSet = responseData.getCharSet(); if (charSet == null) { charSet = Constants.UTF_8; } try { // cache - putResultDataBody( - dataMap, - fieldHelper.cacheField, - new String(InputStreamUtil.getBytes(responseData - .getResponseBody()), charSet)); - putResultDataBody(dataMap, fieldHelper.hasCacheField, - Constants.TRUE); + putResultDataBody(dataMap, fieldHelper.cacheField, new String(InputStreamUtil.getBytes(responseData.getResponseBody()), + charSet)); + putResultDataBody(dataMap, fieldHelper.hasCacheField, Constants.TRUE); } catch (final Exception e) { - logger.warn("Failed to write a cache: " + sessionId + ":" - + responseData, e); + logger.warn("Failed to write a cache: " + sessionId + ":" + responseData, e); } } // digest - putResultDataBody(dataMap, fieldHelper.digestField, - getDocumentDigest(responseData, document)); + putResultDataBody(dataMap, fieldHelper.digestField, getDocumentDigest(responseData, document)); // segment putResultDataBody(dataMap, fieldHelper.segmentField, sessionId); // host putResultDataBody(dataMap, fieldHelper.hostField, getHost(url)); // site - putResultDataBody(dataMap, fieldHelper.siteField, - getSite(url, urlEncoding)); + putResultDataBody(dataMap, fieldHelper.siteField, getSite(url, urlEncoding)); // url putResultDataBody(dataMap, fieldHelper.urlField, url); // created putResultDataBody(dataMap, fieldHelper.createdField, Constants.NOW); // anchor - putResultDataBody(dataMap, fieldHelper.anchorField, - getAnchorList(document, responseData)); + putResultDataBody(dataMap, fieldHelper.anchorField, getAnchorList(document, responseData)); // mimetype final String mimeType = responseData.getMimeType(); putResultDataBody(dataMap, fieldHelper.mimetypeField, mimeType); if (fileTypeHelper != null) { // filetype - putResultDataBody(dataMap, fieldHelper.filetypeField, - fileTypeHelper.get(mimeType)); + putResultDataBody(dataMap, fieldHelper.filetypeField, fileTypeHelper.get(mimeType)); } // contentLength - putResultDataBody(dataMap, fieldHelper.contentLengthField, - Long.toString(responseData.getContentLength())); + putResultDataBody(dataMap, fieldHelper.contentLengthField, Long.toString(responseData.getContentLength())); // lastModified if (responseData.getLastModified() != null) { - putResultDataBody(dataMap, fieldHelper.lastModifiedField, - FessFunctions.formatDate(responseData.getLastModified())); + putResultDataBody(dataMap, fieldHelper.lastModifiedField, FessFunctions.formatDate(responseData.getLastModified())); } // indexingTarget putResultDataBody(dataMap, Constants.INDEXING_TARGET, indexingTarget); // boost - putResultDataBody(dataMap, fieldHelper.boostField, - crawlingConfig.getDocumentBoost()); + putResultDataBody(dataMap, fieldHelper.boostField, crawlingConfig.getDocumentBoost()); // label: labelType final Set labelTypeSet = new HashSet(); for (final String labelType : crawlingConfig.getLabelTypeValues()) { labelTypeSet.add(labelType); } - final LabelTypeHelper labelTypeHelper = ComponentUtil - .getLabelTypeHelper(); + final LabelTypeHelper labelTypeHelper = ComponentUtil.getLabelTypeHelper(); labelTypeSet.addAll(labelTypeHelper.getMatchedLabelValueSet(url)); putResultDataBody(dataMap, fieldHelper.labelField, labelTypeSet); // role: roleType @@ -334,58 +294,46 @@ public class FessXpathTransformer extends AbstractFessXpathTransformer { } putResultDataBody(dataMap, fieldHelper.roleField, roleTypeList); // id - putResultDataBody(dataMap, fieldHelper.idField, - crawlingSessionHelper.generateId(dataMap)); + putResultDataBody(dataMap, fieldHelper.idField, crawlingSessionHelper.generateId(dataMap)); // parentId String parentUrl = responseData.getParentUrl(); if (StringUtil.isNotBlank(parentUrl)) { parentUrl = pathMappingHelper.replaceUrl(sessionId, parentUrl); putResultDataBody(dataMap, fieldHelper.urlField, parentUrl); - putResultDataBody(dataMap, fieldHelper.parentIdField, - crawlingSessionHelper.generateId(dataMap)); + putResultDataBody(dataMap, fieldHelper.parentIdField, crawlingSessionHelper.generateId(dataMap)); putResultDataBody(dataMap, fieldHelper.urlField, url); // set again } // from config - final Map xpathConfigMap = crawlingConfig - .getConfigParameterMap(ConfigName.XPATH); - final Map scriptConfigMap = crawlingConfig - .getConfigParameterMap(ConfigName.SCRIPT); + final Map xpathConfigMap = crawlingConfig.getConfigParameterMap(ConfigName.XPATH); + final Map scriptConfigMap = crawlingConfig.getConfigParameterMap(ConfigName.SCRIPT); for (final Map.Entry entry : xpathConfigMap.entrySet()) { final String key = entry.getKey(); - final String value = getSingleNodeValue(document, entry.getValue(), - true); - putResultDataWithTemplate(dataMap, key, value, - scriptConfigMap.get(key)); + final String value = getSingleNodeValue(document, entry.getValue(), true); + putResultDataWithTemplate(dataMap, key, value, scriptConfigMap.get(key)); } - final Map valueConfigMap = crawlingConfig - .getConfigParameterMap(ConfigName.VALUE); + final Map valueConfigMap = crawlingConfig.getConfigParameterMap(ConfigName.VALUE); for (final Map.Entry entry : valueConfigMap.entrySet()) { final String key = entry.getKey(); - putResultDataWithTemplate(dataMap, key, entry.getValue(), - scriptConfigMap.get(key)); + putResultDataWithTemplate(dataMap, key, entry.getValue(), scriptConfigMap.get(key)); } } - protected String getCanonicalUrl(final ResponseData responseData, - final Document document) { - final String canonicalUrl = getSingleNodeValue(document, - canonicalXpath, false); + protected String getCanonicalUrl(final ResponseData responseData, final Document document) { + final String canonicalUrl = getSingleNodeValue(document, canonicalXpath, false); if (StringUtil.isNotBlank(canonicalUrl)) { return canonicalUrl; } return null; } - protected String getDocumentDigest(final ResponseData responseData, - final Document document) { + protected String getDocumentDigest(final ResponseData responseData, final Document document) { final String digest = getSingleNodeValue(document, digestXpath, false); if (StringUtil.isNotBlank(digest)) { return digest; } - final String body = normalizeContent(removeCommentTag(getSingleNodeValue( - document, contentXpath, prunedCacheContent))); + final String body = normalizeContent(removeCommentTag(getSingleNodeValue(document, contentXpath, prunedCacheContent))); return StringUtils.abbreviate(body, maxDigestLength); } @@ -401,8 +349,7 @@ public class FessXpathTransformer extends AbstractFessXpathTransformer { if (pos == 0) { value = " " + value.substring(lastPos + 3); } else { - value = value.substring(0, pos) + " " - + value.substring(lastPos + 3); + value = value.substring(0, pos) + " " + value.substring(lastPos + 3); } } else { break; @@ -412,13 +359,11 @@ public class FessXpathTransformer extends AbstractFessXpathTransformer { return value; } - private String getDocumentContent(final ResponseData responseData, - final Document document) { + private String getDocumentContent(final ResponseData responseData, final Document document) { return normalizeContent(getSingleNodeValue(document, contentXpath, true)); } - protected String getSingleNodeValue(final Document document, - final String xpath, final boolean pruned) { + protected String getSingleNodeValue(final Document document, final String xpath, final boolean pruned) { StringBuilder buf = null; NodeList list = null; try { @@ -479,8 +424,7 @@ public class FessXpathTransformer extends AbstractFessXpathTransformer { return false; } - protected String getMultipleNodeValue(final Document document, - final String xpath) { + protected String getMultipleNodeValue(final Document document, final String xpath) { NodeList nodeList = null; final StringBuilder buf = new StringBuilder(100); try { @@ -499,28 +443,21 @@ public class FessXpathTransformer extends AbstractFessXpathTransformer { protected String replaceOverlappingHost(final String url) { try { // remove overlapping host - final OverlappingHostHelper overlappingHostHelper = ComponentUtil - .getOverlappingHostHelper(); + final OverlappingHostHelper overlappingHostHelper = ComponentUtil.getOverlappingHostHelper(); return overlappingHostHelper.convert(url); } catch (final Exception e) { return url; } } - protected List getAnchorList(final Document document, - final ResponseData responseData) { + protected List getAnchorList(final Document document, final ResponseData responseData) { List anchorList = new ArrayList<>(); final String baseHref = getBaseHref(document); try { - final URL url = new URL(baseHref != null ? baseHref - : responseData.getUrl()); - for (final Map.Entry entry : childUrlRuleMap - .entrySet()) { - for (final String u : getUrlFromTagAttribute(url, document, - entry.getKey(), entry.getValue(), - responseData.getCharSet())) { - anchorList.add(RequestDataBuilder.newRequestData().get() - .url(u).build()); + final URL url = new URL(baseHref != null ? baseHref : responseData.getUrl()); + for (final Map.Entry entry : childUrlRuleMap.entrySet()) { + for (final String u : getUrlFromTagAttribute(url, document, entry.getKey(), entry.getValue(), responseData.getCharSet())) { + anchorList.add(RequestDataBuilder.newRequestData().get().url(u).build()); } } anchorList = convertChildUrlList(anchorList); @@ -538,13 +475,11 @@ public class FessXpathTransformer extends AbstractFessXpathTransformer { } @Override - protected List convertChildUrlList( - final List urlList) { + protected List convertChildUrlList(final List urlList) { if (urlList != null) { for (final RequestData requestData : urlList) { String url = requestData.getUrl(); - for (final Map.Entry entry : convertUrlMap - .entrySet()) { + for (final Map.Entry entry : convertUrlMap.entrySet()) { url = url.replaceAll(entry.getKey(), entry.getValue()); } requestData.setUrl(replaceOverlappingHost(url)); @@ -566,8 +501,7 @@ public class FessXpathTransformer extends AbstractFessXpathTransformer { try { return SerializeUtil.fromBinaryToObject(data); } catch (final Exception e) { - throw new RobotSystemException( - "Could not create an instanced from bytes.", e); + throw new RobotSystemException("Could not create an instanced from bytes.", e); } } return new HashMap(); @@ -579,8 +513,7 @@ public class FessXpathTransformer extends AbstractFessXpathTransformer { } @Override - protected void addChildUrlFromTagAttribute(final List urlList, - final URL url, final String attrValue, final String encoding) { + protected void addChildUrlFromTagAttribute(final List urlList, final URL url, final String attrValue, final String encoding) { final String urlValue = attrValue.trim(); URL childUrl; String u = null; @@ -615,7 +548,6 @@ public class FessXpathTransformer extends AbstractFessXpathTransformer { } private boolean isUtf8BomBytes(final byte[] b) { - return b[0] == (byte) 0xEF && b[1] == (byte) 0xBB - && b[2] == (byte) 0xBF; + return b[0] == (byte) 0xEF && b[1] == (byte) 0xBB && b[2] == (byte) 0xBF; } } diff --git a/src/main/java/org/codelibs/fess/util/ComponentUtil.java b/src/main/java/org/codelibs/fess/util/ComponentUtil.java index 9d0282d7d..1d6f08909 100644 --- a/src/main/java/org/codelibs/fess/util/ComponentUtil.java +++ b/src/main/java/org/codelibs/fess/util/ComponentUtil.java @@ -127,8 +127,7 @@ public final class ComponentUtil { return SingletonS2Container.getComponent(QUERY_RESPONSE_LIST); } - public static DynamicProperties getSolrGroupProperties( - final String groupName) { + public static DynamicProperties getSolrGroupProperties(final String groupName) { return SingletonS2Container.getComponent(groupName + PROPERTIES_SUFFIX); } diff --git a/src/main/java/org/codelibs/fess/util/FacetResponse.java b/src/main/java/org/codelibs/fess/util/FacetResponse.java index 2736088b3..3311eb03d 100644 --- a/src/main/java/org/codelibs/fess/util/FacetResponse.java +++ b/src/main/java/org/codelibs/fess/util/FacetResponse.java @@ -29,8 +29,7 @@ public class FacetResponse { protected List fieldList; - public FacetResponse(final List facetFields, - final Map facetQueryMap) { + public FacetResponse(final List facetFields, final Map facetQueryMap) { if (facetFields != null && !facetFields.isEmpty()) { fieldList = new ArrayList(); for (final FacetField facetField : facetFields) { @@ -41,8 +40,7 @@ public class FacetResponse { } if (facetQueryMap != null && !facetQueryMap.isEmpty()) { queryCountMap = new LinkedHashMap(); - for (final Map.Entry entry : facetQueryMap - .entrySet()) { + for (final Map.Entry entry : facetQueryMap.entrySet()) { queryCountMap.put(entry.getKey(), entry.getValue().longValue()); } } diff --git a/src/main/java/org/codelibs/fess/util/FessCopy.java b/src/main/java/org/codelibs/fess/util/FessCopy.java index b491a1942..a3718fa99 100644 --- a/src/main/java/org/codelibs/fess/util/FessCopy.java +++ b/src/main/java/org/codelibs/fess/util/FessCopy.java @@ -46,14 +46,12 @@ public class FessCopy extends Copy { list.add(propertyName); } } - return super.excludes(list.toArray(new CharSequence[list.size()])) - .dateConverter(Constants.DEFAULT_DATETIME_FORMAT, - "createdTime", "updatedTime", "deletedTime"); - } - - public Copy commonColumnDateConverter() { - return dateConverter(Constants.DEFAULT_DATETIME_FORMAT, "createdTime", + return super.excludes(list.toArray(new CharSequence[list.size()])).dateConverter(Constants.DEFAULT_DATETIME_FORMAT, "createdTime", "updatedTime", "deletedTime"); } + public Copy commonColumnDateConverter() { + return dateConverter(Constants.DEFAULT_DATETIME_FORMAT, "createdTime", "updatedTime", "deletedTime"); + } + } diff --git a/src/main/java/org/codelibs/fess/util/InputStreamThread.java b/src/main/java/org/codelibs/fess/util/InputStreamThread.java index ec5dfdce7..79aa69076 100644 --- a/src/main/java/org/codelibs/fess/util/InputStreamThread.java +++ b/src/main/java/org/codelibs/fess/util/InputStreamThread.java @@ -28,8 +28,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class InputStreamThread extends Thread { - private static final Logger logger = LoggerFactory - .getLogger(InputStreamThread.class); + private static final Logger logger = LoggerFactory.getLogger(InputStreamThread.class); private BufferedReader br; diff --git a/src/main/java/org/codelibs/fess/util/JobProcess.java b/src/main/java/org/codelibs/fess/util/JobProcess.java index 8eea66171..a71c30474 100644 --- a/src/main/java/org/codelibs/fess/util/JobProcess.java +++ b/src/main/java/org/codelibs/fess/util/JobProcess.java @@ -25,8 +25,7 @@ public class JobProcess { public JobProcess(final Process process) { this.process = process; - inputStreamThread = new InputStreamThread(process.getInputStream(), - Constants.UTF_8); + inputStreamThread = new InputStreamThread(process.getInputStream(), Constants.UTF_8); } public Process getProcess() { diff --git a/src/main/java/org/codelibs/fess/util/MoreLikeThisResponse.java b/src/main/java/org/codelibs/fess/util/MoreLikeThisResponse.java index 78158bcba..abc9aac33 100644 --- a/src/main/java/org/codelibs/fess/util/MoreLikeThisResponse.java +++ b/src/main/java/org/codelibs/fess/util/MoreLikeThisResponse.java @@ -20,8 +20,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -public class MoreLikeThisResponse extends - LinkedHashMap>> { +public class MoreLikeThisResponse extends LinkedHashMap>> { private static final long serialVersionUID = 1L; diff --git a/src/main/java/org/codelibs/fess/util/ParameterUtil.java b/src/main/java/org/codelibs/fess/util/ParameterUtil.java index 2252d285f..2ddce7f31 100644 --- a/src/main/java/org/codelibs/fess/util/ParameterUtil.java +++ b/src/main/java/org/codelibs/fess/util/ParameterUtil.java @@ -48,15 +48,12 @@ public class ParameterUtil { if (StringUtil.isNotBlank(line)) { final int pos = line.indexOf('='); if (pos == 0) { - throw new FessSystemException( - "Invalid parameter. The key is null."); + throw new FessSystemException("Invalid parameter. The key is null."); } else if (pos > 0) { if (pos < line.length()) { - paramMap.put(line.substring(0, pos).trim(), line - .substring(pos + 1).trim()); + paramMap.put(line.substring(0, pos).trim(), line.substring(pos + 1).trim()); } else { - paramMap.put(line.substring(0, pos).trim(), - StringUtil.EMPTY); + paramMap.put(line.substring(0, pos).trim(), StringUtil.EMPTY); } } else { paramMap.put(line.trim(), StringUtil.EMPTY); @@ -67,16 +64,14 @@ public class ParameterUtil { return paramMap; } - public static void loadConfigParams(final Map paramMap, - final String configParam) { + public static void loadConfigParams(final Map paramMap, final String configParam) { final Map map = ParameterUtil.parse(configParam); if (!map.isEmpty()) { paramMap.putAll(map); } } - public static Map> createConfigParameterMap( - final String configParameters) { + public static Map> createConfigParameterMap(final String configParameters) { final Map> map = new HashMap<>(); final Map clientConfigMap = new HashMap<>(); final Map xpathConfigMap = new HashMap<>(); @@ -90,27 +85,20 @@ public class ParameterUtil { map.put(ConfigName.VALUE, valueConfigMap); map.put(ConfigName.SCRIPT, scriptConfigMap); map.put(ConfigName.FIELD, fieldConfigMap); - for (final Map.Entry entry : ParameterUtil.parse( - configParameters).entrySet()) { + for (final Map.Entry entry : ParameterUtil.parse(configParameters).entrySet()) { final String key = entry.getKey(); if (key.startsWith(CLIENT_PREFIX)) { - clientConfigMap.put(key.substring(CLIENT_PREFIX.length()), - entry.getValue()); + clientConfigMap.put(key.substring(CLIENT_PREFIX.length()), entry.getValue()); } else if (key.startsWith(XPATH_PREFIX)) { - xpathConfigMap.put(key.substring(XPATH_PREFIX.length()), - entry.getValue()); + xpathConfigMap.put(key.substring(XPATH_PREFIX.length()), entry.getValue()); } else if (key.startsWith(META_PREFIX)) { - metaConfigMap.put(key.substring(META_PREFIX.length()), - entry.getValue()); + metaConfigMap.put(key.substring(META_PREFIX.length()), entry.getValue()); } else if (key.startsWith(VALUE_PREFIX)) { - valueConfigMap.put(key.substring(VALUE_PREFIX.length()), - entry.getValue()); + valueConfigMap.put(key.substring(VALUE_PREFIX.length()), entry.getValue()); } else if (key.startsWith(SCRIPT_PREFIX)) { - scriptConfigMap.put(key.substring(SCRIPT_PREFIX.length()), - entry.getValue()); + scriptConfigMap.put(key.substring(SCRIPT_PREFIX.length()), entry.getValue()); } else if (key.startsWith(FIELD_PREFIX)) { - fieldConfigMap.put(key.substring(FIELD_PREFIX.length()), - entry.getValue()); + fieldConfigMap.put(key.substring(FIELD_PREFIX.length()), entry.getValue()); } } diff --git a/src/main/java/org/codelibs/fess/util/QueryResponseList.java b/src/main/java/org/codelibs/fess/util/QueryResponseList.java index 1bec876b2..1c8c7b50c 100644 --- a/src/main/java/org/codelibs/fess/util/QueryResponseList.java +++ b/src/main/java/org/codelibs/fess/util/QueryResponseList.java @@ -44,8 +44,7 @@ public class QueryResponseList implements List> { private static final String DOC_VALUES = "docValues"; - private static final Logger logger = LoggerFactory - .getLogger(QueryResponseList.class); + private static final Logger logger = LoggerFactory.getLogger(QueryResponseList.class); private final List> parent; @@ -104,10 +103,8 @@ public class QueryResponseList implements List> { queryTime = queryResponse.getQTime(); searchTime = queryResponse.getElapsedTime(); - final Object partialResultsValue = queryResponse - .getResponseHeader().get(PARTIAL_RESULTS); - if (partialResultsValue != null - && ((Boolean) partialResultsValue).booleanValue()) { + final Object partialResultsValue = queryResponse.getResponseHeader().get(PARTIAL_RESULTS); + if (partialResultsValue != null && ((Boolean) partialResultsValue).booleanValue()) { partialResults = true; } @@ -122,33 +119,26 @@ public class QueryResponseList implements List> { try { final Object idValue = docMap.get(fieldHelper.idField); if (queryResponse.getHighlighting().get(idValue) != null) { - for (final String hf : queryHelper - .getHighlightingFields()) { - final List highlightSnippets = queryResponse - .getHighlighting().get(idValue).get(hf); + for (final String hf : queryHelper.getHighlightingFields()) { + final List highlightSnippets = queryResponse.getHighlighting().get(idValue).get(hf); String value = null; - if (highlightSnippets != null - && !highlightSnippets.isEmpty()) { - value = StringUtils.join(highlightSnippets, - "..."); + if (highlightSnippets != null && !highlightSnippets.isEmpty()) { + value = StringUtils.join(highlightSnippets, "..."); docMap.put(hlPrefix + hf, value); } } } } catch (final Exception e) { if (logger.isDebugEnabled()) { - logger.debug("Could not create a highlighting value: " - + docMap, e); + logger.debug("Could not create a highlighting value: " + docMap, e); } } // ContentTitle final ViewHelper viewHelper = ComponentUtil.getViewHelper(); if (viewHelper != null) { - docMap.put("contentTitle", - viewHelper.getContentTitle(docMap)); - docMap.put("contentDescription", - viewHelper.getContentDescription(docMap)); + docMap.put("contentTitle", viewHelper.getContentTitle(docMap)); + docMap.put("contentDescription", viewHelper.getContentDescription(docMap)); docMap.put("urlLink", viewHelper.getUrlLink(docMap)); docMap.put("sitePath", viewHelper.getSitePath(docMap)); } @@ -158,27 +148,22 @@ public class QueryResponseList implements List> { // facet final List facetFields = queryResponse.getFacetFields(); - final Map facetQueryMap = queryResponse - .getFacetQuery(); + final Map facetQueryMap = queryResponse.getFacetQuery(); if (facetFields != null || facetQueryMap != null) { facetResponse = new FacetResponse(facetFields, facetQueryMap); } // mlt - final Object moreLikeThisMap = queryResponse.getResponse().get( - MORE_LIKE_THIS); + final Object moreLikeThisMap = queryResponse.getResponse().get(MORE_LIKE_THIS); if (moreLikeThisMap instanceof SimpleOrderedMap) { moreLikeThisResponse = new MoreLikeThisResponse(); final int size = ((SimpleOrderedMap) moreLikeThisMap).size(); for (int i = 0; i < size; i++) { - final String id = ((SimpleOrderedMap) moreLikeThisMap) - .getName(i); - final Object docList = ((SimpleOrderedMap) moreLikeThisMap) - .getVal(i); - if (StringUtil.isNotBlank(id) - && docList instanceof SolrDocumentList) { - final List> docMapList = new ArrayList>( - ((SolrDocumentList) docList).size()); + final String id = ((SimpleOrderedMap) moreLikeThisMap).getName(i); + final Object docList = ((SimpleOrderedMap) moreLikeThisMap).getVal(i); + if (StringUtil.isNotBlank(id) && docList instanceof SolrDocumentList) { + final List> docMapList = + new ArrayList>(((SolrDocumentList) docList).size()); for (final SolrDocument solrDoc : (SolrDocumentList) docList) { final Map docMap = new HashMap(); docMap.putAll(solrDoc); @@ -190,8 +175,7 @@ public class QueryResponseList implements List> { } // docValues - final Object docValuesObj = queryResponse.getResponse().get( - DOC_VALUES); + final Object docValuesObj = queryResponse.getResponse().get(DOC_VALUES); if (docValuesObj instanceof SimpleOrderedMap) { @SuppressWarnings("unchecked") final SimpleOrderedMap> docValuesMap = (SimpleOrderedMap>) docValuesObj; @@ -207,19 +191,16 @@ public class QueryResponseList implements List> { calculatePageInfo(start, pageSize, numFound); } - protected void calculatePageInfo(final long start, final int size, - final long numFound) { + protected void calculatePageInfo(final long start, final int size, final long numFound) { pageSize = size; allRecordCount = numFound; allPageCount = (int) ((allRecordCount - 1) / pageSize) + 1; existPrevPage = start > 0; existNextPage = start < (long) (allPageCount - 1) * (long) pageSize; currentPageNumber = (int) (start / pageSize) + 1; - currentStartRecordNumber = numFound != 0 ? (currentPageNumber - 1) - * pageSize + 1 : 0; + currentStartRecordNumber = numFound != 0 ? (currentPageNumber - 1) * pageSize + 1 : 0; currentEndRecordNumber = currentPageNumber * pageSize; - currentEndRecordNumber = allRecordCount < currentEndRecordNumber ? allRecordCount - : currentEndRecordNumber; + currentEndRecordNumber = allRecordCount < currentEndRecordNumber ? allRecordCount : currentEndRecordNumber; final int pageRangeSize = 5; int startPageRangeSize = currentPageNumber - pageRangeSize; @@ -253,8 +234,7 @@ public class QueryResponseList implements List> { } @Override - public boolean addAll(final int index, - final Collection> c) { + public boolean addAll(final int index, final Collection> c) { return parent.addAll(index, c); } @@ -339,8 +319,7 @@ public class QueryResponseList implements List> { } @Override - public Map set(final int index, - final Map element) { + public Map set(final int index, final Map element) { return parent.set(index, element); } @@ -350,8 +329,7 @@ public class QueryResponseList implements List> { } @Override - public List> subList(final int fromIndex, - final int toIndex) { + public List> subList(final int fromIndex, final int toIndex) { return parent.subList(fromIndex, toIndex); } @@ -447,19 +425,12 @@ public class QueryResponseList implements List> { @Override public String toString() { - return "parent=" + parent + ", pageSize=" + pageSize - + ", currentPageNumber=" + currentPageNumber - + ", allRecordCount=" + allRecordCount + ", allPageCount=" - + allPageCount + ", existNextPage=" + existNextPage - + ", existPrevPage=" + existPrevPage - + ", currentStartRecordNumber=" + currentStartRecordNumber - + ", currentEndRecordNumber=" + currentEndRecordNumber - + ", pageNumberList=" + pageNumberList + ", searchQuery=" - + searchQuery + ", solrQuery=" + solrQuery + ", execTime=" - + execTime + ", facetResponse=" + facetResponse - + ", moreLikeThisResponse=" + moreLikeThisResponse - + ", partialResults=" + partialResults + ", queryTime=" - + queryTime + ", searchTime=" + searchTime; + return "parent=" + parent + ", pageSize=" + pageSize + ", currentPageNumber=" + currentPageNumber + ", allRecordCount=" + + allRecordCount + ", allPageCount=" + allPageCount + ", existNextPage=" + existNextPage + ", existPrevPage=" + + existPrevPage + ", currentStartRecordNumber=" + currentStartRecordNumber + ", currentEndRecordNumber=" + + currentEndRecordNumber + ", pageNumberList=" + pageNumberList + ", searchQuery=" + searchQuery + ", solrQuery=" + + solrQuery + ", execTime=" + execTime + ", facetResponse=" + facetResponse + ", moreLikeThisResponse=" + + moreLikeThisResponse + ", partialResults=" + partialResults + ", queryTime=" + queryTime + ", searchTime=" + searchTime; } } diff --git a/src/main/java/org/codelibs/fess/util/QueryUtil.java b/src/main/java/org/codelibs/fess/util/QueryUtil.java index eea5cf17c..183d5e3d0 100644 --- a/src/main/java/org/codelibs/fess/util/QueryUtil.java +++ b/src/main/java/org/codelibs/fess/util/QueryUtil.java @@ -24,8 +24,7 @@ public class QueryUtil { } public static String escapeValue(final String value) { - final String escapedValue = Constants.SOLR_FIELD_RESERVED_PATTERN - .matcher(value).replaceAll("\\\\$1"); + final String escapedValue = Constants.SOLR_FIELD_RESERVED_PATTERN.matcher(value).replaceAll("\\\\$1"); if (escapedValue.length() > 1) { final char c = escapedValue.charAt(0); if (c == '*' || c == '?') { @@ -36,8 +35,7 @@ public class QueryUtil { } public static String escapeRangeValue(final String value) { - final String escapedValue = Constants.SOLR_RANGE_FIELD_RESERVED_PATTERN - .matcher(value).replaceAll("\\\\$1"); + final String escapedValue = Constants.SOLR_RANGE_FIELD_RESERVED_PATTERN.matcher(value).replaceAll("\\\\$1"); if (escapedValue.length() > 1) { final char c = escapedValue.charAt(0); if (c == '*' || c == '?') { diff --git a/src/main/java/org/codelibs/fess/util/ResourceUtil.java b/src/main/java/org/codelibs/fess/util/ResourceUtil.java index a0ec9abe5..95c0a61a6 100644 --- a/src/main/java/org/codelibs/fess/util/ResourceUtil.java +++ b/src/main/java/org/codelibs/fess/util/ResourceUtil.java @@ -60,8 +60,7 @@ public class ResourceUtil { String path = null; try { - final ServletContext servletContext = SingletonS2Container - .getComponent(ServletContext.class); + final ServletContext servletContext = SingletonS2Container.getComponent(ServletContext.class); if (servletContext != null) { path = servletContext.getRealPath("/" + baseName + name); } @@ -106,8 +105,7 @@ public class ResourceUtil { if (replacement == null) { replacement = matcher.group(1); } - matcher.appendReplacement(tunedText, - replacement.replace("\\", "\\\\").replace("$", "\\$")); + matcher.appendReplacement(tunedText, replacement.replace("\\", "\\\\").replace("$", "\\$")); } matcher.appendTail(tunedText); diff --git a/src/main/java/org/codelibs/fess/util/WebApiUtil.java b/src/main/java/org/codelibs/fess/util/WebApiUtil.java index 205518a76..ead4963f8 100644 --- a/src/main/java/org/codelibs/fess/util/WebApiUtil.java +++ b/src/main/java/org/codelibs/fess/util/WebApiUtil.java @@ -37,18 +37,15 @@ public final class WebApiUtil { } public static void setError(final int statusCode, final String message) { - RequestUtil.getRequest().setAttribute(WEB_API_EXCEPTION, - new WebApiException(statusCode, message)); + RequestUtil.getRequest().setAttribute(WEB_API_EXCEPTION, new WebApiException(statusCode, message)); } public static void setError(final int statusCode, final Exception e) { - RequestUtil.getRequest().setAttribute(WEB_API_EXCEPTION, - new WebApiException(statusCode, e)); + RequestUtil.getRequest().setAttribute(WEB_API_EXCEPTION, new WebApiException(statusCode, e)); } public static void validate() { - final WebApiException e = (WebApiException) RequestUtil.getRequest() - .getAttribute(WEB_API_EXCEPTION); + final WebApiException e = (WebApiException) RequestUtil.getRequest().getAttribute(WEB_API_EXCEPTION); if (e != null) { throw e; } diff --git a/src/main/java/org/codelibs/fess/validator/CronExpressionChecks.java b/src/main/java/org/codelibs/fess/validator/CronExpressionChecks.java index 94e8546c2..eaf494995 100644 --- a/src/main/java/org/codelibs/fess/validator/CronExpressionChecks.java +++ b/src/main/java/org/codelibs/fess/validator/CronExpressionChecks.java @@ -30,13 +30,10 @@ public class CronExpressionChecks extends S2FieldChecks { private static final long serialVersionUID = 1L; - public static boolean validateCronExpression(final Object bean, - final ValidatorAction validatorAction, final Field field, - final ActionMessages errors, final Validator validator, - final HttpServletRequest request) { + public static boolean validateCronExpression(final Object bean, final ValidatorAction validatorAction, final Field field, + final ActionMessages errors, final Validator validator, final HttpServletRequest request) { final String value = getValueAsString(bean, field); - if (StringUtil.isNotBlank(value) - && !CronExpression.isValidExpression(value)) { + if (StringUtil.isNotBlank(value) && !CronExpression.isValidExpression(value)) { addError(errors, field, validator, validatorAction, request); return false; } diff --git a/src/main/java/org/codelibs/fess/validator/UriTypeChecks.java b/src/main/java/org/codelibs/fess/validator/UriTypeChecks.java index a1ac205d2..6a256af2b 100644 --- a/src/main/java/org/codelibs/fess/validator/UriTypeChecks.java +++ b/src/main/java/org/codelibs/fess/validator/UriTypeChecks.java @@ -30,10 +30,8 @@ public class UriTypeChecks extends S2FieldChecks { private static final long serialVersionUID = 1L; - public static boolean validateUriType(final Object bean, - final ValidatorAction validatorAction, final Field field, - final ActionMessages errors, final Validator validator, - final HttpServletRequest request) { + public static boolean validateUriType(final Object bean, final ValidatorAction validatorAction, final Field field, + final ActionMessages errors, final Validator validator, final HttpServletRequest request) { final String value = getValueAsString(bean, field); if (StringUtil.isNotBlank(value)) { final String protocols = field.getVarValue("protocols"); diff --git a/src/test/java/org/codelibs/fess/dict/DictionaryManagerTest.java b/src/test/java/org/codelibs/fess/dict/DictionaryManagerTest.java index 466098805..04f5514b6 100644 --- a/src/test/java/org/codelibs/fess/dict/DictionaryManagerTest.java +++ b/src/test/java/org/codelibs/fess/dict/DictionaryManagerTest.java @@ -37,8 +37,7 @@ public class DictionaryManagerTest extends S2TestCase { testDir.delete(); testDir.mkdirs(); synonymFile1 = new File(testDir, "synonym.txt"); - FileUtil.write(synonymFile1.getAbsolutePath(), - "abc=>123\nxyz,890".getBytes(Constants.UTF_8)); + FileUtil.write(synonymFile1.getAbsolutePath(), "abc=>123\nxyz,890".getBytes(Constants.UTF_8)); } @Override @@ -56,16 +55,14 @@ public class DictionaryManagerTest extends S2TestCase { synonymLocator.addSearchPath(testDir.getAbsolutePath()); dictionaryManager.addLocator(synonymLocator); dictionaryManager.init(); - final DictionaryFile[] synonymFiles = dictionaryManager - .getDictionaryFiles(); + final DictionaryFile[] synonymFiles = dictionaryManager.getDictionaryFiles(); assertEquals(1, synonymFiles.length); assertNotNull(dictionaryManager.dicFileMap); Thread.sleep(2000); assertNull(dictionaryManager.dicFileMap); - final DictionaryFile[] synonymFiles2 = dictionaryManager - .getDictionaryFiles(); + final DictionaryFile[] synonymFiles2 = dictionaryManager.getDictionaryFiles(); assertEquals(1, synonymFiles2.length); assertNotNull(dictionaryManager.dicFileMap); diff --git a/src/test/java/org/codelibs/fess/dict/synonym/SynonymFileTest.java b/src/test/java/org/codelibs/fess/dict/synonym/SynonymFileTest.java index 61f33d234..7790cb1e4 100644 --- a/src/test/java/org/codelibs/fess/dict/synonym/SynonymFileTest.java +++ b/src/test/java/org/codelibs/fess/dict/synonym/SynonymFileTest.java @@ -30,9 +30,7 @@ public class SynonymFileTest extends S2TestCase { @Override protected void setUp() throws Exception { file1 = File.createTempFile("synonym", ".txt"); - FileUtil.write(file1.getAbsolutePath(), - "a1=>A1\nb1,b2 => B1\nc1 => C1, C2\nx1,X1\ny1, Y1, y2" - .getBytes(Constants.UTF_8)); + FileUtil.write(file1.getAbsolutePath(), "a1=>A1\nb1,b2 => B1\nc1 => C1, C2\nx1,X1\ny1, Y1, y2".getBytes(Constants.UTF_8)); } @Override @@ -105,8 +103,7 @@ public class SynonymFileTest extends S2TestCase { final PagingList itemList1 = synonymFile.selectList(0, 20); assertEquals(5, itemList1.size()); - final SynonymItem synonymItem1 = new SynonymItem(0, new String[] { - "z1", "z2" }, new String[] { "Z1", "Z2" }); + final SynonymItem synonymItem1 = new SynonymItem(0, new String[] { "z1", "z2" }, new String[] { "Z1", "Z2" }); synonymFile.insert(synonymItem1); final PagingList itemList2 = synonymFile.selectList(0, 20); assertEquals(6, itemList2.size()); @@ -115,8 +112,7 @@ public class SynonymFileTest extends S2TestCase { assertEquals("Z1", itemList2.get(5).getOutputs()[0]); assertEquals("Z2", itemList2.get(5).getOutputs()[1]); - final SynonymItem synonymItem2 = new SynonymItem(0, new String[] { - "z1", "z2" }, new String[] { "z1", "z2" }); + final SynonymItem synonymItem2 = new SynonymItem(0, new String[] { "z1", "z2" }, new String[] { "z1", "z2" }); synonymFile.insert(synonymItem2); final PagingList itemList3 = synonymFile.selectList(0, 20); assertEquals(7, itemList3.size()); @@ -177,10 +173,7 @@ public class SynonymFileTest extends S2TestCase { final PagingList itemList3 = synonymFile.selectList(0, 20); assertEquals(3, itemList3.size()); - assertEquals( - "b1,b2=>B1" + Constants.LINE_SEPARATOR + "c1=>C1,C2" - + Constants.LINE_SEPARATOR + "X1,x1" - + Constants.LINE_SEPARATOR, + assertEquals("b1,b2=>B1" + Constants.LINE_SEPARATOR + "c1=>C1,C2" + Constants.LINE_SEPARATOR + "X1,x1" + Constants.LINE_SEPARATOR, new String(FileUtil.getBytes(file1), Constants.UTF_8)); } diff --git a/src/test/java/org/codelibs/fess/dict/synonym/SynonymItemTest.java b/src/test/java/org/codelibs/fess/dict/synonym/SynonymItemTest.java index d1d8cbd42..c3abafec1 100644 --- a/src/test/java/org/codelibs/fess/dict/synonym/SynonymItemTest.java +++ b/src/test/java/org/codelibs/fess/dict/synonym/SynonymItemTest.java @@ -21,8 +21,7 @@ import org.seasar.extension.unit.S2TestCase; public class SynonymItemTest extends S2TestCase { public void test_new1() { - final SynonymItem synonymItem = new SynonymItem(1, new String[] { "a", - "A" }, new String[] { "b", "B" }); + final SynonymItem synonymItem = new SynonymItem(1, new String[] { "a", "A" }, new String[] { "b", "B" }); assertEquals(1, synonymItem.getId()); assertEquals(2, synonymItem.getInputs().length); assertEquals("A", synonymItem.getInputs()[0]); @@ -47,8 +46,7 @@ public class SynonymItemTest extends S2TestCase { } public void test_new2() { - final SynonymItem synonymItem = new SynonymItem(1, new String[] { "A", - "a" }, new String[] { "B", "b" }); + final SynonymItem synonymItem = new SynonymItem(1, new String[] { "A", "a" }, new String[] { "B", "b" }); assertEquals(1, synonymItem.getId()); assertEquals(2, synonymItem.getInputs().length); assertEquals("A", synonymItem.getInputs()[0]); @@ -73,48 +71,32 @@ public class SynonymItemTest extends S2TestCase { } public void test_equals1() { - final SynonymItem synonymItem1 = new SynonymItem(1, new String[] { "a", - "A" }, new String[] { "b", "B" }); + final SynonymItem synonymItem1 = new SynonymItem(1, new String[] { "a", "A" }, new String[] { "b", "B" }); assertTrue(synonymItem1.equals(synonymItem1)); - assertTrue(synonymItem1.equals(new SynonymItem(1, new String[] { "A", - "a" }, new String[] { "B", "b" }))); - assertTrue(synonymItem1.equals(new SynonymItem(2, new String[] { "A", - "a" }, new String[] { "B", "b" }))); - assertFalse(synonymItem1.equals(new SynonymItem(2, new String[] { "A", - "a" }, new String[] { "B", }))); - assertFalse(synonymItem1.equals(new SynonymItem(2, - new String[] { "A" }, new String[] { "B", "b" }))); - assertFalse(synonymItem1.equals(new SynonymItem(1, new String[] { "A", - "a" }, new String[] { "B", "c" }))); - assertFalse(synonymItem1.equals(new SynonymItem(1, new String[] { "A", - "c" }, new String[] { "B", "b" }))); + assertTrue(synonymItem1.equals(new SynonymItem(1, new String[] { "A", "a" }, new String[] { "B", "b" }))); + assertTrue(synonymItem1.equals(new SynonymItem(2, new String[] { "A", "a" }, new String[] { "B", "b" }))); + assertFalse(synonymItem1.equals(new SynonymItem(2, new String[] { "A", "a" }, new String[] { "B", }))); + assertFalse(synonymItem1.equals(new SynonymItem(2, new String[] { "A" }, new String[] { "B", "b" }))); + assertFalse(synonymItem1.equals(new SynonymItem(1, new String[] { "A", "a" }, new String[] { "B", "c" }))); + assertFalse(synonymItem1.equals(new SynonymItem(1, new String[] { "A", "c" }, new String[] { "B", "b" }))); } public void test_equals2() { - final SynonymItem synonymItem1 = new SynonymItem(1, - new String[] { "a" }, new String[] { "b" }); + final SynonymItem synonymItem1 = new SynonymItem(1, new String[] { "a" }, new String[] { "b" }); assertTrue(synonymItem1.equals(synonymItem1)); - assertTrue(synonymItem1.equals(new SynonymItem(1, new String[] { "a" }, - new String[] { "b" }))); - assertFalse(synonymItem1.equals(new SynonymItem(2, - new String[] { "a" }, new String[] { "B", }))); - assertFalse(synonymItem1.equals(new SynonymItem(2, - new String[] { "A" }, new String[] { "b" }))); + assertTrue(synonymItem1.equals(new SynonymItem(1, new String[] { "a" }, new String[] { "b" }))); + assertFalse(synonymItem1.equals(new SynonymItem(2, new String[] { "a" }, new String[] { "B", }))); + assertFalse(synonymItem1.equals(new SynonymItem(2, new String[] { "A" }, new String[] { "b" }))); } public void test_toLineString() { assertEquals("a1,a2,a3=>b1,b2,b3", - new SynonymItem(1, new String[] { "a1", "a2", "a3" }, - new String[] { "b1", "b2", "b3" }).toLineString()); - assertEquals("a=>b", new SynonymItem(1, new String[] { "a" }, - new String[] { "b" }).toLineString()); - assertEquals("A,a=>B,b", new SynonymItem(1, new String[] { "a", "A" }, - new String[] { "b", "B" }).toLineString()); - assertEquals("A,a", new SynonymItem(1, new String[] { "a", "A" }, - new String[] { "a", "A" }).toLineString()); - assertEquals("a", new SynonymItem(1, new String[] { "a" }, - new String[] { "a" }).toLineString()); + new SynonymItem(1, new String[] { "a1", "a2", "a3" }, new String[] { "b1", "b2", "b3" }).toLineString()); + assertEquals("a=>b", new SynonymItem(1, new String[] { "a" }, new String[] { "b" }).toLineString()); + assertEquals("A,a=>B,b", new SynonymItem(1, new String[] { "a", "A" }, new String[] { "b", "B" }).toLineString()); + assertEquals("A,a", new SynonymItem(1, new String[] { "a", "A" }, new String[] { "a", "A" }).toLineString()); + assertEquals("a", new SynonymItem(1, new String[] { "a" }, new String[] { "a" }).toLineString()); } } diff --git a/src/test/java/org/codelibs/fess/dict/synonym/SynonymLocatorTest.java b/src/test/java/org/codelibs/fess/dict/synonym/SynonymLocatorTest.java index 58a692437..2c05e2f95 100644 --- a/src/test/java/org/codelibs/fess/dict/synonym/SynonymLocatorTest.java +++ b/src/test/java/org/codelibs/fess/dict/synonym/SynonymLocatorTest.java @@ -55,20 +55,15 @@ public class SynonymLocatorTest extends S2TestCase { testCoreDir = new File(testDir, "core"); testCoreDir.mkdirs(); synonymFile1 = new File(testDir, "synonym.txt"); - FileUtil.write(synonymFile1.getAbsolutePath(), - "abc=>123\nxyz,890".getBytes(Constants.UTF_8)); + FileUtil.write(synonymFile1.getAbsolutePath(), "abc=>123\nxyz,890".getBytes(Constants.UTF_8)); synonymFile2 = new File(testDataDir, "synonym_data.txt"); - FileUtil.write(synonymFile2.getAbsolutePath(), - "abc=>123\nxyz,890".getBytes(Constants.UTF_8)); + FileUtil.write(synonymFile2.getAbsolutePath(), "abc=>123\nxyz,890".getBytes(Constants.UTF_8)); synonymFile3 = new File(testCoreDir, "synonym_core.txt"); - FileUtil.write(synonymFile3.getAbsolutePath(), - "abc=>123\nxyz,890".getBytes(Constants.UTF_8)); + FileUtil.write(synonymFile3.getAbsolutePath(), "abc=>123\nxyz,890".getBytes(Constants.UTF_8)); dummyFile1 = new File(testDir, "dummy.txt"); - FileUtil.write(dummyFile1.getAbsolutePath(), - "dummy 1".getBytes(Constants.UTF_8)); + FileUtil.write(dummyFile1.getAbsolutePath(), "dummy 1".getBytes(Constants.UTF_8)); dummyFile2 = new File(testCoreDir, "dummy.txt"); - FileUtil.write(dummyFile2.getAbsolutePath(), - "dummy 2".getBytes(Constants.UTF_8)); + FileUtil.write(dummyFile2.getAbsolutePath(), "dummy 2".getBytes(Constants.UTF_8)); } @@ -82,8 +77,7 @@ public class SynonymLocatorTest extends S2TestCase { synonymLocator.excludedSynonymList = new ArrayList(); synonymLocator.excludedSynonymList.add("data"); synonymLocator.addSearchPath(testDir.getAbsolutePath()); - final List> list = synonymLocator - .find(); + final List> list = synonymLocator.find(); assertEquals(2, list.size()); final DictionaryFile dicFile1 = list.get(0); final DictionaryFile dicFile2 = list.get(1); diff --git a/src/test/java/org/codelibs/fess/dict/userdict/UserDictFileTest.java b/src/test/java/org/codelibs/fess/dict/userdict/UserDictFileTest.java index edab87e66..0e7ace862 100644 --- a/src/test/java/org/codelibs/fess/dict/userdict/UserDictFileTest.java +++ b/src/test/java/org/codelibs/fess/dict/userdict/UserDictFileTest.java @@ -30,10 +30,8 @@ public class UserDictFileTest extends S2TestCase { @Override protected void setUp() throws Exception { file1 = File.createTempFile("userdict_", ".txt"); - FileUtil.write( - file1.getAbsolutePath(), - "token1,seg1,reading1,pos1\ntoken2,seg2,reading2,pos2\ntoken3,seg3,reading3,pos3" - .getBytes(Constants.UTF_8)); + FileUtil.write(file1.getAbsolutePath(), + "token1,seg1,reading1,pos1\ntoken2,seg2,reading2,pos2\ntoken3,seg3,reading3,pos3".getBytes(Constants.UTF_8)); } @Override @@ -43,15 +41,13 @@ public class UserDictFileTest extends S2TestCase { public void test_selectList() { final UserDictFile userDictFile = new UserDictFile(file1); - final PagingList itemList1 = userDictFile.selectList(0, - 20); + final PagingList itemList1 = userDictFile.selectList(0, 20); assertEquals(3, itemList1.size()); assertEquals(3, itemList1.getAllRecordCount()); assertEquals(1, itemList1.getCurrentPageNumber()); assertEquals(20, itemList1.getPageSize()); - final PagingList itemList2 = userDictFile - .selectList(2, 2); + final PagingList itemList2 = userDictFile.selectList(2, 2); assertEquals(1, itemList2.size()); assertEquals(3, itemList2.getAllRecordCount()); assertEquals(2, itemList2.getCurrentPageNumber()); @@ -77,26 +73,21 @@ public class UserDictFileTest extends S2TestCase { public void test_insert() { final UserDictFile userDictFile = new UserDictFile(file1); - final PagingList itemList1 = userDictFile.selectList(0, - 20); + final PagingList itemList1 = userDictFile.selectList(0, 20); assertEquals(3, itemList1.size()); - final UserDictItem userDictItem1 = new UserDictItem(0, "token4", - "seg4", "reading4", "pos4"); + final UserDictItem userDictItem1 = new UserDictItem(0, "token4", "seg4", "reading4", "pos4"); userDictFile.insert(userDictItem1); - final PagingList itemList2 = userDictFile.selectList(0, - 20); + final PagingList itemList2 = userDictFile.selectList(0, 20); assertEquals(4, itemList2.size()); assertEquals("token4", itemList2.get(3).getToken()); assertEquals("seg4", itemList2.get(3).getSegmentation()); assertEquals("reading4", itemList2.get(3).getReading()); assertEquals("pos4", itemList2.get(3).getPos()); - final UserDictItem userDictItem2 = new UserDictItem(0, "token5", - "seg5", "reading5", "pos5"); + final UserDictItem userDictItem2 = new UserDictItem(0, "token5", "seg5", "reading5", "pos5"); userDictFile.insert(userDictItem2); - final PagingList itemList3 = userDictFile.selectList(0, - 20); + final PagingList itemList3 = userDictFile.selectList(0, 20); assertEquals(5, itemList3.size()); assertEquals("token5", itemList3.get(4).getToken()); assertEquals("seg5", itemList3.get(4).getSegmentation()); @@ -106,8 +97,7 @@ public class UserDictFileTest extends S2TestCase { public void test_update() { final UserDictFile userDictFile = new UserDictFile(file1); - final PagingList itemList1 = userDictFile.selectList(0, - 20); + final PagingList itemList1 = userDictFile.selectList(0, 20); assertEquals(3, itemList1.size()); final UserDictItem userDictItem1 = itemList1.get(0); @@ -116,8 +106,7 @@ public class UserDictFileTest extends S2TestCase { userDictItem1.setNewReading("READING1"); userDictItem1.setNewPos("POS1"); userDictFile.update(userDictItem1); - final PagingList itemList2 = userDictFile.selectList(0, - 20); + final PagingList itemList2 = userDictFile.selectList(0, 20); assertEquals(3, itemList2.size()); final UserDictItem userDictItem2 = itemList2.get(0); assertEquals("TOKEN1", userDictItem2.getToken()); @@ -132,8 +121,7 @@ public class UserDictFileTest extends S2TestCase { userDictItem3.setNewReading("READING3"); userDictItem3.setNewPos("POS3"); userDictFile.update(userDictItem3); - final PagingList itemList3 = userDictFile.selectList(0, - 20); + final PagingList itemList3 = userDictFile.selectList(0, 20); assertEquals(3, itemList3.size()); final UserDictItem userDictItem4 = itemList3.get(2); assertEquals("TOKEN3", userDictItem4.getToken()); @@ -145,24 +133,20 @@ public class UserDictFileTest extends S2TestCase { public void test_delete() throws Exception { final UserDictFile userDictFile = new UserDictFile(file1); - final PagingList itemList1 = userDictFile.selectList(0, - 20); + final PagingList itemList1 = userDictFile.selectList(0, 20); assertEquals(3, itemList1.size()); final UserDictItem userDictItem1 = itemList1.get(0); userDictFile.delete(userDictItem1); - final PagingList itemList2 = userDictFile.selectList(0, - 20); + final PagingList itemList2 = userDictFile.selectList(0, 20); assertEquals(2, itemList2.size()); final UserDictItem userDictItem2 = itemList2.get(1); userDictFile.delete(userDictItem2); - final PagingList itemList3 = userDictFile.selectList(0, - 20); + final PagingList itemList3 = userDictFile.selectList(0, 20); assertEquals(1, itemList3.size()); - assertEquals("token2,seg2,reading2,pos2" + Constants.LINE_SEPARATOR, - new String(FileUtil.getBytes(file1), Constants.UTF_8)); + assertEquals("token2,seg2,reading2,pos2" + Constants.LINE_SEPARATOR, new String(FileUtil.getBytes(file1), Constants.UTF_8)); } } diff --git a/src/test/java/org/codelibs/fess/dict/userdict/UserDictItemTest.java b/src/test/java/org/codelibs/fess/dict/userdict/UserDictItemTest.java index 7c7f4dc9f..2349fd98c 100644 --- a/src/test/java/org/codelibs/fess/dict/userdict/UserDictItemTest.java +++ b/src/test/java/org/codelibs/fess/dict/userdict/UserDictItemTest.java @@ -21,8 +21,7 @@ import org.seasar.extension.unit.S2TestCase; public class UserDictItemTest extends S2TestCase { public void test_new1() { - final UserDictItem userDictItem = new UserDictItem(1, "t1", "s1", "r1", - "p1"); + final UserDictItem userDictItem = new UserDictItem(1, "t1", "s1", "r1", "p1"); assertEquals(1, userDictItem.getId()); assertEquals("t1", userDictItem.getToken()); assertEquals("s1", userDictItem.getSegmentation()); @@ -48,33 +47,22 @@ public class UserDictItemTest extends S2TestCase { } public void test_equals1() { - final UserDictItem userDictItem1 = new UserDictItem(1, "t1", "s1", - "r1", "p1"); + final UserDictItem userDictItem1 = new UserDictItem(1, "t1", "s1", "r1", "p1"); assertTrue(userDictItem1.equals(userDictItem1)); - assertTrue(userDictItem1.equals(new UserDictItem(1, "t1", "s1", "r1", - "p1"))); - assertTrue(userDictItem1.equals(new UserDictItem(2, "t1", "s1", "r1", - "p1"))); - assertFalse(userDictItem1.equals(new UserDictItem(1, "T1", "s1", "r1", - "p1"))); - assertFalse(userDictItem1.equals(new UserDictItem(1, "t1", "S1", "r1", - "p1"))); - assertFalse(userDictItem1.equals(new UserDictItem(1, "t1", "s1", "R1", - "p1"))); - assertFalse(userDictItem1.equals(new UserDictItem(1, "t1", "s1", "r1", - "P1"))); + assertTrue(userDictItem1.equals(new UserDictItem(1, "t1", "s1", "r1", "p1"))); + assertTrue(userDictItem1.equals(new UserDictItem(2, "t1", "s1", "r1", "p1"))); + assertFalse(userDictItem1.equals(new UserDictItem(1, "T1", "s1", "r1", "p1"))); + assertFalse(userDictItem1.equals(new UserDictItem(1, "t1", "S1", "r1", "p1"))); + assertFalse(userDictItem1.equals(new UserDictItem(1, "t1", "s1", "R1", "p1"))); + assertFalse(userDictItem1.equals(new UserDictItem(1, "t1", "s1", "r1", "P1"))); } public void test_toLineString() { - assertEquals("t1,s1,r1,p1", - new UserDictItem(1, "t1", "s1", "r1", "p1").toLineString()); - assertEquals("t\"\"1,s\"\"1,r\"\"1,p\"\"1", new UserDictItem(1, "t\"1", - "s\"1", "r\"1", "p\"1").toLineString()); - assertEquals("\"t,1\",\"s,1\",\"r,1\",\"p,1\"", new UserDictItem(1, - "t,1", "s,1", "r,1", "p,1").toLineString()); + assertEquals("t1,s1,r1,p1", new UserDictItem(1, "t1", "s1", "r1", "p1").toLineString()); + assertEquals("t\"\"1,s\"\"1,r\"\"1,p\"\"1", new UserDictItem(1, "t\"1", "s\"1", "r\"1", "p\"1").toLineString()); + assertEquals("\"t,1\",\"s,1\",\"r,1\",\"p,1\"", new UserDictItem(1, "t,1", "s,1", "r,1", "p,1").toLineString()); assertEquals("\"t\"\",1\",\"s\"\",1\",\"r\"\",1\",\"p\"\",1\"", - new UserDictItem(1, "t\",1", "s\",1", "r\",1", "p\",1") - .toLineString()); + new UserDictItem(1, "t\",1", "s\",1", "r\",1", "p\",1").toLineString()); } } diff --git a/src/test/java/org/codelibs/fess/dict/userdict/UserDictLocatorTest.java b/src/test/java/org/codelibs/fess/dict/userdict/UserDictLocatorTest.java index b992673ad..f5c807d89 100644 --- a/src/test/java/org/codelibs/fess/dict/userdict/UserDictLocatorTest.java +++ b/src/test/java/org/codelibs/fess/dict/userdict/UserDictLocatorTest.java @@ -55,20 +55,15 @@ public class UserDictLocatorTest extends S2TestCase { testCoreDir = new File(testDir, "core"); testCoreDir.mkdirs(); userDictFile1 = new File(testDir, "userdict.txt"); - FileUtil.write(userDictFile1.getAbsolutePath(), - "abc=>123\nxyz,890".getBytes(Constants.UTF_8)); + FileUtil.write(userDictFile1.getAbsolutePath(), "abc=>123\nxyz,890".getBytes(Constants.UTF_8)); userDictFile2 = new File(testDataDir, "userdict_data.txt"); - FileUtil.write(userDictFile2.getAbsolutePath(), - "abc=>123\nxyz,890".getBytes(Constants.UTF_8)); + FileUtil.write(userDictFile2.getAbsolutePath(), "abc=>123\nxyz,890".getBytes(Constants.UTF_8)); userDictFile3 = new File(testCoreDir, "userdict_core.txt"); - FileUtil.write(userDictFile3.getAbsolutePath(), - "abc=>123\nxyz,890".getBytes(Constants.UTF_8)); + FileUtil.write(userDictFile3.getAbsolutePath(), "abc=>123\nxyz,890".getBytes(Constants.UTF_8)); dummyFile1 = new File(testDir, "dummy.txt"); - FileUtil.write(dummyFile1.getAbsolutePath(), - "dummy 1".getBytes(Constants.UTF_8)); + FileUtil.write(dummyFile1.getAbsolutePath(), "dummy 1".getBytes(Constants.UTF_8)); dummyFile2 = new File(testCoreDir, "dummy.txt"); - FileUtil.write(dummyFile2.getAbsolutePath(), - "dummy 2".getBytes(Constants.UTF_8)); + FileUtil.write(dummyFile2.getAbsolutePath(), "dummy 2".getBytes(Constants.UTF_8)); } @@ -82,8 +77,7 @@ public class UserDictLocatorTest extends S2TestCase { userDictLocator.excludedUserDictList = new ArrayList(); userDictLocator.excludedUserDictList.add("data"); userDictLocator.addSearchPath(testDir.getAbsolutePath()); - final List> list = userDictLocator - .find(); + final List> list = userDictLocator.find(); assertEquals(2, list.size()); final DictionaryFile dicFile1 = list.get(0); final DictionaryFile dicFile2 = list.get(1); diff --git a/src/test/java/org/codelibs/fess/ds/impl/DatabaseDataStoreImplTest.java b/src/test/java/org/codelibs/fess/ds/impl/DatabaseDataStoreImplTest.java index 387aba7e6..7c421ae95 100644 --- a/src/test/java/org/codelibs/fess/ds/impl/DatabaseDataStoreImplTest.java +++ b/src/test/java/org/codelibs/fess/ds/impl/DatabaseDataStoreImplTest.java @@ -46,8 +46,7 @@ public class DatabaseDataStoreImplTest extends S2TestCase { assertEquals("PARAM2+", databaseDataStore.convertValue(value, paramMap)); value = "\"123\"+param2+\",\"+param3+\"abc\""; - assertEquals("123PARAM2+,PARAM3*abc", - databaseDataStore.convertValue(value, paramMap)); + assertEquals("123PARAM2+,PARAM3*abc", databaseDataStore.convertValue(value, paramMap)); value = null; assertEquals("", databaseDataStore.convertValue(value, paramMap)); diff --git a/src/test/java/org/codelibs/fess/entity/GeoInfoTest.java b/src/test/java/org/codelibs/fess/entity/GeoInfoTest.java index 1ee798f55..30e61c18a 100644 --- a/src/test/java/org/codelibs/fess/entity/GeoInfoTest.java +++ b/src/test/java/org/codelibs/fess/entity/GeoInfoTest.java @@ -26,11 +26,8 @@ public class GeoInfoTest extends S2TestCase { final GeoInfo geoInfo = create(latitude, lonitude, distance); assertTrue(geoInfo.isAvailable()); - assertEquals( - "{!geofilt pt=" + Double.toString(Double.parseDouble(latitude)) - + "," + Double.toString(Double.parseDouble(lonitude)) - + " sfield=location d=" + distance + ".0}", - geoInfo.toGeoQueryString()); + assertEquals("{!geofilt pt=" + Double.toString(Double.parseDouble(latitude)) + "," + Double.toString(Double.parseDouble(lonitude)) + + " sfield=location d=" + distance + ".0}", geoInfo.toGeoQueryString()); } public void test_90_180_10() { @@ -40,11 +37,8 @@ public class GeoInfoTest extends S2TestCase { final GeoInfo geoInfo = create(latitude, lonitude, distance); assertTrue(geoInfo.isAvailable()); - assertEquals( - "{!geofilt pt=" + Double.toString(Double.parseDouble(latitude)) - + "," + Double.toString(Double.parseDouble(lonitude)) - + " sfield=location d=" + distance + ".0}", - geoInfo.toGeoQueryString()); + assertEquals("{!geofilt pt=" + Double.toString(Double.parseDouble(latitude)) + "," + Double.toString(Double.parseDouble(lonitude)) + + " sfield=location d=" + distance + ".0}", geoInfo.toGeoQueryString()); } public void test_91_181_10() { @@ -54,8 +48,7 @@ public class GeoInfoTest extends S2TestCase { final GeoInfo geoInfo = create(latitude, lonitude, distance); assertTrue(geoInfo.isAvailable()); - assertEquals("{!geofilt pt=90.0,-179.0 sfield=location d=10.0}", - geoInfo.toGeoQueryString()); + assertEquals("{!geofilt pt=90.0,-179.0 sfield=location d=10.0}", geoInfo.toGeoQueryString()); } public void test_91_361_10() { @@ -65,8 +58,7 @@ public class GeoInfoTest extends S2TestCase { final GeoInfo geoInfo = create(latitude, lonitude, distance); assertTrue(geoInfo.isAvailable()); - assertEquals("{!geofilt pt=90.0,1.0 sfield=location d=100.0}", - geoInfo.toGeoQueryString()); + assertEquals("{!geofilt pt=90.0,1.0 sfield=location d=100.0}", geoInfo.toGeoQueryString()); } public void test__90__180_10() { @@ -76,11 +68,8 @@ public class GeoInfoTest extends S2TestCase { final GeoInfo geoInfo = create(latitude, lonitude, distance); assertTrue(geoInfo.isAvailable()); - assertEquals( - "{!geofilt pt=" + Double.toString(Double.parseDouble(latitude)) - + "," + Double.toString(Double.parseDouble(lonitude)) - + " sfield=location d=" + distance + ".0}", - geoInfo.toGeoQueryString()); + assertEquals("{!geofilt pt=" + Double.toString(Double.parseDouble(latitude)) + "," + Double.toString(Double.parseDouble(lonitude)) + + " sfield=location d=" + distance + ".0}", geoInfo.toGeoQueryString()); } public void test__91__181_10() { @@ -90,8 +79,7 @@ public class GeoInfoTest extends S2TestCase { final GeoInfo geoInfo = create(latitude, lonitude, distance); assertTrue(geoInfo.isAvailable()); - assertEquals("{!geofilt pt=-90.0,179.0 sfield=location d=10.0}", - geoInfo.toGeoQueryString()); + assertEquals("{!geofilt pt=-90.0,179.0 sfield=location d=10.0}", geoInfo.toGeoQueryString()); } public void test__91__361_10() { @@ -101,8 +89,7 @@ public class GeoInfoTest extends S2TestCase { final GeoInfo geoInfo = create(latitude, lonitude, distance); assertTrue(geoInfo.isAvailable()); - assertEquals("{!geofilt pt=-90.0,-1.0 sfield=location d=100.0}", - geoInfo.toGeoQueryString()); + assertEquals("{!geofilt pt=-90.0,-1.0 sfield=location d=100.0}", geoInfo.toGeoQueryString()); } public void test_0_0_0() { @@ -132,8 +119,7 @@ public class GeoInfoTest extends S2TestCase { assertFalse(geoInfo.isAvailable()); } - private GeoInfo create(final String latitude, final String longitude, - final String distance) { + private GeoInfo create(final String latitude, final String longitude, final String distance) { final GeoInfo geoInfo = new GeoInfo(); geoInfo.latitude = latitude; geoInfo.longitude = longitude; diff --git a/src/test/java/org/codelibs/fess/filter/FessEncodingFilterTest.java b/src/test/java/org/codelibs/fess/filter/FessEncodingFilterTest.java index 55f1ffa27..0d96dbc58 100644 --- a/src/test/java/org/codelibs/fess/filter/FessEncodingFilterTest.java +++ b/src/test/java/org/codelibs/fess/filter/FessEncodingFilterTest.java @@ -76,8 +76,7 @@ public class FessEncodingFilterTest extends S2TestCase { final FessEncodingFilter filter = new FessEncodingFilter(); Map paramMap; - paramMap = filter.parseQueryString("a=%E3%83%86%E3%82%B9%E3%83%88", - "UTF-8"); + paramMap = filter.parseQueryString("a=%E3%83%86%E3%82%B9%E3%83%88", "UTF-8"); assertEquals(1, paramMap.size()); assertEquals("テスト", paramMap.get("a")[0]); diff --git a/src/test/java/org/codelibs/fess/helper/CrawlingSessionHelperTest.java b/src/test/java/org/codelibs/fess/helper/CrawlingSessionHelperTest.java index 4948522a6..6d95117d2 100644 --- a/src/test/java/org/codelibs/fess/helper/CrawlingSessionHelperTest.java +++ b/src/test/java/org/codelibs/fess/helper/CrawlingSessionHelperTest.java @@ -36,16 +36,14 @@ public class CrawlingSessionHelperTest extends S2TestCase { final Map dataMap = new HashMap(); dataMap.put("url", "http://hoge.com/"); - assertEquals("http://hoge.com/", - crawlingSessionHelper.generateId(dataMap)); + assertEquals("http://hoge.com/", crawlingSessionHelper.generateId(dataMap)); final List browserTypeList = new ArrayList(); dataMap.put("type", browserTypeList); final List roleTypeList = new ArrayList(); dataMap.put("role", roleTypeList); - assertEquals("http://hoge.com/", - crawlingSessionHelper.generateId(dataMap)); + assertEquals("http://hoge.com/", crawlingSessionHelper.generateId(dataMap)); } public void test_generateId_roleType() { @@ -55,19 +53,16 @@ public class CrawlingSessionHelperTest extends S2TestCase { roleTypeList.add("admin"); dataMap.put("role", roleTypeList); - assertEquals("http://hoge.com/;role=admin", - crawlingSessionHelper.generateId(dataMap)); + assertEquals("http://hoge.com/;role=admin", crawlingSessionHelper.generateId(dataMap)); roleTypeList.add("guest"); - assertEquals("http://hoge.com/;role=admin,guest", - crawlingSessionHelper.generateId(dataMap)); + assertEquals("http://hoge.com/;role=admin,guest", crawlingSessionHelper.generateId(dataMap)); final List browserTypeList = new ArrayList(); dataMap.put("type", browserTypeList); - assertEquals("http://hoge.com/;role=admin,guest", - crawlingSessionHelper.generateId(dataMap)); + assertEquals("http://hoge.com/;role=admin,guest", crawlingSessionHelper.generateId(dataMap)); } } diff --git a/src/test/java/org/codelibs/fess/helper/IntervalControlHelperTest.java b/src/test/java/org/codelibs/fess/helper/IntervalControlHelperTest.java index fb3ccf39f..4445a10ba 100644 --- a/src/test/java/org/codelibs/fess/helper/IntervalControlHelperTest.java +++ b/src/test/java/org/codelibs/fess/helper/IntervalControlHelperTest.java @@ -36,8 +36,7 @@ public class IntervalControlHelperTest extends S2TestCase { } public void test_0000() throws ParseException { - final IntervalControlHelper intervalControlHelper = createHelper( - "00:00", 1); + final IntervalControlHelper intervalControlHelper = createHelper("00:00", 1); intervalControlHelper.addIntervalRule("01:30", "15:15", "*", 1000); assertEquals(0, intervalControlHelper.getDelay()); @@ -54,8 +53,7 @@ public class IntervalControlHelperTest extends S2TestCase { } public void test_1215() throws ParseException { - final IntervalControlHelper intervalControlHelper = createHelper( - "12:15", 1); + final IntervalControlHelper intervalControlHelper = createHelper("12:15", 1); intervalControlHelper.addIntervalRule("01:30", "12:05", "*", 1000); assertEquals(0, intervalControlHelper.getDelay()); @@ -81,8 +79,7 @@ public class IntervalControlHelperTest extends S2TestCase { } public void test_2250() throws ParseException { - final IntervalControlHelper intervalControlHelper = createHelper( - "22:50", 1); + final IntervalControlHelper intervalControlHelper = createHelper("22:50", 1); intervalControlHelper.addIntervalRule("01:30", "15:15", "*", 1000); assertEquals(0, intervalControlHelper.getDelay()); @@ -98,8 +95,7 @@ public class IntervalControlHelperTest extends S2TestCase { assertEquals(4000, intervalControlHelper.getDelay()); } - private IntervalControlHelper createHelper(final String time, final int day) - throws ParseException { + private IntervalControlHelper createHelper(final String time, final int day) throws ParseException { final Date date = new SimpleDateFormat("HH:mm").parse(time); return new IntervalControlHelper() { @Override diff --git a/src/test/java/org/codelibs/fess/helper/PathMappingHelperTest.java b/src/test/java/org/codelibs/fess/helper/PathMappingHelperTest.java index 77539e28b..cbd6b7bad 100644 --- a/src/test/java/org/codelibs/fess/helper/PathMappingHelperTest.java +++ b/src/test/java/org/codelibs/fess/helper/PathMappingHelperTest.java @@ -57,8 +57,7 @@ public class PathMappingHelperTest extends S2TestCase { pathMappingHelper.setPathMappingList(sessionId, pathMappingList); final String url = "file:///home/taro/"; - assertEquals("http://localhost/taro/", - pathMappingHelper.replaceUrl(sessionId, url)); + assertEquals("http://localhost/taro/", pathMappingHelper.replaceUrl(sessionId, url)); } public void test_replaceUrls() { @@ -71,20 +70,16 @@ public class PathMappingHelperTest extends S2TestCase { pathMappingHelper.cachedPathMappingList = pathMappingList; String text = "\"file:///home/\""; - assertEquals("\"http://localhost/\"", - pathMappingHelper.replaceUrls(text)); + assertEquals("\"http://localhost/\"", pathMappingHelper.replaceUrls(text)); text = "\"file:///home/taro/\""; - assertEquals("\"http://localhost/taro/\"", - pathMappingHelper.replaceUrls(text)); + assertEquals("\"http://localhost/taro/\"", pathMappingHelper.replaceUrls(text)); text = "\"aaafile:///home/taro/\""; - assertEquals("\"aaahttp://localhost/taro/\"", - pathMappingHelper.replaceUrls(text)); + assertEquals("\"aaahttp://localhost/taro/\"", pathMappingHelper.replaceUrls(text)); text = "aaa\"file:///home/taro/\"bbb"; - assertEquals("aaa\"http://localhost/taro/\"bbb", - pathMappingHelper.replaceUrls(text)); + assertEquals("aaa\"http://localhost/taro/\"bbb", pathMappingHelper.replaceUrls(text)); } } diff --git a/src/test/java/org/codelibs/fess/helper/QueryHelperTest.java b/src/test/java/org/codelibs/fess/helper/QueryHelperTest.java index 334338410..0340f394b 100644 --- a/src/test/java/org/codelibs/fess/helper/QueryHelperTest.java +++ b/src/test/java/org/codelibs/fess/helper/QueryHelperTest.java @@ -44,32 +44,22 @@ public class QueryHelperTest extends S2TestCase { getRequest().setAttribute(Constants.DEFAULT_OPERATOR, op); assertEquals("", queryHelper.buildQuery("").getQuery()); - assertEquals("title:QUERY OR content:QUERY", queryHelper - .buildQuery("QUERY").getQuery()); - assertEquals("title:QUERY OR content:QUERY", queryHelper - .buildQuery("QUERY ").getQuery()); - assertEquals("title:QUERY OR content:QUERY", queryHelper - .buildQuery(" QUERY").getQuery()); + assertEquals("title:QUERY OR content:QUERY", queryHelper.buildQuery("QUERY").getQuery()); + assertEquals("title:QUERY OR content:QUERY", queryHelper.buildQuery("QUERY ").getQuery()); + assertEquals("title:QUERY OR content:QUERY", queryHelper.buildQuery(" QUERY").getQuery()); - assertEquals("(title:QUERY1 OR content:QUERY1) " + op - + " (title:QUERY2 OR content:QUERY2)", queryHelper - .buildQuery("QUERY1 QUERY2").getQuery()); - assertEquals("(title:QUERY1 OR content:QUERY1) " + op - + " (title:QUERY2 OR content:QUERY2)", queryHelper - .buildQuery("QUERY1 QUERY2 ").getQuery()); - assertEquals("(title:QUERY1 OR content:QUERY1) " + op - + " (title:QUERY2 OR content:QUERY2)", queryHelper - .buildQuery(" QUERY1 QUERY2").getQuery()); + assertEquals("(title:QUERY1 OR content:QUERY1) " + op + " (title:QUERY2 OR content:QUERY2)", + queryHelper.buildQuery("QUERY1 QUERY2").getQuery()); + assertEquals("(title:QUERY1 OR content:QUERY1) " + op + " (title:QUERY2 OR content:QUERY2)", + queryHelper.buildQuery("QUERY1 QUERY2 ").getQuery()); + assertEquals("(title:QUERY1 OR content:QUERY1) " + op + " (title:QUERY2 OR content:QUERY2)", + queryHelper.buildQuery(" QUERY1 QUERY2").getQuery()); - assertEquals("title:QUERY1\\ QUERY2 OR content:QUERY1\\ QUERY2", - queryHelper.buildQuery("\"QUERY1 QUERY2\"").getQuery()); - assertEquals("title:QUERY1\\ QUERY2 OR content:QUERY1\\ QUERY2", - queryHelper.buildQuery("\"QUERY1 QUERY2\" ").getQuery()); - assertEquals("title:QUERY1\\ QUERY2 OR content:QUERY1\\ QUERY2", - queryHelper.buildQuery(" \"QUERY1 QUERY2\"").getQuery()); + assertEquals("title:QUERY1\\ QUERY2 OR content:QUERY1\\ QUERY2", queryHelper.buildQuery("\"QUERY1 QUERY2\"").getQuery()); + assertEquals("title:QUERY1\\ QUERY2 OR content:QUERY1\\ QUERY2", queryHelper.buildQuery("\"QUERY1 QUERY2\" ").getQuery()); + assertEquals("title:QUERY1\\ QUERY2 OR content:QUERY1\\ QUERY2", queryHelper.buildQuery(" \"QUERY1 QUERY2\"").getQuery()); - assertEquals("(title:QUERY1\\ QUERY2 OR content:QUERY1\\ QUERY2) " - + op + " (title:QUERY3 OR content:QUERY3)", queryHelper + assertEquals("(title:QUERY1\\ QUERY2 OR content:QUERY1\\ QUERY2) " + op + " (title:QUERY3 OR content:QUERY3)", queryHelper .buildQuery("\"QUERY1 QUERY2\" QUERY3").getQuery()); } } @@ -78,74 +68,49 @@ public class QueryHelperTest extends S2TestCase { for (final String op : new String[] { "AND", "OR" }) { getRequest().setAttribute(Constants.DEFAULT_OPERATOR, op); - assertEquals("(title:QUERY1 OR content:QUERY1) " + op - + " (title:QUERY2 OR content:QUERY2)", queryHelper - .buildQuery("QUERY1\u3000QUERY2").getQuery()); - assertEquals("(title:QUERY1 OR content:QUERY1) " + op - + " (title:QUERY2 OR content:QUERY2)", queryHelper - .buildQuery("QUERY1\u3000QUERY2\u3000").getQuery()); - assertEquals("(title:QUERY1 OR content:QUERY1) " + op - + " (title:QUERY2 OR content:QUERY2)", queryHelper - .buildQuery("\u3000QUERY1\u3000QUERY2").getQuery()); + assertEquals("(title:QUERY1 OR content:QUERY1) " + op + " (title:QUERY2 OR content:QUERY2)", + queryHelper.buildQuery("QUERY1\u3000QUERY2").getQuery()); + assertEquals("(title:QUERY1 OR content:QUERY1) " + op + " (title:QUERY2 OR content:QUERY2)", + queryHelper.buildQuery("QUERY1\u3000QUERY2\u3000").getQuery()); + assertEquals("(title:QUERY1 OR content:QUERY1) " + op + " (title:QUERY2 OR content:QUERY2)", + queryHelper.buildQuery("\u3000QUERY1\u3000QUERY2").getQuery()); - assertEquals( - "title:QUERY1\\\u3000QUERY2 OR content:QUERY1\\\u3000QUERY2", - queryHelper.buildQuery("\"QUERY1\u3000QUERY2\"").getQuery()); + assertEquals("title:QUERY1\\\u3000QUERY2 OR content:QUERY1\\\u3000QUERY2", queryHelper.buildQuery("\"QUERY1\u3000QUERY2\"") + .getQuery()); - assertEquals( - "(title:QUERY1\\\u3000QUERY2 OR content:QUERY1\\\u3000QUERY2) " - + op + " (title:QUERY3 OR content:QUERY3)", - queryHelper - .buildQuery("\"QUERY1\u3000QUERY2\"\u3000QUERY3") - .getQuery()); + assertEquals("(title:QUERY1\\\u3000QUERY2 OR content:QUERY1\\\u3000QUERY2) " + op + " (title:QUERY3 OR content:QUERY3)", + queryHelper.buildQuery("\"QUERY1\u3000QUERY2\"\u3000QUERY3").getQuery()); } } public void test_build_prefix() { for (final String op : new String[] { "AND", "OR" }) { getRequest().setAttribute(Constants.DEFAULT_OPERATOR, op); - assertEquals("mimetype:QUERY1", - queryHelper.buildQuery("mimetype:QUERY1").getQuery()); - assertEquals("mimetype:QUERY1 " + op - + " (title:QUERY2 OR content:QUERY2)", queryHelper - .buildQuery("mimetype:QUERY1 QUERY2").getQuery()); - assertEquals("mimetype:QUERY1 " + op - + " (title:QUERY2 OR content:QUERY2) " + op - + " (title:QUERY3 OR content:QUERY3)", queryHelper - .buildQuery("mimetype:QUERY1 QUERY2 QUERY3").getQuery()); - assertEquals("mimetype:QUERY1 " + op + " host:QUERY2 " + op - + " (title:QUERY3 OR content:QUERY3)", queryHelper - .buildQuery("mimetype:QUERY1 host:QUERY2 QUERY3") + assertEquals("mimetype:QUERY1", queryHelper.buildQuery("mimetype:QUERY1").getQuery()); + assertEquals("mimetype:QUERY1 " + op + " (title:QUERY2 OR content:QUERY2)", queryHelper.buildQuery("mimetype:QUERY1 QUERY2") .getQuery()); - assertEquals("mimetype:QUERY1\\ QUERY2 " + op - + " (title:QUERY3 OR content:QUERY3)", queryHelper - .buildQuery("mimetype:\"QUERY1 QUERY2\" QUERY3").getQuery()); + assertEquals("mimetype:QUERY1 " + op + " (title:QUERY2 OR content:QUERY2) " + op + " (title:QUERY3 OR content:QUERY3)", + queryHelper.buildQuery("mimetype:QUERY1 QUERY2 QUERY3").getQuery()); + assertEquals("mimetype:QUERY1 " + op + " host:QUERY2 " + op + " (title:QUERY3 OR content:QUERY3)", + queryHelper.buildQuery("mimetype:QUERY1 host:QUERY2 QUERY3").getQuery()); + assertEquals("mimetype:QUERY1\\ QUERY2 " + op + " (title:QUERY3 OR content:QUERY3)", + queryHelper.buildQuery("mimetype:\"QUERY1 QUERY2\" QUERY3").getQuery()); } } public void test_build_prefix_unknown() { for (final String op : new String[] { "AND", "OR" }) { getRequest().setAttribute(Constants.DEFAULT_OPERATOR, op); - assertEquals("title:site\\: OR content:site\\:", queryHelper - .buildQuery("site:").getQuery()); - assertEquals("title:hoge\\:QUERY1 OR content:hoge\\:QUERY1", - queryHelper.buildQuery("hoge:QUERY1").getQuery()); - assertEquals("(title:hoge\\:QUERY1 OR content:hoge\\:QUERY1) " + op - + " (title:QUERY2 OR content:QUERY2)", queryHelper + assertEquals("title:site\\: OR content:site\\:", queryHelper.buildQuery("site:").getQuery()); + assertEquals("title:hoge\\:QUERY1 OR content:hoge\\:QUERY1", queryHelper.buildQuery("hoge:QUERY1").getQuery()); + assertEquals("(title:hoge\\:QUERY1 OR content:hoge\\:QUERY1) " + op + " (title:QUERY2 OR content:QUERY2)", queryHelper .buildQuery("hoge:QUERY1 QUERY2").getQuery()); - assertEquals("(title:hoge\\:QUERY1 OR content:hoge\\:QUERY1) " + op - + " (title:QUERY2 OR content:QUERY2) " + op - + " (title:QUERY3 OR content:QUERY3)", queryHelper - .buildQuery("hoge:QUERY1 QUERY2 QUERY3").getQuery()); - assertEquals("(title:hoge\\:QUERY1 OR content:hoge\\:QUERY1) " + op - + " host:QUERY2 " + op - + " (title:QUERY3 OR content:QUERY3)", queryHelper - .buildQuery("hoge:QUERY1 host:QUERY2 QUERY3").getQuery()); - assertEquals( - "(title:hoge\\:QUERY1\\ QUERY2 OR content:hoge\\:QUERY1\\ QUERY2) " - + op + " (title:QUERY3 OR content:QUERY3)", - queryHelper.buildQuery("hoge:\"QUERY1 QUERY2\" QUERY3") - .getQuery()); + assertEquals("(title:hoge\\:QUERY1 OR content:hoge\\:QUERY1) " + op + " (title:QUERY2 OR content:QUERY2) " + op + + " (title:QUERY3 OR content:QUERY3)", queryHelper.buildQuery("hoge:QUERY1 QUERY2 QUERY3").getQuery()); + assertEquals("(title:hoge\\:QUERY1 OR content:hoge\\:QUERY1) " + op + " host:QUERY2 " + op + + " (title:QUERY3 OR content:QUERY3)", queryHelper.buildQuery("hoge:QUERY1 host:QUERY2 QUERY3").getQuery()); + assertEquals("(title:hoge\\:QUERY1\\ QUERY2 OR content:hoge\\:QUERY1\\ QUERY2) " + op + " (title:QUERY3 OR content:QUERY3)", + queryHelper.buildQuery("hoge:\"QUERY1 QUERY2\" QUERY3").getQuery()); } } @@ -163,16 +128,12 @@ public class QueryHelperTest extends S2TestCase { getRequest().setAttribute(Constants.DEFAULT_OPERATOR, op); assertEquals("", queryHelper.build("", true).getQuery()); - assertEquals("title:QUERY OR content:QUERY", - queryHelper.build("QUERY", true).getQuery()); - assertEquals("role:guest", queryHelper.build("QUERY", true) - .getFilterQueries()[0]); + assertEquals("title:QUERY OR content:QUERY", queryHelper.build("QUERY", true).getQuery()); + assertEquals("role:guest", queryHelper.build("QUERY", true).getFilterQueries()[0]); - assertEquals("(title:QUERY1 OR content:QUERY1) " + op - + " (title:QUERY2 OR content:QUERY2)", + assertEquals("(title:QUERY1 OR content:QUERY1) " + op + " (title:QUERY2 OR content:QUERY2)", queryHelper.build("QUERY1 QUERY2", true).getQuery()); - assertEquals("role:guest", queryHelper.build("QUERY1 QUERY2", true) - .getFilterQueries()[0]); + assertEquals("role:guest", queryHelper.build("QUERY1 QUERY2", true).getFilterQueries()[0]); queryHelper.roleQueryHelper = new RoleQueryHelper() { @Override @@ -184,17 +145,12 @@ public class QueryHelperTest extends S2TestCase { } }; - assertEquals("title:QUERY OR content:QUERY", - queryHelper.build("QUERY", true).getQuery()); - assertEquals("role:guest OR role:admin", - queryHelper.build("QUERY", true).getFilterQueries()[0]); + assertEquals("title:QUERY OR content:QUERY", queryHelper.build("QUERY", true).getQuery()); + assertEquals("role:guest OR role:admin", queryHelper.build("QUERY", true).getFilterQueries()[0]); - assertEquals("(title:QUERY1 OR content:QUERY1) " + op - + " (title:QUERY2 OR content:QUERY2)", + assertEquals("(title:QUERY1 OR content:QUERY1) " + op + " (title:QUERY2 OR content:QUERY2)", queryHelper.build("QUERY1 QUERY2", true).getQuery()); - assertEquals( - "role:guest OR role:admin", - queryHelper.build("QUERY1 QUERY2", true).getFilterQueries()[0]); + assertEquals("role:guest OR role:admin", queryHelper.build("QUERY1 QUERY2", true).getFilterQueries()[0]); } } @@ -213,97 +169,70 @@ public class QueryHelperTest extends S2TestCase { searchQuery = queryHelper.buildQuery(query); assertEquals("", searchQuery.getQuery()); assertEquals(1, searchQuery.getSortFields().length); - assertEquals("contentLength", - searchQuery.getSortFields()[0].getField()); - assertEquals(Constants.ASC, - searchQuery.getSortFields()[0].getOrder()); + assertEquals("contentLength", searchQuery.getSortFields()[0].getField()); + assertEquals(Constants.ASC, searchQuery.getSortFields()[0].getOrder()); query = "sort:contentLength.desc"; searchQuery = queryHelper.buildQuery(query); assertEquals("", searchQuery.getQuery()); assertEquals(1, searchQuery.getSortFields().length); - assertEquals("contentLength", - searchQuery.getSortFields()[0].getField()); - assertEquals(Constants.DESC, - searchQuery.getSortFields()[0].getOrder()); + assertEquals("contentLength", searchQuery.getSortFields()[0].getField()); + assertEquals(Constants.DESC, searchQuery.getSortFields()[0].getOrder()); query = "sort:contentLength.asc,lastModified"; searchQuery = queryHelper.buildQuery(query); assertEquals("", searchQuery.getQuery()); assertEquals(2, searchQuery.getSortFields().length); - assertEquals("contentLength", - searchQuery.getSortFields()[0].getField()); - assertEquals(Constants.ASC, - searchQuery.getSortFields()[0].getOrder()); - assertEquals("lastModified", - searchQuery.getSortFields()[1].getField()); - assertEquals(Constants.ASC, - searchQuery.getSortFields()[1].getOrder()); + assertEquals("contentLength", searchQuery.getSortFields()[0].getField()); + assertEquals(Constants.ASC, searchQuery.getSortFields()[0].getOrder()); + assertEquals("lastModified", searchQuery.getSortFields()[1].getField()); + assertEquals(Constants.ASC, searchQuery.getSortFields()[1].getOrder()); query = "QUERY sort:contentLength"; searchQuery = queryHelper.buildQuery(query); assertEquals("title:QUERY OR content:QUERY", searchQuery.getQuery()); assertEquals(1, searchQuery.getSortFields().length); - assertEquals("contentLength", - searchQuery.getSortFields()[0].getField()); - assertEquals(Constants.ASC, - searchQuery.getSortFields()[0].getOrder()); + assertEquals("contentLength", searchQuery.getSortFields()[0].getField()); + assertEquals(Constants.ASC, searchQuery.getSortFields()[0].getOrder()); query = "QUERY sort:contentLength.desc"; searchQuery = queryHelper.buildQuery(query); assertEquals("title:QUERY OR content:QUERY", searchQuery.getQuery()); assertEquals(1, searchQuery.getSortFields().length); - assertEquals("contentLength", - searchQuery.getSortFields()[0].getField()); - assertEquals(Constants.DESC, - searchQuery.getSortFields()[0].getOrder()); + assertEquals("contentLength", searchQuery.getSortFields()[0].getField()); + assertEquals(Constants.DESC, searchQuery.getSortFields()[0].getOrder()); query = "QUERY sort:contentLength.asc,lastModified"; searchQuery = queryHelper.buildQuery(query); assertEquals("title:QUERY OR content:QUERY", searchQuery.getQuery()); assertEquals(2, searchQuery.getSortFields().length); - assertEquals("contentLength", - searchQuery.getSortFields()[0].getField()); - assertEquals(Constants.ASC, - searchQuery.getSortFields()[0].getOrder()); - assertEquals("lastModified", - searchQuery.getSortFields()[1].getField()); - assertEquals(Constants.ASC, - searchQuery.getSortFields()[1].getOrder()); + assertEquals("contentLength", searchQuery.getSortFields()[0].getField()); + assertEquals(Constants.ASC, searchQuery.getSortFields()[0].getOrder()); + assertEquals("lastModified", searchQuery.getSortFields()[1].getField()); + assertEquals(Constants.ASC, searchQuery.getSortFields()[1].getOrder()); query = "QUERY mimetype:QUERY1 sort:contentLength"; searchQuery = queryHelper.buildQuery(query); - assertEquals("(title:QUERY OR content:QUERY) " + op - + " mimetype:QUERY1", searchQuery.getQuery()); + assertEquals("(title:QUERY OR content:QUERY) " + op + " mimetype:QUERY1", searchQuery.getQuery()); assertEquals(1, searchQuery.getSortFields().length); - assertEquals("contentLength", - searchQuery.getSortFields()[0].getField()); - assertEquals(Constants.ASC, - searchQuery.getSortFields()[0].getOrder()); + assertEquals("contentLength", searchQuery.getSortFields()[0].getField()); + assertEquals(Constants.ASC, searchQuery.getSortFields()[0].getOrder()); query = "QUERY sort:contentLength.desc mimetype:QUERY1"; searchQuery = queryHelper.buildQuery(query); - assertEquals("(title:QUERY OR content:QUERY) " + op - + " mimetype:QUERY1", searchQuery.getQuery()); + assertEquals("(title:QUERY OR content:QUERY) " + op + " mimetype:QUERY1", searchQuery.getQuery()); assertEquals(1, searchQuery.getSortFields().length); - assertEquals("contentLength", - searchQuery.getSortFields()[0].getField()); - assertEquals(Constants.DESC, - searchQuery.getSortFields()[0].getOrder()); + assertEquals("contentLength", searchQuery.getSortFields()[0].getField()); + assertEquals(Constants.DESC, searchQuery.getSortFields()[0].getOrder()); query = "QUERY sort:contentLength.asc,lastModified mimetype:QUERY1"; searchQuery = queryHelper.buildQuery(query); - assertEquals("(title:QUERY OR content:QUERY) " + op - + " mimetype:QUERY1", searchQuery.getQuery()); + assertEquals("(title:QUERY OR content:QUERY) " + op + " mimetype:QUERY1", searchQuery.getQuery()); assertEquals(2, searchQuery.getSortFields().length); - assertEquals("contentLength", - searchQuery.getSortFields()[0].getField()); - assertEquals(Constants.ASC, - searchQuery.getSortFields()[0].getOrder()); - assertEquals("lastModified", - searchQuery.getSortFields()[1].getField()); - assertEquals(Constants.ASC, - searchQuery.getSortFields()[1].getOrder()); + assertEquals("contentLength", searchQuery.getSortFields()[0].getField()); + assertEquals(Constants.ASC, searchQuery.getSortFields()[0].getOrder()); + assertEquals("lastModified", searchQuery.getSortFields()[1].getField()); + assertEquals(Constants.ASC, searchQuery.getSortFields()[1].getOrder()); } } @@ -334,55 +263,39 @@ public class QueryHelperTest extends S2TestCase { getRequest().setAttribute(Constants.DEFAULT_OPERATOR, op); // * - assertEquals("title:\\* OR content:\\*", queryHelper - .buildQuery("*").getQuery()); - assertEquals("title:QUERY* OR content:QUERY*", queryHelper - .buildQuery("QUERY* ").getQuery()); - assertEquals("title:Q*ERY OR content:Q*ERY", queryHelper - .buildQuery(" Q*ERY").getQuery()); + assertEquals("title:\\* OR content:\\*", queryHelper.buildQuery("*").getQuery()); + assertEquals("title:QUERY* OR content:QUERY*", queryHelper.buildQuery("QUERY* ").getQuery()); + assertEquals("title:Q*ERY OR content:Q*ERY", queryHelper.buildQuery(" Q*ERY").getQuery()); - assertEquals("(title:Q*ERY1 OR content:Q*ERY1) " + op - + " (title:Q*ERY2 OR content:Q*ERY2)", queryHelper - .buildQuery("Q*ERY1 Q*ERY2").getQuery()); + assertEquals("(title:Q*ERY1 OR content:Q*ERY1) " + op + " (title:Q*ERY2 OR content:Q*ERY2)", + queryHelper.buildQuery("Q*ERY1 Q*ERY2").getQuery()); - assertEquals("title:Q*ERY1\\ Q*ERY2 OR content:Q*ERY1\\ Q*ERY2", - queryHelper.buildQuery("\"Q*ERY1 Q*ERY2\"").getQuery()); + assertEquals("title:Q*ERY1\\ Q*ERY2 OR content:Q*ERY1\\ Q*ERY2", queryHelper.buildQuery("\"Q*ERY1 Q*ERY2\"").getQuery()); - assertEquals("(title:Q*ERY1\\ Q*ERY2 OR content:Q*ERY1\\ Q*ERY2) " - + op + " (title:Q*ERY3 OR content:Q*ERY3)", queryHelper + assertEquals("(title:Q*ERY1\\ Q*ERY2 OR content:Q*ERY1\\ Q*ERY2) " + op + " (title:Q*ERY3 OR content:Q*ERY3)", queryHelper .buildQuery("\"Q*ERY1 Q*ERY2\" Q*ERY3").getQuery()); - assertEquals("mimetype:QUERY1*", - queryHelper.buildQuery("mimetype:QUERY1*").getQuery()); - assertEquals("mimetype:QUERY1* " + op - + " (title:QUERY2 OR content:QUERY2)", queryHelper - .buildQuery("mimetype:QUERY1* QUERY2").getQuery()); + assertEquals("mimetype:QUERY1*", queryHelper.buildQuery("mimetype:QUERY1*").getQuery()); + assertEquals("mimetype:QUERY1* " + op + " (title:QUERY2 OR content:QUERY2)", queryHelper.buildQuery("mimetype:QUERY1* QUERY2") + .getQuery()); // ? - assertEquals("title:\\? OR content:\\?", queryHelper - .buildQuery("?").getQuery()); - assertEquals("title:QUERY? OR content:QUERY?", queryHelper - .buildQuery("QUERY? ").getQuery()); - assertEquals("title:Q?ERY OR content:Q?ERY", queryHelper - .buildQuery(" Q?ERY").getQuery()); + assertEquals("title:\\? OR content:\\?", queryHelper.buildQuery("?").getQuery()); + assertEquals("title:QUERY? OR content:QUERY?", queryHelper.buildQuery("QUERY? ").getQuery()); + assertEquals("title:Q?ERY OR content:Q?ERY", queryHelper.buildQuery(" Q?ERY").getQuery()); - assertEquals("(title:Q?ERY1 OR content:Q?ERY1) " + op - + " (title:Q?ERY2 OR content:Q?ERY2)", queryHelper - .buildQuery("Q?ERY1 Q?ERY2").getQuery()); + assertEquals("(title:Q?ERY1 OR content:Q?ERY1) " + op + " (title:Q?ERY2 OR content:Q?ERY2)", + queryHelper.buildQuery("Q?ERY1 Q?ERY2").getQuery()); - assertEquals("title:Q?ERY1\\ Q?ERY2 OR content:Q?ERY1\\ Q?ERY2", - queryHelper.buildQuery("\"Q?ERY1 Q?ERY2\"").getQuery()); + assertEquals("title:Q?ERY1\\ Q?ERY2 OR content:Q?ERY1\\ Q?ERY2", queryHelper.buildQuery("\"Q?ERY1 Q?ERY2\"").getQuery()); - assertEquals("(title:Q?ERY1\\ Q?ERY2 OR content:Q?ERY1\\ Q?ERY2) " - + op + " (title:Q?ERY3 OR content:Q?ERY3)", queryHelper + assertEquals("(title:Q?ERY1\\ Q?ERY2 OR content:Q?ERY1\\ Q?ERY2) " + op + " (title:Q?ERY3 OR content:Q?ERY3)", queryHelper .buildQuery("\"Q?ERY1 Q?ERY2\" Q?ERY3").getQuery()); - assertEquals("mimetype:QUERY1?", - queryHelper.buildQuery("mimetype:QUERY1?").getQuery()); - assertEquals("mimetype:QUERY1? " + op - + " (title:QUERY2 OR content:QUERY2)", queryHelper - .buildQuery("mimetype:QUERY1? QUERY2").getQuery()); + assertEquals("mimetype:QUERY1?", queryHelper.buildQuery("mimetype:QUERY1?").getQuery()); + assertEquals("mimetype:QUERY1? " + op + " (title:QUERY2 OR content:QUERY2)", queryHelper.buildQuery("mimetype:QUERY1? QUERY2") + .getQuery()); } } @@ -391,53 +304,37 @@ public class QueryHelperTest extends S2TestCase { getRequest().setAttribute(Constants.DEFAULT_OPERATOR, op); // ~ - assertEquals("title:QUERY~ OR content:QUERY~", queryHelper - .buildQuery("QUERY~").getQuery()); - assertEquals("(title:QUERY1~ OR content:QUERY1~) " + op - + " (title:QUERY2 OR content:QUERY2)", queryHelper - .buildQuery("QUERY1~ QUERY2").getQuery()); - assertEquals("(title:QUERY1~ OR content:QUERY1~) " + op - + " (title:QUERY2~ OR content:QUERY2~)", queryHelper - .buildQuery("QUERY1~ QUERY2~").getQuery()); + assertEquals("title:QUERY~ OR content:QUERY~", queryHelper.buildQuery("QUERY~").getQuery()); + assertEquals("(title:QUERY1~ OR content:QUERY1~) " + op + " (title:QUERY2 OR content:QUERY2)", + queryHelper.buildQuery("QUERY1~ QUERY2").getQuery()); + assertEquals("(title:QUERY1~ OR content:QUERY1~) " + op + " (title:QUERY2~ OR content:QUERY2~)", + queryHelper.buildQuery("QUERY1~ QUERY2~").getQuery()); - assertEquals("mimetype:QUERY1~", - queryHelper.buildQuery("mimetype:QUERY1~").getQuery()); - assertEquals("mimetype:QUERY1~ " + op - + " (title:QUERY2 OR content:QUERY2)", queryHelper - .buildQuery("mimetype:QUERY1~ QUERY2").getQuery()); + assertEquals("mimetype:QUERY1~", queryHelper.buildQuery("mimetype:QUERY1~").getQuery()); + assertEquals("mimetype:QUERY1~ " + op + " (title:QUERY2 OR content:QUERY2)", queryHelper.buildQuery("mimetype:QUERY1~ QUERY2") + .getQuery()); - assertEquals("title:QUERY1\\ QUERY2~ OR content:QUERY1\\ QUERY2~", - queryHelper.buildQuery("\"QUERY1 QUERY2\"~").getQuery()); - assertEquals("title:QUERY1~ OR content:QUERY1~", queryHelper - .buildQuery("\"QUERY1~\"").getQuery()); + assertEquals("title:QUERY1\\ QUERY2~ OR content:QUERY1\\ QUERY2~", queryHelper.buildQuery("\"QUERY1 QUERY2\"~").getQuery()); + assertEquals("title:QUERY1~ OR content:QUERY1~", queryHelper.buildQuery("\"QUERY1~\"").getQuery()); // ~0.8 - assertEquals("title:QUERY~0.8 OR content:QUERY~0.8", queryHelper - .buildQuery("QUERY~0.8").getQuery()); - assertEquals("(title:QUERY1~0.8 OR content:QUERY1~0.8) " + op - + " (title:QUERY2 OR content:QUERY2)", queryHelper - .buildQuery("QUERY1~0.8 QUERY2").getQuery()); - assertEquals("(title:QUERY1~0.5 OR content:QUERY1~0.5) " + op - + " (title:QUERY2~0.8 OR content:QUERY2~0.8)", queryHelper + assertEquals("title:QUERY~0.8 OR content:QUERY~0.8", queryHelper.buildQuery("QUERY~0.8").getQuery()); + assertEquals("(title:QUERY1~0.8 OR content:QUERY1~0.8) " + op + " (title:QUERY2 OR content:QUERY2)", + queryHelper.buildQuery("QUERY1~0.8 QUERY2").getQuery()); + assertEquals("(title:QUERY1~0.5 OR content:QUERY1~0.5) " + op + " (title:QUERY2~0.8 OR content:QUERY2~0.8)", queryHelper .buildQuery("QUERY1~0.5 QUERY2~0.8").getQuery()); - assertEquals("mimetype:QUERY1~0.8", - queryHelper.buildQuery("mimetype:QUERY1~0.8").getQuery()); - assertEquals("mimetype:QUERY1~0.8 " + op - + " (title:QUERY2 OR content:QUERY2)", queryHelper - .buildQuery("mimetype:QUERY1~0.8 QUERY2").getQuery()); + assertEquals("mimetype:QUERY1~0.8", queryHelper.buildQuery("mimetype:QUERY1~0.8").getQuery()); + assertEquals("mimetype:QUERY1~0.8 " + op + " (title:QUERY2 OR content:QUERY2)", + queryHelper.buildQuery("mimetype:QUERY1~0.8 QUERY2").getQuery()); - assertEquals( - "title:QUERY1\\ QUERY2~0.8 OR content:QUERY1\\ QUERY2~0.8", - queryHelper.buildQuery("\"QUERY1 QUERY2\"~0.8").getQuery()); - assertEquals("title:QUERY1~0.8 OR content:QUERY1~0.8", queryHelper - .buildQuery("\"QUERY1~0.8\"").getQuery()); + assertEquals("title:QUERY1\\ QUERY2~0.8 OR content:QUERY1\\ QUERY2~0.8", queryHelper.buildQuery("\"QUERY1 QUERY2\"~0.8") + .getQuery()); + assertEquals("title:QUERY1~0.8 OR content:QUERY1~0.8", queryHelper.buildQuery("\"QUERY1~0.8\"").getQuery()); - assertEquals("title:QUERY1~0.8 OR content:QUERY1~0.8", queryHelper - .buildQuery("\"QUERY1~0.8a\"").getQuery()); - assertEquals("title:QUERY1~ OR content:QUERY1~", queryHelper - .buildQuery("\"QUERY1~a\"").getQuery()); + assertEquals("title:QUERY1~0.8 OR content:QUERY1~0.8", queryHelper.buildQuery("\"QUERY1~0.8a\"").getQuery()); + assertEquals("title:QUERY1~ OR content:QUERY1~", queryHelper.buildQuery("\"QUERY1~a\"").getQuery()); } } @@ -445,33 +342,23 @@ public class QueryHelperTest extends S2TestCase { for (final String op : new String[] { "AND", "OR" }) { getRequest().setAttribute(Constants.DEFAULT_OPERATOR, op); // ~10 - assertEquals("title:\"QUERY\"~10 OR content:\"QUERY\"~10", - queryHelper.buildQuery("QUERY~10").getQuery()); - assertEquals("title:\"QUERY\"~1 OR content:\"QUERY\"~1", - queryHelper.buildQuery("QUERY~1").getQuery()); - assertEquals("title:\"QUERY\"~5 OR content:\"QUERY\"~5", - queryHelper.buildQuery("QUERY~5.5").getQuery()); - assertEquals("(title:\"QUERY1\"~10 OR content:\"QUERY1\"~10) " + op - + " (title:QUERY2 OR content:QUERY2)", queryHelper + assertEquals("title:\"QUERY\"~10 OR content:\"QUERY\"~10", queryHelper.buildQuery("QUERY~10").getQuery()); + assertEquals("title:\"QUERY\"~1 OR content:\"QUERY\"~1", queryHelper.buildQuery("QUERY~1").getQuery()); + assertEquals("title:\"QUERY\"~5 OR content:\"QUERY\"~5", queryHelper.buildQuery("QUERY~5.5").getQuery()); + assertEquals("(title:\"QUERY1\"~10 OR content:\"QUERY1\"~10) " + op + " (title:QUERY2 OR content:QUERY2)", queryHelper .buildQuery("QUERY1~10 QUERY2").getQuery()); - assertEquals("(title:\"QUERY1\"~5 OR content:\"QUERY1\"~5) " + op - + " (title:\"QUERY2\"~10 OR content:\"QUERY2\"~10)", + assertEquals("(title:\"QUERY1\"~5 OR content:\"QUERY1\"~5) " + op + " (title:\"QUERY2\"~10 OR content:\"QUERY2\"~10)", queryHelper.buildQuery("QUERY1~5 QUERY2~10").getQuery()); - assertEquals("mimetype:\"QUERY1\"~10", - queryHelper.buildQuery("mimetype:QUERY1~10").getQuery()); - assertEquals("mimetype:\"QUERY1\"~10 " + op - + " (title:QUERY2 OR content:QUERY2)", queryHelper - .buildQuery("mimetype:QUERY1~10 QUERY2").getQuery()); + assertEquals("mimetype:\"QUERY1\"~10", queryHelper.buildQuery("mimetype:QUERY1~10").getQuery()); + assertEquals("mimetype:\"QUERY1\"~10 " + op + " (title:QUERY2 OR content:QUERY2)", + queryHelper.buildQuery("mimetype:QUERY1~10 QUERY2").getQuery()); - assertEquals( - "title:\"QUERY1\\ QUERY2\"~10 OR content:\"QUERY1\\ QUERY2\"~10", - queryHelper.buildQuery("\"QUERY1 QUERY2\"~10").getQuery()); - assertEquals("title:\"QUERY1\"~10 OR content:\"QUERY1\"~10", - queryHelper.buildQuery("\"QUERY1~10\"").getQuery()); + assertEquals("title:\"QUERY1\\ QUERY2\"~10 OR content:\"QUERY1\\ QUERY2\"~10", queryHelper.buildQuery("\"QUERY1 QUERY2\"~10") + .getQuery()); + assertEquals("title:\"QUERY1\"~10 OR content:\"QUERY1\"~10", queryHelper.buildQuery("\"QUERY1~10\"").getQuery()); - assertEquals("title:\"QUERY1\"~10 OR content:\"QUERY1\"~10", - queryHelper.buildQuery("\"QUERY1~10a\"").getQuery()); + assertEquals("title:\"QUERY1\"~10 OR content:\"QUERY1\"~10", queryHelper.buildQuery("\"QUERY1~10a\"").getQuery()); } } @@ -480,117 +367,77 @@ public class QueryHelperTest extends S2TestCase { for (final String op : new String[] { "AND", "OR" }) { getRequest().setAttribute(Constants.DEFAULT_OPERATOR, op); // mod_date:[20020101 TO 20030101] - assertEquals( - "title:[20020101 TO 20030101] OR content:[20020101 TO 20030101]", - queryHelper.buildQuery("[20020101 TO 20030101]").getQuery()); - assertEquals("lastModified:[20020101 TO 20030101]", queryHelper - .buildQuery("lastModified:[20020101 TO 20030101]") + assertEquals("title:[20020101 TO 20030101] OR content:[20020101 TO 20030101]", queryHelper.buildQuery("[20020101 TO 20030101]") .getQuery()); - assertEquals("(title:QUERY OR content:QUERY) " + op - + " lastModified:[20020101 TO 20030101]", queryHelper - .buildQuery("QUERY lastModified:[20020101 TO 20030101]") - .getQuery()); - assertEquals("title:{Aida TO Carmen} OR content:{Aida TO Carmen}", - queryHelper.buildQuery("{Aida TO Carmen}").getQuery()); - assertEquals("lastModified:{Aida TO Carmen}", queryHelper - .buildQuery("lastModified:{Aida TO Carmen}").getQuery()); - assertEquals("(title:QUERY OR content:QUERY) " + op - + " title:{Aida TO Carmen}", - queryHelper.buildQuery("QUERY title:{Aida TO Carmen}") - .getQuery()); - assertEquals("lastModified:[20020101 TO abc]", queryHelper - .buildQuery("lastModified:[20020101 TO abc]").getQuery()); - assertEquals("lastModified:[abc TO 20020101]", queryHelper - .buildQuery("lastModified:[abc TO 20020101]").getQuery()); - assertEquals("lastModified:[20020101 TO *]", queryHelper - .buildQuery("lastModified:[20020101 TO *]").getQuery()); - assertEquals("lastModified:[* TO 20020101]", queryHelper - .buildQuery("lastModified:[* TO 20020101]").getQuery()); + assertEquals("lastModified:[20020101 TO 20030101]", queryHelper.buildQuery("lastModified:[20020101 TO 20030101]").getQuery()); + assertEquals("(title:QUERY OR content:QUERY) " + op + " lastModified:[20020101 TO 20030101]", + queryHelper.buildQuery("QUERY lastModified:[20020101 TO 20030101]").getQuery()); + assertEquals("title:{Aida TO Carmen} OR content:{Aida TO Carmen}", queryHelper.buildQuery("{Aida TO Carmen}").getQuery()); + assertEquals("lastModified:{Aida TO Carmen}", queryHelper.buildQuery("lastModified:{Aida TO Carmen}").getQuery()); + assertEquals("(title:QUERY OR content:QUERY) " + op + " title:{Aida TO Carmen}", + queryHelper.buildQuery("QUERY title:{Aida TO Carmen}").getQuery()); + assertEquals("lastModified:[20020101 TO abc]", queryHelper.buildQuery("lastModified:[20020101 TO abc]").getQuery()); + assertEquals("lastModified:[abc TO 20020101]", queryHelper.buildQuery("lastModified:[abc TO 20020101]").getQuery()); + assertEquals("lastModified:[20020101 TO *]", queryHelper.buildQuery("lastModified:[20020101 TO *]").getQuery()); + assertEquals("lastModified:[* TO 20020101]", queryHelper.buildQuery("lastModified:[* TO 20020101]").getQuery()); - rangeQuery = "(content:[1 TO 2] OR content:[3 TO 4]) " + op - + " (content:[5 TO 6] OR content:[7 TO 8])"; - assertEquals(rangeQuery, queryHelper.buildQuery(rangeQuery) - .getQuery()); + rangeQuery = "(content:[1 TO 2] OR content:[3 TO 4]) " + op + " (content:[5 TO 6] OR content:[7 TO 8])"; + assertEquals(rangeQuery, queryHelper.buildQuery(rangeQuery).getQuery()); try { queryHelper.buildQuery("lastModified:[20020101 TO]").getQuery(); fail(); - } catch (final InvalidQueryException e) { - } + } catch (final InvalidQueryException e) {} try { queryHelper.buildQuery("lastModified:[TO 20030101]").getQuery(); fail(); - } catch (final InvalidQueryException e) { - } + } catch (final InvalidQueryException e) {} try { queryHelper.buildQuery("lastModified:[20020101]").getQuery(); fail(); - } catch (final InvalidQueryException e) { - } + } catch (final InvalidQueryException e) {} try { queryHelper.buildQuery("lastModified:[20030101]").getQuery(); fail(); - } catch (final InvalidQueryException e) { - } + } catch (final InvalidQueryException e) {} // mod_date:{20020101 TO 20030101} - assertEquals( - "title:{20020101 TO 20030101} OR content:{20020101 TO 20030101}", - queryHelper.buildQuery("{20020101 TO 20030101}").getQuery()); - assertEquals("lastModified:{20020101 TO 20030101}", queryHelper - .buildQuery("lastModified:{20020101 TO 20030101}") + assertEquals("title:{20020101 TO 20030101} OR content:{20020101 TO 20030101}", queryHelper.buildQuery("{20020101 TO 20030101}") .getQuery()); - assertEquals("(title:QUERY OR content:QUERY) " + op - + " lastModified:{20020101 TO 20030101}", queryHelper - .buildQuery("QUERY lastModified:{20020101 TO 20030101}") - .getQuery()); - assertEquals("title:{Aida TO Carmen} OR content:{Aida TO Carmen}", - queryHelper.buildQuery("{Aida TO Carmen}").getQuery()); - assertEquals("lastModified:{Aida TO Carmen}", queryHelper - .buildQuery("lastModified:{Aida TO Carmen}").getQuery()); - assertEquals("(title:QUERY OR content:QUERY) " + op - + " title:{Aida TO Carmen}", - queryHelper.buildQuery("QUERY title:{Aida TO Carmen}") - .getQuery()); - assertEquals("lastModified:{20020101 TO abc}", queryHelper - .buildQuery("lastModified:{20020101 TO abc}").getQuery()); - assertEquals("lastModified:{abc TO 20020101}", queryHelper - .buildQuery("lastModified:{abc TO 20020101}").getQuery()); - assertEquals("lastModified:{20020101 TO *}", queryHelper - .buildQuery("lastModified:{20020101 TO *}").getQuery()); - assertEquals("lastModified:{* TO 20020101}", queryHelper - .buildQuery("lastModified:{* TO 20020101}").getQuery()); + assertEquals("lastModified:{20020101 TO 20030101}", queryHelper.buildQuery("lastModified:{20020101 TO 20030101}").getQuery()); + assertEquals("(title:QUERY OR content:QUERY) " + op + " lastModified:{20020101 TO 20030101}", + queryHelper.buildQuery("QUERY lastModified:{20020101 TO 20030101}").getQuery()); + assertEquals("title:{Aida TO Carmen} OR content:{Aida TO Carmen}", queryHelper.buildQuery("{Aida TO Carmen}").getQuery()); + assertEquals("lastModified:{Aida TO Carmen}", queryHelper.buildQuery("lastModified:{Aida TO Carmen}").getQuery()); + assertEquals("(title:QUERY OR content:QUERY) " + op + " title:{Aida TO Carmen}", + queryHelper.buildQuery("QUERY title:{Aida TO Carmen}").getQuery()); + assertEquals("lastModified:{20020101 TO abc}", queryHelper.buildQuery("lastModified:{20020101 TO abc}").getQuery()); + assertEquals("lastModified:{abc TO 20020101}", queryHelper.buildQuery("lastModified:{abc TO 20020101}").getQuery()); + assertEquals("lastModified:{20020101 TO *}", queryHelper.buildQuery("lastModified:{20020101 TO *}").getQuery()); + assertEquals("lastModified:{* TO 20020101}", queryHelper.buildQuery("lastModified:{* TO 20020101}").getQuery()); - rangeQuery = "(content:{1 TO 2} OR content:{3 TO 4}) " + op - + " (content:{5 TO 6} OR content:{7 TO 8})"; - assertEquals(rangeQuery, queryHelper.buildQuery(rangeQuery) - .getQuery()); + rangeQuery = "(content:{1 TO 2} OR content:{3 TO 4}) " + op + " (content:{5 TO 6} OR content:{7 TO 8})"; + assertEquals(rangeQuery, queryHelper.buildQuery(rangeQuery).getQuery()); try { queryHelper.buildQuery("lastModified:{20020101 TO}").getQuery(); fail(); - } catch (final InvalidQueryException e) { - } + } catch (final InvalidQueryException e) {} try { queryHelper.buildQuery("lastModified:{TO 20030101}").getQuery(); fail(); - } catch (final InvalidQueryException e) { - } + } catch (final InvalidQueryException e) {} try { queryHelper.buildQuery("lastModified:{20020101}").getQuery(); fail(); - } catch (final InvalidQueryException e) { - } + } catch (final InvalidQueryException e) {} try { queryHelper.buildQuery("lastModified:{20030101}").getQuery(); fail(); - } catch (final InvalidQueryException e) { - } + } catch (final InvalidQueryException e) {} - rangeQuery = "(content:[1 TO 2] OR content:{3 TO 4}) " + op - + " (content:{5 TO 6} OR content:[7 TO 8])"; - assertEquals(rangeQuery, queryHelper.buildQuery(rangeQuery) - .getQuery()); + rangeQuery = "(content:[1 TO 2] OR content:{3 TO 4}) " + op + " (content:{5 TO 6} OR content:[7 TO 8])"; + assertEquals(rangeQuery, queryHelper.buildQuery(rangeQuery).getQuery()); } } @@ -598,225 +445,143 @@ public class QueryHelperTest extends S2TestCase { for (final String op : new String[] { "AND", "OR" }) { getRequest().setAttribute(Constants.DEFAULT_OPERATOR, op); // ^1000 ""^1000 - assertEquals("title:QUERY^1000 OR content:QUERY^1000", queryHelper - .buildQuery("QUERY^1000").getQuery()); - assertEquals("(title:QUERY1^1000 OR content:QUERY1^1000) " + op - + " (title:QUERY2 OR content:QUERY2)", queryHelper - .buildQuery("QUERY1^1000 QUERY2").getQuery()); - assertEquals("(title:QUERY1^500 OR content:QUERY1^500) " + op - + " (title:QUERY2^1000 OR content:QUERY2^1000)", - queryHelper.buildQuery("QUERY1^500 QUERY2^1000").getQuery()); + assertEquals("title:QUERY^1000 OR content:QUERY^1000", queryHelper.buildQuery("QUERY^1000").getQuery()); + assertEquals("(title:QUERY1^1000 OR content:QUERY1^1000) " + op + " (title:QUERY2 OR content:QUERY2)", + queryHelper.buildQuery("QUERY1^1000 QUERY2").getQuery()); + assertEquals("(title:QUERY1^500 OR content:QUERY1^500) " + op + " (title:QUERY2^1000 OR content:QUERY2^1000)", queryHelper + .buildQuery("QUERY1^500 QUERY2^1000").getQuery()); - assertEquals("mimetype:QUERY1^1000", - queryHelper.buildQuery("mimetype:QUERY1^1000").getQuery()); - assertEquals("mimetype:QUERY1^1000 " + op - + " (title:QUERY2 OR content:QUERY2)", queryHelper - .buildQuery("mimetype:QUERY1^1000 QUERY2").getQuery()); + assertEquals("mimetype:QUERY1^1000", queryHelper.buildQuery("mimetype:QUERY1^1000").getQuery()); + assertEquals("mimetype:QUERY1^1000 " + op + " (title:QUERY2 OR content:QUERY2)", + queryHelper.buildQuery("mimetype:QUERY1^1000 QUERY2").getQuery()); - assertEquals( - "title:QUERY1\\ QUERY2^1000 OR content:QUERY1\\ QUERY2^1000", - queryHelper.buildQuery("\"QUERY1 QUERY2\"^1000").getQuery()); - assertEquals("title:QUERY1^1000 OR content:QUERY1^1000", - queryHelper.buildQuery("\"QUERY1^1000\"").getQuery()); + assertEquals("title:QUERY1\\ QUERY2^1000 OR content:QUERY1\\ QUERY2^1000", queryHelper.buildQuery("\"QUERY1 QUERY2\"^1000") + .getQuery()); + assertEquals("title:QUERY1^1000 OR content:QUERY1^1000", queryHelper.buildQuery("\"QUERY1^1000\"").getQuery()); } } public void test_reserved() { for (int i = 0; i < Constants.RESERVED.length - 1; i++) { try { - assertEquals("title:\\" + Constants.RESERVED[i] - + " OR content:\\" + Constants.RESERVED[i], queryHelper - .buildQuery(Constants.RESERVED[i]).getQuery()); + assertEquals("title:\\" + Constants.RESERVED[i] + " OR content:\\" + Constants.RESERVED[i], + queryHelper.buildQuery(Constants.RESERVED[i]).getQuery()); } catch (final InvalidQueryException e) { - if (Constants.RESERVED[i].equals("\"") - && e.getMessageCode().equals( - "errors.invalid_query_quoted")) { - assertEquals("title:\\" + Constants.RESERVED[i] - + " OR content:\\" + Constants.RESERVED[i], - queryHelper - .buildQuery("\\" + Constants.RESERVED[i]) - .getQuery()); + if (Constants.RESERVED[i].equals("\"") && e.getMessageCode().equals("errors.invalid_query_quoted")) { + assertEquals("title:\\" + Constants.RESERVED[i] + " OR content:\\" + Constants.RESERVED[i], + queryHelper.buildQuery("\\" + Constants.RESERVED[i]).getQuery()); continue; - } else if (Constants.RESERVED[i].equals("{") - && e.getMessageCode().equals( - "errors.invalid_query_curly_bracket")) { - assertEquals("title:\\" + Constants.RESERVED[i] - + " OR content:\\" + Constants.RESERVED[i], - queryHelper - .buildQuery("\\" + Constants.RESERVED[i]) - .getQuery()); + } else if (Constants.RESERVED[i].equals("{") && e.getMessageCode().equals("errors.invalid_query_curly_bracket")) { + assertEquals("title:\\" + Constants.RESERVED[i] + " OR content:\\" + Constants.RESERVED[i], + queryHelper.buildQuery("\\" + Constants.RESERVED[i]).getQuery()); continue; - } else if (Constants.RESERVED[i].equals("[") - && e.getMessageCode().equals( - "errors.invalid_query_square_bracket")) { - assertEquals("title:\\" + Constants.RESERVED[i] - + " OR content:\\" + Constants.RESERVED[i], - queryHelper - .buildQuery("\\" + Constants.RESERVED[i]) - .getQuery()); + } else if (Constants.RESERVED[i].equals("[") && e.getMessageCode().equals("errors.invalid_query_square_bracket")) { + assertEquals("title:\\" + Constants.RESERVED[i] + " OR content:\\" + Constants.RESERVED[i], + queryHelper.buildQuery("\\" + Constants.RESERVED[i]).getQuery()); continue; - } else if (Constants.RESERVED[i].equals("(") - && e.getMessageCode().equals( - "errors.invalid_query_parenthesis")) { - assertEquals("title:\\" + Constants.RESERVED[i] - + " OR content:\\" + Constants.RESERVED[i], - queryHelper - .buildQuery("\\" + Constants.RESERVED[i]) - .getQuery()); + } else if (Constants.RESERVED[i].equals("(") && e.getMessageCode().equals("errors.invalid_query_parenthesis")) { + assertEquals("title:\\" + Constants.RESERVED[i] + " OR content:\\" + Constants.RESERVED[i], + queryHelper.buildQuery("\\" + Constants.RESERVED[i]).getQuery()); continue; } } } - assertEquals("title:\\: OR content:\\:", queryHelper.buildQuery(":") - .getQuery()); + assertEquals("title:\\: OR content:\\:", queryHelper.buildQuery(":").getQuery()); } public void test_or() { for (final String op : new String[] { "AND", "OR" }) { getRequest().setAttribute(Constants.DEFAULT_OPERATOR, op); - assertEquals("title:QUERY OR content:QUERY", queryHelper - .buildQuery("OR QUERY").getQuery()); + assertEquals("title:QUERY OR content:QUERY", queryHelper.buildQuery("OR QUERY").getQuery()); + assertEquals("(title:QUERY1 OR content:QUERY1) OR (title:QUERY2 OR content:QUERY2)", queryHelper.buildQuery("QUERY1 OR QUERY2") + .getQuery()); + assertEquals("title:QUERY", queryHelper.buildQuery("OR title:QUERY").getQuery()); + assertEquals("title:QUERY1 OR title:QUERY2", queryHelper.buildQuery("title:QUERY1 OR title:QUERY2").getQuery()); + assertEquals("(title:QUERY1 OR content:QUERY1) OR title:QUERY2", queryHelper.buildQuery("QUERY1 OR title:QUERY2").getQuery()); + assertEquals("mimetype:QUERY1 OR title:QUERY2", queryHelper.buildQuery("mimetype:QUERY1 OR title:QUERY2").getQuery()); assertEquals( - "(title:QUERY1 OR content:QUERY1) OR (title:QUERY2 OR content:QUERY2)", - queryHelper.buildQuery("QUERY1 OR QUERY2").getQuery()); - assertEquals("title:QUERY", queryHelper - .buildQuery("OR title:QUERY").getQuery()); - assertEquals("title:QUERY1 OR title:QUERY2", queryHelper - .buildQuery("title:QUERY1 OR title:QUERY2").getQuery()); - assertEquals("(title:QUERY1 OR content:QUERY1) OR title:QUERY2", - queryHelper.buildQuery("QUERY1 OR title:QUERY2").getQuery()); - assertEquals("mimetype:QUERY1 OR title:QUERY2", queryHelper - .buildQuery("mimetype:QUERY1 OR title:QUERY2").getQuery()); - assertEquals( - "(title:QUERY1 OR content:QUERY1) OR (title:QUERY2 OR content:QUERY2) " - + op + " (title:QUERY3 OR content:QUERY3)", - queryHelper.buildQuery("QUERY1 OR QUERY2 QUERY3") - .getQuery()); - assertEquals( - "(title:QUERY1 OR content:QUERY1) OR (title:QUERY2 OR content:QUERY2) OR (title:QUERY3 OR content:QUERY3)", - queryHelper.buildQuery("QUERY1 OR QUERY2 OR QUERY3") - .getQuery()); + "(title:QUERY1 OR content:QUERY1) OR (title:QUERY2 OR content:QUERY2) " + op + " (title:QUERY3 OR content:QUERY3)", + queryHelper.buildQuery("QUERY1 OR QUERY2 QUERY3").getQuery()); + assertEquals("(title:QUERY1 OR content:QUERY1) OR (title:QUERY2 OR content:QUERY2) OR (title:QUERY3 OR content:QUERY3)", + queryHelper.buildQuery("QUERY1 OR QUERY2 OR QUERY3").getQuery()); } } public void test_and() { for (final String op : new String[] { "AND", "OR" }) { getRequest().setAttribute(Constants.DEFAULT_OPERATOR, op); - assertEquals("title:QUERY OR content:QUERY", queryHelper - .buildQuery("AND QUERY").getQuery()); - assertEquals( - "(title:QUERY1 OR content:QUERY1) AND (title:QUERY2 OR content:QUERY2)", + assertEquals("title:QUERY OR content:QUERY", queryHelper.buildQuery("AND QUERY").getQuery()); + assertEquals("(title:QUERY1 OR content:QUERY1) AND (title:QUERY2 OR content:QUERY2)", queryHelper.buildQuery("QUERY1 AND QUERY2").getQuery()); - assertEquals("title:QUERY", - queryHelper.buildQuery("AND title:QUERY").getQuery()); - assertEquals("title:QUERY1 AND title:QUERY2", queryHelper - .buildQuery("title:QUERY1 AND title:QUERY2").getQuery()); - assertEquals("(title:QUERY1 OR content:QUERY1) AND title:QUERY2", - queryHelper.buildQuery("QUERY1 AND title:QUERY2") - .getQuery()); - assertEquals("mimetype:QUERY1 AND title:QUERY2", queryHelper - .buildQuery("mimetype:QUERY1 AND title:QUERY2").getQuery()); - assertEquals( - "(title:QUERY1 OR content:QUERY1) AND (title:QUERY2 OR content:QUERY2) " - + op + " (title:QUERY3 OR content:QUERY3)", - queryHelper.buildQuery("QUERY1 AND QUERY2 QUERY3") - .getQuery()); - assertEquals( - "(title:QUERY1 OR content:QUERY1) " - + op - + " (title:QUERY2 OR content:QUERY2) AND (title:QUERY3 OR content:QUERY3)", - queryHelper.buildQuery("QUERY1 QUERY2 AND QUERY3") - .getQuery()); - assertEquals( - "(title:QUERY1 OR content:QUERY1) AND (title:QUERY2 OR content:QUERY2) AND (title:QUERY3 OR content:QUERY3)", - queryHelper.buildQuery("QUERY1 AND QUERY2 AND QUERY3") - .getQuery()); + assertEquals("title:QUERY", queryHelper.buildQuery("AND title:QUERY").getQuery()); + assertEquals("title:QUERY1 AND title:QUERY2", queryHelper.buildQuery("title:QUERY1 AND title:QUERY2").getQuery()); + assertEquals("(title:QUERY1 OR content:QUERY1) AND title:QUERY2", queryHelper.buildQuery("QUERY1 AND title:QUERY2").getQuery()); + assertEquals("mimetype:QUERY1 AND title:QUERY2", queryHelper.buildQuery("mimetype:QUERY1 AND title:QUERY2").getQuery()); + assertEquals("(title:QUERY1 OR content:QUERY1) AND (title:QUERY2 OR content:QUERY2) " + op + + " (title:QUERY3 OR content:QUERY3)", queryHelper.buildQuery("QUERY1 AND QUERY2 QUERY3").getQuery()); + assertEquals("(title:QUERY1 OR content:QUERY1) " + op + + " (title:QUERY2 OR content:QUERY2) AND (title:QUERY3 OR content:QUERY3)", + queryHelper.buildQuery("QUERY1 QUERY2 AND QUERY3").getQuery()); + assertEquals("(title:QUERY1 OR content:QUERY1) AND (title:QUERY2 OR content:QUERY2) AND (title:QUERY3 OR content:QUERY3)", + queryHelper.buildQuery("QUERY1 AND QUERY2 AND QUERY3").getQuery()); } } public void test_not() { for (final String op : new String[] { "AND", "OR" }) { getRequest().setAttribute(Constants.DEFAULT_OPERATOR, op); - assertEquals("NOT (title:QUERY OR content:QUERY)", queryHelper - .buildQuery("NOT QUERY").getQuery()); - assertEquals("NOT title:QUERY", - queryHelper.buildQuery("NOT title:QUERY").getQuery()); - assertEquals("(title:QUERY2 OR content:QUERY2) " + op - + " NOT (title:QUERY1 OR content:QUERY1)", queryHelper - .buildQuery("NOT QUERY1 QUERY2").getQuery()); - assertEquals("(title:QUERY2 OR content:QUERY2) " + op - + " NOT (title:QUERY1 OR content:QUERY1)", queryHelper - .buildQuery("NOT QUERY1 OR QUERY2").getQuery()); - assertEquals("NOT (title:QUERY1 OR content:QUERY1) " + op - + " NOT (title:QUERY2 OR content:QUERY2)", queryHelper - .buildQuery("NOT QUERY1 NOT QUERY2").getQuery()); - assertEquals("NOT (title:QUERY1 OR content:QUERY1) " + op - + " NOT (title:QUERY2 OR content:QUERY2)", queryHelper - .buildQuery("NOT QUERY1 OR NOT QUERY2").getQuery()); - assertEquals("(title:QUERY2 OR content:QUERY2) " + op - + " NOT (title:QUERY1 OR content:QUERY1) " + op - + " NOT (title:QUERY3 OR content:QUERY3)", queryHelper - .buildQuery("NOT QUERY1 QUERY2 NOT QUERY3").getQuery()); - assertEquals("NOT mimetype:QUERY", - queryHelper.buildQuery("NOT mimetype:QUERY").getQuery()); - assertEquals( - "NOT mimetype:QUERY1 " + op + " NOT title:QUERY2", - queryHelper.buildQuery( - "NOT mimetype:QUERY1 NOT title:QUERY2").getQuery()); - assertEquals("(title:QUERY2 OR content:QUERY2) " + op - + " NOT mimetype:QUERY1", - queryHelper.buildQuery("NOT mimetype:QUERY1 QUERY2") - .getQuery()); - assertEquals("mimetype:QUERY2 " + op - + " NOT (title:QUERY1 OR content:QUERY1)", queryHelper - .buildQuery("NOT QUERY1 mimetype:QUERY2").getQuery()); + assertEquals("NOT (title:QUERY OR content:QUERY)", queryHelper.buildQuery("NOT QUERY").getQuery()); + assertEquals("NOT title:QUERY", queryHelper.buildQuery("NOT title:QUERY").getQuery()); + assertEquals("(title:QUERY2 OR content:QUERY2) " + op + " NOT (title:QUERY1 OR content:QUERY1)", + queryHelper.buildQuery("NOT QUERY1 QUERY2").getQuery()); + assertEquals("(title:QUERY2 OR content:QUERY2) " + op + " NOT (title:QUERY1 OR content:QUERY1)", + queryHelper.buildQuery("NOT QUERY1 OR QUERY2").getQuery()); + assertEquals("NOT (title:QUERY1 OR content:QUERY1) " + op + " NOT (title:QUERY2 OR content:QUERY2)", + queryHelper.buildQuery("NOT QUERY1 NOT QUERY2").getQuery()); + assertEquals("NOT (title:QUERY1 OR content:QUERY1) " + op + " NOT (title:QUERY2 OR content:QUERY2)", + queryHelper.buildQuery("NOT QUERY1 OR NOT QUERY2").getQuery()); + assertEquals("(title:QUERY2 OR content:QUERY2) " + op + " NOT (title:QUERY1 OR content:QUERY1) " + op + + " NOT (title:QUERY3 OR content:QUERY3)", queryHelper.buildQuery("NOT QUERY1 QUERY2 NOT QUERY3").getQuery()); + assertEquals("NOT mimetype:QUERY", queryHelper.buildQuery("NOT mimetype:QUERY").getQuery()); + assertEquals("NOT mimetype:QUERY1 " + op + " NOT title:QUERY2", queryHelper.buildQuery("NOT mimetype:QUERY1 NOT title:QUERY2") + .getQuery()); + assertEquals("(title:QUERY2 OR content:QUERY2) " + op + " NOT mimetype:QUERY1", + queryHelper.buildQuery("NOT mimetype:QUERY1 QUERY2").getQuery()); + assertEquals("mimetype:QUERY2 " + op + " NOT (title:QUERY1 OR content:QUERY1)", + queryHelper.buildQuery("NOT QUERY1 mimetype:QUERY2").getQuery()); } } public void test_escapeValue() { - final String[] targets = new String[] { "+", "-", "&&", "||", "!", "(", - ")", "{", "}", "[", "]", "^", "\"", "~", ":", "\\", " ", - "\u3000" }; + final String[] targets = + new String[] { "+", "-", "&&", "||", "!", "(", ")", "{", "}", "[", "]", "^", "\"", "~", ":", "\\", " ", "\u3000" }; for (final String target : targets) { - assertEquals("abc\\" + target + "123", - QueryUtil.escapeValue("abc" + target + "123")); + assertEquals("abc\\" + target + "123", QueryUtil.escapeValue("abc" + target + "123")); } for (final String target : targets) { - assertEquals("abc\\" + target, - QueryUtil.escapeValue("abc" + target)); + assertEquals("abc\\" + target, QueryUtil.escapeValue("abc" + target)); } for (final String target : targets) { - assertEquals("\\" + target + "123", - QueryUtil.escapeValue(target + "123")); + assertEquals("\\" + target + "123", QueryUtil.escapeValue(target + "123")); } for (final String target : targets) { - assertEquals( - "abc\\" + target + "123\\" + target + "ABC", - QueryUtil.escapeValue("abc" + target + "123" + target - + "ABC")); + assertEquals("abc\\" + target + "123\\" + target + "ABC", QueryUtil.escapeValue("abc" + target + "123" + target + "ABC")); } } public void test_escapeRangeValue() { - final String[] targets = new String[] { "&&", "||", "!", "(", ")", "{", - "}", "[", "]", "\"", "~", ":", "\\", " ", "\u3000" }; + final String[] targets = new String[] { "&&", "||", "!", "(", ")", "{", "}", "[", "]", "\"", "~", ":", "\\", " ", "\u3000" }; for (final String target : targets) { - assertEquals("abc\\" + target + "123", - QueryUtil.escapeValue("abc" + target + "123")); + assertEquals("abc\\" + target + "123", QueryUtil.escapeValue("abc" + target + "123")); } for (final String target : targets) { - assertEquals("abc\\" + target, - QueryUtil.escapeValue("abc" + target)); + assertEquals("abc\\" + target, QueryUtil.escapeValue("abc" + target)); } for (final String target : targets) { - assertEquals("\\" + target + "123", - QueryUtil.escapeValue(target + "123")); + assertEquals("\\" + target + "123", QueryUtil.escapeValue(target + "123")); } for (final String target : targets) { - assertEquals( - "abc\\" + target + "123\\" + target + "ABC", - QueryUtil.escapeValue("abc" + target + "123" + target - + "ABC")); + assertEquals("abc\\" + target + "123\\" + target + "ABC", QueryUtil.escapeValue("abc" + target + "123" + target + "ABC")); } } @@ -825,32 +590,22 @@ public class QueryHelperTest extends S2TestCase { getRequest().setAttribute(Constants.DEFAULT_OPERATOR, op); assertEquals("", queryHelper.buildFacetQuery("")); - assertEquals("title:QUERY OR content:QUERY", - queryHelper.buildFacetQuery("QUERY")); - assertEquals("title:QUERY OR content:QUERY", - queryHelper.buildFacetQuery("QUERY ")); - assertEquals("title:QUERY OR content:QUERY", - queryHelper.buildFacetQuery(" QUERY")); + assertEquals("title:QUERY OR content:QUERY", queryHelper.buildFacetQuery("QUERY")); + assertEquals("title:QUERY OR content:QUERY", queryHelper.buildFacetQuery("QUERY ")); + assertEquals("title:QUERY OR content:QUERY", queryHelper.buildFacetQuery(" QUERY")); - assertEquals("(title:QUERY1 OR content:QUERY1) " + op - + " (title:QUERY2 OR content:QUERY2)", + assertEquals("(title:QUERY1 OR content:QUERY1) " + op + " (title:QUERY2 OR content:QUERY2)", queryHelper.buildFacetQuery("QUERY1 QUERY2")); - assertEquals("(title:QUERY1 OR content:QUERY1) " + op - + " (title:QUERY2 OR content:QUERY2)", + assertEquals("(title:QUERY1 OR content:QUERY1) " + op + " (title:QUERY2 OR content:QUERY2)", queryHelper.buildFacetQuery("QUERY1 QUERY2 ")); - assertEquals("(title:QUERY1 OR content:QUERY1) " + op - + " (title:QUERY2 OR content:QUERY2)", + assertEquals("(title:QUERY1 OR content:QUERY1) " + op + " (title:QUERY2 OR content:QUERY2)", queryHelper.buildFacetQuery(" QUERY1 QUERY2")); - assertEquals("title:QUERY1\\ QUERY2 OR content:QUERY1\\ QUERY2", - queryHelper.buildFacetQuery("\"QUERY1 QUERY2\"")); - assertEquals("title:QUERY1\\ QUERY2 OR content:QUERY1\\ QUERY2", - queryHelper.buildFacetQuery("\"QUERY1 QUERY2\" ")); - assertEquals("title:QUERY1\\ QUERY2 OR content:QUERY1\\ QUERY2", - queryHelper.buildFacetQuery(" \"QUERY1 QUERY2\"")); + assertEquals("title:QUERY1\\ QUERY2 OR content:QUERY1\\ QUERY2", queryHelper.buildFacetQuery("\"QUERY1 QUERY2\"")); + assertEquals("title:QUERY1\\ QUERY2 OR content:QUERY1\\ QUERY2", queryHelper.buildFacetQuery("\"QUERY1 QUERY2\" ")); + assertEquals("title:QUERY1\\ QUERY2 OR content:QUERY1\\ QUERY2", queryHelper.buildFacetQuery(" \"QUERY1 QUERY2\"")); - assertEquals("(title:QUERY1\\ QUERY2 OR content:QUERY1\\ QUERY2) " - + op + " (title:QUERY3 OR content:QUERY3)", + assertEquals("(title:QUERY1\\ QUERY2 OR content:QUERY1\\ QUERY2) " + op + " (title:QUERY3 OR content:QUERY3)", queryHelper.buildFacetQuery("\"QUERY1 QUERY2\" QUERY3")); } } @@ -859,78 +614,49 @@ public class QueryHelperTest extends S2TestCase { for (final String op : new String[] { "AND", "OR" }) { getRequest().setAttribute(Constants.DEFAULT_OPERATOR, op); - assertEquals("(title:QUERY1 OR content:QUERY1) " + op - + " (title:QUERY2 OR content:QUERY2)", + assertEquals("(title:QUERY1 OR content:QUERY1) " + op + " (title:QUERY2 OR content:QUERY2)", queryHelper.buildFacetQuery("QUERY1\u3000QUERY2")); - assertEquals("(title:QUERY1 OR content:QUERY1) " + op - + " (title:QUERY2 OR content:QUERY2)", + assertEquals("(title:QUERY1 OR content:QUERY1) " + op + " (title:QUERY2 OR content:QUERY2)", queryHelper.buildFacetQuery("QUERY1\u3000QUERY2\u3000")); - assertEquals("(title:QUERY1 OR content:QUERY1) " + op - + " (title:QUERY2 OR content:QUERY2)", + assertEquals("(title:QUERY1 OR content:QUERY1) " + op + " (title:QUERY2 OR content:QUERY2)", queryHelper.buildFacetQuery("\u3000QUERY1\u3000QUERY2")); - assertEquals( - "title:QUERY1\\\u3000QUERY2 OR content:QUERY1\\\u3000QUERY2", + assertEquals("title:QUERY1\\\u3000QUERY2 OR content:QUERY1\\\u3000QUERY2", queryHelper.buildFacetQuery("\"QUERY1\u3000QUERY2\"")); - assertEquals( - "(title:QUERY1\\\u3000QUERY2 OR content:QUERY1\\\u3000QUERY2) " - + op + " (title:QUERY3 OR content:QUERY3)", - queryHelper - .buildFacetQuery("\"QUERY1\u3000QUERY2\"\u3000QUERY3")); + assertEquals("(title:QUERY1\\\u3000QUERY2 OR content:QUERY1\\\u3000QUERY2) " + op + " (title:QUERY3 OR content:QUERY3)", + queryHelper.buildFacetQuery("\"QUERY1\u3000QUERY2\"\u3000QUERY3")); } } public void test_buildFacet_prefix() { for (final String op : new String[] { "AND", "OR" }) { getRequest().setAttribute(Constants.DEFAULT_OPERATOR, op); - assertEquals("mimetype:QUERY1", - queryHelper.buildFacetQuery("mimetype:QUERY1")); - assertEquals("mimetype:QUERY1 " + op - + " (title:QUERY2 OR content:QUERY2)", + assertEquals("mimetype:QUERY1", queryHelper.buildFacetQuery("mimetype:QUERY1")); + assertEquals("mimetype:QUERY1 " + op + " (title:QUERY2 OR content:QUERY2)", queryHelper.buildFacetQuery("mimetype:QUERY1 QUERY2")); - assertEquals("mimetype:QUERY1 " + op - + " (title:QUERY2 OR content:QUERY2) " + op - + " (title:QUERY3 OR content:QUERY3)", - queryHelper - .buildFacetQuery("mimetype:QUERY1 QUERY2 QUERY3")); - assertEquals( - "mimetype:QUERY1 " + op + " host:QUERY2 " + op - + " (title:QUERY3 OR content:QUERY3)", - queryHelper - .buildFacetQuery("mimetype:QUERY1 host:QUERY2 QUERY3")); - assertEquals( - "mimetype:QUERY1\\ QUERY2 " + op - + " (title:QUERY3 OR content:QUERY3)", - queryHelper - .buildFacetQuery("mimetype:\"QUERY1 QUERY2\" QUERY3")); + assertEquals("mimetype:QUERY1 " + op + " (title:QUERY2 OR content:QUERY2) " + op + " (title:QUERY3 OR content:QUERY3)", + queryHelper.buildFacetQuery("mimetype:QUERY1 QUERY2 QUERY3")); + assertEquals("mimetype:QUERY1 " + op + " host:QUERY2 " + op + " (title:QUERY3 OR content:QUERY3)", + queryHelper.buildFacetQuery("mimetype:QUERY1 host:QUERY2 QUERY3")); + assertEquals("mimetype:QUERY1\\ QUERY2 " + op + " (title:QUERY3 OR content:QUERY3)", + queryHelper.buildFacetQuery("mimetype:\"QUERY1 QUERY2\" QUERY3")); } } public void test_buildFacet_prefix_unknown() { for (final String op : new String[] { "AND", "OR" }) { getRequest().setAttribute(Constants.DEFAULT_OPERATOR, op); - assertEquals("title:site\\: OR content:site\\:", - queryHelper.buildFacetQuery("site:")); - assertEquals("title:hoge\\:QUERY1 OR content:hoge\\:QUERY1", - queryHelper.buildFacetQuery("hoge:QUERY1")); - assertEquals("(title:hoge\\:QUERY1 OR content:hoge\\:QUERY1) " + op - + " (title:QUERY2 OR content:QUERY2)", + assertEquals("title:site\\: OR content:site\\:", queryHelper.buildFacetQuery("site:")); + assertEquals("title:hoge\\:QUERY1 OR content:hoge\\:QUERY1", queryHelper.buildFacetQuery("hoge:QUERY1")); + assertEquals("(title:hoge\\:QUERY1 OR content:hoge\\:QUERY1) " + op + " (title:QUERY2 OR content:QUERY2)", queryHelper.buildFacetQuery("hoge:QUERY1 QUERY2")); - assertEquals("(title:hoge\\:QUERY1 OR content:hoge\\:QUERY1) " + op - + " (title:QUERY2 OR content:QUERY2) " + op - + " (title:QUERY3 OR content:QUERY3)", - queryHelper.buildFacetQuery("hoge:QUERY1 QUERY2 QUERY3")); - assertEquals("(title:hoge\\:QUERY1 OR content:hoge\\:QUERY1) " + op - + " host:QUERY2 " + op - + " (title:QUERY3 OR content:QUERY3)", - queryHelper - .buildFacetQuery("hoge:QUERY1 host:QUERY2 QUERY3")); - assertEquals( - "(title:hoge\\:QUERY1\\ QUERY2 OR content:hoge\\:QUERY1\\ QUERY2) " - + op + " (title:QUERY3 OR content:QUERY3)", - queryHelper - .buildFacetQuery("hoge:\"QUERY1 QUERY2\" QUERY3")); + assertEquals("(title:hoge\\:QUERY1 OR content:hoge\\:QUERY1) " + op + " (title:QUERY2 OR content:QUERY2) " + op + + " (title:QUERY3 OR content:QUERY3)", queryHelper.buildFacetQuery("hoge:QUERY1 QUERY2 QUERY3")); + assertEquals("(title:hoge\\:QUERY1 OR content:hoge\\:QUERY1) " + op + " host:QUERY2 " + op + + " (title:QUERY3 OR content:QUERY3)", queryHelper.buildFacetQuery("hoge:QUERY1 host:QUERY2 QUERY3")); + assertEquals("(title:hoge\\:QUERY1\\ QUERY2 OR content:hoge\\:QUERY1\\ QUERY2) " + op + " (title:QUERY3 OR content:QUERY3)", + queryHelper.buildFacetQuery("hoge:\"QUERY1 QUERY2\" QUERY3")); } } @@ -970,18 +696,15 @@ public class QueryHelperTest extends S2TestCase { query = "QUERY mimetype:QUERY1 sort:contentLength"; searchQuery = queryHelper.buildFacetQuery(query); - assertEquals("(title:QUERY OR content:QUERY) " + op - + " mimetype:QUERY1", searchQuery); + assertEquals("(title:QUERY OR content:QUERY) " + op + " mimetype:QUERY1", searchQuery); query = "QUERY sort:contentLength.desc mimetype:QUERY1"; searchQuery = queryHelper.buildFacetQuery(query); - assertEquals("(title:QUERY OR content:QUERY) " + op - + " mimetype:QUERY1", searchQuery); + assertEquals("(title:QUERY OR content:QUERY) " + op + " mimetype:QUERY1", searchQuery); query = "QUERY sort:contentLength.asc,lastModified mimetype:QUERY1"; searchQuery = queryHelper.buildFacetQuery(query); - assertEquals("(title:QUERY OR content:QUERY) " + op - + " mimetype:QUERY1", searchQuery); + assertEquals("(title:QUERY OR content:QUERY) " + op + " mimetype:QUERY1", searchQuery); } } @@ -1007,65 +730,45 @@ public class QueryHelperTest extends S2TestCase { getRequest().setAttribute(Constants.DEFAULT_OPERATOR, op); // * - assertEquals("title:\\* OR content:\\*", - queryHelper.buildFacetQuery("*")); - assertEquals("title:QUERY* OR content:QUERY*", - queryHelper.buildFacetQuery("QUERY* ")); - assertEquals("title:Q*ERY OR content:Q*ERY", - queryHelper.buildFacetQuery(" Q*ERY")); + assertEquals("title:\\* OR content:\\*", queryHelper.buildFacetQuery("*")); + assertEquals("title:QUERY* OR content:QUERY*", queryHelper.buildFacetQuery("QUERY* ")); + assertEquals("title:Q*ERY OR content:Q*ERY", queryHelper.buildFacetQuery(" Q*ERY")); - assertEquals("(title:Q*ERY1 OR content:Q*ERY1) " + op - + " (title:Q*ERY2 OR content:Q*ERY2)", + assertEquals("(title:Q*ERY1 OR content:Q*ERY1) " + op + " (title:Q*ERY2 OR content:Q*ERY2)", queryHelper.buildFacetQuery("Q*ERY1 Q*ERY2")); - assertEquals("title:Q*ERY1\\ Q*ERY2 OR content:Q*ERY1\\ Q*ERY2", - queryHelper.buildFacetQuery("\"Q*ERY1 Q*ERY2\"")); + assertEquals("title:Q*ERY1\\ Q*ERY2 OR content:Q*ERY1\\ Q*ERY2", queryHelper.buildFacetQuery("\"Q*ERY1 Q*ERY2\"")); - assertEquals("(title:Q*ERY1\\ Q*ERY2 OR content:Q*ERY1\\ Q*ERY2) " - + op + " (title:Q*ERY3 OR content:Q*ERY3)", + assertEquals("(title:Q*ERY1\\ Q*ERY2 OR content:Q*ERY1\\ Q*ERY2) " + op + " (title:Q*ERY3 OR content:Q*ERY3)", queryHelper.buildFacetQuery("\"Q*ERY1 Q*ERY2\" Q*ERY3")); - assertEquals("mimetype:QUERY1*", - queryHelper.buildFacetQuery("mimetype:QUERY1*")); - assertEquals("mimetype:QUERY1* " + op - + " (title:QUERY2 OR content:QUERY2)", + assertEquals("mimetype:QUERY1*", queryHelper.buildFacetQuery("mimetype:QUERY1*")); + assertEquals("mimetype:QUERY1* " + op + " (title:QUERY2 OR content:QUERY2)", queryHelper.buildFacetQuery("mimetype:QUERY1* QUERY2")); - assertEquals("title:\\*QUERY1 OR content:\\*QUERY1", - queryHelper.buildFacetQuery("*QUERY1")); - assertEquals("title:\\*QUERY1* OR content:\\*QUERY1*", - queryHelper.buildFacetQuery("*QUERY1*")); + assertEquals("title:\\*QUERY1 OR content:\\*QUERY1", queryHelper.buildFacetQuery("*QUERY1")); + assertEquals("title:\\*QUERY1* OR content:\\*QUERY1*", queryHelper.buildFacetQuery("*QUERY1*")); // ? - assertEquals("title:\\? OR content:\\?", - queryHelper.buildFacetQuery("?")); - assertEquals("title:QUERY? OR content:QUERY?", - queryHelper.buildFacetQuery("QUERY? ")); - assertEquals("title:Q?ERY OR content:Q?ERY", - queryHelper.buildFacetQuery(" Q?ERY")); + assertEquals("title:\\? OR content:\\?", queryHelper.buildFacetQuery("?")); + assertEquals("title:QUERY? OR content:QUERY?", queryHelper.buildFacetQuery("QUERY? ")); + assertEquals("title:Q?ERY OR content:Q?ERY", queryHelper.buildFacetQuery(" Q?ERY")); - assertEquals("(title:Q?ERY1 OR content:Q?ERY1) " + op - + " (title:Q?ERY2 OR content:Q?ERY2)", + assertEquals("(title:Q?ERY1 OR content:Q?ERY1) " + op + " (title:Q?ERY2 OR content:Q?ERY2)", queryHelper.buildFacetQuery("Q?ERY1 Q?ERY2")); - assertEquals("title:Q?ERY1\\ Q?ERY2 OR content:Q?ERY1\\ Q?ERY2", - queryHelper.buildFacetQuery("\"Q?ERY1 Q?ERY2\"")); + assertEquals("title:Q?ERY1\\ Q?ERY2 OR content:Q?ERY1\\ Q?ERY2", queryHelper.buildFacetQuery("\"Q?ERY1 Q?ERY2\"")); - assertEquals("(title:Q?ERY1\\ Q?ERY2 OR content:Q?ERY1\\ Q?ERY2) " - + op + " (title:Q?ERY3 OR content:Q?ERY3)", + assertEquals("(title:Q?ERY1\\ Q?ERY2 OR content:Q?ERY1\\ Q?ERY2) " + op + " (title:Q?ERY3 OR content:Q?ERY3)", queryHelper.buildFacetQuery("\"Q?ERY1 Q?ERY2\" Q?ERY3")); - assertEquals("mimetype:QUERY1?", - queryHelper.buildFacetQuery("mimetype:QUERY1?")); - assertEquals("mimetype:QUERY1? " + op - + " (title:QUERY2 OR content:QUERY2)", + assertEquals("mimetype:QUERY1?", queryHelper.buildFacetQuery("mimetype:QUERY1?")); + assertEquals("mimetype:QUERY1? " + op + " (title:QUERY2 OR content:QUERY2)", queryHelper.buildFacetQuery("mimetype:QUERY1? QUERY2")); - assertEquals("title:\\?QUERY1 OR content:\\?QUERY1", - queryHelper.buildFacetQuery("?QUERY1")); - assertEquals("title:\\?QUERY1? OR content:\\?QUERY1?", - queryHelper.buildFacetQuery("?QUERY1?")); + assertEquals("title:\\?QUERY1 OR content:\\?QUERY1", queryHelper.buildFacetQuery("?QUERY1")); + assertEquals("title:\\?QUERY1? OR content:\\?QUERY1?", queryHelper.buildFacetQuery("?QUERY1?")); } } @@ -1074,53 +777,36 @@ public class QueryHelperTest extends S2TestCase { getRequest().setAttribute(Constants.DEFAULT_OPERATOR, op); // ~ - assertEquals("title:QUERY~ OR content:QUERY~", - queryHelper.buildFacetQuery("QUERY~")); - assertEquals("(title:QUERY1~ OR content:QUERY1~) " + op - + " (title:QUERY2 OR content:QUERY2)", + assertEquals("title:QUERY~ OR content:QUERY~", queryHelper.buildFacetQuery("QUERY~")); + assertEquals("(title:QUERY1~ OR content:QUERY1~) " + op + " (title:QUERY2 OR content:QUERY2)", queryHelper.buildFacetQuery("QUERY1~ QUERY2")); - assertEquals("(title:QUERY1~ OR content:QUERY1~) " + op - + " (title:QUERY2~ OR content:QUERY2~)", + assertEquals("(title:QUERY1~ OR content:QUERY1~) " + op + " (title:QUERY2~ OR content:QUERY2~)", queryHelper.buildFacetQuery("QUERY1~ QUERY2~")); - assertEquals("mimetype:QUERY1~", - queryHelper.buildFacetQuery("mimetype:QUERY1~")); - assertEquals("mimetype:QUERY1~ " + op - + " (title:QUERY2 OR content:QUERY2)", + assertEquals("mimetype:QUERY1~", queryHelper.buildFacetQuery("mimetype:QUERY1~")); + assertEquals("mimetype:QUERY1~ " + op + " (title:QUERY2 OR content:QUERY2)", queryHelper.buildFacetQuery("mimetype:QUERY1~ QUERY2")); - assertEquals("title:QUERY1\\ QUERY2~ OR content:QUERY1\\ QUERY2~", - queryHelper.buildFacetQuery("\"QUERY1 QUERY2\"~")); - assertEquals("title:QUERY1~ OR content:QUERY1~", - queryHelper.buildFacetQuery("\"QUERY1~\"")); + assertEquals("title:QUERY1\\ QUERY2~ OR content:QUERY1\\ QUERY2~", queryHelper.buildFacetQuery("\"QUERY1 QUERY2\"~")); + assertEquals("title:QUERY1~ OR content:QUERY1~", queryHelper.buildFacetQuery("\"QUERY1~\"")); // ~0.8 - assertEquals("title:QUERY~0.8 OR content:QUERY~0.8", - queryHelper.buildFacetQuery("QUERY~0.8")); - assertEquals("(title:QUERY1~0.8 OR content:QUERY1~0.8) " + op - + " (title:QUERY2 OR content:QUERY2)", + assertEquals("title:QUERY~0.8 OR content:QUERY~0.8", queryHelper.buildFacetQuery("QUERY~0.8")); + assertEquals("(title:QUERY1~0.8 OR content:QUERY1~0.8) " + op + " (title:QUERY2 OR content:QUERY2)", queryHelper.buildFacetQuery("QUERY1~0.8 QUERY2")); - assertEquals("(title:QUERY1~0.5 OR content:QUERY1~0.5) " + op - + " (title:QUERY2~0.8 OR content:QUERY2~0.8)", + assertEquals("(title:QUERY1~0.5 OR content:QUERY1~0.5) " + op + " (title:QUERY2~0.8 OR content:QUERY2~0.8)", queryHelper.buildFacetQuery("QUERY1~0.5 QUERY2~0.8")); - assertEquals("mimetype:QUERY1~0.8", - queryHelper.buildFacetQuery("mimetype:QUERY1~0.8")); - assertEquals("mimetype:QUERY1~0.8 " + op - + " (title:QUERY2 OR content:QUERY2)", + assertEquals("mimetype:QUERY1~0.8", queryHelper.buildFacetQuery("mimetype:QUERY1~0.8")); + assertEquals("mimetype:QUERY1~0.8 " + op + " (title:QUERY2 OR content:QUERY2)", queryHelper.buildFacetQuery("mimetype:QUERY1~0.8 QUERY2")); - assertEquals( - "title:QUERY1\\ QUERY2~0.8 OR content:QUERY1\\ QUERY2~0.8", - queryHelper.buildFacetQuery("\"QUERY1 QUERY2\"~0.8")); - assertEquals("title:QUERY1~0.8 OR content:QUERY1~0.8", - queryHelper.buildFacetQuery("\"QUERY1~0.8\"")); + assertEquals("title:QUERY1\\ QUERY2~0.8 OR content:QUERY1\\ QUERY2~0.8", queryHelper.buildFacetQuery("\"QUERY1 QUERY2\"~0.8")); + assertEquals("title:QUERY1~0.8 OR content:QUERY1~0.8", queryHelper.buildFacetQuery("\"QUERY1~0.8\"")); - assertEquals("title:QUERY1~0.8 OR content:QUERY1~0.8", - queryHelper.buildFacetQuery("\"QUERY1~0.8a\"")); - assertEquals("title:QUERY1~ OR content:QUERY1~", - queryHelper.buildFacetQuery("\"QUERY1~a\"")); + assertEquals("title:QUERY1~0.8 OR content:QUERY1~0.8", queryHelper.buildFacetQuery("\"QUERY1~0.8a\"")); + assertEquals("title:QUERY1~ OR content:QUERY1~", queryHelper.buildFacetQuery("\"QUERY1~a\"")); } } @@ -1128,33 +814,23 @@ public class QueryHelperTest extends S2TestCase { for (final String op : new String[] { "AND", "OR" }) { getRequest().setAttribute(Constants.DEFAULT_OPERATOR, op); // ~10 - assertEquals("title:\"QUERY\"~10 OR content:\"QUERY\"~10", - queryHelper.buildFacetQuery("QUERY~10")); - assertEquals("title:\"QUERY\"~1 OR content:\"QUERY\"~1", - queryHelper.buildFacetQuery("QUERY~1")); - assertEquals("title:\"QUERY\"~5 OR content:\"QUERY\"~5", - queryHelper.buildFacetQuery("QUERY~5.5")); - assertEquals("(title:\"QUERY1\"~10 OR content:\"QUERY1\"~10) " + op - + " (title:QUERY2 OR content:QUERY2)", + assertEquals("title:\"QUERY\"~10 OR content:\"QUERY\"~10", queryHelper.buildFacetQuery("QUERY~10")); + assertEquals("title:\"QUERY\"~1 OR content:\"QUERY\"~1", queryHelper.buildFacetQuery("QUERY~1")); + assertEquals("title:\"QUERY\"~5 OR content:\"QUERY\"~5", queryHelper.buildFacetQuery("QUERY~5.5")); + assertEquals("(title:\"QUERY1\"~10 OR content:\"QUERY1\"~10) " + op + " (title:QUERY2 OR content:QUERY2)", queryHelper.buildFacetQuery("QUERY1~10 QUERY2")); - assertEquals("(title:\"QUERY1\"~5 OR content:\"QUERY1\"~5) " + op - + " (title:\"QUERY2\"~10 OR content:\"QUERY2\"~10)", + assertEquals("(title:\"QUERY1\"~5 OR content:\"QUERY1\"~5) " + op + " (title:\"QUERY2\"~10 OR content:\"QUERY2\"~10)", queryHelper.buildFacetQuery("QUERY1~5 QUERY2~10")); - assertEquals("mimetype:\"QUERY1\"~10", - queryHelper.buildFacetQuery("mimetype:QUERY1~10")); - assertEquals("mimetype:\"QUERY1\"~10 " + op - + " (title:QUERY2 OR content:QUERY2)", + assertEquals("mimetype:\"QUERY1\"~10", queryHelper.buildFacetQuery("mimetype:QUERY1~10")); + assertEquals("mimetype:\"QUERY1\"~10 " + op + " (title:QUERY2 OR content:QUERY2)", queryHelper.buildFacetQuery("mimetype:QUERY1~10 QUERY2")); - assertEquals( - "title:\"QUERY1\\ QUERY2\"~10 OR content:\"QUERY1\\ QUERY2\"~10", + assertEquals("title:\"QUERY1\\ QUERY2\"~10 OR content:\"QUERY1\\ QUERY2\"~10", queryHelper.buildFacetQuery("\"QUERY1 QUERY2\"~10")); - assertEquals("title:\"QUERY1\"~10 OR content:\"QUERY1\"~10", - queryHelper.buildFacetQuery("\"QUERY1~10\"")); + assertEquals("title:\"QUERY1\"~10 OR content:\"QUERY1\"~10", queryHelper.buildFacetQuery("\"QUERY1~10\"")); - assertEquals("title:\"QUERY1\"~10 OR content:\"QUERY1\"~10", - queryHelper.buildFacetQuery("\"QUERY1~10a\"")); + assertEquals("title:\"QUERY1\"~10 OR content:\"QUERY1\"~10", queryHelper.buildFacetQuery("\"QUERY1~10a\"")); } } @@ -1162,29 +838,18 @@ public class QueryHelperTest extends S2TestCase { for (final String op : new String[] { "AND", "OR" }) { getRequest().setAttribute(Constants.DEFAULT_OPERATOR, op); // mod_date:[20020101 TO 20030101] - assertEquals( - "title:[20020101 TO 20030101] OR content:[20020101 TO 20030101]", + assertEquals("title:[20020101 TO 20030101] OR content:[20020101 TO 20030101]", queryHelper.buildFacetQuery("[20020101 TO 20030101]")); - assertEquals( - "lastModified:[20020101 TO 20030101]", - queryHelper - .buildFacetQuery("lastModified:[20020101 TO 20030101]")); - assertEquals( - "(title:QUERY OR content:QUERY) " + op - + " lastModified:[20020101 TO 20030101]", - queryHelper - .buildFacetQuery("QUERY lastModified:[20020101 TO 20030101]")); + assertEquals("lastModified:[20020101 TO 20030101]", queryHelper.buildFacetQuery("lastModified:[20020101 TO 20030101]")); + assertEquals("(title:QUERY OR content:QUERY) " + op + " lastModified:[20020101 TO 20030101]", + queryHelper.buildFacetQuery("QUERY lastModified:[20020101 TO 20030101]")); // TODO more.. // title:{Aida TO Carmen} - assertEquals("title:{Aida TO Carmen} OR content:{Aida TO Carmen}", - queryHelper.buildFacetQuery("{Aida TO Carmen}")); - assertEquals("lastModified:{Aida TO Carmen}", - queryHelper - .buildFacetQuery("lastModified:{Aida TO Carmen}")); - assertEquals("(title:QUERY OR content:QUERY) " + op - + " title:{Aida TO Carmen}", + assertEquals("title:{Aida TO Carmen} OR content:{Aida TO Carmen}", queryHelper.buildFacetQuery("{Aida TO Carmen}")); + assertEquals("lastModified:{Aida TO Carmen}", queryHelper.buildFacetQuery("lastModified:{Aida TO Carmen}")); + assertEquals("(title:QUERY OR content:QUERY) " + op + " title:{Aida TO Carmen}", queryHelper.buildFacetQuery("QUERY title:{Aida TO Carmen}")); // TODO more.. @@ -1195,102 +860,64 @@ public class QueryHelperTest extends S2TestCase { for (final String op : new String[] { "AND", "OR" }) { getRequest().setAttribute(Constants.DEFAULT_OPERATOR, op); // ^1000 ""^1000 - assertEquals("title:QUERY^1000 OR content:QUERY^1000", - queryHelper.buildFacetQuery("QUERY^1000")); - assertEquals("(title:QUERY1^1000 OR content:QUERY1^1000) " + op - + " (title:QUERY2 OR content:QUERY2)", + assertEquals("title:QUERY^1000 OR content:QUERY^1000", queryHelper.buildFacetQuery("QUERY^1000")); + assertEquals("(title:QUERY1^1000 OR content:QUERY1^1000) " + op + " (title:QUERY2 OR content:QUERY2)", queryHelper.buildFacetQuery("QUERY1^1000 QUERY2")); - assertEquals("(title:QUERY1^500 OR content:QUERY1^500) " + op - + " (title:QUERY2^1000 OR content:QUERY2^1000)", + assertEquals("(title:QUERY1^500 OR content:QUERY1^500) " + op + " (title:QUERY2^1000 OR content:QUERY2^1000)", queryHelper.buildFacetQuery("QUERY1^500 QUERY2^1000")); - assertEquals("mimetype:QUERY1^1000", - queryHelper.buildFacetQuery("mimetype:QUERY1^1000")); - assertEquals("mimetype:QUERY1^1000 " + op - + " (title:QUERY2 OR content:QUERY2)", + assertEquals("mimetype:QUERY1^1000", queryHelper.buildFacetQuery("mimetype:QUERY1^1000")); + assertEquals("mimetype:QUERY1^1000 " + op + " (title:QUERY2 OR content:QUERY2)", queryHelper.buildFacetQuery("mimetype:QUERY1^1000 QUERY2")); - assertEquals( - "title:QUERY1\\ QUERY2^1000 OR content:QUERY1\\ QUERY2^1000", + assertEquals("title:QUERY1\\ QUERY2^1000 OR content:QUERY1\\ QUERY2^1000", queryHelper.buildFacetQuery("\"QUERY1 QUERY2\"^1000")); - assertEquals("title:QUERY1^1000 OR content:QUERY1^1000", - queryHelper.buildFacetQuery("\"QUERY1^1000\"")); + assertEquals("title:QUERY1^1000 OR content:QUERY1^1000", queryHelper.buildFacetQuery("\"QUERY1^1000\"")); } } public void test_buildFacet_reserved() { for (int i = 0; i < Constants.RESERVED.length - 1; i++) { try { - assertEquals("title:\\" + Constants.RESERVED[i] - + " OR content:\\" + Constants.RESERVED[i], + assertEquals("title:\\" + Constants.RESERVED[i] + " OR content:\\" + Constants.RESERVED[i], queryHelper.buildFacetQuery(Constants.RESERVED[i])); } catch (final InvalidQueryException e) { - if (Constants.RESERVED[i].equals("\"") - && e.getMessageCode().equals( - "errors.invalid_query_quoted")) { - assertEquals( - "title:\\" + Constants.RESERVED[i] - + " OR content:\\" + Constants.RESERVED[i], - queryHelper.buildFacetQuery("\\" - + Constants.RESERVED[i])); + if (Constants.RESERVED[i].equals("\"") && e.getMessageCode().equals("errors.invalid_query_quoted")) { + assertEquals("title:\\" + Constants.RESERVED[i] + " OR content:\\" + Constants.RESERVED[i], + queryHelper.buildFacetQuery("\\" + Constants.RESERVED[i])); continue; - } else if (Constants.RESERVED[i].equals("{") - && e.getMessageCode().equals( - "errors.invalid_query_curly_bracket")) { - assertEquals( - "title:\\" + Constants.RESERVED[i] - + " OR content:\\" + Constants.RESERVED[i], - queryHelper.buildFacetQuery("\\" - + Constants.RESERVED[i])); + } else if (Constants.RESERVED[i].equals("{") && e.getMessageCode().equals("errors.invalid_query_curly_bracket")) { + assertEquals("title:\\" + Constants.RESERVED[i] + " OR content:\\" + Constants.RESERVED[i], + queryHelper.buildFacetQuery("\\" + Constants.RESERVED[i])); continue; - } else if (Constants.RESERVED[i].equals("[") - && e.getMessageCode().equals( - "errors.invalid_query_square_bracket")) { - assertEquals( - "title:\\" + Constants.RESERVED[i] - + " OR content:\\" + Constants.RESERVED[i], - queryHelper.buildFacetQuery("\\" - + Constants.RESERVED[i])); + } else if (Constants.RESERVED[i].equals("[") && e.getMessageCode().equals("errors.invalid_query_square_bracket")) { + assertEquals("title:\\" + Constants.RESERVED[i] + " OR content:\\" + Constants.RESERVED[i], + queryHelper.buildFacetQuery("\\" + Constants.RESERVED[i])); continue; - } else if (Constants.RESERVED[i].equals("(") - && e.getMessageCode().equals( - "errors.invalid_query_parenthesis")) { - assertEquals( - "title:\\" + Constants.RESERVED[i] - + " OR content:\\" + Constants.RESERVED[i], - queryHelper.buildFacetQuery("\\" - + Constants.RESERVED[i])); + } else if (Constants.RESERVED[i].equals("(") && e.getMessageCode().equals("errors.invalid_query_parenthesis")) { + assertEquals("title:\\" + Constants.RESERVED[i] + " OR content:\\" + Constants.RESERVED[i], + queryHelper.buildFacetQuery("\\" + Constants.RESERVED[i])); continue; } } } - assertEquals("title:\\: OR content:\\:", - queryHelper.buildFacetQuery(":")); + assertEquals("title:\\: OR content:\\:", queryHelper.buildFacetQuery(":")); } public void test_buildFacet_or() { for (final String op : new String[] { "AND", "OR" }) { getRequest().setAttribute(Constants.DEFAULT_OPERATOR, op); - assertEquals("title:QUERY OR content:QUERY", - queryHelper.buildFacetQuery("OR QUERY")); - assertEquals( - "(title:QUERY1 OR content:QUERY1) OR (title:QUERY2 OR content:QUERY2)", + assertEquals("title:QUERY OR content:QUERY", queryHelper.buildFacetQuery("OR QUERY")); + assertEquals("(title:QUERY1 OR content:QUERY1) OR (title:QUERY2 OR content:QUERY2)", queryHelper.buildFacetQuery("QUERY1 OR QUERY2")); - assertEquals("title:QUERY", - queryHelper.buildFacetQuery("OR title:QUERY")); - assertEquals("title:QUERY1 OR title:QUERY2", - queryHelper.buildFacetQuery("title:QUERY1 OR title:QUERY2")); - assertEquals("(title:QUERY1 OR content:QUERY1) OR title:QUERY2", - queryHelper.buildFacetQuery("QUERY1 OR title:QUERY2")); - assertEquals("mimetype:QUERY1 OR title:QUERY2", - queryHelper - .buildFacetQuery("mimetype:QUERY1 OR title:QUERY2")); + assertEquals("title:QUERY", queryHelper.buildFacetQuery("OR title:QUERY")); + assertEquals("title:QUERY1 OR title:QUERY2", queryHelper.buildFacetQuery("title:QUERY1 OR title:QUERY2")); + assertEquals("(title:QUERY1 OR content:QUERY1) OR title:QUERY2", queryHelper.buildFacetQuery("QUERY1 OR title:QUERY2")); + assertEquals("mimetype:QUERY1 OR title:QUERY2", queryHelper.buildFacetQuery("mimetype:QUERY1 OR title:QUERY2")); assertEquals( - "(title:QUERY1 OR content:QUERY1) OR (title:QUERY2 OR content:QUERY2) " - + op + " (title:QUERY3 OR content:QUERY3)", + "(title:QUERY1 OR content:QUERY1) OR (title:QUERY2 OR content:QUERY2) " + op + " (title:QUERY3 OR content:QUERY3)", queryHelper.buildFacetQuery("QUERY1 OR QUERY2 QUERY3")); - assertEquals( - "(title:QUERY1 OR content:QUERY1) OR (title:QUERY2 OR content:QUERY2) OR (title:QUERY3 OR content:QUERY3)", + assertEquals("(title:QUERY1 OR content:QUERY1) OR (title:QUERY2 OR content:QUERY2) OR (title:QUERY3 OR content:QUERY3)", queryHelper.buildFacetQuery("QUERY1 OR QUERY2 OR QUERY3")); } } @@ -1298,33 +925,19 @@ public class QueryHelperTest extends S2TestCase { public void test_buildFacet_and() { for (final String op : new String[] { "AND", "OR" }) { getRequest().setAttribute(Constants.DEFAULT_OPERATOR, op); - assertEquals("title:QUERY OR content:QUERY", - queryHelper.buildFacetQuery("AND QUERY")); - assertEquals( - "(title:QUERY1 OR content:QUERY1) AND (title:QUERY2 OR content:QUERY2)", + assertEquals("title:QUERY OR content:QUERY", queryHelper.buildFacetQuery("AND QUERY")); + assertEquals("(title:QUERY1 OR content:QUERY1) AND (title:QUERY2 OR content:QUERY2)", queryHelper.buildFacetQuery("QUERY1 AND QUERY2")); - assertEquals("title:QUERY", - queryHelper.buildFacetQuery("AND title:QUERY")); - assertEquals("title:QUERY1 AND title:QUERY2", - queryHelper - .buildFacetQuery("title:QUERY1 AND title:QUERY2")); - assertEquals("(title:QUERY1 OR content:QUERY1) AND title:QUERY2", - queryHelper.buildFacetQuery("QUERY1 AND title:QUERY2")); - assertEquals( - "mimetype:QUERY1 AND title:QUERY2", - queryHelper - .buildFacetQuery("mimetype:QUERY1 AND title:QUERY2")); - assertEquals( - "(title:QUERY1 OR content:QUERY1) AND (title:QUERY2 OR content:QUERY2) " - + op + " (title:QUERY3 OR content:QUERY3)", - queryHelper.buildFacetQuery("QUERY1 AND QUERY2 QUERY3")); - assertEquals( - "(title:QUERY1 OR content:QUERY1) " - + op - + " (title:QUERY2 OR content:QUERY2) AND (title:QUERY3 OR content:QUERY3)", + assertEquals("title:QUERY", queryHelper.buildFacetQuery("AND title:QUERY")); + assertEquals("title:QUERY1 AND title:QUERY2", queryHelper.buildFacetQuery("title:QUERY1 AND title:QUERY2")); + assertEquals("(title:QUERY1 OR content:QUERY1) AND title:QUERY2", queryHelper.buildFacetQuery("QUERY1 AND title:QUERY2")); + assertEquals("mimetype:QUERY1 AND title:QUERY2", queryHelper.buildFacetQuery("mimetype:QUERY1 AND title:QUERY2")); + assertEquals("(title:QUERY1 OR content:QUERY1) AND (title:QUERY2 OR content:QUERY2) " + op + + " (title:QUERY3 OR content:QUERY3)", queryHelper.buildFacetQuery("QUERY1 AND QUERY2 QUERY3")); + assertEquals("(title:QUERY1 OR content:QUERY1) " + op + + " (title:QUERY2 OR content:QUERY2) AND (title:QUERY3 OR content:QUERY3)", queryHelper.buildFacetQuery("QUERY1 QUERY2 AND QUERY3")); - assertEquals( - "(title:QUERY1 OR content:QUERY1) AND (title:QUERY2 OR content:QUERY2) AND (title:QUERY3 OR content:QUERY3)", + assertEquals("(title:QUERY1 OR content:QUERY1) AND (title:QUERY2 OR content:QUERY2) AND (title:QUERY3 OR content:QUERY3)", queryHelper.buildFacetQuery("QUERY1 AND QUERY2 AND QUERY3")); } } @@ -1332,37 +945,24 @@ public class QueryHelperTest extends S2TestCase { public void test_buildFacet_not() { for (final String op : new String[] { "AND", "OR" }) { getRequest().setAttribute(Constants.DEFAULT_OPERATOR, op); - assertEquals("NOT (title:QUERY OR content:QUERY)", - queryHelper.buildFacetQuery("NOT QUERY")); - assertEquals("NOT title:QUERY", - queryHelper.buildFacetQuery("NOT title:QUERY")); - assertEquals("(title:QUERY2 OR content:QUERY2) " + op - + " NOT (title:QUERY1 OR content:QUERY1)", + assertEquals("NOT (title:QUERY OR content:QUERY)", queryHelper.buildFacetQuery("NOT QUERY")); + assertEquals("NOT title:QUERY", queryHelper.buildFacetQuery("NOT title:QUERY")); + assertEquals("(title:QUERY2 OR content:QUERY2) " + op + " NOT (title:QUERY1 OR content:QUERY1)", queryHelper.buildFacetQuery("NOT QUERY1 QUERY2")); - assertEquals("(title:QUERY2 OR content:QUERY2) " + op - + " NOT (title:QUERY1 OR content:QUERY1)", + assertEquals("(title:QUERY2 OR content:QUERY2) " + op + " NOT (title:QUERY1 OR content:QUERY1)", queryHelper.buildFacetQuery("NOT QUERY1 OR QUERY2")); - assertEquals("NOT (title:QUERY1 OR content:QUERY1) " + op - + " NOT (title:QUERY2 OR content:QUERY2)", + assertEquals("NOT (title:QUERY1 OR content:QUERY1) " + op + " NOT (title:QUERY2 OR content:QUERY2)", queryHelper.buildFacetQuery("NOT QUERY1 NOT QUERY2")); - assertEquals("NOT (title:QUERY1 OR content:QUERY1) " + op - + " NOT (title:QUERY2 OR content:QUERY2)", + assertEquals("NOT (title:QUERY1 OR content:QUERY1) " + op + " NOT (title:QUERY2 OR content:QUERY2)", queryHelper.buildFacetQuery("NOT QUERY1 OR NOT QUERY2")); - assertEquals("(title:QUERY2 OR content:QUERY2) " + op - + " NOT (title:QUERY1 OR content:QUERY1) " + op - + " NOT (title:QUERY3 OR content:QUERY3)", - queryHelper.buildFacetQuery("NOT QUERY1 QUERY2 NOT QUERY3")); - assertEquals("NOT mimetype:QUERY", - queryHelper.buildFacetQuery("NOT mimetype:QUERY")); - assertEquals( - "NOT mimetype:QUERY1 " + op + " NOT title:QUERY2", - queryHelper - .buildFacetQuery("NOT mimetype:QUERY1 NOT title:QUERY2")); - assertEquals("(title:QUERY2 OR content:QUERY2) " + op - + " NOT mimetype:QUERY1", + assertEquals("(title:QUERY2 OR content:QUERY2) " + op + " NOT (title:QUERY1 OR content:QUERY1) " + op + + " NOT (title:QUERY3 OR content:QUERY3)", queryHelper.buildFacetQuery("NOT QUERY1 QUERY2 NOT QUERY3")); + assertEquals("NOT mimetype:QUERY", queryHelper.buildFacetQuery("NOT mimetype:QUERY")); + assertEquals("NOT mimetype:QUERY1 " + op + " NOT title:QUERY2", + queryHelper.buildFacetQuery("NOT mimetype:QUERY1 NOT title:QUERY2")); + assertEquals("(title:QUERY2 OR content:QUERY2) " + op + " NOT mimetype:QUERY1", queryHelper.buildFacetQuery("NOT mimetype:QUERY1 QUERY2")); - assertEquals("mimetype:QUERY2 " + op - + " NOT (title:QUERY1 OR content:QUERY1)", + assertEquals("mimetype:QUERY2 " + op + " NOT (title:QUERY1 OR content:QUERY1)", queryHelper.buildFacetQuery("NOT QUERY1 mimetype:QUERY2")); } } @@ -1370,242 +970,143 @@ public class QueryHelperTest extends S2TestCase { public void test_inner_query() { for (final String op : new String[] { "AND", "OR" }) { getRequest().setAttribute(Constants.DEFAULT_OPERATOR, op); - assertEquals("(title:bbb OR content:bbb) " + op - + " (title:ccc OR content:ccc)", - queryHelper.buildQuery("(bbb ccc)").getQuery()); - assertEquals( - "(title:bbb OR content:bbb) OR (title:ccc OR content:ccc)", - queryHelper.buildQuery("(bbb OR ccc)").getQuery()); - assertEquals( - "(title:bbb OR content:bbb) AND (title:ccc OR content:ccc)", - queryHelper.buildQuery("(bbb AND ccc)").getQuery()); + assertEquals("(title:bbb OR content:bbb) " + op + " (title:ccc OR content:ccc)", queryHelper.buildQuery("(bbb ccc)").getQuery()); + assertEquals("(title:bbb OR content:bbb) OR (title:ccc OR content:ccc)", queryHelper.buildQuery("(bbb OR ccc)").getQuery()); + assertEquals("(title:bbb OR content:bbb) AND (title:ccc OR content:ccc)", queryHelper.buildQuery("(bbb AND ccc)").getQuery()); - assertEquals("(title:aaa OR content:aaa) " + op - + " ((title:bbb OR content:bbb) " + op - + " (title:ccc OR content:ccc))", + assertEquals("(title:aaa OR content:aaa) " + op + " ((title:bbb OR content:bbb) " + op + " (title:ccc OR content:ccc))", queryHelper.buildQuery("aaa (bbb ccc)").getQuery()); - assertEquals( - "(title:aaa OR content:aaa) " - + op - + " ((title:bbb OR content:bbb) AND (title:ccc OR content:ccc))", - queryHelper.buildQuery("aaa (bbb AND ccc)").getQuery()); - assertEquals( - "(title:aaa OR content:aaa) AND ((title:bbb OR content:bbb) AND (title:ccc OR content:ccc))", - queryHelper.buildQuery("aaa AND (bbb AND ccc)").getQuery()); - assertEquals( - "(title:aaa OR content:aaa) OR ((title:bbb OR content:bbb) AND (title:ccc OR content:ccc))", - queryHelper.buildQuery("aaa OR (bbb AND ccc)").getQuery()); + assertEquals("(title:aaa OR content:aaa) " + op + " ((title:bbb OR content:bbb) AND (title:ccc OR content:ccc))", queryHelper + .buildQuery("aaa (bbb AND ccc)").getQuery()); + assertEquals("(title:aaa OR content:aaa) AND ((title:bbb OR content:bbb) AND (title:ccc OR content:ccc))", queryHelper + .buildQuery("aaa AND (bbb AND ccc)").getQuery()); + assertEquals("(title:aaa OR content:aaa) OR ((title:bbb OR content:bbb) AND (title:ccc OR content:ccc))", queryHelper + .buildQuery("aaa OR (bbb AND ccc)").getQuery()); - assertEquals( - "(title:aaa OR content:aaa) " - + op - + " ((title:bbb OR content:bbb) OR (title:ccc OR content:ccc))", - queryHelper.buildQuery("aaa (bbb OR ccc)").getQuery()); - assertEquals( - "(title:aaa OR content:aaa) AND ((title:bbb OR content:bbb) OR (title:ccc OR content:ccc))", - queryHelper.buildQuery("aaa AND (bbb OR ccc)").getQuery()); - assertEquals( - "(title:aaa OR content:aaa) OR ((title:bbb OR content:bbb) OR (title:ccc OR content:ccc))", - queryHelper.buildQuery("aaa OR (bbb OR ccc)").getQuery()); + assertEquals("(title:aaa OR content:aaa) " + op + " ((title:bbb OR content:bbb) OR (title:ccc OR content:ccc))", queryHelper + .buildQuery("aaa (bbb OR ccc)").getQuery()); + assertEquals("(title:aaa OR content:aaa) AND ((title:bbb OR content:bbb) OR (title:ccc OR content:ccc))", queryHelper + .buildQuery("aaa AND (bbb OR ccc)").getQuery()); + assertEquals("(title:aaa OR content:aaa) OR ((title:bbb OR content:bbb) OR (title:ccc OR content:ccc))", queryHelper + .buildQuery("aaa OR (bbb OR ccc)").getQuery()); - assertEquals("((title:bbb OR content:bbb) " + op - + " (title:ccc OR content:ccc)) " + op - + " (title:ddd OR content:ddd)", + assertEquals("((title:bbb OR content:bbb) " + op + " (title:ccc OR content:ccc)) " + op + " (title:ddd OR content:ddd)", queryHelper.buildQuery("(bbb ccc) ddd").getQuery()); - assertEquals( - "((title:bbb OR content:bbb) AND (title:ccc OR content:ccc)) " - + op + " (title:ddd OR content:ddd)", queryHelper - .buildQuery("(bbb AND ccc) ddd").getQuery()); - assertEquals( - "((title:bbb OR content:bbb) AND (title:ccc OR content:ccc)) AND (title:ddd OR content:ddd)", - queryHelper.buildQuery("(bbb AND ccc) AND ddd").getQuery()); - assertEquals( - "((title:bbb OR content:bbb) AND (title:ccc OR content:ccc)) OR (title:ddd OR content:ddd)", - queryHelper.buildQuery("(bbb AND ccc) OR ddd").getQuery()); + assertEquals("((title:bbb OR content:bbb) AND (title:ccc OR content:ccc)) " + op + " (title:ddd OR content:ddd)", queryHelper + .buildQuery("(bbb AND ccc) ddd").getQuery()); + assertEquals("((title:bbb OR content:bbb) AND (title:ccc OR content:ccc)) AND (title:ddd OR content:ddd)", queryHelper + .buildQuery("(bbb AND ccc) AND ddd").getQuery()); + assertEquals("((title:bbb OR content:bbb) AND (title:ccc OR content:ccc)) OR (title:ddd OR content:ddd)", queryHelper + .buildQuery("(bbb AND ccc) OR ddd").getQuery()); - assertEquals( - "((title:bbb OR content:bbb) OR (title:ccc OR content:ccc)) " - + op + " (title:ddd OR content:ddd)", queryHelper - .buildQuery("(bbb OR ccc) ddd").getQuery()); - assertEquals( - "((title:bbb OR content:bbb) OR (title:ccc OR content:ccc)) AND (title:ddd OR content:ddd)", - queryHelper.buildQuery("(bbb OR ccc) AND ddd").getQuery()); - assertEquals( - "((title:bbb OR content:bbb) OR (title:ccc OR content:ccc)) OR (title:ddd OR content:ddd)", - queryHelper.buildQuery("(bbb OR ccc) OR ddd").getQuery()); + assertEquals("((title:bbb OR content:bbb) OR (title:ccc OR content:ccc)) " + op + " (title:ddd OR content:ddd)", queryHelper + .buildQuery("(bbb OR ccc) ddd").getQuery()); + assertEquals("((title:bbb OR content:bbb) OR (title:ccc OR content:ccc)) AND (title:ddd OR content:ddd)", queryHelper + .buildQuery("(bbb OR ccc) AND ddd").getQuery()); + assertEquals("((title:bbb OR content:bbb) OR (title:ccc OR content:ccc)) OR (title:ddd OR content:ddd)", queryHelper + .buildQuery("(bbb OR ccc) OR ddd").getQuery()); - assertEquals("(title:aaa OR content:aaa) " + op - + " ((title:bbb OR content:bbb) " + op - + " (title:ccc OR content:ccc)) " + op - + " (title:ddd OR content:ddd)", - queryHelper.buildQuery("aaa (bbb ccc) ddd").getQuery()); - assertEquals( - "(title:aaa OR content:aaa) " - + op - + " ((title:bbb OR content:bbb) AND (title:ccc OR content:ccc)) " - + op + " (title:ddd OR content:ddd)", queryHelper - .buildQuery("aaa (bbb AND ccc) ddd").getQuery()); + assertEquals("(title:aaa OR content:aaa) " + op + " ((title:bbb OR content:bbb) " + op + " (title:ccc OR content:ccc)) " + op + + " (title:ddd OR content:ddd)", queryHelper.buildQuery("aaa (bbb ccc) ddd").getQuery()); + assertEquals("(title:aaa OR content:aaa) " + op + " ((title:bbb OR content:bbb) AND (title:ccc OR content:ccc)) " + op + + " (title:ddd OR content:ddd)", queryHelper.buildQuery("aaa (bbb AND ccc) ddd").getQuery()); assertEquals( "(title:aaa OR content:aaa) AND ((title:bbb OR content:bbb) AND (title:ccc OR content:ccc)) AND (title:ddd OR content:ddd)", - queryHelper.buildQuery("aaa AND (bbb AND ccc) AND ddd") - .getQuery()); + queryHelper.buildQuery("aaa AND (bbb AND ccc) AND ddd").getQuery()); assertEquals( "(title:aaa OR content:aaa) OR ((title:bbb OR content:bbb) AND (title:ccc OR content:ccc)) OR (title:ddd OR content:ddd)", - queryHelper.buildQuery("aaa OR (bbb AND ccc) OR ddd") - .getQuery()); + queryHelper.buildQuery("aaa OR (bbb AND ccc) OR ddd").getQuery()); - assertEquals( - "(title:aaa OR content:aaa) " - + op - + " ((title:bbb OR content:bbb) OR (title:ccc OR content:ccc)) " - + op + " (title:ddd OR content:ddd)", queryHelper - .buildQuery("aaa (bbb OR ccc) ddd").getQuery()); + assertEquals("(title:aaa OR content:aaa) " + op + " ((title:bbb OR content:bbb) OR (title:ccc OR content:ccc)) " + op + + " (title:ddd OR content:ddd)", queryHelper.buildQuery("aaa (bbb OR ccc) ddd").getQuery()); assertEquals( "(title:aaa OR content:aaa) AND ((title:bbb OR content:bbb) OR (title:ccc OR content:ccc)) AND (title:ddd OR content:ddd)", - queryHelper.buildQuery("aaa AND (bbb OR ccc) AND ddd") - .getQuery()); + queryHelper.buildQuery("aaa AND (bbb OR ccc) AND ddd").getQuery()); assertEquals( "(title:aaa OR content:aaa) OR ((title:bbb OR content:bbb) OR (title:ccc OR content:ccc)) OR (title:ddd OR content:ddd)", - queryHelper.buildQuery("aaa OR (bbb OR ccc) OR ddd") - .getQuery()); + queryHelper.buildQuery("aaa OR (bbb OR ccc) OR ddd").getQuery()); - assertEquals("(title:aaa OR content:aaa) " + op + " (label:bbb " - + op + " (title:ccc OR content:ccc))", queryHelper - .buildQuery("aaa (label:bbb ccc)").getQuery()); - assertEquals("(title:aaa OR content:aaa) " + op - + " (label:bbb AND (title:ccc OR content:ccc))", - queryHelper.buildQuery("aaa (label:bbb AND ccc)") - .getQuery()); - assertEquals("(title:aaa OR content:aaa) " + op - + " (label:bbb OR (title:ccc OR content:ccc))", queryHelper - .buildQuery("aaa (label:bbb OR ccc)").getQuery()); + assertEquals("(title:aaa OR content:aaa) " + op + " (label:bbb " + op + " (title:ccc OR content:ccc))", + queryHelper.buildQuery("aaa (label:bbb ccc)").getQuery()); + assertEquals("(title:aaa OR content:aaa) " + op + " (label:bbb AND (title:ccc OR content:ccc))", + queryHelper.buildQuery("aaa (label:bbb AND ccc)").getQuery()); + assertEquals("(title:aaa OR content:aaa) " + op + " (label:bbb OR (title:ccc OR content:ccc))", + queryHelper.buildQuery("aaa (label:bbb OR ccc)").getQuery()); - assertEquals("(title:aaa OR content:aaa) " + op - + " ((title:bbb OR content:bbb) " + op + " label:ccc)", + assertEquals("(title:aaa OR content:aaa) " + op + " ((title:bbb OR content:bbb) " + op + " label:ccc)", queryHelper.buildQuery("aaa (bbb label:ccc)").getQuery()); - assertEquals("(title:aaa OR content:aaa) " + op - + " ((title:bbb OR content:bbb) AND label:ccc)", - queryHelper.buildQuery("aaa (bbb AND label:ccc)") - .getQuery()); - assertEquals("(title:aaa OR content:aaa) " + op - + " ((title:bbb OR content:bbb) OR label:ccc)", queryHelper - .buildQuery("aaa (bbb OR label:ccc)").getQuery()); + assertEquals("(title:aaa OR content:aaa) " + op + " ((title:bbb OR content:bbb) AND label:ccc)", + queryHelper.buildQuery("aaa (bbb AND label:ccc)").getQuery()); + assertEquals("(title:aaa OR content:aaa) " + op + " ((title:bbb OR content:bbb) OR label:ccc)", + queryHelper.buildQuery("aaa (bbb OR label:ccc)").getQuery()); - assertEquals("(title:aaa OR content:aaa) " + op - + " ((title:bbb OR content:bbb) " + op - + " NOT (title:ccc OR content:ccc))", queryHelper - .buildQuery("aaa (bbb NOT ccc)").getQuery()); + assertEquals("(title:aaa OR content:aaa) " + op + " ((title:bbb OR content:bbb) " + op + " NOT (title:ccc OR content:ccc))", + queryHelper.buildQuery("aaa (bbb NOT ccc)").getQuery()); } } public void test_more_inner_query() { for (final String op : new String[] { "AND", "OR" }) { getRequest().setAttribute(Constants.DEFAULT_OPERATOR, op); - assertEquals("(title:aaa OR content:aaa) " + op - + " ((title:bbb OR content:bbb) " + op - + " ((title:ccc OR content:ccc) " + op - + " (title:ddd OR content:ddd)))", - queryHelper.buildQuery("aaa (bbb (ccc ddd))").getQuery()); - assertEquals("(((title:aaa OR content:aaa) " + op - + " (title:bbb OR content:bbb)) " + op - + " (title:ccc OR content:ccc)) " + op - + " (title:ddd OR content:ddd)", - queryHelper.buildQuery("((aaa bbb) ccc) ddd").getQuery()); + assertEquals("(title:aaa OR content:aaa) " + op + " ((title:bbb OR content:bbb) " + op + " ((title:ccc OR content:ccc) " + op + + " (title:ddd OR content:ddd)))", queryHelper.buildQuery("aaa (bbb (ccc ddd))").getQuery()); + assertEquals("(((title:aaa OR content:aaa) " + op + " (title:bbb OR content:bbb)) " + op + " (title:ccc OR content:ccc)) " + op + + " (title:ddd OR content:ddd)", queryHelper.buildQuery("((aaa bbb) ccc) ddd").getQuery()); } } public void test_inner_facetQuery() { for (final String op : new String[] { "AND", "OR" }) { getRequest().setAttribute(Constants.DEFAULT_OPERATOR, op); - assertEquals("(title:bbb OR content:bbb) " + op - + " (title:ccc OR content:ccc)", - queryHelper.buildFacetQuery("(bbb ccc)")); - assertEquals( - "(title:bbb OR content:bbb) OR (title:ccc OR content:ccc)", - queryHelper.buildFacetQuery("(bbb OR ccc)")); - assertEquals( - "(title:bbb OR content:bbb) AND (title:ccc OR content:ccc)", - queryHelper.buildFacetQuery("(bbb AND ccc)")); + assertEquals("(title:bbb OR content:bbb) " + op + " (title:ccc OR content:ccc)", queryHelper.buildFacetQuery("(bbb ccc)")); + assertEquals("(title:bbb OR content:bbb) OR (title:ccc OR content:ccc)", queryHelper.buildFacetQuery("(bbb OR ccc)")); + assertEquals("(title:bbb OR content:bbb) AND (title:ccc OR content:ccc)", queryHelper.buildFacetQuery("(bbb AND ccc)")); - assertEquals("(title:aaa OR content:aaa) " + op - + " ((title:bbb OR content:bbb) " + op - + " (title:ccc OR content:ccc))", + assertEquals("(title:aaa OR content:aaa) " + op + " ((title:bbb OR content:bbb) " + op + " (title:ccc OR content:ccc))", queryHelper.buildFacetQuery("aaa (bbb ccc)")); - assertEquals( - "(title:aaa OR content:aaa) " - + op - + " ((title:bbb OR content:bbb) AND (title:ccc OR content:ccc))", + assertEquals("(title:aaa OR content:aaa) " + op + " ((title:bbb OR content:bbb) AND (title:ccc OR content:ccc))", queryHelper.buildFacetQuery("aaa (bbb AND ccc)")); - assertEquals( - "(title:aaa OR content:aaa) AND ((title:bbb OR content:bbb) AND (title:ccc OR content:ccc))", + assertEquals("(title:aaa OR content:aaa) AND ((title:bbb OR content:bbb) AND (title:ccc OR content:ccc))", queryHelper.buildFacetQuery("aaa AND (bbb AND ccc)")); - assertEquals( - "(title:aaa OR content:aaa) OR ((title:bbb OR content:bbb) AND (title:ccc OR content:ccc))", + assertEquals("(title:aaa OR content:aaa) OR ((title:bbb OR content:bbb) AND (title:ccc OR content:ccc))", queryHelper.buildFacetQuery("aaa OR (bbb AND ccc)")); - assertEquals( - "(title:aaa OR content:aaa) " - + op - + " ((title:bbb OR content:bbb) OR (title:ccc OR content:ccc))", + assertEquals("(title:aaa OR content:aaa) " + op + " ((title:bbb OR content:bbb) OR (title:ccc OR content:ccc))", queryHelper.buildFacetQuery("aaa (bbb OR ccc)")); - assertEquals( - "(title:aaa OR content:aaa) AND ((title:bbb OR content:bbb) OR (title:ccc OR content:ccc))", + assertEquals("(title:aaa OR content:aaa) AND ((title:bbb OR content:bbb) OR (title:ccc OR content:ccc))", queryHelper.buildFacetQuery("aaa AND (bbb OR ccc)")); - assertEquals( - "(title:aaa OR content:aaa) OR ((title:bbb OR content:bbb) OR (title:ccc OR content:ccc))", + assertEquals("(title:aaa OR content:aaa) OR ((title:bbb OR content:bbb) OR (title:ccc OR content:ccc))", queryHelper.buildFacetQuery("aaa OR (bbb OR ccc)")); - assertEquals("((title:bbb OR content:bbb) " + op - + " (title:ccc OR content:ccc)) " + op - + " (title:ddd OR content:ddd)", + assertEquals("((title:bbb OR content:bbb) " + op + " (title:ccc OR content:ccc)) " + op + " (title:ddd OR content:ddd)", queryHelper.buildFacetQuery("(bbb ccc) ddd")); - assertEquals( - "((title:bbb OR content:bbb) AND (title:ccc OR content:ccc)) " - + op + " (title:ddd OR content:ddd)", + assertEquals("((title:bbb OR content:bbb) AND (title:ccc OR content:ccc)) " + op + " (title:ddd OR content:ddd)", queryHelper.buildFacetQuery("(bbb AND ccc) ddd")); - assertEquals( - "((title:bbb OR content:bbb) AND (title:ccc OR content:ccc)) AND (title:ddd OR content:ddd)", + assertEquals("((title:bbb OR content:bbb) AND (title:ccc OR content:ccc)) AND (title:ddd OR content:ddd)", queryHelper.buildFacetQuery("(bbb AND ccc) AND ddd")); - assertEquals( - "((title:bbb OR content:bbb) AND (title:ccc OR content:ccc)) OR (title:ddd OR content:ddd)", + assertEquals("((title:bbb OR content:bbb) AND (title:ccc OR content:ccc)) OR (title:ddd OR content:ddd)", queryHelper.buildFacetQuery("(bbb AND ccc) OR ddd")); - assertEquals( - "((title:bbb OR content:bbb) OR (title:ccc OR content:ccc)) " - + op + " (title:ddd OR content:ddd)", + assertEquals("((title:bbb OR content:bbb) OR (title:ccc OR content:ccc)) " + op + " (title:ddd OR content:ddd)", queryHelper.buildFacetQuery("(bbb OR ccc) ddd")); - assertEquals( - "((title:bbb OR content:bbb) OR (title:ccc OR content:ccc)) AND (title:ddd OR content:ddd)", + assertEquals("((title:bbb OR content:bbb) OR (title:ccc OR content:ccc)) AND (title:ddd OR content:ddd)", queryHelper.buildFacetQuery("(bbb OR ccc) AND ddd")); - assertEquals( - "((title:bbb OR content:bbb) OR (title:ccc OR content:ccc)) OR (title:ddd OR content:ddd)", + assertEquals("((title:bbb OR content:bbb) OR (title:ccc OR content:ccc)) OR (title:ddd OR content:ddd)", queryHelper.buildFacetQuery("(bbb OR ccc) OR ddd")); - assertEquals("(title:aaa OR content:aaa) " + op - + " ((title:bbb OR content:bbb) " + op - + " (title:ccc OR content:ccc)) " + op - + " (title:ddd OR content:ddd)", - queryHelper.buildFacetQuery("aaa (bbb ccc) ddd")); - assertEquals( - "(title:aaa OR content:aaa) " - + op - + " ((title:bbb OR content:bbb) AND (title:ccc OR content:ccc)) " - + op + " (title:ddd OR content:ddd)", - queryHelper.buildFacetQuery("aaa (bbb AND ccc) ddd")); + assertEquals("(title:aaa OR content:aaa) " + op + " ((title:bbb OR content:bbb) " + op + " (title:ccc OR content:ccc)) " + op + + " (title:ddd OR content:ddd)", queryHelper.buildFacetQuery("aaa (bbb ccc) ddd")); + assertEquals("(title:aaa OR content:aaa) " + op + " ((title:bbb OR content:bbb) AND (title:ccc OR content:ccc)) " + op + + " (title:ddd OR content:ddd)", queryHelper.buildFacetQuery("aaa (bbb AND ccc) ddd")); assertEquals( "(title:aaa OR content:aaa) AND ((title:bbb OR content:bbb) AND (title:ccc OR content:ccc)) AND (title:ddd OR content:ddd)", - queryHelper - .buildFacetQuery("aaa AND (bbb AND ccc) AND ddd")); + queryHelper.buildFacetQuery("aaa AND (bbb AND ccc) AND ddd")); assertEquals( "(title:aaa OR content:aaa) OR ((title:bbb OR content:bbb) AND (title:ccc OR content:ccc)) OR (title:ddd OR content:ddd)", queryHelper.buildFacetQuery("aaa OR (bbb AND ccc) OR ddd")); - assertEquals( - "(title:aaa OR content:aaa) " - + op - + " ((title:bbb OR content:bbb) OR (title:ccc OR content:ccc)) " - + op + " (title:ddd OR content:ddd)", - queryHelper.buildFacetQuery("aaa (bbb OR ccc) ddd")); + assertEquals("(title:aaa OR content:aaa) " + op + " ((title:bbb OR content:bbb) OR (title:ccc OR content:ccc)) " + op + + " (title:ddd OR content:ddd)", queryHelper.buildFacetQuery("aaa (bbb OR ccc) ddd")); assertEquals( "(title:aaa OR content:aaa) AND ((title:bbb OR content:bbb) OR (title:ccc OR content:ccc)) AND (title:ddd OR content:ddd)", queryHelper.buildFacetQuery("aaa AND (bbb OR ccc) AND ddd")); @@ -1613,29 +1114,21 @@ public class QueryHelperTest extends S2TestCase { "(title:aaa OR content:aaa) OR ((title:bbb OR content:bbb) OR (title:ccc OR content:ccc)) OR (title:ddd OR content:ddd)", queryHelper.buildFacetQuery("aaa OR (bbb OR ccc) OR ddd")); - assertEquals("(title:aaa OR content:aaa) " + op + " (label:bbb " - + op + " (title:ccc OR content:ccc))", + assertEquals("(title:aaa OR content:aaa) " + op + " (label:bbb " + op + " (title:ccc OR content:ccc))", queryHelper.buildFacetQuery("aaa (label:bbb ccc)")); - assertEquals("(title:aaa OR content:aaa) " + op - + " (label:bbb AND (title:ccc OR content:ccc))", + assertEquals("(title:aaa OR content:aaa) " + op + " (label:bbb AND (title:ccc OR content:ccc))", queryHelper.buildFacetQuery("aaa (label:bbb AND ccc)")); - assertEquals("(title:aaa OR content:aaa) " + op - + " (label:bbb OR (title:ccc OR content:ccc))", + assertEquals("(title:aaa OR content:aaa) " + op + " (label:bbb OR (title:ccc OR content:ccc))", queryHelper.buildFacetQuery("aaa (label:bbb OR ccc)")); - assertEquals("(title:aaa OR content:aaa) " + op - + " ((title:bbb OR content:bbb) " + op + " label:ccc)", + assertEquals("(title:aaa OR content:aaa) " + op + " ((title:bbb OR content:bbb) " + op + " label:ccc)", queryHelper.buildFacetQuery("aaa (bbb label:ccc)")); - assertEquals("(title:aaa OR content:aaa) " + op - + " ((title:bbb OR content:bbb) AND label:ccc)", + assertEquals("(title:aaa OR content:aaa) " + op + " ((title:bbb OR content:bbb) AND label:ccc)", queryHelper.buildFacetQuery("aaa (bbb AND label:ccc)")); - assertEquals("(title:aaa OR content:aaa) " + op - + " ((title:bbb OR content:bbb) OR label:ccc)", + assertEquals("(title:aaa OR content:aaa) " + op + " ((title:bbb OR content:bbb) OR label:ccc)", queryHelper.buildFacetQuery("aaa (bbb OR label:ccc)")); - assertEquals("(title:aaa OR content:aaa) " + op - + " ((title:bbb OR content:bbb) " + op - + " NOT (title:ccc OR content:ccc))", + assertEquals("(title:aaa OR content:aaa) " + op + " ((title:bbb OR content:bbb) " + op + " NOT (title:ccc OR content:ccc))", queryHelper.buildFacetQuery("aaa (bbb NOT ccc)")); } } @@ -1643,112 +1136,80 @@ public class QueryHelperTest extends S2TestCase { public void test_more_inner_facetQuery() { for (final String op : new String[] { "AND", "OR" }) { getRequest().setAttribute(Constants.DEFAULT_OPERATOR, op); - assertEquals("(title:aaa OR content:aaa) " + op - + " ((title:bbb OR content:bbb) " + op - + " ((title:ccc OR content:ccc) " + op - + " (title:ddd OR content:ddd)))", - queryHelper.buildFacetQuery("aaa (bbb (ccc ddd))")); - assertEquals("(((title:aaa OR content:aaa) " + op - + " (title:bbb OR content:bbb)) " + op - + " (title:ccc OR content:ccc)) " + op - + " (title:ddd OR content:ddd)", - queryHelper.buildFacetQuery("((aaa bbb) ccc) ddd")); + assertEquals("(title:aaa OR content:aaa) " + op + " ((title:bbb OR content:bbb) " + op + " ((title:ccc OR content:ccc) " + op + + " (title:ddd OR content:ddd)))", queryHelper.buildFacetQuery("aaa (bbb (ccc ddd))")); + assertEquals("(((title:aaa OR content:aaa) " + op + " (title:bbb OR content:bbb)) " + op + " (title:ccc OR content:ccc)) " + op + + " (title:ddd OR content:ddd)", queryHelper.buildFacetQuery("((aaa bbb) ccc) ddd")); } } public void test_quote_query() { - final String[] formats = { "%s", " %s ", "aaa %s", "aaa OR %s", - "NOT %s", "%s bbb", "%s bbb", "%s OR bbb", "aaa (%s)", - "(%s) bbb", "aaa (%s) bbb" }; + final String[] formats = + { "%s", " %s ", "aaa %s", "aaa OR %s", "NOT %s", "%s bbb", "%s bbb", "%s OR bbb", "aaa (%s)", "(%s) bbb", "aaa (%s) bbb" }; for (final String format : formats) { assertException(format, "\"", "errors.invalid_query_quoted"); assertException(format, "a\"", "errors.invalid_query_quoted"); assertException(format, "\"b", "errors.invalid_query_quoted"); assertException(format, "a\"b", "errors.invalid_query_quoted"); assertException(format, "content:\"", "errors.invalid_query_quoted"); - assertException(format, "content:\" ", - "errors.invalid_query_quoted"); - assertException(format, "content:a\"", - "errors.invalid_query_quoted"); - assertException(format, "content:\"b", - "errors.invalid_query_quoted"); - assertException(format, "content:a\"b", - "errors.invalid_query_quoted"); + assertException(format, "content:\" ", "errors.invalid_query_quoted"); + assertException(format, "content:a\"", "errors.invalid_query_quoted"); + assertException(format, "content:\"b", "errors.invalid_query_quoted"); + assertException(format, "content:a\"b", "errors.invalid_query_quoted"); } } public void test_curly_bracket_query() { - final String[] formats = { "%s", " %s ", "aaa %s", "aaa OR %s", - "NOT %s", "%s bbb", "%s bbb", "%s OR bbb", "aaa (%s)", - "(%s) bbb", "aaa (%s) bbb" }; + final String[] formats = + { "%s", " %s ", "aaa %s", "aaa OR %s", "NOT %s", "%s bbb", "%s bbb", "%s OR bbb", "aaa (%s)", "(%s) bbb", "aaa (%s) bbb" }; for (final String format : formats) { assertException(format, "{", "errors.invalid_query_curly_bracket"); assertException(format, "a{", "errors.invalid_query_curly_bracket"); assertException(format, "{b", "errors.invalid_query_curly_bracket"); assertException(format, "a{b", "errors.invalid_query_curly_bracket"); - assertException(format, "content:{", - "errors.invalid_query_curly_bracket"); - assertException(format, "content:{ ", - "errors.invalid_query_curly_bracket"); - assertException(format, "content:a{", - "errors.invalid_query_curly_bracket"); - assertException(format, "content:{b", - "errors.invalid_query_curly_bracket"); - assertException(format, "content:a{b", - "errors.invalid_query_curly_bracket"); + assertException(format, "content:{", "errors.invalid_query_curly_bracket"); + assertException(format, "content:{ ", "errors.invalid_query_curly_bracket"); + assertException(format, "content:a{", "errors.invalid_query_curly_bracket"); + assertException(format, "content:{b", "errors.invalid_query_curly_bracket"); + assertException(format, "content:a{b", "errors.invalid_query_curly_bracket"); } } public void test_square_bracket_query() { - final String[] formats = { "%s", " %s ", "aaa %s", "aaa OR %s", - "NOT %s", "%s bbb", "%s bbb", "%s OR bbb", "aaa (%s)", - "(%s) bbb", "aaa (%s) bbb" }; + final String[] formats = + { "%s", " %s ", "aaa %s", "aaa OR %s", "NOT %s", "%s bbb", "%s bbb", "%s OR bbb", "aaa (%s)", "(%s) bbb", "aaa (%s) bbb" }; for (final String format : formats) { assertException(format, "[", "errors.invalid_query_square_bracket"); assertException(format, "a[", "errors.invalid_query_square_bracket"); assertException(format, "[b", "errors.invalid_query_square_bracket"); - assertException(format, "a[b", - "errors.invalid_query_square_bracket"); - assertException(format, "content:[", - "errors.invalid_query_square_bracket"); - assertException(format, "content:[ ", - "errors.invalid_query_square_bracket"); - assertException(format, "content:a[", - "errors.invalid_query_square_bracket"); - assertException(format, "content:[b", - "errors.invalid_query_square_bracket"); - assertException(format, "content:a[b", - "errors.invalid_query_square_bracket"); + assertException(format, "a[b", "errors.invalid_query_square_bracket"); + assertException(format, "content:[", "errors.invalid_query_square_bracket"); + assertException(format, "content:[ ", "errors.invalid_query_square_bracket"); + assertException(format, "content:a[", "errors.invalid_query_square_bracket"); + assertException(format, "content:[b", "errors.invalid_query_square_bracket"); + assertException(format, "content:a[b", "errors.invalid_query_square_bracket"); } } public void test_parenthesis_query() { - final String[] formats = { "%s", " %s ", "aaa %s", "aaa OR %s", - "NOT %s", "%s bbb", "%s bbb", "%s OR bbb", "aaa (%s)", - "(%s) bbb", "aaa (%s) bbb" }; + final String[] formats = + { "%s", " %s ", "aaa %s", "aaa OR %s", "NOT %s", "%s bbb", "%s bbb", "%s OR bbb", "aaa (%s)", "(%s) bbb", "aaa (%s) bbb" }; for (final String format : formats) { assertException(format, "(", "errors.invalid_query_parenthesis"); assertException(format, "a(", "errors.invalid_query_parenthesis"); assertException(format, "(b", "errors.invalid_query_parenthesis"); assertException(format, "a(b", "errors.invalid_query_parenthesis"); - assertException(format, "content:(", - "errors.invalid_query_parenthesis"); - assertException(format, "content:( ", - "errors.invalid_query_parenthesis"); - assertException(format, "content:a(", - "errors.invalid_query_parenthesis"); - assertException(format, "content:(b", - "errors.invalid_query_parenthesis"); - assertException(format, "content:a(b", - "errors.invalid_query_parenthesis"); + assertException(format, "content:(", "errors.invalid_query_parenthesis"); + assertException(format, "content:( ", "errors.invalid_query_parenthesis"); + assertException(format, "content:a(", "errors.invalid_query_parenthesis"); + assertException(format, "content:(b", "errors.invalid_query_parenthesis"); + assertException(format, "content:a(b", "errors.invalid_query_parenthesis"); } } - private void assertException(final String format, final String query, - final String messageCode) { + private void assertException(final String format, final String query, final String messageCode) { try { - final String ret = queryHelper.buildQuery( - String.format(format, query)).getQuery(); + final String ret = queryHelper.buildQuery(String.format(format, query)).getQuery(); fail("format: " + format + ", query: " + query + ", ret: " + ret); } catch (final InvalidQueryException e) { if (!messageCode.equals(e.getMessageCode())) { @@ -1758,106 +1219,66 @@ public class QueryHelperTest extends S2TestCase { } public void test_quote_facetQuery() { - final String[] formats = { "%s", " %s ", "aaa %s", "aaa OR %s", - "NOT %s", "%s bbb", "%s bbb", "%s OR bbb", "aaa (%s)", - "(%s) bbb", "aaa (%s) bbb" }; + final String[] formats = + { "%s", " %s ", "aaa %s", "aaa OR %s", "NOT %s", "%s bbb", "%s bbb", "%s OR bbb", "aaa (%s)", "(%s) bbb", "aaa (%s) bbb" }; for (final String format : formats) { - assertExceptionOnFacetQuery(format, "\"", - "errors.invalid_query_quoted"); - assertExceptionOnFacetQuery(format, "a\"", - "errors.invalid_query_quoted"); - assertExceptionOnFacetQuery(format, "\"b", - "errors.invalid_query_quoted"); - assertExceptionOnFacetQuery(format, "a\"b", - "errors.invalid_query_quoted"); - assertExceptionOnFacetQuery(format, "content:\"", - "errors.invalid_query_quoted"); - assertExceptionOnFacetQuery(format, "content:\" ", - "errors.invalid_query_quoted"); - assertExceptionOnFacetQuery(format, "content:a\"", - "errors.invalid_query_quoted"); - assertExceptionOnFacetQuery(format, "content:\"b", - "errors.invalid_query_quoted"); - assertExceptionOnFacetQuery(format, "content:a\"b", - "errors.invalid_query_quoted"); + assertExceptionOnFacetQuery(format, "\"", "errors.invalid_query_quoted"); + assertExceptionOnFacetQuery(format, "a\"", "errors.invalid_query_quoted"); + assertExceptionOnFacetQuery(format, "\"b", "errors.invalid_query_quoted"); + assertExceptionOnFacetQuery(format, "a\"b", "errors.invalid_query_quoted"); + assertExceptionOnFacetQuery(format, "content:\"", "errors.invalid_query_quoted"); + assertExceptionOnFacetQuery(format, "content:\" ", "errors.invalid_query_quoted"); + assertExceptionOnFacetQuery(format, "content:a\"", "errors.invalid_query_quoted"); + assertExceptionOnFacetQuery(format, "content:\"b", "errors.invalid_query_quoted"); + assertExceptionOnFacetQuery(format, "content:a\"b", "errors.invalid_query_quoted"); } } public void test_curly_bracket_facetQuery() { - final String[] formats = { "%s", " %s ", "aaa %s", "aaa OR %s", - "NOT %s", "%s bbb", "%s bbb", "%s OR bbb", "aaa (%s)", - "(%s) bbb", "aaa (%s) bbb" }; + final String[] formats = + { "%s", " %s ", "aaa %s", "aaa OR %s", "NOT %s", "%s bbb", "%s bbb", "%s OR bbb", "aaa (%s)", "(%s) bbb", "aaa (%s) bbb" }; for (final String format : formats) { - assertExceptionOnFacetQuery(format, "{", - "errors.invalid_query_curly_bracket"); - assertExceptionOnFacetQuery(format, "a{", - "errors.invalid_query_curly_bracket"); - assertExceptionOnFacetQuery(format, "{b", - "errors.invalid_query_curly_bracket"); - assertExceptionOnFacetQuery(format, "a{b", - "errors.invalid_query_curly_bracket"); - assertExceptionOnFacetQuery(format, "content:{", - "errors.invalid_query_curly_bracket"); - assertExceptionOnFacetQuery(format, "content:{ ", - "errors.invalid_query_curly_bracket"); - assertExceptionOnFacetQuery(format, "content:a{", - "errors.invalid_query_curly_bracket"); - assertExceptionOnFacetQuery(format, "content:{b", - "errors.invalid_query_curly_bracket"); - assertExceptionOnFacetQuery(format, "content:a{b", - "errors.invalid_query_curly_bracket"); + assertExceptionOnFacetQuery(format, "{", "errors.invalid_query_curly_bracket"); + assertExceptionOnFacetQuery(format, "a{", "errors.invalid_query_curly_bracket"); + assertExceptionOnFacetQuery(format, "{b", "errors.invalid_query_curly_bracket"); + assertExceptionOnFacetQuery(format, "a{b", "errors.invalid_query_curly_bracket"); + assertExceptionOnFacetQuery(format, "content:{", "errors.invalid_query_curly_bracket"); + assertExceptionOnFacetQuery(format, "content:{ ", "errors.invalid_query_curly_bracket"); + assertExceptionOnFacetQuery(format, "content:a{", "errors.invalid_query_curly_bracket"); + assertExceptionOnFacetQuery(format, "content:{b", "errors.invalid_query_curly_bracket"); + assertExceptionOnFacetQuery(format, "content:a{b", "errors.invalid_query_curly_bracket"); } } public void test_square_bracket_facetQuery() { - final String[] formats = { "%s", " %s ", "aaa %s", "aaa OR %s", - "NOT %s", "%s bbb", "%s bbb", "%s OR bbb", "aaa (%s)", - "(%s) bbb", "aaa (%s) bbb" }; + final String[] formats = + { "%s", " %s ", "aaa %s", "aaa OR %s", "NOT %s", "%s bbb", "%s bbb", "%s OR bbb", "aaa (%s)", "(%s) bbb", "aaa (%s) bbb" }; for (final String format : formats) { - assertExceptionOnFacetQuery(format, "[", - "errors.invalid_query_square_bracket"); - assertExceptionOnFacetQuery(format, "a[", - "errors.invalid_query_square_bracket"); - assertExceptionOnFacetQuery(format, "[b", - "errors.invalid_query_square_bracket"); - assertExceptionOnFacetQuery(format, "a[b", - "errors.invalid_query_square_bracket"); - assertExceptionOnFacetQuery(format, "content:[", - "errors.invalid_query_square_bracket"); - assertExceptionOnFacetQuery(format, "content:[ ", - "errors.invalid_query_square_bracket"); - assertExceptionOnFacetQuery(format, "content:a[", - "errors.invalid_query_square_bracket"); - assertExceptionOnFacetQuery(format, "content:[b", - "errors.invalid_query_square_bracket"); - assertExceptionOnFacetQuery(format, "content:a[b", - "errors.invalid_query_square_bracket"); + assertExceptionOnFacetQuery(format, "[", "errors.invalid_query_square_bracket"); + assertExceptionOnFacetQuery(format, "a[", "errors.invalid_query_square_bracket"); + assertExceptionOnFacetQuery(format, "[b", "errors.invalid_query_square_bracket"); + assertExceptionOnFacetQuery(format, "a[b", "errors.invalid_query_square_bracket"); + assertExceptionOnFacetQuery(format, "content:[", "errors.invalid_query_square_bracket"); + assertExceptionOnFacetQuery(format, "content:[ ", "errors.invalid_query_square_bracket"); + assertExceptionOnFacetQuery(format, "content:a[", "errors.invalid_query_square_bracket"); + assertExceptionOnFacetQuery(format, "content:[b", "errors.invalid_query_square_bracket"); + assertExceptionOnFacetQuery(format, "content:a[b", "errors.invalid_query_square_bracket"); } } public void test_parenthesis_facetQuery() { - final String[] formats = { "%s", " %s ", "aaa %s", "aaa OR %s", - "NOT %s", "%s bbb", "%s bbb", "%s OR bbb", "aaa (%s)", - "(%s) bbb", "aaa (%s) bbb" }; + final String[] formats = + { "%s", " %s ", "aaa %s", "aaa OR %s", "NOT %s", "%s bbb", "%s bbb", "%s OR bbb", "aaa (%s)", "(%s) bbb", "aaa (%s) bbb" }; for (final String format : formats) { - assertExceptionOnFacetQuery(format, "(", - "errors.invalid_query_parenthesis"); - assertExceptionOnFacetQuery(format, "a(", - "errors.invalid_query_parenthesis"); - assertExceptionOnFacetQuery(format, "(b", - "errors.invalid_query_parenthesis"); - assertExceptionOnFacetQuery(format, "a(b", - "errors.invalid_query_parenthesis"); - assertExceptionOnFacetQuery(format, "content:(", - "errors.invalid_query_parenthesis"); - assertExceptionOnFacetQuery(format, "content:( ", - "errors.invalid_query_parenthesis"); - assertExceptionOnFacetQuery(format, "content:a(", - "errors.invalid_query_parenthesis"); - assertExceptionOnFacetQuery(format, "content:(b", - "errors.invalid_query_parenthesis"); - assertExceptionOnFacetQuery(format, "content:a(b", - "errors.invalid_query_parenthesis"); + assertExceptionOnFacetQuery(format, "(", "errors.invalid_query_parenthesis"); + assertExceptionOnFacetQuery(format, "a(", "errors.invalid_query_parenthesis"); + assertExceptionOnFacetQuery(format, "(b", "errors.invalid_query_parenthesis"); + assertExceptionOnFacetQuery(format, "a(b", "errors.invalid_query_parenthesis"); + assertExceptionOnFacetQuery(format, "content:(", "errors.invalid_query_parenthesis"); + assertExceptionOnFacetQuery(format, "content:( ", "errors.invalid_query_parenthesis"); + assertExceptionOnFacetQuery(format, "content:a(", "errors.invalid_query_parenthesis"); + assertExceptionOnFacetQuery(format, "content:(b", "errors.invalid_query_parenthesis"); + assertExceptionOnFacetQuery(format, "content:a(b", "errors.invalid_query_parenthesis"); } } @@ -1870,19 +1291,16 @@ public class QueryHelperTest extends S2TestCase { buf = new StringBuilder(); queryHelper.buildContentQueryWithLang(buf, "aaa", "ja"); - assertEquals("(title:aaa OR content:aaa OR content_ja:aaa)", - buf.toString()); + assertEquals("(title:aaa OR content:aaa OR content_ja:aaa)", buf.toString()); buf = new StringBuilder(); queryHelper.buildContentQueryWithLang(buf, "aaa", "zh_CN"); - assertEquals("(title:aaa OR content:aaa OR content_zh_CN:aaa)", - buf.toString()); + assertEquals("(title:aaa OR content:aaa OR content_zh_CN:aaa)", buf.toString()); } public void test_getQueryLanguage() { assertNull(queryHelper.getQueryLanguage()); - final MockHttpServletRequest request = (MockHttpServletRequest) RequestUtil - .getRequest(); + final MockHttpServletRequest request = (MockHttpServletRequest) RequestUtil.getRequest(); request.setLocale(Locale.JAPAN); assertEquals("ja", queryHelper.getQueryLanguage()); request.setLocale(Locale.SIMPLIFIED_CHINESE); @@ -1898,42 +1316,26 @@ public class QueryHelperTest extends S2TestCase { } public void test_buildWithLang() { - final MockHttpServletRequest request = (MockHttpServletRequest) RequestUtil - .getRequest(); + final MockHttpServletRequest request = (MockHttpServletRequest) RequestUtil.getRequest(); request.setLocale(Locale.JAPAN); for (final String op : new String[] { "AND", "OR" }) { getRequest().setAttribute(Constants.DEFAULT_OPERATOR, op); assertEquals("", queryHelper.buildQuery("").getQuery()); - assertEquals("title:QUERY OR content:QUERY OR content_ja:QUERY", - queryHelper.buildQuery("QUERY").getQuery()); - assertEquals("title:QUERY OR content:QUERY OR content_ja:QUERY", - queryHelper.buildQuery("QUERY ").getQuery()); - assertEquals("title:QUERY OR content:QUERY OR content_ja:QUERY", - queryHelper.buildQuery(" QUERY").getQuery()); + assertEquals("title:QUERY OR content:QUERY OR content_ja:QUERY", queryHelper.buildQuery("QUERY").getQuery()); + assertEquals("title:QUERY OR content:QUERY OR content_ja:QUERY", queryHelper.buildQuery("QUERY ").getQuery()); + assertEquals("title:QUERY OR content:QUERY OR content_ja:QUERY", queryHelper.buildQuery(" QUERY").getQuery()); - assertEquals( - "(title:QUERY1 OR content:QUERY1 OR content_ja:QUERY1) " - + op - + " NOT (title:QUERY2 OR content:QUERY2 OR content_ja:QUERY2)", - queryHelper.buildQuery("QUERY1 NOT QUERY2").getQuery()); + assertEquals("(title:QUERY1 OR content:QUERY1 OR content_ja:QUERY1) " + op + + " NOT (title:QUERY2 OR content:QUERY2 OR content_ja:QUERY2)", queryHelper.buildQuery("QUERY1 NOT QUERY2").getQuery()); - assertEquals( - "(title:QUERY1 OR content:QUERY1 OR content_ja:QUERY1) " - + op - + " (title:QUERY2 OR content:QUERY2 OR content_ja:QUERY2)", - queryHelper.buildQuery("QUERY1 QUERY2").getQuery()); - assertEquals( - "(title:QUERY1 OR content:QUERY1 OR content_ja:QUERY1) " - + op - + " (title:QUERY2 OR content:QUERY2 OR content_ja:QUERY2)", - queryHelper.buildQuery("QUERY1 QUERY2 ").getQuery()); - assertEquals( - "(title:QUERY1 OR content:QUERY1 OR content_ja:QUERY1) " - + op - + " (title:QUERY2 OR content:QUERY2 OR content_ja:QUERY2)", - queryHelper.buildQuery(" QUERY1 QUERY2").getQuery()); + assertEquals("(title:QUERY1 OR content:QUERY1 OR content_ja:QUERY1) " + op + + " (title:QUERY2 OR content:QUERY2 OR content_ja:QUERY2)", queryHelper.buildQuery("QUERY1 QUERY2").getQuery()); + assertEquals("(title:QUERY1 OR content:QUERY1 OR content_ja:QUERY1) " + op + + " (title:QUERY2 OR content:QUERY2 OR content_ja:QUERY2)", queryHelper.buildQuery("QUERY1 QUERY2 ").getQuery()); + assertEquals("(title:QUERY1 OR content:QUERY1 OR content_ja:QUERY1) " + op + + " (title:QUERY2 OR content:QUERY2 OR content_ja:QUERY2)", queryHelper.buildQuery(" QUERY1 QUERY2").getQuery()); } } @@ -1983,53 +1385,42 @@ public class QueryHelperTest extends S2TestCase { try { queryHelper.appendRangeQueryValue(buf, "[* TO *]", '[', ']'); fail(); - } catch (final InvalidQueryException e) { - } + } catch (final InvalidQueryException e) {} try { queryHelper.appendRangeQueryValue(buf, "[1]", '[', ']'); fail(); - } catch (final InvalidQueryException e) { - } + } catch (final InvalidQueryException e) {} try { queryHelper.appendRangeQueryValue(buf, "[1 TO]", '[', ']'); fail(); - } catch (final InvalidQueryException e) { - } + } catch (final InvalidQueryException e) {} try { queryHelper.appendRangeQueryValue(buf, "[1 TO ]", '[', ']'); fail(); - } catch (final InvalidQueryException e) { - } + } catch (final InvalidQueryException e) {} try { queryHelper.appendRangeQueryValue(buf, "[TO 1]", '[', ']'); fail(); - } catch (final InvalidQueryException e) { - } + } catch (final InvalidQueryException e) {} try { queryHelper.appendRangeQueryValue(buf, "[ TO 1]", '[', ']'); fail(); - } catch (final InvalidQueryException e) { - } + } catch (final InvalidQueryException e) {} } public void test_inurl() { for (final String op : new String[] { "AND", "OR" }) { getRequest().setAttribute(Constants.DEFAULT_OPERATOR, op); - assertEquals("url:*QUERY*", queryHelper.buildQuery("inurl:QUERY") - .getQuery()); - assertEquals("url:*QUERY1* " + op + " url:*QUERY2*", queryHelper - .buildQuery("inurl:QUERY1 inurl:QUERY2").getQuery()); - assertEquals("(title:aaa OR content:aaa) " + op + " url:*QUERY1* " - + op + " url:*QUERY2*", - queryHelper.buildQuery("aaa inurl:QUERY1 inurl:QUERY2") - .getQuery()); - assertEquals("url:*QUERY*", - queryHelper.buildQuery("inurl:\"QUERY\"").getQuery()); + assertEquals("url:*QUERY*", queryHelper.buildQuery("inurl:QUERY").getQuery()); + assertEquals("url:*QUERY1* " + op + " url:*QUERY2*", queryHelper.buildQuery("inurl:QUERY1 inurl:QUERY2").getQuery()); + assertEquals("(title:aaa OR content:aaa) " + op + " url:*QUERY1* " + op + " url:*QUERY2*", + queryHelper.buildQuery("aaa inurl:QUERY1 inurl:QUERY2").getQuery()); + assertEquals("url:*QUERY*", queryHelper.buildQuery("inurl:\"QUERY\"").getQuery()); } } @@ -2062,8 +1453,7 @@ public class QueryHelperTest extends S2TestCase { assertEquals("\"a b\" c", queryHelper.buildOptionQuery(options)); options.clear(); - options.put(Constants.OPTION_QUERY_Q, - new String[] { "\"a b\" \"c d\"" }); + options.put(Constants.OPTION_QUERY_Q, new String[] { "\"a b\" \"c d\"" }); assertEquals("\"a b\" \"c d\"", queryHelper.buildOptionQuery(options)); // CQ @@ -2089,8 +1479,7 @@ public class QueryHelperTest extends S2TestCase { assertEquals("\"a b\" \"c\"", queryHelper.buildOptionQuery(options)); options.clear(); - options.put(Constants.OPTION_QUERY_CQ, - new String[] { "\"a b\" \"c d\"" }); + options.put(Constants.OPTION_QUERY_CQ, new String[] { "\"a b\" \"c d\"" }); assertEquals("\"a b\" \"c d\"", queryHelper.buildOptionQuery(options)); // OQ @@ -2116,10 +1505,8 @@ public class QueryHelperTest extends S2TestCase { assertEquals("\"a b\" OR c", queryHelper.buildOptionQuery(options)); options.clear(); - options.put(Constants.OPTION_QUERY_OQ, - new String[] { "\"a b\" \"c d\"" }); - assertEquals("\"a b\" OR \"c d\"", - queryHelper.buildOptionQuery(options)); + options.put(Constants.OPTION_QUERY_OQ, new String[] { "\"a b\" \"c d\"" }); + assertEquals("\"a b\" OR \"c d\"", queryHelper.buildOptionQuery(options)); // NQ @@ -2144,10 +1531,8 @@ public class QueryHelperTest extends S2TestCase { assertEquals("NOT \"a b\" NOT c", queryHelper.buildOptionQuery(options)); options.clear(); - options.put(Constants.OPTION_QUERY_NQ, - new String[] { "\"a b\" \"c d\"" }); - assertEquals("NOT \"a b\" NOT \"c d\"", - queryHelper.buildOptionQuery(options)); + options.put(Constants.OPTION_QUERY_NQ, new String[] { "\"a b\" \"c d\"" }); + assertEquals("NOT \"a b\" NOT \"c d\"", queryHelper.buildOptionQuery(options)); // combine @@ -2163,15 +1548,12 @@ public class QueryHelperTest extends S2TestCase { options.put(Constants.OPTION_QUERY_CQ, new String[] { "b 2" }); options.put(Constants.OPTION_QUERY_OQ, new String[] { "c 3" }); options.put(Constants.OPTION_QUERY_NQ, new String[] { "d 4" }); - assertEquals("a 1 \"b 2\" (c OR 3) NOT d NOT 4", - queryHelper.buildOptionQuery(options)); + assertEquals("a 1 \"b 2\" (c OR 3) NOT d NOT 4", queryHelper.buildOptionQuery(options)); } - private void assertExceptionOnFacetQuery(final String format, - final String query, final String messageCode) { + private void assertExceptionOnFacetQuery(final String format, final String query, final String messageCode) { try { - final String ret = queryHelper.buildFacetQuery(String.format( - format, query)); + final String ret = queryHelper.buildFacetQuery(String.format(format, query)); fail("format: " + format + ", query: " + query + ", ret: " + ret); } catch (final InvalidQueryException e) { if (!messageCode.equals(e.getMessageCode())) { diff --git a/src/test/java/org/codelibs/fess/helper/SystemHelperTest.java b/src/test/java/org/codelibs/fess/helper/SystemHelperTest.java index 71848c8ae..64231ec37 100644 --- a/src/test/java/org/codelibs/fess/helper/SystemHelperTest.java +++ b/src/test/java/org/codelibs/fess/helper/SystemHelperTest.java @@ -34,8 +34,7 @@ public class SystemHelperTest extends S2TestCase { assertEquals(path, systemHelper.encodeUrlFilter(path)); path = "あいう"; - assertEquals("%E3%81%82%E3%81%84%E3%81%86", - systemHelper.encodeUrlFilter(path)); + assertEquals("%E3%81%82%E3%81%84%E3%81%86", systemHelper.encodeUrlFilter(path)); path = "[]^$.*+?,{}|%\\"; assertEquals(path, systemHelper.encodeUrlFilter(path)); diff --git a/src/test/java/org/codelibs/fess/helper/ViewHelperTest.java b/src/test/java/org/codelibs/fess/helper/ViewHelperTest.java index 8c29dfa50..9869e67a2 100644 --- a/src/test/java/org/codelibs/fess/helper/ViewHelperTest.java +++ b/src/test/java/org/codelibs/fess/helper/ViewHelperTest.java @@ -35,18 +35,15 @@ public class ViewHelperTest extends S2TestCase { text = "123456"; queries = new String[] { "123", "456" }; - assertEquals("123456", - viewHelper.replaceHighlightQueries(text, queries)); + assertEquals("123456", viewHelper.replaceHighlightQueries(text, queries)); text = "<123><456>"; queries = new String[] { "123", "456" }; - assertEquals("<123><456>", - viewHelper.replaceHighlightQueries(text, queries)); + assertEquals("<123><456>", viewHelper.replaceHighlightQueries(text, queries)); text = "123456123"; queries = new String[] { "123", "456" }; - assertEquals("123456123", - viewHelper.replaceHighlightQueries(text, queries)); + assertEquals("123456123", viewHelper.replaceHighlightQueries(text, queries)); text = "abc"; queries = new String[] { "123" }; @@ -54,38 +51,31 @@ public class ViewHelperTest extends S2TestCase { text = "123"; queries = new String[] { "123" }; - assertEquals("123", - viewHelper.replaceHighlightQueries(text, queries)); + assertEquals("123", viewHelper.replaceHighlightQueries(text, queries)); text = "abc123efg"; queries = new String[] { "123" }; - assertEquals("abc123efg", - viewHelper.replaceHighlightQueries(text, queries)); + assertEquals("abc123efg", viewHelper.replaceHighlightQueries(text, queries)); text = "123"; queries = new String[] { "123", "456" }; - assertEquals("123", - viewHelper.replaceHighlightQueries(text, queries)); + assertEquals("123", viewHelper.replaceHighlightQueries(text, queries)); text = "123456"; queries = new String[] { "123", "456" }; - assertEquals("123456", - viewHelper.replaceHighlightQueries(text, queries)); + assertEquals("123456", viewHelper.replaceHighlightQueries(text, queries)); text = "a123b456c"; queries = new String[] { "123", "456" }; - assertEquals("a123b456c", - viewHelper.replaceHighlightQueries(text, queries)); + assertEquals("a123b456c", viewHelper.replaceHighlightQueries(text, queries)); text = "abc"; queries = new String[] { "abc" }; - assertEquals("abc", - viewHelper.replaceHighlightQueries(text, queries)); + assertEquals("abc", viewHelper.replaceHighlightQueries(text, queries)); text = "1ABC2"; queries = new String[] { "abc" }; - assertEquals("1abc2", - viewHelper.replaceHighlightQueries(text, queries)); + assertEquals("1abc2", viewHelper.replaceHighlightQueries(text, queries)); } public void test_escapeHighlight() { @@ -103,8 +93,7 @@ public class ViewHelperTest extends S2TestCase { assertEquals("aaa", viewHelper.escapeHighlight(text)); text = "aaabbb"; - assertEquals("aaa<b>bbb</b>", - viewHelper.escapeHighlight(text)); + assertEquals("aaa<b>bbb</b>", viewHelper.escapeHighlight(text)); } diff --git a/src/test/java/org/codelibs/fess/helper/impl/RoleQueryHelperImplTest.java b/src/test/java/org/codelibs/fess/helper/impl/RoleQueryHelperImplTest.java index 88839ab6f..fbbc1139d 100644 --- a/src/test/java/org/codelibs/fess/helper/impl/RoleQueryHelperImplTest.java +++ b/src/test/java/org/codelibs/fess/helper/impl/RoleQueryHelperImplTest.java @@ -59,8 +59,7 @@ public class RoleQueryHelperImplTest extends S2TestCase { roleQueryHelperImpl.cipher = cipher; roleQueryHelperImpl.encryptedParameterValue = true; - getRequest().setParameter("fess2", - cipher.encryptoText("xxx\nrole1,role2,role3")); + getRequest().setParameter("fess2", cipher.encryptoText("xxx\nrole1,role2,role3")); roleSet = roleQueryHelperImpl.buildByParameter(getRequest()); assertEquals(3, roleSet.size()); assertTrue(roleSet.contains("role1")); @@ -120,8 +119,7 @@ public class RoleQueryHelperImplTest extends S2TestCase { roleQueryHelperImpl.cipher = cipher; roleQueryHelperImpl.encryptedHeaderValue = true; - getRequest().addHeader("fess2", - cipher.encryptoText("xxx\nrole1,role2,role3")); + getRequest().addHeader("fess2", cipher.encryptoText("xxx\nrole1,role2,role3")); roleSet = roleQueryHelperImpl.buildByHeader(getRequest()); assertEquals(3, roleSet.size()); assertTrue(roleSet.contains("role1")); @@ -187,8 +185,7 @@ public class RoleQueryHelperImplTest extends S2TestCase { roleQueryHelperImpl.cipher = cipher; roleQueryHelperImpl.encryptedCookieValue = true; - cookie = new Cookie("fess2", - cipher.encryptoText("xxx\nrole1,role2,role3")); + cookie = new Cookie("fess2", cipher.encryptoText("xxx\nrole1,role2,role3")); getRequest().addCookie(cookie); roleSet = roleQueryHelperImpl.buildByCookie(getRequest()); assertEquals(3, roleSet.size()); diff --git a/src/test/java/org/codelibs/fess/transformer/FessXpathTransformerTest.java b/src/test/java/org/codelibs/fess/transformer/FessXpathTransformerTest.java index 7e42e300d..5dd560e1a 100644 --- a/src/test/java/org/codelibs/fess/transformer/FessXpathTransformerTest.java +++ b/src/test/java/org/codelibs/fess/transformer/FessXpathTransformerTest.java @@ -102,8 +102,7 @@ public class FessXpathTransformerTest extends S2TestCase { private Document getDocument(final String data) throws Exception { final DOMParser parser = new DOMParser(); - final ByteArrayInputStream is = new ByteArrayInputStream( - data.getBytes("UTF-8")); + final ByteArrayInputStream is = new ByteArrayInputStream(data.getBytes("UTF-8")); parser.parse(new InputSource(is)); return parser.getDocument(); } @@ -186,27 +185,22 @@ public class FessXpathTransformerTest extends S2TestCase { assertEquals(0, urlList.size()); urlList.clear(); - urlList.add(RequestDataBuilder.newRequestData().get() - .url("http://www.example.com").build()); + urlList.add(RequestDataBuilder.newRequestData().get().url("http://www.example.com").build()); urlList = fessXpathTransformer.convertChildUrlList(urlList); assertEquals(1, urlList.size()); assertEquals("http://www.example.com", urlList.get(0).getUrl()); urlList.clear(); - urlList.add(RequestDataBuilder.newRequestData().get() - .url("http://www.example.com").build()); - urlList.add(RequestDataBuilder.newRequestData().get() - .url("http://www.test.com").build()); + urlList.add(RequestDataBuilder.newRequestData().get().url("http://www.example.com").build()); + urlList.add(RequestDataBuilder.newRequestData().get().url("http://www.test.com").build()); urlList = fessXpathTransformer.convertChildUrlList(urlList); assertEquals(2, urlList.size()); assertEquals("http://www.example.com", urlList.get(0).getUrl()); assertEquals("http://www.test.com", urlList.get(1).getUrl()); urlList.clear(); - urlList.add(RequestDataBuilder.newRequestData().get() - .url("feed://www.example.com").build()); - urlList.add(RequestDataBuilder.newRequestData().get() - .url("http://www.test.com").build()); + urlList.add(RequestDataBuilder.newRequestData().get().url("feed://www.example.com").build()); + urlList.add(RequestDataBuilder.newRequestData().get().url("http://www.test.com").build()); urlList = fessXpathTransformer.convertChildUrlList(urlList); assertEquals(2, urlList.size()); assertEquals("http://www.example.com", urlList.get(0).getUrl()); @@ -227,30 +221,16 @@ public class FessXpathTransformerTest extends S2TestCase { assertEquals("", fessXpathTransformer.removeCommentTag("")); assertEquals(" ", fessXpathTransformer.removeCommentTag("")); assertEquals("abc", fessXpathTransformer.removeCommentTag("abc")); - assertEquals("abc ", - fessXpathTransformer.removeCommentTag("abc")); - assertEquals("abc 123", - fessXpathTransformer.removeCommentTag("abc123")); - assertEquals("abc 123", - fessXpathTransformer.removeCommentTag("abc123")); - assertEquals("abc 123", - fessXpathTransformer.removeCommentTag("abc123")); - assertEquals("abc 123 ", - fessXpathTransformer - .removeCommentTag("abc123")); - assertEquals( - "abc 123 xyz", - fessXpathTransformer - .removeCommentTag("abc123xyz")); - assertEquals("abc ", - fessXpathTransformer.removeCommentTag("abc")); - assertEquals("abc -->", - fessXpathTransformer.removeCommentTag("abc-->")); - assertEquals("abc123", - fessXpathTransformer - .removeCommentTag("abc -->123")); + assertEquals("abc ", fessXpathTransformer.removeCommentTag("abc")); + assertEquals("abc 123", fessXpathTransformer.removeCommentTag("abc123")); + assertEquals("abc 123", fessXpathTransformer.removeCommentTag("abc123")); + assertEquals("abc 123", fessXpathTransformer.removeCommentTag("abc123")); + assertEquals("abc 123 ", fessXpathTransformer.removeCommentTag("abc123")); + assertEquals("abc 123 xyz", fessXpathTransformer.removeCommentTag("abc123xyz")); + assertEquals("abc ", fessXpathTransformer.removeCommentTag("abc")); + assertEquals("abc -->", fessXpathTransformer.removeCommentTag("abc-->")); + assertEquals("abc123", fessXpathTransformer.removeCommentTag("abc -->123")); } public void test_canonicalXpath() throws Exception { @@ -286,8 +266,7 @@ public class FessXpathTransformerTest extends S2TestCase { } catch (final ChildUrlsException e) { final Set childUrlList = e.getChildUrlList(); assertEquals(1, childUrlList.size()); - assertEquals("http://example.com/hoge", childUrlList.iterator() - .next().getUrl()); + assertEquals("http://example.com/hoge", childUrlList.iterator().next().getUrl()); } data = "aaa"; @@ -298,8 +277,7 @@ public class FessXpathTransformerTest extends S2TestCase { } catch (final ChildUrlsException e) { final Set childUrlList = e.getChildUrlList(); assertEquals(1, childUrlList.size()); - assertEquals("http://example.com/hoge", childUrlList.iterator() - .next().getUrl()); + assertEquals("http://example.com/hoge", childUrlList.iterator().next().getUrl()); } } @@ -308,16 +286,13 @@ public class FessXpathTransformerTest extends S2TestCase { final String data = "aaa"; final Document document = getDocument(data); - String value = transformer - .getSingleNodeValue(document, "//BODY", false); + String value = transformer.getSingleNodeValue(document, "//BODY", false); assertEquals("aaa", value); - value = transformer.getSingleNodeValue(document, - "//META[@name='keywords']/@content", false); + value = transformer.getSingleNodeValue(document, "//META[@name='keywords']/@content", false); assertEquals("bbb", value); - value = transformer.getSingleNodeValue(document, - "//META[@name='keywords']/@content|//BODY", false); + value = transformer.getSingleNodeValue(document, "//META[@name='keywords']/@content|//BODY", false); assertEquals("bbb aaa", value); } }