}
private void mergeMetadataFiles( File target, File metadataFile )
throws ProxyException
{
MetadataXpp3Reader reader = new MetadataXpp3Reader();
if ( metadataFile.exists() )
{
Metadata metadata = null;
if ( target.exists() )
{
FileReader fileReader = null;
try
{
fileReader = new FileReader( target );
metadata = reader.read( fileReader );
}
catch ( XmlPullParserException e )
{
throw new ProxyException( "Unable to parse existing metadata: " + e.getMessage(), e );
}
catch ( IOException e )
{
throw new ProxyException( "Unable to read existing metadata: " + e.getMessage(), e );
}
finally
{
IOUtils.closeQuietly( fileReader );
}
}
FileReader fileReader = null;
boolean changed = false;
try
{
fileReader = new FileReader( metadataFile );
Metadata newMetadata = reader.read( fileReader );
if ( metadata != null )
{
setLastUpdatedIfEmpty( newMetadata, metadataFile );
setLastUpdatedIfEmpty( metadata, target );