public Iterable call()

in nuget-feed/src/jetbrains/buildServer/nuget/feed/server/odata4j/functions/SearchFunction.java [52:95]


  public Iterable<NuGetIndexEntry> call(@NotNull final EdmType returnType,
                                        @NotNull final Map<String, OFunctionParameter> params,
                                        @Nullable final QueryInfo queryInfo) {
    final OFunctionParameter searchTermParam = params.get(SEARCH_TERM);
    if (searchTermParam == null) {
      LOG.debug(String.format("Bad %s function call. searchTerm parameter is not specified.", getName()));
      throw new BadRequestException(SEARCH_TERM + " parameter is not specified.");
    }
    final OObject searchTermParamValue = searchTermParam.getValue();
    if (!(searchTermParamValue instanceof OSimpleObject)) {
      LOG.debug(String.format("Bad %s function call. searchTerm parameter type is invalid.", getName()));
      throw new BadRequestException(SEARCH_TERM + " parameter type is invalid.");
    }
    final OSimpleObject searchTermCasted = (OSimpleObject) searchTermParamValue;
    final String searchTerm = searchTermCasted.getValue().toString();

    final OFunctionParameter targetFrameworkParam = params.get(TARGET_FRAMEWORK);
    if (targetFrameworkParam == null) {
      LOG.debug(String.format("Bad %s function call. targetFramework parameter is not specified.", getName()));
      throw new BadRequestException(TARGET_FRAMEWORK + " parameter is not specified.");
    }
    final OObject targetFrameworkParamValue = targetFrameworkParam.getValue();
    if (!(targetFrameworkParamValue instanceof OSimpleObject)) {
      LOG.debug(String.format("Bad %s function call. targetFramework parameter type is invalid.", getName()));
      throw new BadRequestException(TARGET_FRAMEWORK + " parameter type is invalid.");
    }
    final OSimpleObject targetFrameworkCasted = (OSimpleObject) targetFrameworkParamValue;
    final String targetFramework = targetFrameworkCasted.getValue().toString();

    final OFunctionParameter includePreReleaseParam = params.get(INCLUDE_PRERELEASE);
    if (includePreReleaseParam == null) {
      LOG.debug(String.format("Bad %s function call. 'includePrerelease' parameter is not specified.", getName()));
      throw new BadRequestException(INCLUDE_PRERELEASE + " parameter is not specified.");
    }
    final OObject includePreReleaseParamValue = includePreReleaseParam.getValue();
    if (!(includePreReleaseParamValue instanceof OSimpleObject)) {
      LOG.debug(String.format("Bad %s function call. 'includePrerelease' parameter type is invalid.", getName()));
      throw new BadRequestException(INCLUDE_PRERELEASE + " parameter type is invalid.");
    }
    final OSimpleObject includePreReleaseCasted = (OSimpleObject) includePreReleaseParamValue;
    final boolean includePreRelease = Boolean.parseBoolean(includePreReleaseCasted.getValue().toString());
    final boolean includeSemVer2 = ODataUtilities.includeSemVer2(queryInfo);
    return myFeed.search(searchTerm, targetFramework, includePreRelease, includeSemVer2);
  }