001 /* 002 =================== DO NOT EDIT THIS FILE ==================== 003 Generated by Modello 1.4.1 on 2013-02-24 03:31:03, 004 any modifications will be overwritten. 005 ============================================================== 006 */ 007 008 package org.apache.maven.artifact.repository.metadata; 009 010 /** 011 * Class Metadata. 012 * 013 * @version $Revision$ $Date$ 014 */ 015 @SuppressWarnings( "all" ) 016 public class Metadata 017 implements java.io.Serializable, java.lang.Cloneable 018 { 019 020 //--------------------------/ 021 //- Class/Member Variables -/ 022 //--------------------------/ 023 024 /** 025 * The version of the underlying metadata model. 026 */ 027 private String modelVersion; 028 029 /** 030 * The groupId that is directory represents, if any. 031 */ 032 private String groupId; 033 034 /** 035 * The artifactId that is directory represents, if any. 036 */ 037 private String artifactId; 038 039 /** 040 * The version that is directory represents, if any. 041 */ 042 private String version; 043 044 /** 045 * Versioning information for the artifact. 046 */ 047 private Versioning versioning; 048 049 /** 050 * Field plugins. 051 */ 052 private java.util.List<Plugin> plugins; 053 054 /** 055 * Field modelEncoding. 056 */ 057 private String modelEncoding = "UTF-8"; 058 059 060 //-----------/ 061 //- Methods -/ 062 //-----------/ 063 064 /** 065 * Method addPlugin. 066 * 067 * @param plugin 068 */ 069 public void addPlugin( Plugin plugin ) 070 { 071 getPlugins().add( plugin ); 072 } //-- void addPlugin( Plugin ) 073 074 /** 075 * Method clone. 076 * 077 * @return Metadata 078 */ 079 public Metadata clone() 080 { 081 try 082 { 083 Metadata copy = (Metadata) super.clone(); 084 085 if ( this.versioning != null ) 086 { 087 copy.versioning = (Versioning) this.versioning.clone(); 088 } 089 090 if ( this.plugins != null ) 091 { 092 copy.plugins = new java.util.ArrayList<Plugin>(); 093 for ( Plugin item : this.plugins ) 094 { 095 copy.plugins.add( ( (Plugin) item).clone() ); 096 } 097 } 098 099 return copy; 100 } 101 catch ( java.lang.Exception ex ) 102 { 103 throw (java.lang.RuntimeException) new java.lang.UnsupportedOperationException( getClass().getName() 104 + " does not support clone()" ).initCause( ex ); 105 } 106 } //-- Metadata clone() 107 108 /** 109 * Get the artifactId that is directory represents, if any. 110 * 111 * @return String 112 */ 113 public String getArtifactId() 114 { 115 return this.artifactId; 116 } //-- String getArtifactId() 117 118 /** 119 * Get the groupId that is directory represents, if any. 120 * 121 * @return String 122 */ 123 public String getGroupId() 124 { 125 return this.groupId; 126 } //-- String getGroupId() 127 128 /** 129 * Get the modelEncoding field. 130 * 131 * @return String 132 */ 133 public String getModelEncoding() 134 { 135 return this.modelEncoding; 136 } //-- String getModelEncoding() 137 138 /** 139 * Get the version of the underlying metadata model. 140 * 141 * @return String 142 */ 143 public String getModelVersion() 144 { 145 return this.modelVersion; 146 } //-- String getModelVersion() 147 148 /** 149 * Method getPlugins. 150 * 151 * @return List 152 */ 153 public java.util.List<Plugin> getPlugins() 154 { 155 if ( this.plugins == null ) 156 { 157 this.plugins = new java.util.ArrayList<Plugin>(); 158 } 159 160 return this.plugins; 161 } //-- java.util.List<Plugin> getPlugins() 162 163 /** 164 * Get the version that is directory represents, if any. 165 * 166 * @return String 167 */ 168 public String getVersion() 169 { 170 return this.version; 171 } //-- String getVersion() 172 173 /** 174 * Get versioning information for the artifact. 175 * 176 * @return Versioning 177 */ 178 public Versioning getVersioning() 179 { 180 return this.versioning; 181 } //-- Versioning getVersioning() 182 183 /** 184 * Method removePlugin. 185 * 186 * @param plugin 187 */ 188 public void removePlugin( Plugin plugin ) 189 { 190 getPlugins().remove( plugin ); 191 } //-- void removePlugin( Plugin ) 192 193 /** 194 * Set the artifactId that is directory represents, if any. 195 * 196 * @param artifactId 197 */ 198 public void setArtifactId( String artifactId ) 199 { 200 this.artifactId = artifactId; 201 } //-- void setArtifactId( String ) 202 203 /** 204 * Set the groupId that is directory represents, if any. 205 * 206 * @param groupId 207 */ 208 public void setGroupId( String groupId ) 209 { 210 this.groupId = groupId; 211 } //-- void setGroupId( String ) 212 213 /** 214 * Set the modelEncoding field. 215 * 216 * @param modelEncoding 217 */ 218 public void setModelEncoding( String modelEncoding ) 219 { 220 this.modelEncoding = modelEncoding; 221 } //-- void setModelEncoding( String ) 222 223 /** 224 * Set the version of the underlying metadata model. 225 * 226 * @param modelVersion 227 */ 228 public void setModelVersion( String modelVersion ) 229 { 230 this.modelVersion = modelVersion; 231 } //-- void setModelVersion( String ) 232 233 /** 234 * Set the set of plugin mappings for the group. 235 * 236 * @param plugins 237 */ 238 public void setPlugins( java.util.List<Plugin> plugins ) 239 { 240 this.plugins = plugins; 241 } //-- void setPlugins( java.util.List ) 242 243 /** 244 * Set the version that is directory represents, if any. 245 * 246 * @param version 247 */ 248 public void setVersion( String version ) 249 { 250 this.version = version; 251 } //-- void setVersion( String ) 252 253 /** 254 * Set versioning information for the artifact. 255 * 256 * @param versioning 257 */ 258 public void setVersioning( Versioning versioning ) 259 { 260 this.versioning = versioning; 261 } //-- void setVersioning( Versioning ) 262 263 264 public boolean merge( Metadata sourceMetadata ) 265 { 266 boolean changed = false; 267 268 for ( Plugin plugin : sourceMetadata.getPlugins() ) 269 { 270 boolean found = false; 271 272 for ( Plugin preExisting : getPlugins() ) 273 { 274 if ( preExisting.getPrefix().equals( plugin.getPrefix() ) ) 275 { 276 found = true; 277 break; 278 } 279 } 280 281 if ( !found ) 282 { 283 Plugin mappedPlugin = new Plugin(); 284 285 mappedPlugin.setArtifactId( plugin.getArtifactId() ); 286 287 mappedPlugin.setPrefix( plugin.getPrefix() ); 288 289 mappedPlugin.setName( plugin.getName() ); 290 291 addPlugin( mappedPlugin ); 292 293 changed = true; 294 } 295 } 296 297 Versioning versioning = sourceMetadata.getVersioning(); 298 if ( versioning != null ) 299 { 300 Versioning v = getVersioning(); 301 if ( v == null ) 302 { 303 v = new Versioning(); 304 setVersioning( v ); 305 changed = true; 306 } 307 308 for ( String version : versioning.getVersions() ) 309 { 310 if ( !v.getVersions().contains( version ) ) 311 { 312 changed = true; 313 v.getVersions().add( version ); 314 } 315 } 316 317 if ( "null".equals( versioning.getLastUpdated() ) ) 318 { 319 versioning.setLastUpdated( null ); 320 } 321 322 if ( "null".equals( v.getLastUpdated() ) ) 323 { 324 v.setLastUpdated( null ); 325 } 326 327 if ( versioning.getLastUpdated() == null || versioning.getLastUpdated().length() == 0 ) 328 { 329 // this should only be for historical reasons - we assume local is newer 330 versioning.setLastUpdated( v.getLastUpdated() ); 331 } 332 333 if ( v.getLastUpdated() == null || v.getLastUpdated().length() == 0 334 || versioning.getLastUpdated().compareTo( v.getLastUpdated() ) >= 0 ) 335 { 336 changed = true; 337 v.setLastUpdated( versioning.getLastUpdated() ); 338 339 if ( versioning.getRelease() != null ) 340 { 341 changed = true; 342 v.setRelease( versioning.getRelease() ); 343 } 344 if ( versioning.getLatest() != null ) 345 { 346 changed = true; 347 v.setLatest( versioning.getLatest() ); 348 } 349 350 Snapshot s = v.getSnapshot(); 351 Snapshot snapshot = versioning.getSnapshot(); 352 if ( snapshot != null ) 353 { 354 if ( s == null ) 355 { 356 s = new Snapshot(); 357 v.setSnapshot( s ); 358 changed = true; 359 } 360 361 // overwrite 362 if ( s.getTimestamp() == null ? snapshot.getTimestamp() != null 363 : !s.getTimestamp().equals( snapshot.getTimestamp() ) ) 364 { 365 s.setTimestamp( snapshot.getTimestamp() ); 366 changed = true; 367 } 368 if ( s.getBuildNumber() != snapshot.getBuildNumber() ) 369 { 370 s.setBuildNumber( snapshot.getBuildNumber() ); 371 changed = true; 372 } 373 if ( s.isLocalCopy() != snapshot.isLocalCopy() ) 374 { 375 s.setLocalCopy( snapshot.isLocalCopy() ); 376 changed = true; 377 } 378 } 379 } 380 } 381 return changed; 382 } 383 384 }