Subversion Repositories DevTools

Rev

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.io.FileOutputStream;
6
 
7
import java.io.FileWriter;
8
 
9
import java.sql.SQLException;
10
 
11
import java.util.Iterator;
12
import java.util.Vector;
13
 
14
import org.apache.log4j.Logger;
15
 
16
/**Plans release impact by generating a set of Strings containing build file content.
17
 */
18
public class RippleEngine
19
{
20
  /**collection of gbemachtypes in String form associated with the baseline
21
   * limited to the following items "win32", "sparc", "solaris10_sparc32", "solaris10_x86", "linux_i386"
22
   * accessed by Package::isLinuxBuilt, isSolarisBuilt, isWin32Built
23
   * @attribute
24
   */
25
  Vector mGbeMachtypeCollection = new Vector();
26
 
27
  /**configured mail server
28
   * @attribute
29
   */
30
  String mMailServer = new String();
31
 
32
  /**configured mail sender user
33
   * @attribute
34
   */
35
  String mMailSender = new String();
36
 
37
  /**name associated with the baseline
38
   * @attribute
39
   */
40
  String mBaselineName = new String();
41
 
42
  /**collection of released pv_ids associated with the release
43
   * @attribute
44
   */
45
  Vector mReleasedPvIDCollection = new Vector();
46
 
47
  /**timestamp associated with build file generation
48
   * @attribute
49
   */
50
  long mTimestamp = 0;
51
 
52
  /**set to "non generic", "generic" or "dummy" to indicate the nature of the package in the build file in daemon mode
53
   * @attribute
54
   */
55
  String mAddendum = new String("dummy");
56
 
57
  /**Logger
58
   * @attribute
59
   */
60
  private static final Logger mLogger = Logger.getLogger(RippleEngine.class);
61
 
62
  /**collection of escrow clearcase support file content in String form, win32_set_up etc
63
   * @attribute
64
   */
65
  private Vector mEscrowClearcaseSupportCollection = new Vector();
66
 
67
  /**package versions representing the baseline
68
   * @aggregation shared
69
   * @attribute
70
   */
71
  private Vector mPackageCollection = new Vector();
72
 
73
  /**index to current String item
74
   * @attribute
75
   */
76
  private int mBuildIndex;
77
 
78
  /**Database abstraction
79
   * @attribute
80
   */
81
  private ReleaseManager mReleaseManager;
82
 
83
  /**Baseline identifier (rtag_id for a release manager baseline, bom_id for deployment manager baseline)
84
   * @attribute
85
   */
86
  private int mBaseline;
87
 
88
  /**When true, mBuildCollection contains one item based on a release manager rtag_id and contains a daemon property
89
   * When false, mBuildCollection contains at least one item based on a deployment manager bom_id
90
   * Will be accessed by the Package class to calculate its mAlias
91
   * @attribute
92
   */
93
  boolean mDaemon;
94
 
95
  /**collection of build file content in String form
96
   * @attribute
97
   */
98
  private Vector mBuildCollection = new Vector();
99
 
100
  /**constructor
101
   */
102
  public RippleEngine(ReleaseManager releaseManager, int rtag_id, 
103
                      boolean isDaemon)
104
  {
105
    mLogger.debug("RippleEngine rtag_id " + rtag_id + " isDaemon " + isDaemon);
106
    mReleaseManager = releaseManager;
107
    mBaseline = rtag_id;
108
    mDaemon = isDaemon;
109
  }
110
 
111
  /**discards all build file content
112
   * plans new build file content
113
   */
114
  public void planRelease() throws SQLException, Exception
115
  {
116
    mLogger.warn("planRelease mDaemon " + mDaemon);
117
    mAddendum = "dummy";
118
    mBuildCollection.removeAllElements();
119
    mPackageCollection.removeAllElements();
120
    mReleasedPvIDCollection.removeAllElements();
121
 
122
    if ( !mDaemon )
123
    {
124
      mEscrowClearcaseSupportCollection.removeAllElements();  
125
    }
126
 
127
    mReleaseManager.connect();
128
 
129
    if ( mDaemon )
130
    {
131
      // claim the mutex
132
      mReleaseManager.claimMutex();
133
    }
134
 
135
    collectMetaData();
136
 
137
    mReleaseManager.queryPackageVersions(this, mPackageCollection, mDaemon, mBaseline);
138
 
139
    // set up mPackageDependencyCollection
140
    for (Iterator it = mPackageCollection.iterator(); it.hasNext(); )
141
    {
142
      Package p = (Package) it.next();
143
 
144
      for (Iterator it2 = p.mDependencyCollection.iterator(); it2.hasNext(); )
145
      {
146
        String alias = (String) it2.next();
147
        Package dependency = findPackage(alias);
148
 
149
        if (dependency == ReleaseManager.NULL_PACKAGE)
150
        {
151
          mLogger.info("planRelease dependency is not in the baseline " + alias);
152
          // exclude all dependent packages
153
          rippleBuildExclude(p);
154
 
155
          // take the package out of the build
156
          p.mBuildFile = -4;
157
          break;
158
        }
159
 
160
        p.mPackageDependencyCollection.add(dependency);
161
      }
162
    }
163
 
164
    // process packages which are not reproducible, and all packages dependent upon them      
165
    for (Iterator it = mPackageCollection.iterator(); it.hasNext(); )
166
    {
167
      Package p = (Package) it.next();
168
 
169
      if (p.mBuildFile == 0)
170
      {
171
        // package has yet to be processed
172
        if (!p.isReproducible())
173
        {
174
          if ( !mDaemon )
175
          {
176
            // for escrow build purposes, exclude all dependent package versions
177
            mLogger.info("planRelease package not reproducible " + p.mName);
178
            rippleBuildExclude(p);
179
          }
180
 
181
          // package is not reproducible, discard
182
          p.mBuildFile = -1;
183
        }
184
      }
185
    }
186
 
187
    // process packages which are not reproducible on the build platforms configured for this baseline
188
    for (Iterator it = mPackageCollection.iterator(); it.hasNext(); )
189
    {
190
      Package p = (Package) it.next();
191
 
192
      if (p.mBuildFile == 0)
193
      {
194
        // package has yet to be processed
195
        {
196
          // assume it does not need to be reproduced for this baseline
197
          p.mBuildFile = -1;
198
 
199
          for (Iterator it2 = mGbeMachtypeCollection.iterator(); it2.hasNext(); )
200
          {
201
            String machtype = (String) it2.next();
202
 
203
            if ( machtype.compareTo("linux_i386") == 0 )
204
            {
205
              if ( p.isLinuxBuilt() )
206
              {
207
                p.mBuildFile = 0;
208
                break;
209
              }
210
            }
211
            else if ( machtype.compareTo("win32") == 0 )
212
            {
213
              if ( p.isWin32Built() )
214
              {
215
                p.mBuildFile = 0;
216
                break;
217
              }
218
            }
219
            else if ( machtype.compareTo("sparc") == 0
220
                   || machtype.compareTo("solaris10_x86") == 0
221
                   || machtype.compareTo("solaris10_sparc32") == 0 )
222
            {
223
              if ( p.isSolarisBuilt() )
224
              {
225
                p.mBuildFile = 0;
226
                break;
227
              }
228
            }
229
          }
230
 
231
          if ( p.mBuildFile == -1 )
232
          {
233
            if ( !mDaemon )
234
            {
235
              // for escrow build purposes, exclude all dependent package versions
236
              mLogger.info("planRelease package not reproducible on the build platforms configured for this baseline " + p.mName);
237
              rippleBuildExclude(p);
238
            }
239
 
240
            // package is not reproducible on the build platforms configured for this baseline, discard
241
            p.mBuildFile = -2;
242
          }
243
        }
244
      }
245
    }      
246
 
247
    if (mDaemon)
248
    {
249
      // process packages which are not ripple buildable, and all packages dependent upon them      
250
      for (Iterator it = mPackageCollection.iterator(); it.hasNext(); )
251
      {
252
        Package p = (Package) it.next();
253
 
254
        if (p.mBuildFile == 0)
255
        {
256
          // package has yet to be processed
257
          if (p.mDoNotRipple)
258
          {
259
            // exclude all dependent package versions
260
            mLogger.info("planRelease do not ripple " + p.mName);
261
            rippleBuildExclude(p);
262
 
263
            // package is not reproducible, discard
264
            p.mBuildFile = -3;
265
          }
266
        }
267
      }
268
 
269
      // process packages which need to be ripple built
270
      for (Iterator it = mPackageCollection.iterator(); it.hasNext(); )
271
      {
272
        Package p = (Package) it.next();
273
 
274
        if (p.mBuildFile == 0)
275
        {
276
          // package has yet to be processed
277
          if (p.mDirectlyPlanned)
278
          {
279
            // a WIP exists on the package
280
            // exclude all dependent package versions
281
            mLogger.info("planRelease package has WIP " + p.mName);
282
            rippleIndirectlyPlanned(p);
283
          }
284
          else
285
          {
286
            Iterator it2 = p.mDependencyIDCollection.iterator();
287
            Iterator it3 = p.mPackageDependencyCollection.iterator();
288
            for ( ; it2.hasNext() && it3.hasNext(); )
289
            {
290
              Integer dpv_id = (Integer) it2.next();
291
              Package dependency = (Package) it3.next();
292
 
293
              if ( !dependency.mAdvisoryRipple )
294
              {
295
                // not advisory, ie has ripple build impact
296
                boolean found = false;
297
 
298
                for ( Iterator it4 = mReleasedPvIDCollection.iterator(); it4.hasNext(); )
299
                {
300
                  Integer pv_id = (Integer) it4.next();
301
 
302
                  if ( pv_id.compareTo(dpv_id) == 0 )
303
                  {
304
                    found = true;
305
                    break;
306
                  }
307
                }
308
 
309
                if ( !found )
310
                {
311
                  // the package is out of date
312
                  // exclude all dependent package versions
313
                  mLogger.info("planRelease package out of date " + p.mName);
314
                  rippleIndirectlyPlanned(p);                 
315
                  break;
316
                }
317
              }
318
            }
319
          }
320
        }
321
      }
322
 
323
      // process packages which do not exist in the archive
324
      for (Iterator it = mPackageCollection.iterator(); it.hasNext(); )
325
      {
326
        Package p = (Package) it.next();
327
 
328
        if (p.mBuildFile == 0)
329
        {
330
          // package has yet to be processed
331
          // for unit test purposes, assume all packages exist in the archive if released
332
          if ( mReleaseManager.mUseDatabase )
333
          {
334
            // only check existence outside the unit test
335
            if (!p.mDirectlyPlanned && !p.mIndirectlyPlanned)
336
            {
337
              // check package version archive existence
338
              if (!p.exists())
339
              {
340
                mLogger.info("planRelease package not found in archive " + p.mName);
341
                rippleIndirectlyPlanned(p);
342
              }
343
            }
344
          }
345
        }
346
      }
347
    }
348
 
349
    // process remaining packages which need to be reproduced for this baseline
350
    // determine the build file for each package
351
    // for daemon builds, determine the first package that can be built now, this means the first package not dependent upon packages also to be built
352
    // set its mBuildNumber to 1, all remaining reproducible packages to 2
353
    // for escrow builds, determine the package versions that can be built in the build iteration
354
    // set their mBuildNumber to the build iteration
355
    // increment the build iteration and repeat until all package versions that need to be reproduced have been assigned a build iteration
356
    boolean allProcessed = false;
357
    int buildFile = 1;
358
 
359
    // delete the file <rtagId>official
360
    Integer rtag = new Integer(mBaseline);
361
    File rtagIdOfficial = new File(rtag + "official");
362
 
363
    if (rtagIdOfficial.exists())
364
    {
365
      rtagIdOfficial.delete();
366
    }
367
 
368
    do
369
    {
370
      boolean allDependenciesProcessed = true;
371
 
372
      do
373
      {
374
        // assume all dependencies have been processed
375
        allDependenciesProcessed = true;
376
 
377
        for (Iterator it = mPackageCollection.iterator(); it.hasNext(); )
378
        {
379
          Package p = (Package) it.next();
380
 
381
          if ( mDaemon && ( ( !p.mDirectlyPlanned && !p.mIndirectlyPlanned ) || p.mBuildFile < 0 ) )
382
          {
383
            // flag packages with no build requirement as processed in daemon mode
384
            p.mProcessed = true;
385
            mLogger.info("planRelease package has no build requirement " + p.mName);            
386
          }
387
          else
388
          {
389
            if ( ( p.mBuildFile == 0 ) && ( (mDaemon && ( p.mDirectlyPlanned || p.mIndirectlyPlanned ) ) || ( !mDaemon ) ) )
390
            {
391
              // package yet to be processed and
392
              // in daemon mode has a build requirement or
393
              // in escrow mode
394
              boolean canBeBuiltNow = true;
395
              boolean allDependenciesForThisPackageProcessed = true;
396
 
397
              for ( Iterator it2 = p.mPackageDependencyCollection.iterator(); it2.hasNext(); )
398
              {
399
                Package dependency = (Package) it2.next();
400
 
401
                if ( !dependency.mProcessed )
402
                {
403
                  // cannot determine canBeBuiltNow until this dependency has been processed
404
                  allDependenciesForThisPackageProcessed = false;
405
                  allDependenciesProcessed = false;
406
                }
407
                else if ( ( mDaemon && ( dependency.mDirectlyPlanned ) || ( dependency.mIndirectlyPlanned ) ) || 
408
                          ( !mDaemon &&
409
                            ( ( dependency.mBuildFile == 0 ) ||
410
                              ( dependency.mBuildFile == buildFile &&
411
                                ( ( p.isLinuxBuilt() && !dependency.isLinuxBuilt() ) ||
412
                                  ( p.isWin32Built() && !dependency.isWin32Built() ) ||
413
                                  ( p.isSolarisBuilt() && !dependency.isSolarisBuilt() ) ) ) ) ) )
414
                {
415
                  // in daemon mode this processed dependency has a build requirement or
416
                  // in escrow mode...
417
                  // this processed dependency has not been assigned to a build iteration or
418
                  // this processed dependency has been assigned to this build iteration and does not build on this platform
419
                  canBeBuiltNow = false;
420
                  mLogger.info("planRelease package cannot be built in this iteration " + p.mName);
421
                  break;
422
                }
423
              }
424
 
425
              if (allDependenciesForThisPackageProcessed)
426
              {
427
                p.mProcessed = true;
428
 
429
                if ( mDaemon )
430
                {
431
                  if ( canBeBuiltNow )
432
                  {
433
                    // flag package with build requirement, may get downgraded to future build requirement
434
                    p.mBuildFile = 1;
435
                    mLogger.info("planRelease package has current build requirement " + p.mName);
436
                  }
437
                  else
438
                  {
439
                    // flag package with future build requirement
440
                    p.mBuildFile = 2;
441
                    mLogger.info("planRelease package has future build requirement " + p.mName);
442
                  }
443
                }
444
                else
445
                {
446
                  if ( canBeBuiltNow )
447
                  {
448
                    p.mBuildFile = buildFile;
449
                    mLogger.info("planRelease package can be built in this iteration " + p.mName);
450
                  }
451
                }
452
              }
453
            }
454
          }
455
        }
456
      } while( !allDependenciesProcessed );
457
 
458
      if ( mDaemon )
459
      {
460
        for (Iterator it = mPackageCollection.iterator(); it.hasNext(); )
461
        {
462
          Package p = (Package) it.next();
463
 
464
          if ( p.mProcessed && p.mBuildFile == 1 )
465
          {
466
            p.mBuildFile = buildFile;
467
 
468
            if ( buildFile == 1 )
469
            {
470
              p.applyPV(mReleaseManager, mBaseline);
471
              // write <rtagId>offical
472
              String lf = new String( System.getProperty("line.separator") );
473
              rtagIdOfficial.createNewFile();
474
              FileWriter rtagIdOfficialFileWriter = new FileWriter(rtagIdOfficial);
475
              rtagIdOfficialFileWriter.append("packageName=" + p.mName + lf);
476
              String extension = p.mExtension;
477
              String version = p.mVersion;
478
 
479
              if ( extension.length() > 0 )
480
              {
481
                version += extension;
482
              }
483
              else
484
              {
485
                extension = ".";
486
              }
487
 
488
              rtagIdOfficialFileWriter.append("packageExtension=" + extension + lf);
489
              rtagIdOfficialFileWriter.append("packageVersion=" + version + lf);
490
 
491
              // depends in the form 'cs','25.1.0000.cr';'Dinkumware_STL','1.0.0.cots'
492
              String depends = new String();
493
 
494
              for (Iterator it3=p.mPackageDependencyCollection.iterator(); it3.hasNext(); )
495
              {
496
                Package depend = (Package)it3.next();
497
 
498
                if ( depends.compareTo( "" ) != 0 )
499
                {
500
                  depends += ";";
501
                }
502
                depends += "\'" + depend.mName + "\'";
503
                depends += ",";
504
                String dependsExtension = depend.mExtension;
505
                String dependsVersion = depend.mVersion;
506
 
507
                if ( dependsExtension.length() > 0 )
508
                {
509
                  dependsVersion += dependsExtension;
510
                }
511
                else
512
                {
513
                  dependsExtension = ".";
514
                }
515
                depends += "\'" + dependsVersion + "\'";
516
              }
517
 
518
              rtagIdOfficialFileWriter.append("packageDepends=" + depends + lf);
519
 
520
              if ( p.mDirectlyPlanned )
521
              {
522
                // a WIP
523
                rtagIdOfficialFileWriter.append("packageRipple=0" + lf);
524
              }
525
              else
526
              {
527
                // a ripple
528
                rtagIdOfficialFileWriter.append("packageRipple=1" + lf);
529
              }
530
 
531
              rtagIdOfficialFileWriter.append("packageVersionID=" + p.mId);
532
 
533
              rtagIdOfficialFileWriter.close();
534
            }
535
            else
536
            {
537
              mLogger.info("planRelease package has future (downgraded) build requirement " + p.mName + " " + buildFile);              
538
            }
539
 
540
            buildFile = 2;
541
          }
542
        }
543
      }
544
 
545
      // are more build files required
546
      allProcessed = true;
547
 
548
      if (mDaemon)
549
      {
550
        for (Iterator it = mPackageCollection.iterator(); it.hasNext(); )
551
        {
552
          Package p = (Package) it.next();
553
 
554
          if ( p.mBuildFile < 0 || ( !p.mDirectlyPlanned && !p.mIndirectlyPlanned ) )
555
          {
556
            // at this point...
557
            // only 1 package with a build requirement has a mBuildFile of 1,
558
            // all other packages with a build requirement have an mBuildFile of 2
559
            // give packages with no build requirement, reproducible or not, an mBuildFile of 3
560
            p.mBuildFile = 3;
561
            mLogger.info("planRelease reiterating package has no build requirement " + p.mName);
562
          }
563
        }
564
      }
565
      else
566
      {
567
        // this is escrow mode centric
568
        for (Iterator it = mPackageCollection.iterator(); it.hasNext(); )
569
        {
570
          Package p = (Package) it.next();
571
 
572
          if ( p.mBuildFile == 0 )
573
          {
574
            // more build files are required
575
            allProcessed = false;
576
            mLogger.info("planRelease more build files are required for " + p.mName);
577
            break;
578
          }
579
        }
580
 
581
        buildFile++;
582
      }
583
    } while( !allProcessed );
584
 
585
    // persist the build files
586
    allProcessed = false;
587
    buildFile = 1;
588
 
589
    if ( mDaemon )
590
    {
591
      // all interesting packages in daemon mode match the following filter
592
      buildFile = 3;
593
    }
594
 
595
    mTimestamp = System.currentTimeMillis();
596
 
597
    if ( !mReleaseManager.mUseDatabase )
598
    {
599
      mTimestamp = 123456789;
600
    }
601
 
602
    do
603
    {
604
      String buildFileContent = new String( generateBuildFileHeader() );
605
 
606
      for (Iterator it = mPackageCollection.iterator(); it.hasNext(); )
607
      {
608
        Package p = (Package) it.next();
609
 
610
        if ( ( p.mBuildFile > 0 ) && ( p.mBuildFile <= buildFile ) )
611
        {
612
          buildFileContent += generatePackageProperty(p);
613
        }
614
      }
615
 
616
      buildFileContent += generateTaskdef();
617
 
618
      String win32_set_up = new String("");
619
      String win32_tear_down = new String("");
620
      String unix_set_up = new String("");
621
      String unix_tear_down = new String("");
622
      String lf = new String( System.getProperty("line.separator") );
623
 
624
      for (Iterator it = mPackageCollection.iterator(); it.hasNext(); )
625
      {
626
        Package p = (Package) it.next();
627
 
628
        if ( p.mBuildFile > 0 && p.mBuildFile <= buildFile )
629
        {
630
          buildFileContent += generateTarget(p, buildFile);
631
        }
632
 
633
        if ( !mDaemon && buildFile == 1 )
634
        {
635
          for (Iterator it2 = mGbeMachtypeCollection.iterator(); it2.hasNext(); )
636
          {
637
            String machtype = (String) it2.next();
638
 
639
            if ( machtype.compareTo("win32") == 0 )
640
            {
641
              if ( p.isWin32Built() )
642
              {
643
                win32_set_up +=
644
                "jats release -extract " + p.mLabel + " -path=" + p.mLocation + " -view=" + p.mAlias + " -root=. -noprefix" +lf;
645
                win32_tear_down +=
646
                "cleartool rmview " + p.mAlias + lf;
647
                break;
648
              }
649
            }
650
          }
651
 
652
          for (Iterator it2 = mGbeMachtypeCollection.iterator(); it2.hasNext(); )
653
          {
654
            String machtype = (String) it2.next();
655
 
656
            if ( machtype.compareTo("sparc") == 0
657
              || machtype.compareTo("solaris10_x86") == 0
658
              || machtype.compareTo("solaris10_sparc32") == 0
659
              || machtype.compareTo("linux_i386") == 0 )
660
            {
661
              if ( p.isLinuxBuilt() || p.isSolarisBuilt() )
662
              {
663
                unix_set_up +=
664
                "jats release -extract " + p.mLabel + " -view=" + p.mAlias + " -root=. -noprefix" +lf;
665
                unix_tear_down +=
666
                "cleartool rmview " + p.mAlias + lf;
667
                break;
668
              }
669
            }
670
          }
671
        }
672
      }
673
 
674
      if ( !mDaemon && buildFile == 1 )
675
      {
676
        mEscrowClearcaseSupportCollection.add(win32_set_up);  
677
        mEscrowClearcaseSupportCollection.add(win32_tear_down);  
678
        mEscrowClearcaseSupportCollection.add(unix_set_up);  
679
        mEscrowClearcaseSupportCollection.add(unix_tear_down);  
680
      }
681
 
682
      buildFileContent += generateDefaultTarget( buildFile);
683
      buildFileContent += generateBuildFileFooter();
684
 
685
      mBuildCollection.add(buildFileContent);
686
 
687
      // are more build files required
688
      allProcessed = true;
689
 
690
      if (!mDaemon)
691
      {
692
        // this is escrow mode centric
693
        for (Iterator it = mPackageCollection.iterator(); it.hasNext(); )
694
        {
695
          Package p = (Package) it.next();
696
 
697
          if ( p.mBuildFile > buildFile )
698
          {
699
            // more build files are required
700
            allProcessed = false;
701
            mLogger.info("planRelease reiterating package has no build requirement " + p.mName + " " + p.mBuildFile + " " + buildFile);
702
            break;
703
          }
704
        } 
705
 
706
        buildFile++;
707
      }
708
    } while( !allProcessed );
709
 
710
    mReleaseManager.disconnect();
711
    mLogger.warn("planRelease mDaemon " + mDaemon + " returned");
712
  }
713
 
714
  /**returns first build file content
715
   * returns false if no build file content exists
716
   */
717
  public boolean getFirstBuildFileContent(MutableString content)
718
  {
719
    mLogger.debug("getFirstBuildFileContent");
720
    boolean retVal = true;
721
 
722
    try
723
    {
724
      mBuildIndex = 0;
725
      content.value = (String)mBuildCollection.get( mBuildIndex );
726
    }
727
    catch( ArrayIndexOutOfBoundsException e )
728
    {
729
      retVal = false;
730
    }
731
 
732
    mLogger.info("getFirstBuildFileContent returned " + retVal);
733
    return retVal;
734
  }
735
 
736
  /**returns next build file content
737
   * returns false if no next build file content exists
738
   */
739
  public boolean getNextBuildFileContent(MutableString content)
740
  {
741
    mLogger.debug("getNextBuildFileContent");
742
    boolean retVal = true;
743
 
744
    try
745
    {
746
      mBuildIndex++;
747
      content.value = (String)mBuildCollection.get( mBuildIndex );
748
    }
749
    catch( ArrayIndexOutOfBoundsException e )
750
    {
751
      retVal = false;
752
    }
753
 
754
    mLogger.debug("getNextBuildFileContent returned " + retVal);
755
    return retVal;
756
  }
757
 
758
  /**collects meta data associated with the baseline
759
   */
760
  private void collectMetaData() throws SQLException, Exception
761
  {
762
    mLogger.debug("collectMetaData mDaemon " + mDaemon);
763
    mGbeMachtypeCollection.removeAllElements();
764
    mReleaseManager.queryMachtypes(mGbeMachtypeCollection, mDaemon, mBaseline);
765
 
766
    if (mDaemon)
767
    {
768
      mMailServer = mReleaseManager.queryMailServer();
769
      mMailSender = mReleaseManager.queryMailSender();
770
    }
771
    mBaselineName = mReleaseManager.queryBaselineName(mDaemon, mBaseline);
772
  }
773
 
774
  /**returns the Package with the matching mAlias or NULL_PACKAGE if no package has the mID
775
   */
776
  private Package findPackage(String alias)
777
  {
778
    mLogger.debug("findPackage");
779
    Package retVal = ReleaseManager.NULL_PACKAGE;
780
 
781
    for (Iterator it = mPackageCollection.iterator(); it.hasNext(); )
782
    {
783
      Package p = (Package) it.next();
784
 
785
      if ( p.mAlias.compareTo( alias ) == 0 )
786
      {
787
        retVal = p;
788
        break;
789
      }
790
    }
791
 
792
    mLogger.info("findPackage returned " + retVal.mName);
793
    return retVal;
794
  }
795
 
796
  /**sets the mBuildFile to -5 for the package and all dependent packages
797
   */
798
  private void rippleBuildExclude(Package p)
799
  {
800
    mLogger.debug("rippleBuildExclude");
801
    if ( p.mBuildFile == 0 )
802
    {
803
      p.mBuildFile = -5;
804
 
805
      for (Iterator it = mPackageCollection.iterator(); it.hasNext(); )
806
      {
807
        Package pkg = (Package) it.next();
808
 
809
        if ( pkg != p )
810
        {
811
          for (Iterator it2 = pkg.mPackageDependencyCollection.iterator(); it2.hasNext(); )
812
          {
813
            Package dependency = (Package) it2.next();
814
 
815
            if ( dependency == p )
816
            {
817
              rippleBuildExclude( pkg );
818
              break;
819
            }
820
          }
821
        }
822
      }
823
    }
824
    mLogger.info("rippleBuildExclude set " + p.mName + " " + p.mBuildFile);
825
  }
826
 
827
  /**returns a build file header for the mBaseline
828
   */
829
  private String generateBuildFileHeader()
830
  {
831
    mLogger.debug("generateBuildFileHeader");
832
    String lf = new String( System.getProperty("line.separator") );
833
    String retVal = new String("");
834
    retVal +=
835
    "<?xml version=\"1.0\"?>" + lf +
836
    "<project name=\"mass\" default=\"full\" basedir=\".\">" + lf;
837
 
838
    if ( mDaemon )
839
    {
840
      retVal +=
841
      "<property name=\"abt_mail_server\" value=\"" + mMailServer + "\"/>" + lf +
842
      "<property name=\"abt_mail_sender\" value=\"" + mMailSender + "\"/>" + lf +
843
      "<property name=\"abt_rtag_id\" value=\"" + mBaseline + "\"/>" + lf +
844
      "<property name=\"abt_daemon\" value=\"" + mTimestamp + "\"/>" + lf;
845
    }
846
    else
847
    {
848
      retVal +=
849
      "<property name=\"abt_rtag_id\" value=\"-1\"/>" + lf;
850
    }
851
 
852
    retVal +=
853
    "<property name=\"abt_release\" value=\"" + mBaselineName + "\"/>" + lf +
854
    "<property name=\"abt_buildtool_version\" value=\"11\"/>" + lf +
855
    "<condition property=\"abt_family\" value=\"windows\">" + lf +
856
    "  <os family=\"windows\"/>" + lf +
857
    "</condition>" + lf +
858
    "<property name=\"abt_family\" value=\"unix\"/>" + lf;
859
    mLogger.info("generateBuildFileHeader returned " + retVal);
860
    return retVal;
861
  }
862
 
863
  /**returns an ant property for the passed Package
864
   */
865
  private String generatePackageProperty(Package p)
866
  {
867
    mLogger.debug("generatePackageProperty");
868
    String lf = new String( System.getProperty("line.separator") );
869
    String retVal = new String("");
870
    retVal +=
871
    "<property name=\"" + p.mAlias + "\" value=\"" + p.mName + " " + p.mVersion + p.mExtension + "\"/>" + lf;
872
    mLogger.info("generatePackageProperty returned " + retVal);
873
    return retVal;
874
  }
875
 
876
  /**returns an ant taskdef for the abt ant task
877
   */
878
  private String generateTaskdef()
879
  {
880
    mLogger.debug("generateTaskdef");
881
    String lf = new String( System.getProperty("line.separator") );
882
    String retVal = new String("");
883
    retVal +=
884
    "<taskdef name=\"abt\" classname=\"com.erggroup.buildtool.ABT\"/>" + lf;
885
    return retVal;
886
  }
887
 
888
  /**returns an ant target for the passed Package
889
   * in daemon mode:
890
   *  packages are categorised with one of three mBuildFile values:
891
   *   1 the package to be built by this buildfile
892
   *   2 the packages with a future build requirement
893
   *   3 the packages with no build requirement
894
   *  the returned target depends on this categorisation and will have
895
   *   1 full abt info
896
   *   2 full dependency info to determine future build ordering but no abt info (will not build this package)
897
   *   3 only a name attribute (will not build this package)
898
   * in escrow mode:
899
   *  if the passed Package's mBuildFile is different (less than) the passed build file,
900
   *  the returned target have only a name attribute (will not build this package) 
901
   */
902
  private String generateTarget(Package p, int buildFile)
903
  {
904
    mLogger.debug("generateTarget");
905
 
906
    if ( mDaemon && p.mBuildFile == 1 )
907
    {
908
      // populate 'missing' BuildStandards
909
      boolean solaris = false;
910
      boolean linux = false;
911
      boolean win32 = false;
912
      boolean jats = false;
913
      boolean determinedBuildStandard = false;
914
 
915
      for (Iterator it = p.mBuildStandardCollection.iterator(); it.hasNext(); )
916
      {
917
        BuildStandard bs = (BuildStandard)it.next();
918
 
919
        if ( bs.getSolaris() )
920
        {
921
          solaris = true;
922
        }
923
        else
924
        if ( bs.getLinux() )
925
        {
926
          linux = true;
927
        }
928
        else
929
        if ( bs.getWin32() )
930
        {
931
          win32 = true;
932
        }
933
 
934
        if ( !determinedBuildStandard && bs.getBuildStandard(!mReleaseManager.mUseDatabase).contains("<jats") )
935
        {
936
          jats = true;
937
          determinedBuildStandard = true;
938
        }
939
      }
940
 
941
      if ( !solaris )
942
      {
943
        BuildStandard bs = new BuildStandard(this);
944
        bs.setSolaris();
945
 
946
        if ( jats )
947
        {
948
          bs.setJatsNone();
949
        }
950
        else
951
        {
952
          bs.setAntNone();
953
        }
954
 
955
        p.mBuildStandardCollection.add(bs);
956
      }
957
 
958
      if ( !linux )
959
      {
960
        BuildStandard bs = new BuildStandard(this);
961
        bs.setLinux();
962
 
963
        if ( jats )
964
        {
965
          bs.setJatsNone();
966
        }
967
        else
968
        {
969
          bs.setAntNone();
970
        }
971
 
972
        p.mBuildStandardCollection.add(bs);
973
      }
974
 
975
      if ( !win32 )
976
      {
977
        BuildStandard bs = new BuildStandard(this);
978
        bs.setWin32();
979
 
980
        if ( jats )
981
        {
982
          bs.setJatsNone();
983
        }
984
        else
985
        {
986
          bs.setAntNone();
987
        }
988
 
989
        p.mBuildStandardCollection.add(bs);
990
      }
991
    }
992
 
993
    String lf = new String( System.getProperty("line.separator") );
994
    String retVal = new String("");
995
 
996
    if ( ( mDaemon && p.mBuildFile == 3 ) ||
997
         ( !mDaemon && ( p.mBuildFile < buildFile ) ) )
998
    {
999
      retVal +=
1000
      "<target name=\"" + p.mAlias + "\"/>" + lf;
1001
    }
1002
    else
1003
    {
1004
      retVal +=
1005
      "<target name=\"" + p.mAlias + ".wrap\"";
1006
 
1007
      if ( p.mPackageDependencyCollection.size() > 0 )
1008
      {
1009
        retVal +=" depends=\"";
1010
        boolean comma = false;
1011
 
1012
        for (Iterator it = p.mPackageDependencyCollection.iterator(); it.hasNext(); )
1013
        {
1014
          if (comma)
1015
          {
1016
            retVal += ",";
1017
          }
1018
          comma = true;
1019
 
1020
          Package dependency = (Package) it.next();
1021
          retVal += dependency.mAlias;
1022
        }
1023
 
1024
        retVal += "\"";
1025
      }
1026
      retVal += ">" + lf;
1027
 
1028
      if ( !mDaemon )
1029
      {
1030
        boolean hasDependenciesBuiltInThisIteration = false;
1031
        if ( ( p.mPackageDependencyCollection.size() > 0 ) )
1032
        {
1033
          for (Iterator it = p.mPackageDependencyCollection.iterator(); it.hasNext(); )
1034
          {
1035
            Package dependency = (Package) it.next();
1036
 
1037
            if ( dependency.mBuildFile == buildFile )
1038
            {
1039
              hasDependenciesBuiltInThisIteration = true;
1040
              break;
1041
            }
1042
          }
1043
        }
1044
 
1045
        if ( hasDependenciesBuiltInThisIteration )
1046
        {
1047
          retVal +=
1048
          "  <condition property=\"" + p.mAlias + ".build\">" + lf +
1049
          "    <and>" + lf;
1050
 
1051
          for (Iterator it = p.mPackageDependencyCollection.iterator(); it.hasNext(); )
1052
          {
1053
            Package dependency = (Package) it.next();
1054
 
1055
            if ( dependency.mBuildFile == buildFile )
1056
            {
1057
              retVal +=
1058
              "      <or>" + lf +
1059
              "        <equals arg1=\"${" + dependency.mAlias + ".res}\" arg2=\"0\"/>" + lf +
1060
              "        <equals arg1=\"${" + dependency.mAlias + ".res}\" arg2=\"257\"/>" + lf +
1061
              "      </or>" + lf;
1062
            }
1063
          }
1064
 
1065
          retVal +=
1066
          "    </and>" + lf +
1067
          "  </condition>" + lf;
1068
        }
1069
        else
1070
        {
1071
          retVal += "  <property name=\"" + p.mAlias + ".build\" value=\"\"/>" + lf;
1072
        }
1073
      }
1074
 
1075
      retVal +=
1076
      "</target>" + lf +
1077
      "<target name=\"" + p.mAlias + "\" depends=\"" + p.mAlias + ".wrap\"";
1078
 
1079
      if ( !mDaemon )
1080
      {
1081
        retVal += " if=\"" + p.mAlias + ".build\"";
1082
      }
1083
 
1084
      retVal += ">" + lf;
1085
 
1086
      if ( mDaemon && p.mBuildFile == 1 )
1087
      {
1088
        retVal +=
1089
        "<property name=\"" + p.mAlias + "pkg_id\" value=\"" + p.mPid + "\"/>" + lf +
1090
        "<property name=\"" + p.mAlias + "pv_id\" value=\"" + p.mId + "\"/>" + lf;
1091
      }
1092
 
1093
      if ( ( mDaemon && p.mBuildFile == 1 ) || !mDaemon )
1094
      {
1095
        retVal +=
1096
        "<property name=\"" + p.mAlias + "packagename\" value=\"" + p.mName + "\"/>" + lf +
1097
        "<property name=\"" + p.mAlias + "packageversion\" value=\"" + p.mVersion + "\"/>" + lf +
1098
        "<property name=\"" + p.mAlias + "packageextension\" value=\"";
1099
 
1100
        if ( p.mExtension.length() > 0 )
1101
        {
1102
          // drop the .
1103
          retVal += p.mExtension.substring(1);
1104
        }
1105
        else
1106
        {
1107
          retVal += p.mExtension;
1108
        }
1109
 
1110
        retVal += "\"/>" + lf +
1111
        "<property name=\"" + p.mAlias + "packagelabel\" value=\"" + p.mLabel + "\"/>" + lf;
1112
 
1113
        if ( p.mDirectlyPlanned )
1114
        {
1115
          retVal += "<property name=\"" + p.mAlias + "directchange\" value=\"\"/>" + lf;
1116
        }
1117
 
1118
        mAddendum = "non generic";
1119
 
1120
        if ( p.isGeneric() )
1121
        {
1122
          mAddendum = "generic";
1123
          retVal += "<property name=\"" + p.mAlias + "generic\" value=\"\"/>" + lf;
1124
        }
1125
 
1126
        retVal += loc(p, p.mAlias + "loc", lf);
1127
 
1128
        if ( p.mHasAutomatedUnitTests )
1129
        {
1130
          retVal += 
1131
          "<property name=\"" + p.mAlias + "unittests\" value=\"\"/>" + lf;
1132
        }
1133
      }
1134
 
1135
      retVal += "<abt>" + lf;
1136
 
1137
      if ( ( mDaemon && p.mBuildFile == 1 ) || !mDaemon )
1138
      {
1139
        for (Iterator it = p.mPackageDependencyCollection.iterator(); it.hasNext(); )
1140
        {
1141
          Package dependency = (Package) it.next();
1142
          retVal +=
1143
          "  <depend package_alias=\"${" + dependency.mAlias + "}\"/>" + lf;
1144
        }
1145
 
1146
        String platforms = new String();
1147
        String standards = new String();
1148
 
1149
        for (Iterator it = p.mBuildStandardCollection.iterator(); it.hasNext(); )
1150
        {
1151
          BuildStandard bs = (BuildStandard)it.next();
1152
 
1153
          String platform = bs.getPlatform(!mReleaseManager.mUseDatabase);
1154
 
1155
          if ( platform.length() > 0 )
1156
          {
1157
            platforms += platform + lf;
1158
          }
1159
 
1160
          String standard = bs.getBuildStandard(!mReleaseManager.mUseDatabase);
1161
 
1162
          if ( standard.length() > 0 )
1163
          {
1164
            standards += standard + lf;
1165
          }
1166
        }
1167
 
1168
        retVal += platforms + standards;
1169
      }
1170
 
1171
      if ( mDaemon && p.mBuildFile == 1 )
1172
      {
1173
       for (Iterator it = p.mBuildFailureEmailCollection.iterator(); it.hasNext(); )
1174
       {
1175
         String email = (String)it.next();
1176
         retVal +=
1177
         "  <owner email=\"" + email +"\"/>" + lf;
1178
       }
1179
      }
1180
 
1181
      retVal += "</abt>" + lf +
1182
      "</target>" + lf;
1183
 
1184
      if ( mDaemon && p.mBuildFile == 1 )
1185
      {
1186
        retVal +=
1187
        "<target name=\"AbtSetUp\">" + lf +
1188
        "<property name=\"AbtSetUppackagelabel\" value=\"" + p.mLabel + "\"/>" + lf;
1189
 
1190
        retVal += loc(p, "AbtSetUppackagelocation", lf);
1191
 
1192
        retVal +=
1193
        "<abt>" + lf +
1194
        "</abt>" + lf +
1195
        "</target>" + lf +
1196
        "<target name=\"AbtTearDown\">" + lf +
1197
        "<property name=\"AbtTearDownpackagelabel\" value=\"" + p.mLabel + "\"/>" + lf +
1198
        "<property name=\"AbtTearDownpackagename\" value=\"" + p.mName + "\"/>" + lf +
1199
        "<property name=\"AbtTearDownpackageversion\" value=\"" + p.mVersion + "\"/>" + lf +
1200
        "<property name=\"AbtTearDownpackageextension\" value=\"";
1201
 
1202
        if ( p.mExtension.length() > 0 )
1203
        {
1204
          // drop the .
1205
          retVal += p.mExtension.substring(1);
1206
        }
1207
        else
1208
        {
1209
          retVal += p.mExtension;
1210
        }
1211
 
1212
        retVal += "\"/>" + lf;
1213
 
1214
        if ( p.isGeneric() )
1215
        {
1216
          retVal += "<property name=\"" + p.mAlias + "generic\" value=\"\"/>" + lf;
1217
        }
1218
 
1219
        retVal +=        
1220
        "<abt>" + lf +
1221
        "</abt>" + lf +
1222
        "</target>" + lf +
1223
        "<target name=\"AbtPublish\">" + lf +
1224
        "<property name=\"AbtPublishpackagelabel\" value=\"" + p.mLabel + "\"/>" + lf +
1225
        "<property name=\"AbtPublishpackagename\" value=\"" + p.mName + "\"/>" + lf +
1226
        "<property name=\"AbtPublishpackageversion\" value=\"" + p.mVersion + "\"/>" + lf +
1227
        "<property name=\"AbtPublishpackageextension\" value=\"";
1228
 
1229
        if ( p.mExtension.length() > 0 )
1230
        {
1231
          // drop the .
1232
          retVal += p.mExtension.substring(1);
1233
        }
1234
        else
1235
        {
1236
          retVal += p.mExtension;
1237
        }
1238
 
1239
        retVal += "\"/>" + lf;
1240
 
1241
        if ( p.mDirectlyPlanned )
1242
        {
1243
          retVal += "<property name=\"AbtPublishdirectchange\" value=\"\"/>" + lf;
1244
        }
1245
 
1246
        if ( p.isGeneric() )
1247
        {
1248
          retVal += "<property name=\"AbtPublishgeneric\" value=\"\"/>" + lf;
1249
        }
1250
 
1251
        retVal += loc(p, "AbtPublishloc", lf);
1252
        retVal +=
1253
        "<abt>" + lf;
1254
 
1255
        String platforms = new String();
1256
 
1257
        for (Iterator it = p.mBuildStandardCollection.iterator(); it.hasNext(); )
1258
        {
1259
          BuildStandard bs = (BuildStandard)it.next();
1260
 
1261
          if ( !bs.getBuildStandard(!mReleaseManager.mUseDatabase).contains("\"none\"") )
1262
          {
1263
 
1264
            String platform = bs.getPlatform(!mReleaseManager.mUseDatabase);
1265
 
1266
            if ( platform.length() > 0 )
1267
            {
1268
              platforms += platform + lf;
1269
            }
1270
          }
1271
 
1272
        }
1273
 
1274
        retVal += platforms +
1275
        "</abt>" + lf +
1276
        "</target>" + lf;
1277
      }
1278
    }
1279
    mLogger.info("generateTarget returned " + retVal);
1280
    return retVal;
1281
  }
1282
 
1283
  /**returns an ant default target for the current build iteration
1284
   */
1285
  private String generateDefaultTarget(int buildFile)
1286
  {
1287
    mLogger.debug("generateDefaultTarget");
1288
    String lf = new String( System.getProperty("line.separator") );
1289
    String retVal = new String("");
1290
    retVal +=
1291
    "<target name=\"fullstart\">" + lf;
1292
 
1293
    if (buildFile == 1)
1294
    {
1295
      retVal +=
1296
      "<echo message=\"${line.separator}The following package versions are not reproducible on any build platform:${line.separator}${line.separator}\" file=\"publish.log\" append=\"true\"/>" + lf;
1297
 
1298
      for (Iterator it = mPackageCollection.iterator(); it.hasNext(); )
1299
      {
1300
        Package p = (Package)it.next();
1301
 
1302
        if ( p.mBuildFile == -1 )
1303
        {
1304
          retVal +=
1305
          "<echo message=\"${line.separator}" + p.mAlias + "${line.separator}\" file=\"publish.log\" append=\"true\"/>" + lf;
1306
        }
1307
      }
1308
 
1309
      retVal +=
1310
      "<echo message=\"${line.separator}The following package versions are not reproducible on the build platforms associated with this baseline:${line.separator}${line.separator}\" file=\"publish.log\" append=\"true\"/>" + lf;
1311
 
1312
      for (Iterator it = mPackageCollection.iterator(); it.hasNext(); )
1313
      {
1314
        Package p = (Package)it.next();
1315
 
1316
        if ( p.mBuildFile == -2 )
1317
        {
1318
          retVal +=
1319
          "<echo message=\"${line.separator}" + p.mAlias + "${line.separator}\" file=\"publish.log\" append=\"true\"/>" + lf;
1320
        }
1321
      }
1322
 
1323
      retVal +=
1324
      "<echo message=\"${line.separator}The following package versions are not reproducible as they are directly dependent upon package versions not in the baseline:${line.separator}${line.separator}\" file=\"publish.log\" append=\"true\"/>" + lf;
1325
 
1326
      for (Iterator it = mPackageCollection.iterator(); it.hasNext(); )
1327
      {
1328
        Package p = (Package)it.next();
1329
 
1330
        if ( p.mBuildFile == -4 )
1331
        {
1332
          retVal +=
1333
          "<echo message=\"${line.separator}" + p.mAlias + "${line.separator}\" file=\"publish.log\" append=\"true\"/>" + lf;
1334
        }
1335
      }
1336
 
1337
      retVal +=
1338
      "<echo message=\"${line.separator}The following package versions are not reproducible as they are directly/indirectly dependent upon not reproducible package versions:${line.separator}${line.separator}\" file=\"publish.log\" append=\"true\"/>" + lf;
1339
 
1340
      for (Iterator it = mPackageCollection.iterator(); it.hasNext(); )
1341
      {
1342
        Package p = (Package)it.next();
1343
 
1344
        if ( p.mBuildFile == -5 )
1345
        {
1346
          retVal +=
1347
          "<echo message=\"${line.separator}" + p.mAlias + "${line.separator}\" file=\"publish.log\" append=\"true\"/>" + lf;
1348
        }
1349
      }
1350
    }
1351
    if ( !mDaemon )
1352
    {
1353
      retVal +=
1354
      "<echo message=\"${line.separator}Build Started:${line.separator}${line.separator}\" file=\"publish.log\" append=\"true\"/>" + lf;
1355
    }
1356
 
1357
    retVal +=
1358
    "</target>" + lf +
1359
    "<target name=\"full\" depends=\"fullstart";
1360
 
1361
    for (Iterator it = mPackageCollection.iterator(); it.hasNext(); )
1362
    {
1363
      Package p = (Package)it.next();
1364
 
1365
      if ( ( p.mBuildFile > 0 ) && ( p.mBuildFile <= buildFile ) )
1366
      {
1367
        retVal += "," + p.mAlias;
1368
      }
1369
    }
1370
 
1371
    retVal +=
1372
    "\">" + lf;
1373
 
1374
    if ( !mDaemon )
1375
    {
1376
      retVal +=
1377
      "<echo message=\"${line.separator}Build Finished${line.separator}\" file=\"publish.log\" append=\"true\"/>" + lf;
1378
    }
1379
 
1380
    retVal +=
1381
    "</target>" + lf;
1382
    return retVal;
1383
  }
1384
 
1385
  /**returns a build file footer
1386
   */
1387
  private String generateBuildFileFooter()
1388
  {
1389
    mLogger.debug("generateBuildFileFooter");
1390
    String retVal = new String("</project>");
1391
    return retVal;
1392
  }
1393
 
1394
  /**sets the mIndirectlyPlanned true for the package and all dependent packages
1395
   */
1396
  private void rippleIndirectlyPlanned(Package p)
1397
  {
1398
    mLogger.debug("rippleIndirectlyPlanned");
1399
    if ( !p.mIndirectlyPlanned && p.mBuildFile == 0 )
1400
    {
1401
      p.mIndirectlyPlanned = true;
1402
 
1403
      for (Iterator it = mPackageCollection.iterator(); it.hasNext(); )
1404
      {
1405
        Package pkg = (Package) it.next();
1406
 
1407
        if ( pkg != p )
1408
        {
1409
          for (Iterator it2 = pkg.mPackageDependencyCollection.iterator(); it2.hasNext(); )
1410
          {
1411
            Package dependency = (Package) it2.next();
1412
 
1413
            if ( dependency == p )
1414
            {
1415
              rippleIndirectlyPlanned( pkg );
1416
              break;
1417
            }
1418
          }
1419
        }
1420
      }
1421
    }
1422
    mLogger.info("rippleIndirectlyPlanned set " + p.mName + " " + p.mIndirectlyPlanned);    
1423
  }
1424
 
1425
  /**accessor method
1426
   */
1427
  public String getWin32SetUp()
1428
  {
1429
    mLogger.debug("getWin32SetUp");
1430
    String retVal = new String("");
1431
 
1432
    try
1433
    {
1434
      if ( mEscrowClearcaseSupportCollection.size() >= 4 )
1435
      {
1436
        retVal = (String)mEscrowClearcaseSupportCollection.get(0);
1437
      }
1438
    }
1439
    catch( ArrayIndexOutOfBoundsException e )
1440
    {
1441
    }
1442
 
1443
    mLogger.info("getWin32SetUp returned " + retVal);
1444
    return retVal;
1445
  }
1446
 
1447
  /**accessor method
1448
   */
1449
  public String getWin32TearDown()
1450
  {
1451
    mLogger.debug("getWin32TearDown");
1452
    String retVal = new String("");
1453
 
1454
    try
1455
    {
1456
      if ( mEscrowClearcaseSupportCollection.size() >= 4 )
1457
      {
1458
        retVal = (String)mEscrowClearcaseSupportCollection.get(1);
1459
      }
1460
    }
1461
    catch( ArrayIndexOutOfBoundsException e )
1462
    {
1463
    }
1464
 
1465
    mLogger.info("getWin32TearDown returned " + retVal);
1466
    return retVal;
1467
  }
1468
 
1469
  /**accessor method
1470
   */
1471
  public String getUnixSetUp()
1472
  {
1473
    mLogger.debug("getUnixSetUp");
1474
    String retVal = new String("");
1475
 
1476
    try
1477
    {
1478
      if ( mEscrowClearcaseSupportCollection.size() >= 4 )
1479
      {
1480
        retVal = (String)mEscrowClearcaseSupportCollection.get(2);
1481
      }
1482
    }
1483
    catch( ArrayIndexOutOfBoundsException e )
1484
    {
1485
    }
1486
 
1487
    mLogger.info("getUnixSetUp returned " + retVal);
1488
    return retVal;
1489
  }
1490
 
1491
  /**accessor method
1492
   */
1493
  public String getUnixTearDown()
1494
  {
1495
    mLogger.debug("getUnixTearDown");
1496
    String retVal = new String("");
1497
 
1498
    try
1499
    {
1500
      if ( mEscrowClearcaseSupportCollection.size() >= 4 )
1501
      {
1502
        retVal = (String)mEscrowClearcaseSupportCollection.get(3);
1503
      }
1504
    }
1505
    catch( ArrayIndexOutOfBoundsException e )
1506
    {
1507
    }
1508
 
1509
    mLogger.info("getUnixTearDown returned " + retVal);
1510
    return retVal;
1511
  }
1512
 
1513
  /**returns first build file content and addendum
1514
   * the addendum value is one of "non generic", "generic" or "dummy"
1515
   */
1516
  public void getFirstBuildFileContent(MutableString content, 
1517
                                MutableString addendum)
1518
  {
1519
    mLogger.debug("getFirstBuildFileContent");
1520
    try
1521
    {
1522
      mBuildIndex = 0;
1523
      content.value = (String)mBuildCollection.get( mBuildIndex );
1524
      addendum.value = mAddendum;
1525
    }
1526
    catch( ArrayIndexOutOfBoundsException e )
1527
    {
1528
    }
1529
    mLogger.info("getFirstBuildFileContent passed " + content.value + addendum.value);
1530
  }
1531
 
1532
  /**returns the built loc
1533
   */
1534
  private String loc(Package p, String target, String lf)
1535
  {
1536
    mLogger.debug("loc");
1537
    String retVal = new String();
1538
    String loc = new String("\\");
1539
 
1540
    for (Iterator it = mGbeMachtypeCollection.iterator(); it.hasNext(); )
1541
    {
1542
      String machtype = (String) it.next();
1543
 
1544
      if ( machtype.compareTo("win32") == 0 )
1545
      {
1546
        //if ( p.isWin32Built() )
1547
        {
1548
          if ( target.compareTo("AbtSetUppackagelocation") != 0 )
1549
          {
1550
            if (mDaemon)
1551
            {
1552
              loc += mBaseline + "\\" + mTimestamp + "\\";
1553
            }
1554
 
1555
            loc += p.mLabel + p.mLocation;
1556
          }
1557
          else
1558
          {
1559
            loc = p.mLocation;
1560
          }
1561
          break;
1562
        }
1563
      }
1564
    }
1565
 
1566
    loc = loc.replace('/', '\\');
1567
    retVal =
1568
    "<condition property=\"" + target + "\" value=\"" + loc + "\">" + lf +
1569
    "  <os family=\"windows\"/>" + lf +
1570
    "</condition>" + lf;
1571
 
1572
    loc = "/";
1573
 
1574
    for (Iterator it = mGbeMachtypeCollection.iterator(); it.hasNext(); )
1575
    {
1576
      String machtype = (String) it.next();
1577
 
1578
      if ( machtype.compareTo("linux_i386") == 0 )
1579
      {
1580
        //if ( p.isLinuxBuilt() )
1581
        {
1582
          if ( target.compareTo("AbtSetUppackagelocation") != 0 )
1583
          {
1584
            if (mDaemon)
1585
            {
1586
              loc += mBaseline + "/" + mTimestamp + "/";
1587
            }
1588
 
1589
            loc += p.mLabel + "/vobs" + p.mLocation;
1590
          }
1591
          else
1592
          {
1593
            loc = p.mLocation;
1594
          }
1595
          break;
1596
        }
1597
      }
1598
      else if ( machtype.compareTo("sparc") == 0
1599
             || machtype.compareTo("solaris10_x86") == 0
1600
             || machtype.compareTo("solaris10_sparc32") == 0 )
1601
      {
1602
        //if ( p.isSolarisBuilt() )
1603
        {
1604
          if ( target.compareTo("AbtSetUppackagelocation") != 0 )
1605
          {
1606
            if (mDaemon)
1607
            {
1608
              loc += mBaseline + "/" + mTimestamp + "/";
1609
            }
1610
 
1611
            loc += p.mLabel + "/vobs" + p.mLocation;
1612
          }
1613
          else
1614
          {
1615
            loc = p.mLocation;
1616
          }
1617
          break;
1618
        }       
1619
      }
1620
    }
1621
    loc = loc.replace('\\', '/');
1622
    retVal += 
1623
    "<property name=\"" + target + "\" value=\"" + loc + "\"/>" + lf;
1624
 
1625
    mLogger.info("loc returned " + retVal);
1626
    return retVal;
1627
  }
1628
}