class RepositoryMetadataMerger extends ComponentSupport {

  public void merge(final OutputStream outputStream,
                    final MavenPath mavenPath,
                    final Map<Repository, Content> contents)
  {
    log.debug("Merge metadata for {}", mavenPath.getPath());
    List<Envelope> metadatas = new ArrayList<>(contents.size());
    try {
      for (Map.Entry<Repository, Content> entry : contents.entrySet()) {
        addReadMetadata(mavenPath, metadatas, entry);
      }

      final Metadata mergedMetadata = merge(metadatas);
      if (mergedMetadata == null) {
        return;
      }
      MavenModels.writeMetadata(outputStream, mergedMetadata);
    }
    catch (IOException e) {
      log.error("Unable to merge {}", mavenPath, e);
    }
  }

}