Package com.google.enterprise.connector.sharepoint.spiimpl

Examples of com.google.enterprise.connector.sharepoint.spiimpl.SPDocument$SPContent


        SPConstants.GENERIC_LIST, dt.toCalendar(Locale.ENGLISH), "", url,
        webState);

    ls.setPrimaryKey(primaryKey);
    ls.setType(SPConstants.GENERIC_LIST);
    SPDocument doc = new SPDocument(new Integer(docId).toString(), "X",
        Calendar.getInstance(), null);
    ls.setLastDocProcessed(doc);
    ls.setUrl(url);

    ls.setLastMod(dt);
View Full Code Here


    Random r = new Random();

    for (int i = 0; i < 10; i++) {

      Integer docId = r.nextInt(200000);
      SPDocument doc = null;
      if (i % 3 == 0) {
        doc = new SPDocument(docId.toString(), "X", Calendar.getInstance(),
            ActionType.DELETE);
      } else {
        doc = new SPDocument(docId.toString(), "X", Calendar.getInstance(),
            ActionType.ADD);
      }
      doc.setParentWeb(web);
      doc.setParentList(list);

      listOfDocs.add(doc);
    }

    return listOfDocs;
View Full Code Here

            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());
View Full Code Here

          if (idPos == -1) {
            if (FeedType.CONTENT_FEED == sharepointClientContext.getFeedType()) {
              docId = SPConstants.ALERT_SUFFIX_IN_DOCID
                  + alertListState.getListURL() + SPConstants.DOC_TOKEN + docId;
            }
            final SPDocument doc = new SPDocument(docId,
                element.getEditAlertUrl(), c, SPConstants.NO_AUTHOR,
                SPConstants.ALERTS_TYPE, parentWeb.getTitle(),
                sharepointClientContext.getFeedType(),
                parentWeb.getSharePointType());

            lstAllAlerts.add(doc);
          } else {
            knownAlerts.delete(idPos, idPos + docId.length());
          }
        } // End of For

        // Create delete feed docs for all those alerts which have been
        // deleted.
        if (FeedType.CONTENT_FEED == sharepointClientContext.getFeedType()) {
          final Pattern pat = Pattern.compile("\\{.+\\}");
          final Matcher match = pat.matcher(knownAlerts);
          if (match.find()) {
            final String idPart = match.group();
            final String docId = SPConstants.ALERT_SUFFIX_IN_DOCID
                + alertListState.getListURL() + SPConstants.DOC_TOKEN + idPart;
            final SPDocument doc = new SPDocument(docId,
                alertListState.getListURL(), alertListState.getLastModCal(),
                SPConstants.NO_AUTHOR, SPConstants.ALERTS_TYPE,
                parentWeb.getTitle(), sharepointClientContext.getFeedType(),
                parentWeb.getSharePointType());
            doc.setAction(ActionType.DELETE);
            lstAllAlerts.add(doc);
          }
        }
        alertListState.setIDs(currentAlerts);
      } catch (final Exception e) {
View Full Code Here

    }

    if (FeedType.CONTENT_FEED == sharepointClientContext.getFeedType()) {
      docId = list.getListURL() + SPConstants.DOC_TOKEN + docId;     
    }
    SPDocument doc = new SPDocument(docId, url.toString(), calMod, author,
        strObjectType, list.getParentWebState().getTitle(),
        sharepointClientContext.getFeedType(), list.getParentWebState().getSharePointType());
    doc.setFileref(fileref);
    doc.setDisplayUrl(displayUrl);
    doc.setParentList(list);
    boolean skipAttributes = isFolder && !isFeedable;
    doc.setEmptyDocument(skipAttributes);
    if (skipAttributes) {
      LOGGER.log(Level.FINE, "FeedType = ["
          + sharepointClientContext.getFeedType() + "] isInitialTraversal = ["
          + sharepointClientContext.isInitialTraversal() + "]");
      if ((sharepointClientContext.getFeedType() == FeedType.METADATA_URL_FEED)
          || sharepointClientContext.isInitialTraversal()) {       
        doc.setDocumentType(DocumentType.ACL);
      }
    }

    if (fileSize != null && !fileSize.equals("")) {
      try {
        doc.setFileSize(Integer.parseInt(fileSize));
      } catch (NumberFormatException nfe) {
        // Just log the message in case of errors.
        if (LOGGER.isLoggable(Level.FINEST)) {
          LOGGER.log(Level.FINEST, "Problems while parsing the file size attribute",
              nfe.getMessage());
        }
      }
    } else if (LOGGER.isLoggable(Level.FINER)) {
      // Just log for any doc level debugging purposes
      LOGGER.finer("No file size attribute retrieved for document : "
          + doc.getUrl());
    }

    // iterate through all the attributes get the atribute name and value
    if (itAttrs != null && !skipAttributes) {
      while (itAttrs.hasNext()) {
        final Object oneAttr = itAttrs.next();
        if (oneAttr != null) {
          String strAttrName = oneAttr.toString();
          if ((strAttrName != null) && (!strAttrName.trim().equals(""))) {
            String strAttrValue = listItem.getAttribute(strAttrName);
            // Apply the well known rules of name resolution and
            // normalizing the values
            strAttrName = Util.normalizeMetadataName(strAttrName);
            strAttrValue = Util.normalizeMetadataValue(strAttrValue);
            if (sharepointClientContext.isIncludeMetadata(strAttrName)) {
              doc.setAttribute(strAttrName, strAttrValue);
            } else {
              LOGGER.log(Level.FINE, "Excluding metadata name [ " + strAttrName
                  + " ], value [ " + strAttrValue + " ] for doc URL [ " + url
                  + " ]. ");
            }
View Full Code Here

          } catch (final Exception e) {
            LOGGER.log(Level.WARNING, "Failed to load lastCrawledDocLastModified for List [ "
                + list.getListURL() + " ]. ", e);
          }

          SPDocument lastCrawledDoc = new SPDocument(lastCrawledDocId,
              lastCrawledDocURL, lastCrawledDocLastMod, lastCrawledDocAction);
          lastCrawledDoc.setParentFolder(lastCrawledDocParentFolder);
          lastCrawledDoc.setRenamedFolder(lastCrawledDocRenamedFolder);
          list.setLastDocProcessed(lastCrawledDoc);
        } else {
          LOGGER.log(Level.SEVERE, "Cannot parse the current LastDocCrawled node because the expected ListState/WebState parent has not been initialized. This may occur because of the bad sequence / wrong hierarchy of stateful objects.");
        }
      } else if (SPConstants.STATE_RENAMED_FOLDER_LIST.equals(localName)) {
View Full Code Here

    GlobalState gs = new GlobalState(clientFactory,
        TestConfiguration.googleConnectorWorkDir,
        TestConfiguration.feedType);
    this.webState = TestConfiguration.createWebState(gs, sharepointClientContext, this.spURL, 1);
    final SPDocument doc1 = new SPDocument("id1", "url1",
        new GregorianCalendar(2007, 1, 1), SPConstants.NO_AUTHOR,
        SPConstants.NO_OBJTYPE, SPConstants.PARENT_WEB_TITLE,
        FeedType.CONTENT_FEED, SPType.SP2007);
    final SPDocument doc2 = new SPDocument("id2", "url2",
        new GregorianCalendar(2007, 1, 2), SPConstants.NO_AUTHOR,
        SPConstants.NO_OBJTYPE, SPConstants.PARENT_WEB_TITLE,
        FeedType.CONTENT_FEED, SPType.SP2007);
    final SPDocument doc3 = new SPDocument("id3", "url3",
        new GregorianCalendar(2007, 1, 3), SPConstants.NO_AUTHOR,
        SPConstants.NO_OBJTYPE, SPConstants.PARENT_WEB_TITLE,
        FeedType.CONTENT_FEED, SPType.SP2007);

    ListState testList = null;
View Full Code Here

    list.setLastCrawledDateTime(Util.getCurrentTimestampString());
    list.setAttchmnts(new StringBuffer("X"));
    list.addToDeleteCache("X");
    list.setIDs(new StringBuffer("X"));

    final SPDocument doc = new SPDocument("DocID", "DocURL",
        new GregorianCalendar(2007, 1, 1), SPConstants.NO_AUTHOR,
        SPConstants.NO_OBJTYPE, SPConstants.PARENT_WEB_TITLE,
        TestConfiguration.feedType, ws.getSharePointType());
    doc.setParentFolder(new Folder("/X/XX", "1"));

    list.setLastDocProcessed(doc);
    ws.AddOrUpdateListStateInWebState(list, dt);
    ws.setCurrentList(list);
    state1.setCurrentWeb(ws);
View Full Code Here

        TestConfiguration.Site1_List1_URL, null);
    assertEquals(cal1, list1.getDateForWSRefresh());

    Calendar cal2 = Calendar.getInstance();
    cal2.add(Calendar.MONTH, -1);
    list1.setLastDocProcessed(new SPDocument("1", "X", cal2, ActionType.ADD));
    assertEquals(cal2, list1.getDateForWSRefresh());
  }
View Full Code Here

    ListState list1 = new ListState(TestConfiguration.Site1_List1_GUID,
        "No Title", SPConstants.DOC_LIB, cal1, SPConstants.NO_TEMPLATE,
        TestConfiguration.Site1_List1_URL, null);
    assertNull(list1.getLastDocForWSRefresh());

    SPDocument doc1 = new SPDocument("1", "X", cal1, SPConstants.NO_AUTHOR,
        SPConstants.DOCUMENT, "XX", FeedType.METADATA_URL_FEED, SPType.SP2007);
    list1.setLastDocProcessed(doc1);
    assertEquals(doc1, list1.getLastDocForWSRefresh());

    SPDocument doc2 = new SPDocument("2", "X", cal1, SPConstants.NO_AUTHOR,
        SPConstants.DOCUMENT, "XX", FeedType.METADATA_URL_FEED, SPType.SP2007);
    SPDocument doc3 = new SPDocument("3", "X", cal1, SPConstants.NO_AUTHOR,
        SPConstants.DOCUMENT, "XX", FeedType.METADATA_URL_FEED, SPType.SP2007);
    SPDocument doc4 = new SPDocument("4", "X", cal1, SPConstants.NO_AUTHOR,
        SPConstants.DOCUMENT, "XX", FeedType.METADATA_URL_FEED, SPType.SP2007);
    List<SPDocument> docs = new LinkedList<SPDocument>();
    docs.add(doc2);
    docs.add(doc3);
    docs.add(doc4);
    list1.setCrawlQueue(docs);
    assertEquals(doc4, list1.getLastDocForWSRefresh());

    doc4.setAction(ActionType.DELETE);
    assertEquals(doc3, list1.getLastDocForWSRefresh());
  }
View Full Code Here

TOP

Related Classes of com.google.enterprise.connector.sharepoint.spiimpl.SPDocument$SPContent

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.