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

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


            "type", NotesItem.TEXT, "values", "notes url"));

    NotesConnectorSession connectorSession =
        (NotesConnectorSession) connector.login();
    NotesSession session = connectorSession.createNotesSession();
    NotesDatabase configDb = session.getDatabase("testserver",
        "testconfig.nsf");
    NotesView crawlQueue = configDb.getView(NCCONST.VIEWCRAWLQ);
    assertEquals(1, crawlQueue.getEntryCount());
    NotesDocument docFromQueue = NotesCrawlerThread.getNextFromCrawlQueue(
        session, crawlQueue);
    assertNotNull("No doc from queue", docFromQueue);
    assertEquals(NCCONST.STATEINCRAWL,
View Full Code Here


        + "this_is_a_very_long_file_name_this_is_a_very_long_file_name.doc";

    NotesConnector nc = createNiceMock(NotesConnector.class);
    NotesConnectorSession ncs = createNiceMock(NotesConnectorSession.class);
    NotesSession ns = createMock(NotesSession.class);
    NotesDatabase cdb = createNiceMock(NotesDatabase.class);
    NotesView crawlQ = createNiceMock(NotesView.class);
    expect(ncs.getServer()).andReturn("domino1");
    expect(ncs.getDatabase()).andReturn("gsaconfig.nsf");
    expect(ncs.getSpoolDir()).andReturn("spooldir");
    expect(ncs.createNotesSession()).andReturn(ns);
    expect(ns.getDatabase(isA(String.class), isA(String.class))).andReturn(cdb);
    expect(cdb.getView(isA(String.class))).andReturn(crawlQ);
    expect(cdb.getReplicaID()).andReturn("REPLICA100");

    NotesDocument docCrawl = createNiceMock(NotesDocument.class);
    expect(docCrawl.getUniversalID()).andReturn("UNID100");

    NotesDocument docSrc = createNiceMock(NotesDocument.class);
    NotesEmbeddedObject embObj = createNiceMock(NotesEmbeddedObject.class);
    expect(docSrc.getAttachment(attachmentName)).andReturn(embObj);
    expect(embObj.getType()).andReturn(NotesEmbeddedObject.EMBED_ATTACHMENT);
    expect(embObj.getFileSize()).andReturn(1);

    NotesDocument docAttach = createNiceMock(NotesDocument.class);
    expect(cdb.createDocument()).andReturn(docAttach);
    Capture<String> captureContentPath = new Capture<String>();
    expect(docAttach.replaceItemValue(eq(NCCONST.ITM_CONTENTPATH),
        capture(captureContentPath))).andReturn(null);
    replay(ncs, ns, cdb, crawlQ, docCrawl, docSrc, docAttach, embObj);
View Full Code Here

      LOGGER.logp(Level.FINE, CLASS_NAME, METHOD,
          "Resuming from checkpoint: " + checkpoint);

      ns = ncs.createNotesSession();
      NotesDatabase cdb = ns.getDatabase(ncs.getServer(), ncs.getDatabase());

      // Poll for changes
      // TODO:  Consider moving this to the housekeeping thread
      // Since it takes two polling cycles to get documents into the GSA
      // if the system is idle

      NotesDatabasePoller dbpoller = new NotesDatabasePoller(ncs);
      dbpoller.pollDatabases(ns, cdb, ncs.getMaxCrawlQDepth());
      NotesPollerNotifier npn = ncs.getNotifier();
      npn.wakeWorkers();

      // Give the worker threads a chance to pre-fetch documents
      Thread.sleep(2000);

      // Get list of pre-fetched documents and put these in the doclist
      NotesView submitQ = cdb.getView(NCCONST.VIEWSUBMITQ);
      NotesViewNavigator submitQNav = submitQ.createViewNav();
      NotesViewEntry ve = submitQNav.getFirst();
      int batchSize = 0;
      while (( ve != null) && (batchSize < batchHint)) {
        batchSize++;
View Full Code Here

      return;
    }

    NotesSession session = connectorSession.createNotesSession();
    try {
      NotesDatabase connectorDatabase = session.getDatabase(
          connectorSession.getServer(), connectorSession.getDatabase());
      NotesView databaseView = connectorDatabase.getView(
          NCCONST.VIEWDATABASES);
      NotesDocument databaseDocument = databaseView.getFirstDocument();
      while (databaseDocument != null) {
        String server =
            databaseDocument.getItemValueString(NCCONST.DITM_SERVER);
View Full Code Here

            "Groups for " + gsaName + " are: " + userGroups);

        NotesSession ns = null;
        try {
          ns = ncs.createNotesSession();
          NotesDatabase cdb =
              ns.getDatabase(ncs.getServer(), ncs.getDatabase());
          NotesView securityView = cdb.getView(NCCONST.VIEWSECURITY);
          for (String docId : docIds) {
            NotesViewNavigator secVN = null;
            NotesDocument dbdoc = null;
            try {
              // Extract the database and UNID from the URL
View Full Code Here

          ns.getEnvironmentString(NCCONST.INISERVERKEYFILENAME, true));
      LOGGER.logp(Level.CONFIG, CLASS_NAME, METHOD,
          "Connector debug_outfile: " +
          ns.getEnvironmentString(NCCONST.INIDEBUGOUTFILE, true));

      NotesDatabase db = ns.getDatabase(server, database);
      configValidated = loadConfig(ns,db);

      db.recycle();
      notesDocManager = new NotesDocumentManager(this);
    } catch (Exception e) {
      LOGGER.log(Level.SEVERE, CLASS_NAME, e);
      throw new RepositoryException("NotesConnectorSession error", e);
    } finally {
View Full Code Here

      directory = systemDoc.getItemValueString(
          NCCONST.SITM_DIRECTORY);
      LOGGER.logp(Level.CONFIG, CLASS_NAME, METHOD,
          "Path to Domino directory: " + directory);

      NotesDatabase dirDb = ns.getDatabase(this.getServer(), directory);
      dirDb.recycle();

      userNameFormula = systemDoc.getItemValueString(
          NCCONST.SITM_USERNAMEFORMULA);
      if (0 == userNameFormula.length()) {
        LOGGER.logp(Level.CONFIG, CLASS_NAME, METHOD,
View Full Code Here

    NotesSession ns = null;

    LOGGER.entering(CLASS_NAME, METHOD);
    try {
      ns = ncs.createNotesSession();
      NotesDatabase cdb = ns.getDatabase(
          ncs.getServer(), ncs.getDatabase());

      // Reset the last update date for each configured database
      NotesView incrawlView = cdb.getView(NCCONST.VIEWINCRAWL);
      incrawlView.refresh();
      NotesDocument srcDoc = incrawlView.getFirstDocument();
      while (null != srcDoc) {
        LOGGER.logp(Level.FINER, CLASS_NAME, METHOD,
            "Connector starting - Resetting crawl document found " +
View Full Code Here

    final String METHOD = "resetDatabases";
    NotesSession ns = null;
    LOGGER.entering(CLASS_NAME, METHOD);
    try {
      ns = ncs.createNotesSession();
      NotesDatabase cdb = ns.getDatabase(
          ncs.getServer(), ncs.getDatabase());

      // Reset the last update date for each configured database
      NotesView srcdbView = cdb.getView(NCCONST.VIEWDATABASES);
      srcdbView.refresh();
      NotesDocument srcdbDoc = srcdbView.getFirstDocument();
      while (null != srcdbDoc) {
        LOGGER.logp(Level.FINER, CLASS_NAME, METHOD,
            "Connector reset - Resetting database last update date for "
View Full Code Here

        ns.recycle(lastUpdatedV);
        return;
      }

      // Get modified documents
      NotesDatabase srcdb = ns.getDatabase(null, null);
      srcdb.openByReplicaID(
          srcdbDoc.getItemValueString(NCCONST.DITM_SERVER),
          srcdbDoc.getItemValueString(NCCONST.DITM_REPLICAID));

      // Did the database open succeed? If not exit
      if (!srcdb.isOpen()) {
        LOGGER.logp(Level.FINE, CLASS_NAME, METHOD,
            "Skipping database - Database could not be opened.");
        lastUpdated.recycle();
        ns.recycle(lastUpdatedV);
        srcdb.recycle();
        return;
      }

      String dbName = srcdbDoc.getItemValueString(NCCONST.DITM_DBNAME);
      String authType = srcdbDoc.getItemValueString(NCCONST.DITM_AUTHTYPE);
      LOGGER.log(Level.FINE,
          "{0} database is configured using {1} authentication type",
          new Object[] {dbName, authType});
      if (processACL(ns, cdb, srcdb, srcdbDoc)) {
        // Scan database ACLs and update H2 cache
        LOGGER.log(Level.FINE, "Scan ACLs and update H2 for {0} replica",
            srcdb.getReplicaID());
        notesConnectorSession.getUserGroupManager().updateRoles(srcdb);

        // If the ACL has changed and we are using per Document
        // ACLs we need to resend all documents.
        if (authType.contentEquals(NCCONST.AUTH_ACL)) {
          LOGGER.logp(Level.FINE, CLASS_NAME, METHOD,
              "Database ACL has changed - Resetting last update "
              + "to reindex all document ACLs.");
          lastUpdated = ns.createDateTime("1/1/1980");
        }
      }

      // From the template, we get the search string to determine
      // which documents should be processed
      NotesDocument templateDoc = templateView.getDocumentByKey(
          srcdbDoc.getItemValueString(NCCONST.DITM_TEMPLATE), true);
      String searchString = templateDoc.getItemValueString(
          NCCONST.TITM_SEARCHSTRING);
      LOGGER.logp(Level.FINE, CLASS_NAME, METHOD,
          "Search string is: " + searchString);

      NotesDocumentCollection dc = srcdb.search(searchString, lastUpdated, 0);
      LOGGER.logp(Level.FINE, CLASS_NAME, METHOD,
          srcdb.getFilePath() + " Number of documents to be processed: "
          + dc.getCount());
      NotesDocument curDoc = dc.getFirstDocument();
      while (null != curDoc) {
        String NotesURL = curDoc.getNotesURL();
        LOGGER.logp(Level.FINER, CLASS_NAME, METHOD,
            "Processing document " + NotesURL);
        if (curDoc.hasItem(NCCONST.NCITM_CONFLICT)) {
          LOGGER.logp(Level.FINER, CLASS_NAME, METHOD,
              "Skipping conflict document " + NotesURL);
          NotesDocument prevDoc = curDoc;
          curDoc = dc.getNextDocument(prevDoc);
          prevDoc.recycle();
          continue;
        }

        // Create a new crawl request
        NotesDocument crawlRequestDoc = cdb.createDocument();
        crawlRequestDoc.appendItemValue(NCCONST.NCITM_STATE, NCCONST.STATENEW);
        crawlRequestDoc.appendItemValue(NCCONST.ITM_MIMETYPE,
            NCCONST.DEFAULT_DOCMIMETYPE);

        // Create the fields necessary to crawl the document
        crawlRequestDoc.appendItemValue(NCCONST.ITMFORM,
            NCCONST.FORMCRAWLREQUEST);
        crawlRequestDoc.appendItemValue(NCCONST.NCITM_UNID,
            curDoc.getUniversalID());
        crawlRequestDoc.appendItemValue(NCCONST.NCITM_REPLICAID,
            srcdbDoc.getItemValueString(NCCONST.DITM_REPLICAID));
        crawlRequestDoc.appendItemValue(NCCONST.NCITM_SERVER,
            srcdbDoc.getItemValueString(NCCONST.DITM_SERVER));
        crawlRequestDoc.appendItemValue(NCCONST.NCITM_TEMPLATE,
            srcdbDoc.getItemValueString(NCCONST.DITM_TEMPLATE));
        crawlRequestDoc.appendItemValue(NCCONST.NCITM_DOMAIN,
            srcdbDoc.getItemValueString(NCCONST.DITM_DOMAIN));
        crawlRequestDoc.appendItemValue(NCCONST.NCITM_AUTHTYPE,
            srcdbDoc.getItemValueString(NCCONST.DITM_AUTHTYPE));

        // Map the lock field directly across
        crawlRequestDoc.appendItemValue(NCCONST.ITM_LOCK,
            srcdbDoc.getItemValueString(NCCONST.DITM_LOCKATTRIBUTE)
            .toLowerCase());

        // Add any database level meta data to the document
        crawlRequestDoc.appendItemValue(NCCONST.ITM_GMETAREPLICASERVERS,
            srcdbDoc.getItemValue(NCCONST.DITM_REPLICASERVERS));
        crawlRequestDoc.appendItemValue(NCCONST.ITM_GMETACATEGORIES,
            srcdbDoc.getItemValue(NCCONST.DITM_DBCATEGORIES));
        crawlRequestDoc.appendItemValue(NCCONST.ITM_GMETADATABASE,
            srcdbDoc.getItemValueString(NCCONST.DITM_DBNAME));
        crawlRequestDoc.appendItemValue(NCCONST.ITM_GMETANOTESLINK, NotesURL);

        crawlRequestDoc.save();
        crawlRequestDoc.recycle()//TEST THIS
        crawlRequestDoc = null;
        NotesDateTime lastModified = curDoc.getLastModified();
        if (lastModified.timeDifference(lastUpdated) > 0) {
          lastUpdated = lastModified;
        }
        NotesDocument prevDoc = curDoc;
        curDoc = dc.getNextDocument(prevDoc);
        prevDoc.recycle();
      }
      dc.recycle();

      // Set last modified date
      LOGGER.log(Level.FINE,
          "[{0}] Source database last updated: {1}", new Object[] {
              srcdbDoc.getItemValueString(NCCONST.DITM_DBNAME), lastUpdated});
      srcdbDoc.replaceItemValue(NCCONST.DITM_LASTUPDATE, lastUpdated);
      srcdbDoc.save();

      // TODO: Handle db.search for case where there are more
      // that 5000 documents
      // Suspect this limitation is for DIIOP only and not for RPC access
      // Have sucessfully tested up to 9000 documents

      // Recycle our objects
      srcdb.recycle();
      templateDoc.recycle();
      lastUpdated.recycle();
      ns.recycle(lastUpdatedV);
    } catch (Exception e) {
      LOGGER.log(Level.SEVERE, CLASS_NAME, e);
View Full Code Here

TOP

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

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.