Subversion Repositories DevTools

Rev

Rev 7046 | Rev 7099 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7046 Rev 7082
Line 1... Line 1...
1
package com.erggroup.buildtool.ripple;
1
package com.erggroup.buildtool.ripple;
2
 
2
 
3
import java.io.File;
3
import java.io.File;
4
import java.sql.SQLException;
4
import java.sql.SQLException;
5
import java.util.ArrayList;
5
import java.util.ArrayList;
-
 
6
import java.util.Comparator;
6
import java.util.HashMap;
7
import java.util.HashMap;
7
import java.util.Iterator;
8
import java.util.Iterator;
8
import java.util.LinkedHashSet;
9
import java.util.LinkedHashSet;
9
import java.util.Vector;
10
import java.util.Vector;
10
import java.util.Comparator;
-
 
11
 
11
 
12
import org.slf4j.Logger;
12
import org.slf4j.Logger;
13
import org.slf4j.LoggerFactory;
13
import org.slf4j.LoggerFactory;
14
 
14
 
15
import com.erggroup.buildtool.ripple.ReleaseManager.BuildReason;
15
import com.erggroup.buildtool.ripple.ReleaseManager.BuildReason;
Line 39... Line 39...
39
     * instance identifier
39
     * instance identifier
40
     * 
40
     * 
41
     * @attribute
41
     * @attribute
42
     */
42
     */
43
    public String mVersion = new String();
43
    public String mVersion = new String();
-
 
44
    
-
 
45
    /**
-
 
46
     * If this package is a candidate for building, then this value will be calculated
-
 
47
     * and will  be used if the package is selected for building
-
 
48
     */
-
 
49
    public String mNextVersion = null;
44
 
50
 
45
    /**
51
    /**
46
     * Version string as specified by the user. Used with a ripple type of 'F'
52
     * Version string as specified by the user. Used with a ripple type of 'F'
47
     */
53
     */
48
    String mFixedVersion = new String();
54
    String mFixedVersion = new String();
Line 157... Line 163...
157
     */
163
     */
158
    public boolean mIsBuildable = true;
164
    public boolean mIsBuildable = true;
159
 
165
 
160
    /**
166
    /**
161
     * determines the build file the package is built in, or not
167
     * determines the build file the package is built in, or not
162
     * @param   1 Post Plan: build file - Result of planning
168
     * <br>   1 Post Plan: build file - Result of planning
163
     * @param   2 Post Plan: Future build requirement
169
     * <br>   2 Post Plan: Future build requirement
164
     * @param   3 Post Plan: Package has no build requirement
170
     * <br>   3 Post Plan: Package has no build requirement
165
     * @param   0 not yet processed (initial value) 
171
     * <br>   0 not yet processed (initial value) 
166
     * @param  -1 not reproducible
172
     * <br>  -1 not reproducible
167
     * @param  -2 escrow: not reproducible on the build platforms configured for this release
173
     * <br>  -2 escrow: not reproducible on the build platforms configured for this release
168
     * @param  -3 daemon: do not ripple
174
     * <br>  -3 daemon: do not ripple
169
     * @param  -4 directly dependent on package versions not in the baseline
175
     * <br>  -4 directly dependent on package versions not in the baseline
170
     * @param  -5 indirectly dependent on package versions which are not reproducible due to detected fault
176
     * <br>  -5 indirectly dependent on package versions which are not reproducible due to detected fault
171
     * @param  -6 circular dependency
177
     * <br>  -6 circular dependency
172
     * @param  -7 Pegged or SDK Imported package not in dpkg_archive
178
     * <br>  -7 Pegged or SDK Imported package not in dpkg_archive
173
     * @param  -8 Pegged or SDK Imported package
179
     * <br>  -8 Pegged or SDK Imported package
174
     * @param  -9 Rejected Daemon Instruction
180
     * <br>  -9 Rejected Daemon Instruction
175
     * @param  -10 UnBuildable Package not in dpkg_archive
181
     * <br>  -10 UnBuildable Package not in dpkg_archive
176
     * @param  -11 Marked as RippleStop
182
     * <br>  -11 Marked as RippleStop
177
     * 
183
     * 
178
     */
184
     */
179
    int mBuildFile = 0;
185
    int mBuildFile = 0;
180
    
186
    
181
    /** Retained reason the package will not be built
187
    /** Retained reason the package will not be built
Line 221... Line 227...
221
    /**
227
    /**
222
     * non zero instruction number when it is determined to be ripple built by force
228
     * non zero instruction number when it is determined to be ripple built by force
223
     * 
229
     * 
224
     * @attribute
230
     * @attribute
225
     */
231
     */
226
    int mForcedRippleInstruction = 0;
232
    public int mForcedRippleInstruction = 0;
227
 
233
 
228
    /**
234
    /**
229
     * test build - non zero instruction number when it is determined to be test built
235
     * test build - non zero instruction number when it is determined to be test built
230
     * 
236
     * 
231
     * @attribute
237
     * @attribute
232
     */
238
     */
233
    int mTestBuildInstruction = 0;
239
    public int mTestBuildInstruction = 0;
234
 
-
 
235
    /**
-
 
236
     * test build - Package PVID
-
 
237
     * 
-
 
238
     * @attribute
-
 
239
     */
-
 
240
    int mTestBuildPvId = -1;
-
 
241
 
-
 
242
    /**
-
 
243
     * test build email destination
-
 
244
     * Used by all daemon instructions to retain instigator of the instruction 
-
 
245
     * 
-
 
246
     * @attribute
-
 
247
     */
-
 
248
    String mTestBuildEmail;
-
 
249
 
-
 
250
    /**
-
 
251
     * test build - Version Control System Tag
-
 
252
     * 
-
 
253
     * @attribute
-
 
254
     */
-
 
255
    String mTestBuildVcsTag = new String();
-
 
256
 
-
 
257
    /**
-
 
258
     * test build - build standards
-
 
259
     * 
-
 
260
     * @attribute
-
 
261
     */
-
 
262
    Vector<BuildStandard> mTestBuildStandardCollection = new Vector<BuildStandard>();
-
 
263
 
-
 
264
    /**
-
 
265
     * test build - build dependencies by package alias
-
 
266
     * 
-
 
267
     * @attribute
-
 
268
     */
-
 
269
    Vector<String> mTestBuildDependencyCollection = new Vector<String>();
-
 
270
 
-
 
271
    /** 
-
 
272
     * test build - package has build dependencies
-
 
273
     */
-
 
274
	public boolean mTestBuildHasAutomatedUnitTests;
-
 
275
 
240
 
276
    /**
241
    /**
277
     * build dependencies by pv_id (-1 or not used for planned dependencies)
242
     * build dependencies by pv_id (-1 or not used for planned dependencies)
278
     * 
243
     * 
279
     * @attribute
244
     * @attribute
Line 385... Line 350...
385
     * Planned packages (WIPS) need calculate a new version number
350
     * Planned packages (WIPS) need calculate a new version number
386
     * This should be based on the Version of the package that the WIP was based upon
351
     * This should be based on the Version of the package that the WIP was based upon
387
     */
352
     */
388
	public String mPrevVersion;
353
	public String mPrevVersion;
389
	
354
	
390
	/** Used to preserve the basic ordering of the package list(s)
355
    /** Used to preserve the basic ordering of the package list(s)
391
	 *  Only valid for the duration of the comparison sorts
356
     *  Only valid for the duration of the comparison sorts
392
	 */
357
     */
393
	int mSeqId;
358
    int mSeqId;	
394
 
359
	
395
	/** Indicates that the package not be ripple built at this time
360
	/** Indicates that the package not be ripple built at this time
396
	 *  Sequence is:
361
	 *  Sequence is:
397
	 *     User sets to 's'
362
	 *     User sets to 's'
398
	 *     This buildtool will set to 'w' when a ripple has been detected
363
	 *     This buildtool will set to 'w' when a ripple has been detected
399
	 *     User resets to NULL when the ripple can be resumed. This is stored as an 'n'
364
	 *     User resets to NULL when the ripple can be resumed. This is stored as an 'n'
Line 405... Line 370...
405
     *  Used to estimate the cost of building the package
370
     *  Used to estimate the cost of building the package
406
     *  A WIP packages gets the buildTime of the package its based upon
371
     *  A WIP packages gets the buildTime of the package its based upon
407
     */
372
     */
408
    public int mBuildTime;
373
    public int mBuildTime;
409
 
374
 
-
 
375
    /** Set to indicate that the package is NOT a part of the full release set
-
 
376
     *  The package is a WIP, TestBuild or a ForcedRipple
-
 
377
     *  
-
 
378
     *   Used to simplify detection of such packages and to limit processing of these packages
-
 
379
     *   May be cleared if the package is added to the full set
-
 
380
     */
-
 
381
    public boolean mIsNotReleased = false;
-
 
382
    
-
 
383
    /** Used by some algorithms for various indications
-
 
384
     * 
-
 
385
     */
-
 
386
    public boolean mIsProcessed = false;
-
 
387
 
410
    /**
388
    /**
411
     * Constructor
389
     * Constructor
412
     * Used to create planned packages. In these packages the change_type is significant
390
     * Used to create planned packages. In these packages the change_type is significant
413
     * 
391
     * 
414
     * @param pkg_id	   Package Name Identifier
392
     * @param pkg_id	   Package Name Identifier
Line 419... Line 397...
419
     * @param alias        Package Alias
397
     * @param alias        Package Alias
420
     * @param pkg_vcs_tag  Vcs Tag
398
     * @param pkg_vcs_tag  Vcs Tag
421
     * @param ripple_field Ripple Field
399
     * @param ripple_field Ripple Field
422
     * @param change_type  Change Type
400
     * @param change_type  Change Type
423
     */
401
     */
424
    public Package(int pkg_id, int pv_id, String pkg_name, String pkg_version, String v_ext, String alias, String pkg_vcs_tag,
402
    public Package(int pkg_id, int pv_id, String pkg_name, String pkg_version, String v_ext, String alias, String pkg_vcs_tag, char ripple_field, char change_type)
425
            char ripple_field, char change_type)
-
 
426
    {
403
    {
427
        mLogger.debug("Package 1: pv_id " + pv_id + " pkg_name " + pkg_name + " v_ext " + v_ext + " alias " + alias
404
        mLogger.debug("Package 1: pv_id " + pv_id + " pkg_name " + pkg_name + " v_ext " + v_ext + " alias " + alias
428
                + " pkg_vcs_tag " + pkg_vcs_tag + " change_type " + change_type);
405
                + " pkg_vcs_tag " + pkg_vcs_tag + " change_type " + change_type);
429
        mId = pv_id;
406
        mId = pv_id;
430
        mName = pkg_name;
407
        mName = pkg_name;
Line 467... Line 444...
467
     * @param v_ext        Package Suffix
444
     * @param v_ext        Package Suffix
468
     * @param alias        Package Alias
445
     * @param alias        Package Alias
469
     * @param pkg_vcs_tag  Vcs Tag
446
     * @param pkg_vcs_tag  Vcs Tag
470
     * @param ripple_field Ripple Field
447
     * @param ripple_field Ripple Field
471
     */
448
     */
472
    public Package(int pkg_id,int pv_id, String pkg_name, String pkg_version, String v_ext, String alias, String pkg_vcs_tag,
449
    public Package(int pkg_id,int pv_id, String pkg_name, String pkg_version, String v_ext, String alias, String pkg_vcs_tag, char ripple_field)
473
            char ripple_field)
-
 
474
    {
450
    {
475
        mLogger.debug("Package 2: pv_id " + pv_id + " pkg_name " + pkg_name + " pkg_version " + pkg_version + " v_ext "
451
        mLogger.debug("Package 2: pv_id " + pv_id + " pkg_name " + pkg_name + " pkg_version " + pkg_version + " v_ext "
476
                + v_ext + " alias " + alias + " pkg_vcs_tag " + pkg_vcs_tag + " ripple_field " + ripple_field);
452
                + v_ext + " alias " + alias + " pkg_vcs_tag " + pkg_vcs_tag + " ripple_field " + ripple_field);
477
        mId = pv_id;
453
        mId = pv_id;
478
        mName = pkg_name;
454
        mName = pkg_name;
Line 516... Line 492...
516
        mAlias = "null";
492
        mAlias = "null";
517
        mVcsTag = "null";
493
        mVcsTag = "null";
518
    }
494
    }
519
 
495
 
520
    /**
496
    /**
521
     * Constructor for test build purposes
497
     * Constructor for unit test purposes
522
     * Used when a test build package does not exist in the current package set
498
     *  Will invoke applyPV and save the results for the UTF framework
523
     * 
-
 
524
     */
-
 
525
    Package(int pkg_id, int pv_id, String pkg_name, String v_ext, String alias, String pkg_vcs_tag, int testBuildInstruction, String email)
-
 
526
    {
-
 
527
        mLogger.debug("Package 4: pkg_name " + pkg_name + " v_ext " + v_ext + " alias " + alias + " pkg_vcs_tag "
-
 
528
                + pkg_vcs_tag);
-
 
529
        // don't need pv_id
-
 
530
        mId = -1;
-
 
531
        mName = pkg_name;
-
 
532
        mPid = pkg_id;
-
 
533
        // avoid interaction with real versions
-
 
534
        mVersion = "0.0.0000";
-
 
535
        mExtension = v_ext;
-
 
536
        mAlias = alias;
-
 
537
        mTestBuildInstruction = testBuildInstruction;
-
 
538
        mTestBuildEmail = email;
-
 
539
        mTestBuildVcsTag = pkg_vcs_tag;
-
 
540
        mTestBuildPvId = pv_id;
-
 
541
        mTestBuildHasAutomatedUnitTests = false;
-
 
542
 
-
 
543
    }
-
 
544
 
-
 
545
    /**
-
 
546
     * constructor for unit test purposes
-
 
547
     */
499
     */
548
    public Package(ReleaseManager rm, String version, int majorLimit, int minorLimit, int patchLimit, int buildNumberLimit)
500
    public Package(ReleaseManager rm, String version, int majorLimit, int minorLimit, int patchLimit, int buildNumberLimit)
549
    {
501
    {
550
        mId = -1;
502
        mId = -1;
551
        mRippleField.setLimit();
503
        mRippleField.setLimit();
Line 565... Line 517...
565
            mRippleField.setBuild();
517
            mRippleField.setBuild();
566
        }
518
        }
567
 
519
 
568
        try
520
        try
569
        {
521
        {
570
            mId = applyPV(rm, 0);
522
            mId = applyPV(rm);
571
        } catch (Exception e)
523
        } catch (Exception e)
572
        {
524
        {
573
        }
525
        }
574
    }
526
    }
575
 
527
 
576
    /**
528
    /**
-
 
529
     * Constructor for unit test purposes
-
 
530
     * Performs a partial copy of a package - sufficient for test purposes
-
 
531
     * @param base      - Base package  
-
 
532
     * @param newPvId   - New pvid of the package
-
 
533
     */
-
 
534
 
-
 
535
    public Package(int newPvId, Package base) {
-
 
536
        
-
 
537
        mId = newPvId;
-
 
538
        mPid = base.mPid;
-
 
539
        mName = base.mName;
-
 
540
        mExtension = base.mExtension;
-
 
541
        mVersion = base.mVersion;
-
 
542
        mAlias = base.mAlias;
-
 
543
        mVcsTag = base.mVcsTag;
-
 
544
        mFixedVersion = base.mFixedVersion;
-
 
545
        mChangeType = base.mChangeType;
-
 
546
        mRippleField = base.mRippleField;
-
 
547
        mBuildTime = base.mBuildTime;
-
 
548
        mHasAutomatedUnitTests = base.mHasAutomatedUnitTests;
-
 
549
        mSeqId = base.mSeqId;
-
 
550
        
-
 
551
        mBuildFailureEmailCollection = new Vector<String>(base.mBuildFailureEmailCollection);
-
 
552
        mPackageDependencyCollection = new Vector<Package>(base.mPackageDependencyCollection);
-
 
553
        mDependencyIDCollection = new Vector<Integer>(base.mDependencyIDCollection);
-
 
554
        mDependencyCollection = new Vector<String>(base.mDependencyCollection);
-
 
555
        mBuildStandardCollection = new Vector<BuildStandard>( base.mBuildStandardCollection);
-
 
556
        
-
 
557
    }
-
 
558
    
-
 
559
    /** Generate a nice text string useful for debugging
-
 
560
     * 
-
 
561
     */
-
 
562
    public String toString()
-
 
563
    {
-
 
564
        return mId + ":" + mAlias;
-
 
565
    }
-
 
566
 
-
 
567
    /**
577
     * accessor for unit test purposes
568
     * accessor for unit test purposes
578
     */
569
     */
579
    public int getId()
570
    public int getId()
580
    {
571
    {
581
        return mId;
572
        return mId;
Line 587... Line 578...
587
    public String getVersion()
578
    public String getVersion()
588
    {
579
    {
589
        return mVersion;
580
        return mVersion;
590
    }
581
    }
591
    
582
    
592
    
583
    /**
593
    /** Set the sequence of all packages in the list
-
 
594
     *  Used so that the UnitTestComparator function can preserve the
-
 
595
     *  basic ordering of the list 
584
     * accessor for unit test purposes
596
     */
585
     */
597
    public static void setSequence(ArrayList<Package> al)
586
    public String getNextVersion()
598
    {
587
    {
599
        int seq = 1;
-
 
600
        for (Iterator<Package> it = al.iterator(); it.hasNext(); )
-
 
601
        {
-
 
602
            Package p = it.next();
-
 
603
            p.mSeqId = seq++;
588
        return mNextVersion;
604
        }
-
 
605
    }
589
    }
606
    
590
    
607
    /** Comparator for sorting unit tests
-
 
608
     *      Used to sort a list of packages such that the package with the lowest mTestBuildInstruction
-
 
609
     *      is at the head of the list.
-
 
610
     *      
-
 
611
     *      Packages without a unit test are sorted by mSeqId to preserve the basic 
-
 
612
     *      ordering of the list. 
-
 
613
     */
-
 
614
    public static final Comparator<Package> UnitTestComparator = new Comparator<Package>() {
-
 
615
        
-
 
616
        /**
-
 
617
         * Returns -ve: p1 is less than p2
-
 
618
         *           0: p1 = p2
-
 
619
         *         +ve: p1 > p2
-
 
620
         */
-
 
621
        public int compare (Package p1, Package p2) {
-
 
622
            // Both are test builds
-
 
623
            if (p1.mTestBuildInstruction > 0 && p2.mTestBuildInstruction > 0)
-
 
624
                return p1.mTestBuildInstruction - p2.mTestBuildInstruction;
-
 
625
            
-
 
626
            // Neither is a test build
-
 
627
            if (p1.mTestBuildInstruction == 0 && p2.mTestBuildInstruction == 0)
-
 
628
                return p1.mSeqId - p2.mSeqId;
-
 
629
            
-
 
630
            // Only one is a test build
-
 
631
            if (p1.mTestBuildInstruction > 0)
-
 
632
                return -1;
-
 
633
            
-
 
634
            return 1;
-
 
635
        }
-
 
636
    };
-
 
637
 
591
 
638
    /**
592
    /**
639
     * returns true if mBuildStandardCollection is not empty
593
     * returns true if mBuildStandardCollection is not empty
640
     */
594
     */
641
    boolean isReproducible()
595
    boolean isReproducible()
642
    {
596
    {
643
        mLogger.debug("isReproducible on Package " + mName);
597
        mLogger.debug("isReproducible on Package {}", mName);
644
        boolean retVal = ! mBuildStandardCollection.isEmpty();
598
        boolean retVal = ! mBuildStandardCollection.isEmpty();
645
        mLogger.info("isReproducible returned " + retVal);
599
        mLogger.info("isReproducible returned {}", retVal);
646
        return retVal;
600
        return retVal;
647
    }
601
    }
648
 
602
 
649
 
603
 
650
    /**
604
    /**
651
     * returns true if at least one of its BuildStandards has mGeneric true
605
     * returns true if at least one of its BuildStandards has mGeneric true
652
     */
606
     */
653
    boolean isGeneric()
607
    boolean isGeneric()
654
    {
608
    {
655
        mLogger.debug("isGeneric on Package " + mName);
609
        mLogger.debug("isGeneric on Package {}", mName);
656
        boolean retVal = false;
610
        boolean retVal = false;
657
        for (Iterator<BuildStandard> it = mBuildStandardCollection.iterator(); it.hasNext();)
611
        for (Iterator<BuildStandard> it = mBuildStandardCollection.iterator(); it.hasNext();)
658
        {
612
        {
659
            BuildStandard buildStandard = it.next();
613
            BuildStandard buildStandard = it.next();
660
 
614
 
Line 663... Line 617...
663
                retVal = true;
617
                retVal = true;
664
                break;
618
                break;
665
            }
619
            }
666
        }
620
        }
667
 
621
 
668
        mLogger.info("isGeneric returned " + retVal);
622
        mLogger.info("isGeneric returned {}", retVal);
669
        return retVal;
623
        return retVal;
670
    }
624
    }
671
    
625
    
672
    /**
626
    /**
673
     * Returns true if at least one of the packages build standards can be 
627
     * Returns true if at least one of the packages build standards can be 
Line 821... Line 775...
821
        return false;
775
        return false;
822
      
776
      
823
    }
777
    }
824
 
778
 
825
    /**
779
    /**
826
     * Applies the required version number change
780
     * Applies the required version number change. Will calculate mNextVersion
-
 
781
     * while not changing mVersion.
827
     * 
782
     * 
828
     * @param releaseManager    Release Manager instance to work against
783
     * @param releaseManager    Release Manager instance to work against
829
     * @param rtag_id           Release Identifier
-
 
830
     * 
784
     * 
831
     * @return 0 on success
785
     * @return 0 : success
832
     *         1 on cannot work with non standard versioning
786
     *         1 : cannot work with non standard versioning
833
     *         2 on ripple field limitations prevent a ripple build
787
     *         2 : ripple field limitations prevent a ripple build
834
     *         3 on Invalid Change Type
788
     *         3 : Invalid Change Type
835
     * @exception Exception
789
     * @exception Exception
836
     */
790
     */
-
 
791
    
837
    int applyPV(ReleaseManager releaseManager, int rtag_id) throws Exception
792
    int applyPV(ReleaseManager releaseManager) throws Exception
838
    {
793
    {
839
        String logInfo = "applyPV," + mName;
794
        String logInfo = "applyPV," + mName;
840
        mLogger.debug("applyPV on Package " + mName);
795
        mLogger.debug("applyPV on Package " + mName);
-
 
796
        
-
 
797
        //
-
 
798
        //  This method used to actually perform the version change
-
 
799
        //  Now it just calculates the potential value
-
 
800
        //  Must not alter mVersion as it will be used if the package is not selected to be built,
-
 
801
        //  but some of the code assumes that it can be.
-
 
802
        //
-
 
803
        String originalVersion = mVersion;
-
 
804
        
841
        //
805
        //
842
        // Four scenarios, only applyPV for 3 of them
806
        // Four scenarios, only applyPV for 3 of them
843
        // mDirectlyPlanned mIndirectlyPlanned mArchivalExistence mForcedRipple
807
        // mDirectlyPlanned mIndirectlyPlanned mArchivalExistence mForcedRipple
844
        // Action
808
        // Action
845
        // WIP/test build exists: true true don't care don't care applyPV
809
        // WIP/test build exists: true true don't care don't care applyPV
Line 850... Line 814...
850
        if (!mDirectlyPlanned && mIndirectlyPlanned && !mArchivalExistence && mForcedRippleInstruction == 0)
814
        if (!mDirectlyPlanned && mIndirectlyPlanned && !mArchivalExistence && mForcedRippleInstruction == 0)
851
        {
815
        {
852
            // the package has an mIndirectlyPlanned flag set true in daemon
816
            // the package has an mIndirectlyPlanned flag set true in daemon
853
            // mode because the package does not exist in an archive
817
            // mode because the package does not exist in an archive
854
            // do not apply a different package version
818
            // do not apply a different package version
855
            mLogger.info("applyPV. Rebuild Package " + mName);
819
            mLogger.info("applyPV. Rebuild Package {}", mName);
856
            releaseManager.claimVersion(mPid, mVersion + mExtension, rtag_id);
-
 
857
            mLogger.info("applyPv returned 0");
820
            mLogger.info("applyPv returned 0");
858
            return 0;
821
            return 0;
859
        }
822
        }
860
 
823
 
861
        // override - no longer doing a rebuild - version number change from this point on
824
        // override - no longer doing a rebuild - version number change from this point on
Line 876... Line 839...
876
        // Detect invalid change type
839
        // Detect invalid change type
877
        // Flagged when package instance is created
840
        // Flagged when package instance is created
878
        //
841
        //
879
        if (mChangeType.mUnknown)
842
        if (mChangeType.mUnknown)
880
        {
843
        {
881
            mLogger.info("Package Version specified on Package " + mName + "New Version:" + mVersion);
844
            mLogger.info("Package Version specified on Package {} New Version: {}", mName, mVersion);
882
            mLogger.info("applyPv returned 3");
845
            mLogger.info("applyPv returned 3");
883
            return 3;
846
            return 3;
884
        }
847
        }
885
 
848
 
886
        // If we are not calculating the new package version because the user
849
        // If we are not calculating the new package version because the user
887
        // has fixed the version of the package. We are given the new package version.
850
        // has fixed the version of the package. We are given the new package version.
888
        if (mChangeType.mFixed)
851
        if (mChangeType.mFixed)
889
        {
852
        {
890
            // mVersion is already setup
853
            // mVersion is already setup
891
 
854
 
892
            mVersion = mFixedVersion;
855
            mNextVersion = mFixedVersion;
893
            mLogger.info("Package Version specified on Package " + mName + "New Version:" + mVersion);
856
            mLogger.info("Package Version specified on Package {} New Version: {}", mName,  mVersion);
894
            releaseManager.claimVersion(mPid, mVersion + mExtension, rtag_id);
-
 
895
            mLogger.info("applyPv returned 0");
857
            mLogger.info("applyPv returned 0");
896
            return 0;
858
            return 0;
897
        }
859
        }
898
 
860
 
899
        // We need to calculate the new version number
861
        // We need to calculate the new version number
Line 925... Line 887...
925
            // Can ripple a .cots package under very controlled conditions
887
            // Can ripple a .cots package under very controlled conditions
926
            // Its ends with a .patchBuild field
888
            // Its ends with a .patchBuild field
927
            // Package is marked as ripple via build number
889
            // Package is marked as ripple via build number
928
            // Change type of Major and Minor are not allowed
890
            // Change type of Major and Minor are not allowed
929
            //
891
            //
930
            if (!mChangeType.mMajor && !mChangeType.mMinor && mRippleField.mBuild && mExtension.compareTo(".cots") == 0
892
            if (!mChangeType.mMajor && !mChangeType.mMinor && mRippleField.mBuild && mExtension.compareTo(".cots") == 0 && field.length > 0)
931
                    && field.length > 0)
-
 
932
            {
893
            {
933
                // DEVI 52782
-
 
934
                // allow and work with (ripple build) versions a.b.c.d....xxxx
894
                // allow and work with (ripple build) versions a.b.c.d....xxxx
935
                // where xxxx.length > 3
895
                // where xxxx.length > 3
936
                String patchStr = field[field.length - 1];
896
                String patchStr = field[field.length - 1];
937
                int patchLen = patchStr.length();
897
                int patchLen = patchStr.length();
938
 
898
 
Line 954... Line 914...
954
            }
914
            }
955
        }
915
        }
956
 
916
 
957
        if (nonStandardCotsVersion.length() == 0 && patch.value < 1000 && field[2].substring(0, 1).compareTo("0") != 0)
917
        if (nonStandardCotsVersion.length() == 0 && patch.value < 1000 && field[2].substring(0, 1).compareTo("0") != 0)
958
        {
918
        {
959
            mLogger.info("applyPV accomodate old style mVersion of the form 1.0.1");
919
            mLogger.info("applyPV accomodate old style Version of the form 1.0.1");
960
            patch.value = patch.value * 1000;
920
            patch.value = patch.value * 1000;
961
        }
921
        }
962
 
922
 
963
        // mChangeType overrides mRippleField
923
        // mChangeType overrides mRippleField
964
        do
924
        do
Line 967... Line 927...
967
            {
927
            {
968
                logInfo += ",CT Major";
928
                logInfo += ",CT Major";
969
                if (!incrementFieldsAccordingToLimits(4, major, minor, patch))
929
                if (!incrementFieldsAccordingToLimits(4, major, minor, patch))
970
                {
930
                {
971
                    mLogger.info("applyPv returned 2");
931
                    mLogger.info("applyPv returned 2");
-
 
932
                    mVersion = originalVersion;
972
                    return 2;
933
                    return 2;
973
                }
934
                }
974
            } else if (mChangeType.mMinor)
935
            } else if (mChangeType.mMinor)
975
            {
936
            {
976
                logInfo += ",CT Minor";
937
                logInfo += ",CT Minor";
977
                if (!incrementFieldsAccordingToLimits(3, major, minor, patch))
938
                if (!incrementFieldsAccordingToLimits(3, major, minor, patch))
978
                {
939
                {
979
                    mLogger.info("applyPv returned 2");
940
                    mLogger.info("applyPv returned 2");
-
 
941
                    mVersion = originalVersion;
980
                    return 2;
942
                    return 2;
981
                }
943
                }
982
            } else if (mChangeType.mPatch)
944
            } else if (mChangeType.mPatch)
983
            {
945
            {
984
                logInfo += ",CT Patch";
946
                logInfo += ",CT Patch";
985
                if (!incrementFieldsAccordingToLimits(2, major, minor, patch))
947
                if (!incrementFieldsAccordingToLimits(2, major, minor, patch))
986
                {
948
                {
987
                    mLogger.info("applyPv returned 2");
949
                    mLogger.info("applyPv returned 2");
-
 
950
                    mVersion = originalVersion;
988
                    return 2;
951
                    return 2;
989
                }
952
                }
990
            } else
953
            } else
991
            {
954
            {
992
                if (mRippleField.mMajor)
955
                if (mRippleField.mMajor)
993
                {
956
                {
994
                    logInfo += ",R Major";
957
                    logInfo += ",R Major";
995
                    major.value++;
958
                    major.value++;
996
                    mLogger.info("applyPV mRippleField.mMajor " + major.value);
959
                    mLogger.info("applyPV mRippleField.mMajor {}", major.value);
997
                    minor.value = 0;
960
                    minor.value = 0;
998
                    patch.value = 0;
961
                    patch.value = 0;
999
                } else if (mRippleField.mMinor)
962
                } else if (mRippleField.mMinor)
1000
                {
963
                {
1001
                    logInfo += ",R Minor";
964
                    logInfo += ",R Minor";
1002
                    minor.value++;
965
                    minor.value++;
1003
                    mLogger.info("applyPV mRippleField.mMinor " + minor.value);
966
                    mLogger.info("applyPV mRippleField.mMinor {}", minor.value);
1004
                    patch.value = 0;
967
                    patch.value = 0;
1005
                } else if (mRippleField.mPatch)
968
                } else if (mRippleField.mPatch)
1006
                {
969
                {
1007
                    logInfo += ",R Patch";
970
                    logInfo += ",R Patch";
1008
                    patch.value = ((patch.value / 1000) + 1) * 1000; 
971
                    patch.value = ((patch.value / 1000) + 1) * 1000; 
1009
                    mLogger.info("applyPV mRippleField.mPatch " + patch.value);
972
                    mLogger.info("applyPV mRippleField.mPatch {}", patch.value);
1010
                } else if (mRippleField.mBuild)
973
                } else if (mRippleField.mBuild)
1011
                {
974
                {
1012
                    logInfo += ", R Build";
975
                    logInfo += ", R Build";
1013
                    patch.value++;
976
                    patch.value++;
1014
                    mLogger.info("applyPV mRippleField.mBuild " + patch.value);
977
                    mLogger.info("applyPV mRippleField.mBuild {}", patch.value);
1015
                } else
978
                } else
1016
                {
979
                {
1017
                    if (!incrementFieldsAccordingToLimits(1, major, minor, patch))
980
                    if (!incrementFieldsAccordingToLimits(1, major, minor, patch))
1018
                    {
981
                    {
1019
                        mLogger.info("applyPv returned 2");
982
                        mLogger.info("applyPv returned 2");
-
 
983
                        mVersion = originalVersion;
1020
                        return 2;
984
                        return 2;
1021
                    }
985
                    }
1022
                }
986
                }
1023
            }
987
            }
1024
 
988
 
Line 1040... Line 1004...
1040
            {
1004
            {
1041
                mVersion += "0";
1005
                mVersion += "0";
1042
            }
1006
            }
1043
 
1007
 
1044
            mVersion += String.valueOf(patch.value);
1008
            mVersion += String.valueOf(patch.value);
1045
        } while (exists(releaseManager, rtag_id));
1009
        } while (exists(releaseManager));
1046
 
1010
 
1047
        logInfo += ", Claim:" + mVersion;
1011
        logInfo += ", Next Version:" + mVersion;
1048
        releaseManager.claimVersion(mPid, mVersion + mExtension, rtag_id);
-
 
1049
        mLogger.error(logInfo);
1012
        mLogger.error(logInfo);
1050
        mLogger.info("applyPv returned 0");
1013
        mLogger.info("applyPv returned 0");
-
 
1014
        mNextVersion = mVersion;
-
 
1015
        mVersion = originalVersion;
1051
        return 0;
1016
        return 0;
1052
    }
1017
    }
1053
 
1018
 
1054
    /**
1019
    /**
1055
     * increments fields according to mRippleField.mLimit if necessary will
1020
     * increments fields according to mRippleField.mLimit if necessary will
Line 1188... Line 1153...
1188
 
1153
 
1189
        return retVal;
1154
        return retVal;
1190
    }
1155
    }
1191
 
1156
 
1192
    /**
1157
    /**
1193
     * Check if a Package Version exists in dpkg_archive or the Release Manager Database
1158
     * Check if a specified Version of the package exists in dpkg_archive or the Release Manager Database
1194
     * 
1159
     * 
1195
     * @param releaseManager Release Manager Instance
1160
     * @param releaseManager Release Manager Instance
1196
     * @param rtag_id        Release Tag Identifier
-
 
1197
     * 
1161
     * 
1198
     * @return True if the Package Version exists within the Release Manager Database
1162
     * @return True if the Package Version exists within the Release Manager Database
1199
     * @exception Exception
1163
     * @exception Exception
1200
     */
1164
     */
1201
    private boolean exists(ReleaseManager releaseManager, int rtag_id) throws Exception
1165
    private boolean exists(ReleaseManager releaseManager) throws Exception
1202
    {
1166
    {
1203
        mLogger.debug("exists on Package " + mName + " version " + mVersion + " extension " + mExtension);
1167
        mLogger.debug("exists on Package " + mName + " version " + mVersion + " extension " + mExtension);
1204
        boolean retVal = false;
1168
        boolean retVal = false;
1205
 
1169
 
1206
        if (!releaseManager.mUseDatabase)
1170
        if (!releaseManager.mUseDatabase)
Line 1389... Line 1353...
1389
    }
1353
    }
1390
 
1354
 
1391
    /**
1355
    /**
1392
     * Adds email to mBuildFailureEmailCollection.
1356
     * Adds email to mBuildFailureEmailCollection.
1393
     * Do not worry about multiple entries. These will be handled when the data is extracted
1357
     * Do not worry about multiple entries. These will be handled when the data is extracted
1394
     * @param   email   - Email address
1358
     * @param   email   - Email address. Null is allowed and will not be added
1395
     */
1359
     */
1396
    public void addEmail(String email)
1360
    public void addEmail(String email)
1397
    {
1361
    {
1398
        mBuildFailureEmailCollection.add(email);
-
 
1399
    }
-
 
1400
 
-
 
1401
    /**
-
 
1402
     * Transfer the Test Build Email information to the packages email list
-
 
1403
     */
-
 
1404
    void setTestEmail()
-
 
1405
    {
-
 
1406
        mBuildFailureEmailCollection.clear();
-
 
1407
        addEmail(mTestBuildEmail);
1362
        if (email != null) 
1408
    }
-
 
1409
 
-
 
1410
    /**
-
 
1411
     * Transfer the Test Build Dependency information to the packages dependency collection
-
 
1412
     */
-
 
1413
    void setTestDependencyCollection()
-
 
1414
    {
-
 
1415
        // does not worry about mPackageDendencyCollection by design
-
 
1416
        mDependencyCollection.clear();
-
 
1417
 
-
 
1418
        for (Iterator<String> it = mTestBuildDependencyCollection.iterator(); it.hasNext();)
-
 
1419
        {
1363
        {
1420
            String dependency = it.next();
-
 
1421
            mDependencyCollection.add(dependency);
-
 
1422
        }
-
 
1423
    }
-
 
1424
 
-
 
1425
    /**
-
 
1426
     * Transfer the Test Build Build Standard information to the packages build standard collection
-
 
1427
     */
-
 
1428
    void setTestBuildStandardCollection()
-
 
1429
    {
-
 
1430
        mBuildStandardCollection.clear();
-
 
1431
 
-
 
1432
        for (Iterator<BuildStandard> it = mTestBuildStandardCollection.iterator(); it.hasNext();)
-
 
1433
        {
-
 
1434
            BuildStandard buildStandard = it.next();
-
 
1435
            mBuildStandardCollection.add(buildStandard);
1364
            mBuildFailureEmailCollection.add(email);
1436
        }
1365
        }
1437
    }
1366
    }
1438
 
1367
 
1439
    /**
1368
    /**
1440
     * End of Processing for a Test Build
1369
     * End of Processing for a Test Build
Line 1524... Line 1453...
1524
        mLogger.error("completeTest. Returning");
1453
        mLogger.error("completeTest. Returning");
1525
    }
1454
    }
1526
 
1455
 
1527
 
1456
 
1528
    /**
1457
    /**
1529
     * Returns true if the package is a part of a circular dependency
1458
     * Returns true if the package is a part of a circular dependency within the provided collection
1530
     * 
1459
     * 
1531
     * If the package depends on a package with a circular dependency then the function
1460
     * If the package depends on a package with a circular dependency then the function
1532
     * will return false.
1461
     * will return false.
1533
     */
1462
     */
1534
    public boolean hasCircularDependency(RippleEngine ripEng)
1463
    public boolean hasCircularDependency(ArrayList<Package> packageCollection)
1535
    {
1464
    {
1536
        mLogger.debug("hasCircularDependency: " + mAlias);
1465
        mLogger.debug("hasCircularDependency: {}", mAlias);
1537
        boolean retVal = detectCircularDependency(mAlias, ripEng, null);
1466
        boolean retVal = detectCircularDependency(mAlias, packageCollection, null);
1538
        mLogger.info("hasCircularDependency returned " + retVal);
1467
        mLogger.info("hasCircularDependency returned {} ", retVal);
1539
        return retVal;
1468
        return retVal;
1540
    }
1469
    }
-
 
1470
    
-
 
1471
    /** Reset the circular dependency testing information
-
 
1472
     * 
-
 
1473
     * @param packageCollection - Collection of packages to process
-
 
1474
     */
-
 
1475
    public static void resetCircularDependency(ArrayList<Package> packageCollection)
-
 
1476
    {
-
 
1477
        for (Iterator<Package> it = packageCollection.iterator(); it.hasNext(); )
-
 
1478
        {
-
 
1479
            Package p = it.next();
-
 
1480
            p.mCheckedCircularDependency = false;
-
 
1481
            p.mHasCircularDependency = false;
-
 
1482
            p.mBreadCrumb = 0;
-
 
1483
        }
-
 
1484
    }
1541
 
1485
 
1542
    /**
1486
    /**
1543
     * Returns true is a part of a circular dependency
1487
     * Returns true is a part of a circular dependency
1544
     * Will examine all the packages sub dependencies and mark those that do have a
1488
     * Will examine all the packages sub dependencies and mark those that do have a
1545
     * circular dependency.
1489
     * circular dependency.
Line 1550... Line 1494...
1550
     * 
1494
     * 
1551
     *  Assumes that the caller will walk ALL packages and flag those with a circular
1495
     *  Assumes that the caller will walk ALL packages and flag those with a circular
1552
     *  dependence AND those that depend on that package.
1496
     *  dependence AND those that depend on that package.
1553
     * 
1497
     * 
1554
     */
1498
     */
1555
    private boolean detectCircularDependency(String alias, RippleEngine ripEng, Package parent)
1499
    private boolean detectCircularDependency(String alias, ArrayList<Package> packageCollection, Package parent)
1556
    {
1500
    {
1557
        mLogger.debug("detectCircularDependency");
1501
        mLogger.debug("detectCircularDependency");
1558
        boolean retVal = false;
1502
        boolean retVal = false;
1559
        
1503
        
1560
        // if this package has yet to be checked for circular dependency
1504
        // if this package has yet to be checked for circular dependency
Line 1580... Line 1524...
1580
                
1524
                
1581
                // Recurse down the dependencies and sub dependencies
1525
                // Recurse down the dependencies and sub dependencies
1582
                for (Iterator<String> it2 = mDependencyCollection.iterator(); it2.hasNext();)
1526
                for (Iterator<String> it2 = mDependencyCollection.iterator(); it2.hasNext();)
1583
                {
1527
                {
1584
                    String dependencyAlias = it2.next();
1528
                    String dependencyAlias = it2.next();
-
 
1529
                    
-
 
1530
                    // Scan the collection looking for the specified package alias
-
 
1531
                    for (Iterator<Package> it = packageCollection.iterator(); it.hasNext();)
-
 
1532
                    {
-
 
1533
                        Package dependency = it.next();
-
 
1534
 
1585
                    Package dependency = ripEng.findPackage(dependencyAlias);
1535
                        if ( dependency.mAlias.compareTo( dependencyAlias ) == 0 )
-
 
1536
                        {
1586
                    dependency.detectCircularDependency(alias, ripEng, this);
1537
                            dependency.detectCircularDependency(alias, packageCollection, this);
-
 
1538
                            break;
-
 
1539
                        }
-
 
1540
                    }
1587
                }
1541
                }
1588
                
1542
                
1589
                if (mBreadCrumb == 2)
1543
                if (mBreadCrumb == 2)
1590
                {
1544
                {
1591
                    mHasCircularDependency = true;
1545
                    mHasCircularDependency = true;
Line 1601... Line 1555...
1601
            mCheckedCircularDependency = true;
1555
            mCheckedCircularDependency = true;
1602
        } 
1556
        } 
1603
 
1557
 
1604
        // return the persisted circular dependency outcome
1558
        // return the persisted circular dependency outcome
1605
        retVal = mHasCircularDependency;
1559
        retVal = mHasCircularDependency;
1606
        mLogger.info("detectCircularDependency 2 returned " + retVal);
1560
        mLogger.info("detectCircularDependency 2 returned {}", retVal);
1607
        return retVal;
1561
        return retVal;
1608
    }
1562
    }
-
 
1563
    
-
 
1564
    /** Set the sequence of all packages in the list
-
 
1565
     *  Used so that the Unit Tests function can preserve the basic ordering of the list 
-
 
1566
     */
-
 
1567
    public static void setSequence(ArrayList<Package> al)
-
 
1568
    {
-
 
1569
        int seq = 1;
-
 
1570
        for (Iterator<Package> it = al.iterator(); it.hasNext(); )
-
 
1571
        {
-
 
1572
            Package p = it.next();
-
 
1573
            p.mSeqId = seq++;
-
 
1574
        }
-
 
1575
    }
1609
 
1576
 
-
 
1577
    /** Reset the processed flag on a collection of packages
-
 
1578
     * 
-
 
1579
     */
-
 
1580
    public static void resetProcessed (ArrayList<Package> al)
-
 
1581
    {
-
 
1582
        for (Iterator<Package> it = al.iterator(); it.hasNext(); )
-
 
1583
        {
-
 
1584
            Package p = it.next();
-
 
1585
            p.mIsProcessed = false;
-
 
1586
            p.mProcessed = false;
-
 
1587
            if (p.mBuildFile > 0)
-
 
1588
                p.mBuildFile = 0;
-
 
1589
        }
-
 
1590
    }
-
 
1591
    
-
 
1592
    /** Comparator for sorting package collections by mSeqId
-
 
1593
     *  Used to preserve order for unit testing
-
 
1594
     */
-
 
1595
    public static final Comparator<Package> SeqComparator = new Comparator<Package>() {
-
 
1596
        
-
 
1597
        /**
-
 
1598
         * Returns -ve: p1 is less than p2
-
 
1599
         *           0: p1 = p2
-
 
1600
         *         +ve: p1 > p2
-
 
1601
         */
-
 
1602
        public int compare (Package p1, Package p2) {
-
 
1603
                return p1.mSeqId - p2.mSeqId;
-
 
1604
        }
-
 
1605
    };
-
 
1606
    
1610
    /**
1607
    /**
1611
     * entity class supporting the ERG version numbering standard:
1608
     * entity class supporting the ERG version numbering standard:
1612
     * <major>.<minor>.<patch/build> patch/build is at least a 4 digit number
1609
     * <major>.<minor>.<patch/build> patch/build is at least a 4 digit number
1613
     * whose last 3 digits represent the build
1610
     * whose last 3 digits represent the build
1614
     */
1611
     */
Line 1817... Line 1814...
1817
            mUnknown = true;
1814
            mUnknown = true;
1818
        }
1815
        }
1819
 
1816
 
1820
    }
1817
    }
1821
 
1818
 
-
 
1819
    /**
-
 
1820
     *  Add a package dependency
-
 
1821
     *  UTF Use
-
 
1822
     *  @param p - The package to add as a dependent
-
 
1823
     *  @return - The current package to allow chaining of calls
-
 
1824
     */
-
 
1825
    public Package addDependency(Package p) {
-
 
1826
        mDependencyCollection.add(p.mAlias);
-
 
1827
        mDependencyIDCollection.add(p.mId);
-
 
1828
        return this;
-
 
1829
    }
-
 
1830
 
-
 
1831
    /** Clear the packages list of dependencies
-
 
1832
     *  UTF use
-
 
1833
     *  @return - The current package to allow chaining of calls
-
 
1834
     */
-
 
1835
    public Package resetDependencies() {
-
 
1836
        mDependencyCollection.clear();
-
 
1837
        mDependencyIDCollection.clear();
-
 
1838
        return this;
-
 
1839
    }
-
 
1840
 
1822
}
1841
}