Пример #1
0
 private void checkSubstance(ArchivalUnit au) {
   SubstanceChecker subChecker = new SubstanceChecker(au);
   if (!subChecker.isEnabled()) {
     errMsg = "No substance patterns defined for plugin.";
     return;
   }
   AuState auState = AuUtil.getAuState(au);
   SubstanceChecker.State oldState = auState.getSubstanceState();
   SubstanceChecker.State newState = subChecker.findSubstance();
   String chtxt = (newState == oldState ? "(unchanged)" : "(was " + oldState.toString() + ")");
   switch (newState) {
     case Unknown:
       log.error("Shouldn't happen: SubstanceChecker returned Unknown");
       errMsg = "Error in SubstanceChecker; see log.";
       break;
     case Yes:
       statusMsg = "AU has substance " + chtxt + ": " + au.getName();
       auState.setSubstanceState(SubstanceChecker.State.Yes);
       break;
     case No:
       statusMsg = "AU has no substance " + chtxt + ": " + au.getName();
       auState.setSubstanceState(SubstanceChecker.State.No);
       break;
   }
 }
Пример #2
0
  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;
  }
 private List getSummaryInfo(CrawlerStatus status) {
   List res = new ArrayList();
   StatusTable.SummaryInfo statusSi =
       new StatusTable.SummaryInfo(
           "Status", ColumnDescriptor.TYPE_STRING, status.getCrawlStatusMsg());
   ArchivalUnit au = status.getAu();
   if (au != null) {
     AuState aus = AuUtil.getAuState(au);
     if (status.getCrawlStatus() == Crawler.STATUS_SUCCESSFUL && aus.hasNoSubstance()) {
       statusSi.setValueFootnote(FOOT_NO_SUBSTANCE_CRAWL_STATUS);
     }
   }
   res.add(statusSi);
   String sources = StringUtil.separatedString(status.getSources());
   res.add(new StatusTable.SummaryInfo("Source", ColumnDescriptor.TYPE_STRING, sources));
   String startUrls = StringUtil.separatedString(status.getStartUrls());
   res.add(
       new StatusTable.SummaryInfo("Starting Url(s)", ColumnDescriptor.TYPE_STRING, startUrls));
   return res;
 }
Пример #4
0
  /**
   * Provides the status information of an archival unit in the system.
   *
   * @param auId A String with the identifier of the archival unit.
   * @return an AuStatus with the status information of the archival unit.
   * @throws LockssWebServicesFault
   */
  AuStatus getAuStatus(String auId) throws LockssWebServicesFault {
    final String DEBUG_HEADER = "getAuStatus(): ";

    LockssDaemon theDaemon = LockssDaemon.getLockssDaemon();
    PluginManager pluginMgr = theDaemon.getPluginManager();
    ArchivalUnit au = pluginMgr.getAuFromId(auId);

    if (au == null) {
      throw new LockssWebServicesFault(
          "No Archival Unit with provided identifier",
          new LockssWebServicesFaultInfo("Archival Unit identifier = " + auId));
    }

    AuStatus result = new AuStatus();
    result.setVolume(au.getName());

    TitleConfig tc = au.getTitleConfig();
    if (tc != null) {
      result.setJournalTitle(tc.getJournalTitle());
    }

    Plugin plugin = au.getPlugin();
    result.setPluginName(plugin.getPluginName());

    result.setYear(AuUtil.getTitleAttribute(au, "year"));

    NodeManager nodeMgr = theDaemon.getNodeManager(au);
    AuState state = nodeMgr.getAuState();
    AuState.AccessType atype = state.getAccessType();

    if (atype != null) {
      result.setAccessType(atype.toString());
    }

    long contentSize = AuUtil.getAuContentSize(au, false);

    if (contentSize != -1) {
      result.setContentSize(contentSize);
    }

    long du = AuUtil.getAuDiskUsage(au, false);

    if (du != -1) {
      result.setDiskUsage(du);
    }

    String spec = LockssRepositoryImpl.getRepositorySpec(au);
    String repo =
        LockssRepositoryImpl.mapAuToFileLocation(
            LockssRepositoryImpl.getLocalRepositoryPath(spec), au);
    result.setRepository(repo);

    CachedUrlSet auCus = au.getAuCachedUrlSet();
    NodeState topNode = nodeMgr.getNodeState(auCus);

    if (AuUtil.getProtocolVersion(au) == Poll.V3_PROTOCOL) {
      if (state.getV3Agreement() < 0) {
        if (state.getLastCrawlTime() < 0) {
          result.setStatus("Waiting for Crawl");
        } else {
          result.setStatus("Waiting for Poll");
        }
      } else {
        result.setStatus(doubleToPercent(state.getHighestV3Agreement()) + "% Agreement");
        if (state.getHighestV3Agreement() != state.getV3Agreement()) {
          result.setRecentPollAgreement(state.getV3Agreement());
        }
      }
    } else {
      result.setStatus(topNode.hasDamage() ? "Repairing" : "Ok");
    }

    String publishingPlatform = plugin.getPublishingPlatform();

    if (!StringUtil.isNullString(publishingPlatform)) {
      result.setPublishingPlatform(publishingPlatform);
    }

    String publisher = AuUtil.getTitleAttribute(au, "publisher");

    if (!StringUtil.isNullString(publisher)) {
      result.setPublisher(publisher);
    }

    result.setAvailableFromPublisher(!AuUtil.isPubDown(au));
    result.setSubstanceState(state.getSubstanceState().toString());
    result.setCreationTime(state.getAuCreationTime());

    AuUtil.AuProxyInfo aupinfo = AuUtil.getAuProxyInfo(au);

    if (aupinfo.isAuOverride()) {
      String disp =
          (aupinfo.getHost() == null
              ? "Direct connection"
              : aupinfo.getHost() + ":" + aupinfo.getPort());
      result.setCrawlProxy(disp);
    }

    CrawlWindow window = au.getCrawlWindow();

    if (window != null) {
      String wmsg = window.toString();

      if (wmsg.length() > 140) {
        wmsg = "(not displayable)";
      }

      if (!window.canCrawl()) {
        wmsg = "Currently closed: " + wmsg;
      }

      result.setCrawlWindow(wmsg);
    }

    String crawlPool = au.getFetchRateLimiterKey();

    if (crawlPool == null) {
      crawlPool = "(none)";
    }

    result.setCrawlPool(crawlPool);

    result.setLastCompletedCrawl(state.getLastCrawlTime());

    long lastCrawlAttempt = state.getLastCrawlAttempt();

    if (lastCrawlAttempt > 0) {
      result.setLastCrawl(lastCrawlAttempt);
      result.setLastCrawlResult(state.getLastCrawlResultMsg());
    }

    long lastTopLevelPollTime = state.getLastTopLevelPollTime();

    if (lastTopLevelPollTime > 0) {
      result.setLastCompletedPoll(lastTopLevelPollTime);
    }

    long lastPollStart = state.getLastPollStart();

    if (lastPollStart > 0) {
      result.setLastPoll(lastPollStart);
      String pollResult = state.getLastPollResultMsg();

      if (!StringUtil.isNullString(pollResult)) {
        result.setLastPollResult(state.getLastPollResultMsg());
      }
    }

    result.setCurrentlyCrawling(
        theDaemon.getCrawlManager().getStatusSource().getStatus().isRunningNCCrawl(au));

    result.setCurrentlyPolling(theDaemon.getPollManager().isPollRunning(au));

    if (theDaemon.isDetectClockssSubscription()) {
      result.setSubscriptionStatus(AuUtil.getAuState(au).getClockssSubscriptionStatusString());
    }

    if (log.isDebug2()) log.debug2(DEBUG_HEADER + "result = " + result);
    return result;
  }
 protected void setAuAccessType(Crawler.PermissionHelper pHelper, AuState.AccessType accessType) {
   ArchivalUnit au = pHelper.getAu();
   AuState aus = AuUtil.getAuState(au);
   aus.setAccessType(accessType);
 }