Skip to content

Apache Lucene open-source search software

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

Timothy Potterde191c73d35d
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 5f23fc71cbe..1cc1a75cb1d 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -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
----------------------
diff --git a/solr/contrib/dataimporthandler-extras/src/java/org/apache/solr/handler/dataimport/MailEntityProcessor.java b/solr/contrib/dataimporthandler-extras/src/java/org/apache/solr/handler/dataimport/MailEntityProcessor.java
index 6a41e60bf39..c41d43edbac 100644
--- a/solr/contrib/dataimporthandler-extras/src/java/org/apache/solr/handler/dataimport/MailEntityProcessor.java
+++ b/solr/contrib/dataimporthandler-extras/src/java/org/apache/solr/handler/dataimport/MailEntityProcessor.java
@@ -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;