Package org.sonatype.nexus.rest.model

Examples of org.sonatype.nexus.rest.model.SearchResponse


    String entityText = doSearchForR(queryArgs, repositoryId, searchType, matchers);

    XStreamRepresentation representation =
        new XStreamRepresentation(xstream, entityText, MediaType.APPLICATION_XML);

    return ((SearchResponse) representation.getPayload(new SearchResponse())).getData();
  }
View Full Code Here


        "artifact"));
  }

  @Test
  public void testSearchResponse() {
    SearchResponse response = new SearchResponse();
    response.setCount(10);
    response.setFrom(50);
    response.setTotalCount(8);
    response.setTooManyResults(true);

    NexusArtifact artifact1 = new NexusArtifact();
    artifact1.setArtifactId("artifactId1");
    artifact1.setClassifier("classifier1");
    artifact1.setContextId("contextId1");
    artifact1.setGroupId("groupId1");
    artifact1.setPackaging("packaging1");
    artifact1.setRepoId("repoId1");
    artifact1.setResourceURI("resourceURI1");
    artifact1.setVersion("version1");
    artifact1.setArtifactLink("artifactLink");
    artifact1.setExtension("extension");
    artifact1.setPomLink("pomLink");
    response.addData(artifact1);

    NexusArtifact artifact2 = new NexusArtifact();
    artifact2.setArtifactId("artifactId1");
    artifact2.setClassifier("classifier1");
    artifact2.setContextId("contextId1");
    artifact2.setGroupId("groupId1");
    artifact2.setPackaging("packaging1");
    artifact2.setRepoId("repoId1");
    artifact2.setResourceURI("resourceURI1");
    artifact2.setVersion("version1");
    artifact2.setArtifactLink("artifactLink2");
    artifact2.setExtension("extension2");
    artifact2.setPomLink("pomLink2");
    response.addData(artifact2);

    this.marshalUnmarchalThenCompare(response);
    this.validateXmlHasNoPackageNames(response);
  }
View Full Code Here

      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='"
View Full Code Here

        if (params.isEmpty()) {
            io.error("Missing search criteria");
            return Result.FAILURE;
        }

        SearchResponse response = client.ext(BasicClient.class).search(params);

        // TODO: Need to return better results, and handle errors
       
        io.println("Total count: {}", response.getTotalCount());
        io.println("From: {}", response.getFrom());
        io.println("Count: {}", response.getCount());
        io.println("Too many results: {}", response.isTooManyResults());

        List<NexusArtifact> results = response.getData();
        if (!results.isEmpty()) {
            log.info("Results:");
            for (NexusArtifact artifact : results) {
                log.info("  Resource: {}", artifact.getResourceURI());
            }
View Full Code Here

TOP

Related Classes of org.sonatype.nexus.rest.model.SearchResponse

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.