class MavenMetadataContentValidator extends ComponentSupport {

  public void validate(final String path, final InputStream mavenMetadata) {
    try {
      Metadata metadata = MavenModels.readMetadata(mavenMetadata);

      if (metadata == null) {
        throw new InvalidContentException("Metadata at path " + path + " is not a valid maven-metadata.xml");
      }

      // maven-metadata.xml files for plugins do not contain groupId and therefore cannot be validated
      if (isNotEmpty(metadata.getGroupId())) {
        validatePath(path, metadata);
      }
      else {
        log.debug("No groupId found in maven-metadata.xml therefore skipping validation");
      }
    }
    catch (IOException e) {
      log.warn("Unable to read maven-metadata.xml at path {}", path, e );
      
      throw new InvalidContentException("Unable to read maven-metadata.xml reason: " + e.getMessage());
    }
  }

}