Rewrite deploy-file goal from scratch

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@618593 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrDeployFile.java b/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrDeployFile.java
index beaa4b6..0596556 100644
--- a/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrDeployFile.java
+++ b/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrDeployFile.java
@@ -19,20 +19,13 @@
 package org.apache.felix.obr.plugin;
 
 
-import java.io.File;
-import java.net.URI;
-
-import org.apache.maven.artifact.manager.WagonManager;
-import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.settings.Settings;
 
 
 /**
- * Deploy bundle metadata to remote OBR (command-line goal).
+ * Deploys bundle details to a remote OBR repository (command-line goal)
  * 
+ * @requiresProject false
  * @goal deploy-file
  * @phase deploy
  * 
@@ -40,139 +33,8 @@
  */
 public class ObrDeployFile extends AbstractMojo
 {
-    /**
-     * Maven settings.
-     * 
-     * @parameter expression="${settings}"
-     * @require
-     */
-    private Settings m_settings;
-
-    /**
-     * name of the repository xml descriptor file.
-     * 
-     * @parameter expression="${repository-name}" default-value="repository.xml" alias="repository-name"
-     */
-    private String m_repositoryName;
-
-    /**
-     * The local Maven repository.
-     * 
-     * @parameter expression="${localRepository}"
-     * @required
-     * @readonly
-     */
-    private ArtifactRepository m_localRepo;
-
-    /**
-     * Project in use.
-     * 
-     * @parameter expression="${project}"
-     * @require
-     */
-    private MavenProject m_project;
-
-    /**
-     * Wagon Manager.
-     * @component
-     */
-    private WagonManager m_wagonManager;
-
-    /**
-     * obr file define by the user.
-     * 
-     * @parameter expression="${obr-file}" alias="obr-file"
-     * 
-     */
-    private String m_obrFile;
-
-    /**
-     * When true, ignore remote locking.
-     * 
-     * @parameter expression="${ignore-lock}" alias="ignore-lock"
-     */
-    private boolean m_ignoreLock;
-
-
-    /**
-     * main method for this goal.
-     * @implements org.apache.maven.plugin.Mojo.execute 
-     * @throws MojoExecutionException
-     */
-    public void execute() throws MojoExecutionException
+    public void execute()
     {
-        ArtifactRepository ar = m_project.getDistributionManagementArtifactRepository();
-
-        // locate the obr.xml file
-        URI obrXml = ObrUtils.toFileURI( m_obrFile );
-        if ( null == obrXml )
-        {
-            getLog().info( "obr.xml is not present, use default" );
-        }
-
-        File repoDescriptorFile = null;
-
-        // init the wagon connection
-        RemoteFileManager remoteFile = new RemoteFileManager( ar, m_wagonManager, m_settings, getLog() );
-        remoteFile.connect();
-
-        if ( !m_ignoreLock )
-        {
-            int countError = 0;
-            while ( remoteFile.isLockedFile( m_repositoryName ) && countError < 2 )
-            {
-                countError++;
-                getLog().warn( "OBR is locked, retry in 10s" );
-                try
-                {
-                    Thread.sleep( 10000 );
-                }
-                catch ( InterruptedException e )
-                {
-                    getLog().warn( "Sleep interrupted" );
-                }
-            }
-
-            if ( countError == 2 )
-            {
-                getLog().error( "OBR " + m_repositoryName + " is locked. Use -Dignore-lock to force uploading" );
-                throw new MojoExecutionException( "OBR locked" );
-            }
-        }
-
-        // ======== LOCK REMOTE OBR ========
-        remoteFile.lockFile( m_repositoryName );
-
-        // ======== DOWNLOAD REMOTE OBR ========
-        repoDescriptorFile = remoteFile.get( m_repositoryName, ".xml" );
-
-        // get the path to local maven repository
-        String mavenRepository = m_localRepo.getBasedir();
-
-        URI repoXml = repoDescriptorFile.toURI();
-        URI bundleJar = ObrUtils.findBundleJar( m_localRepo, m_project.getArtifact() );
-
-        if ( !new File( bundleJar ).exists() )
-        {
-            getLog().error( "file not found in local repository: " + bundleJar );
-            return;
-        }
-
-        Config userConfig = new Config();
-        userConfig.setPathRelative( true );
-        userConfig.setRemotely( true );
-
-        ObrUpdate update = new ObrUpdate( repoXml, obrXml, m_project, bundleJar, mavenRepository, userConfig, getLog() );
-
-        update.updateRepository();
-
-        // ======== UPLOAD MODIFIED OBR ========
-        remoteFile.put( repoDescriptorFile, m_repositoryName );
-        repoDescriptorFile.delete();
-
-        // ======== UNLOCK REMOTE OBR ========
-        remoteFile.unlockFile( m_repositoryName );
-
-        remoteFile.disconnect();
+        // TODO Auto-generated method stub       
     }
 }
diff --git a/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrInstall.java b/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrInstall.java
index fb29573..fd1a80d 100644
--- a/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrInstall.java
+++ b/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrInstall.java
@@ -92,7 +92,7 @@
         }
         catch ( Exception e )
         {
-            log.warn( "Exception while updating OBR: " + e.getLocalizedMessage(), e );
+            log.warn( "Exception while updating local OBR: " + e.getLocalizedMessage(), e );
         }
     }
 }