Subversion Repositories DevTools

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
814 mhunt 1
package com.erggroup.buildtool.ripple;
2
 
3
import java.io.File;
4
 
5
import java.util.Iterator;
6
import java.util.Vector;
7
 
8
import org.apache.log4j.Logger;
9
 
10
public class Package
11
{
12
  /**name of package, must not contain spaces
13
   * @attribute
14
   */
15
  String mName = new String();
16
 
17
  /**package scope
18
   * @attribute
19
   */
20
  String mExtension = new String();
21
 
22
  /**instance identifier
23
   * @attribute
24
   */
25
  String mVersion = new String();
26
 
27
  /**unique identifier
28
   * for daemon builds = mName + mExtension
29
   * for escrow builds = mName + mVersion + mExtension
30
   * @attribute
31
   */
32
  String mAlias = new String();
33
 
34
  /**clearcase vob location, must not contain spaces
35
   * @attribute
36
   */
37
  String mLocation = new String();
38
 
39
  /**clearcase source file instance identifier
40
   * @attribute
41
   */
42
  String mLabel = new String();
43
 
44
  /**build standards
45
   * @attribute
46
   */
864 mhunt 47
  Vector<BuildStandard> mBuildStandardCollection = new Vector<BuildStandard>();
814 mhunt 48
 
49
  /**GBE_MACHTYPE used to build generic packages for this baseline
50
   * only has meaning in the daemon build, not the escrow build
51
   * accessed by BuildStandard::getPlatform, getBuildStandard
52
   * @attribute
53
   */
54
  public static final String mGenericMachtype = System.getenv("GBE_MACHTYPE");
55
 
56
  /**build dependencies by package alias
57
   * @attribute
58
   */
864 mhunt 59
  Vector<String> mDependencyCollection = new Vector<String>();
814 mhunt 60
 
61
  /**primary package version key pv_id in database
62
   * @attribute
63
   */
64
  int mId;
65
 
66
  /**indication of the nature of change
67
   * @attribute
68
   */
69
  Package.VersionNumberingStandard mChangeType = new VersionNumberingStandard();
70
 
71
  /**determines what field is rippled on a package version whose dependencies have changed
72
   * @attribute
73
   */
74
  Package.VersionNumberingStandard mRippleField = new VersionNumberingStandard();
75
 
76
  /**interested owners
77
   * @attribute
78
   */
864 mhunt 79
  private Vector<String> mBuildFailureEmailCollection = new Vector<String>();
814 mhunt 80
 
81
  /**when true will trigger unit tests as part of the package build phase in daemon mode
82
   * @attribute
83
   */
84
  boolean mHasAutomatedUnitTests = false;
85
 
86
  /**when true, do not ripple this package through packages which are dependent upon it in daemon mode
87
   * @attribute
88
   */
89
  boolean mAdvisoryRipple = false;
90
 
91
  /**determines the build file the package is built in, or not
92
   *  1 buildfile 1 etc
93
   *  0 not yet processed (initial value)
94
   * -1 not reproducible
95
   * -2 not reproducible on the build platforms configured for this release
96
   * -3 do not ripple
97
   * -4 directly dependent on package versions not in the baseline
98
   * -5 indirectly dependent on package versions which are not reproducible
99
   *    because of -1, -2 (escrow), -3 (daemon), -4
100
   * @attribute
101
   */
102
  int mBuildFile = 0;
103
 
104
  /**build dependencies by package
105
   * @attribute
106
   */
864 mhunt 107
  Vector<Package> mPackageDependencyCollection = new Vector<Package>();
814 mhunt 108
 
109
  /**used for escrow build purposes
110
   * set true when a package has been processed
111
   * @attribute
112
   */
113
  boolean mProcessed = false;
114
 
115
  /**set true for WIP package versions
116
   * only used in daemon mode
117
   * @attribute
118
   */
119
  boolean mDirectlyPlanned = false;
120
 
121
  /**set true when it is determined to be ripple built
122
   * @attribute
123
   */
124
  boolean mIndirectlyPlanned = false;
125
 
126
  /**build dependencies by pv_id (-1 or not used for planned dependencies)
127
   * @attribute
128
   */
864 mhunt 129
  Vector<Integer> mDependencyIDCollection = new Vector<Integer>();
814 mhunt 130
 
131
  /**unique pkg_id in the database
132
   * used for querying package version existence in the database in daemon mode
133
   * @attribute
134
   */
135
  int mPid;
136
 
874 mhunt 137
  /**maximum major number supported for determining ripple number
138
   * @attribute
139
   */
140
  int mMajorLimit;
141
 
142
  /**maximum minor number supported for determining ripple number
143
   * @attribute
144
   */
145
  int mMinorLimit;
146
 
147
  /**maximum patch number supported for determining ripple number
148
   * @attribute
149
   */
150
  int mPatchLimit;
151
 
152
  /**maximum build number number supported for determining ripple number
153
   * @attribute
154
   */
155
  int mBuildLimit;
156
 
814 mhunt 157
  /**Logger
158
   * @attribute
159
   */
160
  private static final Logger mLogger = Logger.getLogger(Package.class);
161
 
162
  /**dpkg archive location
163
   * @attribute
164
   */
165
  public static final String mGbeDpkg = System.getenv("GBE_DPKG");
166
 
167
  /**deploy archive location
168
   * @attribute
169
   */
170
  public static final String mGbeDply = System.getenv("GBE_DPLY");
171
 
172
  /**true if the package exists in the dpkg or deploy archive
173
   * @attribute
174
   */
175
  private boolean mArchivalExistence = true;
176
 
852 mhunt 177
  /**when true will trigger source control interaction eg labelling
178
   * @attribute
179
   */
180
  public boolean mRequiresSourceControlInteraction = true;
181
 
814 mhunt 182
  /**constructor
183
   */
184
  Package(int pv_id, String pkg_name, String v_ext, String alias, 
185
          String pkg_label, String src_path, char change_type)
186
  {
187
    mLogger.debug("Package 1: pv_id " + pv_id + " pkg_name " + pkg_name + " v_ext " + v_ext + " alias " + alias + " pkg_label " + pkg_label + " src_path " + src_path + " change_type " + change_type);
188
    mId = pv_id;
189
    mName = pkg_name;
190
    mVersion = "0.0.0000";
191
    mExtension = v_ext;
192
    mAlias = alias;
193
    mLabel = pkg_label;
194
    mLocation = src_path;
195
 
196
    if (change_type == 'M')
197
    {
198
      mChangeType.setMajor();
199
    }
200
    else if (change_type == 'N')
201
    {
202
      mChangeType.setMinor();
203
    }
204
    else
205
    {
206
      mChangeType.setPatch();
207
    }
208
  }
209
 
210
  /**constructor
211
   */
212
  Package(int pv_id, String pkg_name, String pkg_version, String v_ext, 
213
          String alias, String pkg_label, String src_path, 
214
          char ripple_field)
215
  {
216
    mLogger.debug("Package 2: pv_id " + pv_id + " pkg_name " + pkg_name + " pkg_version " + pkg_version + " v_ext " + v_ext + " alias " + alias + " pkg_label " + pkg_label + " src_path " + src_path + " ripple_field " + ripple_field);
217
    mId = pv_id;
218
    mName = pkg_name;
219
    mVersion = pkg_version;
220
    int endindex = mVersion.length() - v_ext.length();
221
 
222
    if ( endindex > 0 )
223
    {
224
      mVersion = mVersion.substring(0, endindex);
225
    }
226
 
227
    mExtension = v_ext;
228
    mAlias = alias;
229
    mLabel = pkg_label;
230
    mLocation = src_path;
231
 
874 mhunt 232
    // setBuild is the default
814 mhunt 233
    if (ripple_field == 'M')
234
    {
235
      mRippleField.setMajor();
236
    }
237
    else if (ripple_field == 'm')
238
    {
239
      mRippleField.setMinor();
240
    }
241
    else if (ripple_field == 'p')
242
    {
243
      mRippleField.setPatch();
244
    }
874 mhunt 245
    else if (ripple_field == 'L')
246
    {
247
      mRippleField.setLimit();
248
    }
814 mhunt 249
  }
250
 
251
  /**constructor
252
   */
253
  Package()
254
  {
255
    mLogger.debug("Package 3");
256
    mId = 0;
257
    mName = "null";
258
    mExtension = "null";
259
    mAlias = "null";
260
    mLabel = "null";
261
    mLocation = "null";
262
  }
263
 
874 mhunt 264
  /**constructor for unit test purposes
265
  */
266
  public Package(ReleaseManager rm, String version, int majorLimit, int minorLimit, int patchLimit, int buildNumberLimit)
267
  {
268
    mId = -1;
269
    mRippleField.setLimit();
270
    mVersion = version;
271
    mMajorLimit = majorLimit;
272
    mMinorLimit = minorLimit;
273
    mPatchLimit = patchLimit;
274
    mBuildLimit = buildNumberLimit;
275
    try
276
    {
277
      mId = applyPV( rm, 0 );
278
    }
279
    catch(Exception e)
280
    {
281
    }
282
  }
283
 
284
  /**accessor for unit test purposes
285
   */
286
  public int getId()
287
  {
288
    return mId;
289
  }
290
 
291
  /**accessor for unit test purposes
292
   */
293
  public String getVersion()
294
  {
295
    return mVersion;
296
  }
297
 
814 mhunt 298
  /**returns true if mBuildStandardCollection is not empty
299
   */
300
  boolean isReproducible()
301
  {
302
    mLogger.debug("isReproducible on Package " + mName);
303
    boolean retVal = false;
304
 
305
    if ( mBuildStandardCollection.size() > 0 )
306
    {
307
      retVal = true;
308
    }
309
 
310
    mLogger.info("isReproducible returned " + retVal);
311
    return retVal;
312
  }
313
 
314
  /**returns true if at least one of its BuildStandards has mWin32 or mGeneric true
315
   */
316
  boolean isWin32Built()
317
  {
318
    mLogger.debug("isWin32Built on Package " + mName);
319
    boolean retVal = false;
864 mhunt 320
    for (Iterator<BuildStandard> it = mBuildStandardCollection.iterator(); it.hasNext(); )
814 mhunt 321
    {
864 mhunt 322
      BuildStandard buildStandard = it.next();
814 mhunt 323
 
324
      if (buildStandard.getWin32() || buildStandard.getGeneric())
325
      {
326
        retVal = true;
327
        break;
328
      }
329
    }
330
 
331
    mLogger.info("isWin32Built returned " + retVal);
332
    return retVal;
333
  }
334
 
335
  /**returns true if at least one of its BuildStandards has mSolaris or mGeneric true
336
   */
337
  boolean isSolarisBuilt()
338
  {
339
    mLogger.debug("isSolarisBuilt on Package " + mName);
340
    boolean retVal = false;
864 mhunt 341
    for (Iterator<BuildStandard> it = mBuildStandardCollection.iterator(); it.hasNext(); )
814 mhunt 342
    {
864 mhunt 343
      BuildStandard buildStandard = it.next();
814 mhunt 344
 
345
      if (buildStandard.getSolaris() || buildStandard.getGeneric())
346
      {
347
        retVal = true;
348
        break;
349
      }
350
    }
351
 
352
    mLogger.info("isSolarisBuilt returned " + retVal);
353
    return retVal;
354
  }
355
 
356
  /**returns true if at least one of its BuildStandards has mLinux or mGeneric true
357
   */
358
  boolean isLinuxBuilt()
359
  {
360
    mLogger.debug("isLinuxBuilt on Package " + mName);
361
    boolean retVal = false;
864 mhunt 362
    for (Iterator<BuildStandard> it = mBuildStandardCollection.iterator(); it.hasNext(); )
814 mhunt 363
    {
864 mhunt 364
      BuildStandard buildStandard = it.next();
814 mhunt 365
 
366
      if (buildStandard.getLinux() || buildStandard.getGeneric())
367
      {
368
        retVal = true;
369
        break;
370
      }
371
    }
372
 
373
    mLogger.info("isLinuxBuilt returned " + retVal);
374
    return retVal;
375
  }
376
 
377
  /**returns true if at least one of its BuildStandards has mGeneric true
378
   */
379
  boolean isGeneric()
380
  {
381
    mLogger.debug("isGeneric on Package " + mName);
382
    boolean retVal = false;
864 mhunt 383
    for (Iterator<BuildStandard> it = mBuildStandardCollection.iterator(); it.hasNext(); )
814 mhunt 384
    {
864 mhunt 385
      BuildStandard buildStandard = it.next();
814 mhunt 386
 
387
      if (buildStandard.getGeneric())
388
      {
389
        retVal = true;
390
        break;
391
      }
392
    }
393
 
394
    mLogger.info("isGeneric returned " + retVal);
395
    return retVal;
396
  }
397
 
398
  /**applies the required version number change
874 mhunt 399
   * returns 0 on success
400
   *         1 on cannot work with non standard versioning
401
   *         2 on ripple field limitations prevent a ripple build
814 mhunt 402
   */
874 mhunt 403
  int applyPV(ReleaseManager releaseManager, int rtag_id) throws Exception
814 mhunt 404
  {
405
    mLogger.debug("applyPV on Package " + mName);
406
    // three scenarios, only applyPV for 2 of them
407
    // WIP exists:                      mDirectlyPlanned == true;   mIndirectlyPlanned == true; mArchivalExistence don't care - applyPV
408
    // Package version is out of date:  mDirectlyPlanned == false;  mIndirectlyPlanned == true; mArchivalExistence == true    - applyPV
409
    // Package version does not exist:  mDirectlyPlanned == false;  mIndirectlyPlanned == true; mArchivalExistence == false   - do not applyPV
410
    if ( !mDirectlyPlanned && mIndirectlyPlanned && !mArchivalExistence )
411
    {
412
      // the package has an mIndirectlyPlanned flag set true in daemon mode because the package does not exist in an archive
413
      // do not apply a different package version
414
      mLogger.info("applyPV !mDirectlyPlanned && mIndirectlyPlanned && !mArchivalExistence on Package " + mName);
836 mhunt 415
      releaseManager.claimVersion(mPid, mVersion + mExtension, rtag_id);
874 mhunt 416
      mLogger.info("applyPv returned 0");
417
      return 0;
814 mhunt 418
    }
419
 
892 mhunt 420
    MutableInt major = new MutableInt();
421
    major.value = 0;
422
    MutableInt minor = new MutableInt();
423
    minor.value = 0;
424
    MutableInt patch = new MutableInt();
425
    patch.value = 1000;
814 mhunt 426
 
427
    String field[] = mVersion.split("\\D");
888 mhunt 428
    String nonStandardCotsVersion = "";
429
 
814 mhunt 430
    if ( field.length == 3 )
431
    {
892 mhunt 432
      major.value = Integer.parseInt(field[0]);
433
      minor.value = Integer.parseInt(field[1]);
434
      patch.value = Integer.parseInt(field[2]);
814 mhunt 435
    }
436
    else
437
    {
888 mhunt 438
      if ( !mChangeType.mMajor &&
439
           !mChangeType.mMinor &&
440
           !mChangeType.mPatch &&
441
           mRippleField.mBuild &&
442
           mExtension.compareTo(".cots") == 0 &&
443
           field.length > 0 )
444
      {
445
        // DEVI 52782
446
        // allow and work with (ripple build) versions a.b.c.d....xxxx
447
        // where xxxx.length > 3
448
        String patchStr = field[field.length - 1];
449
        int patchLen = patchStr.length();
450
 
451
        // check patchStr is the last (at least 4) digits
452
        if ( patchLen > 3 && mVersion.substring( mVersion.length() - patchLen, mVersion.length() ).compareTo(patchStr) == 0 )
453
        {
892 mhunt 454
          patch.value = Integer.parseInt(patchStr);
888 mhunt 455
          nonStandardCotsVersion = mVersion.substring(0, mVersion.length() - patchLen );
456
        }
457
      }
458
 
459
      if ( nonStandardCotsVersion.length() == 0 )
460
      {
461
        // cannot work with non standard versioning
462
        mLogger.error("applyPV cannot work with non standard versioning");
463
        mLogger.info("applyPv returned 1");
464
        return 1;
465
      }
814 mhunt 466
    }
467
 
888 mhunt 468
    if ( nonStandardCotsVersion.length() == 0 &&
892 mhunt 469
         patch.value < 1000 && 
888 mhunt 470
         field[2].substring(0, 1).compareTo("0") != 0 )
814 mhunt 471
    {
472
      mLogger.info("applyPV accomodate old style mVersion of the form 1.0.1");
892 mhunt 473
      patch.value = patch.value * 1000;
814 mhunt 474
    }
475
 
476
    // mChangeType overrides mRippleField
477
    do
478
    {
479
      if ( mChangeType.mMajor )
480
      {
892 mhunt 481
        if ( !incrementFieldsAccordingToLimits(4, major, minor, patch) )
482
        {
483
          mLogger.info("applyPv returned 2");
484
          return 2;
485
        }
814 mhunt 486
      }
487
      else if ( mChangeType.mMinor )
488
      {
892 mhunt 489
        if ( !incrementFieldsAccordingToLimits(3, major, minor, patch) )
490
        {
491
          mLogger.info("applyPv returned 2");
492
          return 2;
493
        }
814 mhunt 494
      }
495
      else if ( mChangeType.mPatch )
496
      {
892 mhunt 497
        if ( !incrementFieldsAccordingToLimits(2, major, minor, patch) )
814 mhunt 498
        {
892 mhunt 499
          mLogger.info("applyPv returned 2");
500
          return 2;
501
        }
814 mhunt 502
      }
503
      else
504
      {
505
        if ( mRippleField.mMajor )
506
        {
892 mhunt 507
          major.value++;
508
          mLogger.info("applyPV mRippleField.mMajor " + major.value);
509
          minor.value = 0;
510
          patch.value = 0;
814 mhunt 511
        }
512
        else if ( mRippleField.mMinor )
513
        {
892 mhunt 514
          minor.value++;
515
          mLogger.info("applyPV mRippleField.mMinor " + minor.value);
516
          patch.value = 0;
814 mhunt 517
        }
518
        else if ( mRippleField.mPatch )
519
        {
520
          do
521
          {
892 mhunt 522
            patch.value++;
523
          } while ( ( patch.value / 1000 ) * 1000 != patch.value );
524
          mLogger.info("applyPV mRippleField.mPatch " + patch.value);
814 mhunt 525
        }
874 mhunt 526
        else if ( mRippleField.mBuild )
814 mhunt 527
        {
892 mhunt 528
          patch.value++;
529
          mLogger.info("applyPV mRippleField.mBuild " + patch.value);
814 mhunt 530
        }
874 mhunt 531
        else
532
        {
892 mhunt 533
          if ( !incrementFieldsAccordingToLimits(1, major, minor, patch) )
874 mhunt 534
          {
535
            mLogger.info("applyPv returned 2");
536
            return 2;
537
          }
538
        }
814 mhunt 539
      }
888 mhunt 540
 
541
      if ( nonStandardCotsVersion.length() == 0 )
542
      {
892 mhunt 543
        mVersion = String.valueOf(major.value) + "." + String.valueOf(minor.value) + ".";
888 mhunt 544
      }
545
      else
546
      {
547
        mVersion = nonStandardCotsVersion;
548
      }
814 mhunt 549
 
892 mhunt 550
      if ( patch.value < 10 )
814 mhunt 551
      {
552
        mVersion += "000";
553
      }
892 mhunt 554
      else if ( patch.value < 100 )
814 mhunt 555
      {
556
        mVersion += "00";
557
      }
892 mhunt 558
      else if ( patch.value < 1000 )
814 mhunt 559
      {
560
        mVersion += "0";
561
      }
562
 
892 mhunt 563
      mVersion += String.valueOf(patch.value);
814 mhunt 564
    } while ( exists(releaseManager, rtag_id) );
565
 
566
    releaseManager.claimVersion(mPid, mVersion + mExtension, rtag_id);
874 mhunt 567
    mLogger.info("applyPv returned 0");
568
    return 0;
814 mhunt 569
  }
570
 
892 mhunt 571
  /**increments fields according to mRippleField.mLimit if necessary
572
   * will apply it to the field passed as follows
573
   * 1 = build
574
   * 2 = patch
575
   * 3 = minor
576
   * other = major
577
   * returns true on success
578
   *         false on ripple field limitations prevent a ripple build
579
   */
580
  private boolean incrementFieldsAccordingToLimits(int field, MutableInt major, MutableInt minor, MutableInt patch)
581
  {
582
    boolean retVal = true;
583
 
584
    if (!mRippleField.mLimit)
585
    {
586
      // simple case
587
      // no need to take field limits into consideration
588
      switch (field)
589
      {
590
      case 1:
591
        // unreachable
592
        // the only scenario involving build number manipulation involves the mRippleField.mLimit being set
593
        retVal = false;
594
        break;
595
      case 2:
596
        do
597
        {
598
          patch.value++;
599
        } while ( ( patch.value / 1000 ) * 1000 != patch.value );
600
        mLogger.info("incrementFieldsAccordingToLimits patch " + patch.value);
601
        break;
602
      case 3:
603
        minor.value++;
604
        mLogger.info("incrementFieldsAccordingToLimits minor " + minor.value);
605
        patch.value = 0;
606
        break;
607
      default:
608
        major.value++;
609
        mLogger.info("incrementFieldsAccordingToLimits major " + major.value);
610
        minor.value = 0;
611
        patch.value = 0;
612
      }
613
    }
614
    else
615
    {
616
      // take field limits into consideration
617
      boolean changeOccurred = false;
618
      boolean incrementField = true;
619
 
620
      switch (field)
621
      {
622
      case 1:
623
        if ( mBuildLimit != 0 )
624
        {
625
          // increment or reset the patch build number
626
          int buildNumber = patch.value - (patch.value/1000) * 1000;
627
 
628
          if ( buildNumber < mBuildLimit )
629
          {
630
            // can increment the patch build number
631
            patch.value++;
632
            mLogger.info("incrementFieldsAccordingToLimits mRippleField.mLimit build number " + patch.value);
633
            changeOccurred = true;
634
            incrementField = false;
635
          }
636
          else
637
          {
638
            if ( mPatchLimit == 0 )
639
            {
640
              // reset the patch number and patch build number
641
              patch.value = 0;
642
            }
643
          }
644
        }
645
        // no break by design
646
      case 2:
647
        if ( mPatchLimit != 0 && incrementField )
648
        {
649
          // increment or reset the patch number
650
          if ( ( patch.value / 1000 ) < mPatchLimit )
651
          {
652
            do
653
            {
654
              patch.value++;
655
            } while ( ( patch.value / 1000 ) * 1000 != patch.value );
656
 
657
            mLogger.info("incrementFieldsAccordingToLimits mRippleField.mLimit patch " + patch.value);
658
            changeOccurred = true;
659
            incrementField = false;
660
          }
661
          else
662
          {
663
            // reset the patch number and patch build number
664
            patch.value = 0;
665
          }
666
        }
667
        // no break by design
668
      case 3:
669
        if ( mMinorLimit != 0 && incrementField )
670
        {
671
          // increment or reset the minor number
672
          if ( minor.value < mMinorLimit )
673
          {
674
            minor.value++;
675
            patch.value = 0;
676
            mLogger.info("incrementFieldsAccordingToLimits mRippleField.mLimit minor " + minor.value);
677
            changeOccurred = true;
678
            incrementField = false;
679
          }
680
          else
681
          {
682
            // reset the minor number
683
            minor.value = 0;
684
          }
685
        }
686
        // no break by design
687
      default:
688
        if ( mMajorLimit != 0 && incrementField )
689
        {
690
          // increment or reset the major number
691
          if ( major.value < mMajorLimit )
692
          {
693
            // increment the major number
694
            changeOccurred = true;
695
            major.value++;
696
            minor.value = 0;
697
            patch.value = 0;
698
            mLogger.info("incrementFieldsAccordingToLimits mRippleField.mLimit major " + major.value);
699
          }
700
        }
701
      }
702
 
703
      if ( !changeOccurred )
704
      {
705
        // unable to increment a field due to field limitations
706
        mLogger.error("incrementFieldsAccordingToLimits ripple field limitations prevent a ripple build");
707
        mLogger.info("incrementFieldsAccordingToLimits returned false");
708
        retVal = false;
709
      }
710
    }
711
 
712
    return retVal;
713
  }
714
 
814 mhunt 715
  /**returns true if the version exists in the dpkg_archive, deploy_archive or release manager database
716
   * claims the version in the release manager database
717
   */
718
  private boolean exists(ReleaseManager releaseManager, int rtag_id) throws Exception
719
  {
720
    mLogger.debug("exists 1 on Package " + mName + " version " + mVersion + " extension " + mExtension);
721
    boolean retVal = false;
722
 
864 mhunt 723
    if ( !ReleaseManager.mUseDatabase )
814 mhunt 724
    {
725
      mLogger.info("exists 1 !releaseManager.mUseDatabase");
726
    }
727
    else
728
    {
729
      retVal = exists();
730
 
731
      if ( !retVal )
732
      {
733
        String pkg_version = new String(mVersion);
734
 
735
        if ( mExtension.length() > 0 )
736
        {
737
          pkg_version += mExtension;
738
        }
739
 
740
        retVal = releaseManager.queryPackageVersions(mPid, pkg_version);
741
      }
742
    }
743
 
744
    mLogger.info("exists 1 returned " + retVal);
745
    return retVal;
746
  }
747
 
748
  /**returns true if the version exists in the dpkg_archive or deploy_archive
749
   */
750
  boolean exists()
751
    throws Exception
752
  {
753
    mLogger.debug("exists 2 on Package " + mName);
754
    boolean retVal = false;
755
 
756
    String Release = mGbeDpkg;
757
    String Deploy = mGbeDply;
758
 
759
    if (Release == null || Deploy == null)
760
    {
868 mhunt 761
      mLogger.fatal("exists 2 Release == null || Deploy == null");
762
      throw new Exception("exists 2 Release == null || Deploy == null");
814 mhunt 763
    }
764
 
765
    String fs = System.getProperty( "file.separator" );
766
    String name = new String(Release);
767
    name += fs + mName + fs + mVersion + mExtension;
768
    File release = new File(name);
769
 
770
    if (release.exists())
771
    {
772
      mLogger.info("exists 2 release.exists()");
773
      retVal = true;
774
    }
775
 
776
    if (!retVal && (Release != Deploy))
777
    {
778
      name = Deploy + fs + mName + fs + mVersion + mExtension;
779
 
780
      File deploy = new File(name);
781
 
782
      if (deploy.exists())
783
      {
784
        mLogger.info("exists 2 deploy.exists()");
785
        retVal = true;
786
      }
787
    }
788
 
789
    mArchivalExistence = retVal;
790
    mLogger.info("exists 2 returned " + retVal);
791
    return retVal;
792
  }
854 mhunt 793
 
794
  /**returns email information
795
   */
796
  String emailInfo( String lf )
797
  {
798
    String retVal = new String();
799
 
864 mhunt 800
    for (Iterator<String> it = mBuildFailureEmailCollection.iterator(); it.hasNext(); )
854 mhunt 801
    {
864 mhunt 802
      String email = it.next();
854 mhunt 803
      retVal +=
804
      "  <owner email=\"" + email +"\"/>" + lf;
805
    }
806
 
807
    return retVal;
808
  }
814 mhunt 809
 
866 mhunt 810
  /**returns email information
811
   */
812
  String emailInfoNonAntTask()
813
  {
814
    String retVal = null;
815
 
816
    for (Iterator<String> it = mBuildFailureEmailCollection.iterator(); it.hasNext(); )
817
    {
818
      String email = it.next();
819
 
820
      if ( retVal == null )
821
      {
822
        retVal = new String();
823
      }
824
      else
825
      {
826
        retVal += ",";
827
      }
828
      retVal += email;
829
    }
830
 
831
    return retVal;
832
  }
833
 
864 mhunt 834
  /**adds email to mBuildFailureEmailCollection if unique
835
   */
836
  void addEmail( String email )
837
  {
838
    boolean alreadyExists = false;
839
 
840
    for (Iterator<String> it = mBuildFailureEmailCollection.iterator(); it.hasNext(); )
841
    {
842
      String existingEmail = it.next();
843
 
844
      if ( existingEmail.compareTo(email) == 0 )
845
      {
846
        alreadyExists = true;
847
        break;
848
      }
849
    }
850
 
851
    if ( !alreadyExists )
852
    {
853
      mBuildFailureEmailCollection.add(email);
854
    }
855
  }
856
 
814 mhunt 857
  /**entity class supporting the ERG version numbering standard:
858
   * <major>.<minor>.<patch/build>
859
   * patch/build is at least a 4 digit number whose last 3 digits represent the build
860
   */
861
  public class VersionNumberingStandard
862
  {
863
    /**in terms of the mChangeType Package field,
864
     * when true indicates the contract of the package has changed in a non backwardly compatible manner
865
     * in terms of the mRippleField Package field,
866
     * when true indicates the major version number will be incremented
867
     * @attribute
868
     */
869
    private boolean mMajor = false;
870
 
871
    /**in terms of the mChangeType Package field,
872
     * when true indicates the contract of the package has changed in a backwardly compatible manner
873
     * in terms of the mRippleField Package field,
874
     * when true indicates the minor version number will be incremented
875
     * @attribute
876
     */
877
    private boolean mMinor = false;
878
 
879
    /**in terms of the mChangeType Package field,
880
     * when true indicates the contract of the package has not changed, but the package has changed internally
881
     * in terms of the mRippleField Package field,
882
     * when true indicates the minor version number will be incremented
883
     * @attribute
884
     */
885
    private boolean mPatch = false;
886
 
887
    /**in terms of the mChangeType Package field,
888
     * when true indicates the package has not changed, its dependencies potentially have
889
     * in terms of the mRippleField Package field,
890
     * when true indicates the build number will be incremented
891
     * @attribute
892
     */
893
    private boolean mBuild = true;
894
 
874 mhunt 895
    /**in terms of the mChangeType Package field,
896
     * always false, does not apply
897
     * in terms of the mRippleField Package field,
898
     * when true indicates the major, minor, patch and build number will be incremented according to field limits
899
     * @attribute
900
     */
901
    private boolean mLimit = false;
902
 
814 mhunt 903
    /**constructor
904
     */
905
    private VersionNumberingStandard()
906
    {
907
      mLogger.debug("VersionNumberingStandard");
908
    }
909
 
874 mhunt 910
    /**sets mBuild true, mMajor false, mMinor false, mPatch false, mLimit false
814 mhunt 911
     */
912
    void setBuild()
913
    {
914
      mLogger.debug("setBuild");
915
      mBuild = true;
916
      mMajor = false;
917
      mMinor = false;
918
      mPatch = false;
874 mhunt 919
      mLimit = false;
814 mhunt 920
    }
921
 
874 mhunt 922
    /**sets mBuild false, mMajor true, mMinor false, mPatch false, mLimit false
814 mhunt 923
     */
924
    void setMajor()
925
    {
926
      mLogger.debug("setMajor");
927
      mBuild = false;
928
      mMajor = true;
929
      mMinor = false;
930
      mPatch = false;
874 mhunt 931
      mLimit = false;
814 mhunt 932
    }
933
 
874 mhunt 934
    /**sets mBuild false, mMajor false, mMinor true, mPatch false, mLimit false
814 mhunt 935
     */
936
    void setMinor()
937
    {
938
      mLogger.debug("setMinor");
939
      mBuild = false;
940
      mMajor = false;
941
      mMinor = true;
942
      mPatch = false;
874 mhunt 943
      mLimit = false;
814 mhunt 944
    }
945
 
874 mhunt 946
    /**sets mBuild false, mMajor false, mMinor false, mPatch true, mLimit false
814 mhunt 947
     */
948
    void setPatch()
949
    {
950
      mLogger.debug("setPatch");
951
      mBuild = false;
952
      mMajor = false;
953
      mMinor = false;
954
      mPatch = true;
874 mhunt 955
      mLimit = false;
814 mhunt 956
    }
957
 
874 mhunt 958
    /**sets mBuild false, mMajor false, mMinor false, mPatch false, mLimit true
959
     */
960
    void setLimit()
961
    {
962
      mLogger.debug("setPatch");
963
      mBuild = false;
964
      mMajor = false;
965
      mMinor = false;
966
      mPatch = false;
967
      mLimit = true;
968
    }
969
 
814 mhunt 970
  }
971
 
972
}