#21 add cid_s_s
This commit is contained in:
parent
4b34f13890
commit
e56083224e
10 changed files with 83 additions and 21 deletions
|
@ -316,4 +316,10 @@ public class Constants extends CoreLibConstants {
|
|||
|
||||
public static final int EXIT_FAIL = 1;
|
||||
|
||||
public static final String DATE_CONFIG_ID_PREFIX = "D";
|
||||
|
||||
public static final String FILE_CONFIG_ID_PREFIX = "F";
|
||||
|
||||
public static final String WEB_CONFIG_ID_PREFIX = "W";
|
||||
|
||||
}
|
||||
|
|
|
@ -18,15 +18,17 @@ package jp.sf.fess.db.exentity;
|
|||
|
||||
public interface CrawlingConfig {
|
||||
|
||||
public abstract Long getId();
|
||||
Long getId();
|
||||
|
||||
public abstract String[] getBrowserTypeValues();
|
||||
String[] getBrowserTypeValues();
|
||||
|
||||
public abstract String[] getRoleTypeValues();
|
||||
String[] getRoleTypeValues();
|
||||
|
||||
public abstract String[] getLabelTypeValues();
|
||||
String[] getLabelTypeValues();
|
||||
|
||||
public abstract String getDocumentBoost();
|
||||
String getDocumentBoost();
|
||||
|
||||
public abstract String getIndexingTarget(String input);
|
||||
String getIndexingTarget(String input);
|
||||
|
||||
String getConfigId();
|
||||
}
|
|
@ -150,4 +150,12 @@ public class DataCrawlingConfig extends BsDataCrawlingConfig implements
|
|||
// always return true
|
||||
return Constants.TRUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConfigId() {
|
||||
if (getId() != null) {
|
||||
return Constants.DATE_CONFIG_ID_PREFIX + getId().toString();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -214,4 +214,12 @@ public class FileCrawlingConfig extends BsFileCrawlingConfig implements
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConfigId() {
|
||||
if (getId() != null) {
|
||||
return Constants.FILE_CONFIG_ID_PREFIX + getId().toString();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -217,4 +217,12 @@ public class WebCrawlingConfig extends BsWebCrawlingConfig implements
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConfigId() {
|
||||
if (getId() != null) {
|
||||
return Constants.WEB_CONFIG_ID_PREFIX + getId().toString();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ 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.taglib.FessFunctions;
|
||||
import jp.sf.fess.util.ParameterUtil;
|
||||
|
@ -61,12 +62,21 @@ public abstract class AbstractDataStoreImpl implements DataStore {
|
|||
final CrawlingSessionHelper crawlingSessionHelper = SingletonS2Container
|
||||
.getComponent("crawlingSessionHelper");
|
||||
final Date documentExpires = crawlingSessionHelper.getDocumentExpires();
|
||||
final CrawlingConfigHelper crawlingConfigHelper = SingletonS2Container
|
||||
.getComponent("crawlingConfigHelper");
|
||||
|
||||
initParamMap.putAll(paramMap);
|
||||
paramMap = initParamMap;
|
||||
|
||||
// default values
|
||||
final Map<String, Object> defaultDataMap = new HashMap<String, Object>();
|
||||
|
||||
// cid
|
||||
final String configId = config.getConfigId();
|
||||
if (configId != null) {
|
||||
defaultDataMap.put(crawlingConfigHelper.getConfigIdField(),
|
||||
configId);
|
||||
}
|
||||
// expires
|
||||
if (documentExpires != null) {
|
||||
defaultDataMap.put(crawlingSessionHelper.getExpiresField(),
|
||||
|
|
|
@ -30,12 +30,14 @@ public class CrawlingConfigHelper implements Serializable {
|
|||
|
||||
protected int count = 1;
|
||||
|
||||
protected String configIdField = "cid_s_s";
|
||||
|
||||
public synchronized String store(final String sessionId,
|
||||
final CrawlingConfig crawlingConfig) {
|
||||
final String sid = sessionId + "-" + count;
|
||||
crawlingConfigMap.put(sid, crawlingConfig);
|
||||
final String sessionCountId = sessionId + "-" + count;
|
||||
crawlingConfigMap.put(sessionCountId, crawlingConfig);
|
||||
count++;
|
||||
return sid;
|
||||
return sessionCountId;
|
||||
}
|
||||
|
||||
public void remove(final String sessionId) {
|
||||
|
@ -46,4 +48,12 @@ public class CrawlingConfigHelper implements Serializable {
|
|||
return crawlingConfigMap.get(sessionId);
|
||||
}
|
||||
|
||||
public String getConfigIdField() {
|
||||
return configIdField;
|
||||
}
|
||||
|
||||
public void setConfigIdField(final String configIdField) {
|
||||
this.configIdField = configIdField;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -138,9 +138,9 @@ public class RobotLogHelper extends LogHelperImpl {
|
|||
failureUrlBhv.insertOrUpdate(failureUrl);
|
||||
}
|
||||
|
||||
private CrawlingConfig getCrawlingConfig(final String sessionId) {
|
||||
private CrawlingConfig getCrawlingConfig(final String sessionCountId) {
|
||||
return SingletonS2Container.getComponent(CrawlingConfigHelper.class)
|
||||
.get(sessionId);
|
||||
.get(sessionCountId);
|
||||
}
|
||||
|
||||
private String getStackTrace(final Throwable t) {
|
||||
|
|
|
@ -181,7 +181,17 @@ public abstract class AbstractFessFileTransformer extends
|
|||
final boolean useAclAsRole = crawlerProperties.getProperty(
|
||||
Constants.USE_ACL_AS_ROLE, Constants.FALSE).equals(
|
||||
Constants.TRUE);
|
||||
final CrawlingConfigHelper crawlingConfigHelper = SingletonS2Container
|
||||
.getComponent("crawlingConfigHelper");
|
||||
final CrawlingConfig crawlingConfig = crawlingConfigHelper
|
||||
.get(responseData.getSessionId());
|
||||
|
||||
// cid
|
||||
final String configId = crawlingConfig.getConfigId();
|
||||
if (configId != null) {
|
||||
putResultDataBody(dataMap, crawlingConfigHelper.getConfigIdField(),
|
||||
configId);
|
||||
}
|
||||
// expires
|
||||
if (documentExpires != null) {
|
||||
putResultDataBody(dataMap, crawlingSessionHelper.getExpiresField(),
|
||||
|
@ -250,11 +260,6 @@ public abstract class AbstractFessFileTransformer extends
|
|||
// lastModified
|
||||
putResultDataBody(dataMap, "lastModified",
|
||||
FessFunctions.formatDate(responseData.getLastModified()));
|
||||
// config
|
||||
final CrawlingConfigHelper crawlingConfigHelper = SingletonS2Container
|
||||
.getComponent("crawlingConfigHelper");
|
||||
final CrawlingConfig crawlingConfig = crawlingConfigHelper
|
||||
.get(responseData.getSessionId());
|
||||
// indexingTarget
|
||||
putResultDataBody(dataMap, Constants.INDEXING_TARGET,
|
||||
crawlingConfig.getIndexingTarget(url));
|
||||
|
|
|
@ -214,7 +214,17 @@ public class FessXpathTransformer extends AbstractFessXpathTransformer {
|
|||
.getComponent("pathMappingHelper");
|
||||
final String url = pathMappingHelper.replaceUrl(sessionId,
|
||||
responseData.getUrl());
|
||||
final CrawlingConfigHelper crawlingConfigHelper = SingletonS2Container
|
||||
.getComponent("crawlingConfigHelper");
|
||||
final CrawlingConfig crawlingConfig = crawlingConfigHelper
|
||||
.get(responseData.getSessionId());
|
||||
|
||||
// cid
|
||||
final String configId = crawlingConfig.getConfigId();
|
||||
if (configId != null) {
|
||||
putResultDataBody(dataMap, crawlingConfigHelper.getConfigIdField(),
|
||||
configId);
|
||||
}
|
||||
// expires
|
||||
if (documentExpires != null) {
|
||||
putResultDataBody(dataMap, crawlingSessionHelper.getExpiresField(),
|
||||
|
@ -254,11 +264,6 @@ public class FessXpathTransformer extends AbstractFessXpathTransformer {
|
|||
// lastModified
|
||||
putResultDataBody(dataMap, "lastModified",
|
||||
FessFunctions.formatDate(responseData.getLastModified()));
|
||||
// config
|
||||
final CrawlingConfigHelper crawlingConfigHelper = SingletonS2Container
|
||||
.getComponent("crawlingConfigHelper");
|
||||
final CrawlingConfig crawlingConfig = crawlingConfigHelper
|
||||
.get(responseData.getSessionId());
|
||||
// indexingTarget
|
||||
putResultDataBody(dataMap, Constants.INDEXING_TARGET,
|
||||
crawlingConfig.getIndexingTarget(url));
|
||||
|
|
Loading…
Add table
Reference in a new issue