Package com.google.enterprise.connector.notes.client

Examples of com.google.enterprise.connector.notes.client.NotesItem


  @Override
  public Vector getColumnValues() throws RepositoryException {
    LOGGER.entering(CLASS_NAME, "getColumnValues");
    Vector<Object> values = new Vector<Object>();
    for (String field: view.getFields()) {
      NotesItem item = document.getFirstItem(field);
      values.add(item.getValues().get(0));
    }
    return values;
  }
View Full Code Here


        }
        pstmt.executeBatch();
        pstmt.close();
       
        // Insert attachment names
        NotesItem itemAttachmentIds =
            docIndexed.getFirstItem(NCCONST.ITM_GMETAATTACHMENTDOCIDS);
        if (itemAttachmentIds != null) {
          Vector attachmentIds = itemAttachmentIds.getValues();
          if (attachmentIds != null && attachmentIds.size() > 0) {
            pstmt = connection.prepareStatement(
                "insert into " + attachmentsTableName
                + "(attachment_unid, docid) values(?,?)");
            for (int i = 0; i < attachmentIds.size(); i++) {
View Full Code Here

      Vector<Integer> authorItems = new Vector<Integer>();

      // Find the Readers field(s), if any. There can be more
      // than one Readers field.
      for (int i = 0; i < allItems.size(); i++) {
        NotesItem item = (NotesItem) allItems.elementAt(i);
        if (item.isReaders()) {
          boolean hasCurrentItemReaders =
              copyValues(item, authorReaders, "readers");
          hasReaders = hasCurrentItemReaders || hasReaders;
        } else if (item.isAuthors()) {
          authorItems.add(i);
        }
      }
      // If there are Readers, add any Authors to the Readers list
      // for AuthZ purposes. With no Readers, database security applies.
View Full Code Here

  @VisibleForTesting
  void mapMetaFields(NotesDocument crawlDoc, NotesDocument srcDoc)
      throws RepositoryException {
    final String METHOD = "mapMetaFields";
    LOGGER.entering(CLASS_NAME, METHOD);
    NotesItem item = null;
    for (MetaField mf : metaFields) {
      try {
        if (null == mf.getFieldName()) {
          if (LOGGER.isLoggable(Level.FINEST)) {
            LOGGER.logp(Level.FINEST, CLASS_NAME, METHOD,
                "Skipping null fieldname");
          }
          continue;
        }
        String configForm = mf.getFormName();
        if (null != configForm) {
          String docForm = srcDoc.getItemValueString(NCCONST.ITMFORM);
          if (!configForm.equalsIgnoreCase(docForm)) {
            if (LOGGER.isLoggable(Level.FINEST)) {
              LOGGER.logp(Level.FINEST, CLASS_NAME, METHOD,
                  "Skipping metafields because configured form {0} does not "
                  + "match doc form {1}",
                  new Object[] { configForm, docForm });
            }
            continue;
          }
        }
        if (!srcDoc.hasItem(mf.getFieldName())) {
          if (LOGGER.isLoggable(Level.FINEST)) {
            LOGGER.logp(Level.FINEST, CLASS_NAME, METHOD,
                "Source doc does not have field: " + mf.getFieldName());
          }
          continue;
        }
        // If there are multiple items with the same name (not a
        // common Notes occurrence), only the first item will be
        // mapped.
        item = srcDoc.getFirstItem(mf.getFieldName());
        if (null == item.getValues()) {
          if (LOGGER.isLoggable(Level.FINEST)) {
            LOGGER.logp(Level.FINEST, CLASS_NAME, METHOD,
                "Source doc does not have value for: " + mf.getFieldName());
          }
          continue;
        }
        Object content = item;
        if (item.getType() == NotesItem.RICHTEXT) {
          content = item.getText(2 * 1024);
        }
        if (crawlDoc.hasItem(META_FIELDS_PREFIX + mf.getMetaName())) {
          LOGGER.logp(Level.WARNING, CLASS_NAME, METHOD,
              "Mapping meta fields: meta field {0} already exists in crawl doc",
              mf.getMetaName());
          // If multiple Notes fields are mapped to the same meta
          // field, only the first mapping will be used.
          continue;
        }
        crawlDoc.replaceItemValue(META_FIELDS_PREFIX + mf.getMetaName(),
            content);
        if (LOGGER.isLoggable(Level.FINEST)) {
          LOGGER.logp(Level.FINEST, CLASS_NAME, METHOD,
              "Mapped meta field : " + META_FIELDS_PREFIX
              + mf.getMetaName() + " =  " + content);
        }
      } catch (RepositoryException e) {
        LOGGER.logp(Level.WARNING, CLASS_NAME, METHOD,
            "Error mapping MetaField " + mf, e);
      } finally {
        if (null != item) {
          item.recycle();
        }
      }
    }
    LOGGER.exiting(CLASS_NAME, METHOD);
  }
View Full Code Here

        if ((fieldName.charAt(0) == '$') ||
            (fieldName.equalsIgnoreCase("form"))) {
          continue;
        }
        content.append("\n");
        NotesItem tmpItem = srcDoc.getFirstItem(fieldName);
        if (null != tmpItem) {
          // Must use getText to get more than 64k of text
          content.append(tmpItem.getText(2 * 1024 * 1024));
          tmpItem.recycle();
        }
      }
      LOGGER.exiting(CLASS_NAME, METHOD);
      return content.toString();
    }

    // Otherwise we will index all allowable fields
    Vector <?> vi = srcDoc.getItems();
    for (int j = 0; j < vi.size(); j++) {
      NotesItem itm = (NotesItem) vi.elementAt(j);
      String ItemName = itm.getName();
      if ((ItemName.charAt(0) == '$') || (ItemName.equalsIgnoreCase("form"))) {
        continue;
      }
      int type = itm.getType();
      switch (type) {
        case NotesItem.TEXT:
        case NotesItem.NUMBERS:
        case NotesItem.DATETIMES:
        case NotesItem.RICHTEXT:
        case NotesItem.NAMES:
        case NotesItem.AUTHORS:
        case NotesItem.READERS:
          content.append("\n");
          NotesItem tmpItem = srcDoc.getFirstItem(ItemName);
          if (null != tmpItem) {
            // Must use getText to get more than 64k of text
            content.append(tmpItem.getText(2 * 1024 * 1024));
            tmpItem.recycle();
          }
          break;
        default:
          break;
      }
View Full Code Here

      // When there are multiple attachments with the same name
      // Lotus Notes automatically generates unique names for next document
      Vector<?> va = ns.evaluate("@AttachmentNames", srcDoc);
      Vector<String> docIds = new Vector<String>();

      NotesItem attachItems = crawlDoc.replaceItemValue(
          NCCONST.ITM_GMETAATTACHMENTS, "");
      for (int i = 0; i < va.size(); i++) {
        String attachName = va.elementAt(i).toString();

        if (attachName.length() == 0) {
          continue;
        }
        String xtn = null;
        int period = attachName.lastIndexOf(".");
        if (period == -1) {
          xtn = "";
        } else {
          xtn = attachName.substring(period + 1);
        }
        if (!ncs.isExcludedExtension(xtn.toLowerCase())) {
          String docId = createAttachmentDoc(crawlDoc, srcDoc,
              attachName, ncs.getMimeType(xtn));
          if (docId != null) {
            attachItems.appendToTextList(attachName);
            docIds.add(docId);
          } else {
            LOGGER.log(Level.FINER,
                "Attachment document was not created for {0}", attachName);
          }
View Full Code Here

    }
  }

  private void updateTextList(NotesDocument dbdoc, String itemName,
      Collection<String> textData) throws RepositoryException {
    NotesItem item = dbdoc.replaceItemValue(itemName, null);
    try {
      item.setSummary(false);
      for (String text : textData) {
        item.appendToTextList(text);
      }
    } finally {
      item.recycle();
    }
  }
View Full Code Here

  @VisibleForTesting
  void setMetaFields() throws RepositoryException {
    Vector items = crawlDoc.getItems();
    for (Object i : items) {
      NotesItem item = (NotesItem) i;
      String name = item.getName();
      if (!name.startsWith(NotesCrawlerThread.META_FIELDS_PREFIX)) {
        continue;
      }
      if (LOGGER.isLoggable(Level.FINEST)) {
        LOGGER.finest("found a custom property to map to a meta field: "
View Full Code Here

  // Items with multiple values are separated by semicolons
  protected void putTextItem(String PropName, String ItemName,
      String defaultText) throws RepositoryException {
    final String METHOD = "putTextItem";
    String text = null;
    NotesItem itm = crawlDoc.getFirstItem(ItemName);

    // Does the item exist?
    if (itm == null) {
      if (defaultText != null) {
        docProps.put(PropName, asList(Value.getStringValue(defaultText)));
      }
      return;
    }

    // Get the text of the item
    text = itm.getText(1024 * 1024 * 2)// Maximum of 2mb of text
    if (Strings.isNullOrEmpty(text)) { // Does this field exist?
      LOGGER.logp(Level.FINEST, CLASS_NAME, METHOD,
          "Using default value document. " + PropName + " in " + docid);
      if (defaultText != null) {
        text = defaultText;
View Full Code Here

TOP

Related Classes of com.google.enterprise.connector.notes.client.NotesItem

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.