Package com.google.enterprise.connector.sharepoint.state

Examples of com.google.enterprise.connector.sharepoint.state.ListState


      throws SharepointException {
    WebState ws = globalState.makeWebState(spContext, url);
    ws.setPrimaryKey(url);
    DateTime dt = new DateTime();
    ws.setInsertionTime(dt);
    ListState ls = getListState("http://testcase.com:22819/tempSite/Lists/Announcements/AllItems.aspx", 10, 156790, "{872819FC-6FA7-42AF-A71F-DCF7B8CD1E4A}", ws);
    ListState ls2 = getListState("http://testcase.com:22819/tempSite2/Lists/Announcements/AllItems.aspx", 11, 122790, "{872819FC-6FA7-42AF-A71F-DCF7B8CD1G4A}", ws);
    ListState ls3 = getListState("http://testcase.com/tempSite2/Lists/Announcements/AllItems.aspx", 12, 157790, "{872819FC-6FA7-42AF-A71F-DCF7B8CD1T4A}", ws);
    ListState ls4 = getListState("http://testcase.com/tempSite4/Lists/Announcements/AllItems.aspx", 22, 158790, "{872819FC-6FA7-42AF-A71F-DCF7B8RT1T4A}", ws);

    ws.AddOrUpdateListStateInWebState(ls, ls.getLastMod());
    ws.AddOrUpdateListStateInWebState(ls2, ls2.getLastMod());
    ws.AddOrUpdateListStateInWebState(ls3, ls3.getLastMod());
    ws.AddOrUpdateListStateInWebState(ls4, ls4.getLastMod());

    switch (indexOfLastCrawledList) {
    case 1:
      ws.setLastCrawledList(ls);
      ws.setCurrentList(ls);
View Full Code Here


        TestConfiguration.googleConnectorWorkDir, TestConfiguration.feedType);

    if (null != Site1_URL && Site1_URL.trim().length() > 0) {
      WebState webstate1 = globalState.makeWebState(sharepointClientContext, TestConfiguration.Site1_URL);
      if (null != Site1_List1_URL && Site1_List1_URL.trim().length() > 0) {
        ListState liststate11 = new ListState(Site1_List1_GUID, "inTitle",
            SPConstants.DOC_LIB, Calendar.getInstance(), "", Site1_List1_URL,
            webstate1);
        List<SPDocument> docs = new ArrayList<SPDocument>();
        if (null != Site1_List1_Item1_URL
            && Site1_List1_Item1_URL.trim().length() > 0) {
          SPDocument doc = new SPDocument("111", Site1_List1_Item1_URL,
              Calendar.getInstance(), ActionType.ADD);
          docs.add(doc);
        }
        if (null != Site1_List1_Item2_URL
            && Site1_List1_Item2_URL.trim().length() > 0) {
          SPDocument doc = new SPDocument("112", Site1_List1_Item2_URL,
              Calendar.getInstance(), ActionType.ADD);
          docs.add(doc);
        }
        liststate11.setCrawlQueue(docs);
        webstate1.AddOrUpdateListStateInWebState(liststate11, new DateTime());
      }
      if (null != Site1_List2_URL && Site1_List2_URL.trim().length() > 0) {
        ListState liststate12 = new ListState(Site1_List2_GUID, "inTitle",
            SPConstants.GENERIC_LIST, Calendar.getInstance(), "",
            Site1_List2_URL, webstate1);
        List<SPDocument> docs = new ArrayList<SPDocument>();
        if (null != Site1_List2_Item1_URL
            && Site1_List2_Item1_URL.trim().length() > 0) {
          SPDocument doc = new SPDocument("121", Site1_List2_Item1_URL,
              Calendar.getInstance(), ActionType.ADD);
          docs.add(doc);
        }
        if (null != Site1_List2_Item2_URL
            && Site1_List2_Item2_URL.trim().length() > 0) {
          SPDocument doc = new SPDocument("122", Site1_List2_Item2_URL,
              Calendar.getInstance(), ActionType.ADD);
          docs.add(doc);
        }
        liststate12.setCrawlQueue(docs);
        webstate1.AddOrUpdateListStateInWebState(liststate12, new DateTime());
      }
    }

    if (null != Site2_URL && Site2_URL.trim().length() > 0) {
      WebState webstate2 = globalState.makeWebState(sharepointClientContext, TestConfiguration.Site2_URL);
      if (null != Site2_List1_URL && Site2_List1_URL.trim().length() > 0) {
        ListState liststate21 = new ListState(Site2_List1_GUID, "inTitle",
            SPConstants.DOC_LIB, Calendar.getInstance(), "", Site2_List1_URL,
            webstate2);
        List<SPDocument> docs = new ArrayList<SPDocument>();
        if (null != Site2_List1_Item1_URL) {
          SPDocument doc = new SPDocument("211", Site2_List1_Item1_URL,
              Calendar.getInstance(), ActionType.ADD);
          docs.add(doc);
        }
        if (null != Site2_List1_Item2_URL) {
          SPDocument doc = new SPDocument("212", Site2_List1_Item2_URL,
              Calendar.getInstance(), ActionType.ADD);
          docs.add(doc);
        }
        liststate21.setCrawlQueue(docs);
        webstate2.AddOrUpdateListStateInWebState(liststate21, new DateTime());
      }
      if (null != Site2_List2_URL && Site2_List2_URL.trim().length() > 0) {
        ListState liststate22 = new ListState(Site1_List2_GUID, "inTitle",
            SPConstants.GENERIC_LIST, Calendar.getInstance(), "",
            Site2_List2_URL, webstate2);
        List<SPDocument> docs = new ArrayList<SPDocument>();
        if (null != Site2_List2_Item1_URL) {
          SPDocument doc = new SPDocument("221", Site2_List2_Item1_URL,
              Calendar.getInstance(), ActionType.ADD);
          docs.add(doc);
        }
        if (null != Site2_List2_Item2_URL) {
          SPDocument doc = new SPDocument("222", Site2_List2_Item2_URL,
              Calendar.getInstance(), ActionType.ADD);
          docs.add(doc);
        }
        liststate22.setCrawlQueue(docs);
        webstate2.AddOrUpdateListStateInWebState(liststate22, new DateTime());
      }
    }

    if (null != Site3_URL && Site3_URL.trim().length() > 0) {
      WebState webstate3 = globalState.makeWebState(sharepointClientContext, TestConfiguration.Site3_URL);
      if (null != Site3_List1_URL && Site3_List1_URL.trim().length() > 0) {
        ListState liststate31 = new ListState(Site3_List1_GUID, "inTitle",
            SPConstants.DOC_LIB, Calendar.getInstance(), "", Site3_List1_URL,
            webstate3);
        List<SPDocument> docs = new ArrayList<SPDocument>();
        if (null != Site3_List1_Item1_URL) {
          SPDocument doc = new SPDocument("311", Site3_List1_Item1_URL,
              Calendar.getInstance(), ActionType.ADD);
          docs.add(doc);
        }
        if (null != Site3_List1_Item2_URL) {
          SPDocument doc = new SPDocument("312", Site3_List1_Item2_URL,
              Calendar.getInstance(), ActionType.ADD);
          docs.add(doc);
        }
        liststate31.setCrawlQueue(docs);
        webstate3.AddOrUpdateListStateInWebState(liststate31, new DateTime());
      }
      if (null != Site3_List2_URL && Site3_List2_URL.trim().length() > 0) {
        ListState liststate32 = new ListState(Site3_List2_GUID, "inTitle",
            SPConstants.GENERIC_LIST, Calendar.getInstance(), "",
            Site3_List2_URL, webstate3);
        List<SPDocument> docs = new ArrayList<SPDocument>();
        if (null != Site3_List2_Item1_URL) {
          SPDocument doc = new SPDocument("321", Site3_List2_Item1_URL,
              Calendar.getInstance(), ActionType.ADD);
          docs.add(doc);
        }
        if (null != Site3_List2_Item2_URL) {
          SPDocument doc = new SPDocument("322", Site2_List2_Item2_URL,
              Calendar.getInstance(), ActionType.ADD);
          docs.add(doc);
        }
        liststate32.setCrawlQueue(docs);
        webstate3.AddOrUpdateListStateInWebState(liststate32, new DateTime());
      }
    }
    if (null != Site4_URL && Site4_URL.trim().length() > 0) {
      WebState webstate4 = globalState.makeWebState(sharepointClientContext, TestConfiguration.Site4_URL);
      if (null != Site4_List1_URL && Site4_List1_URL.trim().length() > 0) {
        ListState liststate41 = new ListState(Site4_List1_GUID, "inTitle",
            SPConstants.DOC_LIB, Calendar.getInstance(), "", Site4_List1_URL,
            webstate4);
        List<SPDocument> docs = new ArrayList<SPDocument>();
        if (null != Site4_List1_Item1_URL) {
          SPDocument doc = new SPDocument("411", Site4_List1_Item1_URL,
              Calendar.getInstance(), ActionType.ADD);
          docs.add(doc);
        }
        if (null != Site4_List1_Item2_URL) {
          SPDocument doc = new SPDocument("412", Site4_List1_Item2_URL,
              Calendar.getInstance(), ActionType.ADD);
          docs.add(doc);
        }
        liststate41.setCrawlQueue(docs);
        webstate4.AddOrUpdateListStateInWebState(liststate41, new DateTime());
      }
      if (null != Site4_List2_URL && Site4_List2_URL.trim().length() > 0) {
        ListState liststate42 = new ListState(Site4_List2_GUID, "inTitle",
            SPConstants.GENERIC_LIST, Calendar.getInstance(), "",
            Site4_List2_URL, webstate4);
        List<SPDocument> docs = new ArrayList<SPDocument>();
        if (null != Site4_List2_Item1_URL) {
          SPDocument doc = new SPDocument("421", Site4_List2_Item1_URL,
              Calendar.getInstance(), ActionType.ADD);
          docs.add(doc);
        }
        if (null != Site4_List2_Item2_URL) {
          SPDocument doc = new SPDocument("422", Site2_List2_Item2_URL,
              Calendar.getInstance(), ActionType.ADD);
          docs.add(doc);
        }
        liststate42.setCrawlQueue(docs);
        webstate4.AddOrUpdateListStateInWebState(liststate42, new DateTime());
      }
    }
    return globalState;
  }
View Full Code Here

   */
  private SPDocumentList traverse(final SharepointClient sharepointClient,
      boolean checkForPendingDocs) {
    if (checkForPendingDocs) {
      WebState ws = globalState.getLastCrawledWeb();
      ListState listState = globalState.getLastCrawledList();
      globalState.setCurrentWeb(ws);
      if (null != ws) {
        ws.setCurrentList(listState);
      }
    }
View Full Code Here

   * @param spDocument The document being processed. This document is the one
   *          from the list maintained here and not the one from crawlqueue of
   *          individual lists
   */
  private void processListStateforCheckPoint(SPDocument spDocument) {
    final ListState listState = spDocument.getParentList();
    final String currentID = Util.getOriginalDocId(spDocument.getDocId(), spDocument.getFeedType());

    // for deleted documents, make sure to remove the extraid from list
    // state and add it to delete cache ids as long as the list itself has
    // not been deleted. Else just remove the list
    // For ADD action, simply mark the document as the reference from where
    // to begin next incremental crawl
    if (ActionType.DELETE.equals(spDocument.getAction())) {
      // Remove ExtraIDs
      if (SPConstants.OBJTYPE_ATTACHMENT.equals(spDocument.getObjType())) {
        listState.removeAttachmntURLFor(currentID, spDocument.getUrl());
      } else {
        listState.removeExtraID(currentID);
      }

      boolean isCurrentDocForList = Util.getCollator().equals(listState.getPrimaryKey(), currentID);

      // A delete feed has being sent from a list
      // Add it to the delete cache so that same delete feed is
      // not reported
      // Check that the docId is not for the current list. The delete
      // cache IDs are for listitems and not for individual lists
      if (!isCurrentDocForList
          && !SPConstants.OBJTYPE_ATTACHMENT.equals(spDocument.getObjType())) {
        listState.addToDeleteCache(currentID);
      }
      if (!listState.isExisting() && isCurrentDocForList) {
        // Last delete feed of a non-existent list has been sent
        // Since list are sent at last and the list is non-exisitng, we
        // can now delete this list state.
        if (LOGGER.isLoggable(Level.CONFIG)) {
          LOGGER.log(Level.CONFIG, "Removing List State info List URL [ "
              + listState.getListURL() + " ].");
        }

        if (spDocument.getParentWeb() != null) {
          spDocument.getParentWeb().removeListStateFromKeyMap(listState);
          spDocument.getParentWeb().removeListStateFromSet(listState);
        }
      }
    } else if (ActionType.ADD.equals(spDocument.getAction())) {
      // The pre-existing logic of checkpointing does not apply to the
      // documents which are being crawled because of any ACL change.
      // This is to keep the regular crawling separate from ACl based
      // crawling.
      if (FeedType.CONTENT_FEED == spDocument.getFeedType()) {
        // Remove document id from delete cache if item is restored back.
        listState.removeFromDeleteCache(currentID);
      }
      if (!spDocument.isForAclChange()) {
        listState.setLastDocProcessed(spDocument);

        // Update ExtraIDs
        if (FeedType.CONTENT_FEED == spDocument.getFeedType()) {
          updateExtraIDs(listState, spDocument, currentID);
        }
      }
    }

    if (LOGGER.isLoggable(Level.FINER)) {
      LOGGER.log(Level.FINER, "Document with DocID [ " + spDocument.getDocId()
          + " ] from List URL [ " + listState.getListURL()
          + " ] is being removed from crawl queue");
    }
    // Remove the document from the crawl queue. No need to remove the
    // documents from DocumentList as the whole list is discarded by the CM
    // at the completion of this traversal.
    listState.removeDocFromCrawlQueue(spDocument);

    if (listState.isCrawlQueueEmpty()) {
      listState.commitAclCrawlStatus();
      if (null == listState.getNextPage()
          && !listState.isNextChangeTokenBlank()) {
        // Since, all the docs are sent, commit the next suitable change
        // token value as current change token which gets used for the
        // subsequent WS calls.
        listState.commitChangeTokenForWSCall();
      }
    }
  }
View Full Code Here

    globalState = TestConfiguration.initState(sharepointClientContext);
  }

  public void testGetAclForUrls() throws Exception {
    WebState webState = globalState.lookupWeb(TestConfiguration.Site1_URL, sharepointClientContext);
    ListState listState = globalState.lookupList(TestConfiguration.Site1_URL, TestConfiguration.Site1_List1_GUID);
    assertNotNull(listState);

    List<SPDocument> testDocs = listState.getCrawlQueue();
    assertNotNull(testDocs);

    // SharePoint document representing list
    SPDocument spdocument = listState.getDocumentInstance(FeedType.CONTENT_FEED);
    testDocs.add(spdocument);

    // SharePoint document representing site landing page(site)
    final SPDocument spdocument2 = siteData.getSiteData(webState);
    testDocs.add(spdocument2);
View Full Code Here

    assertNotSame("Change Token is not updated", changeToken, webstate.getNextAclChangeToken());
  }

  public void testGetListItemsWithInheritingRoleAssignments()
      throws SharepointException {
    ListState listState = globalState.lookupList(TestConfiguration.Site1_URL, TestConfiguration.Site1_List1_GUID);
    assertNotNull(listState);
    listState.startAclCrawl();
    ListsHelper listHelper = new ListsHelper(sharepointClientContext);
    assertNotNull(listHelper);
    aclHelper = new AclHelper(this.sharepointClientContext,
        listState.getParentWebState().getWebUrl());
    List<SPDocument> docs = aclHelper.getListItemsForAclChangeAndUpdateState(
        listState, listHelper);
    assertNotNull(docs);
  }
View Full Code Here

    cLastMod.setTime(new Date());
    GlobalState gs = new GlobalState(clientFactory,
        TestConfiguration.googleConnectorWorkDir,
        TestConfiguration.feedType);
    WebState ws = gs.makeWebState(sharepointClientContext, TestConfiguration.Site1_URL);
    final ListState currentDummyAlertList = new ListState(internalName,
        SPConstants.ALERTS_TYPE, SPConstants.ALERTS_TYPE, cLastMod,
        SPConstants.ALERTS_TYPE, internalName, ws);

    List<SPDocument> lstAlerts = alerts.getAlerts(ws, currentDummyAlertList);
    assertNotNull(lstAlerts);
View Full Code Here

    GlobalState globalState = new GlobalState(
        spContext.getClientFactory(),"temp",FeedType.CONTENT_FEED);
    WebState dummyWebState = globalState.makeWebState(
        spContext, "http://sharepoint.example.com/defaul.aspx");

    ListState list1 = new ListState("{GUID_LIST_1}", "List1", "GenericList",
        Calendar.getInstance(), "List",
        "http://sharepoint.example.com/List1/AllItems.aspx", dummyWebState);
    dummyWebState.AddOrUpdateListStateInWebState(
        list1, Util.calendarToJoda(Calendar.getInstance()));
    ListState list2 = new ListState("{GUID_LIST_2}", "List2", "GenericList",
        Calendar.getInstance(), "List",
        "http://sharepoint.example.com/List2/AllItems.aspx", dummyWebState);
    dummyWebState.AddOrUpdateListStateInWebState(
        list2, Util.calendarToJoda(Calendar.getInstance()));
View Full Code Here

    GlobalState globalState = new GlobalState(
        spContext.getClientFactory(),"temp",FeedType.CONTENT_FEED);
    WebState dummyWebState = globalState.makeWebState(
        spContext, "http://sharepoint.example.com/defaul.aspx");

    ListState list1 = new ListState("{GUID_LIST_1}", "List1", "GenericList",
        Calendar.getInstance(), "List",
        "http://sharepoint.example.com/List1/AllItems.aspx", dummyWebState);
    dummyWebState.AddOrUpdateListStateInWebState(
        list1, Util.calendarToJoda(Calendar.getInstance()));
    ListState list2 = new ListState("{GUID_LIST_2}", "List2", "GenericList",
        Calendar.getInstance(), "List",
        "http://sharepoint.example.com/List2/AllItems.aspx", dummyWebState);
    dummyWebState.AddOrUpdateListStateInWebState(
        list2, Util.calendarToJoda(Calendar.getInstance()));

    List<SPDocument> list1CrawlQueue = new ArrayList<SPDocument>();
    SPDocument document0 = new SPDocument(
        "LIST_ITEM_1", "http://sharepoint.example.com/List1/DispForm.aspx?ID=1",
        Calendar.getInstance(), ActionType.ADD);
    document0.setParentList(list1);
    list1CrawlQueue.add(document0);
    SPDocument document1 = new SPDocument(
        "LIST_ITEM_2",
        "http://sharepoint.example.com/List1/DispForm.aspx?ID=2",
        Calendar.getInstance(), ActionType.ADD);
    document1.setParentList(list1);
    list1CrawlQueue.add(document1);
    list1.setCrawlQueue(list1CrawlQueue);

    SPDocument document2 = new SPDocument("LIST_ITEM_1_LIST2",
        "http://sharepoint.example.com/List2/DispForm.aspx?ID=1",
        Calendar.getInstance(), ActionType.ADD);
    document2.setParentList(list2);
    List<SPDocument> list2CrawlQueue = new ArrayList<SPDocument>();
    list2CrawlQueue.add(document2);
    list2.setCrawlQueue(list2CrawlQueue);

    SPDocumentList traversalResult =
        spClient.traverse(globalState, dummyWebState, 0, true);

    assertNotNull(traversalResult);
    assertEquals(ImmutableList.of(
        document0, document1, document2), traversalResult.getDocuments());
    assertEquals(ImmutableList.of(document0, document1), list1.getCrawlQueue());
    assertEquals(ImmutableList.of(document2), list2.getCrawlQueue());
  }
View Full Code Here

          }

          LOGGER.config("List URL :" + url);

          // Children of all URLs are discovered
          ListState list = new ListState(element.getInternalName(),
              element.getTitle(), element.getBaseType(),
              Util.siteDataStringToCalendar(element.getLastModified()),
              strBaseTemplate, url, webstate);

          list.setInheritedSecurity(element.isInheritedSecurity());
          list.setApplyReadSecurity(element.getReadSecurity() == 2);

          String myNewListConst = "";   
          LOGGER.log(Level.FINE,
              "getting listConst for list URL [{0}]", defaultViewItemUrl);
          if (defaultViewItemUrl != null) {
            final StringTokenizer strTokList =
                new StringTokenizer(defaultViewItemUrl, SPConstants.SLASH);
            if (null != strTokList) {
              while ((strTokList.hasMoreTokens())
                  && (strTokList.countTokens() > 1)) {
                final String listToken = strTokList.nextToken();
                if (list.isDocumentLibrary()
                    && listToken.equals(SPConstants.FORMS_LIST_URL_SUFFIX)
                    && (strTokList.countTokens() == 1)) {
                  break;
                }
                if (null != listToken) {
                  myNewListConst += listToken + SPConstants.SLASH;
                }
              }
              list.setListConst(myNewListConst);
              LOGGER.log(Level.CONFIG, "using listConst [ " + myNewListConst
                  + " ] for list URL [ " + defaultViewItemUrl + " ] ");

              // Apply the URL filter here

              // check if the entire list subtree is to excluded
              // by comparing the prefix of the list URL with the
              // patterns
              if (sharepointClientContext.isIncludedUrl(webstate.getWebUrl()
                  + SPConstants.SLASH + myNewListConst)) {
                // is included check if actual list url itself
                // is to be excluded
                if (sharepointClientContext.isIncludedUrl(url, LOGGER)) {
                  // if a List URL is included, it WILL be
                  // sent as a
                  // Document
                  list.setSendListAsDocument(true);
                } else {
                  // if a List URL is EXCLUDED, it will NOT be
                  // sent as a
                  // Document
                  list.setSendListAsDocument(false);
                }
                // add the attribute(Metadata to the list )
                list = getListWithAllAttributes(list, element);

                listCollection.add(list);
View Full Code Here

TOP

Related Classes of com.google.enterprise.connector.sharepoint.state.ListState

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.