Example usage for org.apache.maven.artifact.repository.metadata RepositoryMetadataReadException RepositoryMetadataReadException

List of usage examples for org.apache.maven.artifact.repository.metadata RepositoryMetadataReadException RepositoryMetadataReadException

Introduction

In this page you can find the example usage for org.apache.maven.artifact.repository.metadata RepositoryMetadataReadException RepositoryMetadataReadException.

Prototype

public RepositoryMetadataReadException(String message, Exception e) 

Source Link

Usage

From source file:org.ck.maven.plugins.pom.versions.service.version.PomVersionRepositoryMetadataManager.java

License:Apache License

/**
 * @todo share with DefaultPluginMappingManager.
 *//*from w ww . j  a  v  a  2  s . c o  m*/
protected static Metadata readMetadata(File mappingFile) throws RepositoryMetadataReadException {
    Metadata result;

    Reader reader = null;
    try {
        reader = ReaderFactory.newXmlReader(mappingFile);

        MetadataXpp3Reader mappingReader = new MetadataXpp3Reader();

        result = mappingReader.read(reader, false);
    } catch (FileNotFoundException e) {
        throw new RepositoryMetadataReadException("Cannot read metadata from '" + mappingFile + "'", e);
    } catch (IOException e) {
        throw new RepositoryMetadataReadException(
                "Cannot read metadata from '" + mappingFile + "': " + e.getMessage(), e);
    } catch (XmlPullParserException e) {
        throw new RepositoryMetadataReadException(
                "Cannot read metadata from '" + mappingFile + "': " + e.getMessage(), e);
    } finally {
        IOUtil.close(reader);
    }
    return result;
}