Package hudson.scm
Class DerbyUtils
java.lang.Object
hudson.scm.DerbyUtils
This class provides certain utility functions for working with the embedded derby database
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String------------ CP Cache tables end --------------------static final Stringstatic final Stringstatic final String------------ CP Cache tables --------------------static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcleanupProjectCache(ConnectionPoolDataSource dataSource, String jobName, long buildNumber) Maintenance function to limit project cache to the most recent buildsstatic intcompareBaseline(String serverConfigId, String baselineProjectCache, String projectCacheTable, Map<IntegrityCMMember.CPInfo, List<IntegrityCMMember.CPMember>> membersInCP, boolean skipAuthorInfo, boolean CPMode) Compares this version of the project to a previous/new version to determine what are the updates and what was deletedstatic booleancreateCMProjectTables(ConnectionPoolDataSource dataSource, String tableName) Establishes a fresh set of Integrity SCM cache tablesstatic ConnectionPoolDataSourcecreateConnectionPoolDataSource(String derbyHome) Creates a pooled connection data source for the derby databasestatic booleancreateRegistry(ConnectionPoolDataSource dataSource) Creates the Integrity SCM cache registry tablestatic voiddeleteProjectCache(ConnectionPoolDataSource dataSource, String jobName) Maintenance function to delete all inactive project cache tablesdoCPCacheOperations(String cpCacheTable, String cp, String cpState, String operation) Cache the list of CPs (all states except "closed").static booleanexecuteStmt(ConnectionPoolDataSource dataSource, String sql) Generic SQL statement execution functionstatic StringfixDescription(String desc) Attempts to fix known issues with characters that can potentially break the change log xmlstatic StringgetAuthorFromRevisionInfo(String serverConfigId, String configPath, String memberID, String memberRev) Performs a revision info on this Integrity Source Filestatic StringgetCachedTableFromRegistry(String tableName, ConnectionPoolDataSource dataSource, String jobName, String configurationName, long buildNumber) Returns the name of the project cache table for the specified job/configuration and buildstatic booleangetCPCacheTable(ConnectionPoolDataSource dataSource, String cpCacheTableName) Create or return existing CP cache tablegetDirList(String projectCacheTable) Returns a string list of relative paths to all directories in this projectgetDistinctJobNames(ConnectionPoolDataSource dataSource) Maintenance function that returns a list of distinct job names for additional checking to see which ones are inactivestatic final CM_PROJECTReturns the CM_PROJECT column name for the string column namestatic intgetRowCount(ResultSet rs) This function provides a count of the total number of rows in the ResultSetstatic Hashtable<CM_PROJECT, Object> getRowData(ResultSet rs) Convenience function that converts a result set row into a Hashtable for easy accessstatic final StringRandom unique id generator for cache table namesstatic voidUtility function to load the Java DB Driverstatic voidprimeAuthorInformation(String serverConfigId, String projectCacheTable) Updates the author information for all the members in the projectstatic StringregisterProjectCache(ConnectionPoolDataSource dataSource, String jobName, String configurationName, long buildNumber) Creates a single Integrity SCM Project/Configuration cache tablestatic voidupdateChecksum(String projectCacheTable, ConcurrentHashMap<String, String> checksumHash) Updates the underlying Integrity SCM Project table cache with the new checksum informationstatic List<Hashtable<CM_PROJECT, Object>> viewProject(String projectCacheTable) Project access function that returns the state of the current project NOTE: For maximum efficiency, this should be called only once and after the compareBasline() has been invoked!static List<Hashtable<CM_PROJECT, Object>> viewSubProjects(String projectCacheTable) Project access function that returns the state of the current project NOTE: For maximum efficiency, this should be called only once and after the compareBasline() has been invoked!
-
Field Details
-
DERBY_DRIVER
- See Also:
-
DERBY_SYS_HOME_PROPERTY
- See Also:
-
DERBY_URL_PREFIX
- See Also:
-
CREATE_INTEGRITY_SCM_REGISTRY
- See Also:
-
SELECT_REGISTRY_1
- See Also:
-
SELECT_REGISTRY_TABLE
- See Also:
-
SELECT_REGISTRY_TABLE_DROP
- See Also:
-
INSERT_REGISTRY_ENTRY
- See Also:
-
SELECT_REGISTRY_DISTINCT_PROJECTS
- See Also:
-
SELECT_REGISTRY_PROJECTS
- See Also:
-
SELECT_REGISTRY_PROJECT
- See Also:
-
DROP_REGISTRY_ENTRY
- See Also:
-
CREATE_PROJECT_TABLE
-
DROP_PROJECT_TABLE
- See Also:
-
SELECT_MEMBER_1
-
SELECT_CP_1
------------ CP Cache tables -------------------- -
CREATE_PROJECT_CP_TABLE
-
INSERT_CP_RECORD
-
CP_SELECT
-
DELETE_CP_RECORD
-
INSERT_MEMBER_RECORD
------------ CP Cache tables end -------------------- -
BASELINE_SELECT
-
DELTA_SELECT
-
PROJECT_SELECT
-
SUB_PROJECT_SELECT
-
AUTHOR_SELECT
-
DIR_SELECT
-
CHECKSUM_UPDATE
-
CP_MEMBER_SELECT
-
-
Constructor Details
-
DerbyUtils
public DerbyUtils()
-
-
Method Details
-
getEnum
Returns the CM_PROJECT column name for the string column name- Parameters:
name-- Returns:
-
getUUIDTableName
Random unique id generator for cache table names- Returns:
-
loadDerbyDriver
public static void loadDerbyDriver()Utility function to load the Java DB Driver -
createConnectionPoolDataSource
Creates a pooled connection data source for the derby database- Returns:
-
executeStmt
public static boolean executeStmt(ConnectionPoolDataSource dataSource, String sql) throws SQLException Generic SQL statement execution function- Parameters:
dataSource- A pooled connection data sourcesql- String sql statement- Returns:
- Throws:
SQLException
-
createRegistry
Creates the Integrity SCM cache registry table- Parameters:
dataSource-- Returns:
-
registerProjectCache
public static String registerProjectCache(ConnectionPoolDataSource dataSource, String jobName, String configurationName, long buildNumber) throws SQLException Creates a single Integrity SCM Project/Configuration cache table- Parameters:
dataSource-jobName-configurationName-buildNumber-- Returns:
- Throws:
SQLException
-
getCachedTableFromRegistry
public static String getCachedTableFromRegistry(String tableName, ConnectionPoolDataSource dataSource, String jobName, String configurationName, long buildNumber) throws SQLException Returns the name of the project cache table for the specified job/configuration and build- Parameters:
dataSource-jobName-configurationName-buildNumber-- Returns:
- Throws:
SQLException
-
getDistinctJobNames
public static List<String> getDistinctJobNames(ConnectionPoolDataSource dataSource) throws SQLException Maintenance function that returns a list of distinct job names for additional checking to see which ones are inactive- Parameters:
dataSource-- Returns:
- Throws:
SQLException
-
deleteProjectCache
public static void deleteProjectCache(ConnectionPoolDataSource dataSource, String jobName) throws SQLException Maintenance function to delete all inactive project cache tables- Parameters:
dataSource-jobName-- Throws:
SQLException
-
cleanupProjectCache
public static void cleanupProjectCache(ConnectionPoolDataSource dataSource, String jobName, long buildNumber) throws SQLException Maintenance function to limit project cache to the most recent builds- Parameters:
dataSource-jobName-buildNumber-- Throws:
SQLException
-
createCMProjectTables
Establishes a fresh set of Integrity SCM cache tables- Parameters:
db- Derby database connection- Returns:
- true/false depending on the success of the operation
-
getCPCacheTable
Create or return existing CP cache table- Parameters:
i-configurationName-db- Derby database connection- Returns:
- true/false depending on the success of the operation
-
getRowData
public static Hashtable<CM_PROJECT,Object> getRowData(ResultSet rs) throws SQLException, IOException Convenience function that converts a result set row into a Hashtable for easy access- Parameters:
rs- ResultSet row object- Returns:
- Hashtable containing the non-null values for each column
- Throws:
SQLExceptionIOException
-
getRowCount
This function provides a count of the total number of rows in the ResultSet- Parameters:
set-- Returns:
- Throws:
SQLException
-
fixDescription
Attempts to fix known issues with characters that can potentially break the change log xml- Parameters:
desc- Input comment string for the revision- Returns:
- Sanitized string that can be embedded within a CDATA tag
-
compareBaseline
public static int compareBaseline(String serverConfigId, String baselineProjectCache, String projectCacheTable, Map<IntegrityCMMember.CPInfo, List<IntegrityCMMember.CPMember>> membersInCP, boolean skipAuthorInfo, boolean CPMode) throws SQLException, IOExceptionCompares this version of the project to a previous/new version to determine what are the updates and what was deleted- Parameters:
baselineProjectCache- The previous baseline (build) for this Integrity CM Projectreturn- The total number of changes found in the comparison- Throws:
SQLExceptionIOException
-
primeAuthorInformation
public static void primeAuthorInformation(String serverConfigId, String projectCacheTable) throws SQLException, IOException Updates the author information for all the members in the project- Throws:
SQLExceptionIOException
-
updateChecksum
public static void updateChecksum(String projectCacheTable, ConcurrentHashMap<String, String> checksumHash) throws SQLException, IOExceptionUpdates the underlying Integrity SCM Project table cache with the new checksum information- Parameters:
checksumHash- Checksum hashtable generated from a checkout operation- Throws:
SQLExceptionIOException
-
viewProject
public static List<Hashtable<CM_PROJECT,Object>> viewProject(String projectCacheTable) throws SQLException, IOException Project access function that returns the state of the current project NOTE: For maximum efficiency, this should be called only once and after the compareBasline() has been invoked!- Returns:
- A List containing every member in this project, including any dropped artifacts
- Throws:
SQLExceptionIOException
-
viewSubProjects
public static List<Hashtable<CM_PROJECT,Object>> viewSubProjects(String projectCacheTable) throws SQLException, IOException Project access function that returns the state of the current project NOTE: For maximum efficiency, this should be called only once and after the compareBasline() has been invoked!- Returns:
- A List containing every subproject in this project
- Throws:
SQLExceptionIOException
-
getDirList
Returns a string list of relative paths to all directories in this project- Returns:
- Throws:
SQLExceptionIOException
-
doCPCacheOperations
public static Set<String> doCPCacheOperations(String cpCacheTable, String cp, String cpState, String operation) throws SQLException Cache the list of CPs (all states except "closed"). THis is to ensure that all CPs for a project are tracked by Jenkins- Parameters:
cpCacheTable-cp-cpState-operation-- Throws:
SQLException
-
getAuthorFromRevisionInfo
public static String getAuthorFromRevisionInfo(String serverConfigId, String configPath, String memberID, String memberRev) throws hudson.AbortException Performs a revision info on this Integrity Source File- Parameters:
configPath- Full project configuration pathmemberID- Member ID for this filememberRev- Member Revision for this file- Returns:
- User responsible for making this change
-