You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by mc...@apache.org on 2008/01/25 09:10:28 UTC

svn commit: r615140 [1/4] - /felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/

Author: mcculls
Date: Fri Jan 25 00:10:25 2008
New Revision: 615140

URL: http://svn.apache.org/viewvc?rev=615140&view=rev
Log:
Fix EOL style

Modified:
    felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/Capability.java
    felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/Category.java
    felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/Config.java
    felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ExtractBindexInfo.java
    felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrCleanRepo.java
    felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrDeploy.java
    felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrDeployFile.java
    felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrInstallFile.java
    felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrUpdate.java
    felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/PElement.java
    felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/PathFile.java
    felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/RemoteFileManager.java
    felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/Require.java
    felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ResourcesBundle.java

Modified: felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/Capability.java
URL: http://svn.apache.org/viewvc/felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/Capability.java?rev=615140&r1=615139&r2=615140&view=diff
==============================================================================
--- felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/Capability.java (original)
+++ felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/Capability.java Fri Jan 25 00:10:25 2008
@@ -1,123 +1,123 @@
-/* 
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.obr.plugin;
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-
-/**
- * This class describe and store capability node.
- * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
- */
-public class Capability
-{
-
-    /**
-     * m_name: name of the capability.
-     */
-    private String m_name;
-
-    /**
-     * m_p: List of PElement.
-     */
-    private List m_p = new ArrayList();
-
-
-    /**
-     * get the name attribute.
-     * 
-     * @return name attribute
-     */
-    public String getName()
-    {
-        return m_name;
-    }
-
-
-    /**
-     * set the name attribute.
-     * 
-     * @param name new name value
-     *            
-     */
-    public void setName( String name )
-    {
-        this.m_name = name;
-    }
-
-
-    /**
-     * return the capabilities.
-     * 
-     * @return List of PElement
-     */
-    public List getP()
-    {
-        return m_p;
-    }
-
-
-    /**
-     * set the capabilities.
-     * 
-     * @param mp List of PElement
-     *            
-     */
-    public void setP( List mp )
-    {
-        this.m_p = mp;
-    }
-
-
-    /**
-     * add one element in List.
-     * 
-     * @param pelement PElement
-     *            
-     */
-    public void addP( PElement pelement )
-    {
-        m_p.add( pelement );
-    }
-
-
-    /**
-     * transform this object to Node.
-     * 
-     * @param father father document for create Node
-     * @return node
-     */
-    public Node getNode( Document father )
-    {
-        Element capability = father.createElement( "capability" );
-        capability.setAttribute( "name", this.getName() );
-        for ( int i = 0; i < this.getP().size(); i++ )
-        {
-            capability.appendChild( ( ( PElement ) ( this.getP().get( i ) ) ).getNode( father ) );
-        }
-        return capability;
-    }
-
-}
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.obr.plugin;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+
+/**
+ * This class describe and store capability node.
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class Capability
+{
+
+    /**
+     * m_name: name of the capability.
+     */
+    private String m_name;
+
+    /**
+     * m_p: List of PElement.
+     */
+    private List m_p = new ArrayList();
+
+
+    /**
+     * get the name attribute.
+     * 
+     * @return name attribute
+     */
+    public String getName()
+    {
+        return m_name;
+    }
+
+
+    /**
+     * set the name attribute.
+     * 
+     * @param name new name value
+     *            
+     */
+    public void setName( String name )
+    {
+        this.m_name = name;
+    }
+
+
+    /**
+     * return the capabilities.
+     * 
+     * @return List of PElement
+     */
+    public List getP()
+    {
+        return m_p;
+    }
+
+
+    /**
+     * set the capabilities.
+     * 
+     * @param mp List of PElement
+     *            
+     */
+    public void setP( List mp )
+    {
+        this.m_p = mp;
+    }
+
+
+    /**
+     * add one element in List.
+     * 
+     * @param pelement PElement
+     *            
+     */
+    public void addP( PElement pelement )
+    {
+        m_p.add( pelement );
+    }
+
+
+    /**
+     * transform this object to Node.
+     * 
+     * @param father father document for create Node
+     * @return node
+     */
+    public Node getNode( Document father )
+    {
+        Element capability = father.createElement( "capability" );
+        capability.setAttribute( "name", this.getName() );
+        for ( int i = 0; i < this.getP().size(); i++ )
+        {
+            capability.appendChild( ( ( PElement ) ( this.getP().get( i ) ) ).getNode( father ) );
+        }
+        return capability;
+    }
+
+}

Modified: felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/Category.java
URL: http://svn.apache.org/viewvc/felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/Category.java?rev=615140&r1=615139&r2=615140&view=diff
==============================================================================
--- felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/Category.java (original)
+++ felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/Category.java Fri Jan 25 00:10:25 2008
@@ -1,73 +1,73 @@
-/* 
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.obr.plugin;
-
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-
-/**
- * describe and store category node.
- * 
- * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
- */
-
-public class Category
-{
-    /**
-     * id of the category.
-     */
-    private String m_id;
-
-
-    /**
-     * get the id attribute.
-     * 
-     * @return id
-     */
-    public String getId()
-    {
-        return m_id;
-    }
-
-
-    /**
-     * set the id attribute.
-     * @param id new id value
-     */
-    public void setId( String id )
-    {
-        this.m_id = id;
-    }
-
-
-    /**
-     * transform this object to node.
-     * @param father father document for create Node
-     * @return node
-     */
-    public Node getNode( Document father )
-    {
-        Element category = father.createElement( "category" );
-        category.setAttribute( "id", this.getId() );
-        return category;
-    }
-}
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.obr.plugin;
+
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+
+/**
+ * describe and store category node.
+ * 
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+
+public class Category
+{
+    /**
+     * id of the category.
+     */
+    private String m_id;
+
+
+    /**
+     * get the id attribute.
+     * 
+     * @return id
+     */
+    public String getId()
+    {
+        return m_id;
+    }
+
+
+    /**
+     * set the id attribute.
+     * @param id new id value
+     */
+    public void setId( String id )
+    {
+        this.m_id = id;
+    }
+
+
+    /**
+     * transform this object to node.
+     * @param father father document for create Node
+     * @return node
+     */
+    public Node getNode( Document father )
+    {
+        Element category = father.createElement( "category" );
+        category.setAttribute( "id", this.getId() );
+        return category;
+    }
+}

Modified: felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/Config.java
URL: http://svn.apache.org/viewvc/felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/Config.java?rev=615140&r1=615139&r2=615140&view=diff
==============================================================================
--- felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/Config.java (original)
+++ felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/Config.java Fri Jan 25 00:10:25 2008
@@ -1,91 +1,91 @@
-/* 
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.obr.plugin;
-
-
-/**
- * this class is used to store some user information about configuration of the plugin.
- * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
- *
- */
-public class Config
-{
-
-    /**
-     * use relative path or not.
-     */
-    private boolean m_pathRelative; // use relative or absolute path in repository.xml
-
-    /**
-     * deploy file or not.
-     */
-    private boolean m_fileRemote; // deploy file on remote server
-
-
-    /**
-     * constructor: set default configuration: use relative path and don't upload file.
-     *
-     */
-    public Config()
-    {
-        // default configuration
-        m_pathRelative = true;
-        m_fileRemote = false;
-    }
-
-
-    /**
-     * set relativePath attribute.
-     * @param value new value of attribute
-     */
-    public void setPathRelative( boolean value )
-    {
-        m_pathRelative = value;
-    }
-
-
-    /**
-     * set fileRemote attribute.
-     * @param value new value of attribute
-     */
-    public void setRemotely( boolean value )
-    {
-        m_fileRemote = value;
-    }
-
-
-    /**
-     * get use path relative.
-     * @return true if plugin use relative path, else false
-     */
-    public boolean isPathRelative()
-    {
-        return m_pathRelative;
-    }
-
-
-    /**
-     * get if use upload file.
-     * @return true if the file will be uploaded, else false
-     */
-    public boolean isRemotely()
-    {
-        return m_fileRemote;
-    }
-}
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.obr.plugin;
+
+
+/**
+ * this class is used to store some user information about configuration of the plugin.
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ *
+ */
+public class Config
+{
+
+    /**
+     * use relative path or not.
+     */
+    private boolean m_pathRelative; // use relative or absolute path in repository.xml
+
+    /**
+     * deploy file or not.
+     */
+    private boolean m_fileRemote; // deploy file on remote server
+
+
+    /**
+     * constructor: set default configuration: use relative path and don't upload file.
+     *
+     */
+    public Config()
+    {
+        // default configuration
+        m_pathRelative = true;
+        m_fileRemote = false;
+    }
+
+
+    /**
+     * set relativePath attribute.
+     * @param value new value of attribute
+     */
+    public void setPathRelative( boolean value )
+    {
+        m_pathRelative = value;
+    }
+
+
+    /**
+     * set fileRemote attribute.
+     * @param value new value of attribute
+     */
+    public void setRemotely( boolean value )
+    {
+        m_fileRemote = value;
+    }
+
+
+    /**
+     * get use path relative.
+     * @return true if plugin use relative path, else false
+     */
+    public boolean isPathRelative()
+    {
+        return m_pathRelative;
+    }
+
+
+    /**
+     * get if use upload file.
+     * @return true if the file will be uploaded, else false
+     */
+    public boolean isRemotely()
+    {
+        return m_fileRemote;
+    }
+}

Modified: felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ExtractBindexInfo.java
URL: http://svn.apache.org/viewvc/felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ExtractBindexInfo.java?rev=615140&r1=615139&r2=615140&view=diff
==============================================================================
--- felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ExtractBindexInfo.java (original)
+++ felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ExtractBindexInfo.java Fri Jan 25 00:10:25 2008
@@ -1,322 +1,322 @@
-/* 
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.obr.plugin;
-
-
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.maven.plugin.MojoExecutionException;
-import org.osgi.impl.bundle.obr.resource.BundleInfo;
-import org.osgi.impl.bundle.obr.resource.CapabilityImpl;
-import org.osgi.impl.bundle.obr.resource.RepositoryImpl;
-import org.osgi.impl.bundle.obr.resource.RequirementImpl;
-import org.osgi.impl.bundle.obr.resource.ResourceImpl;
-import org.osgi.impl.bundle.obr.resource.VersionRange;
-
-
-/**
- * this class is used to configure bindex and get information built by bindex about targeted bundle.
- * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
- */
-public class ExtractBindexInfo
-{
-
-    /**
-     * attribute get from bindex which describe targeted resource.
-     */
-    private ResourceImpl m_resource;
-
-
-    /**
-     * configure bindex and build information.
-     * @param repoFilename URI on OBR descriptor file
-     * @param outFile path on targeted jar-file
-     * @throws MojoExecutionException occurs if bindex configuration failed
-     */
-    public ExtractBindexInfo( URI repoFilename, String outFile ) throws MojoExecutionException
-    {
-
-        this.m_resource = null;
-        RepositoryImpl repository = null;
-        try
-        {
-            repository = new RepositoryImpl( new File( repoFilename ).getAbsoluteFile().toURL() );
-        }
-        catch ( MalformedURLException e )
-        {
-            e.printStackTrace();
-            throw new MojoExecutionException( "MalformedURLException" );
-        }
-        BundleInfo info = null;
-        try
-        {
-            info = new BundleInfo( repository, new File( outFile ) );
-        }
-        catch ( Exception e )
-        {
-            e.printStackTrace();
-            throw new MojoExecutionException( "Exception" );
-        }
-
-        try
-        {
-            m_resource = info.build();
-        }
-        catch ( Exception e )
-        {
-            e.printStackTrace();
-            throw new MojoExecutionException( "Exception" );
-        }
-    }
-
-
-    /**
-     * transform logical operator in xml syntax.
-     * @param filter string which contains logical operator
-     * @return string in correct xml syntax
-     */
-    private String parseFilter( String filter )
-    {
-        filter.replaceAll( "&", "&amp" );
-        filter.replaceAll( ">=", "&gt" );
-
-        return filter;
-    }
-
-
-    /**
-     * extract capabilities from bindex information.
-     * @return bundle capabilities List
-     */
-    public List getCapabilities()
-    {
-        List list = new ArrayList();
-        Collection res = m_resource.getCapabilityList();
-        Iterator it = res.iterator();
-        while ( it.hasNext() )
-        {
-            Capability capability = new Capability();
-            CapabilityImpl ci = ( CapabilityImpl ) it.next();
-            capability.setName( ci.getName() );
-            // System.out.println(ci.getName()) ;
-            if ( !( ci.getName().compareTo( "bundle" ) == 0 ) )
-            {
-                Map properties = ci.getProperties();
-                for ( Iterator k = properties.keySet().iterator(); k.hasNext(); )
-                {
-                    PElement p = new PElement();
-                    String key = ( String ) k.next();
-                    List values = ( List ) properties.get( key );
-                    for ( Iterator v = values.iterator(); v.hasNext(); )
-                    {
-                        Object value = v.next();
-                        p.setN( key );
-                        if ( value != null )
-                        {
-                            p.setV( value.toString() );
-                        }
-                        else
-                        {
-                            System.out.println( "Missing value " + key );
-                        }
-                        String type = null;
-                        if ( value instanceof Number )
-                        {
-                            type = "number";
-                        }
-                        else
-                        {
-                            if ( value.getClass() == VersionRange.class )
-                            {
-                                type = "version";
-                            }
-                        }
-                        if ( type != null )
-                        {
-                            p.setT( type );
-                        }
-                    }
-                    capability.addP( p );
-                }
-
-                list.add( capability );
-            }
-        }
-        return list;
-    }
-
-
-    /**
-     * extract requirement from bindex information.
-     * @return bundle requirement List
-     */
-    public List getRequirement()
-    {
-        List list = new ArrayList();
-        Collection res = m_resource.getRequirementList();
-        Iterator it = res.iterator();
-        while ( it.hasNext() )
-        {
-            RequirementImpl ci = ( RequirementImpl ) it.next();
-            Require require = new Require();
-
-            require.setExtend( String.valueOf( ci.isExtend() ) );
-            require.setMultiple( String.valueOf( ci.isMultiple() ) );
-            require.setOptional( String.valueOf( ci.isOptional() ) );
-            require.setName( ci.getName() );
-            require.setFilter( this.parseFilter( ci.getFilter() ) );
-            require.setValue( ci.getComment() );
-            list.add( require );
-        }
-        return list;
-    }
-
-
-    /**
-     * extract symbolic name from bindex information.
-     * @return bundle symbolic name
-     */
-    public String getSymbolicName()
-    {
-        return m_resource.getSymbolicName();
-    }
-
-
-    /**
-     * extract version from bindex information.
-     * @return bundle version
-     */
-    public String getVersion()
-    {
-        if ( m_resource.getVersion() != null )
-        {
-            return m_resource.getVersion().toString();
-        }
-        else
-        {
-            return null;
-        }
-    }
-
-
-    /**
-     * extract presentation name from bindex information.
-     * @return bundle presentation name
-     */
-    public String getPresentationName()
-    {
-        return m_resource.getPresentationName();
-    }
-
-
-    /**
-     * extract copyright from bindex information.
-     * @return bundle copyright
-     */
-    public String getCopyright()
-    {
-        return m_resource.getCopyright();
-    }
-
-
-    /**
-     * extract description from bindex information.
-     * @return bundle description
-     */
-    public String getDescription()
-    {
-        return m_resource.getDescription();
-    }
-
-
-    /**
-     * extract documentation from bindex information.
-     * @return bundle documentation
-     */
-    public String getDocumentation()
-    {
-        if ( m_resource.getDocumentation() != null )
-        {
-            return m_resource.getDocumentation().toString();
-        }
-        else
-        {
-            return null;
-        }
-    }
-
-
-    /**
-     * extract license from bindex information.
-     * @return bundle license
-     */
-    public String getLicense()
-    {
-        if ( m_resource.getLicense() != null )
-        {
-            return m_resource.getLicense().toString();
-        }
-        else
-        {
-            return null;
-        }
-    }
-
-
-    /**
-     * extract source from bindex information.
-     * @return bundle source
-     */
-    public String getSource()
-    {
-        if ( m_resource.getSource() != null )
-        {
-            return m_resource.getSource().toString();
-        }
-        else
-        {
-            return null;
-        }
-    }
-
-
-    /**
-     * extract source from bindex information.
-     * @return bundle source
-     */
-    public String getId()
-    {
-        if ( m_resource.getId() != null )
-        {
-            return m_resource.getId();
-        }
-        else
-        {
-            return null;
-        }
-    }
-
-}
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.obr.plugin;
+
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.osgi.impl.bundle.obr.resource.BundleInfo;
+import org.osgi.impl.bundle.obr.resource.CapabilityImpl;
+import org.osgi.impl.bundle.obr.resource.RepositoryImpl;
+import org.osgi.impl.bundle.obr.resource.RequirementImpl;
+import org.osgi.impl.bundle.obr.resource.ResourceImpl;
+import org.osgi.impl.bundle.obr.resource.VersionRange;
+
+
+/**
+ * this class is used to configure bindex and get information built by bindex about targeted bundle.
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class ExtractBindexInfo
+{
+
+    /**
+     * attribute get from bindex which describe targeted resource.
+     */
+    private ResourceImpl m_resource;
+
+
+    /**
+     * configure bindex and build information.
+     * @param repoFilename URI on OBR descriptor file
+     * @param outFile path on targeted jar-file
+     * @throws MojoExecutionException occurs if bindex configuration failed
+     */
+    public ExtractBindexInfo( URI repoFilename, String outFile ) throws MojoExecutionException
+    {
+
+        this.m_resource = null;
+        RepositoryImpl repository = null;
+        try
+        {
+            repository = new RepositoryImpl( new File( repoFilename ).getAbsoluteFile().toURL() );
+        }
+        catch ( MalformedURLException e )
+        {
+            e.printStackTrace();
+            throw new MojoExecutionException( "MalformedURLException" );
+        }
+        BundleInfo info = null;
+        try
+        {
+            info = new BundleInfo( repository, new File( outFile ) );
+        }
+        catch ( Exception e )
+        {
+            e.printStackTrace();
+            throw new MojoExecutionException( "Exception" );
+        }
+
+        try
+        {
+            m_resource = info.build();
+        }
+        catch ( Exception e )
+        {
+            e.printStackTrace();
+            throw new MojoExecutionException( "Exception" );
+        }
+    }
+
+
+    /**
+     * transform logical operator in xml syntax.
+     * @param filter string which contains logical operator
+     * @return string in correct xml syntax
+     */
+    private String parseFilter( String filter )
+    {
+        filter.replaceAll( "&", "&amp" );
+        filter.replaceAll( ">=", "&gt" );
+
+        return filter;
+    }
+
+
+    /**
+     * extract capabilities from bindex information.
+     * @return bundle capabilities List
+     */
+    public List getCapabilities()
+    {
+        List list = new ArrayList();
+        Collection res = m_resource.getCapabilityList();
+        Iterator it = res.iterator();
+        while ( it.hasNext() )
+        {
+            Capability capability = new Capability();
+            CapabilityImpl ci = ( CapabilityImpl ) it.next();
+            capability.setName( ci.getName() );
+            // System.out.println(ci.getName()) ;
+            if ( !( ci.getName().compareTo( "bundle" ) == 0 ) )
+            {
+                Map properties = ci.getProperties();
+                for ( Iterator k = properties.keySet().iterator(); k.hasNext(); )
+                {
+                    PElement p = new PElement();
+                    String key = ( String ) k.next();
+                    List values = ( List ) properties.get( key );
+                    for ( Iterator v = values.iterator(); v.hasNext(); )
+                    {
+                        Object value = v.next();
+                        p.setN( key );
+                        if ( value != null )
+                        {
+                            p.setV( value.toString() );
+                        }
+                        else
+                        {
+                            System.out.println( "Missing value " + key );
+                        }
+                        String type = null;
+                        if ( value instanceof Number )
+                        {
+                            type = "number";
+                        }
+                        else
+                        {
+                            if ( value.getClass() == VersionRange.class )
+                            {
+                                type = "version";
+                            }
+                        }
+                        if ( type != null )
+                        {
+                            p.setT( type );
+                        }
+                    }
+                    capability.addP( p );
+                }
+
+                list.add( capability );
+            }
+        }
+        return list;
+    }
+
+
+    /**
+     * extract requirement from bindex information.
+     * @return bundle requirement List
+     */
+    public List getRequirement()
+    {
+        List list = new ArrayList();
+        Collection res = m_resource.getRequirementList();
+        Iterator it = res.iterator();
+        while ( it.hasNext() )
+        {
+            RequirementImpl ci = ( RequirementImpl ) it.next();
+            Require require = new Require();
+
+            require.setExtend( String.valueOf( ci.isExtend() ) );
+            require.setMultiple( String.valueOf( ci.isMultiple() ) );
+            require.setOptional( String.valueOf( ci.isOptional() ) );
+            require.setName( ci.getName() );
+            require.setFilter( this.parseFilter( ci.getFilter() ) );
+            require.setValue( ci.getComment() );
+            list.add( require );
+        }
+        return list;
+    }
+
+
+    /**
+     * extract symbolic name from bindex information.
+     * @return bundle symbolic name
+     */
+    public String getSymbolicName()
+    {
+        return m_resource.getSymbolicName();
+    }
+
+
+    /**
+     * extract version from bindex information.
+     * @return bundle version
+     */
+    public String getVersion()
+    {
+        if ( m_resource.getVersion() != null )
+        {
+            return m_resource.getVersion().toString();
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+
+    /**
+     * extract presentation name from bindex information.
+     * @return bundle presentation name
+     */
+    public String getPresentationName()
+    {
+        return m_resource.getPresentationName();
+    }
+
+
+    /**
+     * extract copyright from bindex information.
+     * @return bundle copyright
+     */
+    public String getCopyright()
+    {
+        return m_resource.getCopyright();
+    }
+
+
+    /**
+     * extract description from bindex information.
+     * @return bundle description
+     */
+    public String getDescription()
+    {
+        return m_resource.getDescription();
+    }
+
+
+    /**
+     * extract documentation from bindex information.
+     * @return bundle documentation
+     */
+    public String getDocumentation()
+    {
+        if ( m_resource.getDocumentation() != null )
+        {
+            return m_resource.getDocumentation().toString();
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+
+    /**
+     * extract license from bindex information.
+     * @return bundle license
+     */
+    public String getLicense()
+    {
+        if ( m_resource.getLicense() != null )
+        {
+            return m_resource.getLicense().toString();
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+
+    /**
+     * extract source from bindex information.
+     * @return bundle source
+     */
+    public String getSource()
+    {
+        if ( m_resource.getSource() != null )
+        {
+            return m_resource.getSource().toString();
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+
+    /**
+     * extract source from bindex information.
+     * @return bundle source
+     */
+    public String getId()
+    {
+        if ( m_resource.getId() != null )
+        {
+            return m_resource.getId();
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+}

Modified: felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrCleanRepo.java
URL: http://svn.apache.org/viewvc/felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrCleanRepo.java?rev=615140&r1=615139&r2=615140&view=diff
==============================================================================
--- felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrCleanRepo.java (original)
+++ felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrCleanRepo.java Fri Jan 25 00:10:25 2008
@@ -1,331 +1,331 @@
-/* 
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.obr.plugin;
-
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Properties;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.Result;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
-
-
-/**
- * Clean an OBR repository by finding and removing missing resources. 
- * @goal clean
- * @phase install
- * @requiresDependencyResolution compile
- * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
- */
-public class ObrCleanRepo extends AbstractMojo
-{
-
-    /**
-     * OBR Repository.
-     * 
-     * @parameter expression="${obrRepository}"
-     */
-    private String obrRepository;
-
-    /**
-     * Local Repository.
-     * 
-     * @parameter expression="${localRepository}"
-     * @required
-     * @readonly
-     */
-    private ArtifactRepository localRepository;
-
-
-    public void execute() throws MojoExecutionException
-    {
-        // If no OBR repository, return
-        if ( "NONE".equalsIgnoreCase( obrRepository ) )
-        {
-            return;
-        }
-
-        try
-        {
-            // Compute local repository location
-            String localRepoPath = localRepository.getBasedir();
-            PathFile repositoryXml = normalizeRepositoryPath( obrRepository, localRepoPath );
-
-            // Check if the file exist
-            if ( !repositoryXml.isExists() )
-            {
-                getLog().error( "The repository file " + repositoryXml.getAbsoluteFilename() + " does not exist" );
-                return;
-            }
-
-            Document doc = parseFile( repositoryXml.getFile(), initConstructor() );
-            Node finalDocument = cleanDocument( doc.getDocumentElement() ); //Analyze existing repository.
-
-            if ( finalDocument == null )
-            {
-                getLog().info( "Nothing to clean in " + repositoryXml.getAbsoluteFilename() );
-            }
-            else
-            {
-                getLog().info( "Cleaning..." );
-                writeToFile( repositoryXml.getUri(), finalDocument ); // Write the new file
-                getLog().info( "Repository " + repositoryXml.getAbsoluteFilename() + " updated" );
-            }
-        }
-        catch ( Exception e )
-        {
-            getLog().error( "Exception while cleaning the OBR repository file : " + e.getLocalizedMessage(), e );
-        }
-    }
-
-
-    /**
-     * Analyze the given XML tree (DOM of the repository file) and remove missing resources.
-     * @param elem : the input XML tree
-     * @return the cleaned XML tree
-     */
-    private Element cleanDocument( Element elem )
-    {
-        NodeList nodes = elem.getElementsByTagName( "resource" );
-        List toRemove = new ArrayList();
-
-        // First, look for missing resources
-        for ( int i = 0; i < nodes.getLength(); i++ )
-        {
-            Element n = ( Element ) nodes.item( i );
-            String value = n.getAttribute( "uri" );
-
-            String localRepoPath = localRepository.getBasedir();
-            File file = new File( localRepoPath, value );
-
-            if ( !file.exists() )
-            {
-                getLog().info(
-                    "The bundle " + n.getAttribute( "presentationname" ) + " - " + n.getAttribute( "version" )
-                        + " will be removed" );
-                toRemove.add( n );
-            }
-        }
-
-        if ( toRemove.size() > 0 )
-        {
-            // Then remove missing resources.
-            for ( int i = 0; i < toRemove.size(); i++ )
-            {
-                elem.removeChild( ( Node ) toRemove.get( i ) );
-            }
-
-            // If we have to remove resources, we need to update  'lastmodified' attribute
-            SimpleDateFormat format = new SimpleDateFormat( "yyyyMMddHHmmss.SSS" );
-            Date d = new Date();
-            d.setTime( System.currentTimeMillis() );
-            elem.setAttribute( "lastmodified", format.format( d ) );
-            return elem;
-        }
-        else
-        {
-            return null;
-        }
-    }
-
-
-    /**
-     * Initialize the document builder from Xerces.
-     * @return DocumentBuilder ready to create new document
-     * @throws MojoExecutionException : occurs when the instantiation of the document builder fails
-     */
-    private DocumentBuilder initConstructor() throws MojoExecutionException
-    {
-        DocumentBuilder constructor = null;
-        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-        try
-        {
-            constructor = factory.newDocumentBuilder();
-        }
-        catch ( ParserConfigurationException e )
-        {
-            getLog().error( "Unable to create a new xml document" );
-            throw new MojoExecutionException( "Cannot create the Document Builder : " + e.getMessage() );
-        }
-        return constructor;
-    }
-
-
-    /**
-     * Open an XML file.
-     * @param filename : XML file path
-     * @param constructor DocumentBuilder get from xerces
-     * @return Document which describes this file
-     * @throws MojoExecutionException occurs when the given file cannot be opened or is a valid XML file.
-     */
-    private Document parseFile( File file, DocumentBuilder constructor ) throws MojoExecutionException
-    {
-        if ( constructor == null )
-        {
-            return null;
-        }
-        // The document is the root of the DOM tree.
-        getLog().info( "Parsing " + file.getAbsolutePath() );
-        Document doc = null;
-        try
-        {
-            doc = constructor.parse( file );
-        }
-        catch ( SAXException e )
-        {
-            getLog().error( "Cannot parse " + file.getAbsolutePath() + " : " + e.getMessage() );
-            throw new MojoExecutionException( "Cannot parse " + file.getAbsolutePath() + " : " + e.getMessage() );
-        }
-        catch ( IOException e )
-        {
-            getLog().error( "Cannot open " + file.getAbsolutePath() + " : " + e.getMessage() );
-            throw new MojoExecutionException( "Cannot open " + file.getAbsolutePath() + " : " + e.getMessage() );
-        }
-        return doc;
-    }
-
-
-    /**
-     * write a Node in a xml file.
-     * @param outputFilename URI to the output file
-     * @param treeToBeWrite Node root of the tree to be write in file
-     * @throws MojoExecutionException if the plugin failed
-     */
-    private void writeToFile( URI outputFilename, Node treeToBeWrite ) throws MojoExecutionException
-    {
-        // init the transformer
-        Transformer transformer = null;
-        TransformerFactory tfabrique = TransformerFactory.newInstance();
-        try
-        {
-            transformer = tfabrique.newTransformer();
-        }
-        catch ( TransformerConfigurationException e )
-        {
-            getLog().error( "Unable to write to file: " + outputFilename.toString() );
-            throw new MojoExecutionException( "Unable to write to file: " + outputFilename.toString() + " : "
-                + e.getMessage() );
-        }
-        Properties proprietes = new Properties();
-        proprietes.put( "method", "xml" );
-        proprietes.put( "version", "1.0" );
-        proprietes.put( "encoding", "ISO-8859-1" );
-        proprietes.put( "standalone", "yes" );
-        proprietes.put( "indent", "yes" );
-        proprietes.put( "omit-xml-declaration", "no" );
-        transformer.setOutputProperties( proprietes );
-
-        DOMSource input = new DOMSource( treeToBeWrite );
-
-        File fichier = new File( outputFilename );
-        FileOutputStream flux = null;
-        try
-        {
-            flux = new FileOutputStream( fichier );
-        }
-        catch ( FileNotFoundException e )
-        {
-            getLog().error( "Unable to write to file: " + fichier.getName() );
-            throw new MojoExecutionException( "Unable to write to file: " + fichier.getName() + " : " + e.getMessage() );
-        }
-        Result output = new StreamResult( flux );
-        try
-        {
-            transformer.transform( input, output );
-        }
-        catch ( TransformerException e )
-        {
-            throw new MojoExecutionException( "Unable to write to file: " + outputFilename.toString() + " : "
-                + e.getMessage() );
-        }
-
-        try
-        {
-            flux.flush();
-            flux.close();
-        }
-        catch ( IOException e )
-        {
-            throw new MojoExecutionException( "IOException when closing file : " + e.getMessage() );
-        }
-
-    }
-
-
-    private static PathFile normalizeRepositoryPath( String obrPath, String mavenPath )
-    {
-        if ( null == obrPath || obrPath.length() == 0 )
-        {
-            obrPath = mavenPath + File.separatorChar + "repository.xml";
-        }
-        else if ( !obrPath.endsWith( ".xml" ) )
-        {
-            obrPath = obrPath + File.separatorChar + "repository.xml";
-        }
-
-        URI uri;
-        try
-        {
-            uri = new URI( obrPath );
-        }
-        catch ( URISyntaxException e )
-        {
-            uri = null;
-        }
-
-        if ( null == uri || !uri.isAbsolute() )
-        {
-            File file = new File( obrPath );
-            if ( !file.isAbsolute() )
-            {
-                file = new File( mavenPath, obrPath );
-            }
-
-            uri = file.toURI();
-        }
-
-        return new PathFile( uri.toASCIIString() );
-    }
-}
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.obr.plugin;
+
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Properties;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Result;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+
+/**
+ * Clean an OBR repository by finding and removing missing resources. 
+ * @goal clean
+ * @phase install
+ * @requiresDependencyResolution compile
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class ObrCleanRepo extends AbstractMojo
+{
+
+    /**
+     * OBR Repository.
+     * 
+     * @parameter expression="${obrRepository}"
+     */
+    private String obrRepository;
+
+    /**
+     * Local Repository.
+     * 
+     * @parameter expression="${localRepository}"
+     * @required
+     * @readonly
+     */
+    private ArtifactRepository localRepository;
+
+
+    public void execute() throws MojoExecutionException
+    {
+        // If no OBR repository, return
+        if ( "NONE".equalsIgnoreCase( obrRepository ) )
+        {
+            return;
+        }
+
+        try
+        {
+            // Compute local repository location
+            String localRepoPath = localRepository.getBasedir();
+            PathFile repositoryXml = normalizeRepositoryPath( obrRepository, localRepoPath );
+
+            // Check if the file exist
+            if ( !repositoryXml.isExists() )
+            {
+                getLog().error( "The repository file " + repositoryXml.getAbsoluteFilename() + " does not exist" );
+                return;
+            }
+
+            Document doc = parseFile( repositoryXml.getFile(), initConstructor() );
+            Node finalDocument = cleanDocument( doc.getDocumentElement() ); //Analyze existing repository.
+
+            if ( finalDocument == null )
+            {
+                getLog().info( "Nothing to clean in " + repositoryXml.getAbsoluteFilename() );
+            }
+            else
+            {
+                getLog().info( "Cleaning..." );
+                writeToFile( repositoryXml.getUri(), finalDocument ); // Write the new file
+                getLog().info( "Repository " + repositoryXml.getAbsoluteFilename() + " updated" );
+            }
+        }
+        catch ( Exception e )
+        {
+            getLog().error( "Exception while cleaning the OBR repository file : " + e.getLocalizedMessage(), e );
+        }
+    }
+
+
+    /**
+     * Analyze the given XML tree (DOM of the repository file) and remove missing resources.
+     * @param elem : the input XML tree
+     * @return the cleaned XML tree
+     */
+    private Element cleanDocument( Element elem )
+    {
+        NodeList nodes = elem.getElementsByTagName( "resource" );
+        List toRemove = new ArrayList();
+
+        // First, look for missing resources
+        for ( int i = 0; i < nodes.getLength(); i++ )
+        {
+            Element n = ( Element ) nodes.item( i );
+            String value = n.getAttribute( "uri" );
+
+            String localRepoPath = localRepository.getBasedir();
+            File file = new File( localRepoPath, value );
+
+            if ( !file.exists() )
+            {
+                getLog().info(
+                    "The bundle " + n.getAttribute( "presentationname" ) + " - " + n.getAttribute( "version" )
+                        + " will be removed" );
+                toRemove.add( n );
+            }
+        }
+
+        if ( toRemove.size() > 0 )
+        {
+            // Then remove missing resources.
+            for ( int i = 0; i < toRemove.size(); i++ )
+            {
+                elem.removeChild( ( Node ) toRemove.get( i ) );
+            }
+
+            // If we have to remove resources, we need to update  'lastmodified' attribute
+            SimpleDateFormat format = new SimpleDateFormat( "yyyyMMddHHmmss.SSS" );
+            Date d = new Date();
+            d.setTime( System.currentTimeMillis() );
+            elem.setAttribute( "lastmodified", format.format( d ) );
+            return elem;
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+
+    /**
+     * Initialize the document builder from Xerces.
+     * @return DocumentBuilder ready to create new document
+     * @throws MojoExecutionException : occurs when the instantiation of the document builder fails
+     */
+    private DocumentBuilder initConstructor() throws MojoExecutionException
+    {
+        DocumentBuilder constructor = null;
+        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+        try
+        {
+            constructor = factory.newDocumentBuilder();
+        }
+        catch ( ParserConfigurationException e )
+        {
+            getLog().error( "Unable to create a new xml document" );
+            throw new MojoExecutionException( "Cannot create the Document Builder : " + e.getMessage() );
+        }
+        return constructor;
+    }
+
+
+    /**
+     * Open an XML file.
+     * @param filename : XML file path
+     * @param constructor DocumentBuilder get from xerces
+     * @return Document which describes this file
+     * @throws MojoExecutionException occurs when the given file cannot be opened or is a valid XML file.
+     */
+    private Document parseFile( File file, DocumentBuilder constructor ) throws MojoExecutionException
+    {
+        if ( constructor == null )
+        {
+            return null;
+        }
+        // The document is the root of the DOM tree.
+        getLog().info( "Parsing " + file.getAbsolutePath() );
+        Document doc = null;
+        try
+        {
+            doc = constructor.parse( file );
+        }
+        catch ( SAXException e )
+        {
+            getLog().error( "Cannot parse " + file.getAbsolutePath() + " : " + e.getMessage() );
+            throw new MojoExecutionException( "Cannot parse " + file.getAbsolutePath() + " : " + e.getMessage() );
+        }
+        catch ( IOException e )
+        {
+            getLog().error( "Cannot open " + file.getAbsolutePath() + " : " + e.getMessage() );
+            throw new MojoExecutionException( "Cannot open " + file.getAbsolutePath() + " : " + e.getMessage() );
+        }
+        return doc;
+    }
+
+
+    /**
+     * write a Node in a xml file.
+     * @param outputFilename URI to the output file
+     * @param treeToBeWrite Node root of the tree to be write in file
+     * @throws MojoExecutionException if the plugin failed
+     */
+    private void writeToFile( URI outputFilename, Node treeToBeWrite ) throws MojoExecutionException
+    {
+        // init the transformer
+        Transformer transformer = null;
+        TransformerFactory tfabrique = TransformerFactory.newInstance();
+        try
+        {
+            transformer = tfabrique.newTransformer();
+        }
+        catch ( TransformerConfigurationException e )
+        {
+            getLog().error( "Unable to write to file: " + outputFilename.toString() );
+            throw new MojoExecutionException( "Unable to write to file: " + outputFilename.toString() + " : "
+                + e.getMessage() );
+        }
+        Properties proprietes = new Properties();
+        proprietes.put( "method", "xml" );
+        proprietes.put( "version", "1.0" );
+        proprietes.put( "encoding", "ISO-8859-1" );
+        proprietes.put( "standalone", "yes" );
+        proprietes.put( "indent", "yes" );
+        proprietes.put( "omit-xml-declaration", "no" );
+        transformer.setOutputProperties( proprietes );
+
+        DOMSource input = new DOMSource( treeToBeWrite );
+
+        File fichier = new File( outputFilename );
+        FileOutputStream flux = null;
+        try
+        {
+            flux = new FileOutputStream( fichier );
+        }
+        catch ( FileNotFoundException e )
+        {
+            getLog().error( "Unable to write to file: " + fichier.getName() );
+            throw new MojoExecutionException( "Unable to write to file: " + fichier.getName() + " : " + e.getMessage() );
+        }
+        Result output = new StreamResult( flux );
+        try
+        {
+            transformer.transform( input, output );
+        }
+        catch ( TransformerException e )
+        {
+            throw new MojoExecutionException( "Unable to write to file: " + outputFilename.toString() + " : "
+                + e.getMessage() );
+        }
+
+        try
+        {
+            flux.flush();
+            flux.close();
+        }
+        catch ( IOException e )
+        {
+            throw new MojoExecutionException( "IOException when closing file : " + e.getMessage() );
+        }
+
+    }
+
+
+    private static PathFile normalizeRepositoryPath( String obrPath, String mavenPath )
+    {
+        if ( null == obrPath || obrPath.length() == 0 )
+        {
+            obrPath = mavenPath + File.separatorChar + "repository.xml";
+        }
+        else if ( !obrPath.endsWith( ".xml" ) )
+        {
+            obrPath = obrPath + File.separatorChar + "repository.xml";
+        }
+
+        URI uri;
+        try
+        {
+            uri = new URI( obrPath );
+        }
+        catch ( URISyntaxException e )
+        {
+            uri = null;
+        }
+
+        if ( null == uri || !uri.isAbsolute() )
+        {
+            File file = new File( obrPath );
+            if ( !file.isAbsolute() )
+            {
+                file = new File( mavenPath, obrPath );
+            }
+
+            uri = file.toURI();
+        }
+
+        return new PathFile( uri.toASCIIString() );
+    }
+}

Modified: felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrDeploy.java
URL: http://svn.apache.org/viewvc/felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrDeploy.java?rev=615140&r1=615139&r2=615140&view=diff
==============================================================================
--- felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrDeploy.java (original)
+++ felix/trunk/maven-obr-plugin/src/main/java/org/apache/felix/obr/plugin/ObrDeploy.java Fri Jan 25 00:10:25 2008
@@ -1,374 +1,374 @@
-/* 
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.obr.plugin;
-
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.Writer;
-import java.util.List;
-
-import org.apache.maven.artifact.manager.WagonManager;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.model.Resource;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.settings.Settings;
-import org.apache.maven.wagon.ResourceDoesNotExistException;
-import org.apache.maven.wagon.TransferFailedException;
-import org.apache.maven.wagon.authorization.AuthorizationException;
-
-
-/**
- * deploy the bundle to a remote site.
- * this goal is used when you compile a project with a pom file
- * @goal deployment
- * @phase deploy
- * @requiresDependencyResolution compile
- * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
- */
-
-public class ObrDeploy extends AbstractMojo
-{
-
-    /**
-     * setting of maven.
-     * 
-     * @parameter expression="${settings}"
-     * @require
-     */
-    private Settings m_settings;
-
-    /**
-     * name of the repository xml descriptor file.
-     * 
-     * @parameter expression="${repository-name}" default-value="repository.xml"
-     */
-    private String m_repositoryName;
-
-    /**
-     * The local Maven repository.
-     * 
-     * @parameter expression="${localRepository}"
-     * @required
-     */
-    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="${ignore-lock}"
-     * 
-     */
-    private boolean m_ignoreLock;
-
-    /**
-     * used to store pathfile in local repo.
-     */
-    private String m_fileInLocalRepo;
-
-    /**
-     * Enable/Disable this goal
-     * @description If true evrything the goal do nothing, the goal just skip over 
-     * @parameter expression="${maven.obr.installToRemoteOBR}" default-value="false"
-     */
-    private boolean installToRemoteOBR;
-
-
-    /**
-     * main method for this goal.
-     * @implements org.apache.maven.plugin.Mojo.execute 
-     * @throws MojoExecutionException if the plugin failed
-     * @throws MojoFailureException if the plugin failed
-     */
-    public void execute() throws MojoExecutionException, MojoFailureException
-    {
-        getLog().info( "Obr-deploy start:" );
-        if ( !installToRemoteOBR )
-        {
-            getLog().info( "maven-obr-plugin:deploy goal is disable due to one of the following reason:" );
-            getLog().info( " - 'installToRemoteOBR' configuration set to false" );
-            getLog().info( " - JVM property maven.obr.installToRemoteOBR set to false" );
-            return;
-        }
-        ArtifactRepository ar = m_project.getDistributionManagementArtifactRepository();
-
-        // locate the obr.xml file
-        String obrXmlFile = null;
-        List l = m_project.getResources();
-        for ( int i = 0; i < l.size(); i++ )
-        {
-            File f = new File( ( ( Resource ) l.get( i ) ).getDirectory() + File.separator + "obr.xml" );
-            if ( f.exists() )
-            {
-                obrXmlFile = ( ( Resource ) l.get( i ) ).getDirectory() + File.separator + "obr.xml";
-                break;
-            }
-        }
-
-        // the obr.xml file is not present
-        if ( obrXmlFile == null )
-        {
-            getLog().warn( "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();
-
-        // create a non-empty file used to lock the repository descriptor file
-        File lockFile = null;
-        Writer output = null;
-        try
-        {
-            lockFile = File.createTempFile( String.valueOf( System.currentTimeMillis() ), null );
-            output = new BufferedWriter( new FileWriter( lockFile ) );
-            output.write( "locked" );
-            output.close();
-        }
-        catch ( IOException e )
-        {
-            getLog().error( "Unable to create temporary file" );
-            throw new MojoFailureException( "IOException" );
-        }
-
-        if ( m_ignoreLock )
-        {
-            try
-            {
-                remoteFile.put( lockFile, m_repositoryName + ".lock" );
-            }
-            catch ( TransferFailedException e )
-            {
-                getLog().error( "Transfer failed" );
-                e.printStackTrace();
-                throw new MojoFailureException( "TransferFailedException" );
-
-            }
-            catch ( ResourceDoesNotExistException e )
-            {
-                throw new MojoFailureException( "ResourceDoesNotExistException" );
-            }
-            catch ( AuthorizationException e )
-            {
-                getLog().error( "Authorization failed" );
-                e.printStackTrace();
-                throw new MojoFailureException( "AuthorizationException" );
-            }
-
-        }
-        else
-        {
-            int countError = 0;
-            while ( remoteFile.isLockedFile( remoteFile, m_repositoryName ) && countError < 2 )
-            {
-                countError++;
-                getLog().warn( "File is locked, retry in 10s" );
-                try
-                {
-                    Thread.sleep( 10000 );
-                }
-                catch ( InterruptedException e )
-                {
-                    getLog().warn( "Sleep interupted" );
-                }
-            }
-
-            if ( countError == 2 )
-            {
-                getLog().error(
-                    "File: " + m_repositoryName + " is locked. Try -Dignore-lock=true if you want force uploading" );
-                throw new MojoFailureException( "fileLocked" );
-            }
-        }
-
-        // file is not locked, so we lock it now
-        try
-        {
-            remoteFile.put( lockFile, m_repositoryName + ".lock" );
-        }
-        catch ( TransferFailedException e )
-        {
-            getLog().error( "Transfer failed" );
-            e.printStackTrace();
-            throw new MojoFailureException( "TransferFailedException" );
-
-        }
-        catch ( ResourceDoesNotExistException e )
-        {
-            throw new MojoFailureException( "ResourceDoesNotExistException" );
-        }
-        catch ( AuthorizationException e )
-        {
-            getLog().error( "Authorization failed" );
-            e.printStackTrace();
-            throw new MojoFailureException( "AuthorizationException" );
-        }
-
-        try
-        {
-            repoDescriptorFile = remoteFile.get( m_repositoryName );
-        }
-        catch ( TransferFailedException e )
-        {
-            getLog().error( "Transfer failed" );
-            e.printStackTrace();
-            throw new MojoFailureException( "TransferFailedException" );
-
-        }
-        catch ( ResourceDoesNotExistException e )
-        {
-            // file doesn't exist! create a new one
-            getLog().warn( "file specified does not exist: " + m_repositoryName );
-            getLog().warn( "Create a new repository descriptor file " + m_repositoryName );
-            try
-            {
-                File f = File.createTempFile( String.valueOf( System.currentTimeMillis() ), null );
-                repoDescriptorFile = new File( f.getParent() + File.separator
-                    + String.valueOf( System.currentTimeMillis() ) + ".xml" );
-            }
-            catch ( IOException e1 )
-            {
-                getLog().error( "canno't create temporary file" );
-                e1.printStackTrace();
-                return;
-            }
-        }
-        catch ( AuthorizationException e )
-        {
-            getLog().error( "Authorization failed" );
-            e.printStackTrace();
-            throw new MojoFailureException( "AuthorizationException" );
-        }
-        catch ( IOException e )
-        {
-            e.printStackTrace();
-            throw new MojoFailureException( "IOException" );
-        }
-
-        Config userConfig = new Config();
-        userConfig.setPathRelative( true );
-        userConfig.setRemotely( true );
-
-        PathFile file = null;
-
-        // get the path to local maven repository
-        file = new PathFile( PathFile.uniformSeparator( m_settings.getLocalRepository() ) + File.separator
-            + PathFile.uniformSeparator( m_localRepo.pathOf( m_project.getArtifact() ) ) );
-        if ( file.isExists() )
-        {
-            m_fileInLocalRepo = file.getOnlyAbsoluteFilename();
-        }
-        else
-        {
-            getLog().error(
-                "file not found in local repository: " + m_settings.getLocalRepository() + File.separator
-                    + m_localRepo.pathOf( m_project.getArtifact() ) );
-            return;
-        }
-
-        file = new PathFile( "file:/" + repoDescriptorFile.getAbsolutePath() );
-
-        ObrUpdate obrUpdate = new ObrUpdate( file, obrXmlFile, m_project, m_fileInLocalRepo, PathFile
-            .uniformSeparator( m_settings.getLocalRepository() ), userConfig, getLog() );
-
-        obrUpdate.updateRepository();
-
-        // the reposiroty descriptor file is modified, we upload it on the remote repository
-        try
-        {
-            remoteFile.put( repoDescriptorFile, m_repositoryName );
-        }
-        catch ( TransferFailedException e )
-        {
-            getLog().error( "Transfer failed" );
-            e.printStackTrace();
-            throw new MojoFailureException( "TransferFailedException" );
-        }
-        catch ( ResourceDoesNotExistException e )
-        {
-            getLog().error( "Resource does not exist:" + repoDescriptorFile.getName() );
-            e.printStackTrace();
-            throw new MojoFailureException( "ResourceDoesNotExistException" );
-        }
-        catch ( AuthorizationException e )
-        {
-            getLog().error( "Authorization failed" );
-            e.printStackTrace();
-            throw new MojoFailureException( "AuthorizationException" );
-        }
-        repoDescriptorFile.delete();
-
-        // we remove lockFile activation
-        lockFile = null;
-        try
-        {
-            lockFile = File.createTempFile( String.valueOf( System.currentTimeMillis() ), null );
-        }
-        catch ( IOException e )
-        {
-            e.printStackTrace();
-            throw new MojoFailureException( "IOException" );
-        }
-        try
-        {
-            remoteFile.put( lockFile, m_repositoryName + ".lock" );
-        }
-        catch ( TransferFailedException e )
-        {
-            getLog().error( "Transfer failed" );
-            e.printStackTrace();
-            throw new MojoFailureException( "TransferFailedException" );
-        }
-        catch ( ResourceDoesNotExistException e )
-        {
-            e.printStackTrace();
-            throw new MojoFailureException( "ResourceDoesNotExistException" );
-        }
-        catch ( AuthorizationException e )
-        {
-            getLog().error( "Authorization failed" );
-            e.printStackTrace();
-            throw new MojoFailureException( "AuthorizationException" );
-        }
-
-        remoteFile.disconnect();
-    }
-
-}
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.obr.plugin;
+
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.Writer;
+import java.util.List;
+
+import org.apache.maven.artifact.manager.WagonManager;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.model.Resource;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.settings.Settings;
+import org.apache.maven.wagon.ResourceDoesNotExistException;
+import org.apache.maven.wagon.TransferFailedException;
+import org.apache.maven.wagon.authorization.AuthorizationException;
+
+
+/**
+ * deploy the bundle to a remote site.
+ * this goal is used when you compile a project with a pom file
+ * @goal deployment
+ * @phase deploy
+ * @requiresDependencyResolution compile
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+
+public class ObrDeploy extends AbstractMojo
+{
+
+    /**
+     * setting of maven.
+     * 
+     * @parameter expression="${settings}"
+     * @require
+     */
+    private Settings m_settings;
+
+    /**
+     * name of the repository xml descriptor file.
+     * 
+     * @parameter expression="${repository-name}" default-value="repository.xml"
+     */
+    private String m_repositoryName;
+
+    /**
+     * The local Maven repository.
+     * 
+     * @parameter expression="${localRepository}"
+     * @required
+     */
+    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="${ignore-lock}"
+     * 
+     */
+    private boolean m_ignoreLock;
+
+    /**
+     * used to store pathfile in local repo.
+     */
+    private String m_fileInLocalRepo;
+
+    /**
+     * Enable/Disable this goal
+     * @description If true evrything the goal do nothing, the goal just skip over 
+     * @parameter expression="${maven.obr.installToRemoteOBR}" default-value="false"
+     */
+    private boolean installToRemoteOBR;
+
+
+    /**
+     * main method for this goal.
+     * @implements org.apache.maven.plugin.Mojo.execute 
+     * @throws MojoExecutionException if the plugin failed
+     * @throws MojoFailureException if the plugin failed
+     */
+    public void execute() throws MojoExecutionException, MojoFailureException
+    {
+        getLog().info( "Obr-deploy start:" );
+        if ( !installToRemoteOBR )
+        {
+            getLog().info( "maven-obr-plugin:deploy goal is disable due to one of the following reason:" );
+            getLog().info( " - 'installToRemoteOBR' configuration set to false" );
+            getLog().info( " - JVM property maven.obr.installToRemoteOBR set to false" );
+            return;
+        }
+        ArtifactRepository ar = m_project.getDistributionManagementArtifactRepository();
+
+        // locate the obr.xml file
+        String obrXmlFile = null;
+        List l = m_project.getResources();
+        for ( int i = 0; i < l.size(); i++ )
+        {
+            File f = new File( ( ( Resource ) l.get( i ) ).getDirectory() + File.separator + "obr.xml" );
+            if ( f.exists() )
+            {
+                obrXmlFile = ( ( Resource ) l.get( i ) ).getDirectory() + File.separator + "obr.xml";
+                break;
+            }
+        }
+
+        // the obr.xml file is not present
+        if ( obrXmlFile == null )
+        {
+            getLog().warn( "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();
+
+        // create a non-empty file used to lock the repository descriptor file
+        File lockFile = null;
+        Writer output = null;
+        try
+        {
+            lockFile = File.createTempFile( String.valueOf( System.currentTimeMillis() ), null );
+            output = new BufferedWriter( new FileWriter( lockFile ) );
+            output.write( "locked" );
+            output.close();
+        }
+        catch ( IOException e )
+        {
+            getLog().error( "Unable to create temporary file" );
+            throw new MojoFailureException( "IOException" );
+        }
+
+        if ( m_ignoreLock )
+        {
+            try
+            {
+                remoteFile.put( lockFile, m_repositoryName + ".lock" );
+            }
+            catch ( TransferFailedException e )
+            {
+                getLog().error( "Transfer failed" );
+                e.printStackTrace();
+                throw new MojoFailureException( "TransferFailedException" );
+
+            }
+            catch ( ResourceDoesNotExistException e )
+            {
+                throw new MojoFailureException( "ResourceDoesNotExistException" );
+            }
+            catch ( AuthorizationException e )
+            {
+                getLog().error( "Authorization failed" );
+                e.printStackTrace();
+                throw new MojoFailureException( "AuthorizationException" );
+            }
+
+        }
+        else
+        {
+            int countError = 0;
+            while ( remoteFile.isLockedFile( remoteFile, m_repositoryName ) && countError < 2 )
+            {
+                countError++;
+                getLog().warn( "File is locked, retry in 10s" );
+                try
+                {
+                    Thread.sleep( 10000 );
+                }
+                catch ( InterruptedException e )
+                {
+                    getLog().warn( "Sleep interupted" );
+                }
+            }
+
+            if ( countError == 2 )
+            {
+                getLog().error(
+                    "File: " + m_repositoryName + " is locked. Try -Dignore-lock=true if you want force uploading" );
+                throw new MojoFailureException( "fileLocked" );
+            }
+        }
+
+        // file is not locked, so we lock it now
+        try
+        {
+            remoteFile.put( lockFile, m_repositoryName + ".lock" );
+        }
+        catch ( TransferFailedException e )
+        {
+            getLog().error( "Transfer failed" );
+            e.printStackTrace();
+            throw new MojoFailureException( "TransferFailedException" );
+
+        }
+        catch ( ResourceDoesNotExistException e )
+        {
+            throw new MojoFailureException( "ResourceDoesNotExistException" );
+        }
+        catch ( AuthorizationException e )
+        {
+            getLog().error( "Authorization failed" );
+            e.printStackTrace();
+            throw new MojoFailureException( "AuthorizationException" );
+        }
+
+        try
+        {
+            repoDescriptorFile = remoteFile.get( m_repositoryName );
+        }
+        catch ( TransferFailedException e )
+        {
+            getLog().error( "Transfer failed" );
+            e.printStackTrace();
+            throw new MojoFailureException( "TransferFailedException" );
+
+        }
+        catch ( ResourceDoesNotExistException e )
+        {
+            // file doesn't exist! create a new one
+            getLog().warn( "file specified does not exist: " + m_repositoryName );
+            getLog().warn( "Create a new repository descriptor file " + m_repositoryName );
+            try
+            {
+                File f = File.createTempFile( String.valueOf( System.currentTimeMillis() ), null );
+                repoDescriptorFile = new File( f.getParent() + File.separator
+                    + String.valueOf( System.currentTimeMillis() ) + ".xml" );
+            }
+            catch ( IOException e1 )
+            {
+                getLog().error( "canno't create temporary file" );
+                e1.printStackTrace();
+                return;
+            }
+        }
+        catch ( AuthorizationException e )
+        {
+            getLog().error( "Authorization failed" );
+            e.printStackTrace();
+            throw new MojoFailureException( "AuthorizationException" );
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();
+            throw new MojoFailureException( "IOException" );
+        }
+
+        Config userConfig = new Config();
+        userConfig.setPathRelative( true );
+        userConfig.setRemotely( true );
+
+        PathFile file = null;
+
+        // get the path to local maven repository
+        file = new PathFile( PathFile.uniformSeparator( m_settings.getLocalRepository() ) + File.separator
+            + PathFile.uniformSeparator( m_localRepo.pathOf( m_project.getArtifact() ) ) );
+        if ( file.isExists() )
+        {
+            m_fileInLocalRepo = file.getOnlyAbsoluteFilename();
+        }
+        else
+        {
+            getLog().error(
+                "file not found in local repository: " + m_settings.getLocalRepository() + File.separator
+                    + m_localRepo.pathOf( m_project.getArtifact() ) );
+            return;
+        }
+
+        file = new PathFile( "file:/" + repoDescriptorFile.getAbsolutePath() );
+
+        ObrUpdate obrUpdate = new ObrUpdate( file, obrXmlFile, m_project, m_fileInLocalRepo, PathFile
+            .uniformSeparator( m_settings.getLocalRepository() ), userConfig, getLog() );
+
+        obrUpdate.updateRepository();
+
+        // the reposiroty descriptor file is modified, we upload it on the remote repository
+        try
+        {
+            remoteFile.put( repoDescriptorFile, m_repositoryName );
+        }
+        catch ( TransferFailedException e )
+        {
+            getLog().error( "Transfer failed" );
+            e.printStackTrace();
+            throw new MojoFailureException( "TransferFailedException" );
+        }
+        catch ( ResourceDoesNotExistException e )
+        {
+            getLog().error( "Resource does not exist:" + repoDescriptorFile.getName() );
+            e.printStackTrace();
+            throw new MojoFailureException( "ResourceDoesNotExistException" );
+        }
+        catch ( AuthorizationException e )
+        {
+            getLog().error( "Authorization failed" );
+            e.printStackTrace();
+            throw new MojoFailureException( "AuthorizationException" );
+        }
+        repoDescriptorFile.delete();
+
+        // we remove lockFile activation
+        lockFile = null;
+        try
+        {
+            lockFile = File.createTempFile( String.valueOf( System.currentTimeMillis() ), null );
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();
+            throw new MojoFailureException( "IOException" );
+        }
+        try
+        {
+            remoteFile.put( lockFile, m_repositoryName + ".lock" );
+        }
+        catch ( TransferFailedException e )
+        {
+            getLog().error( "Transfer failed" );
+            e.printStackTrace();
+            throw new MojoFailureException( "TransferFailedException" );
+        }
+        catch ( ResourceDoesNotExistException e )
+        {
+            e.printStackTrace();
+            throw new MojoFailureException( "ResourceDoesNotExistException" );
+        }
+        catch ( AuthorizationException e )
+        {
+            getLog().error( "Authorization failed" );
+            e.printStackTrace();
+            throw new MojoFailureException( "AuthorizationException" );
+        }
+
+        remoteFile.disconnect();
+    }
+
+}