public Map checkForChanges()

in nuget-server/src/jetbrains/buildServer/nuget/server/exec/impl/ListPackagesCommandImpl.java [37:73]


  public Map<SourcePackageReference, ListPackagesResult> checkForChanges(@NotNull File nugetPath,
                                                                         @NotNull Collection<SourcePackageReference> refs) throws NuGetExecutionException {
    final File tempDirectory = myTempFiles.getTempDirectory();
    final File spec = TempFilesUtil.createTempFile(tempDirectory, "trigger-spec");
    final File result = TempFilesUtil.createTempFile(tempDirectory, "trigget-result");

    final ListPackagesArguments argz = new ListPackagesArguments();
    try {
      argz.encodeParameters(spec, refs);
    } catch (IOException e) {
      throw new NuGetExecutionException("Failed to encode parameters. " + e.getMessage(), e);
    }

    try {
      final List<String> cmd = new ArrayList<String>();
      final String commandName = "TeamCity.ListPackages";
      cmd.add(commandName);
      cmd.add("-Request");
      cmd.add(FileUtil.getCanonicalFile(spec).getPath());
      cmd.add("-Response");
      cmd.add(FileUtil.getCanonicalFile(result).getPath());

      return myExec.executeNuGet(nugetPath, cmd, getSources(refs), new NuGetOutputProcessorAdapter<Map<SourcePackageReference,ListPackagesResult>>(commandName) {
        @NotNull
        public Map<SourcePackageReference, ListPackagesResult> getResult() throws NuGetExecutionException {
          try {
            return argz.decodeParameters(result);
          } catch (IOException e) {
            throw new NuGetExecutionException("Failed to decode parameters. " + e.getMessage(), e);
          }
        }
      });
    } finally {
      FileUtil.delete(spec);
      FileUtil.delete(result);
    }
  }