public void releaseIndex(int id) throws MavenServerIndexerException {
   try {
     myIndexer.removeIndexingContext(getIndex(id), false);
   } catch (Exception e) {
     throw new MavenServerIndexerException(wrapException(e));
   }
 }
Beispiel #2
0
  /**
   * Will reindex, shift if needed and publish indexes for a "remote" repository (published over
   * jetty component).
   *
   * @param repositoryRoot
   * @param repositoryId
   * @param deleteIndexFiles
   * @param shiftDays
   * @throws IOException
   */
  protected void reindexRemoteRepositoryAndPublish(
      File repositoryRoot, String repositoryId, boolean deleteIndexFiles, int shiftDays)
      throws IOException, ComponentLookupException {
    File indexDirectory = getIndexFamilyDirectory(repositoryId);

    Directory directory = FSDirectory.getDirectory(indexDirectory);

    IndexingContext ctx =
        nexusIndexer.addIndexingContextForced(
            repositoryId + "-temp",
            repositoryId,
            repositoryRoot,
            directory,
            null,
            null,
            new IndexCreatorHelper(getContainer()).getFullCreators());

    // shifting if needed (very crude way to do it, but heh)
    shiftContextInTime(ctx, shiftDays);

    // and scan "today"
    nexusIndexer.scan(ctx);

    ctx.updateTimestamp(true);

    // pack it up
    File targetDir = new File(repositoryRoot, ".index");

    targetDir.mkdirs();

    IndexPackingRequest ipr = new IndexPackingRequest(ctx, targetDir);

    ipr.setCreateIncrementalChunks(true);

    indexPacker.packIndex(ipr);

    nexusIndexer.removeIndexingContext(ctx, deleteIndexFiles);
  }