Subversion Repositories DevTools

Rev

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

Rev 7033 Rev 7044
Line 159... Line 159...
159
                if (connection != null)
159
                if (connection != null)
160
                	connection.close();
160
                	connection.close();
161
            }
161
            }
162
            catch (SQLException e)
162
            catch (SQLException e)
163
            {
163
            {
164
                mLogger.error("SQL Exception closing connection:" + e.getMessage());
164
                mLogger.error("SQL Exception closing connection: {}", e.getMessage());
165
            }
165
            }
166
    	}
166
    	}
167
    }
167
    }
168
    
168
    
169
    /**database connection for use when not planning a build
169
    /**database connection for use when not planning a build
Line 261... Line 261...
261
     * @param username
261
     * @param username
262
     * @param password
262
     * @param password
263
     */
263
     */
264
    public ReleaseManager(final String connectionString, final String username, final String password)
264
    public ReleaseManager(final String connectionString, final String username, final String password)
265
    {
265
    {
266
        mLogger.debug("ReleaseManager " + connectionString);
266
        mLogger.debug("ReleaseManager {}", connectionString);
267
        mConnectionString = connectionString;
267
        mConnectionString = connectionString;
268
        mUsername = username;
268
        mUsername = username;
269
        mPassword = password;
269
        mPassword = password;
270
 
270
 
271
        String gbeBtDebug = System.getenv("GBE_BUILDTOOL_DEBUG");
271
        String gbeBtDebug = System.getenv("GBE_BUILDTOOL_DEBUG");
Line 313... Line 313...
313
     *               False: Escrow Mode
313
     *               False: Escrow Mode
314
     */
314
     */
315
    public void setDaemonMode(boolean isDaemon)
315
    public void setDaemonMode(boolean isDaemon)
316
    {
316
    {
317
        mDaemon = isDaemon;
317
        mDaemon = isDaemon;
318
        mLogger.debug("DaemonMode:" + mDaemon);
318
        mLogger.debug("DaemonMode:{}", mDaemon);
319
    }
319
    }
320
    
320
    
321
    /**
321
    /**
322
     * Clear mUseMutex
322
     * Clear mUseMutex
323
     * Used only in test mode to prevent the use of a mutex 
323
     * Used only in test mode to prevent the use of a mutex 
Line 564... Line 564...
564
     * @throws Exception
564
     * @throws Exception
565
     */
565
     */
566
    void handleSQLException(SQLException e, String instanceId ) throws SQLException, Exception
566
    void handleSQLException(SQLException e, String instanceId ) throws SQLException, Exception
567
    {
567
    {
568
        String callingMethodName = Thread.currentThread().getStackTrace()[2].getMethodName() + instanceId ;
568
        String callingMethodName = Thread.currentThread().getStackTrace()[2].getMethodName() + instanceId ;
569
        mLogger.error(callingMethodName + " sql exception:" + e.getMessage());
569
        mLogger.error("{} sql exception:{}", callingMethodName, e.getMessage());
570
        
570
        
571
        if ( mConnection == null || !mConnection.isValid(10) )
571
        if ( mConnection == null || !mConnection.isValid(10) )
572
        {
572
        {
573
            mLogger.error(callingMethodName + " database access error only");
573
            mLogger.error( "{} database access error only", callingMethodName);
574
            RmConnection.closeConnection(mConnection);
574
            RmConnection.closeConnection(mConnection);
575
            throw new SQLException(e);
575
            throw new SQLException(e);
576
        }
576
        }
577
        else
577
        else
578
        {
578
        {
579
            mLogger.error(callingMethodName + " show stopper");
579
            mLogger.error( "{} show stopper", callingMethodName);
580
            throw new Exception(callingMethodName + " show stopper");
580
            throw new Exception(callingMethodName + " show stopper");
581
        }
581
        }
582
    }
582
    }
583
    
583
    
584
    /** Claim the Build System Planning Lock
584
    /** Claim the Build System Planning Lock
Line 687... Line 687...
687
            }
687
            }
688
            catch( SQLException e )
688
            catch( SQLException e )
689
            {
689
            {
690
                // do not throw Exception
690
                // do not throw Exception
691
                // this is part of Exception handling
691
                // this is part of Exception handling
692
                mLogger.error( "indefinitePause caught SQLException " + e.getMessage() );
692
                mLogger.error( "indefinitePause caught SQLException {}", e.getMessage() );
693
                RmConnection.closeConnection(mConnection);
693
                RmConnection.closeConnection(mConnection);
694
            }
694
            }
695
            catch( Exception e )
695
            catch( Exception e )
696
            {
696
            {
697
                mLogger.error( "indefinitePause caught Exception " + e.getMessage() );
697
                mLogger.error( "indefinitePause caught Exception {}", e.getMessage() );
698
            }
698
            }
699
            finally
699
            finally
700
            {
700
            {
701
                // this block is executed regardless of what happens in the try block
701
                // this block is executed regardless of what happens in the try block
702
                // even if an exception is thrown
702
                // even if an exception is thrown
Line 707... Line 707...
707
                }
707
                }
708
                catch( Exception e )
708
                catch( Exception e )
709
                {
709
                {
710
                    // do not throw Exception
710
                    // do not throw Exception
711
                    // this is part of Exception handling
711
                    // this is part of Exception handling
712
                    mLogger.error( "indefinitePause2 caught Exception " + e.getMessage() );
712
                    mLogger.error( "indefinitePause2 caught Exception {}", e.getMessage() );
713
                    RmConnection.closeConnection(mConnection);
713
                    RmConnection.closeConnection(mConnection);
714
                }
714
                }
715
            }
715
            }
716
        }
716
        }
717
    }
717
    }
Line 755... Line 755...
755
     * @exception SQLException
755
     * @exception SQLException
756
     * @exception Exception
756
     * @exception Exception
757
     */
757
     */
758
    void claimVersion(int pkgId, String pkgVersion, int rtagId) throws SQLException, Exception
758
    void claimVersion(int pkgId, String pkgVersion, int rtagId) throws SQLException, Exception
759
    {
759
    {
760
        mLogger.debug("claimVersion " + pkgId + " " + pkgVersion);
760
        mLogger.debug("claimVersion {} {}", pkgId, pkgVersion);
761
        if ( mUseDatabase )
761
        if ( mUseDatabase )
762
        {
762
        {
763
            CallableStatement stmt1 = null;
763
            CallableStatement stmt1 = null;
764
            try
764
            try
765
            {
765
            {
Line 856... Line 856...
856
     *  @param pkgId - Identifies the name of the package being built
856
     *  @param pkgId - Identifies the name of the package being built
857
     *  @param pkgPvId - Identifies the packageVersion the build is based upon
857
     *  @param pkgPvId - Identifies the packageVersion the build is based upon
858
     */
858
     */
859
    public void setCurrentPackageBeingBuilt(int rconId, int pkgId, int pkgPvId) throws SQLException, Exception
859
    public void setCurrentPackageBeingBuilt(int rconId, int pkgId, int pkgPvId) throws SQLException, Exception
860
    {
860
    {
861
        mLogger.error("setCurrentPackageBeingBuilt " + rconId);
861
        mLogger.error("setCurrentPackageBeingBuilt {}", rconId);
862
        if ( mUseDatabase )
862
        if ( mUseDatabase )
863
        {
863
        {
864
            CallableStatement stmt = null;
864
            CallableStatement stmt = null;
865
            try
865
            try
866
            {
866
            {
Line 902... Line 902...
902
     * 
902
     * 
903
     *  @param rconId - Identifies the Release Config table entry
903
     *  @param rconId - Identifies the Release Config table entry
904
     */
904
     */
905
    public void clearCurrentPackageBeingBuilt(int rconId) throws SQLException, Exception
905
    public void clearCurrentPackageBeingBuilt(int rconId) throws SQLException, Exception
906
    {
906
    {
907
        mLogger.error("clearCurrentPackageBeingBuilt " + rconId);
907
        mLogger.error("clearCurrentPackageBeingBuilt {}", rconId);
908
        if ( mUseDatabase )
908
        if ( mUseDatabase )
909
        {
909
        {
910
            try
910
            try
911
            {
911
            {
912
                connect();
912
                connect();
Line 951... Line 951...
951
     */
951
     */
952
    public boolean autoMakeRelease(ReportingData mReporting) throws SQLException, Exception
952
    public boolean autoMakeRelease(ReportingData mReporting) throws SQLException, Exception
953
    {
953
    {
954
 
954
 
955
        mReporting.errMsg = null;
955
        mReporting.errMsg = null;
956
        mLogger.debug("autoMakeRelease " + mReporting.packageName);
956
        mLogger.debug("autoMakeRelease {}", mReporting.packageName);
957
        if ( mUseDatabase )
957
        if ( mUseDatabase )
958
        {
958
        {
959
            try
959
            try
960
            {
960
            {
961
                //  Create an array of dependencies
961
                //  Create an array of dependencies
Line 1003... Line 1003...
1003
                //  Report per-package errors directly
1003
                //  Report per-package errors directly
1004
                //  Exceptions are for errors that need to halt the entire system
1004
                //  Exceptions are for errors that need to halt the entire system
1005
                //
1005
                //
1006
                if ( result <= 0 )
1006
                if ( result <= 0 )
1007
                {
1007
                {
1008
                    mLogger.error("autoMakeRelease PK_RMAPI.AUTO_MAKE_VCSRELEASE failed, returned " + result);
1008
                    mLogger.error("autoMakeRelease PK_RMAPI.AUTO_MAKE_VCSRELEASE failed, returned {}", result);
1009
                    if ( result == -4 ) {
1009
                    if ( result == -4 ) {
1010
                        mReporting.errMsg = "Package migrated to SVN being built from CC tag";
1010
                        mReporting.errMsg = "Package migrated to SVN being built from CC tag";
1011
                    } else if ( result == -3 ) {
1011
                    } else if ( result == -3 ) {
1012
                        mReporting.errMsg = "Package not approved for autobuild";
1012
                        mReporting.errMsg = "Package not approved for autobuild";
1013
                    } else if ( result == -2 ) {
1013
                    } else if ( result == -2 ) {
Line 1051... Line 1051...
1051
     *  Handles database connection/disconnection
1051
     *  Handles database connection/disconnection
1052
     */
1052
     */
1053
    public void insertPackageMetrics(int mRtagId, String packageName, 
1053
    public void insertPackageMetrics(int mRtagId, String packageName, 
1054
            String packageExtension, String metrics) throws SQLException, Exception
1054
            String packageExtension, String metrics) throws SQLException, Exception
1055
    {
1055
    {
1056
        mLogger.debug("insertPackageMetrics " + packageName);
1056
        mLogger.debug("insertPackageMetrics {}", packageName);
1057
        if ( mUseDatabase )
1057
        if ( mUseDatabase )
1058
        {
1058
        {
1059
            try
1059
            try
1060
            {
1060
            {
1061
                connect();
1061
                connect();
Line 1069... Line 1069...
1069
                int result = stmt.getInt( 1 );
1069
                int result = stmt.getInt( 1 );
1070
 
1070
 
1071
                if ( result != 0 )
1071
                if ( result != 0 )
1072
                {
1072
                {
1073
                    // flag build failure
1073
                    // flag build failure
1074
                    mLogger.error("insertPackageMetrics show stopper PK_RMAPI.INSERT_PACKAGE_METRICS failed, returned" + result);
1074
                    mLogger.error("insertPackageMetrics show stopper PK_RMAPI.INSERT_PACKAGE_METRICS failed, returned {}", result);
1075
                    throw new Exception("insertPackageMetrics show stopper PK_RMAPI.INSERT_PACKAGE_METRICS failed, returned" + result);
1075
                    throw new Exception("insertPackageMetrics show stopper PK_RMAPI.INSERT_PACKAGE_METRICS failed, returned" + result);
1076
                }
1076
                }
1077
                stmt.close();
1077
                stmt.close();
1078
                commit();
1078
                commit();
1079
            }
1079
            }
Line 1100... Line 1100...
1100
     */
1100
     */
1101
    public int createBuildInstance(int rtagId, int pvId, BuildReason reason) throws SQLException, Exception
1101
    public int createBuildInstance(int rtagId, int pvId, BuildReason reason) throws SQLException, Exception
1102
    {
1102
    {
1103
        int buildId = 0;
1103
        int buildId = 0;
1104
        
1104
        
1105
        mLogger.debug("createBuildInstance " + rtagId + ":" + pvId);
1105
        mLogger.debug("createBuildInstance {}:{}", rtagId, pvId);
1106
        if ( mUseDatabase )
1106
        if ( mUseDatabase )
1107
        {
1107
        {
1108
            try
1108
            try
1109
            {
1109
            {
1110
                connect();
1110
                connect();
Line 1115... Line 1115...
1115
                stmt.setLong( 3,pvId );
1115
                stmt.setLong( 3,pvId );
1116
                stmt.setString( 4,reason.toString() );
1116
                stmt.setString( 4,reason.toString() );
1117
                stmt.executeUpdate();
1117
                stmt.executeUpdate();
1118
                buildId = stmt.getInt( 1 );
1118
                buildId = stmt.getInt( 1 );
1119
                
1119
                
1120
                mLogger.warn("createBuildInstance: Build Instance ID: " + buildId);
1120
                mLogger.warn("createBuildInstance: Build Instance ID: {}", buildId);
1121
 
1121
 
1122
                stmt.close();
1122
                stmt.close();
1123
                commit();
1123
                commit();
1124
            }
1124
            }
1125
            catch ( SQLException e )
1125
            catch ( SQLException e )
Line 1152... Line 1152...
1152
     */
1152
     */
1153
    public int updateBuildInstance(int buildID, int pvId, BuildResult result) throws SQLException, Exception
1153
    public int updateBuildInstance(int buildID, int pvId, BuildResult result) throws SQLException, Exception
1154
    {
1154
    {
1155
        int rv = 0;
1155
        int rv = 0;
1156
        
1156
        
1157
        mLogger.debug("updateBuildInstance " + buildID + ":" + pvId + ":" + result);
1157
        mLogger.debug("updateBuildInstance {}:{}:{}", buildID, pvId, result);
1158
        if ( mUseDatabase )
1158
        if ( mUseDatabase )
1159
        {
1159
        {
1160
            try
1160
            try
1161
            {
1161
            {
1162
                connect();
1162
                connect();
Line 1169... Line 1169...
1169
                stmt.setLong( 3,pvId );
1169
                stmt.setLong( 3,pvId );
1170
                stmt.setString( 4,result.toString() );
1170
                stmt.setString( 4,result.toString() );
1171
                stmt.executeUpdate();
1171
                stmt.executeUpdate();
1172
                rv = stmt.getInt( 1 );
1172
                rv = stmt.getInt( 1 );
1173
                
1173
                
1174
                mLogger.warn("updateBuildInstance: Result: " + rv);
1174
                mLogger.warn("updateBuildInstance: Result: {}", rv);
1175
 
1175
 
1176
                stmt.close();
1176
                stmt.close();
1177
                commit();
1177
                commit();
1178
            }
1178
            }
1179
            catch ( SQLException e )
1179
            catch ( SQLException e )
Line 1210... Line 1210...
1210
        if ( !mUseDatabase || !btr.mResultsFound )
1210
        if ( !mUseDatabase || !btr.mResultsFound )
1211
        {
1211
        {
1212
            return;
1212
            return;
1213
        }
1213
        }
1214
 
1214
 
1215
        mLogger.warn("insertTestResults: " + buildId + ", Number:" + btr.mTestResults.size() );
1215
        mLogger.warn("insertTestResults: {}, Number:{}", buildId, btr.mTestResults.size() );
1216
        try
1216
        try
1217
        {
1217
        {
1218
            connect();
1218
            connect();
1219
            String sql = "BEGIN ? := PK_RMAPI.insert_test_run(?, ?, ?, ?, ?, ?, ?);end;";
1219
            String sql = "BEGIN ? := PK_RMAPI.insert_test_run(?, ?, ?, ?, ?, ?, ?);end;";
1220
            CallableStatement stmt = mConnection.prepareCall(sql);
1220
            CallableStatement stmt = mConnection.prepareCall(sql);
Line 1282... Line 1282...
1282
     * 
1282
     * 
1283
     * @return  true if an instruction exists - for use in a while loop
1283
     * @return  true if an instruction exists - for use in a while loop
1284
     */
1284
     */
1285
    public boolean getDaemonInst(DaemonInstruction di ) throws SQLException, Exception
1285
    public boolean getDaemonInst(DaemonInstruction di ) throws SQLException, Exception
1286
    {
1286
    {
1287
        mLogger.debug("getDaemonInst " + di.instruction);
1287
        mLogger.debug("getDaemonInst {}", di.instruction);
1288
        boolean retVal = false;
1288
        boolean retVal = false;
1289
 
1289
 
1290
        if ( mUseDatabase )
1290
        if ( mUseDatabase )
1291
        {
1291
        {
1292
            try
1292
            try
Line 1350... Line 1350...
1350
     *  
1350
     *  
1351
     *  @param  instruction - PVID of the daemon instruction to process
1351
     *  @param  instruction - PVID of the daemon instruction to process
1352
     */
1352
     */
1353
    public void markDaemonInstInProgress(final int instruction) throws SQLException, Exception
1353
    public void markDaemonInstInProgress(final int instruction) throws SQLException, Exception
1354
    {
1354
    {
1355
        mLogger.debug("markDaemonInstInProgress " + instruction);
1355
        mLogger.debug("markDaemonInstInProgress {}", instruction);
1356
 
1356
 
1357
        if ( mUseDatabase )
1357
        if ( mUseDatabase )
1358
        {
1358
        {
1359
            try
1359
            try
1360
            {
1360
            {
Line 1376... Line 1376...
1376
     *  
1376
     *  
1377
     *  @param  instruction - PVID of Daemon Instruction to process
1377
     *  @param  instruction - PVID of Daemon Instruction to process
1378
     */
1378
     */
1379
    public void markDaemonInstCompleted(final int instruction) throws SQLException, Exception
1379
    public void markDaemonInstCompleted(final int instruction) throws SQLException, Exception
1380
    {
1380
    {
1381
        mLogger.debug("markDaemonInstCompletedConnect " + instruction);
1381
        mLogger.debug("markDaemonInstCompletedConnect {}", instruction);
1382
        boolean connectionCreated = false;
1382
        boolean connectionCreated = false;
1383
 
1383
 
1384
        try
1384
        try
1385
        {
1385
        {
1386
            if (! mIsConnected)
1386
            if (! mIsConnected)
Line 1461... Line 1461...
1461
     *  
1461
     *  
1462
     * Overridden in ReleaseManagerUtf 
1462
     * Overridden in ReleaseManagerUtf 
1463
     */
1463
     */
1464
    public String queryBaselineName(int baseline) throws SQLException, Exception
1464
    public String queryBaselineName(int baseline) throws SQLException, Exception
1465
    {
1465
    {
1466
        mLogger.debug("queryBaselineName " + mDaemon);
1466
        mLogger.debug("queryBaselineName {}", mDaemon);
1467
        StringBuilder retVal = new StringBuilder();
1467
        StringBuilder retVal = new StringBuilder();
1468
 
1468
 
1469
        String sql = "";
1469
        String sql = "";
1470
 
1470
 
1471
        if ( mDaemon )
1471
        if ( mDaemon )
Line 1535... Line 1535...
1535
        catch ( SQLException e )
1535
        catch ( SQLException e )
1536
        {
1536
        {
1537
            handleSQLException(e, "");
1537
            handleSQLException(e, "");
1538
        }
1538
        }
1539
 
1539
 
1540
        mLogger.info("queryBaselineName returned " + retVal);
1540
        mLogger.info("queryBaselineName returned {}", retVal);
1541
        return retVal.toString();
1541
        return retVal.toString();
1542
    }
1542
    }
1543
    
1543
    
1544
    /**only used in daemon mode
1544
    /**only used in daemon mode
1545
     *   select config from release_manager.build_service_config where service='MAIL SERVER';
1545
     *   select config from release_manager.build_service_config where service='MAIL SERVER';
Line 1577... Line 1577...
1577
        {
1577
        {
1578
            handleSQLException(e, "");
1578
            handleSQLException(e, "");
1579
        }
1579
        }
1580
 
1580
 
1581
 
1581
 
1582
        mLogger.info("queryMailServer returned " + retVal);
1582
        mLogger.info("queryMailServer returned {}", retVal);
1583
        return retVal;
1583
        return retVal;
1584
    }
1584
    }
1585
 
1585
 
1586
    /**only used in daemon mode
1586
    /**only used in daemon mode
1587
     * returns the configured service 
1587
     * returns the configured service 
Line 1616... Line 1616...
1616
        catch ( SQLException e )
1616
        catch ( SQLException e )
1617
        {
1617
        {
1618
            handleSQLException(e, "");
1618
            handleSQLException(e, "");
1619
        }
1619
        }
1620
 
1620
 
1621
        mLogger.debug("queryMailSender returned " + retVal);
1621
        mLogger.debug("queryMailSender returned {}", retVal);
1622
        return retVal;
1622
        return retVal;
1623
    }
1623
    }
1624
 
1624
 
1625
    /**only used in daemon mode
1625
    /**only used in daemon mode
1626
     * returns the configured global email addresses 
1626
     * returns the configured global email addresses 
Line 1658... Line 1658...
1658
        {
1658
        {
1659
            handleSQLException(e, "");
1659
            handleSQLException(e, "");
1660
        }
1660
        }
1661
 
1661
 
1662
 
1662
 
1663
        mLogger.debug("queryGlobalAddresses returned " + retVal);
1663
        mLogger.debug("queryGlobalAddresses returned {}", retVal);
1664
        return retVal;
1664
        return retVal;
1665
    }
1665
    }
1666
    
1666
    
1667
    /**
1667
    /**
1668
     * Determine a list of global, project wide and release email recipients
1668
     * Determine a list of global, project wide and release email recipients
Line 1776... Line 1776...
1776
     * @param rtag_id   - Target Release
1776
     * @param rtag_id   - Target Release
1777
     * @param buildFile - buildfile content to be saved
1777
     * @param buildFile - buildfile content to be saved
1778
     */
1778
     */
1779
    public void publishBuildFile(int rtag_id, BuildFile buildFile) throws SQLException, Exception
1779
    public void publishBuildFile(int rtag_id, BuildFile buildFile) throws SQLException, Exception
1780
    {
1780
    {
1781
        mLogger.debug("publishBuildFile publishing a build file of length " + buildFile.content.length());
1781
        mLogger.debug("publishBuildFile publishing a build file of length {}", buildFile.content.length());
1782
        mLogger.debug("publishBuildFile publishing pkgId: " + buildFile.mPkgId + " pvid: " + buildFile.mPvId);
1782
        mLogger.debug("publishBuildFile publishing pkgId: {} pvid: {}", buildFile.mPkgId, buildFile.mPvId);
1783
 
1783
 
1784
        try
1784
        try
1785
        {
1785
        {
1786
            connect();
1786
            connect();
1787
 
1787
 
Line 1824... Line 1824...
1824
        }
1824
        }
1825
        catch ( Exception e )
1825
        catch ( Exception e )
1826
        {
1826
        {
1827
            // this catch and rethrow is historical
1827
            // this catch and rethrow is historical
1828
            // problems were found using CallableStatement when updating a CLOB column with data > 4000 bytes
1828
            // problems were found using CallableStatement when updating a CLOB column with data > 4000 bytes
1829
            mLogger.error("publishBuildFile caught Exception " + e.getMessage());
1829
            mLogger.error("publishBuildFile caught Exception {}", e.getMessage());
1830
            throw new Exception("publishBuildFile caught Exception " + e.getMessage());
1830
            throw new Exception("publishBuildFile caught Exception " + e.getMessage());
1831
        }
1831
        }
1832
        finally
1832
        finally
1833
        {
1833
        {
1834
            // this block is executed regardless of what happens in the try block
1834
            // this block is executed regardless of what happens in the try block
Line 1897... Line 1897...
1897
            {
1897
            {
1898
                disconnect();
1898
                disconnect();
1899
            }
1899
            }
1900
        }
1900
        }
1901
        
1901
        
1902
        mLogger.warn("queryReleaseSeqNum returned " + retVal);
1902
        mLogger.warn("queryReleaseSeqNum returned {}", retVal);
1903
        return retVal;
1903
        return retVal;
1904
    }
1904
    }
1905
 
1905
 
1906
    /**
1906
    /**
1907
     * Disable all the daemons for a specific release
1907
     * Disable all the daemons for a specific release
Line 1912... Line 1912...
1912
     * @throws SQLException
1912
     * @throws SQLException
1913
     * @throws Exception
1913
     * @throws Exception
1914
     */
1914
     */
1915
    private void disableDaemons(final int rtag_id) throws SQLException, Exception
1915
    private void disableDaemons(final int rtag_id) throws SQLException, Exception
1916
    {
1916
    {
1917
        mLogger.error("disableDaemons: " + rtag_id );
1917
        mLogger.error("disableDaemons: {}", rtag_id );
1918
        
1918
        
1919
        try
1919
        try
1920
        {
1920
        {
1921
            CallableStatement stmt1 = mConnection.prepareCall( "call PK_BUILDAPI.set_daemon_states(?,2)" );
1921
            CallableStatement stmt1 = mConnection.prepareCall( "call PK_BUILDAPI.set_daemon_states(?,2)" );
1922
            stmt1.setInt( 1, rtag_id );
1922
            stmt1.setInt( 1, rtag_id );
Line 1963... Line 1963...
1963
        }
1963
        }
1964
        catch ( SQLException e )
1964
        catch ( SQLException e )
1965
        {
1965
        {
1966
            handleSQLException(e, "");
1966
            handleSQLException(e, "");
1967
        }
1967
        }
1968
        mLogger.info("isRtagIdConfigured returning " + retVal);
1968
        mLogger.info("isRtagIdConfigured returning {}", retVal);
1969
        return retVal;
1969
        return retVal;
1970
    }
1970
    }
1971
 
1971
 
1972
    /**queries the RUN_LEVEL table for daemon to determine if the daemon has been paused
1972
    /**queries the RUN_LEVEL table for daemon to determine if the daemon has been paused
1973
     * or disabled.
1973
     * or disabled.
Line 1987... Line 1987...
1987
     * @exception SQLException
1987
     * @exception SQLException
1988
     * @exception Exception
1988
     * @exception Exception
1989
     */
1989
     */
1990
    public boolean queryDirectedRunLevel(final int rcon_id) throws SQLException, Exception
1990
    public boolean queryDirectedRunLevel(final int rcon_id) throws SQLException, Exception
1991
    {
1991
    {
1992
        mLogger.debug("queryDirectedRunLevel " + rcon_id);
1992
        mLogger.debug("queryDirectedRunLevel {}", rcon_id);
1993
        boolean retVal = true;
1993
        boolean retVal = true;
1994
 
1994
 
1995
        if ( mUseDatabase )
1995
        if ( mUseDatabase )
1996
        {
1996
        {
1997
            try
1997
            try
Line 2035... Line 2035...
2035
            {
2035
            {
2036
                handleSQLException(e, "");
2036
                handleSQLException(e, "");
2037
            }
2037
            }
2038
        }
2038
        }
2039
 
2039
 
2040
        mLogger.info("queryDirectedRunLevel returning " + retVal);
2040
        mLogger.info("queryDirectedRunLevel returning {}", retVal);
2041
        return retVal;
2041
        return retVal;
2042
    }
2042
    }
2043
 
2043
 
2044
    /**
2044
    /**
2045
     * queries the RELEASE_CONFIG and BUILD_MACHINE_CONFIG tables using the rcon_id primary key, rtag_id, machine_hostname, daemon_mode
2045
     * queries the RELEASE_CONFIG and BUILD_MACHINE_CONFIG tables using the rcon_id primary key, rtag_id, machine_hostname, daemon_mode
Line 2122... Line 2122...
2122
                //      Handles case where daemon has just been started/restarted
2122
                //      Handles case where daemon has just been started/restarted
2123
                //
2123
                //
2124
                if ( daemon_mode == 'M' &&  build_age > 0 && days_since_last_build > (build_age + 1) )
2124
                if ( daemon_mode == 'M' &&  build_age > 0 && days_since_last_build > (build_age + 1) )
2125
                {
2125
                {
2126
                    long upTimeSecs = (System.currentTimeMillis() - threadStartTime)/1000;
2126
                    long upTimeSecs = (System.currentTimeMillis() - threadStartTime)/1000;
2127
                    mLogger.error("queryReleaseConfig 1: " + rtag_id + ", " + rcon_id + ", "+ daemon_mode + ", " + pause + ", " + build_age + ", " + days_since_last_build + ", " + upTimeSecs );
2127
                    mLogger.error("queryReleaseConfig 1: {},{},{},{},{},{},{}",rtag_id, rcon_id, daemon_mode, pause, build_age, days_since_last_build, upTimeSecs );
2128
                    if ( upTimeSecs > mPostponeShutdown)
2128
                    if ( upTimeSecs > mPostponeShutdown)
2129
                    {
2129
                    {
2130
                        disableDaemons(rtag_id);
2130
                        disableDaemons(rtag_id);
2131
                        pause = 2;
2131
                        pause = 2;
2132
                    }
2132
                    }
Line 2134... Line 2134...
2134
                    {
2134
                    {
2135
                        mLogger.error("queryReleaseConfig 1: Shutdown Postponed"  );    
2135
                        mLogger.error("queryReleaseConfig 1: Shutdown Postponed"  );    
2136
                    }
2136
                    }
2137
                }
2137
                }
2138
 
2138
 
2139
                mLogger.info("queryReleaseConfig 1: " + rtag_id + ", " + rcon_id + ", "+ daemon_mode + ", " + pause + ", " + build_age + ", " + days_since_last_build );
2139
                mLogger.info("queryReleaseConfig 1: {},{},{},{},{},{}",rtag_id, rcon_id, daemon_mode, pause, build_age, days_since_last_build  );
2140
 
2140
 
2141
                if ( pause <= 1 )
2141
                if ( pause <= 1 )
2142
                {
2142
                {
2143
                    retVal = true;
2143
                    retVal = true;
2144
                }
2144
                }
Line 2157... Line 2157...
2157
        catch ( SQLException e )
2157
        catch ( SQLException e )
2158
        {
2158
        {
2159
            handleSQLException(e, ":1");
2159
            handleSQLException(e, ":1");
2160
        }
2160
        }
2161
 
2161
 
2162
        mLogger.info("queryReleaseConfig 1 returning " + retVal);
2162
        mLogger.info("queryReleaseConfig 1 returning {}", retVal);
2163
        return retVal;
2163
        return retVal;
2164
    }
2164
    }
2165
 
2165
 
2166
    /**removes all elements from the mReleaseConfigCollection
2166
    /**removes all elements from the mReleaseConfigCollection
2167
     * handles database connection and disconnection
2167
     * handles database connection and disconnection
Line 2213... Line 2213...
2213
                int rcon_id = rset.mustGetInt("rcon_id");
2213
                int rcon_id = rset.mustGetInt("rcon_id");
2214
                
2214
                
2215
                char dm = 'S';          
2215
                char dm = 'S';          
2216
                String daemon_mode = rset.getString("daemon_mode","S");
2216
                String daemon_mode = rset.getString("daemon_mode","S");
2217
               
2217
               
2218
                mLogger.info("queryReleaseConfig 2 daemon_mode " + daemon_mode + ".");
2218
                mLogger.info("queryReleaseConfig 2 daemon_mode '{}'", daemon_mode);
2219
 
2219
 
2220
                if ( daemon_mode.compareTo("M") == 0 )
2220
                if ( daemon_mode.compareTo("M") == 0 )
2221
                {
2221
                {
2222
                    dm = 'M';
2222
                    dm = 'M';
2223
                }
2223
                }
Line 2271... Line 2271...
2271
     *  
2271
     *  
2272
     * Used by the BuildDaemon thread to determine daemons to start and stop
2272
     * Used by the BuildDaemon thread to determine daemons to start and stop
2273
     */
2273
     */
2274
    public void queryReleaseConfig(final String hostname) throws SQLException, Exception
2274
    public void queryReleaseConfig(final String hostname) throws SQLException, Exception
2275
    {
2275
    {
2276
        mLogger.debug("queryReleaseConfig 3 " + hostname);
2276
        mLogger.debug("queryReleaseConfig 3 {}", hostname);
2277
        mReleaseConfigCollection.resetData();
2277
        mReleaseConfigCollection.resetData();
2278
 
2278
 
2279
        try
2279
        try
2280
        {
2280
        {
2281
            connect();
2281
            connect();
Line 2314... Line 2314...
2314
                int rcon_id = rset.mustGetInt("rcon_id");
2314
                int rcon_id = rset.mustGetInt("rcon_id");
2315
 
2315
 
2316
                char dm = 'S';          
2316
                char dm = 'S';          
2317
                String daemon_mode = rset.getString("daemon_mode", "S");
2317
                String daemon_mode = rset.getString("daemon_mode", "S");
2318
 
2318
 
2319
                mLogger.info("queryReleaseConfig 3 daemon_mode " + daemon_mode + ".");
2319
                mLogger.info("queryReleaseConfig 3 daemon_mode '{}'", daemon_mode);
2320
 
2320
 
2321
                if ( daemon_mode.compareTo("M") == 0 )
2321
                if ( daemon_mode.compareTo("M") == 0 )
2322
                {
2322
                {
2323
                    dm = 'M';
2323
                    dm = 'M';
2324
                }
2324
                }
Line 2376... Line 2376...
2376
     *  Used by the Master and Slave Daemons 
2376
     *  Used by the Master and Slave Daemons 
2377
     *  Overridden in ReleaseManagerUtf 
2377
     *  Overridden in ReleaseManagerUtf 
2378
     */
2378
     */
2379
    public int queryMasterCount(final int rtag_id) throws SQLException, Exception
2379
    public int queryMasterCount(final int rtag_id) throws SQLException, Exception
2380
    {
2380
    {
2381
        mLogger.debug("queryMasterCount rtag_id " + rtag_id);
2381
        mLogger.debug("queryMasterCount rtag_id {}", rtag_id);
2382
 
2382
 
2383
        int masterCount = 0;
2383
        int masterCount = 0;
2384
        try
2384
        try
2385
        {
2385
        {
2386
            connect();
2386
            connect();
Line 2469... Line 2469...
2469
            disconnect();
2469
            disconnect();
2470
        }
2470
        }
2471
        return rv;
2471
        return rv;
2472
    }
2472
    }
2473
 
2473
 
2474
    /**in daemon mode
-
 
2475
     *  1 get planned package info
-
 
2476
     *     select pl.pv_id, p.pkg_id, p.pkg_name, pv.v_ext, pv.pkg_vcs_tag, pv.change_type
-
 
2477
     *     from release_manager.planned pl, release_manager.package_versions pv, release_manager.packages p
-
 
2478
     *     where pl.rtag_id=<mBaseline> and pv.build_type='A' and pv.dlocked='A'
-
 
2479
     *     and pv.pv_id=pl.pv_id and p.pkg_id=pv.pkg_id
-
 
2480
     *     order by pl.pv_id;
-
 
2481
     *  2 get planned package dependency info
-
 
2482
     *     select pl.pv_id, p.pkg_name, dpv.v_ext
-
 
2483
     *     from release_manager.planned pl, release_manager.package_versions pv, release_manager.package_dependencies pd, release_manager.package_versions dpv, release_manager.packages p
-
 
2484
     *     where pl.rtag_id=<mBaseline> and pv.build_type='A' and pv.dlocked='A'
-
 
2485
     *     and pv.pv_id = pl.pv_id and pd.pv_id=pl.pv_id and dpv.pv_id=pd.dpv_id and p.pkg_id=dpv.pkg_id
-
 
2486
     *     order by pl.pv_id;
-
 
2487
     *  3 get planned package build info
-
 
2488
     *     select pl.pv_id, bm.bm_name, bsa.bsa_name
-
 
2489
     *     from release_manager.planned pl, release_manager.package_versions pv, release_manager.package_build_info pbi, release_manager.build_machines bm, release_manager.build_standards_addendum bsa
-
 
2490
     *     where pl.rtag_id=<mBaseline> and pv.build_type='A' and pv.dlocked='A'
-
 
2491
     *     and pv.pv_id = pl.pv_id and pbi.pv_id=pv.pv_id and bm.bm_id=pbi.bm_id and bsa.bsa_id=pbi.bsa_id
-
 
2492
     *     order by pl.pv_id;
-
 
2493
     *  4 get planned package unit test info
-
 
2494
     *     select pl.pv_id, tt.test_type_name
-
 
2495
     *     from release_manager.planned pl, release_manager.package_versions pv, release_manager.unit_tests ut, release_manager.test_types tt
-
 
2496
     *     where pl.rtag_id=<mBaseline> and pv.build_type='A' and pv.dlocked='A'
-
 
2497
     *     and pv.pv_id = pl.pv_id and ut.pv_id=pv.pv_id and tt.test_type_id=ut.test_types_fk
-
 
2498
     *     order by pl.pv_id;
-
 
2499
     *  5 get planned package build failure info
-
 
2500
     *     select pl.pv_id, u.user_email
-
 
2501
     *     from release_manager.planned pl, release_manager.release_tags rt, release_manager.package_versions pv, release_manager.autobuild_failure af, release_manager.members_group mg, release_manager.users u
-
 
2502
     *     where pl.rtag_id=<mBaseline> and rt.rtag_id=pl.rtag_id and pv.build_type='A' and pv.dlocked='A'
-
 
2503
     *     and pv.pv_id = pl.pv_id and af.view_id=pl.view_id and mg.group_email_id=af.group_email_id and u.user_id=mg.user_id and af.proj_id=rt.proj_id
-
 
2504
     *     order by pl.pv_id;
-
 
2505
     *  6 get planned package do not ripple info
-
 
2506
     *     select pl.pv_id
-
 
2507
     *     from release_manager.planned pl, release_manager.package_versions pv, release_manager.do_not_ripple dnr
-
 
2508
     *     where pl.rtag_id=<mBaseline> and pv.build_type='A' and pv.dlocked='A'
-
 
2509
     *     and pv.pv_id = pl.pv_id and dnr.rtag_id=pl.rtag_id and dnr.pv_id=pl.pv_id
-
 
2510
     *     order by pl.pv_id;
-
 
2511
     *  7 get planned package advisory ripple info
-
 
2512
     *     select pl.pv_id
-
 
2513
     *     from release_manager.planned pl, release_manager.package_versions pv, release_manager.advisory_ripple ar
-
 
2514
     *     where pl.rtag_id=<mBaseline> and pv.build_type='A' and pv.dlocked='A'
-
 
2515
     *     and pv.pv_id = pl.pv_id and ar.rtag_id=pl.rtag_id and ar.pv_id=pl.pv_id
-
 
2516
     *     order by pl.pv_id;
-
 
2517
     *  8 get released package info
-
 
2518
     *     select rc.pv_id, p.pkg_id, p.pkg_name, pv.pkg_version, pv.v_ext, pv.pkg_vcs_tag, pv.ripple_field
-
 
2519
     *     pv.major_limit, pv.minor_limit, pv.patch_limit, pv.build_number_limit
-
 
2520
     *     from release_manager.release_content rc, release_manager.package_versions pv, release_manager.packages p
-
 
2521
     *     where rc.rtag_id=<mBaseline>
-
 
2522
     *     and pv.pv_id = rc.pv_id and p.pkg_id = pv.pkg_id
-
 
2523
     *     order by rc.pv_id;
-
 
2524
     *  9 get released package dependency info
-
 
2525
     *     select rc.pv_id, dpv.pv_id, p.pkg_name, dpv.v_ext
-
 
2526
     *     from release_manager.release_content rc, release_manager.package_versions pv, release_manager.package_dependencies pd, release_manager.package_versions dpv, release_manager.packages p
-
 
2527
     *     where rc.rtag_id=<mBaseline>
-
 
2528
     *     and pv.pv_id = rc.pv_id and pd.pv_id=pv.pv_id and dpv.pv_id=pd.dpv_id and p.pkg_id=dpv.pkg_id
-
 
2529
     *     order by rc.pv_id;
-
 
2530
     * 10 get released package build info
-
 
2531
     *     select rc.pv_id, bm.bm_name, bsa.bsa_name
-
 
2532
     *     from release_manager.release_content rc, release_manager.package_versions pv, release_manager.package_build_info pbi, release_manager.build_machines bm, release_manager.build_standards_addendum bsa
-
 
2533
     *     where rc.rtag_id=<mBaseline>
-
 
2534
     *     and pv.pv_id = rc.pv_id and pbi.pv_id=pv.pv_id and bm.bm_id=pbi.bm_id and bsa.bsa_id=pbi.bsa_id
-
 
2535
     *     order by rc.pv_id;
-
 
2536
     * 11 get released package unit test info
-
 
2537
     *     select rc.pv_id, tt.test_type_name
-
 
2538
     *     from release_manager.release_content rc, release_manager.package_versions pv, release_manager.unit_tests ut, release_manager.test_types tt
-
 
2539
     *     where rc.rtag_id=<mBaseline>
-
 
2540
     *     and pv.pv_id = rc.pv_id and ut.pv_id=pv.pv_id and tt.test_type_id=ut.test_types_fk
-
 
2541
     *     order by rc.pv_id;
-
 
2542
     * 12 get released package build failure email info
-
 
2543
     *     select rc.pv_id, u.user_email
-
 
2544
     *     from release_manager.release_content rc, release_manager.release_tags rt, release_manager.package_versions pv, release_manager.autobuild_failure af, release_manager.members_group mg, release_manager.users u
-
 
2545
     *     where rc.rtag_id=<mBaseline> and rt.rtag_id=rc.rtag_id
-
 
2546
     *     and pv.pv_id = rc.pv_id and af.view_id=rc.base_view_id and mg.group_email_id=af.group_email_id and u.user_id=mg.user_id and af.proj_id=rt.proj_id
-
 
2547
     *     order by rc.pv_id;
-
 
2548
     * 13 get released package do not ripple info
-
 
2549
     *     select rc.pv_id
-
 
2550
     *     from release_manager.release_content rc, release_manager.package_versions pv, release_manager.do_not_ripple dnr
-
 
2551
     *     where rc.rtag_id=<mBaseline>
-
 
2552
     *     and pv.pv_id = rc.pv_id and dnr.rtag_id=rc.rtag_id and dnr.pv_id=rc.pv_id
-
 
2553
     *     order by rc.pv_id;
-
 
2554
     * 14 get released advisory ripple info
-
 
2555
     *     select rc.pv_id
-
 
2556
     *     from release_manager.release_content rc, release_manager.package_versions pv, release_manager.advisory_ripple ar
-
 
2557
     *     where rc.rtag_id=<mBaseline>
-
 
2558
     *     and pv.pv_id = rc.pv_id and ar.rtag_id=rc.rtag_id and ar.pv_id=rc.pv_id
-
 
2559
     *     order by rc.pv_id;
-
 
2560
     *     
2474
    /**
2561
     * in escrow mode
-
 
2562
     *  1 get released product info
-
 
2563
     *     select oc.prod_id, p.pkg_name, pv.pkg_version, pv.v_ext, pv.pkg_vcs_tag
-
 
2564
     *     from deployment_manager.bom_contents bc, deployment_manager.operating_systems os, deployment_manager.os_contents oc, release_manager.package_versions pv, release_manager.packages p
-
 
2565
     *     where bc.bom_id=<mBaseline> and os.node_id=bc.node_id and oc.os_id=os.os_id and pv.pv_id=oc.prod_id and p.pkg_id=pv.pkg_id
-
 
2566
     *     order by oc.prod_id;
-
 
2567
     *    this will generate a list of pv_ids associated with products
2475
     * Extract all package-version information for planned, test and released packages
2568
     *    many in the list will reference cots products outside the scope of a escrow build
-
 
2569
     *  2 for each <pv_id>, call traverseDependencies( packageCollection, pv_id, false ) to traverse its set of dependencies
-
 
2570
     *  3 for each Package, call queryBuildInfo to get released package build info
2476
     * In escrow mode there are no Planned or Test packages.
2571
     *  
2477
     * 
2572
     * Supports
-
 
2573
     *    test_type_name="Autobuild UTF"
2478
     * @param   rippleEngine        - Instance to use
2574
     *    bm_name="Generic"|"Linux"|"Solaris"|"Win32"
2479
     * @param   packageCollection   - Package Collection structure to fill. Expected to be cleared
2575
     *    bsa_name="Debug"|"Production"|"Production and Debug"|"Java 1.4"|"Java 1.5"|"Java 1.6"
2480
     * @param   baseline            - RtagId of the release being processed, BomId of an Escrow being processed
2576
     *  
2481
     *  
2577
     * Overridden in ReleaseManagerUtf
2482
     * Overridden in ReleaseManagerUtf
2578
     *  
2483
     *  
2579
     */
2484
     */
2580
    
2485
    
2581
    protected void queryPackageVersions(
-
 
2582
            RippleEngine rippleEngine, 
-
 
2583
            ArrayList<Package> packageCollection, 
-
 
2584
            int baseline) throws SQLException, Exception
2486
    protected void queryPackageVersions(RippleEngine rippleEngine, ArrayList<Package> packageCollection, int baseline) throws SQLException, Exception
2585
    {
2487
    {
2586
        Phase phase = new Phase("rmData");
2488
        Phase phase = new Phase("rmData");
2587
        mLogger.debug("queryPackageVersions " + mDaemon);
2489
        mLogger.debug("queryPackageVersions {}", mDaemon);
2588
 
2490
 
2589
        try
2491
        try
2590
        {
2492
        {
2591
            if (mDaemon)
2493
            if (mDaemon)
2592
            {
2494
            {
Line 2622... Line 2524...
2622
 
2524
 
2623
                    // Previous Version of this package, without the project suffix
2525
                    // Previous Version of this package, without the project suffix
2624
                    String pkg_prevVersion = getBaseVersionNumber(pv_id);
2526
                    String pkg_prevVersion = getBaseVersionNumber(pv_id);
2625
                    if ( pkg_prevVersion == null)
2527
                    if ( pkg_prevVersion == null)
2626
                    {
2528
                    {
2627
                        mLogger.error("queryPackageVersions. No Previous version" + pv_id);
2529
                        mLogger.error("queryPackageVersions. No Previous version {}", pv_id);
2628
                        // show stopper
2530
                        // show stopper
2629
                        throw new Exception("queryPackageVersions. No Previous version" + pv_id);
2531
                        throw new Exception("queryPackageVersions. No Previous version" + pv_id);
2630
                    }
2532
                    }
2631
                    
2533
                    
2632
                    String v_ext = rset1.getString("v_ext","");
2534
                    String v_ext = rset1.getString("v_ext","");
Line 2674... Line 2576...
2674
                        // If there are multiple packages with the same Alias, then only the first one
2576
                        // If there are multiple packages with the same Alias, then only the first one
2675
                        // will be placed in the build set. The will be the oldest, the first one released
2577
                        // will be placed in the build set. The will be the oldest, the first one released
2676
                        // to be built
2578
                        // to be built
2677
                        if ( prevPlannedPackage == NULL_PACKAGE )
2579
                        if ( prevPlannedPackage == NULL_PACKAGE )
2678
                        {
2580
                        {
2679
                            mLogger.info("queryPackageVersions rset1 no previous planned package " + pv_id);
2581
                            mLogger.info("queryPackageVersions rset1 no previous planned package {}", pv_id);
2680
                            packageCollection.add(p);
2582
                            packageCollection.add(p);
2681
                        }
2583
                        }
2682
                    }
2584
                    }
2683
                }
2585
                }
2684
 
2586
 
Line 2714... Line 2616...
2714
                    int pv_id = rset2.mustGetKeyInt("pv_id");
2616
                    int pv_id = rset2.mustGetKeyInt("pv_id");
2715
                    Package p = findPackage(pv_id, packageCollection);
2617
                    Package p = findPackage(pv_id, packageCollection);
2716
 
2618
 
2717
                    if ( p == NULL_PACKAGE )
2619
                    if ( p == NULL_PACKAGE )
2718
                    {
2620
                    {
2719
                        mLogger.info("queryPackageVersions rset2 package superceded by planned " + pv_id);
2621
                        mLogger.info("queryPackageVersions rset2 package superceded by planned {}", pv_id);
2720
                        ignore = true;
2622
                        ignore = true;
2721
                    }
2623
                    }
2722
 
2624
 
2723
                    String pkg_name = rset2.mustGetString("pkg_name");
2625
                    String pkg_name = rset2.mustGetString("pkg_name");
2724
                    String v_ext = rset2.getString("v_ext","");
2626
                    String v_ext = rset2.getString("v_ext","");
Line 2759... Line 2661...
2759
                    int pv_id = rset3.mustGetKeyInt("pv_id");
2661
                    int pv_id = rset3.mustGetKeyInt("pv_id");
2760
 
2662
 
2761
                    Package p = findPackage(pv_id, packageCollection);
2663
                    Package p = findPackage(pv_id, packageCollection);
2762
                    if ( p == NULL_PACKAGE )
2664
                    if ( p == NULL_PACKAGE )
2763
                    {
2665
                    {
2764
                        mLogger.info("queryPackageVersions rset3 package superceded by planned " + pv_id);
2666
                        mLogger.info("queryPackageVersions rset3 package superceded by planned {}", pv_id);
2765
                        ignore = true;
2667
                        ignore = true;
2766
                    }
2668
                    }
2767
 
2669
 
2768
                    String bm_name = rset3.mustGetString("bm_name");
2670
                    String bm_name = rset3.mustGetString("bm_name");
2769
                    String bsa_name = rset3.mustGetString("bsa_name");
2671
                    String bsa_name = rset3.mustGetString("bsa_name");
Line 2807... Line 2709...
2807
 
2709
 
2808
                    int pv_id = rset4.mustGetKeyInt("pv_id");
2710
                    int pv_id = rset4.mustGetKeyInt("pv_id");
2809
                    Package p = findPackage(pv_id, packageCollection);
2711
                    Package p = findPackage(pv_id, packageCollection);
2810
                    if ( p == NULL_PACKAGE )
2712
                    if ( p == NULL_PACKAGE )
2811
                    {
2713
                    {
2812
                        mLogger.info("queryPackageVersions rset4 package superceded by planned " + pv_id);
2714
                        mLogger.info("queryPackageVersions rset4 package superceded by planned {}", pv_id);
2813
                        ignore = true;
2715
                        ignore = true;
2814
                    }
2716
                    }
2815
 
2717
 
2816
                    String test_type_name = rset4.mustGetString("test_type_name");
2718
                    String test_type_name = rset4.mustGetString("test_type_name");
2817
                    if ( !ignore )
2719
                    if ( !ignore )
Line 2855... Line 2757...
2855
                {
2757
                {
2856
                    int pv_id = rset5.mustGetKeyInt("pv_id");
2758
                    int pv_id = rset5.mustGetKeyInt("pv_id");
2857
                    Package p = findPackage(pv_id, packageCollection);
2759
                    Package p = findPackage(pv_id, packageCollection);
2858
                    if ( p == NULL_PACKAGE )
2760
                    if ( p == NULL_PACKAGE )
2859
                    {
2761
                    {
2860
                        mLogger.info("queryPackageVersions rset5 package superceded by planned " + pv_id);
2762
                        mLogger.info("queryPackageVersions rset5 package superceded by planned {}", pv_id);
2861
                    }
2763
                    }
2862
                    else
2764
                    else
2863
                    {
2765
                    {
2864
                        String user_email = rset5.getString("user_email", null);
2766
                        String user_email = rset5.getString("user_email", null);
2865
                        if ( user_email != null )
2767
                        if ( user_email != null )
Line 2901... Line 2803...
2901
                {
2803
                {
2902
                    int pv_id = rset6.mustGetKeyInt("pv_id");
2804
                    int pv_id = rset6.mustGetKeyInt("pv_id");
2903
                    Package p = findPackage(pv_id, packageCollection);
2805
                    Package p = findPackage(pv_id, packageCollection);
2904
                    if ( p == NULL_PACKAGE )
2806
                    if ( p == NULL_PACKAGE )
2905
                    {
2807
                    {
2906
                        mLogger.info("queryPackageVersions rset6 package superceded by planned " + pv_id);
2808
                        mLogger.info("queryPackageVersions rset6 package superceded by planned {}", pv_id);
2907
                    }
2809
                    }
2908
                    else
2810
                    else
2909
                    {
2811
                    {
2910
 
2812
 
2911
                        // walk the 3 columns of user_email in the resultset
2813
                        // walk the 3 columns of user_email in the resultset
Line 2949... Line 2851...
2949
 
2851
 
2950
                    int pv_id = rset7.mustGetInt("pv_id");
2852
                    int pv_id = rset7.mustGetInt("pv_id");
2951
                    Package p = findPackage(pv_id, packageCollection);
2853
                    Package p = findPackage(pv_id, packageCollection);
2952
                    if ( p == NULL_PACKAGE )
2854
                    if ( p == NULL_PACKAGE )
2953
                    {
2855
                    {
2954
                        mLogger.info("queryPackageVersions rset7 package superceded by planned " + pv_id);
2856
                        mLogger.info("queryPackageVersions rset7 package superceded by planned {}", pv_id);
2955
                        ignore = true;
2857
                        ignore = true;
2956
                    }
2858
                    }
2957
 
2859
 
2958
                    if ( !ignore )
2860
                    if ( !ignore )
2959
                    {
2861
                    {
Line 2976... Line 2878...
2976
              
2878
              
2977
                phase.setPhase("removeOldSchedBuilds");
2879
                phase.setPhase("removeOldSchedBuilds");
2978
                while ( getDaemonInst( di ) )
2880
                while ( getDaemonInst( di ) )
2979
                {
2881
                {
2980
                    markDaemonInstCompleted(di.instruction);
2882
                    markDaemonInstCompleted(di.instruction);
2981
                    mLogger.info("queryPackageVersions remove Scheduled Build Approvals " + di.pvId);
2883
                    mLogger.info("queryPackageVersions remove Scheduled Build Approvals {}", di.pvId);
2982
                }
2884
                }
2983
                
2885
                
2984
                phase.setPhase("getSchedBuilds");
2886
                phase.setPhase("getSchedBuilds");
2985
                di = new DaemonInstruction(baseline, 2, false);
2887
                di = new DaemonInstruction(baseline, 2, false);
2986
                while ( getDaemonInst( di ) )
2888
                while ( getDaemonInst( di ) )
2987
                {
2889
                {
2988
                    Package p = findPackage(di.pvId, packageCollection);
2890
                    Package p = findPackage(di.pvId, packageCollection);
2989
 
2891
 
2990
                    if ( p != NULL_PACKAGE )
2892
                    if ( p != NULL_PACKAGE )
2991
                    {
2893
                    {
2992
                        mLogger.info("queryPackageVersions Scheduled Build Approvals " + di.pvId);
2894
                        mLogger.info("queryPackageVersions Scheduled Build Approvals {}", di.pvId);
2993
                        packageCollection.remove(p);
2895
                        packageCollection.remove(p);
2994
                    }
2896
                    }
2995
                    else
2897
                    else
2996
                    {
2898
                    {
2997
                        // discard - the package no longer exists
2899
                        // discard - the package no longer exists
2998
                        markDaemonInstCompleted( di.instruction );
2900
                        markDaemonInstCompleted( di.instruction );
2999
                        mLogger.info("queryPackageVersions remove Scheduled Build Approvals for nonexistent package " + di.pvId);
2901
                        mLogger.info("queryPackageVersions remove Scheduled Build Approvals for nonexistent package {}", di.pvId);
3000
                    }
2902
                    }
3001
                }                
2903
                }                
3002
 
2904
 
3003
                // get released package info
2905
                // get released package info
3004
                //    Get package information on ALL released packages within the release of interest
2906
                //    Get package information on ALL released packages within the release of interest
Line 3076... Line 2978...
3076
                    //  Otherwise, add the the package to the package collection
2978
                    //  Otherwise, add the the package to the package collection
3077
                    //
2979
                    //
3078
                    Package plannedPackage = findPackage(p.mAlias, packageCollection);
2980
                    Package plannedPackage = findPackage(p.mAlias, packageCollection);
3079
                    if ( plannedPackage == NULL_PACKAGE )
2981
                    if ( plannedPackage == NULL_PACKAGE )
3080
                    {
2982
                    {
3081
                        mLogger.info("queryPackageVersions rset8 no planned package " + pv_id);
2983
                        mLogger.info("queryPackageVersions rset8 no planned package {}", pv_id);
3082
                        packageCollection.add(p);
2984
                        packageCollection.add(p);
3083
                    }
2985
                    }
3084
                    else
2986
                    else
3085
                    {
2987
                    {
3086
                        //  Copy these flags from the package that will be replaced
2988
                        //  Copy these flags from the package that will be replaced
Line 3127... Line 3029...
3127
                    int dpv_id = rset9.mustGetInt("dpv_id");
3029
                    int dpv_id = rset9.mustGetInt("dpv_id");
3128
                    Package p = findPackage(pv_id, packageCollection);
3030
                    Package p = findPackage(pv_id, packageCollection);
3129
 
3031
 
3130
                    if ( p == NULL_PACKAGE )
3032
                    if ( p == NULL_PACKAGE )
3131
                    {
3033
                    {
3132
                        mLogger.info("queryPackageVersions rset9 package superceded by planned " + pv_id);
3034
                        mLogger.info("queryPackageVersions rset9 package superceded by planned {}", pv_id);
3133
                        ignore = true;
3035
                        ignore = true;
3134
                    }
3036
                    }
3135
 
3037
 
3136
                    String pkg_name = rset9.mustGetString("pkg_name");
3038
                    String pkg_name = rset9.mustGetString("pkg_name");
3137
                    String v_ext = rset9.getString("v_ext","");
3039
                    String v_ext = rset9.getString("v_ext","");
Line 3173... Line 3075...
3173
                    boolean ignore = false;
3075
                    boolean ignore = false;
3174
                    int pv_id = rset10.mustGetKeyInt("pv_id");
3076
                    int pv_id = rset10.mustGetKeyInt("pv_id");
3175
                    Package p = findPackage(pv_id, packageCollection);
3077
                    Package p = findPackage(pv_id, packageCollection);
3176
                    if ( p == NULL_PACKAGE )
3078
                    if ( p == NULL_PACKAGE )
3177
                    {
3079
                    {
3178
                        mLogger.info("queryPackageVersions rset10 package superceded by planned " + pv_id);
3080
                        mLogger.info("queryPackageVersions rset10 package superceded by planned {}", pv_id);
3179
                        ignore = true;
3081
                        ignore = true;
3180
                    }
3082
                    }
3181
 
3083
 
3182
                    String bm_name = rset10.mustGetString("bm_name");
3084
                    String bm_name = rset10.mustGetString("bm_name");
3183
                    String bsa_name = rset10.mustGetString("bsa_name");
3085
                    String bsa_name = rset10.mustGetString("bsa_name");
Line 3215... Line 3117...
3215
 
3117
 
3216
                    int pv_id = rset11.mustGetKeyInt("pv_id");
3118
                    int pv_id = rset11.mustGetKeyInt("pv_id");
3217
                    Package p = findPackage(pv_id, packageCollection);
3119
                    Package p = findPackage(pv_id, packageCollection);
3218
                    if ( p == NULL_PACKAGE )
3120
                    if ( p == NULL_PACKAGE )
3219
                    {
3121
                    {
3220
                        mLogger.info("queryPackageVersions rset11 package superceded by planned " + pv_id);
3122
                        mLogger.info("queryPackageVersions rset11 package superceded by planned {}", pv_id);
3221
                        ignore = true;
3123
                        ignore = true;
3222
                    }
3124
                    }
3223
 
3125
 
3224
                    String test_type_name = rset11.mustGetString("test_type_name");
3126
                    String test_type_name = rset11.mustGetString("test_type_name");
3225
                    if ( !ignore )
3127
                    if ( !ignore )
Line 3264... Line 3166...
3264
                    int pv_id = rset12.mustGetKeyInt("pv_id");
3166
                    int pv_id = rset12.mustGetKeyInt("pv_id");
3265
                    Package p = findPackage(pv_id, packageCollection);
3167
                    Package p = findPackage(pv_id, packageCollection);
3266
 
3168
 
3267
                    if ( p == NULL_PACKAGE )
3169
                    if ( p == NULL_PACKAGE )
3268
                    {
3170
                    {
3269
                        mLogger.info("queryPackageVersions rset12 package superceded by planned " + pv_id);
3171
                        mLogger.info("queryPackageVersions rset12 package superceded by planned {}", pv_id);
3270
                    }
3172
                    }
3271
                    else
3173
                    else
3272
                    {
3174
                    {
3273
                        String user_email = rset12.getString("user_email",null);
3175
                        String user_email = rset12.getString("user_email",null);
3274
 
3176
 
Line 3301... Line 3203...
3301
 
3203
 
3302
                    int pv_id = rset14.mustGetInt("pv_id");
3204
                    int pv_id = rset14.mustGetInt("pv_id");
3303
                    Package p = findPackage(pv_id, packageCollection);
3205
                    Package p = findPackage(pv_id, packageCollection);
3304
                    if ( p == NULL_PACKAGE )
3206
                    if ( p == NULL_PACKAGE )
3305
                    {
3207
                    {
3306
                        mLogger.info("queryPackageVersions rset14 package superceded by planned " + pv_id);
3208
                        mLogger.info("queryPackageVersions rset14 package superceded by planned {}", pv_id);
3307
                        ignore = true;
3209
                        ignore = true;
3308
                    }
3210
                    }
3309
 
3211
 
3310
                    if ( !ignore )
3212
                    if ( !ignore )
3311
                    {
3213
                    {
Line 3325... Line 3227...
3325
                {
3227
                {
3326
                    Package p = findPackage(di.pvId, packageCollection);
3228
                    Package p = findPackage(di.pvId, packageCollection);
3327
 
3229
 
3328
                    if ( p != NULL_PACKAGE )
3230
                    if ( p != NULL_PACKAGE )
3329
                    {
3231
                    {
3330
                        mLogger.info("queryPackageVersions forced ripple data " + di.pvId);
3232
                        mLogger.info("queryPackageVersions forced ripple data {}", di.pvId);
3331
                        p.mForcedRippleInstruction = di.instruction;
3233
                        p.mForcedRippleInstruction = di.instruction;
3332
                        p.mTestBuildEmail = di.userEmail;
3234
                        p.mTestBuildEmail = di.userEmail;
3333
                    }
3235
                    }
3334
                    else
3236
                    else
3335
                    {
3237
                    {
Line 3364... Line 3266...
3364
                phase.setPhase("getTestBuild1");
3266
                phase.setPhase("getTestBuild1");
3365
                di = new DaemonInstruction( baseline, 1, true);
3267
                di = new DaemonInstruction( baseline, 1, true);
3366
                while ( getDaemonInst( di ) )
3268
                while ( getDaemonInst( di ) )
3367
                {
3269
                {
3368
                    // can only do one test build at a time - others will be discarded until future cycle
3270
                    // can only do one test build at a time - others will be discarded until future cycle
3369
                    mLogger.info("queryPackageVersions test build data " + di.pvId);
3271
                    mLogger.info("queryPackageVersions test build data {}", di.pvId);
3370
                    int testBuildPvId = di.pvId;
3272
                    int testBuildPvId = di.pvId;
3371
                    int testBuildInstruction = di.instruction;
3273
                    int testBuildInstruction = di.instruction;
3372
                    String testBuildEmail = di.userEmail; 
3274
                    String testBuildEmail = di.userEmail; 
3373
 
3275
 
3374
                    String pkg_name = "";
3276
                    String pkg_name = "";
Line 3403... Line 3305...
3403
                    stmt15.close();
3305
                    stmt15.close();
3404
 
3306
 
3405
                    mLogger.debug("queryPackageVersions: stmt16");
3307
                    mLogger.debug("queryPackageVersions: stmt16");
3406
                    if ( rsetSize == 0 )
3308
                    if ( rsetSize == 0 )
3407
                    {
3309
                    {
3408
                        mLogger.error("queryPackageVersions rset15 no data found " + di.instruction);
3310
                        mLogger.error("queryPackageVersions rset15 no data found {}", di.instruction);
3409
                        markDaemonInstCompleted( di.instruction );
3311
                        markDaemonInstCompleted( di.instruction );
3410
                    }
3312
                    }
3411
                    else
3313
                    else
3412
                    {
3314
                    {
3413
                        Package q = findPackage(pkg_name + pkg_ext, packageCollection);
3315
                        Package q = findPackage(pkg_name + pkg_ext, packageCollection);
Line 3559... Line 3461...
3559
                    }
3461
                    }
3560
                }
3462
                }
3561
 
3463
 
3562
                rset.close();
3464
                rset.close();
3563
                stmt.close();
3465
                stmt.close();
-
 
3466
                
-
 
3467
                //  Now have all the package-versions used in the SBOM need to 
-
 
3468
                //      determine all the dependent packages 
-
 
3469
                //      determine the build info for all the packages
-
 
3470
                
-
 
3471
                //  Determine all dependent packages
-
 
3472
                //  Note: use a ListIterator as it allows traverseDependencies to modify the packageCollection
-
 
3473
                for (ListIterator<Package> it = packageCollection.listIterator(); it.hasNext(); )
-
 
3474
                {
-
 
3475
                    Package p = it.next();
-
 
3476
                    traverseDependencies(packageCollection, p, false, it);
-
 
3477
                }
-
 
3478
 
-
 
3479
                //  Add required build information
-
 
3480
                for (Iterator<Package> it = packageCollection.iterator(); it.hasNext(); )
-
 
3481
                {
-
 
3482
                    Package p = it.next();
-
 
3483
                    queryBuildInfo(rippleEngine, p);
-
 
3484
                }
3564
            }
3485
            }
3565
        }
3486
        }
3566
        catch ( SQLException e )
3487
        catch ( SQLException e )
3567
        {
3488
        {
3568
            handleSQLException(e, "");
3489
            handleSQLException(e, "");
3569
        }
3490
        }
3570
 
-
 
3571
        if (!mDaemon)
-
 
3572
        {
-
 
3573
            // use a ListIterator as it allows traverseDependencies to modify the packageCollection
-
 
3574
            for (ListIterator<Package> it = packageCollection.listIterator(); it.hasNext(); )
-
 
3575
            {
-
 
3576
                Package p = it.next();
-
 
3577
                traverseDependencies(packageCollection, p, false, it);
-
 
3578
            }
-
 
3579
 
-
 
3580
            for (Iterator<Package> it = packageCollection.iterator(); it.hasNext(); )
-
 
3581
            {
-
 
3582
                Package p = it.next();
-
 
3583
                queryBuildInfo(rippleEngine, p);
-
 
3584
            }
-
 
3585
        }
-
 
3586
        phase.setPhase("End");
3491
        phase.setPhase("End");
3587
    }
3492
    }
3588
    
3493
    
3589
    
3494
    
3590
   /**	Determine the version number of the base package
3495
   /**	Determine the version number of the base package
Line 3651... Line 3556...
3651
			rset.close();
3556
			rset.close();
3652
			stmt.close();
3557
			stmt.close();
3653
        
3558
        
3654
    	} catch (SQLException e) {
3559
    	} catch (SQLException e) {
3655
    		baseVersion = null;
3560
    		baseVersion = null;
3656
    		mLogger.error("Exception for getBaseVersionNumber " + pv_id);
3561
    		mLogger.error("Exception for getBaseVersionNumber {}", pv_id);
3657
		}
3562
		}
3658
        return baseVersion;
3563
        return baseVersion;
3659
    }
3564
    }
3660
 
3565
 
3661
    /**called only in escrow mode
3566
    /** Called only in escrow mode
-
 
3567
     * 
-
 
3568
     * Used to process each package in the escrow list and to locate all dependent packages - recursively.
-
 
3569
     * 
3662
     * if checkCollection is true, checks the pv_id is in the packageCollection
3570
     * if checkCollection is true, checks the pv_id is in the packageCollection
3663
     * if checkCollection is false, or the pv_id is not in the collection
3571
     * if checkCollection is false, or the pv_id is not in the collection
3664
     * 1 traverses the pv_id package dependencies
3572
     *    Traverses the pv_id package dependencies
3665
     *   select dpv.pv_id, p.pkg_name, dpv.pkg_version, dpv.v_ext
-
 
3666
     *   from release_manager.package_versions pv, release_manager.package_dependencies pd, release_manager.package_versions dpv, release_manager.packages p
-
 
3667
     *   where pv.pv_id = <pv_id> and pd.pv_id=pv.pv_id and dpv.pv_id=pd.dpv_id and p.pkg_id=dpv.pkg_id
-
 
3668
     *   order by pv.pv_id;
-
 
3669
     * 2 for each dpv.pv_id in the resultset
3573
     *    for each dpv.pv_id in the resultset
3670
     *     call traverseDependencies( packageCollection, dpv.pv_id, true )
3574
     *     call traverseDependencies( packageCollection, dpv.pv_id, true )
3671
     *     if the pv_id is not in the collection, add it
3575
     *     if the pv_id is not in the collection, add it
-
 
3576
     * 
-
 
3577
     *   @param packageCollection   - Collection of packages being processed
-
 
3578
     *   @param pkg                 - Current package in the collection
-
 
3579
     *   @param checkCollection     - How to handle pkg not in the collection. False: Process all package dependencies. True: Skip if package is in collection
-
 
3580
     *   @param listIterator        - List iterator being used to iterate over packageCollection. Used to insert new packages
3672
     *   
3581
     *   
-
 
3582
     *   This function is called recursively
3673
     */
3583
     */
3674
    private void traverseDependencies(ArrayList<Package> packageCollection, Package pkg, 
3584
    private void traverseDependencies(ArrayList<Package> packageCollection, Package pkg, boolean checkCollection, ListIterator<Package> listIterator) throws SQLException, Exception
3675
            boolean checkCollection, 
-
 
3676
            ListIterator<Package> listIterator) throws SQLException, Exception
-
 
3677
            {
3585
    {
3678
        mLogger.debug("traverseDependencies " + checkCollection);
3586
        mLogger.debug("traverseDependencies {}", checkCollection);
3679
        boolean pvIdInCollection = false;
3587
        boolean pvIdInCollection = false;
3680
 
3588
 
3681
        if ( checkCollection )
3589
        if ( checkCollection )
3682
        {
3590
        {
3683
            for (Iterator<Package> it = packageCollection.iterator(); it.hasNext(); )
3591
            for (Iterator<Package> it = packageCollection.iterator(); it.hasNext(); )
Line 3735... Line 3643...
3735
            catch ( SQLException e )
3643
            catch ( SQLException e )
3736
            {
3644
            {
3737
                handleSQLException(e, "");
3645
                handleSQLException(e, "");
3738
            }
3646
            }
3739
 
3647
 
-
 
3648
            //  Process each dependent package
3740
            for (Iterator<Package> it = resultset.iterator(); it.hasNext();)
3649
            for (Iterator<Package> it = resultset.iterator(); it.hasNext();)
3741
            {
3650
            {
3742
                Package r = it.next();
3651
                Package r = it.next();
3743
                traverseDependencies(packageCollection, r, true, listIterator);
3652
                traverseDependencies(packageCollection, r, true, listIterator);
3744
 
3653
 
Line 3762... Line 3671...
3762
                    listIterator.add(r);
3671
                    listIterator.add(r);
3763
                }
3672
                }
3764
 
3673
 
3765
            }
3674
            }
3766
        }
3675
        }
3767
            }
3676
    }
3768
 
3677
 
3769
    /**called only in escrow mode to add build info to the Package
3678
    /** Called only in escrow mode
-
 
3679
     * 
3770
     * select bm.bm_name, bsa.bsa_name
3680
     *  <p>Add build information to a Package
3771
     * from release_manager.package_versions pv, release_manager.package_build_info pbi, release_manager.build_machines bm, release_manager.build_standards_addendum bsa
3681
     *  <br>Adds: bm_name and bsa_name, but only if they are supported
-
 
3682
     * 
3772
     * where pv.pv_id = <p.pv_id> and pbi.pv_id=pv.pv_id and bm.bm_id=pbi.bm_id and bsa.bsa_id=pbi.bsa_id
3683
     * @param   rippleEngine    - Ripple Engine being used
-
 
3684
     * @param   p               - Package to process
3773
     * order by pv.pv_id;
3685
     * 
3774
     */
3686
     */
3775
    private void queryBuildInfo(RippleEngine rippleEngine, Package p) throws SQLException, Exception
3687
    private void queryBuildInfo(RippleEngine rippleEngine, Package p) throws SQLException, Exception
3776
    {
3688
    {
3777
        mLogger.debug("queryBuildInfo");
3689
        mLogger.debug("queryBuildInfo");
3778
 
3690
 
Line 3819... Line 3731...
3819
     * @param   packageCollection   - Collection to scan
3731
     * @param   packageCollection   - Collection to scan
3820
     * @return  Package with the matching mID or NULL_PACKAGE if no package has the mID
3732
     * @return  Package with the matching mID or NULL_PACKAGE if no package has the mID
3821
     */
3733
     */
3822
    protected Package findPackage(int id, ArrayList<Package> packageCollection)
3734
    protected Package findPackage(int id, ArrayList<Package> packageCollection)
3823
    {
3735
    {
3824
        mLogger.debug("findPackage 1 id " + id);
3736
        mLogger.debug("findPackage 1 id {}", id);
3825
        Package retVal = NULL_PACKAGE;
3737
        Package retVal = NULL_PACKAGE;
3826
 
3738
 
3827
        for (Iterator<Package> it = packageCollection.iterator(); it.hasNext(); )
3739
        for (Iterator<Package> it = packageCollection.iterator(); it.hasNext(); )
3828
        {
3740
        {
3829
            Package p = it.next();
3741
            Package p = it.next();
Line 3833... Line 3745...
3833
                retVal = p;
3745
                retVal = p;
3834
                break;
3746
                break;
3835
            }
3747
            }
3836
        }
3748
        }
3837
 
3749
 
3838
        mLogger.debug("findPackage 1 returned " + retVal.mName);
3750
        mLogger.debug("findPackage 1 returned {}", retVal.mName);
3839
        return retVal;
3751
        return retVal;
3840
    }
3752
    }
3841
 
3753
 
3842
    /**
3754
    /**
3843
     * Find Package by package alias
3755
     * Find Package by package alias
Line 3845... Line 3757...
3845
     * @param   packageCollection   - Collection to scan
3757
     * @param   packageCollection   - Collection to scan
3846
     * @return  Package with the matching mAlias or NULL_PACKAGE if no package has the mAlias
3758
     * @return  Package with the matching mAlias or NULL_PACKAGE if no package has the mAlias
3847
     */
3759
     */
3848
    protected Package findPackage(String alias, ArrayList<Package> packageCollection)
3760
    protected Package findPackage(String alias, ArrayList<Package> packageCollection)
3849
    {
3761
    {
3850
        mLogger.debug("findPackage 2 alias " + alias);
3762
        mLogger.debug("findPackage 2 alias {}", alias);
3851
        Package retVal = NULL_PACKAGE;
3763
        Package retVal = NULL_PACKAGE;
3852
 
3764
 
3853
        for (Iterator<Package> it = packageCollection.iterator(); it.hasNext(); )
3765
        for (Iterator<Package> it = packageCollection.iterator(); it.hasNext(); )
3854
        {
3766
        {
3855
            Package p = it.next();
3767
            Package p = it.next();
Line 3859... Line 3771...
3859
                retVal = p;
3771
                retVal = p;
3860
                break;
3772
                break;
3861
            }
3773
            }
3862
        }
3774
        }
3863
 
3775
 
3864
        mLogger.info("findPackage 2 returned " + retVal.mName);
3776
        mLogger.info("findPackage 2 returned {}", retVal.mName);
3865
        return retVal;
3777
        return retVal;
3866
    }
3778
    }
3867
 
3779
 
3868
    /**only used in daemon mode to determine version existence in the database
3780
    /**only used in daemon mode to determine version existence in the database
3869
     *  1 select pkg_id from release_manager.package_versions where pkg_id=<pkg_id> and pkg_version=<pkg_version>;
3781
     *  1 select pkg_id from release_manager.package_versions where pkg_id=<pkg_id> and pkg_version=<pkg_version>;
Line 3897... Line 3809...
3897
                rset1.close();
3809
                rset1.close();
3898
                stmt1.close();
3810
                stmt1.close();
3899
 
3811
 
3900
                if ( rsetSize > 1 )
3812
                if ( rsetSize > 1 )
3901
                {
3813
                {
3902
                    mLogger.error("queryPackageVersions rsetSize > 1 " + pkg_id + " " + pkg_version);
3814
                    String msg = "queryPackageVersions rsetSize > 1 " + pkg_id + " " + pkg_version;
-
 
3815
                    mLogger.error(msg);
3903
                    // show stopper
3816
                    // show stopper
3904
                    throw new Exception("queryPackageVersions rsetSize > 1 " + pkg_id + " " + pkg_version);
3817
                    throw new Exception(msg);
3905
                }
3818
                }
3906
 
3819
 
3907
                if ( rsetSize == 1 )
3820
                if ( rsetSize == 1 )
3908
                {
3821
                {
3909
                    retVal = true;
3822
                    retVal = true;
Line 3927... Line 3840...
3927
                    rset2.close();
3840
                    rset2.close();
3928
                    stmt2.close();
3841
                    stmt2.close();
3929
 
3842
 
3930
                    if ( rsetSize > 1 )
3843
                    if ( rsetSize > 1 )
3931
                    {
3844
                    {
3932
                        mLogger.error("queryPackageVersions rsetSize > 1 " + pkg_id + " " + pkg_version);
3845
                        String msg = "queryPackageVersions rsetSize > 1 " + pkg_id + " " + pkg_version;
-
 
3846
                        mLogger.error(msg);
3933
                        // show stopper
3847
                        // show stopper
3934
                        throw new Exception("queryPackageVersions rsetSize > 1 " + pkg_id + " " + pkg_version);
3848
                        throw new Exception(msg);
3935
                    }
3849
                    }
3936
 
3850
 
3937
                    if ( rsetSize == 1 )
3851
                    if ( rsetSize == 1 )
3938
                    {
3852
                    {
3939
                        retVal = true;
3853
                        retVal = true;
Line 3944... Line 3858...
3944
            {
3858
            {
3945
                handleSQLException(e, "");
3859
                handleSQLException(e, "");
3946
            }
3860
            }
3947
        }
3861
        }
3948
 
3862
 
3949
        mLogger.info("queryPackageVersions returned " + retVal);
3863
        mLogger.info("queryPackageVersions returned {}", retVal);
3950
        return retVal;
3864
        return retVal;
3951
    }
3865
    }
3952
 
3866
 
3953
    /**
3867
    /**
3954
     * Determine the set of packages that have been excluded from the build 
3868
     * Determine the set of packages that have been excluded from the build 
Line 3962... Line 3876...
3962
     * @exception SQLException
3876
     * @exception SQLException
3963
     * @exception Exception
3877
     * @exception Exception
3964
     */
3878
     */
3965
    public void queryBuildExclusions(List<BuildExclusion> buildExclusionCollection, int baseline) throws SQLException, Exception
3879
    public void queryBuildExclusions(List<BuildExclusion> buildExclusionCollection, int baseline) throws SQLException, Exception
3966
    {
3880
    {
3967
        mLogger.debug("queryBuildExclusions " + baseline);
3881
        mLogger.debug("queryBuildExclusions {}", baseline);
3968
 
3882
 
3969
        try
3883
        try
3970
        {
3884
        {
3971
            PreparedStatement stmt = mConnection.prepareStatement(
3885
            PreparedStatement stmt = mConnection.prepareStatement(
3972
                    "select pv_id, root_pv_id, root_cause" +
3886
                    "select pv_id, root_pv_id, root_cause" +
Line 4026... Line 3940...
4026
            String rootPvId, 
3940
            String rootPvId, 
4027
            String rootCause,
3941
            String rootCause,
4028
            String rootFile,
3942
            String rootFile,
4029
            boolean supercede, Boolean testBuildInstruction) throws SQLException, Exception
3943
            boolean supercede, Boolean testBuildInstruction) throws SQLException, Exception
4030
    {
3944
    {
4031
        mLogger.debug("excludeFromBuild " + packageVersionId);
3945
        mLogger.debug("excludeFromBuild {}", packageVersionId);
4032
 
3946
 
4033
        //  If a Test Build, then don't excluded package
3947
        //  If a Test Build, then don't excluded package
4034
        if ( testBuildInstruction )
3948
        if ( testBuildInstruction )
4035
        {
3949
        {
4036
            return;
3950
            return;
Line 4104... Line 4018...
4104
                    int result = stmt.getInt( 1 );
4018
                    int result = stmt.getInt( 1 );
4105
 
4019
 
4106
                    if ( result != 0 )
4020
                    if ( result != 0 )
4107
                    {
4021
                    {
4108
                        // flag build failure
4022
                        // flag build failure
4109
                        mLogger.error( "excludeFromBuild show stopper PK_RMAPI.EXCLUDE_INDIRECT_FROM_BUILD failed, returned " + result );
4023
                        mLogger.error( "excludeFromBuild show stopper PK_RMAPI.EXCLUDE_INDIRECT_FROM_BUILD failed, returned {}",  result );
4110
                        throw new Exception("excludeFromBuild show stopper PK_RMAPI.EXCLUDE_INDIRECT_FROM_BUILD failed, returned " + result);
4024
                        throw new Exception("excludeFromBuild show stopper PK_RMAPI.EXCLUDE_INDIRECT_FROM_BUILD failed, returned " + result);
4111
                    }
4025
                    }
4112
                    stmt.close();
4026
                    stmt.close();
4113
                    if (!hasConnection )
4027
                    if (!hasConnection )
4114
                        commit();
4028
                        commit();
Line 4141... Line 4055...
4141
     * @exception Exception
4055
     * @exception Exception
4142
     */
4056
     */
4143
 
4057
 
4144
    public void includeToBuild(int packageVersionId, int rtagId) throws SQLException, Exception
4058
    public void includeToBuild(int packageVersionId, int rtagId) throws SQLException, Exception
4145
    {
4059
    {
4146
        mLogger.debug("includeToBuild " + packageVersionId);
4060
        mLogger.debug("includeToBuild {}", packageVersionId);
4147
        if ( mUseDatabase )
4061
        if ( mUseDatabase )
4148
        {
4062
        {
4149
            try
4063
            try
4150
            {
4064
            {
4151
                CallableStatement stmt = mConnection.prepareCall(
4065
                CallableStatement stmt = mConnection.prepareCall(
Line 4179... Line 4093...
4179
     */
4093
     */
4180
    public String queryBuildFile(int rcon_id) throws SQLException, Exception
4094
    public String queryBuildFile(int rcon_id) throws SQLException, Exception
4181
    {
4095
    {
4182
        String buildFile = null;
4096
        String buildFile = null;
4183
        
4097
        
4184
        mLogger.debug("queryRunLevel 1 rcon_id " + rcon_id);
4098
        mLogger.debug("queryRunLevel 1 rcon_id {}", rcon_id);
4185
        if ( !mUseDatabase )
4099
        if ( !mUseDatabase )
4186
        {
4100
        {
4187
            mLogger.info("queryRunLevel 1 !mUseDatabase");
4101
            mLogger.info("queryRunLevel 1 !mUseDatabase");
4188
            buildFile = "unit test build file content";
4102
            buildFile = "unit test build file content";
4189
        }
4103
        }
Line 4242... Line 4156...
4242
     *	Used by the Master Daemon 
4156
     *	Used by the Master Daemon 
4243
     * 	Overridden in ReleaseManagerUtf 
4157
     * 	Overridden in ReleaseManagerUtf 
4244
     */
4158
     */
4245
    public void queryRunLevel(final int rtag_id) throws SQLException, Exception
4159
    public void queryRunLevel(final int rtag_id) throws SQLException, Exception
4246
    {
4160
    {
4247
        mLogger.debug("queryRunLevel 2 rtag_id " + rtag_id);
4161
        mLogger.debug("queryRunLevel 2 rtag_id {}", rtag_id);
4248
 
4162
 
4249
        mRunLevelCollection.clear();
4163
        mRunLevelCollection.clear();
4250
 
4164
 
4251
        try
4165
        try
4252
        {
4166
        {
Line 4331... Line 4245...
4331
     * @exception Exception Too many rows extracted from the database
4245
     * @exception Exception Too many rows extracted from the database
4332
     *                      Empty(NULL) data in database
4246
     *                      Empty(NULL) data in database
4333
     */
4247
     */
4334
    public void querySingleRunLevel(final int rcon_id, String hostname, char daemon_mode) throws SQLException, Exception
4248
    public void querySingleRunLevel(final int rcon_id, String hostname, char daemon_mode) throws SQLException, Exception
4335
    {
4249
    {
4336
        mLogger.debug("querySingleRunLevel rcon_id " + rcon_id);
4250
        mLogger.debug("querySingleRunLevel rcon_id {}", rcon_id);
4337
        mRunLevelCollection.clear();
4251
        mRunLevelCollection.clear();
4338
 
4252
 
4339
        try
4253
        try
4340
        {
4254
        {
4341
            connect();
4255
            connect();
Line 4479... Line 4393...
4479
 
4393
 
4480
                        if ( sr != null )
4394
                        if ( sr != null )
4481
                        {
4395
                        {
4482
                            Date scheduledResume = new Date( sr.getTime() );
4396
                            Date scheduledResume = new Date( sr.getTime() );
4483
                            int repeat = rset.getInt("repeat");
4397
                            int repeat = rset.getInt("repeat");
4484
                            mLogger.info("queryRunLevelSchedule repeat " + repeat);
4398
                            mLogger.info("queryRunLevelSchedule repeat {}", repeat);
4485
 
4399
 
4486
                            //
4400
                            //
4487
                            //  Have scheduled_pause and scheduled_resume
4401
                            //  Have scheduled_pause and scheduled_resume
4488
                            //  Examine the repeat field and determine how these are used
4402
                            //  Examine the repeat field and determine how these are used
4489
                            //  Supported repeat:
4403
                            //  Supported repeat:
Line 4597... Line 4511...
4597
            {
4511
            {
4598
                handleSQLException(e, ":2");
4512
                handleSQLException(e, ":2");
4599
            }
4513
            }
4600
        }
4514
        }
4601
 
4515
 
4602
        mLogger.info("queryRunLevelSchedule returning " + retVal);
4516
        mLogger.info("queryRunLevelSchedule returning {}", retVal);
4603
        return retVal;
4517
        return retVal;
4604
    }
4518
    }
4605
 
4519
 
4606
    /**persists the runLevel in the RUN_LEVEL table for the rcon_id primary key
4520
    /**persists the runLevel in the RUN_LEVEL table for the rcon_id primary key
4607
     * 
4521
     * 
Line 4617... Line 4531...
4617
 
4531
 
4618
        try
4532
        try
4619
        {
4533
        {
4620
            connect();
4534
            connect();
4621
 
4535
 
4622
            mLogger.warn("updateCurrentRunLevel: Set Runlevel:" + runLevel + ", rcon_id: " + rcon_id);
4536
            mLogger.warn("updateCurrentRunLevel: Set Runlevel:{}, rconId:{}", runLevel, rcon_id);
4623
            PreparedStatement stmt = mConnection.prepareCall("update release_manager.run_level set current_run_level=" + runLevel + ", keep_alive=SYSDATE where rcon_id=" + rcon_id);
4537
            PreparedStatement stmt = mConnection.prepareCall("update release_manager.run_level set current_run_level=" + runLevel + ", keep_alive=SYSDATE where rcon_id=" + rcon_id);
4624
            stmt.executeUpdate();
4538
            stmt.executeUpdate();
4625
            stmt.close();
4539
            stmt.close();
4626
 
4540
 
4627
            mLogger.info("updateCurrentRunLevel: committing");
4541
            mLogger.info("updateCurrentRunLevel: committing");
Line 4650... Line 4564...
4650
     * @param mBuildOrder - Ordered list of PackageVersions that we plan to build
4564
     * @param mBuildOrder - Ordered list of PackageVersions that we plan to build
4651
     * @throws Exception 
4565
     * @throws Exception 
4652
     * @throws SQLException 
4566
     * @throws SQLException 
4653
     */
4567
     */
4654
    public void reportPlan(int mRtagId, List<Package> mBuildOrder) throws SQLException, Exception {
4568
    public void reportPlan(int mRtagId, List<Package> mBuildOrder) throws SQLException, Exception {
4655
        mLogger.debug("reportPlan " + mRtagId);
4569
        mLogger.debug("reportPlan {}", mRtagId);
4656
 
4570
 
4657
        if ( mUseDatabase )
4571
        if ( mUseDatabase )
4658
        {
4572
        {
4659
            try
4573
            try
4660
            {
4574
            {
Line 4713... Line 4627...
4713
            }
4627
            }
4714
        }
4628
        }
4715
    }
4629
    }
4716
    
4630
    
4717
    public void updateBuildDuration(int pvId, int duration) throws Exception {
4631
    public void updateBuildDuration(int pvId, int duration) throws Exception {
4718
        mLogger.debug("updateBuildDuration " + pvId + ":" + duration);
4632
        mLogger.debug("updateBuildDuration {}:{}", pvId, duration);
4719
        if ( mUseDatabase )
4633
        if ( mUseDatabase )
4720
        {
4634
        {
4721
            try
4635
            try
4722
            {
4636
            {
4723
                connect();
4637
                connect();