Revert "Improving handling of last access time"

This reverts commit c638b7d602e9a2ab91c26642ea12214d6a08e895.

Conflicts:
	src/com/google/enterprise/adaptor/fs/WindowsFileDelegate.java
diff --git a/src/com/google/enterprise/adaptor/fs/FileDelegate.java b/src/com/google/enterprise/adaptor/fs/FileDelegate.java
index a480cb0..1bdd715 100644
--- a/src/com/google/enterprise/adaptor/fs/FileDelegate.java
+++ b/src/com/google/enterprise/adaptor/fs/FileDelegate.java
@@ -61,13 +61,6 @@
   BasicFileAttributes readBasicAttributes(Path doc) throws IOException;
 
   /**
-   * Gets the lastAccess time for the file or directory.
-   *
-   * @param doc the file/folder to set the last accessed time on
-   */
-  FileTime getLastAccessTime(Path doc) throws IOException;
-
-  /**
    * Sets the lastAccess time for the file or directory.
    *
    * @param doc the file/folder to set the last accessed time on
diff --git a/src/com/google/enterprise/adaptor/fs/FsAdaptor.java b/src/com/google/enterprise/adaptor/fs/FsAdaptor.java
index 60343f9..fc59c7c 100644
--- a/src/com/google/enterprise/adaptor/fs/FsAdaptor.java
+++ b/src/com/google/enterprise/adaptor/fs/FsAdaptor.java
@@ -516,7 +516,7 @@
     }
 
     final boolean docIsDirectory = attrs.isDirectory();
-    final FileTime lastAccessTime = delegate.getLastAccessTime(doc);
+    final FileTime lastAccessTime = attrs.lastAccessTime();
 
     if (!docIsDirectory) {
       if (lastAccessTimeFilter.excluded(lastAccessTime)) {
@@ -653,18 +653,13 @@
         try {
           input.close();
         } finally {
-          // Do a follow up check to see if the last access time has changed.
-          // If the last access time has changed, attempt to reset it.
-          if (!lastAccessTime.equals(delegate.getLastAccessTime(doc))) {
-            log.log(Level.FINE, "Restoring last access time for {0}.", doc);
-            try {
-              delegate.setLastAccessTime(doc, lastAccessTime);
-            } catch (IOException e) {
-              // This failure can be expected. We can have full permissions
-              // to read but not write/update permissions.
-              log.log(Level.FINE,
-                  "Unable to restore last access time for {0}.", doc);
-            }
+          try {
+            delegate.setLastAccessTime(doc, lastAccessTime);
+          } catch (IOException e) {
+            // This failure can be expected. We can have full permissions
+            // to read but not write/update permissions.
+            log.log(Level.CONFIG,
+                "Unable to restore last access time for {0}.", doc);
           }
         }
       }
diff --git a/src/com/google/enterprise/adaptor/fs/NioFileDelegate.java b/src/com/google/enterprise/adaptor/fs/NioFileDelegate.java
index ebb737e..84ab250 100644
--- a/src/com/google/enterprise/adaptor/fs/NioFileDelegate.java
+++ b/src/com/google/enterprise/adaptor/fs/NioFileDelegate.java
@@ -64,12 +64,6 @@
   }
 
   @Override
-  public FileTime getLastAccessTime(Path doc) throws IOException {
-    return (FileTime)Files.getAttribute(doc, "lastAccessTime",
-        LinkOption.NOFOLLOW_LINKS);
-  }
-
-  @Override
   public void setLastAccessTime(Path doc, FileTime time) throws IOException {
     Files.setAttribute(doc, "lastAccessTime", time, LinkOption.NOFOLLOW_LINKS);
   }
diff --git a/src/com/google/enterprise/adaptor/fs/WindowsFileDelegate.java b/src/com/google/enterprise/adaptor/fs/WindowsFileDelegate.java
index c893d32..cf1ded4 100644
--- a/src/com/google/enterprise/adaptor/fs/WindowsFileDelegate.java
+++ b/src/com/google/enterprise/adaptor/fs/WindowsFileDelegate.java
@@ -43,18 +43,14 @@
 import com.sun.jna.ptr.PointerByReference;
 import com.sun.jna.win32.W32APIOptions;
 
-import java.io.BufferedInputStream;
 import java.io.File;
 import java.io.IOException;
-import java.io.InputStream;
 import java.nio.file.attribute.AclEntry;
 import java.nio.file.attribute.AclFileAttributeView;
-import java.nio.file.attribute.FileTime;
 import java.nio.file.Files;
 import java.nio.file.LinkOption;
 import java.nio.file.Path;
 import java.nio.file.Paths;
-import java.nio.ByteBuffer;
 import java.util.Arrays;
 import java.util.List;
 import java.util.concurrent.CountDownLatch;
@@ -86,31 +82,6 @@
   }
 
   @Override
-  public InputStream newInputStream(Path doc) throws IOException {
-    return new BufferedInputStream(new WinFileInputStream(doc));
-  }
-
-  @Override
-  public FileTime getLastAccessTime(Path doc) throws IOException {
-    WinBase.FILETIME.ByReference accessTime =
-        new WinBase.FILETIME.ByReference();
-    HANDLE handle = kernel32.CreateFile(doc.toString(), WinNT.GENERIC_READ,
-        WinNT.FILE_SHARE_READ | WinNT.FILE_SHARE_WRITE,
-        new WinBase.SECURITY_ATTRIBUTES(), WinNT.OPEN_EXISTING,
-        WinNT.FILE_ATTRIBUTE_NORMAL, null);
-    if (Kernel32.INVALID_HANDLE_VALUE.equals(handle)) {
-      throw new IOException("Unable to open " + doc
-           + ". GetLastError: " + kernel32.GetLastError());
-    }
-    try {  
-      kernel32.GetFileTime(handle, null, accessTime, null);
-    } finally {
-      kernel32.CloseHandle(handle);
-    }
-    return FileTime.fromMillis(accessTime.toDate().getTime());
-  }
-
-  @Override
   public AclFileAttributeViews getAclViews(Path doc) throws IOException {
     return aclViews.getAclViews(doc);
   }
@@ -518,55 +489,4 @@
   public void destroy() {
     stopMonitorPath();
   }
-
-  private class WinFileInputStream extends InputStream {
-    private final HANDLE handle;
-
-    public WinFileInputStream(Path path) throws IOException {
-      handle = kernel32.CreateFile(path.toString(),
-          WinNT.GENERIC_READ | WinNT.GENERIC_WRITE,
-          WinNT.FILE_SHARE_READ | WinNT.FILE_SHARE_WRITE,
-          new WinBase.SECURITY_ATTRIBUTES(),
-          WinNT.OPEN_EXISTING, WinNT.FILE_ATTRIBUTE_NORMAL, null);
-      if (Kernel32.INVALID_HANDLE_VALUE.equals(handle)) {
-        throw new IOException("Unable to open " + path
-            + ". GetLastError: " + kernel32.GetLastError());
-      }
-
-      // Call SetFileTime with a value of 0xFFFFFFFF for lpLastAccessTime
-      // to keep Windows from updating the last access time
-      // when reading the file content.
-      WinBase.FILETIME ft = new WinBase.FILETIME();
-      ft.dwHighDateTime = 0xFFFFFFFF;
-      ft.dwLowDateTime = 0xFFFFFFFF;
-      kernel32.SetFileTime(handle, null, ft, null);
-    }
-
-    @Override
-    public int read() throws IOException {
-      throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public int read(byte[] inBuf, int start, int count) throws IOException {
-      IntByReference lpNumberOfBytesRead = new IntByReference(0);
-      boolean result = kernel32.ReadFile(handle,
-          ByteBuffer.wrap(inBuf, start, count), count,
-          lpNumberOfBytesRead, null);
-      if (!result) {
-        throw new IOException("Unable to read file data. "
-            + "GetLastError: " + kernel32.GetLastError());
-      }
-      if (lpNumberOfBytesRead.getValue() != 0) {
-        return lpNumberOfBytesRead.getValue();
-      } else {
-        return -1;
-      }
-    }
-
-    @Override
-    public void close() throws IOException {
-      kernel32.CloseHandle(handle);
-    }
-  }
 }
diff --git a/test/com/google/enterprise/adaptor/fs/MockFileDelegate.java b/test/com/google/enterprise/adaptor/fs/MockFileDelegate.java
index f03f444..9a02158 100644
--- a/test/com/google/enterprise/adaptor/fs/MockFileDelegate.java
+++ b/test/com/google/enterprise/adaptor/fs/MockFileDelegate.java
@@ -110,11 +110,6 @@
   }
 
   @Override
-  public FileTime getLastAccessTime(Path doc) throws IOException {
-    return readBasicAttributes(doc).lastAccessTime();
-  }
-
-  @Override
   public void setLastAccessTime(Path doc, FileTime time) throws IOException {
     getFile(doc).setLastAccessTime(time);
   }