}
URI tempURI = ObrUtils.findRepositoryXml( "", remoteOBR );
String repositoryName = new File( tempURI.getSchemeSpecificPart() ).getName();
Log log = getLog();
ObrUpdate update;
RemoteFileManager remoteFile = new RemoteFileManager( m_wagonManager, settings, log );
openRepositoryConnection( remoteFile );
// ======== LOCK REMOTE OBR ========
log.info( "LOCK " + remoteFile + '/' + repositoryName );
remoteFile.lockFile( repositoryName, ignoreLock );
File downloadedRepositoryXml = null;
try
{
// ======== DOWNLOAD REMOTE OBR ========
log.info( "Downloading " + repositoryName );
downloadedRepositoryXml = remoteFile.get( repositoryName, ".xml" );
String mavenRepository = localRepository.getBasedir();
URI repositoryXml = downloadedRepositoryXml.toURI();
URI obrXmlFile = ObrUtils.findObrXml( project );
Config userConfig = new Config();
userConfig.setRemoteFile( true );
if ( bundleUrl != null )
{
// public URL differs from the bundle file location
URI uri = URI.create( bundleUrl );
log.info( "Computed bundle uri: " + uri );
userConfig.setRemoteBundle( uri );
}
else if ( prefixUrl != null )
{
// support absolute bundle URLs based on given prefix
URI bundleJar = ObrUtils.getArtifactURI( localRepository, project.getArtifact() );
String relative = ObrUtils.getRelativeURI( ObrUtils.toFileURI( mavenRepository ), bundleJar )
.toASCIIString();
URL resourceURL = new URL( new URL( prefixUrl + '/' ), relative );
URI uri = URI.create( resourceURL.toString() );
log.info( "Computed bundle uri: " + uri );
userConfig.setRemoteBundle( uri );
}
update = new ObrUpdate( repositoryXml, obrXmlFile, project, mavenRepository, userConfig, log );
update.parseRepositoryXml();
updateRemoteBundleMetadata( project.getArtifact(), update );
for ( Iterator i = attachedArtifacts.iterator(); i.hasNext(); )
{
updateRemoteBundleMetadata( ( Artifact ) i.next(), update );
}
update.writeRepositoryXml();
if ( downloadedRepositoryXml.exists() )
{
// ======== UPLOAD MODIFIED OBR ========
log.info( "Uploading " + repositoryName );
remoteFile.put( downloadedRepositoryXml, repositoryName );
}
}
catch ( Exception e )
{
log.warn( "Exception while updating remote OBR: " + e.getLocalizedMessage(), e );
}
finally
{
// ======== UNLOCK REMOTE OBR ========
log.info( "UNLOCK " + remoteFile + '/' + repositoryName );
remoteFile.unlockFile( repositoryName );
remoteFile.disconnect();
if ( null != downloadedRepositoryXml )
{