manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1455351 - in /manifoldcf/trunk/connectors/rss/connector/src: main/java/org/apache/manifoldcf/crawler/connectors/rss/RSSConnector.java test/java/org/apache/manifoldcf/crawler/connectors/rss/tests/DateTest.java
Date Mon, 11 Mar 2013 22:36:21 GMT
Author: kwright
Date: Mon Mar 11 22:36:21 2013
New Revision: 1455351

URL: http://svn.apache.org/r1455351
Log:
Add date test class.

Added:
    manifoldcf/trunk/connectors/rss/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/rss/tests/DateTest.java
  (with props)
Modified:
    manifoldcf/trunk/connectors/rss/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/rss/RSSConnector.java

Modified: manifoldcf/trunk/connectors/rss/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/rss/RSSConnector.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/rss/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/rss/RSSConnector.java?rev=1455351&r1=1455350&r2=1455351&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/rss/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/rss/RSSConnector.java
(original)
+++ manifoldcf/trunk/connectors/rss/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/rss/RSSConnector.java
Mon Mar 11 22:36:21 2013
@@ -4422,10 +4422,16 @@ public class RSSConnector extends org.ap
     {
       if (linkField != null && linkField.length() > 0)
       {
-        Long origDate = null;
+        Date origDateDate = null;
         if (pubDateField != null && pubDateField.length() > 0)
-          origDate = parseZuluDate(pubDateField);
+          origDateDate = parseISO8601Date(pubDateField);
 
+        Long origDate;
+        if (origDateDate != null)
+          origDate = new Long(origDateDate.getTime());
+        else
+          origDate = null;
+        
         String[] links = linkField.split(", ");
         int l = 0;
         while (l < links.length)
@@ -4819,9 +4825,15 @@ public class RSSConnector extends org.ap
     {
       if (linkField.size() > 0)
       {
-        Long origDate = null;
+        Date origDateDate = null;
         if (pubDateField != null && pubDateField.length() > 0)
-          origDate = parseZuluDate(pubDateField);
+          origDateDate = parseISO8601Date(pubDateField);
+
+        Long origDate;
+        if (origDateDate != null)
+          origDate = new Long(origDateDate.getTime());
+        else
+          origDate = null;
 
         for (String linkValue : linkField)
         {
@@ -5106,9 +5118,15 @@ public class RSSConnector extends org.ap
     {
       if (linkField != null && linkField.length() > 0)
       {
-        Long origDate = null;
+        Date origDateDate = null;
         if (pubDateField != null && pubDateField.length() > 0)
-          origDate = parseZuluDate(pubDateField);
+          origDateDate = parseISO8601Date(pubDateField);
+
+        Long origDate;
+        if (origDateDate != null)
+          origDate = new Long(origDateDate.getTime());
+        else
+          origDate = null;
 
         String[] links = linkField.split(", ");
         int l = 0;
@@ -5150,26 +5168,8 @@ public class RSSConnector extends org.ap
     }
   }
 
-  // Month map
-  protected static HashMap monthMap = new HashMap();
-  static
-  {
-    monthMap.put("jan",new Integer(1));
-    monthMap.put("feb",new Integer(2));
-    monthMap.put("mar",new Integer(3));
-    monthMap.put("apr",new Integer(4));
-    monthMap.put("may",new Integer(5));
-    monthMap.put("jun",new Integer(6));
-    monthMap.put("jul",new Integer(7));
-    monthMap.put("aug",new Integer(8));
-    monthMap.put("sep",new Integer(9));
-    monthMap.put("oct",new Integer(10));
-    monthMap.put("nov",new Integer(11));
-    monthMap.put("dec",new Integer(12));
-  }
-
-  /** Parse an RDF date */
-  protected static Long parseZuluDate(String dateValue)
+  /** Parse an ISO8601 date */
+  protected static Date parseISO8601Date(String dateValue)
   {
     dateValue = dateValue.trim();
     // Format: YYYY-MM-DDTHH:MM:SSZ
@@ -5260,7 +5260,7 @@ public class RSSConnector extends org.ap
       c.set(Calendar.SECOND,value);
 
       c.set(Calendar.MILLISECOND,0);
-      return new Long(c.getTimeInMillis());
+      return new Date(c.getTimeInMillis());
     }
     catch (NumberFormatException e)
     {
@@ -5355,8 +5355,7 @@ public class RSSConnector extends org.ap
 
   }
 
-  /** Parse ISO8601 date.
-  */
+  /**
   protected static Date parseISO8601Date(String isoDateValue)
   {
     java.text.DateFormat iso8601Format = new java.text.SimpleDateFormat ("yyyy-MM-dd'T'HH:mm:ss'Z'");
@@ -5369,8 +5368,28 @@ public class RSSConnector extends org.ap
       return null;
     }
   }
-
+  */
+  
   /** Timezone mapping from RFC822 timezones to ones understood by Java */
+  
+  // Month map
+  protected static HashMap monthMap = new HashMap();
+  static
+  {
+    monthMap.put("jan",new Integer(1));
+    monthMap.put("feb",new Integer(2));
+    monthMap.put("mar",new Integer(3));
+    monthMap.put("apr",new Integer(4));
+    monthMap.put("may",new Integer(5));
+    monthMap.put("jun",new Integer(6));
+    monthMap.put("jul",new Integer(7));
+    monthMap.put("aug",new Integer(8));
+    monthMap.put("sep",new Integer(9));
+    monthMap.put("oct",new Integer(10));
+    monthMap.put("nov",new Integer(11));
+    monthMap.put("dec",new Integer(12));
+  }
+
   protected static final HashMap milTzMap;
   static
   {

Added: manifoldcf/trunk/connectors/rss/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/rss/tests/DateTest.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/rss/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/rss/tests/DateTest.java?rev=1455351&view=auto
==============================================================================
--- manifoldcf/trunk/connectors/rss/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/rss/tests/DateTest.java
(added)
+++ manifoldcf/trunk/connectors/rss/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/rss/tests/DateTest.java
Mon Mar 11 22:36:21 2013
@@ -0,0 +1,42 @@
+/* $Id$ */
+
+/**
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.manifoldcf.crawler.connectors.rss.tests;
+
+import java.util.*;
+import org.apache.manifoldcf.crawler.connectors.rss.RSSConnector;
+import org.junit.*;
+import static org.junit.Assert.*;
+
+public class DateTest extends RSSConnector
+{
+
+  @Test
+  public void iso8601()
+    throws Exception
+  {
+    Date d = RSSConnector.parseISO8601Date("2012-11-15T01:32:33.344Z");
+    assertNotNull(d);
+    d = RSSConnector.parseISO8601Date("2012-11-15T01:32:33Z");
+    assertNotNull(d);
+    d = RSSConnector.parseISO8601Date("2012-11-15T01:32:33+01");
+    assertNotNull(d);
+  }
+
+
+}

Propchange: manifoldcf/trunk/connectors/rss/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/rss/tests/DateTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: manifoldcf/trunk/connectors/rss/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/rss/tests/DateTest.java
------------------------------------------------------------------------------
    svn:keywords = Id



Mime
View raw message