Package hudson.scm

Class DerbyUtils

java.lang.Object
hudson.scm.DerbyUtils

public class DerbyUtils extends Object
This class provides certain utility functions for working with the embedded derby database
  • Field Details

    • DERBY_DRIVER

      public static final String DERBY_DRIVER
      See Also:
    • DERBY_SYS_HOME_PROPERTY

      public static final String DERBY_SYS_HOME_PROPERTY
      See Also:
    • DERBY_URL_PREFIX

      public static final String DERBY_URL_PREFIX
      See Also:
    • CREATE_INTEGRITY_SCM_REGISTRY

      public static final String CREATE_INTEGRITY_SCM_REGISTRY
      See Also:
    • SELECT_REGISTRY_1

      public static final String SELECT_REGISTRY_1
      See Also:
    • SELECT_REGISTRY_TABLE

      public static final String SELECT_REGISTRY_TABLE
      See Also:
    • SELECT_REGISTRY_TABLE_DROP

      public static final String SELECT_REGISTRY_TABLE_DROP
      See Also:
    • INSERT_REGISTRY_ENTRY

      public static final String INSERT_REGISTRY_ENTRY
      See Also:
    • SELECT_REGISTRY_DISTINCT_PROJECTS

      public static final String SELECT_REGISTRY_DISTINCT_PROJECTS
      See Also:
    • SELECT_REGISTRY_PROJECTS

      public static final String SELECT_REGISTRY_PROJECTS
      See Also:
    • SELECT_REGISTRY_PROJECT

      public static final String SELECT_REGISTRY_PROJECT
      See Also:
    • DROP_REGISTRY_ENTRY

      public static final String DROP_REGISTRY_ENTRY
      See Also:
    • CREATE_PROJECT_TABLE

      public static final String CREATE_PROJECT_TABLE
    • DROP_PROJECT_TABLE

      public static final String DROP_PROJECT_TABLE
      See Also:
    • SELECT_MEMBER_1

      public static final String SELECT_MEMBER_1
    • SELECT_CP_1

      public static final String SELECT_CP_1
      ------------ CP Cache tables --------------------
    • CREATE_PROJECT_CP_TABLE

      public static final String CREATE_PROJECT_CP_TABLE
    • INSERT_CP_RECORD

      public static final String INSERT_CP_RECORD
    • CP_SELECT

      public static final String CP_SELECT
    • DELETE_CP_RECORD

      public static final String DELETE_CP_RECORD
    • INSERT_MEMBER_RECORD

      public static final String INSERT_MEMBER_RECORD
      ------------ CP Cache tables end --------------------
    • BASELINE_SELECT

      public static final String BASELINE_SELECT
    • DELTA_SELECT

      public static final String DELTA_SELECT
    • PROJECT_SELECT

      public static final String PROJECT_SELECT
    • SUB_PROJECT_SELECT

      public static final String SUB_PROJECT_SELECT
    • AUTHOR_SELECT

      public static final String AUTHOR_SELECT
    • DIR_SELECT

      public static final String DIR_SELECT
    • CHECKSUM_UPDATE

      public static final String CHECKSUM_UPDATE
    • CP_MEMBER_SELECT

      public static final String CP_MEMBER_SELECT
  • Constructor Details

    • DerbyUtils

      public DerbyUtils()
  • Method Details

    • getEnum

      public static final CM_PROJECT getEnum(String name)
      Returns the CM_PROJECT column name for the string column name
      Parameters:
      name -
      Returns:
    • getUUIDTableName

      public static final String getUUIDTableName()
      Random unique id generator for cache table names
      Returns:
    • loadDerbyDriver

      public static void loadDerbyDriver()
      Utility function to load the Java DB Driver
    • createConnectionPoolDataSource

      public static ConnectionPoolDataSource createConnectionPoolDataSource(String derbyHome)
      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 source
      sql - String sql statement
      Returns:
      Throws:
      SQLException
    • createRegistry

      public static boolean createRegistry(ConnectionPoolDataSource dataSource)
      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

      public static boolean createCMProjectTables(ConnectionPoolDataSource dataSource, String tableName)
      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

      public static boolean getCPCacheTable(ConnectionPoolDataSource dataSource, String cpCacheTableName)
      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:
      SQLException
      IOException
    • getRowCount

      public static int getRowCount(ResultSet rs) throws SQLException
      This function provides a count of the total number of rows in the ResultSet
      Parameters:
      set -
      Returns:
      Throws:
      SQLException
    • fixDescription

      public static String fixDescription(String desc)
      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, IOException
      Compares 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 Project
      return - The total number of changes found in the comparison
      Throws:
      SQLException
      IOException
    • primeAuthorInformation

      public static void primeAuthorInformation(String serverConfigId, String projectCacheTable) throws SQLException, IOException
      Updates the author information for all the members in the project
      Throws:
      SQLException
      IOException
    • updateChecksum

      public static void updateChecksum(String projectCacheTable, ConcurrentHashMap<String,String> checksumHash) throws SQLException, IOException
      Updates the underlying Integrity SCM Project table cache with the new checksum information
      Parameters:
      checksumHash - Checksum hashtable generated from a checkout operation
      Throws:
      SQLException
      IOException
    • 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:
      SQLException
      IOException
    • 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:
      SQLException
      IOException
    • getDirList

      public static List<String> getDirList(String projectCacheTable) throws SQLException, IOException
      Returns a string list of relative paths to all directories in this project
      Returns:
      Throws:
      SQLException
      IOException
    • 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 path
      memberID - Member ID for this file
      memberRev - Member Revision for this file
      Returns:
      User responsible for making this change