コード例 #1
0
ファイル: DebugPanel.java プロジェクト: edina/lockss-daemon
  private boolean startReindexingMetadata(ArchivalUnit au, boolean force) {
    if (metadataMgr == null) {
      errMsg = "Metadata processing is not enabled.";
      return false;
    }

    if (!force) {
      if (!AuUtil.hasCrawled(au)) {
        errMsg = "Au has never crawled. Click again to reindex metadata";
        showForceReindexMetadata = true;
        return false;
      }

      AuState auState = AuUtil.getAuState(au);
      switch (auState.getSubstanceState()) {
        case No:
          errMsg = "Au has no substance. Click again to reindex metadata";
          showForceReindexMetadata = true;
          return false;
        case Unknown:
          errMsg = "Unknown substance for Au. Click again to reindex metadata.";
          showForceReindexMetadata = true;
          return false;
        case Yes:
          // fall through
      }
    }

    // Fully reindex metadata with the highest priority.
    Connection conn = null;
    PreparedStatement insertPendingAuBatchStatement = null;

    try {
      conn = dbMgr.getConnection();
      insertPendingAuBatchStatement = metadataMgr.getPrioritizedInsertPendingAuBatchStatement(conn);

      if (metadataMgr.enableAndAddAuToReindex(
          au, conn, insertPendingAuBatchStatement, false, true)) {
        statusMsg = "Reindexing metadata for " + au.getName();
        return true;
      }
    } catch (DbException dbe) {
      log.error("Cannot reindex metadata for " + au.getName(), dbe);
    } finally {
      DbManager.safeCloseStatement(insertPendingAuBatchStatement);
      DbManager.safeRollbackAndClose(conn);
    }

    if (force) {
      errMsg = "Still cannot reindex metadata for " + au.getName();
    } else {
      errMsg = "Cannot reindex metadata for " + au.getName();
    }
    return false;
  }
コード例 #2
0
 /**
  * Returns a list of BibliographicItems from the metadata database.
  *
  * @return a list of BibliobraphicItems from the metadata database.
  */
 public static List<BibliographicItem> getBibliographicItems() {
   List<BibliographicItem> items = Collections.<BibliographicItem>emptyList();
   Connection conn = null;
   try {
     DbManager dbManager = getDaemon().getDbManager();
     conn = dbManager.getConnection();
     items = getBibliographicItems(dbManager, conn);
   } catch (DbException ex) {
     log.warning(ex.getMessage());
     log.warning("bibliographicItemsQuery = " + bibliographicItemsQuery);
   } finally {
     DbManager.safeRollbackAndClose(conn);
   }
   return items;
 }