/** * 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); }
public int createIndex( @NotNull String indexId, @NotNull String repositoryId, @Nullable File file, @Nullable String url, @NotNull File indexDir) throws MavenServerIndexerException { try { IndexingContext context = myIndexer.addIndexingContextForced( indexId, repositoryId, file, indexDir, url, null, // repo update url NexusIndexer.FULL_INDEX); int id = System.identityHashCode(context); myIndices.put(id, context); return id; } catch (Exception e) { throw new MavenServerIndexerException(wrapException(e)); } }