public List processArtifacts()

in maven2-server-impl/src/org/jetbrains/idea/maven/server/embedder/Maven2ServerIndexerImpl.java [187:232]


  public List<IndexedMavenId> processArtifacts(MavenIndexId indexId, int startFrom, MavenToken token)
    throws MavenServerIndexerException {

    MavenServerUtil.checkToken(token);
    try {
      final int CHUNK_SIZE = 10000;
      IndexingContext context = getIndex(indexId);
      synchronized (context) {
        IndexReader r = getIndex(indexId).getIndexReader();
        int total = r.numDocs();

        List<IndexedMavenId> result = new ArrayList<IndexedMavenId>(Math.min(CHUNK_SIZE, total));
        for (int i = startFrom; i < total; i++) {
          if (r.isDeleted(i)) continue;

          Document doc = r.document(i);
          String uinfo = doc.get(ArtifactInfo.UINFO);
          if (uinfo == null) continue;
          String[] uInfoParts = uinfo.split("\\|");
          if (uInfoParts.length < 3) continue;
          String groupId = uInfoParts[0];
          String artifactId = uInfoParts[1];
          String version = uInfoParts[2];

          String packaging = doc.get(ArtifactInfo.PACKAGING);
          String description = doc.get(ArtifactInfo.DESCRIPTION);

          result.add(new IndexedMavenId(groupId, artifactId, version, packaging, description));

          if (result.size() == CHUNK_SIZE) {
            return result;
          }
        }

        if (result.isEmpty()) {
          return null;
        }
        else {
          return result;
        }
      }
    }
    catch (Exception e) {
      throw new MavenServerIndexerException(wrapException(e));
    }
  }