Examples of IteratorSearchResponse


Examples of org.apache.maven.index.IteratorSearchResponse

  protected void searchFor(String groupId, int expected)
      throws IOException
  {
    Query query = indexerManager.constructQuery(MAVEN.GROUP_ID, groupId, SearchType.EXACT);

    IteratorSearchResponse response;

    try {
      response = indexerManager.searchQueryIterator(query, null, null, null, null, false, null);
    }
    catch (NoSuchRepositoryException e) {
      // will not happen since we are not selecting a repo to search
      throw new IOException("Huh?");
    }

    try {
      ArrayList<ArtifactInfo> results = new ArrayList<ArtifactInfo>(response.getTotalHits());

      for (ArtifactInfo hit : response) {
        results.add(hit);
      }

      assertEquals("Query \"" + query + "\" returned wrong results: " + results + "!", expected, results.size());
    }
    finally {
      response.close();
    }
  }
View Full Code Here

Examples of org.apache.maven.index.IteratorSearchResponse

  }

  protected void searchForKeywordNG(String term, int expected)
      throws Exception
  {
    IteratorSearchResponse result =
        indexerManager.searchArtifactIterator(term, null, null, null, null, false, SearchType.SCORED, null);

    try {
      if (expected != result.getTotalHits()) {
        // dump the stuff
        StringBuilder sb = new StringBuilder("Found artifacts:\n");

        for (ArtifactInfo ai : result) {
          sb.append(ai.context).append(" : ").append(ai.toString()).append("\n");
        }

        fail(sb.toString() + "\nUnexpected result set size! We expected " + expected + " but got "
            + result.getTotalHits());
      }
    }
    finally {
      result.close();
    }
  }
View Full Code Here

Examples of org.apache.maven.index.IteratorSearchResponse

  protected void searchFor(String groupId, int expected, String repoId)
      throws IOException, Exception
  {
    Query q = indexerManager.constructQuery(MAVEN.GROUP_ID, groupId, SearchType.EXACT);

    IteratorSearchResponse response = indexerManager.searchQueryIterator(q, repoId, null, null, null, false, null);
    try {
      ArrayList<ArtifactInfo> ais = new ArrayList<ArtifactInfo>(response.getTotalHits());

      for (ArtifactInfo ai : response) {
        ais.add(ai);
      }

      assertEquals(ais.toString(), expected, ais.size());
    }
    finally {
      response.close();
    }
  }
View Full Code Here

Examples of org.apache.maven.index.IteratorSearchResponse

        new ResourceStoreRequest("/org/sonatype/nexus5525/bundle/1.0-SNAPSHOT/" + pomFile.getName()),
        new FileInputStream(pomFile), null);

    wairForAsyncEventsToCalmDown();

    IteratorSearchResponse response = null;
    try {
      // check index
      response =
          lookup(IndexerManager.class).searchArtifactIterator("org.sonatype.nexus5525", "bundle", null,
              "bundle", null, snapshots.getId(), null, null, null, false, SearchType.EXACT, null);

      assertThat(response.getTotalHitsCount(), equalTo(1));
      final ArtifactInfo ai = response.getResults().next();

      assertThat(ai.packaging, equalTo("bundle"));
      assertThat(ai.fextension, equalTo("jar"));
    }
    finally {
      if (response != null) {
        response.close();
      }
    }
  }
View Full Code Here

Examples of org.apache.maven.index.IteratorSearchResponse

    // this search wont work in this case
        /*
         * IteratorSearchResponse response = indexerManager.searchArtifactSha1ChecksumIterator(
         * "a216468fbebacabdf941ab5f1b2e4f3484103f1b", null, null, null, null, null );
         */
    IteratorSearchResponse response =
        indexerManager.searchArtifactIterator("org.apache.maven.plugins", "maven-pmd-plugin", "2.6-SNAPSHOT",
            "maven-plugin", null, snapshots.getId(), null, null, null, false,
            SearchType.EXACT, null);

    assertEquals("There should be one hit!", 1, response.getTotalHits());

    ArtifactInfo ai = response.getResults().next();

    assertEquals("Coordinates should match too!",
        "org.apache.maven.plugins:maven-pmd-plugin:2.6-SNAPSHOT:null:maven-plugin", ai.toString());
  }
View Full Code Here

Examples of org.apache.maven.index.IteratorSearchResponse

    final String checksum =
        fileItem == null ? null : fileItem.getRepositoryItemAttributes()
            .get(DigestCalculatingInspector.DIGEST_SHA1_KEY);
    if (checksum != null) {
      IteratorSearchResponse searchResponse = null;

      try {
        searchResponse =
            indexerManager.searchArtifactSha1ChecksumIterator(checksum, null, null, null, null, null);

        for (ArtifactInfo info : searchResponse) {
          repositories.add(info.repository);
        }
      }
      catch (NoSuchRepositoryException e) {
        // should never trigger this exception since I'm searching on all repositories
        getLogger().error(e.getMessage(), e);
      }
      finally {
        if (searchResponse != null) {
          searchResponse.close();
        }
      }
    }

    // hosted / cache check useful if the index is out to date or disable
View Full Code Here

Examples of org.apache.maven.index.IteratorSearchResponse

    indexerManager.reindexRepository("/", releases.getId(), true);
    indexerManager.optimizeRepositoryIndex(releases.getId());

    Query query = new MatchAllDocsQuery();
    IteratorSearchResponse iterator =
        indexerManager.searchQueryIterator(query, releases.getId(), null /* from */, null/* count */,
            null/* hitLimit */, false/* uniqueRGA */, null/* filters */);
    iterator.close();

    iterator =
        indexerManager.searchQueryIterator(query, null/* repositoryId */, null /* from */, null/* count */,
            null/* hitLimit */, false/* uniqueRGA */, null/* filters */);
    iterator.close();

    indexerManager.removeRepositoryIndexContext(releases.getId(), false);
  }
View Full Code Here

Examples of org.apache.maven.index.IteratorSearchResponse

  private ArtifactInfo search(MavenRepository repository, String groupId, String artifactId, String version)
      throws NoSuchRepositoryException, IOException
  {
    BooleanQuery query = newGavQuery(groupId, artifactId, version);
    String repoId = repository != null ? repository.getId() : null;
    IteratorSearchResponse iterator =
        indexerManager.searchQueryIterator(query, repoId, null, null, null, false, null);
    try {
      if (iterator.getTotalHitsCount() == 0) {
        return null;
      }
      Assert.assertEquals(1, iterator.getTotalHitsCount());
      ArtifactInfo ai = iterator.iterator().next();
      Assert.assertEquals(version, ai.version);
      return ai;
    }
    finally {
      iterator.close();
    }
  }
View Full Code Here

Examples of org.apache.maven.index.IteratorSearchResponse

    boolean forceExpand = expandVersion || !collapseResults;

    try {
      try {
        IteratorSearchResponse searchResult =
            searchByTerms(terms, repositoryId, from, count, exact, searchers);

        try {
          SearchNGResponse searchResponse = packSearchNGResponse(request, terms, searchResult, forceExpand);
          searchResponse.setTotalCount(searchResult.getTotalHitsCount());
          searchResponse.setFrom(from == null ? -1 : from.intValue());
          searchResponse.setCount(count == LUCENE_HIT_LIMIT ? -1 : count);
          return searchResponse;
        }
        finally {
          searchResult.close();
        }
      }
      catch (IOException e) {
        throw new ResourceException(Status.SERVER_ERROR_INTERNAL, e.getMessage(), e);
      }
View Full Code Here

Examples of org.apache.maven.index.IteratorSearchResponse

      if (exact != null) {
        searchType = exact ? SearchType.EXACT : SearchType.SCORED;
      }

      final IteratorSearchResponse searchResponse =
          searcher.flatIteratorSearch(terms, repositoryId, from, count, null, false, searchType, null/* filters */);

      return searchResponse;
    }
    catch (IllegalArgumentException e) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.