public void encodeParameters()

in nuget-server/src/jetbrains/buildServer/nuget/server/exec/impl/ListPackagesArguments.java [36:72]


  public void encodeParameters(@NotNull final File file,
                               @NotNull Collection<SourcePackageReference> refs) throws IOException {
    final Element root = new Element(NUGET_PACKAGES);
    final Element packages = new Element(PACKAGES);
    for (SourcePackageReference ref : refs) {
      final Element pkg = new Element(PACKAGE);
      pkg.setAttribute("id", ref.getPackageId());
      final String source = ref.getSource();
      final NuGetFeedCredentials credentials = ref.getCredentials();

      if (source != null) {
        pkg.setAttribute(SOURCE_ATTRIBUTE, source);
      }

      if (credentials != null) {
        pkg.setAttribute(USERNAME, credentials.getUsername());
        pkg.setAttribute(PASSWORD, credentials.getPassword());
      }

      final String spec = ref.getVersionSpec();
      if (spec != null) {
        pkg.setAttribute(VERSIONS, spec);
      }
      if (ref.isIncludePrerelease()) {
        pkg.setAttribute(INCLUDE_PRERELEASE, "true");
      }
      packages.addContent((Content)pkg);
    }
    root.addContent((Content)packages);

    final OutputStream os = new BufferedOutputStream(new FileOutputStream(file));
    try {
      XmlUtil.saveDocument(new Document(root), os);
    } finally {
      FileUtil.close(os);
    }
  }