diff --git a/src/main/java/jp/sf/fess/action/IndexAction.java b/src/main/java/jp/sf/fess/action/IndexAction.java index d05ef22e2..7d0c49c41 100644 --- a/src/main/java/jp/sf/fess/action/IndexAction.java +++ b/src/main/java/jp/sf/fess/action/IndexAction.java @@ -621,7 +621,7 @@ public class IndexAction { return null; } - if (!favoriteLogService.addUrl(userCode, favoriteUrl)) { + if (!favoriteLogService.addUrl(userCode, favoriteUrl, doc)) { WebApiUtil.setError(4, "Failed to add url: " + favoriteUrl); return null; } diff --git a/src/main/java/jp/sf/fess/ds/impl/AbstractDataStoreImpl.java b/src/main/java/jp/sf/fess/ds/impl/AbstractDataStoreImpl.java index f41ffcc85..66ef0c877 100644 --- a/src/main/java/jp/sf/fess/ds/impl/AbstractDataStoreImpl.java +++ b/src/main/java/jp/sf/fess/ds/impl/AbstractDataStoreImpl.java @@ -26,8 +26,8 @@ import jp.sf.fess.Constants; import jp.sf.fess.db.exentity.DataCrawlingConfig; import jp.sf.fess.ds.DataStore; import jp.sf.fess.ds.IndexUpdateCallback; -import jp.sf.fess.helper.CrawlingConfigHelper; import jp.sf.fess.helper.CrawlingSessionHelper; +import jp.sf.fess.helper.SystemHelper; import jp.sf.fess.taglib.FessFunctions; import org.seasar.framework.container.SingletonS2Container; @@ -61,8 +61,8 @@ public abstract class AbstractDataStoreImpl implements DataStore { final CrawlingSessionHelper crawlingSessionHelper = SingletonS2Container .getComponent("crawlingSessionHelper"); final Date documentExpires = crawlingSessionHelper.getDocumentExpires(); - final CrawlingConfigHelper crawlingConfigHelper = SingletonS2Container - .getComponent("crawlingConfigHelper"); + final SystemHelper systemHelper = SingletonS2Container + .getComponent("systemHelper"); initParamMap.putAll(configParamMap); final Map paramMap = initParamMap; @@ -73,12 +73,11 @@ public abstract class AbstractDataStoreImpl implements DataStore { // cid final String configId = config.getConfigId(); if (configId != null) { - defaultDataMap.put(crawlingConfigHelper.getConfigIdField(), - configId); + defaultDataMap.put(systemHelper.configIdField, configId); } // expires if (documentExpires != null) { - defaultDataMap.put(crawlingSessionHelper.getExpiresField(), + defaultDataMap.put(systemHelper.expiresField, FessFunctions.formatDate(documentExpires)); } // segment diff --git a/src/main/java/jp/sf/fess/ds/impl/IndexUpdateCallbackImpl.java b/src/main/java/jp/sf/fess/ds/impl/IndexUpdateCallbackImpl.java index deed9e05f..1bd8bc730 100644 --- a/src/main/java/jp/sf/fess/ds/impl/IndexUpdateCallbackImpl.java +++ b/src/main/java/jp/sf/fess/ds/impl/IndexUpdateCallbackImpl.java @@ -46,10 +46,6 @@ public class IndexUpdateCallbackImpl implements IndexUpdateCallback { public boolean favoriteCountEnabled = true; - public String clickCountField = "clickCount_i"; - - public String favoriteCountField = "favoriteCount_i"; - protected volatile AtomicLong documentSize = new AtomicLong(0); protected volatile long commitPerCount = 0; @@ -137,7 +133,7 @@ public class IndexUpdateCallbackImpl implements IndexUpdateCallback { if (!dataMap.containsKey(Constants.DOC_ID)) { final SystemHelper systemHelper = SingletonS2Container - .getComponent(SystemHelper.class); + .getComponent("systemHelper"); doc.addField(Constants.DOC_ID, systemHelper.generateDocId(dataMap)); } @@ -186,8 +182,10 @@ public class IndexUpdateCallbackImpl implements IndexUpdateCallback { final String url) { final SearchLogHelper searchLogHelper = SingletonS2Container .getComponent(SearchLogHelper.class); + final SystemHelper systemHelper = SingletonS2Container + .getComponent("systemHelper"); final int count = searchLogHelper.getClickCount(url); - doc.addField(clickCountField, count); + doc.addField(systemHelper.clickCountField, count); if (logger.isDebugEnabled()) { logger.debug("Click Count: " + count + ", url: " + url); } @@ -197,8 +195,10 @@ public class IndexUpdateCallbackImpl implements IndexUpdateCallback { final String url) { final SearchLogHelper searchLogHelper = SingletonS2Container .getComponent(SearchLogHelper.class); + final SystemHelper systemHelper = SingletonS2Container + .getComponent("systemHelper"); final long count = searchLogHelper.getFavoriteCount(url); - doc.addField(favoriteCountField, count); + doc.addField(systemHelper.favoriteCountField, count); if (logger.isDebugEnabled()) { logger.debug("Favorite Count: " + count + ", url: " + url); } diff --git a/src/main/java/jp/sf/fess/exec/Crawler.java b/src/main/java/jp/sf/fess/exec/Crawler.java index d461ec931..5dc1a5ae6 100644 --- a/src/main/java/jp/sf/fess/exec/Crawler.java +++ b/src/main/java/jp/sf/fess/exec/Crawler.java @@ -42,6 +42,7 @@ import jp.sf.fess.helper.DatabaseHelper; import jp.sf.fess.helper.MailHelper; import jp.sf.fess.helper.OverlappingHostHelper; import jp.sf.fess.helper.PathMappingHelper; +import jp.sf.fess.helper.SystemHelper; import jp.sf.fess.helper.WebFsIndexHelper; import jp.sf.fess.screenshot.ScreenShotManager; import jp.sf.fess.service.CrawlingSessionService; @@ -378,6 +379,8 @@ public class Crawler implements Serializable { final CrawlingSessionHelper crawlingSessionHelper = SingletonS2Container .getComponent("crawlingSessionHelper"); + final SystemHelper systemHelper = SingletonS2Container + .getComponent("systemHelper"); boolean completed = false; int exitCode = Constants.EXIT_OK; @@ -459,10 +462,8 @@ public class Crawler implements Serializable { // clean up try { - updateSolrGroup.deleteByQuery(crawlingSessionHelper - .getExpiresField() - + ":[* TO " - + FessFunctions.formatDate(new Date()) + updateSolrGroup.deleteByQuery(systemHelper.expiresField + + ":[* TO " + FessFunctions.formatDate(new Date()) + "] NOT segment:" + options.sessionId); } catch (final Exception e) { if (logger.isWarnEnabled()) { diff --git a/src/main/java/jp/sf/fess/filter/LoginInfoFilter.java b/src/main/java/jp/sf/fess/filter/LoginInfoFilter.java index 49adf211f..1d932b537 100644 --- a/src/main/java/jp/sf/fess/filter/LoginInfoFilter.java +++ b/src/main/java/jp/sf/fess/filter/LoginInfoFilter.java @@ -73,7 +73,7 @@ public class LoginInfoFilter implements Filter { private void updateRoleList(final HttpServletRequest hRequest, final LoginInfo loginInfo) { final SystemHelper systemHelper = SingletonS2Container - .getComponent(SystemHelper.class); + .getComponent("systemHelper"); final List authenticatedRoleList = systemHelper .getAuthenticatedRoleList(); final List roleList = new ArrayList(); diff --git a/src/main/java/jp/sf/fess/helper/CrawlingConfigHelper.java b/src/main/java/jp/sf/fess/helper/CrawlingConfigHelper.java index c07e92b78..842825a20 100644 --- a/src/main/java/jp/sf/fess/helper/CrawlingConfigHelper.java +++ b/src/main/java/jp/sf/fess/helper/CrawlingConfigHelper.java @@ -60,18 +60,6 @@ public class CrawlingConfigHelper implements Serializable { protected int count = 1; - protected String configIdField = "cid_s_s"; - - protected String urlField = "url"; - - public String getUrlField() { - return urlField; - } - - public void setUrlField(final String urlField) { - this.urlField = urlField; - } - public ConfigType getConfigType(final String configId) { if (configId == null || configId.length() < 2) { return null; @@ -143,19 +131,13 @@ public class CrawlingConfigHelper implements Serializable { return crawlingConfigMap.get(sessionId); } - public String getConfigIdField() { - return configIdField; - } - - public void setConfigIdField(final String configIdField) { - this.configIdField = configIdField; - } - public void writeContent(final Map doc) { if (logger.isDebugEnabled()) { logger.debug("writing the content of: " + doc); } - final Object configIdObj = doc.get(configIdField); + final SystemHelper systemHelper = SingletonS2Container + .getComponent("systemHelper"); + final Object configIdObj = doc.get(systemHelper.configIdField); if (configIdObj == null) { throw new FessSystemException("Invalid configId: " + configIdObj); } @@ -188,7 +170,7 @@ public class CrawlingConfigHelper implements Serializable { if (config == null) { throw new FessSystemException("No crawlingConfig: " + configIdObj); } - final String url = (String) doc.get(urlField); + final String url = (String) doc.get(systemHelper.urlField); final S2RobotClientFactory robotClientFactory = SingletonS2Container .getComponent(S2RobotClientFactory.class); config.initializeClientFactory(robotClientFactory); diff --git a/src/main/java/jp/sf/fess/helper/CrawlingSessionHelper.java b/src/main/java/jp/sf/fess/helper/CrawlingSessionHelper.java index 57a67eddc..3bae25b00 100644 --- a/src/main/java/jp/sf/fess/helper/CrawlingSessionHelper.java +++ b/src/main/java/jp/sf/fess/helper/CrawlingSessionHelper.java @@ -57,8 +57,6 @@ public class CrawlingSessionHelper implements Serializable { protected Date documentExpires; - protected String expiresField = "expires_dt"; - protected CrawlingSessionService getCrawlingSessionService() { return SingletonS2Container.getComponent(CrawlingSessionService.class); } @@ -220,12 +218,4 @@ public class CrawlingSessionHelper implements Serializable { return value.replace('"', ' '); } - public String getExpiresField() { - return expiresField; - } - - public void setExpiresField(final String expiresField) { - this.expiresField = expiresField; - } - } diff --git a/src/main/java/jp/sf/fess/helper/SystemHelper.java b/src/main/java/jp/sf/fess/helper/SystemHelper.java index 1da29c8fb..b0a71dea0 100644 --- a/src/main/java/jp/sf/fess/helper/SystemHelper.java +++ b/src/main/java/jp/sf/fess/helper/SystemHelper.java @@ -105,6 +105,18 @@ public class SystemHelper implements Serializable { private final AtomicBoolean forceStop = new AtomicBoolean(false); + public String favoriteCountField = "favoriteCount_i"; + + public String clickCountField = "clickCount_i"; + + public String screenshotField = "screenshot_s_s"; + + public String configIdField = "cid_s_s"; + + public String expiresField = "expires_dt"; + + public String urlField = "url"; + @InitMethod public void init() { final File[] files = ResourceUtil.getJarFiles(launcherFileNamePrefix); diff --git a/src/main/java/jp/sf/fess/job/CrawlJob.java b/src/main/java/jp/sf/fess/job/CrawlJob.java index 0eadc5412..86fadcb17 100644 --- a/src/main/java/jp/sf/fess/job/CrawlJob.java +++ b/src/main/java/jp/sf/fess/job/CrawlJob.java @@ -210,7 +210,7 @@ public class CrawlJob { final ServletContext servletContext = SingletonS2Container .getComponent(ServletContext.class); final SystemHelper systemHelper = SingletonS2Container - .getComponent(SystemHelper.class); + .getComponent("systemHelper"); final JobHelper jobHelper = SingletonS2Container .getComponent(JobHelper.class); diff --git a/src/main/java/jp/sf/fess/job/TriggeredJob.java b/src/main/java/jp/sf/fess/job/TriggeredJob.java index 83662aca6..c706d3e1c 100644 --- a/src/main/java/jp/sf/fess/job/TriggeredJob.java +++ b/src/main/java/jp/sf/fess/job/TriggeredJob.java @@ -51,7 +51,7 @@ public class TriggeredJob implements Job { public void execute(final ScheduledJob scheduledJob) { final SystemHelper systemHelper = SingletonS2Container - .getComponent(SystemHelper.class); + .getComponent("systemHelper"); final JobHelper jobHelper = SingletonS2Container .getComponent(JobHelper.class); final JobLog jobLog = new JobLog(scheduledJob); diff --git a/src/main/java/jp/sf/fess/robot/FessS2RobotThread.java b/src/main/java/jp/sf/fess/robot/FessS2RobotThread.java index 039e31ff4..647592442 100644 --- a/src/main/java/jp/sf/fess/robot/FessS2RobotThread.java +++ b/src/main/java/jp/sf/fess/robot/FessS2RobotThread.java @@ -33,6 +33,7 @@ import jp.sf.fess.helper.CrawlingConfigHelper; import jp.sf.fess.helper.CrawlingSessionHelper; import jp.sf.fess.helper.SambaHelper; import jp.sf.fess.helper.SearchLogHelper; +import jp.sf.fess.helper.SystemHelper; import org.apache.commons.io.IOUtils; import org.apache.solr.client.solrj.SolrQuery; @@ -81,12 +82,14 @@ public class FessS2RobotThread extends S2RobotThread { .getComponent(CrawlingConfigHelper.class); final CrawlingSessionHelper crawlingSessionHelper = SingletonS2Container .getComponent(CrawlingSessionHelper.class); + final SystemHelper systemHelper = SingletonS2Container + .getComponent("systemHelper"); final SambaHelper sambaHelper = SingletonS2Container .getComponent(SambaHelper.class); final boolean useAclAsRole = crawlerProperties.getProperty( Constants.USE_ACL_AS_ROLE, Constants.FALSE).equals( Constants.TRUE); - final String expiresField = crawlingSessionHelper.getExpiresField(); + final String expiresField = systemHelper.expiresField; ResponseData responseData = null; try { diff --git a/src/main/java/jp/sf/fess/screenshot/ScreenShotManager.java b/src/main/java/jp/sf/fess/screenshot/ScreenShotManager.java index 9fbfac6a7..18b58672e 100644 --- a/src/main/java/jp/sf/fess/screenshot/ScreenShotManager.java +++ b/src/main/java/jp/sf/fess/screenshot/ScreenShotManager.java @@ -32,8 +32,10 @@ import javax.servlet.http.HttpSession; import jp.sf.fess.Constants; import jp.sf.fess.FessSystemException; +import jp.sf.fess.helper.SystemHelper; import org.apache.commons.io.FileUtils; +import org.seasar.framework.container.SingletonS2Container; import org.seasar.framework.container.annotation.tiger.InitMethod; import org.seasar.framework.util.StringUtil; import org.seasar.robot.util.LruHashMap; @@ -54,8 +56,6 @@ public class ScreenShotManager { public int threadNum = 10; - public String solrFieldName = "screenshot_s_s"; - public long shutdownTimeout = 5 * 60 * 1000; // 5min public int screenShotPathCacheSize = 10; @@ -90,12 +90,14 @@ public class ScreenShotManager { } public void generate(final Map docMap) { + final SystemHelper systemHelper = SingletonS2Container + .getComponent("systemHelper"); for (final ScreenShotGenerator generator : generatorList) { if (generator.isTarget(docMap)) { final String segment = (String) docMap.get("segment"); final String url = (String) docMap.get("url"); final String path = segment + "/" + generator.getPath(docMap); - docMap.put(solrFieldName, path); + docMap.put(systemHelper.screenshotField, path); executorService.execute(new GenerateTask(url, new File(baseDir, path), generator)); break; @@ -105,11 +107,14 @@ public class ScreenShotManager { public void storeRequest(final String queryId, final List> documentItems) { + final SystemHelper systemHelper = SingletonS2Container + .getComponent("systemHelper"); final Map dataMap = new HashMap( documentItems.size()); for (final Map docMap : documentItems) { final String url = (String) docMap.get("url"); - final String screenShotPath = (String) docMap.get(solrFieldName); + final String screenShotPath = (String) docMap + .get(systemHelper.screenshotField); if (StringUtil.isNotBlank(url) && StringUtil.isNotBlank(screenShotPath)) { dataMap.put(url, screenShotPath); diff --git a/src/main/java/jp/sf/fess/service/FailureUrlService.java b/src/main/java/jp/sf/fess/service/FailureUrlService.java index 0c8169678..0e43b0a5d 100644 --- a/src/main/java/jp/sf/fess/service/FailureUrlService.java +++ b/src/main/java/jp/sf/fess/service/FailureUrlService.java @@ -202,7 +202,7 @@ public class FailureUrlService extends BsFailureUrlService implements private String getStackTrace(final Throwable t) { final SystemHelper systemHelper = SingletonS2Container - .getComponent(SystemHelper.class); + .getComponent("systemHelper"); final StringWriter sw = new StringWriter(); final PrintWriter pw = new PrintWriter(sw, true); t.printStackTrace(pw); diff --git a/src/main/java/jp/sf/fess/service/FavoriteLogService.java b/src/main/java/jp/sf/fess/service/FavoriteLogService.java index e1020626f..88e9df755 100644 --- a/src/main/java/jp/sf/fess/service/FavoriteLogService.java +++ b/src/main/java/jp/sf/fess/service/FavoriteLogService.java @@ -98,7 +98,8 @@ public class FavoriteLogService extends BsFavoriteLogService implements } - public boolean addUrl(final String userCode, final String url) { + public boolean addUrl(final String userCode, final String url, + final Map doc) { final UserInfoCB cb = new UserInfoCB(); cb.query().setCode_Equal(userCode); final UserInfo userInfo = userInfoBhv.selectEntity(cb); diff --git a/src/main/java/jp/sf/fess/solr/IndexUpdater.java b/src/main/java/jp/sf/fess/solr/IndexUpdater.java index da761adbd..39aec31e1 100644 --- a/src/main/java/jp/sf/fess/solr/IndexUpdater.java +++ b/src/main/java/jp/sf/fess/solr/IndexUpdater.java @@ -123,10 +123,6 @@ public class IndexUpdater extends Thread { public boolean favoriteCountEnabled = true; - public String clickCountField = "clickCount_i"; - - public String favoriteCountField = "favoriteCount_i"; - private final List boostRuleList = new ArrayList(); private final Map docValueMap = new HashMap(); @@ -497,8 +493,8 @@ public class IndexUpdater extends Thread { final ClickLogCB cb = new ClickLogCB(); cb.query().setUrl_Equal(url); final int count = clickLogBhv.selectCount(cb); - doc.addField(clickCountField, count); - map.put(clickCountField, count); + doc.addField(systemHelper.clickCountField, count); + map.put(systemHelper.clickCountField, count); if (logger.isDebugEnabled()) { logger.debug("Click Count: " + count + ", url: " + url); } @@ -520,8 +516,8 @@ public class IndexUpdater extends Thread { count = list.get(0).getCnt().longValue(); } - doc.addField(favoriteCountField, count); - map.put(favoriteCountField, count); + doc.addField(systemHelper.favoriteCountField, count); + map.put(systemHelper.favoriteCountField, count); if (logger.isDebugEnabled()) { logger.debug("Favorite Count: " + count + ", url: " + url); } diff --git a/src/main/java/jp/sf/fess/transformer/AbstractFessFileTransformer.java b/src/main/java/jp/sf/fess/transformer/AbstractFessFileTransformer.java index 0244a105e..a721efa47 100644 --- a/src/main/java/jp/sf/fess/transformer/AbstractFessFileTransformer.java +++ b/src/main/java/jp/sf/fess/transformer/AbstractFessFileTransformer.java @@ -37,6 +37,7 @@ import jp.sf.fess.helper.CrawlingSessionHelper; import jp.sf.fess.helper.LabelTypeHelper; import jp.sf.fess.helper.PathMappingHelper; import jp.sf.fess.helper.SambaHelper; +import jp.sf.fess.helper.SystemHelper; import jp.sf.fess.taglib.FessFunctions; import org.apache.commons.io.IOUtils; @@ -185,6 +186,8 @@ public abstract class AbstractFessFileTransformer extends .getComponent("crawlingConfigHelper"); final CrawlingConfig crawlingConfig = crawlingConfigHelper .get(responseData.getSessionId()); + final SystemHelper systemHelper = SingletonS2Container + .getComponent("systemHelper"); String urlEncoding; final UrlQueue urlQueue = CrawlingParameterUtil.getUrlQueue(); if (urlQueue != null && urlQueue.getEncoding() != null) { @@ -196,12 +199,11 @@ public abstract class AbstractFessFileTransformer extends // cid final String configId = crawlingConfig.getConfigId(); if (configId != null) { - putResultDataBody(dataMap, crawlingConfigHelper.getConfigIdField(), - configId); + putResultDataBody(dataMap, systemHelper.configIdField, configId); } // expires if (documentExpires != null) { - putResultDataBody(dataMap, crawlingSessionHelper.getExpiresField(), + putResultDataBody(dataMap, systemHelper.expiresField, FessFunctions.formatDate(documentExpires)); } // segment diff --git a/src/main/java/jp/sf/fess/transformer/FessXpathTransformer.java b/src/main/java/jp/sf/fess/transformer/FessXpathTransformer.java index 0971c1472..7d155191f 100644 --- a/src/main/java/jp/sf/fess/transformer/FessXpathTransformer.java +++ b/src/main/java/jp/sf/fess/transformer/FessXpathTransformer.java @@ -43,6 +43,7 @@ import jp.sf.fess.helper.CrawlingSessionHelper; import jp.sf.fess.helper.LabelTypeHelper; import jp.sf.fess.helper.OverlappingHostHelper; import jp.sf.fess.helper.PathMappingHelper; +import jp.sf.fess.helper.SystemHelper; import jp.sf.fess.taglib.FessFunctions; import org.apache.commons.io.IOUtils; @@ -220,6 +221,8 @@ public class FessXpathTransformer extends AbstractFessXpathTransformer { .getComponent("crawlingConfigHelper"); final CrawlingConfig crawlingConfig = crawlingConfigHelper .get(responseData.getSessionId()); + final SystemHelper systemHelper = SingletonS2Container + .getComponent("systemHelper"); String urlEncoding; final UrlQueue urlQueue = CrawlingParameterUtil.getUrlQueue(); if (urlQueue != null && urlQueue.getEncoding() != null) { @@ -231,12 +234,11 @@ public class FessXpathTransformer extends AbstractFessXpathTransformer { // cid final String configId = crawlingConfig.getConfigId(); if (configId != null) { - putResultDataBody(dataMap, crawlingConfigHelper.getConfigIdField(), - configId); + putResultDataBody(dataMap, systemHelper.configIdField, configId); } // expires if (documentExpires != null) { - putResultDataBody(dataMap, crawlingSessionHelper.getExpiresField(), + putResultDataBody(dataMap, systemHelper.expiresField, FessFunctions.formatDate(documentExpires)); } // title