SOLR-2245: Better way to check if last_index_time is the initial value and fixup changes.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1611667 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Timothy Potter 2014-07-18 14:51:45 +00:00
parent 92bb1803ff
commit de191c73d3
2 changed files with 34 additions and 16 deletions

View File

@ -70,13 +70,6 @@ New Features
* SOLR-6103: Added DateRangeField for indexing date ranges, especially
multi-valued ones. Based on LUCENE-5648. (David Smiley)
* SOLR-2245: Improvements to the MailEntityProcessor:
- Support for server-side date filtering if using GMail; requires new
dependency on the Sun Gmail Java mail extensions
- Support for using the last_index_time from the previous run as the
value for the fetchMailsSince filter.
(Peter Sturge, Timothy Potter)
Other Changes
----------------------
@ -97,10 +90,6 @@ Other Changes
* SOLR-6215: TrieDateField should directly extend TrieField instead of
forwarding to a wrapped TrieField. (Steve Rowe)
* SOLR-2245: Numerous improvements of the MailEntityProcessor, including using
the GMail extensions to do server-side date filtering and using GreenMail in
the unit test to enable automated tests. (Timothy Potter)
================== 4.10.0 =================
Versions of Major Components
@ -147,6 +136,14 @@ New Features
* SOLR-6232: You can now unload/delete cores that have failed to initialize (Alan Woodward)
* SOLR-2245: Improvements to the MailEntityProcessor:
- Support for server-side date filtering if using GMail; requires new
dependency on the Sun Gmail Java mail extensions
- Support for using the last_index_time from the previous run as the
value for the fetchMailsSince filter.
(Peter Sturge, Timothy Potter)
Bug Fixes
----------------------

View File

@ -108,14 +108,35 @@ public class MailEntityProcessor extends EntityProcessorBase {
String varName = ConfigNameConstants.IMPORTER_NS_SHORT + "." + cname + "."
+ DocBuilder.LAST_INDEX_TIME;
Object varValue = context.getVariableResolver().resolve(varName);
if ("1970-01-01 00:00:00".equals(varValue) &&
LOG.info(varName+"="+varValue);
if (varValue != null && !"".equals(varValue) &&
!"".equals(getStringFromContext("fetchMailsSince", ""))) {
// favor fetchMailsSince in this case because the value from
// dataimport.properties is the default/init value
varValue = getStringFromContext("fetchMailsSince", "");
// need to check if varValue is the epoch, which we'll take to mean the
// initial value, in which case means we should use fetchMailsSince instead
Date tmp = null;
try {
tmp = sinceDateParser.parse((String)varValue);
if (tmp.getTime() == 0) {
LOG.info("Ignoring initial value "+varValue+" for "+varName+
" in favor of fetchMailsSince config parameter");
tmp = null; // don't use this value
}
} catch (ParseException e) {
// probably ok to ignore this since we have other options below
// as we're just trying to figure out if the date is 0
LOG.warn("Failed to parse "+varValue+" from "+varName+" due to: "+e);
}
if (tmp == null) {
// favor fetchMailsSince in this case because the value from
// dataimport.properties is the default/init value
varValue = getStringFromContext("fetchMailsSince", "");
LOG.info("fetchMailsSince="+varValue);
}
}
LOG.info(varName+"="+varValue);
if (varValue == null || "".equals(varValue)) {
varName = ConfigNameConstants.IMPORTER_NS_SHORT + "."
+ DocBuilder.LAST_INDEX_TIME;