public Site insertNewSite ( String siteString ) throws PersistenceException { if ( _sitesByString . containsKey ( siteString ) ) { return null ; } // add it to the db Site site = new Site ( ) ; site . siteString = siteString ; _repo . insertNewSite ( site ) ; // add it to our two mapping tables, taking care to avoid causing enumerateSites() to choke @ SuppressWarnings ( "unchecked" ) HashMap < String , Site > newStrings = ( HashMap < String , Site > ) _sitesByString . clone ( ) ; HashIntMap < Site > newIds = _sitesById . clone ( ) ; newIds . put ( site . siteId , site ) ; newStrings . put ( site . siteString , site ) ; _sitesByString = newStrings ; _sitesById = newIds ; return site ; }
Insert a new site into the site table and into this mapping .