Package org.apache.maven.index

Examples of org.apache.maven.index.IteratorSearchResponse


    Collection<ArtifactInfo> ais =
        indexerManager.identifyArtifact(MAVEN.SHA1, "86e12071021fa0be4ec809d4d2e08f07b80d4877");

    assertTrue("The artifact has to be found!", ais.size() == 1);

    IteratorSearchResponse response;

    // this will be EXACT search, since we gave full SHA1 checksum of 40 chars
    response =
        indexerManager.searchArtifactSha1ChecksumIterator("86e12071021fa0be4ec809d4d2e08f07b80d4877", null, null,
            null, null, null);

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

    response.close();

    // this will be SCORED search, since we have just part of the SHA1 checksum
    response = indexerManager.searchArtifactSha1ChecksumIterator("86e12071021", null, null, null, null, null);

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

    response.close();
  }
View Full Code Here


    }
    if (form.getFirstValue("collapseresults") != null) {
      collapseResults = Boolean.valueOf(form.getFirstValue("collapseresults"));
    }

    IteratorSearchResponse searchResult = null;

    SearchResponse result = new SearchResponse();

    try {
      int countRequested = count == null ? HIT_LIMIT : count;

      searchResult =
          searchByTerms(terms, getRepositoryId(request), from, countRequested, exact, expandVersion,
              expandPackaging, expandClassifier, collapseResults);

      result.setTooManyResults(searchResult.getTotalHitsCount() > countRequested);

      result.setTotalCount(searchResult.getTotalHitsCount());

      result.setFrom(from == null ? -1 : from.intValue());

      result.setCount(count == null ? -1 : count);

      result.setData(new ArrayList<NexusArtifact>(ai2NaColl(request, searchResult.getResults())));

      // if we had collapseResults ON, and the totalHits are larger than actual (filtered) results,
      // and
      // the actual result count is below COLLAPSE_OVERRIDE_TRESHOLD,
      // and full result set is smaller than HIT_LIMIT
      // then repeat without collapse
      if (collapseResults && result.getData().size() < searchResult.getTotalHitsCount()
          && result.getData().size() < COLLAPSE_OVERRIDE_TRESHOLD && searchResult.getTotalHitsCount() < HIT_LIMIT) {
        collapseResults = false;
      }
    }
    catch (NoSuchRepositoryException e) {
      throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "Repository with ID='"
          + getRepositoryId(request) + "' does not exists!", e);
    }
    catch (IOException e) {
      throw new ResourceException(Status.SERVER_ERROR_INTERNAL, e.getMessage(), e);
    }
    finally {
      if (searchResult != null) {
        try {
          searchResult.close();
        }
        catch (IOException e) {
          throw new ResourceException(Status.SERVER_ERROR_INTERNAL, e.getMessage(), e);
        }
      }
View Full Code Here

            uniqueRGA = true;
          }
        }

        final IteratorSearchResponse searchResponse =
            searcher.flatIteratorSearch(terms, repositoryId, from, count, HIT_LIMIT, uniqueRGA, searchType,
                filters);

        if (searchResponse != null) {
          if (collapseResults && searchResponse.getTotalHitsCount() < COLLAPSE_OVERRIDE_TRESHOLD) {
            searchResponse.close();

            // this was a "collapsed" search (probably initiated by UI), and we have less then treshold hits
            // override collapse
            return searchByTerms(terms, repositoryId, from, count, exact, expandVersion, expandPackaging,
                expandClassifier, false);
View Full Code Here

  }

  public ArchetypeCatalog listArcherypesAsCatalog(final MacRequest request, final IndexingContext ctx)
      throws IOException
  {
    final IteratorSearchResponse infos = listArchetypes(request, ctx);

    try {
      final ArchetypeCatalog catalog = new ArchetypeCatalog();
      Archetype archetype = null;
      // fill it in
      for (ArtifactInfo info : infos) {
        archetype = new Archetype();
        archetype.setGroupId(info.groupId);
        archetype.setArtifactId(info.artifactId);
        archetype.setVersion(info.version);
        archetype.setDescription(info.description);

        if (StringUtils.isNotEmpty(request.getRepositoryUrl())) {
          archetype.setRepository(request.getRepositoryUrl());
        }
        catalog.addArchetype(archetype);
      }
      return catalog;
    }
    finally {
      if (infos != null) {
        infos.close();
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.maven.index.IteratorSearchResponse

Copyright © 2018 www.massapicom. 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.