Use AsyncDocIdPusher to push named resources
Code review : https://codereview.appspot.com/85020043/
diff --git a/src/com/google/enterprise/adaptor/sharepoint/SharePointAdaptor.java b/src/com/google/enterprise/adaptor/sharepoint/SharePointAdaptor.java
index 22fc5eb..25365d7 100644
--- a/src/com/google/enterprise/adaptor/sharepoint/SharePointAdaptor.java
+++ b/src/com/google/enterprise/adaptor/sharepoint/SharePointAdaptor.java
@@ -1494,18 +1494,9 @@
         response.setAcl(new Acl.Builder().setInheritFrom(rootFolderDocId)
             .setInheritanceType(Acl.InheritanceType.PARENT_OVERRIDES)
             .build());
-        final Map<DocId, Acl> map = Collections.singletonMap(rootFolderDocId,
-            acl.setInheritanceType(Acl.InheritanceType.PARENT_OVERRIDES)
-            .build());
-        executor.execute(new Runnable() {
-          @Override public void run() {
-            try {
-              context.getDocIdPusher().pushNamedResources(map);
-            } catch (InterruptedException ie) {
-              log.log(Level.WARNING, "Error pushing named resource", ie);
-	    }
-          }
-        });
+        context.getAsyncDocIdPusher().pushNamedResource(rootFolderDocId,
+                acl.setInheritanceType(Acl.InheritanceType.PARENT_OVERRIDES)
+                    .build());
       }
 
       response.addMetadata(METADATA_OBJECT_TYPE,
diff --git a/test/com/google/enterprise/adaptor/sharepoint/AccumulatingAsyncDocIdPusher.java b/test/com/google/enterprise/adaptor/sharepoint/AccumulatingAsyncDocIdPusher.java
new file mode 100644
index 0000000..b592142
--- /dev/null
+++ b/test/com/google/enterprise/adaptor/sharepoint/AccumulatingAsyncDocIdPusher.java
@@ -0,0 +1,66 @@
+// Copyright 2014 Google Inc. All Rights Reserved.
+//
+// Licensed 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 com.google.enterprise.adaptor.sharepoint;
+
+import com.google.enterprise.adaptor.Acl;
+import com.google.enterprise.adaptor.AsyncDocIdPusher;
+import com.google.enterprise.adaptor.DocId;
+import com.google.enterprise.adaptor.DocIdPusher;
+
+import java.util.Collections;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+public class AccumulatingAsyncDocIdPusher implements AsyncDocIdPusher{
+  private static final Logger log
+      = Logger.getLogger(AccumulatingAsyncDocIdPusher.class.getName());
+
+  private final DocIdPusher pusher;
+  AccumulatingAsyncDocIdPusher(DocIdPusher pusher) {
+    if (pusher == null) {
+      throw new NullPointerException();
+    }
+    this.pusher = pusher;
+  }
+  @Override
+  public void pushDocId(DocId docid) {
+    try {
+      pusher.pushDocIds(Collections.singletonList(docid));
+    } catch (InterruptedException e) {
+      log.log(Level.WARNING, "Interrupted during pushDocId", e);
+      Thread.currentThread().interrupt();
+    }
+  }
+
+  @Override
+  public void pushRecord(DocIdPusher.Record record) {
+    try {
+      pusher.pushRecords(Collections.singletonList(record));
+    } catch (InterruptedException e) {
+      log.log(Level.WARNING, "Interrupted during pushRecord", e);
+      Thread.currentThread().interrupt();
+    }
+  }
+
+  @Override
+  public void pushNamedResource(DocId docid, Acl acl) {
+    try {
+      pusher.pushNamedResources(Collections.singletonMap(docid, acl));
+    } catch (InterruptedException e) {
+      log.log(Level.WARNING, "Interrupted during pushNamedResource", e);
+      Thread.currentThread().interrupt();
+    }
+  }
+}
diff --git a/test/com/google/enterprise/adaptor/sharepoint/MockAdaptorContext.java b/test/com/google/enterprise/adaptor/sharepoint/MockAdaptorContext.java
index f96f8c5..7eb2f6f 100644
--- a/test/com/google/enterprise/adaptor/sharepoint/MockAdaptorContext.java
+++ b/test/com/google/enterprise/adaptor/sharepoint/MockAdaptorContext.java
@@ -62,6 +62,8 @@
     }
   };
   private PollingIncrementalLister pollingIncrementalLister;
+  
+  private final AccumulatingAsyncDocIdPusher asynPusher;
 
   public MockAdaptorContext(Config config, DocIdPusher pusher) {
     if (config == null) {
@@ -69,6 +71,7 @@
     }
     this.config = config;
     this.pusher = pusher;
+    this.asynPusher = new AccumulatingAsyncDocIdPusher(pusher);
   }
 
   @Override
@@ -152,6 +155,6 @@
 
   @Override
   public AsyncDocIdPusher getAsyncDocIdPusher() {
-    throw new UnsupportedOperationException();
+    return asynPusher;
   }
 }