本文整理汇总了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 );
}
}
示例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$
}
}
示例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 );
}
}
示例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 );
}
}
示例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);
}
}
示例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$
}
}
示例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 );
}
示例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() );
}
}