当前位置: 首页>>代码示例>>Java>>正文


Java MetadataXpp3Reader.read方法代码示例

本文整理汇总了Java中org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader.read方法的典型用法代码示例。如果您正苦于以下问题:Java MetadataXpp3Reader.read方法的具体用法?Java MetadataXpp3Reader.read怎么用?Java MetadataXpp3Reader.read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader的用法示例。


在下文中一共展示了MetadataXpp3Reader.read方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: read

import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader; //导入方法依赖的package包/类
public Metadata read( Reader input, Map<String, ?> options )
    throws IOException
{
    if ( input == null )
    {
        throw new IllegalArgumentException( "input reader missing" );
    }

    try
    {
        MetadataXpp3Reader r = new MetadataXpp3Reader();
        return r.read( input, isStrict( options ) );
    }
    catch ( XmlPullParserException e )
    {
        throw new MetadataParseException( e.getMessage(), e.getLineNumber(), e.getColumnNumber(), e );
    }
    finally
    {
        IOUtil.close( input );
    }
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:23,代码来源:DefaultMetadataReader.java

示例2: readMetadata

import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader; //导入方法依赖的package包/类
private Metadata readMetadata( File file )
    throws ArtifactConversionException
{
    MetadataXpp3Reader reader = new MetadataXpp3Reader();

    try (Reader fileReader = Files.newBufferedReader( file.toPath(), Charset.defaultCharset() ))
    {
        return reader.read( fileReader );
    }
    catch ( IOException | XmlPullParserException e )
    {
        throw new ArtifactConversionException( Messages.getString( "error.reading.target.metadata" ),
                                               e ); //$NON-NLS-1$
    }
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:16,代码来源:LegacyToDefaultConverter.java

示例3: getMetadata

import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public Metadata getMetadata( String path )
    throws IOException, MetadataNotFoundException
{
    File file = root;
    String[] parts = StringUtils.strip( path, "/" ).split( "/" );
    for ( int i = 0; i < parts.length; i++ )
    {
        file = new File( file, parts[i] );
    }
    file = new File( file, "maven-metadata.xml" );
    if ( !file.isFile() )
    {
        throw new MetadataNotFoundException( path );
    }
    MetadataXpp3Reader reader = new MetadataXpp3Reader();
    InputStream inputStream = null;
    try
    {
        inputStream = new FileInputStream( file );
        return reader.read( inputStream );
    }
    catch ( XmlPullParserException e )
    {
        IOException ioe = new IOException( e.getMessage() );
        ioe.initCause( e );
        throw ioe;
    }
    finally
    {
        IOUtils.closeQuietly( inputStream );
    }
}
 
开发者ID:mojohaus,项目名称:mrm,代码行数:36,代码来源:DiskArtifactStore.java

示例4: getMetadata

import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public Metadata getMetadata( String path )
    throws IOException, MetadataNotFoundException
{
    Entry entry = backing.get(
        StringUtils.join( StringUtils.split( StringUtils.strip( path, "/" ), "/" ), "/" ) + "/maven-metadata.xml" );
    if ( !( entry instanceof FileEntry ) )
    {
        throw new MetadataNotFoundException( path );
    }
    MetadataXpp3Reader reader = new MetadataXpp3Reader();
    InputStream inputStream = null;
    try
    {
        inputStream = ( (FileEntry) entry ).getInputStream();
        return reader.read( inputStream );
    }
    catch ( XmlPullParserException e )
    {
        IOException ioe = new IOException( e.getMessage() );
        ioe.initCause( e );
        throw ioe;
    }
    finally
    {
        IOUtils.closeQuietly( inputStream );
    }
}
 
开发者ID:mojohaus,项目名称:mrm,代码行数:31,代码来源:FileSystemArtifactStore.java

示例5: toMavenMetadata

import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader; //导入方法依赖的package包/类
/**
 * Creates a maven <code>Metadata</code> out of a <code>java.io.Reader</code> and will close the reader.
 *
 * @param reader Reader representing content of maven-metadata.xml
 * @return Metadata object created from the reader
 * @throws java.io.IOException If the input reader doesn't holds a valid maven metadata
 */
public static Metadata toMavenMetadata(Reader reader) throws IOException {
    MetadataXpp3Reader metadataReader = new MetadataXpp3Reader();
    try {
        return metadataReader.read(reader, false);
    } catch (XmlPullParserException e) {
        throw new IOException("Failed to parse metadata: " + e.getMessage());
    } finally {
        IOUtils.closeQuietly(reader);
    }
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:18,代码来源:MavenModelUtils.java

示例6: readMetadata

import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader; //导入方法依赖的package包/类
private Metadata readMetadata( Path file )
    throws ArtifactConversionException
{
    MetadataXpp3Reader reader = new MetadataXpp3Reader();

    try (Reader fileReader = Files.newBufferedReader( file, Charset.defaultCharset() ))
    {
        return reader.read( fileReader );
    }
    catch ( IOException | XmlPullParserException e )
    {
        throw new ArtifactConversionException( Messages.getString( "error.reading.target.metadata" ),
                                               e ); //$NON-NLS-1$
    }
}
 
开发者ID:apache,项目名称:archiva,代码行数:16,代码来源:LegacyToDefaultConverter.java

示例7: put

import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader; //导入方法依赖的package包/类
@Override
public FileEntry put( DirectoryEntry parent, String name, InputStream content )
    throws IOException
{
    String path = "/";
    if ( StringUtils.isNotEmpty( parent.toPath()  ) )
    {
        path += parent.toPath() + "/";
    }

    if ( "maven-metadata.xml".equals( name ) )
    {
        MetadataXpp3Reader reader = new MetadataXpp3Reader();
        try
        {
            Metadata metadata = reader.read( content );
            
            if ( metadata == null )
            {
                return null;
            }
            
            store.setMetadata( path, metadata );
        }
        catch ( XmlPullParserException e1 )
        {
            throw new IOException();
        }
        
        return new MetadataFileEntry( this, parent, path, store );
    }
    
    Artifact artifact = getArtifact( parent, name );
    
    if ( artifact == null )
    {
        return null;
    }
    
    store.set( artifact , content );
    
    return new ArtifactFileEntry( this, parent, artifact, store );
}
 
开发者ID:mojohaus,项目名称:mrm,代码行数:44,代码来源:ArtifactStoreFileSystem.java

示例8: updateRepositoryMetadata

import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader; //导入方法依赖的package包/类
protected void updateRepositoryMetadata( ArtifactRepository localRepository,
                                         ArtifactRepository remoteRepository )
    throws IOException, XmlPullParserException
{
    MetadataXpp3Reader mappingReader = new MetadataXpp3Reader();

    Metadata metadata = null;

    File metadataFile = new File( localRepository.getBasedir(),
        localRepository.pathOfLocalRepositoryMetadata( this, remoteRepository ) );

    if ( metadataFile.length() == 0 )
    {
        metadataFile.delete();
    }
    else if ( metadataFile.exists() )
    {
        Reader reader = null;

        try
        {
            reader = ReaderFactory.newXmlReader( metadataFile );

            metadata = mappingReader.read( reader, false );
        }
        finally
        {
            IOUtil.close( reader );
        }
    }

    boolean changed;

    // If file could not be found or was not valid, start from scratch
    if ( metadata == null )
    {
        metadata = this.metadata;

        changed = true;
    }
    else
    {
        changed = metadata.merge( this.metadata );
    }

    // beware meta-versions!
    String version = metadata.getVersion();
    if ( version != null && ( Artifact.LATEST_VERSION.equals( version ) || Artifact.RELEASE_VERSION.equals(
        version ) ) )
    {
        // meta-versions are not valid <version/> values...don't write them.
        metadata.setVersion( null );
    }

    if ( changed || !metadataFile.exists() )
    {
        Writer writer = null;
        try
        {
            metadataFile.getParentFile().mkdirs();
            writer = WriterFactory.newXmlWriter( metadataFile );

            MetadataXpp3Writer mappingWriter = new MetadataXpp3Writer();

            mappingWriter.write( writer, metadata );
        }
        finally
        {
            IOUtil.close( writer );
        }
    }
    else
    {
        metadataFile.setLastModified( System.currentTimeMillis() );
    }
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:77,代码来源:AbstractRepositoryMetadata.java


注:本文中的org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader.read方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。