You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@manifoldcf.apache.org by kw...@apache.org on 2017/07/06 06:34:30 UTC

svn commit: r1800969 - in /manifoldcf/trunk: CHANGES.txt connectors/filesystem/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/filesystem/FileConnector.java

Author: kwright
Date: Thu Jul  6 06:34:30 2017
New Revision: 1800969

URL: http://svn.apache.org/viewvc?rev=1800969&view=rev
Log:
Fix for CONNECTORS-1440.

Modified:
    manifoldcf/trunk/CHANGES.txt
    manifoldcf/trunk/connectors/filesystem/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/filesystem/FileConnector.java

Modified: manifoldcf/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/CHANGES.txt?rev=1800969&r1=1800968&r2=1800969&view=diff
==============================================================================
--- manifoldcf/trunk/CHANGES.txt (original)
+++ manifoldcf/trunk/CHANGES.txt Thu Jul  6 06:34:30 2017
@@ -3,6 +3,9 @@ $Id$
 
 ======================= 2.8-dev =====================
 
+CONNECTORS-1440: Add support for created date in File System connector.
+(Steph van Schalkwyk, Karl Wright)
+
 CONNECTORS-1438: Wrong content-type parse in Solr connector caused
 failure when content type contained a charset.
 (Kenta Kasahara, Karl Wright)

Modified: manifoldcf/trunk/connectors/filesystem/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/filesystem/FileConnector.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/filesystem/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/filesystem/FileConnector.java?rev=1800969&r1=1800968&r2=1800969&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/filesystem/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/filesystem/FileConnector.java (original)
+++ manifoldcf/trunk/connectors/filesystem/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/filesystem/FileConnector.java Thu Jul  6 06:34:30 2017
@@ -27,6 +27,10 @@ import java.util.*;
 import java.io.*;
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.nio.file.Paths;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.attribute.BasicFileAttributes;
 
 /** This is the "repository connector" for a file system.  It's a relative of the share crawler, and should have
 * comparable basic functionality, with the exception of the ability to use ActiveDirectory and look at other shares.
@@ -297,12 +301,13 @@ public class FileConnector extends org.a
       }
       
       // It's a file
+      final Path path = file.toPath();
       String versionString;
       String convertPath;
       long fileLength = file.length();
       // Get the file's modified date.
       long lastModified = file.lastModified();
-            
+
       // Check if the path is to be converted.  We record that info in the version string so that we'll reindex documents whose
       // URI's change.
       convertPath = findConvertPath(spec, file);
@@ -336,7 +341,7 @@ public class FileConnector extends org.a
         }
         
         String fileName = file.getName();
-        Date modifiedDate = new Date(file.lastModified());
+        final Date modifiedDate = new Date(file.lastModified());
         String mimeType = mapExtensionToMimeType(fileName);
         String uri;
         if (convertPath != null) {
@@ -381,7 +386,7 @@ public class FileConnector extends org.a
           activities.noDocument(documentIdentifier,versionString);
           continue;
         }
-        
+
         RepositoryDocument data = new RepositoryDocument();
         data.setFileName(fileName);
         data.setMimeType(mimeType);
@@ -397,6 +402,10 @@ public class FileConnector extends org.a
         // Ingest the document.
         try
         {
+          final BasicFileAttributes attributes = Files.readAttributes(path, BasicFileAttributes.class);
+          final Date createdDate = new Date(attributes.creationTime().toMillis());
+          data.setCreatedDate(createdDate);
+
           InputStream is = new FileInputStream(file);
           try
           {