Subversion Repositories DevTools

Rev

Rev 4280 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4280 Rev 4285
Line 10... Line 10...
10
 
10
 
11
import com.erggroup.buildtool.smtp.Smtpsend;
11
import com.erggroup.buildtool.smtp.Smtpsend;
12
 
12
 
13
public class Package
13
public class Package
14
{
14
{
15
  /**name of package, must not contain spaces
15
	/**
16
   * @attribute
16
	 * name of package, must not contain spaces
17
   */
17
	 * 
18
  String mName = new String();
18
	 * @attribute
19
 
19
	 */
20
  /**package scope
20
	String mName = new String();
21
   * @attribute
21
 
22
   */
22
	/**
23
  String mExtension = new String();
23
	 * package scope
24
 
24
	 * 
25
  /**instance identifier
25
	 * @attribute
26
   * @attribute
26
	 */
27
   */
27
	String mExtension = new String();
28
  String mVersion = new String();
28
 
29
 
29
	/**
30
  /** Version string as specified by the user. Used with a ripple
30
	 * instance identifier
31
   *  type of 'F'
31
	 * 
32
   */
32
	 * @attribute
33
  String mFixedVersion = new String();
33
	 */
34
 
34
	String mVersion = new String();
35
  /**unique identifier
35
 
36
   * for daemon builds = mName + mExtension
36
	/**
37
   * for escrow builds = mName + mVersion + mExtension
37
	 * Version string as specified by the user. Used with a ripple type of 'F'
38
   * @attribute
38
	 */
39
   */
39
	String mFixedVersion = new String();
40
  String mAlias = new String();
40
 
41
 
41
	/**
42
  /**Version Control System Tag
42
	 * unique identifier for daemon builds = mName + mExtension for escrow
43
   * @attribute
43
	 * builds = mName + mVersion + mExtension
44
   */
44
	 * 
45
  String mVcsTag = new String();
45
	 * @attribute
46
 
46
	 */
47
  /**build standards
47
	String mAlias = new String();
48
   * @attribute
48
 
49
   */
49
	/**
50
  Vector<BuildStandard> mBuildStandardCollection = new Vector<BuildStandard>();
50
	 * Version Control System Tag
51
 
51
	 * 
52
  /**GBE_MACHTYPE used to build generic packages for this baseline
52
	 * @attribute
53
   * only has meaning in the daemon build, not the escrow build
53
	 */
54
   * accessed by BuildStandard::getPlatform, getBuildStandard
54
	String mVcsTag = new String();
55
   * @attribute
55
 
56
   */
56
	/**
57
  public static final String mGenericMachtype = System.getenv("GBE_MACHTYPE");
57
	 * build standards
58
 
58
	 * 
59
  /**build dependencies by package alias
59
	 * @attribute
60
   * @attribute
60
	 */
61
   */
61
	Vector<BuildStandard> mBuildStandardCollection = new Vector<BuildStandard>();
62
  Vector<String> mDependencyCollection = new Vector<String>();
62
 
63
 
63
	/**
64
  /**primary package version key pv_id in database
64
	 * GBE_MACHTYPE used to build generic packages for this baseline only has
65
   * @attribute
65
	 * meaning in the daemon build, not the escrow build accessed by
66
   */
66
	 * BuildStandard::getPlatform, getBuildStandard
67
  int mId;
67
	 * 
68
 
68
	 * @attribute
69
  /**indication of the nature of change
69
	 */
70
   * @attribute
70
	public static final String mGenericMachtype = System.getenv("GBE_MACHTYPE");
71
   */
71
 
72
  Package.VersionNumberingStandard mChangeType = new VersionNumberingStandard();
72
	/**
73
 
73
	 * build dependencies by package alias
74
  /**determines what field is rippled on a package version whose dependencies have changed
74
	 * 
75
   * @attribute
75
	 * @attribute
76
   */
76
	 */
77
  Package.VersionNumberingStandard mRippleField = new VersionNumberingStandard();
77
	Vector<String> mDependencyCollection = new Vector<String>();
78
 
78
 
79
  /**interested owners
79
	/**
80
   * @attribute
80
	 * primary package version key pv_id in database
81
   */
81
	 * 
82
  private Vector<String> mBuildFailureEmailCollection = new Vector<String>();
82
	 * @attribute
83
 
83
	 */
84
  /**when true will trigger unit tests as part of the package build phase in daemon mode
84
	int mId;
85
   * @attribute
85
 
86
   */
86
	/**
87
  boolean mHasAutomatedUnitTests = false;
87
	 * indication of the nature of change
88
 
88
	 * 
89
  /**when true, do not ripple this package through packages which are dependent upon it in daemon mode
89
	 * @attribute
90
   * @attribute
90
	 */
91
   */
91
	Package.VersionNumberingStandard mChangeType = new VersionNumberingStandard();
92
  boolean mAdvisoryRipple = false;
92
 
93
 
93
	/**
94
  /**determines the build file the package is built in, or not
94
	 * determines what field is rippled on a package version whose dependencies
95
   *  1 Post Plan: buildfile - Result of planning
95
	 * have changed
96
   *  2 Post Plan: Future build requirement
96
	 * 
97
   *  3 Post Plan: Package has no build requiremnt
97
	 * @attribute
98
   *  0 not yet processed (initial value)
98
	 */
99
   * -1 not reproducible
99
	Package.VersionNumberingStandard mRippleField = new VersionNumberingStandard();
100
   * -2 not reproducible on the build platforms configured for this release
100
 
101
   * -3 do not ripple
101
	/**
102
   * -4 directly dependent on package versions not in the baseline
102
	 * interested owners
103
   * -5 indirectly dependent on package versions which are not reproducible
103
	 * 
104
   *    because of -1, -2 (escrow), -3 (daemon), -4, -6
104
	 * @attribute
105
   * -6 circular dependency
105
	 */
106
   * @attribute
106
	private Vector<String> mBuildFailureEmailCollection = new Vector<String>();
107
   */
107
 
108
  int mBuildFile = 0;
108
	/**
109
 
109
	 * when true will trigger unit tests as part of the package build phase in
110
  /**build dependencies by package
110
	 * daemon mode
111
   * @attribute
111
	 * 
112
   */
112
	 * @attribute
113
  Vector<Package> mPackageDependencyCollection = new Vector<Package>();
113
	 */
114
 
114
	boolean mHasAutomatedUnitTests = false;
115
  /**used for escrow build purposes
115
 
116
   * set true when a package has been processed
116
	/**
117
   * @attribute
117
	 * when true, do not ripple this package through packages which are
118
   */
118
	 * dependent upon it in daemon mode
119
  boolean mProcessed = false;
119
	 * 
120
 
120
	 * @attribute
121
  /**set true for WIP package versions
121
	 */
122
   * only used in daemon mode
122
	boolean mAdvisoryRipple = false;
123
   * @attribute
123
 
124
   */
124
	/**
125
  boolean mDirectlyPlanned = false;
125
	 * determines the build file the package is built in, or not 1 Post Plan:
126
 
126
	 * buildfile - Result of planning 2 Post Plan: Future build requirement 3
127
  /**set true when it is determined to be ripple built
127
	 * Post Plan: Package has no build requiremnt 0 not yet processed (initial
128
   * @attribute
128
	 * value) -1 not reproducible -2 not reproducible on the build platforms
129
   */
129
	 * configured for this release -3 do not ripple -4 directly dependent on
130
  boolean mIndirectlyPlanned = false;
130
	 * package versions not in the baseline -5 indirectly dependent on package
131
 
131
	 * versions which are not reproducible because of -1, -2 (escrow), -3
132
  /**non zero instruction number when it is determined to be ripple built by force
132
	 * (daemon), -4, -6 -6 circular dependency
133
   * @attribute
133
	 * 
134
   */
134
	 * @attribute
135
  int mForcedRippleInstruction = 0;
135
	 */
136
 
136
	int mBuildFile = 0;
137
  /**non zero instruction number when it is determined to be test built
137
 
138
   * @attribute
138
	/**
139
   */
139
	 * build dependencies by package
140
  int mTestBuildInstruction = 0;
140
	 * 
141
 
141
	 * @attribute
142
  /**test build email destination
142
	 */
143
   * @attribute
143
	Vector<Package> mPackageDependencyCollection = new Vector<Package>();
144
   */
144
 
145
  String mTestBuildEmail;
145
	/**
146
 
146
	 * used for escrow build purposes set true when a package has been processed
147
  /**Version Control System Tag
147
	 * 
148
   * @attribute
148
	 * @attribute
149
   */
149
	 */
150
  String mTestBuildVcsTag = new String();
150
	boolean mProcessed = false;
151
 
151
 
152
  /**build standards
152
	/**
153
   * @attribute
153
	 * set true for WIP package versions only used in daemon mode
154
   */
154
	 * 
155
  Vector<BuildStandard> mTestBuildStandardCollection = new Vector<BuildStandard>();
155
	 * @attribute
156
 
156
	 */
157
  /**build dependencies by package alias
157
	boolean mDirectlyPlanned = false;
158
   * @attribute
158
 
159
   */
159
	/**
160
  Vector<String> mTestBuildDependencyCollection = new Vector<String>();
160
	 * set true when it is determined to be ripple built
161
 
161
	 * 
162
  /**build dependencies by pv_id (-1 or not used for planned dependencies)
162
	 * @attribute
163
   * @attribute
163
	 */
164
   */
164
	boolean mIndirectlyPlanned = false;
165
  Vector<Integer> mDependencyIDCollection = new Vector<Integer>();
165
 
166
 
166
	/**
167
  /**unique pkg_id in the database
167
	 * non zero instruction number when it is determined to be ripple built by
168
   * used for querying package version existence in the database in daemon mode
168
	 * force
169
   * @attribute
169
	 * 
170
   */
170
	 * @attribute
171
  int mPid;
171
	 */
172
 
172
	int mForcedRippleInstruction = 0;
173
  /**maximum major number supported for determining ripple number
173
 
174
   * @attribute
174
	/**
175
   */
175
	 * non zero instruction number when it is determined to be test built
176
  int mMajorLimit;
176
	 * 
177
 
177
	 * @attribute
178
  /**maximum minor number supported for determining ripple number
178
	 */
179
   * @attribute
179
	int mTestBuildInstruction = 0;
180
   */
180
 
181
  int mMinorLimit;
181
	/**
182
 
182
	 * test build email destination
183
  /**maximum patch number supported for determining ripple number
183
	 * 
184
   * @attribute
184
	 * @attribute
185
   */
185
	 */
186
  int mPatchLimit;
186
	String mTestBuildEmail;
187
 
187
 
188
  /**maximum build number number supported for determining ripple number
188
	/**
189
   * @attribute
189
	 * Version Control System Tag
190
   */
190
	 * 
191
  int mBuildLimit;
191
	 * @attribute
192
 
192
	 */
193
  /**Logger
193
	String mTestBuildVcsTag = new String();
194
   * @attribute
194
 
195
   */
195
	/**
196
  private static final Logger mLogger = Logger.getLogger(Package.class);
196
	 * build standards
197
 
197
	 * 
198
  /**dpkg archive location
198
	 * @attribute
199
   * @attribute
199
	 */
200
   */
200
	Vector<BuildStandard> mTestBuildStandardCollection = new Vector<BuildStandard>();
201
  public static final String mGbeDpkg = System.getenv("GBE_DPKG");
201
 
202
 
202
	/**
203
  /**Exception message used upon detection an archive does not exist
203
	 * build dependencies by package alias
204
   * Seems this is a rare but transient and recoverable scenario
204
	 * 
205
   * @attribute
205
	 * @attribute
206
   */
206
	 */
207
  public static final String mRecoverable = "dpkg_archive does not exist, recovery will be attempted";
207
	Vector<String> mTestBuildDependencyCollection = new Vector<String>();
208
 
208
 
209
  /**true if the package exists in the package archive (dpkg_archive)
209
	/**
210
   * @attribute
210
	 * build dependencies by pv_id (-1 or not used for planned dependencies)
211
   */
211
	 * 
212
  private boolean mArchivalExistence = true;
212
	 * @attribute
213
 
213
	 */
214
  /**when true will trigger source control interaction eg labelling
214
	Vector<Integer> mDependencyIDCollection = new Vector<Integer>();
215
   * @attribute
215
 
216
   */
216
	/**
217
  public boolean mRequiresSourceControlInteraction = true;
217
	 * unique pkg_id in the database used for querying package version existence
218
 
218
	 * in the database in daemon mode
219
  /**when true has been checked for circular dependency
219
	 * 
220
   * @attribute
220
	 * @attribute
221
   */
221
	 */
222
  boolean mCheckedCircularDependency = false;
222
	int mPid;
223
 
223
 
224
  /**when true has circular dependency
224
	/**
225
   * @attribute
225
	 * maximum major number supported for determining ripple number
226
   */
226
	 * 
227
  boolean mHasCircularDependency = false;
227
	 * @attribute
228
 
228
	 */
229
  /**constructor
229
	int mMajorLimit;
230
   */
230
 
231
  Package(int pv_id, String pkg_name, String v_ext, String alias, 
231
	/**
232
          String pkg_vcs_tag, char change_type, char ripple_field, String pkg_version)
232
	 * maximum minor number supported for determining ripple number
233
  {
233
	 * 
234
    mLogger.debug("Package 1: pv_id " + pv_id + " pkg_name " + pkg_name + " v_ext " + v_ext + " alias " + alias + " pkg_vcs_tag " + pkg_vcs_tag + " change_type " + change_type);
234
	 * @attribute
235
    mId = pv_id;
235
	 */
236
    mName = pkg_name;
236
	int mMinorLimit;
237
    mVersion = "0.0.0000";
237
 
238
    mExtension = v_ext;
238
	/**
239
    mAlias = alias;
239
	 * maximum patch number supported for determining ripple number
240
    mVcsTag = pkg_vcs_tag;
240
	 * 
241
 
241
	 * @attribute
242
    // Must not have any extension
242
	 */
243
    mFixedVersion = pkg_version;
243
	int mPatchLimit;
244
    mFixedVersion = mFixedVersion.substring(0, mFixedVersion.length() - mExtension.length());
244
 
245
 
245
	/**
246
    if (change_type == 'M')
246
	 * maximum build number number supported for determining ripple number
247
    {
247
	 * 
248
      // a ripple_field of 'L' indicates this package has limited version numbering
248
	 * @attribute
249
      mChangeType.setMajor(ripple_field == 'L' ? true : false);
249
	 */
250
    }
250
	int mBuildLimit;
251
    else if (change_type == 'N')
251
 
252
    {
252
	/**
253
      mChangeType.setMinor(ripple_field == 'L' ? true : false);
253
	 * Logger
254
    }
254
	 * 
255
    else if (change_type == 'P')
255
	 * @attribute
256
    {
256
	 */
257
      mChangeType.setPatch(ripple_field == 'L' ? true : false);
257
	private static final Logger mLogger = Logger.getLogger(Package.class);
258
    }
258
 
259
    else if (change_type == 'F')
259
	/**
260
    {
260
	 * dpkg archive location
261
      mChangeType.setFixed();
261
	 * 
262
    }
262
	 * @attribute
263
    else
263
	 */
264
    {
264
	public static final String mGbeDpkg = System.getenv("GBE_DPKG");
265
        mChangeType.setUnknown();
265
 
266
    }
266
	/**
267
  }
267
	 * Exception message used upon detection an archive does not exist Seems
268
 
268
	 * this is a rare but transient and recoverable scenario
269
  /**constructor
269
	 * 
270
   */
270
	 * @attribute
271
  Package(int pv_id, String pkg_name, String pkg_version, String v_ext, 
271
	 */
272
          String alias, String pkg_vcs_tag, char ripple_field)
272
	public static final String mRecoverable = "dpkg_archive does not exist, recovery will be attempted";
273
  {
273
 
274
    mLogger.debug("Package 2: pv_id " + pv_id + " pkg_name " + pkg_name + " pkg_version " + pkg_version + " v_ext " + v_ext + " alias " + alias + " pkg_vcs_tag " + pkg_vcs_tag + " ripple_field " + ripple_field);
274
	/**
275
    mId = pv_id;
275
	 * true if the package exists in the package archive (dpkg_archive)
276
    mName = pkg_name;
276
	 * 
277
    mVersion = pkg_version;
277
	 * @attribute
278
    int endindex = mVersion.length() - v_ext.length();
278
	 */
279
    
279
	private boolean mArchivalExistence = true;
280
    if ( endindex > 0 )
280
 
281
    {
281
	/**
282
      mVersion = mVersion.substring(0, endindex);
282
	 * when true will trigger source control interaction eg labelling
283
    }
283
	 * 
284
    
284
	 * @attribute
285
    mExtension = v_ext;
285
	 */
286
    mAlias = alias;
286
	public boolean mRequiresSourceControlInteraction = true;
287
    mVcsTag = pkg_vcs_tag;
287
 
288
 
288
	/**
289
    // setBuild is the default
289
	 * when true has been checked for circular dependency
290
    if (ripple_field == 'M')
290
	 * 
291
    {
291
	 * @attribute
292
      mRippleField.setMajor();
292
	 */
293
    }
293
	boolean mCheckedCircularDependency = false;
294
    else if (ripple_field == 'm')
294
 
295
    {
295
	/**
296
      mRippleField.setMinor();
296
	 * when true has circular dependency
297
    }
297
	 * 
298
    else if (ripple_field == 'p')
298
	 * @attribute
299
    {
299
	 */
300
      mRippleField.setPatch();
300
	boolean mHasCircularDependency = false;
301
    }
301
 
302
    else if (ripple_field == 'L')
302
	/**
303
    {
303
	 * constructor
304
      mRippleField.setLimit();
304
	 */
305
    }
305
	Package(int pv_id, String pkg_name, String v_ext, String alias, String pkg_vcs_tag, char change_type,
306
  }
306
			char ripple_field, String pkg_version)
307
 
307
	{
308
  /**constructor
308
		mLogger.debug("Package 1: pv_id " + pv_id + " pkg_name " + pkg_name + " v_ext " + v_ext + " alias " + alias
309
   */
309
				+ " pkg_vcs_tag " + pkg_vcs_tag + " change_type " + change_type);
310
  Package()
310
		mId = pv_id;
311
  {
311
		mName = pkg_name;
312
    mLogger.debug("Package 3");
312
		mVersion = "0.0.0000";
313
    mId = 0;
313
		mExtension = v_ext;
314
    mName = "null";
314
		mAlias = alias;
315
    mExtension = "null";
315
		mVcsTag = pkg_vcs_tag;
316
    mAlias = "null";
316
 
317
    mVcsTag = "null";
317
		// Must not have any extension
318
  }
318
		mFixedVersion = pkg_version;
319
 
319
		mFixedVersion = mFixedVersion.substring(0, mFixedVersion.length() - mExtension.length());
320
  /**constructor for test build purposes
320
 
321
   */
321
		if (change_type == 'M')
322
  Package(String pkg_name, String v_ext, String alias, 
322
		{
323
          String pkg_vcs_tag, int testBuildInstruction, String email)
323
			// a ripple_field of 'L' indicates this package has limited version
324
  {
324
			// numbering
325
    mLogger.debug("Package 4: pkg_name " + pkg_name + " v_ext " + v_ext + " alias " + alias + " pkg_vcs_tag " + pkg_vcs_tag );
325
			mChangeType.setMajor(ripple_field == 'L' ? true : false);
326
    // don't need pv_id
326
		} else if (change_type == 'N')
327
    mId = -1;
327
		{
328
    mName = pkg_name;
328
			mChangeType.setMinor(ripple_field == 'L' ? true : false);
329
    // avoid interaction with real versions
329
		} else if (change_type == 'P')
330
    mVersion = "0.0.0000";
330
		{
331
    mExtension = v_ext;
331
			mChangeType.setPatch(ripple_field == 'L' ? true : false);
332
    mAlias = alias;
332
		} else if (change_type == 'F')
333
    mTestBuildInstruction = testBuildInstruction;
333
		{
334
    mTestBuildEmail = email;
334
			mChangeType.setFixed();
335
    mTestBuildVcsTag = pkg_vcs_tag;
335
		} else
336
 
336
		{
337
  }
337
			mChangeType.setUnknown();
338
  
338
		}
339
/**constructor for unit test purposes
339
	}
340
  */
340
 
341
  public Package(ReleaseManager rm, String version, int majorLimit, int minorLimit, int patchLimit, int buildNumberLimit)
341
	/**
342
  {
342
	 * constructor
343
    mId = -1;
343
	 */
344
    mRippleField.setLimit();
344
	Package(int pv_id, String pkg_name, String pkg_version, String v_ext, String alias, String pkg_vcs_tag,
345
    mVersion = version;
345
			char ripple_field)
346
    mMajorLimit = majorLimit;
346
	{
347
    mMinorLimit = minorLimit;
347
		mLogger.debug("Package 2: pv_id " + pv_id + " pkg_name " + pkg_name + " pkg_version " + pkg_version + " v_ext "
348
    mPatchLimit = patchLimit;
348
				+ v_ext + " alias " + alias + " pkg_vcs_tag " + pkg_vcs_tag + " ripple_field " + ripple_field);
349
    mBuildLimit = buildNumberLimit;
349
		mId = pv_id;
350
 
350
		mName = pkg_name;
351
    if ( version.endsWith(".cots") )
351
		mVersion = pkg_version;
352
    {
352
		int endindex = mVersion.length() - v_ext.length();
353
        mExtension = ".cots";
353
 
354
        mVersion = version.substring( 0, version.length() - 5 );
354
		if (endindex > 0)
355
        mChangeType.setMajor(false);
355
		{
356
        mChangeType.setMinor(false);
356
			mVersion = mVersion.substring(0, endindex);
357
        mChangeType.setPatch(true);
357
		}
358
        mRippleField.setBuild();
358
 
359
    }
359
		mExtension = v_ext;
360
 
360
		mAlias = alias;
361
    try
361
		mVcsTag = pkg_vcs_tag;
362
    {
362
 
363
      mId = applyPV( rm, 0 );
363
		// setBuild is the default
364
    }
364
		if (ripple_field == 'M')
365
    catch(Exception e)
365
		{
366
    {
366
			mRippleField.setMajor();
367
    }
367
		} else if (ripple_field == 'm')
368
  }
368
		{
369
 
369
			mRippleField.setMinor();
370
  /**accessor for unit test purposes
370
		} else if (ripple_field == 'p')
371
   */
371
		{
372
  public int getId()
372
			mRippleField.setPatch();
373
  {
373
		} else if (ripple_field == 'L')
374
    return mId;
374
		{
375
  }
375
			mRippleField.setLimit();
376
  
376
		}
377
  /**accessor for unit test purposes
377
	}
378
   */
378
 
379
  public String getVersion()
379
	/**
380
  {
380
	 * constructor
381
    return mVersion;
381
	 */
382
  }
382
	Package()
383
 
383
	{
384
  /**returns true if mBuildStandardCollection is not empty
384
		mLogger.debug("Package 3");
385
   */
385
		mId = 0;
386
  boolean isReproducible()
386
		mName = "null";
387
  {
387
		mExtension = "null";
388
    mLogger.debug("isReproducible on Package " + mName);
388
		mAlias = "null";
389
    boolean retVal = false;
389
		mVcsTag = "null";
390
    
390
	}
391
    if ( mBuildStandardCollection.size() > 0 )
391
 
392
    {
392
	/**
393
      retVal = true;
393
	 * constructor for test build purposes
394
    }
394
	 */
395
    
395
	Package(String pkg_name, String v_ext, String alias, String pkg_vcs_tag, int testBuildInstruction, String email)
396
    mLogger.info("isReproducible returned " + retVal);
396
	{
397
    return retVal;
397
		mLogger.debug("Package 4: pkg_name " + pkg_name + " v_ext " + v_ext + " alias " + alias + " pkg_vcs_tag "
398
  }
398
				+ pkg_vcs_tag);
399
 
399
		// don't need pv_id
400
  /**returns true if at least one of its BuildStandards has mWin32 or mGeneric true
400
		mId = -1;
401
   */
401
		mName = pkg_name;
402
  boolean isWin32Built()
402
		// avoid interaction with real versions
403
  {
403
		mVersion = "0.0.0000";
404
    mLogger.debug("isWin32Built on Package " + mName);
404
		mExtension = v_ext;
405
    boolean retVal = false;
405
		mAlias = alias;
406
    for (Iterator<BuildStandard> it = mBuildStandardCollection.iterator(); it.hasNext(); )
406
		mTestBuildInstruction = testBuildInstruction;
407
    {
407
		mTestBuildEmail = email;
408
      BuildStandard buildStandard = it.next();
408
		mTestBuildVcsTag = pkg_vcs_tag;
409
 
409
 
410
      if (buildStandard.getWin32() || buildStandard.getGeneric())
410
	}
411
      {
411
 
412
        retVal = true;
412
	/**
413
        break;
413
	 * constructor for unit test purposes
414
      }
414
	 */
415
    }
415
	public Package(ReleaseManager rm, String version, int majorLimit, int minorLimit, int patchLimit,
416
 
416
			int buildNumberLimit)
417
    mLogger.info("isWin32Built returned " + retVal);
417
	{
418
    return retVal;
418
		mId = -1;
419
  }
419
		mRippleField.setLimit();
420
 
420
		mVersion = version;
421
  /**returns true if at least one of its BuildStandards has mSolaris or mGeneric true
421
		mMajorLimit = majorLimit;
422
   */
422
		mMinorLimit = minorLimit;
423
  boolean isSolarisBuilt()
423
		mPatchLimit = patchLimit;
424
  {
424
		mBuildLimit = buildNumberLimit;
425
    mLogger.debug("isSolarisBuilt on Package " + mName);
425
 
426
    boolean retVal = false;
426
		if (version.endsWith(".cots"))
427
    for (Iterator<BuildStandard> it = mBuildStandardCollection.iterator(); it.hasNext(); )
427
		{
428
    {
428
			mExtension = ".cots";
429
      BuildStandard buildStandard = it.next();
429
			mVersion = version.substring(0, version.length() - 5);
430
 
430
			mChangeType.setMajor(false);
431
      if (buildStandard.getSolaris() || buildStandard.getGeneric())
431
			mChangeType.setMinor(false);
432
      {
432
			mChangeType.setPatch(true);
433
        retVal = true;
433
			mRippleField.setBuild();
434
        break;
434
		}
435
      }
435
 
436
    }
436
		try
437
 
437
		{
438
    mLogger.info("isSolarisBuilt returned " + retVal);
438
			mId = applyPV(rm, 0);
439
    return retVal;
439
		} catch (Exception e)
440
  }
440
		{
441
 
441
		}
442
  /**returns true if at least one of its BuildStandards has mLinux or mGeneric true
442
	}
443
   */
443
 
444
  boolean isLinuxBuilt()
444
	/**
445
  {
445
	 * accessor for unit test purposes
446
    mLogger.debug("isLinuxBuilt on Package " + mName);
446
	 */
447
    boolean retVal = false;
447
	public int getId()
448
    for (Iterator<BuildStandard> it = mBuildStandardCollection.iterator(); it.hasNext(); )
448
	{
449
    {
449
		return mId;
450
      BuildStandard buildStandard = it.next();
450
	}
451
 
451
 
452
      if (buildStandard.getLinux() || buildStandard.getGeneric())
452
	/**
453
      {
453
	 * accessor for unit test purposes
454
        retVal = true;
454
	 */
455
        break;
455
	public String getVersion()
456
      }
456
	{
457
    }
457
		return mVersion;
458
 
458
	}
459
    mLogger.info("isLinuxBuilt returned " + retVal);
459
 
460
    return retVal;
460
	/**
461
  }
461
	 * returns true if mBuildStandardCollection is not empty
462
 
462
	 */
463
  /**returns true if at least one of its BuildStandards has mGeneric true
463
	boolean isReproducible()
464
   */
464
	{
465
  boolean isGeneric()
465
		mLogger.debug("isReproducible on Package " + mName);
466
  {
466
		boolean retVal = false;
467
    mLogger.debug("isGeneric on Package " + mName);
467
 
468
    boolean retVal = false;
468
		if (mBuildStandardCollection.size() > 0)
469
    for (Iterator<BuildStandard> it = mBuildStandardCollection.iterator(); it.hasNext(); )
469
		{
470
    {
470
			retVal = true;
471
      BuildStandard buildStandard = it.next();
471
		}
472
 
472
 
473
      if (buildStandard.getGeneric())
473
		mLogger.info("isReproducible returned " + retVal);
474
      {
474
		return retVal;
475
        retVal = true;
475
	}
476
        break;
476
 
477
      }
477
	/**
478
    }
478
	 * returns true if at least one of its BuildStandards has mWin32 or mGeneric
479
 
479
	 * true
480
    mLogger.info("isGeneric returned " + retVal);
480
	 */
481
    return retVal;
481
	boolean isWin32Built()
482
  }
482
	{
483
 
483
		mLogger.debug("isWin32Built on Package " + mName);
484
  /**applies the required version number change
484
		boolean retVal = false;
485
   * returns 0 on success
485
		for (Iterator<BuildStandard> it = mBuildStandardCollection.iterator(); it.hasNext();)
486
   *         1 on cannot work with non standard versioning
486
		{
487
   *         2 on ripple field limitations prevent a ripple build
487
			BuildStandard buildStandard = it.next();
488
   *         3 on Invalid Change Type
488
 
489
   */
489
			if (buildStandard.getWin32() || buildStandard.getGeneric())
490
  int applyPV(ReleaseManager releaseManager, int rtag_id) throws Exception
490
			{
491
  {
491
				retVal = true;
492
    mLogger.debug("applyPV on Package " + mName);
492
				break;
493
    //
493
			}
494
    // Four scenarios, only applyPV for 3 of them
494
		}
495
    //                                  mDirectlyPlanned    mIndirectlyPlanned  mArchivalExistence  mForcedRipple   Action
495
 
496
    // WIP/test build exists:           true                true                don't care          don't care     applyPV
496
		mLogger.info("isWin32Built returned " + retVal);
497
    // Package version is out of date:  false               true                true                don't care     applyPV
497
		return retVal;
498
    // Forced ripple:                   false               true                don't care          > 0            applyPV
498
	}
499
    // Package version does not exist:  false               true                false               = 0            do not applyPV
499
 
500
    //
500
	/**
501
    if ( !mDirectlyPlanned && mIndirectlyPlanned && !mArchivalExistence && mForcedRippleInstruction == 0 )
501
	 * returns true if at least one of its BuildStandards has mSolaris or
502
    {
502
	 * mGeneric true
503
      // the package has an mIndirectlyPlanned flag set true in daemon mode because the package does not exist in an archive
503
	 */
504
      // do not apply a different package version
504
	boolean isSolarisBuilt()
505
      mLogger.info("applyPV !mDirectlyPlanned && mIndirectlyPlanned && !mArchivalExistence && zero mForcedRippleInstruction on Package " + mName);
505
	{
506
      releaseManager.claimVersion(mPid, mVersion + mExtension, rtag_id);
506
		mLogger.debug("isSolarisBuilt on Package " + mName);
507
      mLogger.info("applyPv returned 0");
507
		boolean retVal = false;
508
      return 0;
508
		for (Iterator<BuildStandard> it = mBuildStandardCollection.iterator(); it.hasNext();)
509
    }
509
		{
510
 
510
			BuildStandard buildStandard = it.next();
511
    // override - no longer doing a rebuild - version number change from this point on
511
 
512
    if ( mTestBuildInstruction == 0 )
512
			if (buildStandard.getSolaris() || buildStandard.getGeneric())
513
    {
513
			{
514
      mRequiresSourceControlInteraction = true;
514
				retVal = true;
515
    }
515
				break;
516
 
516
			}
517
    //
517
		}
518
    //  Detect invalid change type
518
 
519
    //  Flagged when package instance is created
519
		mLogger.info("isSolarisBuilt returned " + retVal);
520
    //
520
		return retVal;
521
    if (mChangeType.mUnknown)
521
	}
522
    {
522
 
523
        mLogger.info("Package Vesrion specified on Package " + mName + "New Version:" + mVersion);
523
	/**
524
        mLogger.info("applyPv returned 3");
524
	 * returns true if at least one of its BuildStandards has mLinux or mGeneric
525
        return 3;
525
	 * true
526
    }
526
	 */
527
    
527
	boolean isLinuxBuilt()
528
    // If we are not calculating the new package version because the user has fixed the version
528
	{
529
    // of the package. We are given the new package version.
529
		mLogger.debug("isLinuxBuilt on Package " + mName);
530
    if (mChangeType.mFixed)
530
		boolean retVal = false;
531
    {
531
		for (Iterator<BuildStandard> it = mBuildStandardCollection.iterator(); it.hasNext();)
532
        // mVersion is already setup
532
		{
533
 
533
			BuildStandard buildStandard = it.next();
534
        mVersion = mFixedVersion;
534
 
535
        mLogger.info("Package Vesrion specified on Package " + mName + "New Version:" + mVersion);
535
			if (buildStandard.getLinux() || buildStandard.getGeneric())
536
        releaseManager.claimVersion(mPid, mVersion + mExtension, rtag_id);
536
			{
537
        mLogger.info("applyPv returned 0");
537
				retVal = true;
538
        return 0;
538
				break;
539
    }
539
			}
540
 
540
		}
541
    // We need to calculate the new version number
541
 
542
    //
542
		mLogger.info("isLinuxBuilt returned " + retVal);
543
    MutableInt major = new MutableInt();
543
		return retVal;
544
    major.value = 0;
544
	}
545
    MutableInt minor = new MutableInt();
545
 
546
    minor.value = 0;
546
	/**
547
    MutableInt patch = new MutableInt();
547
	 * returns true if at least one of its BuildStandards has mGeneric true
548
    patch.value = 1000;
548
	 */
549
 
549
	boolean isGeneric()
550
    String field[] = mVersion.split("\\D");
550
	{
551
    String nonStandardCotsVersion = "";
551
		mLogger.debug("isGeneric on Package " + mName);
552
 
552
		boolean retVal = false;
553
    if ( field.length == 3 )
553
		for (Iterator<BuildStandard> it = mBuildStandardCollection.iterator(); it.hasNext();)
554
    {
554
		{
555
      major.value = Integer.parseInt(field[0]);
555
			BuildStandard buildStandard = it.next();
556
      minor.value = Integer.parseInt(field[1]);
556
 
557
      patch.value = Integer.parseInt(field[2]);
557
			if (buildStandard.getGeneric())
558
    }
558
			{
559
    else
559
				retVal = true;
560
    {
560
				break;
561
      //
561
			}
562
      //    Can ripple a .cots package under very controlled conditions
562
		}
563
      //    Its ends with a .patchBuild field
563
 
564
      //    Package is marked as ripple via build number
564
		mLogger.info("isGeneric returned " + retVal);
565
      //    Change type of Major and Minor are not allowed
565
		return retVal;
566
      //
566
	}
567
      if ( !mChangeType.mMajor &&
567
 
568
           !mChangeType.mMinor &&
568
	/**
569
           mRippleField.mBuild &&
569
	 * applies the required version number change returns 0 on success 1 on
570
           mExtension.compareTo(".cots") == 0 &&
570
	 * cannot work with non standard versioning 2 on ripple field limitations
571
           field.length > 0 )
571
	 * prevent a ripple build 3 on Invalid Change Type
572
      {
572
	 */
573
        // DEVI 52782
573
	int applyPV(ReleaseManager releaseManager, int rtag_id) throws Exception
574
        // allow and work with (ripple build) versions a.b.c.d....xxxx
574
	{
575
        // where xxxx.length > 3
575
		mLogger.debug("applyPV on Package " + mName);
576
        String patchStr = field[field.length - 1];
576
		//
577
        int patchLen = patchStr.length();
577
		// Four scenarios, only applyPV for 3 of them
578
 
578
		// mDirectlyPlanned mIndirectlyPlanned mArchivalExistence mForcedRipple
579
        // check patchStr is the last (at least 4) digits
579
		// Action
580
        if ( patchLen > 3 && mVersion.substring( mVersion.length() - patchLen, mVersion.length() ).compareTo(patchStr) == 0 )
580
		// WIP/test build exists: true true don't care don't care applyPV
581
        {
581
		// Package version is out of date: false true true don't care applyPV
582
          patch.value = Integer.parseInt(patchStr);
582
		// Forced ripple: false true don't care > 0 applyPV
583
          nonStandardCotsVersion = mVersion.substring(0, mVersion.length() - patchLen );
583
		// Package version does not exist: false true false = 0 do not applyPV
584
        }
584
		//
585
      }
585
		if (!mDirectlyPlanned && mIndirectlyPlanned && !mArchivalExistence && mForcedRippleInstruction == 0)
586
      
586
		{
587
      if ( nonStandardCotsVersion.length() == 0 )
587
			// the package has an mIndirectlyPlanned flag set true in daemon
588
      {
588
			// mode because the package does not exist in an archive
589
        // cannot work with non standard versioning
589
			// do not apply a different package version
590
        mLogger.error("applyPV cannot work with non standard versioning");
590
			mLogger.info("applyPV !mDirectlyPlanned && mIndirectlyPlanned && !mArchivalExistence && zero mForcedRippleInstruction on Package "
591
        mLogger.info("applyPv returned 1");
591
					+ mName);
592
        return 1;
592
			releaseManager.claimVersion(mPid, mVersion + mExtension, rtag_id);
593
      }
593
			mLogger.info("applyPv returned 0");
594
    }
594
			return 0;
595
 
595
		}
596
    if ( nonStandardCotsVersion.length() == 0 &&
596
 
597
         patch.value < 1000 && 
597
		// override - no longer doing a rebuild - version number change from
598
         field[2].substring(0, 1).compareTo("0") != 0 )
598
		// this point on
599
    {
599
		if (mTestBuildInstruction == 0)
600
      mLogger.info("applyPV accomodate old style mVersion of the form 1.0.1");
600
		{
601
      patch.value = patch.value * 1000;
601
			mRequiresSourceControlInteraction = true;
602
    }
602
		}
603
      
603
 
604
    // mChangeType overrides mRippleField
604
		//
605
    do
605
		// Detect invalid change type
606
    {
606
		// Flagged when package instance is created
607
      if ( mChangeType.mMajor )
607
		//
608
      {
608
		if (mChangeType.mUnknown)
609
        if ( !incrementFieldsAccordingToLimits(4, major, minor, patch) )
609
		{
610
        {
610
			mLogger.info("Package Vesrion specified on Package " + mName + "New Version:" + mVersion);
611
          mLogger.info("applyPv returned 2");
611
			mLogger.info("applyPv returned 3");
612
          return 2;
612
			return 3;
613
        }
613
		}
614
      }
614
 
615
      else if ( mChangeType.mMinor )
615
		// If we are not calculating the new package version because the user
616
      {
616
		// has fixed the version
617
        if ( !incrementFieldsAccordingToLimits(3, major, minor, patch) )
617
		// of the package. We are given the new package version.
618
        {
618
		if (mChangeType.mFixed)
619
          mLogger.info("applyPv returned 2");
619
		{
620
          return 2;
620
			// mVersion is already setup
621
        }
621
 
622
      }
622
			mVersion = mFixedVersion;
623
      else if ( mChangeType.mPatch )
623
			mLogger.info("Package Vesrion specified on Package " + mName + "New Version:" + mVersion);
624
      {
624
			releaseManager.claimVersion(mPid, mVersion + mExtension, rtag_id);
625
        if ( !incrementFieldsAccordingToLimits(2, major, minor, patch) )
625
			mLogger.info("applyPv returned 0");
626
        {
626
			return 0;
627
          mLogger.info("applyPv returned 2");
627
		}
628
          return 2;
628
 
629
        }
629
		// We need to calculate the new version number
630
      }
630
		//
631
      else
631
		MutableInt major = new MutableInt();
632
      {
632
		major.value = 0;
633
        if ( mRippleField.mMajor )
633
		MutableInt minor = new MutableInt();
634
        {
634
		minor.value = 0;
635
          major.value++;
635
		MutableInt patch = new MutableInt();
636
          mLogger.info("applyPV mRippleField.mMajor " + major.value);
636
		patch.value = 1000;
637
          minor.value = 0;
637
 
638
          patch.value = 0;
638
		String field[] = mVersion.split("\\D");
639
        }
639
		String nonStandardCotsVersion = "";
640
        else if ( mRippleField.mMinor )
640
 
641
        {
641
		if (field.length == 3)
642
          minor.value++;
642
		{
643
          mLogger.info("applyPV mRippleField.mMinor " + minor.value);
643
			major.value = Integer.parseInt(field[0]);
644
          patch.value = 0;
644
			minor.value = Integer.parseInt(field[1]);
645
        }
645
			patch.value = Integer.parseInt(field[2]);
646
        else if ( mRippleField.mPatch )
646
		} else
647
        {
647
		{
648
          do
648
			//
649
          {
649
			// Can ripple a .cots package under very controlled conditions
650
            patch.value++;
650
			// Its ends with a .patchBuild field
651
          } while ( ( patch.value / 1000 ) * 1000 != patch.value );
651
			// Package is marked as ripple via build number
652
          mLogger.info("applyPV mRippleField.mPatch " + patch.value);
652
			// Change type of Major and Minor are not allowed
653
        }
653
			//
654
        else if ( mRippleField.mBuild )
654
			if (!mChangeType.mMajor && !mChangeType.mMinor && mRippleField.mBuild && mExtension.compareTo(".cots") == 0
655
        {
655
					&& field.length > 0)
656
          patch.value++;
656
			{
657
          mLogger.info("applyPV mRippleField.mBuild " + patch.value);
657
				// DEVI 52782
658
        }
658
				// allow and work with (ripple build) versions a.b.c.d....xxxx
659
        else
659
				// where xxxx.length > 3
660
        {
660
				String patchStr = field[field.length - 1];
661
          if ( !incrementFieldsAccordingToLimits(1, major, minor, patch) )
661
				int patchLen = patchStr.length();
662
          {
662
 
663
            mLogger.info("applyPv returned 2");
663
				// check patchStr is the last (at least 4) digits
664
            return 2;
664
				if (patchLen > 3
665
          }
665
						&& mVersion.substring(mVersion.length() - patchLen, mVersion.length()).compareTo(patchStr) == 0)
666
        }
666
				{
667
      }
667
					patch.value = Integer.parseInt(patchStr);
668
 
668
					nonStandardCotsVersion = mVersion.substring(0, mVersion.length() - patchLen);
669
      if ( nonStandardCotsVersion.length() == 0 )
669
				}
670
      {
670
			}
671
        mVersion = String.valueOf(major.value) + "." + String.valueOf(minor.value) + ".";
671
 
672
      }
672
			if (nonStandardCotsVersion.length() == 0)
673
      else
673
			{
674
      {
674
				// cannot work with non standard versioning
675
        mVersion = nonStandardCotsVersion;
675
				mLogger.error("applyPV cannot work with non standard versioning");
676
      }
676
				mLogger.info("applyPv returned 1");
677
      
677
				return 1;
678
      if ( patch.value < 10 )
678
			}
679
      {
679
		}
680
        mVersion += "000";
680
 
681
      }
681
		if (nonStandardCotsVersion.length() == 0 && patch.value < 1000 && field[2].substring(0, 1).compareTo("0") != 0)
682
      else if ( patch.value < 100 )
682
		{
683
      {
683
			mLogger.info("applyPV accomodate old style mVersion of the form 1.0.1");
684
        mVersion += "00";
684
			patch.value = patch.value * 1000;
685
      }
685
		}
686
      else if ( patch.value < 1000 )
686
 
687
      {
687
		// mChangeType overrides mRippleField
688
        mVersion += "0";
688
		do
689
      }
689
		{
690
      
690
			if (mChangeType.mMajor)
691
      mVersion += String.valueOf(patch.value);
691
			{
692
    } while ( exists(releaseManager, rtag_id) );
692
				if (!incrementFieldsAccordingToLimits(4, major, minor, patch))
693
    
693
				{
694
    releaseManager.claimVersion(mPid, mVersion + mExtension, rtag_id);
694
					mLogger.info("applyPv returned 2");
695
    mLogger.info("applyPv returned 0");
695
					return 2;
696
    return 0;
696
				}
697
  }
697
			} else if (mChangeType.mMinor)
698
 
698
			{
699
  /**increments fields according to mRippleField.mLimit if necessary
699
				if (!incrementFieldsAccordingToLimits(3, major, minor, patch))
700
   * will apply it to the field passed as follows
700
				{
701
   * 1 = build
701
					mLogger.info("applyPv returned 2");
702
   * 2 = patch
702
					return 2;
703
   * 3 = minor
703
				}
704
   * other = major
704
			} else if (mChangeType.mPatch)
705
   * returns true on success
705
			{
706
   *         false on ripple field limitations prevent a ripple build
706
				if (!incrementFieldsAccordingToLimits(2, major, minor, patch))
707
   */
707
				{
708
  private boolean incrementFieldsAccordingToLimits(int field, MutableInt major, MutableInt minor, MutableInt patch)
708
					mLogger.info("applyPv returned 2");
709
  {
709
					return 2;
710
    boolean retVal = true;
710
				}
711
    
711
			} else
712
    if (!mChangeType.mLimit && !mRippleField.mLimit)
712
			{
713
    {
713
				if (mRippleField.mMajor)
714
      // simple case
714
				{
715
      // no need to take field limits into consideration
715
					major.value++;
716
      switch (field)
716
					mLogger.info("applyPV mRippleField.mMajor " + major.value);
717
      {
717
					minor.value = 0;
718
      case 1:
718
					patch.value = 0;
719
        // unreachable
719
				} else if (mRippleField.mMinor)
720
        // the only scenario involving build number manipulation involves the mRippleField.mLimit being set
720
				{
721
        retVal = false;
721
					minor.value++;
722
        break;
722
					mLogger.info("applyPV mRippleField.mMinor " + minor.value);
723
      case 2:
723
					patch.value = 0;
724
        do
724
				} else if (mRippleField.mPatch)
725
        {
725
				{
726
          patch.value++;
726
					do
727
        } while ( ( patch.value / 1000 ) * 1000 != patch.value );
727
					{
728
        mLogger.info("incrementFieldsAccordingToLimits patch " + patch.value);
728
						patch.value++;
729
        break;
729
					} while ((patch.value / 1000) * 1000 != patch.value);
730
      case 3:
730
					mLogger.info("applyPV mRippleField.mPatch " + patch.value);
731
        minor.value++;
731
				} else if (mRippleField.mBuild)
732
        mLogger.info("incrementFieldsAccordingToLimits minor " + minor.value);
732
				{
733
        patch.value = 0;
733
					patch.value++;
734
        break;
734
					mLogger.info("applyPV mRippleField.mBuild " + patch.value);
735
      default:
735
				} else
736
        major.value++;
736
				{
737
        mLogger.info("incrementFieldsAccordingToLimits major " + major.value);
737
					if (!incrementFieldsAccordingToLimits(1, major, minor, patch))
738
        minor.value = 0;
738
					{
739
        patch.value = 0;
739
						mLogger.info("applyPv returned 2");
740
      }
740
						return 2;
741
    }
741
					}
742
    else
742
				}
743
    {
743
			}
744
      // take field limits into consideration
744
 
745
      boolean changeOccurred = false;
745
			if (nonStandardCotsVersion.length() == 0)
746
      boolean incrementField = true;
746
			{
747
      
747
				mVersion = String.valueOf(major.value) + "." + String.valueOf(minor.value) + ".";
748
      switch (field)
748
			} else
749
      {
749
			{
750
      case 1:
750
				mVersion = nonStandardCotsVersion;
751
        if ( mBuildLimit != 0 )
751
			}
752
        {
752
 
753
          // increment or reset the patch build number
753
			if (patch.value < 10)
754
          int buildNumber = patch.value - (patch.value/1000) * 1000;
754
			{
755
          
755
				mVersion += "000";
756
          if ( buildNumber < mBuildLimit )
756
			} else if (patch.value < 100)
757
          {
757
			{
758
            // can increment the patch build number
758
				mVersion += "00";
759
            patch.value++;
759
			} else if (patch.value < 1000)
760
            mLogger.info("incrementFieldsAccordingToLimits mRippleField.mLimit build number " + patch.value);
760
			{
761
            changeOccurred = true;
761
				mVersion += "0";
762
            incrementField = false;
762
			}
763
          }
763
 
764
          else
764
			mVersion += String.valueOf(patch.value);
765
          {
765
		} while (exists(releaseManager, rtag_id));
766
            if ( mPatchLimit == 0 )
766
 
767
            {
767
		releaseManager.claimVersion(mPid, mVersion + mExtension, rtag_id);
768
              // reset the patch number and patch build number
768
		mLogger.info("applyPv returned 0");
769
              patch.value = 0;
769
		return 0;
770
            }
770
	}
771
          }
771
 
772
        }
772
	/**
773
        // no break by design
773
	 * increments fields according to mRippleField.mLimit if necessary will
774
      case 2:
774
	 * apply it to the field passed as follows 1 = build 2 = patch 3 = minor
775
        if ( mPatchLimit != 0 && incrementField )
775
	 * other = major returns true on success false on ripple field limitations
776
        {
776
	 * prevent a ripple build
777
          // increment or reset the patch number
777
	 */
778
          if ( ( patch.value / 1000 ) < mPatchLimit )
778
	private boolean incrementFieldsAccordingToLimits(int field, MutableInt major, MutableInt minor, MutableInt patch)
779
          {
779
	{
780
            do
780
		boolean retVal = true;
781
            {
781
 
782
              patch.value++;
782
		if (!mChangeType.mLimit && !mRippleField.mLimit)
783
            } while ( ( patch.value / 1000 ) * 1000 != patch.value );
783
		{
784
            
784
			// simple case
785
            mLogger.info("incrementFieldsAccordingToLimits mRippleField.mLimit patch " + patch.value);
785
			// no need to take field limits into consideration
786
            changeOccurred = true;
786
			switch (field)
787
            incrementField = false;
787
			{
788
          }
788
			case 1:
789
          else
789
				// unreachable
790
          {
790
				// the only scenario involving build number manipulation
791
            // reset the patch number and patch build number
791
				// involves the mRippleField.mLimit being set
792
            patch.value = 0;
792
				retVal = false;
793
          }
793
				break;
794
        }
794
			case 2:
795
        // no break by design
795
				do
796
      case 3:
796
				{
797
        if ( mMinorLimit != 0 && incrementField )
797
					patch.value++;
798
        {
798
				} while ((patch.value / 1000) * 1000 != patch.value);
799
          // increment or reset the minor number
799
				mLogger.info("incrementFieldsAccordingToLimits patch " + patch.value);
800
          if ( minor.value < mMinorLimit )
800
				break;
801
          {
801
			case 3:
802
            minor.value++;
802
				minor.value++;
803
            patch.value = 0;
803
				mLogger.info("incrementFieldsAccordingToLimits minor " + minor.value);
804
            mLogger.info("incrementFieldsAccordingToLimits mRippleField.mLimit minor " + minor.value);
804
				patch.value = 0;
805
            changeOccurred = true;
805
				break;
806
            incrementField = false;
806
			default:
807
          }
807
				major.value++;
808
          else
808
				mLogger.info("incrementFieldsAccordingToLimits major " + major.value);
809
          {
809
				minor.value = 0;
810
            // reset the minor number
810
				patch.value = 0;
811
            minor.value = 0;
811
			}
812
          }
812
		} else
813
        }
813
		{
814
        // no break by design
814
			// take field limits into consideration
815
      default:
815
			boolean changeOccurred = false;
816
        if ( mMajorLimit != 0 && incrementField )
816
			boolean incrementField = true;
817
        {
817
 
818
          // increment or reset the major number
818
			switch (field)
819
          if ( major.value < mMajorLimit )
819
			{
820
          {
820
			case 1:
821
            // increment the major number
821
				if (mBuildLimit != 0)
822
            changeOccurred = true;
822
				{
823
            major.value++;
823
					// increment or reset the patch build number
824
            minor.value = 0;
824
					int buildNumber = patch.value - (patch.value / 1000) * 1000;
825
            patch.value = 0;
825
 
826
            mLogger.info("incrementFieldsAccordingToLimits mRippleField.mLimit major " + major.value);
826
					if (buildNumber < mBuildLimit)
827
          }
827
					{
828
        }
828
						// can increment the patch build number
829
      }
829
						patch.value++;
830
      
830
						mLogger.info("incrementFieldsAccordingToLimits mRippleField.mLimit build number " + patch.value);
831
      if ( !changeOccurred )
831
						changeOccurred = true;
832
      {
832
						incrementField = false;
833
        // unable to increment a field due to field limitations
833
					} else
834
        mLogger.error("incrementFieldsAccordingToLimits ripple field limitations prevent a ripple build");
834
					{
835
        mLogger.info("incrementFieldsAccordingToLimits returned false");
835
						if (mPatchLimit == 0)
836
        retVal = false;
836
						{
837
      }
837
							// reset the patch number and patch build number
838
    }
838
							patch.value = 0;
839
    
839
						}
840
    return retVal;
840
					}
841
  }
841
				}
842
  
842
				// no break by design
843
  /**returns true if the version exists in the dpkg_archive or release manager database
843
			case 2:
844
   * claims the version in the release manager database
844
				if (mPatchLimit != 0 && incrementField)
845
   */
845
				{
846
  private boolean exists(ReleaseManager releaseManager, int rtag_id) throws Exception
846
					// increment or reset the patch number
847
  {
847
					if ((patch.value / 1000) < mPatchLimit)
848
    mLogger.debug("exists 1 on Package " + mName + " version " + mVersion + " extension " + mExtension);
848
					{
849
    boolean retVal = false;
849
						do
850
    
850
						{
851
    if ( !ReleaseManager.mUseDatabase )
851
							patch.value++;
852
    {
852
						} while ((patch.value / 1000) * 1000 != patch.value);
853
      mLogger.info("exists 1 !releaseManager.mUseDatabase");
853
 
854
    }
854
						mLogger.info("incrementFieldsAccordingToLimits mRippleField.mLimit patch " + patch.value);
855
    else
855
						changeOccurred = true;
856
    {
856
						incrementField = false;
857
      retVal = exists();
857
					} else
858
 
858
					{
859
      if ( !retVal )
859
						// reset the patch number and patch build number
860
      {
860
						patch.value = 0;
861
        String pkg_version = new String(mVersion);
861
					}
862
        
862
				}
863
        if ( mExtension.length() > 0 )
863
				// no break by design
864
        {
864
			case 3:
865
          pkg_version += mExtension;
865
				if (mMinorLimit != 0 && incrementField)
866
        }
866
				{
867
        
867
					// increment or reset the minor number
868
        retVal = releaseManager.queryPackageVersions(mPid, pkg_version);
868
					if (minor.value < mMinorLimit)
869
      }
869
					{
870
    }
870
						minor.value++;
871
    
871
						patch.value = 0;
872
    mLogger.info("exists 1 returned " + retVal);
872
						mLogger.info("incrementFieldsAccordingToLimits mRippleField.mLimit minor " + minor.value);
873
    return retVal;
873
						changeOccurred = true;
874
  }
874
						incrementField = false;
875
 
875
					} else
876
  /**returns true if the required package archives (dpkg_archive) exist
876
					{
877
   * attempt to recover from their transient loss 
877
						// reset the minor number
878
   */
878
						minor.value = 0;
879
  public static boolean recover()
879
					}
880
  {
880
				}
881
    mLogger.debug("recover");
881
				// no break by design
882
    boolean retVal = false;
882
			default:
883
 
883
				if (mMajorLimit != 0 && incrementField)
884
    String Release = mGbeDpkg;
884
				{
885
    if (Release != null )
885
					// increment or reset the major number
886
    {
886
					if (major.value < mMajorLimit)
887
      File dpkg = new File(mGbeDpkg);
887
					{
888
      
888
						// increment the major number
889
      if ( dpkg.exists() )
889
						changeOccurred = true;
890
      {
890
						major.value++;
891
        retVal = true;
891
						minor.value = 0;
892
        mLogger.fatal("recover: dpkg_archive access has been restored");
892
						patch.value = 0;
893
      }
893
						mLogger.info("incrementFieldsAccordingToLimits mRippleField.mLimit major " + major.value);
894
    }
894
					}
895
    
895
				}
896
    mLogger.info("recover returned " + retVal);
896
			}
897
    return retVal;
897
 
898
  }
898
			if (!changeOccurred)
899
  
899
			{
900
  /**returns true if the version exists in a package archive (dpkg_archive)
900
				// unable to increment a field due to field limitations
901
   */
901
				mLogger.error("incrementFieldsAccordingToLimits ripple field limitations prevent a ripple build");
902
  boolean exists()
902
				mLogger.info("incrementFieldsAccordingToLimits returned false");
903
    throws Exception
903
				retVal = false;
904
  {
904
			}
905
    mLogger.debug("exists 2 on Package " + mName);
905
		}
906
    boolean retVal = false;
906
 
907
 
907
		return retVal;
908
    String Release = mGbeDpkg;
908
	}
909
    if (Release == null)
909
 
910
    {
910
	/**
911
      mLogger.fatal("exists 2 Release == null");
911
	 * returns true if the version exists in the dpkg_archive or release manager
912
      throw new Exception("exists 2 Release == null");
912
	 * database claims the version in the release manager database
913
    }
913
	 */
914
    
914
	private boolean exists(ReleaseManager releaseManager, int rtag_id) throws Exception
915
    File dpkg = new File(mGbeDpkg);
915
	{
916
    if ( !dpkg.exists()  )
916
		mLogger.debug("exists 1 on Package " + mName + " version " + mVersion + " extension " + mExtension);
917
    {
917
		boolean retVal = false;
918
      mLogger.fatal("exists 2 " + mRecoverable);
918
 
919
      throw new Exception(mRecoverable);
919
		if (!ReleaseManager.mUseDatabase)
920
    }
920
		{
921
 
921
			mLogger.info("exists 1 !releaseManager.mUseDatabase");
922
    String fs = System.getProperty( "file.separator" );
922
		} else
923
    String name = new String(Release);
923
		{
924
    name += fs + mName + fs + mVersion + mExtension;
924
			retVal = exists();
925
    File release = new File(name);
925
 
926
 
926
			if (!retVal)
927
    if (release.exists())
927
			{
928
    {
928
				String pkg_version = new String(mVersion);
929
      mLogger.info("exists 2 release.exists()");
929
 
930
      retVal = true;
930
				if (mExtension.length() > 0)
931
    }
931
				{
932
 
932
					pkg_version += mExtension;
933
    mArchivalExistence = retVal;
933
				}
934
    mLogger.info("exists 2 returned " + retVal);
934
 
935
    return retVal;
935
				retVal = releaseManager.queryPackageVersions(mPid, pkg_version);
936
  }
936
			}
937
  
937
		}
938
  /**returns email information
938
 
939
   */
939
		mLogger.info("exists 1 returned " + retVal);
940
  String emailInfo( String lf )
940
		return retVal;
941
  {
941
	}
942
    String retVal = new String();
942
 
943
    
943
	/**
944
    for (Iterator<String> it = mBuildFailureEmailCollection.iterator(); it.hasNext(); )
944
	 * returns true if the required package archives (dpkg_archive) exist
945
    {
945
	 * attempt to recover from their transient loss
946
      String email = it.next();
946
	 */
947
      retVal +=
947
	public static boolean recover()
948
      "  <owner email=\"" + email +"\"/>" + lf;
948
	{
949
    }
949
		mLogger.debug("recover");
950
    
950
		boolean retVal = false;
951
    return retVal;
951
 
952
  }
952
		String Release = mGbeDpkg;
953
 
953
		if (Release != null)
954
  /**returns email information
954
		{
955
   */
955
			File dpkg = new File(mGbeDpkg);
956
  String emailInfoNonAntTask()
956
 
957
  {
957
			if (dpkg.exists())
958
    String retVal = null;
958
			{
959
    
959
				retVal = true;
960
    for (Iterator<String> it = mBuildFailureEmailCollection.iterator(); it.hasNext(); )
960
				mLogger.fatal("recover: dpkg_archive access has been restored");
961
    {
961
			}
962
      String email = it.next();
962
		}
963
      
963
 
964
      if ( retVal == null )
964
		mLogger.info("recover returned " + retVal);
965
      {
965
		return retVal;
966
        retVal = new String();
966
	}
967
      }
967
 
968
      else
968
	/**
969
      {
969
	 * returns true if the version exists in a package archive (dpkg_archive)
970
        retVal += ",";
970
	 */
971
      }
971
	boolean exists() throws Exception
972
      retVal += email;
972
	{
973
    }
973
		mLogger.debug("exists 2 on Package " + mName);
974
    
974
		boolean retVal = false;
975
    return retVal;
975
 
976
  }
976
		String Release = mGbeDpkg;
977
 
977
		if (Release == null)
978
  /**adds email to mBuildFailureEmailCollection if unique
978
		{
979
   */
979
			mLogger.fatal("exists 2 Release == null");
980
  void addEmail( String email )
980
			throw new Exception("exists 2 Release == null");
981
  {
981
		}
982
    boolean alreadyExists = false;
982
 
983
    
983
		File dpkg = new File(mGbeDpkg);
984
    for (Iterator<String> it = mBuildFailureEmailCollection.iterator(); it.hasNext(); )
984
		if (!dpkg.exists())
985
    {
985
		{
986
      String existingEmail = it.next();
986
			mLogger.fatal("exists 2 " + mRecoverable);
987
      
987
			throw new Exception(mRecoverable);
988
      if ( existingEmail.compareTo(email) == 0 )
988
		}
989
      {
989
 
990
        alreadyExists = true;
990
		String fs = System.getProperty("file.separator");
991
        break;
991
		String name = new String(Release);
992
      }
992
		name += fs + mName + fs + mVersion + mExtension;
993
    }
993
		File release = new File(name);
994
    
994
 
995
    if ( !alreadyExists )
995
		if (release.exists())
996
    {
996
		{
997
      mBuildFailureEmailCollection.add(email);
997
			mLogger.info("exists 2 release.exists()");
998
    }
998
			retVal = true;
999
  }
999
		}
1000
 
1000
 
1001
  /**accessor method
1001
		mArchivalExistence = retVal;
1002
   */
1002
		mLogger.info("exists 2 returned " + retVal);
1003
  void setEmail()
1003
		return retVal;
1004
  {
1004
	}
1005
    mBuildFailureEmailCollection.clear();
1005
 
1006
    addEmail( mTestBuildEmail );
1006
	/**
1007
  }
1007
	 * returns email information
1008
 
1008
	 */
1009
  /**accessor method
1009
	String emailInfo(String lf)
1010
   */
1010
	{
1011
  void setDependencyCollection()
1011
		String retVal = new String();
1012
  {
1012
 
1013
    // does not worry about mPackageDendencyCollection by design
1013
		for (Iterator<String> it = mBuildFailureEmailCollection.iterator(); it.hasNext();)
1014
    mDependencyCollection.clear();
1014
		{
1015
    
1015
			String email = it.next();
1016
    for (Iterator<String> it = mTestBuildDependencyCollection.iterator(); it.hasNext(); )
1016
			retVal += "  <owner email=\"" + email + "\"/>" + lf;
1017
    {
1017
		}
1018
      String dependency = it.next();
1018
 
1019
      mDependencyCollection.add(dependency);
1019
		return retVal;
1020
    }
1020
	}
1021
  }
1021
 
1022
 
1022
	/**
1023
  /**accessor method
1023
	 * returns email information
1024
   */
1024
	 */
1025
  void setBuildStandardCollection()
1025
	String emailInfoNonAntTask()
1026
  {
1026
	{
1027
    mBuildStandardCollection.clear();
1027
		String retVal = null;
1028
    
1028
 
1029
    for (Iterator<BuildStandard> it = mTestBuildStandardCollection.iterator(); it.hasNext(); )
1029
		for (Iterator<String> it = mBuildFailureEmailCollection.iterator(); it.hasNext();)
1030
    {
1030
		{
1031
      BuildStandard buildStandard = it.next();
1031
			String email = it.next();
1032
      mBuildStandardCollection.add(buildStandard);
1032
 
1033
    }
1033
			if (retVal == null)
1034
  }
1034
			{
1035
 
1035
				retVal = new String();
1036
  /**sends email notification and marks the instruction complete in the database
1036
			} else
1037
   */
1037
			{
1038
  public void completeTestBuild( String mailServer, String mailSender, ReleaseManager releaseManager, String release, boolean success ) throws SQLException, Exception
1038
				retVal += ",";
1039
  {
1039
			}
1040
    mLogger.debug("completeTestBuild");
1040
			retVal += email;
1041
    
1041
		}
1042
    if ( mTestBuildInstruction == 0)
1042
 
1043
    {
1043
		return retVal;
1044
      mLogger.fatal("completeTestBuild. Not Build Instruction");
1044
	}
1045
      return;
1045
 
1046
    }
1046
	/**
1047
    String subject = (success == true ? "TEST BUILD COMPLETED SUCCESSFULLY" : "TEST BUILD FAILED") + " on package " + mAlias; 
1047
	 * adds email to mBuildFailureEmailCollection if unique
1048
    String mailBody="Test build issues are identified in preceding build failure email.<p>" +
1048
	 */
1049
                    "Release: " + release + "<br>" +
1049
	void addEmail(String email)
1050
                    "Package: " + mAlias + "<br>" +
1050
	{
1051
                    "VcsTag: " + mVcsTag + "<br>" +
1051
		boolean alreadyExists = false;
1052
                    "Build dependencies:<br>";
1052
 
1053
    String indentString = "&nbsp;&nbsp;&nbsp;&nbsp;";
1053
		for (Iterator<String> it = mBuildFailureEmailCollection.iterator(); it.hasNext();)
1054
    
1054
		{
1055
    for (Iterator<Package> it3 = mPackageDependencyCollection.iterator(); it3.hasNext(); )
1055
			String existingEmail = it.next();
1056
    {
1056
 
1057
      Package depend = it3.next();
1057
			if (existingEmail.compareTo(email) == 0)
1058
      
1058
			{
1059
      String dependsExtension = depend.mExtension;
1059
				alreadyExists = true;
1060
      String dependsVersion = depend.mVersion;
1060
				break;
1061
      
1061
			}
1062
      if ( dependsExtension.length() > 0 )
1062
		}
1063
      {
1063
 
1064
        dependsVersion += dependsExtension;
1064
		if (!alreadyExists)
1065
      }
1065
		{
1066
      mailBody += indentString + "\'" + depend.mName + "\',\'" + dependsVersion + "\' <br>";
1066
			mBuildFailureEmailCollection.add(email);
1067
    }
1067
		}
1068
 
1068
	}
1069
    mailBody += "<br>Build standards:<br>";
1069
 
1070
 
1070
	/**
1071
    for (Iterator<BuildStandard> it = mBuildStandardCollection.iterator(); it.hasNext(); )
1071
	 * accessor method
1072
    {
1072
	 */
1073
      BuildStandard bs = it.next();
1073
	void setEmail()
1074
      
1074
	{
1075
      String platform = bs.getPlatform(!ReleaseManager.mUseDatabase, false);
1075
		mBuildFailureEmailCollection.clear();
1076
    
1076
		addEmail(mTestBuildEmail);
1077
      if ( platform.length() > 0 )
1077
	}
1078
      {
1078
 
1079
        mailBody += indentString + platform + ", ";
1079
	/**
1080
      }
1080
	 * accessor method
1081
 
1081
	 */
1082
      String standard = bs.getBuildStandard(!ReleaseManager.mUseDatabase, false);
1082
	void setDependencyCollection()
1083
      
1083
	{
1084
      if ( standard.length() > 0 )
1084
		// does not worry about mPackageDendencyCollection by design
1085
      {
1085
		mDependencyCollection.clear();
1086
        mailBody += standard + "<br>";
1086
 
1087
      }
1087
		for (Iterator<String> it = mTestBuildDependencyCollection.iterator(); it.hasNext();)
1088
    }
1088
		{
1089
 
1089
			String dependency = it.next();
1090
    mailBody += "<p><hr>";
1090
			mDependencyCollection.add(dependency);
1091
    try
1091
		}
1092
    {
1092
	}
1093
      String target = emailInfoNonAntTask();
1093
 
1094
mLogger.fatal("completeTestBuildEmail Server: " + mailServer);
1094
	/**
1095
mLogger.fatal("completeTestBuildEmail Sender: " + mailSender);
1095
	 * accessor method
1096
mLogger.fatal("completeTestBuildEmail Target: " + target);
1096
	 */
1097
      
1097
	void setBuildStandardCollection()
1098
      Smtpsend.send( mailServer,           // mailServer
1098
	{
1099
                     mailSender,           // source
1099
		mBuildStandardCollection.clear();
1100
                     target,               // target
1100
 
1101
                     mailSender,           // cc
1101
		for (Iterator<BuildStandard> it = mTestBuildStandardCollection.iterator(); it.hasNext();)
1102
                     null,                 // bcc
1102
		{
1103
                     subject,              // subject
1103
			BuildStandard buildStandard = it.next();
1104
                     mailBody,             // body
1104
			mBuildStandardCollection.add(buildStandard);
1105
                     null                  // attachment
1105
		}
1106
                     );
1106
	}
1107
    }
1107
 
1108
    catch( Exception e )
1108
	/**
1109
    {
1109
	 * sends email notification and marks the instruction complete in the
1110
        mLogger.warn("Email Failure: completeTestBuild:" + e.getMessage());
1110
	 * database
1111
    }
1111
	 */
1112
    
1112
	public void completeTestBuild(String mailServer, String mailSender, ReleaseManager releaseManager, String release,
1113
    releaseManager.markDaemonInstCompletedConnect(mTestBuildInstruction);
1113
			boolean success) throws SQLException, Exception
1114
mLogger.fatal("completeTest. Returning");
1114
	{
1115
  }
1115
		mLogger.debug("completeTestBuild");
1116
 
1116
 
1117
  /**returns true if the package has a circular dependency
1117
		if (mTestBuildInstruction == 0)
1118
   */
1118
		{
1119
  public boolean hasCircularDependency(RippleEngine ripEng)
1119
			mLogger.fatal("completeTestBuild. Not Build Instruction");
1120
  {
1120
			return;
1121
    mLogger.debug("hasCircularDependency");
1121
		}
1122
    boolean retVal = detectCircularDependency( mAlias, ripEng );
1122
		String subject = (success == true ? "TEST BUILD COMPLETED SUCCESSFULLY" : "TEST BUILD FAILED") + " on package "
1123
    mLogger.info("hasCircularDependency returned " + retVal);
1123
				+ mAlias;
1124
    return retVal;
1124
		String mailBody = "Test build issues are identified in preceding build failure email.<p>" + "Release: "
1125
  }
1125
				+ release + "<br>" + "Package: " + mAlias + "<br>" + "VcsTag: " + mVcsTag + "<br>"
1126
  
1126
				+ "Build dependencies:<br>";
1127
  /**returns true if the package has a circular dependency
1127
		String indentString = "&nbsp;&nbsp;&nbsp;&nbsp;";
1128
   */
1128
 
1129
  public boolean detectCircularDependency(String alias, RippleEngine ripEng)
1129
		for (Iterator<Package> it3 = mPackageDependencyCollection.iterator(); it3.hasNext();)
1130
  {
1130
		{
1131
    mLogger.debug("detectCircularDependency");
1131
			Package depend = it3.next();
1132
    boolean retVal = false;
1132
 
1133
    
1133
			String dependsExtension = depend.mExtension;
1134
    // if this package has yet to be checked for circular dependency
1134
			String dependsVersion = depend.mVersion;
1135
    if ( !mCheckedCircularDependency )
1135
 
1136
    {
1136
			if (dependsExtension.length() > 0)
1137
      for (Iterator<String> it2 = mDependencyCollection.iterator(); it2.hasNext(); )
1137
			{
1138
      {
1138
				dependsVersion += dependsExtension;
1139
        String dependencyAlias = it2.next();
1139
			}
1140
        
1140
			mailBody += indentString + "\'" + depend.mName + "\',\'" + dependsVersion + "\' <br>";
1141
        // check its direct dependencies for an alias match
1141
		}
1142
        if ( alias.compareTo( dependencyAlias ) == 0 )
1142
 
1143
        {
1143
		mailBody += "<br>Build standards:<br>";
1144
          retVal = true;
1144
 
1145
          break;
1145
		for (Iterator<BuildStandard> it = mBuildStandardCollection.iterator(); it.hasNext();)
1146
        }
1146
		{
1147
        
1147
			BuildStandard bs = it.next();
1148
        Package dependency = ripEng.findPackage( dependencyAlias );
1148
 
1149
        
1149
			String platform = bs.getPlatform(!ReleaseManager.mUseDatabase, false);
1150
        // check its indirect dependencies for an alias match
1150
 
1151
        if ( dependency.detectCircularDependency(alias, ripEng) )
1151
			if (platform.length() > 0)
1152
        {
1152
			{
1153
          retVal = true;
1153
				mailBody += indentString + platform + ", ";
1154
          break;
1154
			}
1155
        }
1155
 
1156
      }
1156
			String standard = bs.getBuildStandard(!ReleaseManager.mUseDatabase, false);
1157
      // mark the check complete
1157
 
1158
      mCheckedCircularDependency = true;
1158
			if (standard.length() > 0)
1159
      // persist the circular dependency outcome
1159
			{
1160
      mHasCircularDependency = retVal;
1160
				mailBody += standard + "<br>";
1161
    }
1161
			}
1162
    else
1162
		}
1163
    {
1163
 
1164
      // return the persisted circular dependency outcome
1164
		mailBody += "<p><hr>";
1165
      retVal = mHasCircularDependency;
1165
		try
1166
    }
1166
		{
1167
    mLogger.info("detectCircularDependency 2 returned " + retVal);
1167
			String target = emailInfoNonAntTask();
1168
    return retVal;
1168
			mLogger.fatal("completeTestBuildEmail Server: " + mailServer);
1169
  }
1169
			mLogger.fatal("completeTestBuildEmail Sender: " + mailSender);
1170
  
1170
			mLogger.fatal("completeTestBuildEmail Target: " + target);
1171
  /**entity class supporting the ERG version numbering standard:
1171
 
1172
   * <major>.<minor>.<patch/build>
1172
			Smtpsend.send(mailServer, 	// mailServer
1173
   * patch/build is at least a 4 digit number whose last 3 digits represent the build
1173
					mailSender, 		// source
1174
   */
1174
					target, 			// target
1175
  public class VersionNumberingStandard
1175
					mailSender, 		// cc
1176
  {
1176
					null, 				// bcc
1177
    /**in terms of the mChangeType Package field,
1177
					subject, 			// subject
1178
     * when true indicates the contract of the package has changed in a non backwardly compatible manner
1178
					mailBody, 			// body
1179
     * in terms of the mRippleField Package field,
1179
					null 				// attachment
1180
     * when true indicates the major version number will be incremented
1180
			);
1181
     * @attribute
1181
		} catch (Exception e)
1182
     */
1182
		{
1183
    private boolean mMajor = false;
1183
			mLogger.warn("Email Failure: completeTestBuild:" + e.getMessage());
1184
 
1184
		}
1185
    /**in terms of the mChangeType Package field,
1185
 
1186
     * when true indicates the contract of the package has changed in a backwardly compatible manner
1186
		releaseManager.markDaemonInstCompletedConnect(mTestBuildInstruction);
1187
     * in terms of the mRippleField Package field,
1187
		mLogger.fatal("completeTest. Returning");
1188
     * when true indicates the minor version number will be incremented
1188
	}
1189
     * @attribute
1189
 
1190
     */
1190
	/**
1191
    private boolean mMinor = false;
1191
	 * returns true if the package has a circular dependency
1192
 
1192
	 */
1193
    /**in terms of the mChangeType Package field,
1193
	public boolean hasCircularDependency(RippleEngine ripEng)
1194
     * when true indicates the contract of the package has not changed, but the package has changed internally
1194
	{
1195
     * in terms of the mRippleField Package field,
1195
		mLogger.debug("hasCircularDependency");
1196
     * when true indicates the minor version number will be incremented
1196
		boolean retVal = detectCircularDependency(mAlias, ripEng);
1197
     * @attribute
1197
		mLogger.info("hasCircularDependency returned " + retVal);
1198
     */
1198
		return retVal;
1199
    private boolean mPatch = false;
1199
	}
1200
 
1200
 
1201
    /**in terms of the mChangeType Package field,
1201
	/**
1202
     * when true indicates the package has not changed, its dependencies potentially have
1202
	 * returns true if the package has a circular dependency
1203
     * in terms of the mRippleField Package field,
1203
	 */
1204
     * when true indicates the build number will be incremented
1204
	public boolean detectCircularDependency(String alias, RippleEngine ripEng)
1205
     * @attribute
1205
	{
1206
     */
1206
		mLogger.debug("detectCircularDependency");
1207
    private boolean mBuild = true;
1207
		boolean retVal = false;
1208
 
1208
 
1209
    /**in terms of the mChangeType Package field,
1209
		// if this package has yet to be checked for circular dependency
1210
     * when true indicates the major, minor, and patch number will be incremented according to field limits
1210
		if (!mCheckedCircularDependency)
1211
     * in terms of the mRippleField Package field,
1211
		{
1212
     * when true indicates the major, minor, patch and build number will be incremented according to field limits
1212
			for (Iterator<String> it2 = mDependencyCollection.iterator(); it2.hasNext();)
1213
     * @attribute
1213
			{
1214
     */
1214
				String dependencyAlias = it2.next();
1215
    private boolean mLimit = false;
1215
 
1216
 
1216
				// check its direct dependencies for an alias match
1217
    /**in terms of the mChangeType Package field,
1217
				if (alias.compareTo(dependencyAlias) == 0)
1218
     * when true indicates the package version number will not be rippled. The user will have 
1218
				{
1219
     * fixed the version number. This is only application to WIP packages 
1219
					retVal = true;
1220
     *  
1220
					break;
1221
     * @attribute
1221
				}
1222
     */
1222
 
1223
    private boolean mFixed = false;
1223
				Package dependency = ripEng.findPackage(dependencyAlias);
1224
 
1224
 
1225
    /**in terms of the mChangeType Package field,
1225
				// check its indirect dependencies for an alias match
1226
     * when true indicates the method of rippling a package version 
1226
				if (dependency.detectCircularDependency(alias, ripEng))
1227
     * number is not known. 
1227
				{
1228
     *  
1228
					retVal = true;
1229
     * @attribute
1229
					break;
1230
     */
1230
				}
1231
    private boolean mUnknown = false;
1231
			}
1232
 
1232
			// mark the check complete
1233
    /**constructor
1233
			mCheckedCircularDependency = true;
1234
     */
1234
			// persist the circular dependency outcome
1235
    private VersionNumberingStandard()
1235
			mHasCircularDependency = retVal;
1236
    {
1236
		} else
1237
      mLogger.debug("VersionNumberingStandard");
1237
		{
1238
    }
1238
			// return the persisted circular dependency outcome
1239
 
1239
			retVal = mHasCircularDependency;
1240
    /**sets mBuild true, mMajor false, mMinor false, mPatch false, mLimit false
1240
		}
1241
     */
1241
		mLogger.info("detectCircularDependency 2 returned " + retVal);
1242
    void setBuild()
1242
		return retVal;
1243
    {
1243
	}
1244
      mLogger.debug("setBuild");
1244
 
1245
      mBuild = true;
1245
	/**
1246
      mMajor = false;
1246
	 * entity class supporting the ERG version numbering standard:
1247
      mMinor = false;
1247
	 * <major>.<minor>.<patch/build> patch/build is at least a 4 digit number
1248
      mPatch = false;
1248
	 * whose last 3 digits represent the build
1249
      mLimit = false;
1249
	 */
1250
      mFixed = false;
1250
	public class VersionNumberingStandard
1251
    }
1251
	{
1252
 
1252
		/**
1253
    /**sets mBuild false, mMajor true, mMinor false, mPatch false, mLimit false
1253
		 * in terms of the mChangeType Package field, when true indicates the
1254
     */
1254
		 * contract of the package has changed in a non backwardly compatible
1255
    void setMajor()
1255
		 * manner in terms of the mRippleField Package field, when true indicates
1256
    {
1256
		 * the major version number will be incremented
1257
      mLogger.debug("setMajor");
1257
		 * 
1258
      mBuild = false;
1258
		 * @attribute
1259
      mMajor = true;
1259
		 */
1260
      mMinor = false;
1260
		private boolean mMajor = false;
1261
      mPatch = false;
1261
 
1262
      mLimit = false;
1262
		/**
1263
      mFixed = false;
1263
		 * in terms of the mChangeType Package field, when true indicates the
1264
    }
1264
		 * contract of the package has changed in a backwardly compatible manner
1265
 
1265
		 * in terms of the mRippleField Package field, when true indicates the
1266
    /**sets mBuild false, mMajor true, mMinor false, mPatch false, mLimit limit
1266
		 * minor version number will be incremented
1267
     */
1267
		 * 
1268
    void setMajor( boolean limit )
1268
		 * @attribute
1269
    {
1269
		 */
1270
      mLogger.debug("setMajor " + limit);
1270
		private boolean mMinor = false;
1271
      mBuild = false;
1271
 
1272
      mMajor = true;
1272
		/**
1273
      mMinor = false;
1273
		 * in terms of the mChangeType Package field, when true indicates the
1274
      mPatch = false;
1274
		 * contract of the package has not changed, but the package has changed
1275
      mLimit = limit;
1275
		 * internally in terms of the mRippleField Package field, when true
1276
      mFixed = false;
1276
		 * indicates the minor version number will be incremented
1277
    }
1277
		 * 
1278
 
1278
		 * @attribute
1279
    /**sets mBuild false, mMajor false, mMinor true, mPatch false, mLimit false
1279
		 */
1280
     */
1280
		private boolean mPatch = false;
1281
    void setMinor()
1281
 
1282
    {
1282
		/**
1283
      mLogger.debug("setMinor");
1283
		 * in terms of the mChangeType Package field, when true indicates the
1284
      mBuild = false;
1284
		 * package has not changed, its dependencies potentially have in terms
1285
      mMajor = false;
1285
		 * of the mRippleField Package field, when true indicates the build
1286
      mMinor = true;
1286
		 * number will be incremented
1287
      mPatch = false;
1287
		 * 
1288
      mLimit = false;
1288
		 * @attribute
1289
      mFixed = false;
1289
		 */
1290
    }
1290
		private boolean mBuild = true;
1291
 
1291
 
1292
    /**sets mBuild false, mMajor false, mMinor true, mPatch false, mLimit limit
1292
		/**
1293
     */
1293
		 * in terms of the mChangeType Package field, when true indicates the
1294
    void setMinor( boolean limit )
1294
		 * major, minor, and patch number will be incremented according to field
1295
    {
1295
		 * limits in terms of the mRippleField Package field, when true indicates
1296
      mLogger.debug("setMinor " + limit);
1296
		 * the major, minor, patch and build number will be incremented
1297
      mBuild = false;
1297
		 * according to field limits
1298
      mMajor = false;
1298
		 * 
1299
      mMinor = true;
1299
		 * @attribute
1300
      mPatch = false;
1300
		 */
1301
      mLimit = limit;
1301
		private boolean mLimit = false;
1302
      mFixed = false;
1302
 
1303
    }
1303
		/**
1304
 
1304
		 * in terms of the mChangeType Package field, when true indicates the
1305
    /**sets mBuild false, mMajor false, mMinor false, mPatch true, mLimit false
1305
		 * package version number will not be rippled. The user will have fixed
1306
     */
1306
		 * the version number. This is only application to WIP packages
1307
    void setPatch()
1307
		 * 
1308
    {
1308
		 * @attribute
1309
      mLogger.debug("setPatch");
1309
		 */
1310
      mBuild = false;
1310
		private boolean mFixed = false;
1311
      mMajor = false;
1311
 
1312
      mMinor = false;
1312
		/**
1313
      mPatch = true;
1313
		 * in terms of the mChangeType Package field, when true indicates the
1314
      mLimit = false;
1314
		 * method of rippling a package version number is not known.
1315
      mFixed = false;
1315
		 * 
1316
    }
1316
		 * @attribute
1317
 
1317
		 */
1318
    /**sets mBuild false, mMajor false, mMinor false, mPatch true, mLimit limit
1318
		private boolean mUnknown = false;
1319
     */
1319
 
1320
    void setPatch( boolean limit )
1320
		/**
1321
    {
1321
		 * constructor
1322
      mLogger.debug("setPatch");
1322
		 */
1323
      mBuild = false;
1323
		private VersionNumberingStandard()
1324
      mMajor = false;
1324
		{
1325
      mMinor = false;
1325
			mLogger.debug("VersionNumberingStandard");
1326
      mPatch = true;
1326
		}
1327
      mLimit = limit;
1327
 
1328
      mFixed = false;
1328
		/**
1329
    }
1329
		 * Reset all values to a known state
1330
 
1330
		 * 
1331
    /**sets mBuild false, mMajor false, mMinor false, mPatch false, mLimit true
1331
		 */
1332
     */
1332
		void resetData()
1333
    void setLimit()
1333
		{
1334
    {
1334
			mBuild = false;
1335
      mLogger.debug("setPatch");
1335
			mMajor = false;
1336
      mBuild = false;
1336
			mMinor = false;
1337
      mMajor = false;
1337
			mPatch = false;
1338
      mMinor = false;
1338
			mLimit = false;
1339
      mPatch = false;
1339
			mFixed = false;
1340
      mLimit = true;
1340
			mUnknown = false;
1341
      mFixed = false;
1341
		}
1342
    }
1342
 
1343
 
1343
		/**
1344
    /**sets parameters to indicate that the change type is Fixed. The version number is set by the user 
1344
		 * sets mBuild true, mMajor false, mMinor false, mPatch false, mLimit
1345
     * and a ripple will not be calculated 
1345
		 * false
1346
     */ 
1346
		 */
1347
    void setFixed()
1347
		void setBuild()
1348
    {
1348
		{
1349
        mLogger.debug("setFixed");
1349
			mLogger.debug("setBuild");
1350
        mBuild = false;
1350
			resetData();
1351
        mMajor = false;
1351
			mBuild = true;
1352
        mMinor = false;
1352
		}
1353
        mPatch = false;
1353
 
1354
        mLimit = false;
1354
		/**
1355
        mFixed = true;
1355
		 * sets mBuild false, mMajor true, mMinor false, mPatch false, mLimit
1356
    }
1356
		 * false
1357
 
1357
		 */
1358
    /** Sets parameters to indicate that the chnage type is not
1358
		void setMajor()
1359
     *  known
1359
		{
1360
     *  
1360
			mLogger.debug("setMajor");
1361
     */
1361
			resetData();
1362
    void setUnknown()
1362
			mMajor = true;
1363
    {
1363
		}
1364
        mUnknown = true;
1364
 
1365
    }
1365
		/**
-
 
1366
		 * sets mBuild false, mMajor true, mMinor false, mPatch false, mLimit
-
 
1367
		 * limit
-
 
1368
		 */
-
 
1369
		void setMajor(boolean limit)
-
 
1370
		{
-
 
1371
			mLogger.debug("setMajor " + limit);
-
 
1372
			resetData();
-
 
1373
			mMajor = true;
-
 
1374
			mLimit = limit;
-
 
1375
		}
-
 
1376
 
-
 
1377
		/**
-
 
1378
		 * sets mBuild false, mMajor false, mMinor true, mPatch false, mLimit
-
 
1379
		 * false
-
 
1380
		 */
-
 
1381
		void setMinor()
-
 
1382
		{
-
 
1383
			mLogger.debug("setMinor");
-
 
1384
			resetData();
-
 
1385
			mMinor = true;
-
 
1386
		}
-
 
1387
 
-
 
1388
		/**
-
 
1389
		 * sets mBuild false, mMajor false, mMinor true, mPatch false, mLimit
-
 
1390
		 * limit
-
 
1391
		 */
-
 
1392
		void setMinor(boolean limit)
-
 
1393
		{
-
 
1394
			mLogger.debug("setMinor " + limit);
-
 
1395
			resetData();
-
 
1396
			mMinor = true;
-
 
1397
			mLimit = limit;
-
 
1398
		}
-
 
1399
 
-
 
1400
		/**
-
 
1401
		 * sets mBuild false, mMajor false, mMinor false, mPatch true, mLimit
-
 
1402
		 * false
-
 
1403
		 */
-
 
1404
		void setPatch()
-
 
1405
		{
-
 
1406
			mLogger.debug("setPatch");
-
 
1407
			resetData();
-
 
1408
			mPatch = true;
-
 
1409
		}
-
 
1410
 
-
 
1411
		/**
-
 
1412
		 * sets mBuild false, mMajor false, mMinor false, mPatch true, mLimit
-
 
1413
		 * limit
-
 
1414
		 */
-
 
1415
		void setPatch(boolean limit)
-
 
1416
		{
-
 
1417
			mLogger.debug("setPatch");
-
 
1418
			resetData();
-
 
1419
			mPatch = true;
-
 
1420
			mLimit = limit;
-
 
1421
		}
-
 
1422
 
-
 
1423
		/**
-
 
1424
		 * sets mBuild false, mMajor false, mMinor false, mPatch false, mLimit
-
 
1425
		 * true
-
 
1426
		 */
-
 
1427
		void setLimit()
-
 
1428
		{
-
 
1429
			mLogger.debug("setPatch");
-
 
1430
			resetData();
-
 
1431
			mLimit = true;
-
 
1432
		}
-
 
1433
 
-
 
1434
		/**
-
 
1435
		 * sets parameters to indicate that the change type is Fixed. The
-
 
1436
		 * version number is set by the user and a ripple will not be calculated
-
 
1437
		 */
-
 
1438
		void setFixed()
-
 
1439
		{
-
 
1440
			mLogger.debug("setFixed");
-
 
1441
			resetData();
-
 
1442
			mFixed = true;
-
 
1443
		}
-
 
1444
 
-
 
1445
		/**
-
 
1446
		 * Sets parameters to indicate that the change type is not known
-
 
1447
		 * 
-
 
1448
		 */
-
 
1449
		void setUnknown()
-
 
1450
		{
-
 
1451
			resetData();
-
 
1452
			mUnknown = true;
-
 
1453
		}
1366
 
1454
 
1367
  }
1455
	}
1368
 
1456
 
1369
}
1457
}