Use fragment-based named resource

The adaptor library can now handle sending multiple ACLs for a
particular document, so we make use of it. The library batches sending
of the named resources, so it should greatly reduce the amount of feed
spam.
diff --git a/lib/plexi b/lib/plexi
index 272e144..82ac4a0 160000
--- a/lib/plexi
+++ b/lib/plexi
@@ -1 +1 @@
-Subproject commit 272e144e78ef5f3416daf77ece11a0e66f2b2f10
+Subproject commit 82ac4a0517ee5b60cfd20520f03073d54c6b3015
diff --git a/src/com/google/enterprise/adaptor/sharepoint/SharePointAdaptor.java b/src/com/google/enterprise/adaptor/sharepoint/SharePointAdaptor.java
index 82d705e..a60f6a4 100644
--- a/src/com/google/enterprise/adaptor/sharepoint/SharePointAdaptor.java
+++ b/src/com/google/enterprise/adaptor/sharepoint/SharePointAdaptor.java
@@ -1407,8 +1407,7 @@
               + request.getDocId());
         }
       } else {
-        DocId namedResource
-            = new DocId(request.getDocId().getUniqueId() + "_READ_SECURITY");
+        final String fragmentName = "readSecurity";
         List<Permission> permission = null;
         Scopes scopes = getFirstChildOfType(xml, Scopes.class);
         for (Scopes.Scope scope : scopes.getScope()) {
@@ -1422,7 +1421,7 @@
               = i.getMetadata().getScope().getPermissions().getPermission();
         }
         acl = generateAcl(permission, LIST_ITEM_MASK)
-            .setInheritFrom(namedResource);
+            .setInheritFrom(request.getDocId(), fragmentName);
         int authorId = -1;
         String authorValue = row.getAttribute(OWS_AUTHOR_ATTRIBUTE);
         if (authorValue != null) {
@@ -1436,18 +1435,7 @@
             .setInheritFrom(virtualServerDocId)
             .setInheritanceType(Acl.InheritanceType.AND_BOTH_PERMIT);
         addPermitUserToAcl(authorId, aclNamedResource);
-        final Map<DocId, Acl> map = new TreeMap<DocId, Acl>();
-        map.put(namedResource, aclNamedResource.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);
-            }
-          }
-        });
+        response.putNamedResource(fragmentName, aclNamedResource.build());
       }
       response.setAcl(acl
           .setInheritanceType(Acl.InheritanceType.PARENT_OVERRIDES)
diff --git a/test/com/google/enterprise/adaptor/sharepoint/GetContentsResponse.java b/test/com/google/enterprise/adaptor/sharepoint/GetContentsResponse.java
index cf4aaf8..6d622b9 100644
--- a/test/com/google/enterprise/adaptor/sharepoint/GetContentsResponse.java
+++ b/test/com/google/enterprise/adaptor/sharepoint/GetContentsResponse.java
@@ -38,6 +38,7 @@
   private boolean lock;
   private boolean crawlOnce;
   private URI displayUrl;
+  private Map<String, Acl> namedResources = new HashMap<String, Acl>();
 
   public GetContentsResponse(OutputStream os) {
     this.os = os;
@@ -119,6 +120,11 @@
     this.displayUrl = displayUrl;
   }
 
+  @Override
+  public void putNamedResource(String fragment, Acl acl) {
+    namedResources.put(fragment, acl);
+  }
+
   public String getContentType() {
     return contentType;
   }
@@ -167,4 +173,8 @@
   public URI getDisplayUrl() {
     return displayUrl;
   }
+
+  public Map<String, Acl> getNamedResources() {
+    return namedResources;
+  }
 }
diff --git a/test/com/google/enterprise/adaptor/sharepoint/SharePointAdaptorTest.java b/test/com/google/enterprise/adaptor/sharepoint/SharePointAdaptorTest.java
index 7b71429..621ffea 100644
--- a/test/com/google/enterprise/adaptor/sharepoint/SharePointAdaptorTest.java
+++ b/test/com/google/enterprise/adaptor/sharepoint/SharePointAdaptorTest.java
@@ -981,13 +981,7 @@
               mockUserGroupSoap)
           .endpoint(SITES_SITECOLLECTION_ENDPOINT, new UnsupportedSiteData()),
         new UnsupportedHttpClient(), executorFactory);
-    final AccumulatingDocIdPusher docIdPusher = new AccumulatingDocIdPusher();
-    adaptor.init(new MockAdaptorContext(config, pusher) {
-      @Override
-      public DocIdPusher getDocIdPusher() {
-        return docIdPusher;
-      }
-    });
+    adaptor.init(new MockAdaptorContext(config, pusher));
     ByteArrayOutputStream baos = new ByteArrayOutputStream();
     GetContentsRequest request = new GetContentsRequest(
         new DocId("http://localhost:1/sites/SiteCollection/Lists/Custom List/"
@@ -1010,15 +1004,14 @@
     assertEquals(new Acl.Builder()
         .setEverythingCaseInsensitive()
         .setInheritFrom(new DocId("http://localhost:1/sites/SiteCollection"
-            + "/Lists/Custom List/Test Folder/2_.000_READ_SECURITY"))
+            + "/Lists/Custom List/Test Folder/2_.000"), "readSecurity")
         .setPermitUsers(Arrays.asList(GDC_PSL_ADMINISTRATOR))
         .setPermitGroups(Arrays.asList(SITES_SITECOLLECTION_OWNERS,
             SITES_SITECOLLECTION_MEMBERS, SITES_SITECOLLECTION_VISITORS))
         .setInheritanceType(Acl.InheritanceType.PARENT_OVERRIDES).build(),
         response.getAcl());
-    assertEquals(Collections.singletonList(Collections.singletonMap(
-        new DocId("http://localhost:1/sites/SiteCollection/Lists/Custom List/"
-            + "Test Folder/2_.000_READ_SECURITY"),
+    assertEquals(Collections.singletonMap(
+        "readSecurity",
         new Acl.Builder()
             .setEverythingCaseInsensitive()
             .setPermitUsers(Arrays.asList(GDC_PSL_ADMINISTRATOR,
@@ -1026,8 +1019,8 @@
             .setPermitGroups(Arrays.asList(SITES_SITECOLLECTION_OWNERS))
             .setInheritanceType(Acl.InheritanceType.AND_BOTH_PERMIT)
             .setInheritFrom(new DocId(""))
-            .build())),
-        docIdPusher.getNamedResources());
+            .build()),
+        response.getNamedResources());
   }
 
   public void testGetDocContentListItemScopeSameAsParent() throws Exception {