Coverage Report - org.apache.maven.artifact.repository.metadata.Metadata
 
Classes in this File Line Coverage Branch Coverage Complexity
Metadata
0 %
0/92
0 %
0/56
0
 
 1  
 /*
 2  
  =================== DO NOT EDIT THIS FILE ====================
 3  
  Generated by Modello 1.0.1 on 2009-09-09 03:03:24,
 4  
  any modifications will be overwritten.
 5  
  ==============================================================
 6  
  */
 7  
 
 8  
 package org.apache.maven.artifact.repository.metadata;
 9  
 
 10  
 /**
 11  
  * Class Metadata.
 12  
  * 
 13  
  * @version $Revision$ $Date$
 14  
  */
 15  0
 public class Metadata
 16  
     implements java.io.Serializable
 17  
 {
 18  
 
 19  
       //--------------------------/
 20  
      //- Class/Member Variables -/
 21  
     //--------------------------/
 22  
 
 23  
     /**
 24  
      * The groupId that this directory represents, if any.
 25  
      */
 26  
     private String groupId;
 27  
 
 28  
     /**
 29  
      * The artifactId that this directory represents, if any.
 30  
      */
 31  
     private String artifactId;
 32  
 
 33  
     /**
 34  
      * The version that this directory represents, if any.
 35  
      */
 36  
     private String version;
 37  
 
 38  
     /**
 39  
      * Versioning information for the artifact.
 40  
      */
 41  
     private Versioning versioning;
 42  
 
 43  
     /**
 44  
      * Field plugins.
 45  
      */
 46  
     private java.util.List<Plugin> plugins;
 47  
 
 48  
     /**
 49  
      * Field modelEncoding.
 50  
      */
 51  0
     private String modelEncoding = "UTF-8";
 52  
 
 53  
 
 54  
       //-----------/
 55  
      //- Methods -/
 56  
     //-----------/
 57  
 
 58  
     /**
 59  
      * Method addPlugin.
 60  
      * 
 61  
      * @param plugin
 62  
      */
 63  
     public void addPlugin( Plugin plugin )
 64  
     {
 65  0
         if ( !(plugin instanceof Plugin) )
 66  
         {
 67  0
             throw new ClassCastException( "Metadata.addPlugins(plugin) parameter must be instanceof " + Plugin.class.getName() );
 68  
         }
 69  0
         getPlugins().add( plugin );
 70  0
     } //-- void addPlugin( Plugin )
 71  
 
 72  
     /**
 73  
      * Get the artifactId that this directory represents, if any.
 74  
      * 
 75  
      * @return String
 76  
      */
 77  
     public String getArtifactId()
 78  
     {
 79  0
         return this.artifactId;
 80  
     } //-- String getArtifactId()
 81  
 
 82  
     /**
 83  
      * Get the groupId that this directory represents, if any.
 84  
      * 
 85  
      * @return String
 86  
      */
 87  
     public String getGroupId()
 88  
     {
 89  0
         return this.groupId;
 90  
     } //-- String getGroupId()
 91  
 
 92  
     /**
 93  
      * Method getModelEncoding.
 94  
      * 
 95  
      * @return the current encoding used when reading/writing this
 96  
      * model
 97  
      */
 98  
     public String getModelEncoding()
 99  
     {
 100  0
         return modelEncoding;
 101  
     } //-- String getModelEncoding()
 102  
 
 103  
     /**
 104  
      * Method getPlugins.
 105  
      * 
 106  
      * @return List
 107  
      */
 108  
     public java.util.List<Plugin> getPlugins()
 109  
     {
 110  0
         if ( this.plugins == null )
 111  
         {
 112  0
             this.plugins = new java.util.ArrayList<Plugin>();
 113  
         }
 114  
 
 115  0
         return this.plugins;
 116  
     } //-- java.util.List<Plugin> getPlugins()
 117  
 
 118  
     /**
 119  
      * Get the version that this directory represents, if any.
 120  
      * 
 121  
      * @return String
 122  
      */
 123  
     public String getVersion()
 124  
     {
 125  0
         return this.version;
 126  
     } //-- String getVersion()
 127  
 
 128  
     /**
 129  
      * Get versioning information for the artifact.
 130  
      * 
 131  
      * @return Versioning
 132  
      */
 133  
     public Versioning getVersioning()
 134  
     {
 135  0
         return this.versioning;
 136  
     } //-- Versioning getVersioning()
 137  
 
 138  
     /**
 139  
      * Method removePlugin.
 140  
      * 
 141  
      * @param plugin
 142  
      */
 143  
     public void removePlugin( Plugin plugin )
 144  
     {
 145  0
         if ( !(plugin instanceof Plugin) )
 146  
         {
 147  0
             throw new ClassCastException( "Metadata.removePlugins(plugin) parameter must be instanceof " + Plugin.class.getName() );
 148  
         }
 149  0
         getPlugins().remove( plugin );
 150  0
     } //-- void removePlugin( Plugin )
 151  
 
 152  
     /**
 153  
      * Set the artifactId that this directory represents, if any.
 154  
      * 
 155  
      * @param artifactId
 156  
      */
 157  
     public void setArtifactId( String artifactId )
 158  
     {
 159  0
         this.artifactId = artifactId;
 160  0
     } //-- void setArtifactId( String )
 161  
 
 162  
     /**
 163  
      * Set the groupId that this directory represents, if any.
 164  
      * 
 165  
      * @param groupId
 166  
      */
 167  
     public void setGroupId( String groupId )
 168  
     {
 169  0
         this.groupId = groupId;
 170  0
     } //-- void setGroupId( String )
 171  
 
 172  
     /**
 173  
      * Set an encoding used for reading/writing the model.
 174  
      * 
 175  
      * @param modelEncoding
 176  
      */
 177  
     public void setModelEncoding( String modelEncoding )
 178  
     {
 179  0
         this.modelEncoding = modelEncoding;
 180  0
     } //-- void setModelEncoding( String )
 181  
 
 182  
     /**
 183  
      * Set the set of plugin mappings for the group.
 184  
      * 
 185  
      * @param plugins
 186  
      */
 187  
     public void setPlugins( java.util.List<Plugin> plugins )
 188  
     {
 189  0
         this.plugins = plugins;
 190  0
     } //-- void setPlugins( java.util.List )
 191  
 
 192  
     /**
 193  
      * Set the version that this directory represents, if any.
 194  
      * 
 195  
      * @param version
 196  
      */
 197  
     public void setVersion( String version )
 198  
     {
 199  0
         this.version = version;
 200  0
     } //-- void setVersion( String )
 201  
 
 202  
     /**
 203  
      * Set versioning information for the artifact.
 204  
      * 
 205  
      * @param versioning
 206  
      */
 207  
     public void setVersioning( Versioning versioning )
 208  
     {
 209  0
         this.versioning = versioning;
 210  0
     } //-- void setVersioning( Versioning )
 211  
 
 212  
 
 213  
     public boolean merge( Metadata sourceMetadata )
 214  
     {
 215  0
         boolean changed = false;
 216  
 
 217  0
         for ( java.util.Iterator i = sourceMetadata.getPlugins().iterator(); i.hasNext(); )
 218  
         {
 219  0
             Plugin plugin = (Plugin) i.next();
 220  0
             boolean found = false;
 221  
 
 222  0
             for ( java.util.Iterator it = getPlugins().iterator(); it.hasNext() && !found; )
 223  
             {
 224  0
                 Plugin preExisting = (Plugin) it.next();
 225  
 
 226  0
                 if ( preExisting.getPrefix().equals( plugin.getPrefix() ) )
 227  
                 {
 228  0
                     found = true;
 229  
                 }
 230  0
             }
 231  
 
 232  0
             if ( !found )
 233  
             {
 234  0
                 Plugin mappedPlugin = new Plugin();
 235  
 
 236  0
                 mappedPlugin.setArtifactId( plugin.getArtifactId() );
 237  
 
 238  0
                 mappedPlugin.setPrefix( plugin.getPrefix() );
 239  
 
 240  0
                 mappedPlugin.setName( plugin.getName() );
 241  
 
 242  0
                 addPlugin( mappedPlugin );
 243  
 
 244  0
                 changed = true;
 245  
             }
 246  0
         }
 247  
 
 248  0
         Versioning versioning = sourceMetadata.getVersioning();
 249  0
         if ( versioning != null )
 250  
         {
 251  0
             Versioning v = getVersioning();
 252  0
             if ( v == null )
 253  
             {
 254  0
                 v = new Versioning();
 255  0
                 setVersioning( v );
 256  0
                 changed = true;
 257  
             }
 258  
 
 259  0
             for ( java.util.Iterator i = versioning.getVersions().iterator(); i.hasNext(); )
 260  
             {
 261  0
                 String version = (String) i.next();
 262  0
                 if ( !v.getVersions().contains( version ) )
 263  
                 {
 264  0
                     changed = true;
 265  0
                     v.getVersions().add( version );
 266  
                 }
 267  0
             }
 268  
 
 269  0
             if ( "null".equals( versioning.getLastUpdated() ) )
 270  
             {
 271  0
                 versioning.setLastUpdated( null );
 272  
             }
 273  
 
 274  0
             if ( "null".equals( v.getLastUpdated() ) )
 275  
             {
 276  0
                 v.setLastUpdated( null );
 277  
             }
 278  
 
 279  0
             if ( versioning.getLastUpdated() == null || versioning.getLastUpdated().length() == 0 )
 280  
             {
 281  
                 // this should only be for historical reasons - we assume local is newer
 282  0
                 versioning.setLastUpdated( v.getLastUpdated() );
 283  
             }
 284  
 
 285  0
             if ( v.getLastUpdated() == null || v.getLastUpdated().length() == 0 ||
 286  
                  versioning.getLastUpdated().compareTo( v.getLastUpdated() ) >= 0 )
 287  
             {
 288  0
                 changed = true;
 289  0
                 v.setLastUpdated( versioning.getLastUpdated() );
 290  
 
 291  0
                 if ( versioning.getRelease() != null )
 292  
                 {
 293  0
                     changed = true;
 294  0
                     v.setRelease( versioning.getRelease() );
 295  
                 }
 296  0
                 if ( versioning.getLatest() != null )
 297  
                 {
 298  0
                     changed = true;
 299  0
                     v.setLatest( versioning.getLatest() );
 300  
                 }
 301  
 
 302  0
                 Snapshot s = v.getSnapshot();
 303  0
                 Snapshot snapshot = versioning.getSnapshot();
 304  0
                 if ( snapshot != null )
 305  
                 {
 306  0
                     if ( s == null )
 307  
                     {
 308  0
                         s = new Snapshot();
 309  0
                         v.setSnapshot( s );
 310  0
                         changed = true;
 311  
                     }
 312  
 
 313  
                     // overwrite
 314  0
                     if ( s.getTimestamp() == null ? snapshot.getTimestamp() != null
 315  
                         : !s.getTimestamp().equals( snapshot.getTimestamp() ) )
 316  
                     {
 317  0
                         s.setTimestamp( snapshot.getTimestamp() );
 318  0
                         changed = true;
 319  
                     }
 320  0
                     if ( s.getBuildNumber() != snapshot.getBuildNumber() )
 321  
                     {
 322  0
                         s.setBuildNumber( snapshot.getBuildNumber() );
 323  0
                         changed = true;
 324  
                     }
 325  0
                     if ( s.isLocalCopy() != snapshot.isLocalCopy() )
 326  
                     {
 327  0
                         s.setLocalCopy( snapshot.isLocalCopy() );
 328  0
                         changed = true;
 329  
                     }
 330  
                 }
 331  
             }
 332  
         }
 333  0
         return changed;
 334  
     }
 335  
           
 336  
 }