public static GitService initializeConfigDirectory ( String uri , String branch , String root , String warName , HistoryManager historyManager , ConfigManager configManager ) throws Exception { initializeBaseDirectoryStructure ( root , warName ) ; String warDir = FileSystemManager . getChildDirectoryIfExists ( root , warName ) ; Properties configProperties = configManager . getDefaultProperties ( ) ; GitLocation gitLocation = new GitLocation ( uri , branch , configProperties . getProperty ( "config.git.ref.sha" ) ) ; GitService cloned = initializeRepo ( gitLocation , warDir , "git-config-checkout" ) ; try { String renderedContentDir = initializeSnapshotDirectory ( warDir , configProperties , "com.meltmedia.cadmium.config.lastUpdated" , "git-config-checkout" , "config" ) ; boolean hasExisting = configProperties . containsKey ( "com.meltmedia.cadmium.config.lastUpdated" ) && renderedContentDir != null && renderedContentDir . equals ( configProperties . getProperty ( "com.meltmedia.cadmium.config.lastUpdated" ) ) ; if ( renderedContentDir != null ) { configProperties . setProperty ( "com.meltmedia.cadmium.config.lastUpdated" , renderedContentDir ) ; } configProperties . setProperty ( "config.branch" , cloned . getBranchName ( ) ) ; configProperties . setProperty ( "config.git.ref.sha" , cloned . getCurrentRevision ( ) ) ; configProperties . setProperty ( "config.repo" , cloned . getRemoteRepository ( ) ) ; configManager . persistDefaultProperties ( ) ; ExecutorService pool = null ; if ( historyManager == null ) { pool = Executors . newSingleThreadExecutor ( ) ; historyManager = new HistoryManager ( warDir , pool ) ; } try { if ( historyManager != null && ! hasExisting ) { historyManager . logEvent ( EntryType . CONFIG , // NOTE: We should integrate the git pointer into this class. new GitLocation ( cloned . getRemoteRepository ( ) , cloned . getBranchName ( ) , cloned . getCurrentRevision ( ) ) , "AUTO" , renderedContentDir , "" , "Initial config pull." , true , true ) ; } } finally { if ( pool != null ) { pool . shutdownNow ( ) ; } } return cloned ; } catch ( Throwable e ) { cloned . close ( ) ; throw new Exception ( e ) ; } }
Initializes war configuration directory for a Cadmium war .