cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject git commit: CXF-5549: Introduce Tika Search Visitor. Refactored contextual property date retrieval
Date Wed, 09 Jul 2014 01:24:13 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 73ba9acd5 -> f55a02f15


CXF-5549: Introduce Tika Search Visitor. Refactored contextual property date retrieval


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/f55a02f1
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/f55a02f1
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/f55a02f1

Branch: refs/heads/master
Commit: f55a02f157b94b7781ff72811372d99cb15244a6
Parents: 73ba9ac
Author: reta <drreta@gmail.com>
Authored: Tue Jul 8 21:23:58 2014 -0400
Committer: reta <drreta@gmail.com>
Committed: Tue Jul 8 21:23:58 2014 -0400

----------------------------------------------------------------------
 .../cxf/jaxrs/ext/search/SearchUtils.java       | 27 +++++++++++++++-----
 .../tika/TikaLuceneContentExtractorTest.java    |  2 --
 2 files changed, 20 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/f55a02f1/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchUtils.java
----------------------------------------------------------------------
diff --git a/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchUtils.java
b/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchUtils.java
index 49ad457..4051d33 100644
--- a/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchUtils.java
+++ b/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchUtils.java
@@ -49,19 +49,32 @@ public final class SearchUtils {
     
     public static SimpleDateFormat getContextualDateFormat() {
         Message m = PhaseInterceptorChain.getCurrentMessage();
+        
         if (m != null) {
             return getDateFormat((String)m.getContextualProperty(DATE_FORMAT_PROPERTY));
-        } else {
-            return new SimpleDateFormat(DEFAULT_DATE_FORMAT);
-        }
+        } 
+          
+        return null;        
+    }
+    
+    public static SimpleDateFormat getContextualDateFormatOrDefault(final String pattern)
{
+        final SimpleDateFormat format = getContextualDateFormat();
+        return format != null ? format : new SimpleDateFormat(pattern);        
     }
+
     
+    //new SimpleDateFormat(DEFAULT_DATE_FORMAT);
     public static Date dateFromStringWithContextProperties(String value) {
-        try {
-            return getContextualDateFormat().parse(value);
+        try {            
+            final SimpleDateFormat format = getContextualDateFormat();
+            if (format != null) {
+                return format.parse(value);
+            }            
         } catch (ParseException ex) {
-            return dateFromStringWithDefaultFormats(value);
+            LOG.log(Level.FINE, "Unable to parse date using contextual date format specification",
ex);
         }
+        
+        return dateFromStringWithDefaultFormats(value);
     }
     
     public static SimpleDateFormat getDateFormat(Map<String, String> properties) {
@@ -181,7 +194,7 @@ public final class SearchUtils {
         }
         
         if (date == null) {
-            date = timestampFromString(getContextualDateFormat(), value);
+            date = timestampFromString(getContextualDateFormatOrDefault(DEFAULT_DATE_FORMAT),
value);
         }
                 
         return date;

http://git-wip-us.apache.org/repos/asf/cxf/blob/f55a02f1/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/tika/TikaLuceneContentExtractorTest.java
----------------------------------------------------------------------
diff --git a/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/tika/TikaLuceneContentExtractorTest.java
b/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/tika/TikaLuceneContentExtractorTest.java
index 5eca776..1012db6 100644
--- a/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/tika/TikaLuceneContentExtractorTest.java
+++ b/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/tika/TikaLuceneContentExtractorTest.java
@@ -44,7 +44,6 @@ import org.apache.tika.parser.pdf.PDFParser;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 
 public class TikaLuceneContentExtractorTest extends Assert {
@@ -82,7 +81,6 @@ public class TikaLuceneContentExtractorTest extends Assert {
     }
 
     @Test
-    @Ignore
     public void testExtractedTextContentMatchesTypesAndDateSearchCriteria() throws Exception
{
         final LuceneDocumentMetadata documentMetadata = new LuceneDocumentMetadata("contents")
             .withField("modified", Date.class);


Mime
View raw message