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