Buggy code:
public int cleanSiteNodeVersions ( int numberOfVersionsToKeep , boolean keepOnlyOldPublishedVersions , long minimumTimeBetweenVersionsDuringClean , boolean deleteVersions ) throws Exception , SystemException { } public Map < Integer , Integer > getSiteNodeIdVersionCountMap ( int numberOfVersionsToKeep ) throws SystemException { } public List < SiteNodeVersionVO > getSiteNodeVersionVOList ( int numberOfVersionsToKeep , boolean keepOnlyOldPublishedVersions , long minimumTimeBetweenVersionsDuringClean ) throws Exception , Bug , SystemException { } public List < SiteNodeVersionVO > getSiteNodeVersionVOListImpl ( List < Integer > siteNodeIdList , int numberOfVersionsToKeep , boolean keepOnlyOldPublishedVersions , long minimumTimeBetweenVersionsDuringClean ) throws SystemException { } private void cleanVersions ( int numberOfVersionsToKeep , List siteNodeVersionVOList ) throws SystemException { } public void delete ( SiteNodeVersion siteNodeVersion , Database db , boolean forceDelete ) throws Exception , ConstraintException , SystemException { } public void delete ( MediumSiteNodeVersionImpl siteNodeVersion , Database db , boolean forceDelete ) throws Exception , ConstraintException , SystemException { } public void copySiteNode ( SiteNodeVO siteNodeVO , Integer newParentSiteNodeId , InfoGluePrincipal principal , ProcessBean processBean ) throws ConstraintException , SystemException { } private String getNewNameSuffixForCopy ( InfoGluePrincipal principal , Database db , SiteNodeVO newParentSiteNode ) throws Exception , SystemException { } private void copySiteNodeRecursive ( SiteNodeVO siteNode , SiteNodeVO newParentSiteNode , InfoGluePrincipal principal , Map < Integer , Integer > siteNodesIdsMapping , Map < Integer , Integer > contentIdsMapping , Set < Integer > contentIdsToCopy , List < ContentVersion > newCreatedContentVersions , String newNameSuffix , Database db , ProcessBean processBean , Map < String , String > replaceMap ) throws Exception { } private void getRelatedEntities ( SiteNodeVO newParentSiteNode , InfoGluePrincipal principal , String versionValue , Integer oldRepositoryId , Integer newRepositoryId , Map < Integer , Integer > siteNodeIdsMapping , Map < Integer , Integer > contentIdsMapping , Set < Integer > siteNodeIdsToCopy , Set < Integer > contentIdsToCopy , List < ContentVersion > versions , int depth , int maxDepth , String newNameSuffix , Database db , ProcessBean processBean , Map < String , String > replaceMap ) throws Exception { } private void copyContents ( SiteNodeVO newParentSiteNode , InfoGluePrincipal principal , Set < Integer > contentIdsToCopy , Integer oldRepositoryId , Integer newRepositoryId , Map < Integer , Integer > contentIdsMapping , List < ContentVersion > versions , Database db , PropertySet ps , Map < String , String > replaceMap ) throws Exception { } private void copyContents ( SiteNodeVO newParentSiteNode , InfoGluePrincipal principal , Set < Integer > contentIdsToCopy , Integer oldRepositoryId , Integer newRepositoryId , Map < Integer , Integer > contentIdsMapping , List < ContentVersion > versions , boolean includeRootContentInPath , String onlyLatestVersions , ProcessBean processBean , Database db , PropertySet ps , Map < String , String > replaceMap ) throws Exception { VisualFormatter visualFormatter = new VisualFormatter ( ) ; SiteNodeController . logger . info ( ( "contentIdsToCopy:" + ( contentIdsToCopy . size ( ) ) ) ) ; int totalCount = 0 ; int count = 0 ; for ( Integer contentId : contentIdsToCopy ) { if ( count > 100 ) { count = 0 ; if ( processBean != null ) processBean . updateProcess ( ( ( "Copied<seq2seq4repair_space>" + totalCount ) + "<seq2seq4repair_space>contents<seq2seq4repair_space>so<seq2seq4repair_space>far." ) ) ; db . commit ( ) ; db . begin ( ) ; } count ++ ; totalCount ++ ; SiteNodeController . logger . info ( ( "contentId:" + contentId ) ) ; try { ContentVO contentVO = ContentController . getContentController ( ) . getContentVOWithId ( contentId , db ) ; if ( ( contentVO != null ) && ( ( newRepositoryId . intValue ( ) ) != ( contentVO . getRepositoryId ( ) . intValue ( ) ) ) ) { SiteNodeController . logger . info ( ( ( ( ( ( "The<seq2seq4repair_space>contentVO:<seq2seq4repair_space>" + ( contentVO . getName ( ) ) ) + "<seq2seq4repair_space>from<seq2seq4repair_space>repo<seq2seq4repair_space>" ) + ( contentVO . getRepositoryId ( ) ) ) + "<seq2seq4repair_space>ctd:" ) + ( contentVO . getContentTypeDefinitionId ( ) ) ) ) ; if ( ( contentVO . getRepositoryId ( ) . intValue ( ) ) == ( oldRepositoryId . intValue ( ) ) ) { SiteNodeController . logger . info ( "The<seq2seq4repair_space>related<seq2seq4repair_space>content<seq2seq4repair_space>was<seq2seq4repair_space>in<seq2seq4repair_space>the<seq2seq4repair_space>old<seq2seq4repair_space>repo<seq2seq4repair_space>as<seq2seq4repair_space>well<seq2seq4repair_space>-<seq2seq4repair_space>let's<seq2seq4repair_space>copy<seq2seq4repair_space>that<seq2seq4repair_space>as<seq2seq4repair_space>well" ) ; if ( contentIdsMapping . containsKey ( contentId ) ) { SiteNodeController . logger . info ( ( "Allready<seq2seq4repair_space>transferred<seq2seq4repair_space>content<seq2seq4repair_space>so<seq2seq4repair_space>skipping:" + ( contentVO . getName ( ) ) ) ) ; continue ; } ContentVO copiedContent = null ; if ( ( contentVO . getParentContentId ( ) ) == null ) { <START_BUG> ContentVO rootContentNewRepo = ContentController . getContentController ( ) . getRootContentVO ( newRepositoryId , principal . getName ( ) , false ) ; <END_BUG> if ( rootContentNewRepo != null ) { ContentController . getContentController ( ) . copyContentProperties ( ps , contentVO . getId ( ) , rootContentNewRepo . getId ( ) ) ; copiedContent = rootContentNewRepo ; } } else { String path = ContentController . getContentController ( ) . getContentPath ( contentId , includeRootContentInPath , false , db ) ; SiteNodeController . logger . info ( ( "path:" + path ) ) ; path = visualFormatter . replaceAccordingToMappings ( replaceMap , path ) ; SiteNodeController . logger . info ( ( "path:" + path ) ) ; copiedContent = ContentController . getContentController ( ) . getContentVOWithPath ( newRepositoryId , path , true , ( ! ( contentVO . getIsBranch ( ) ) ) , principal , db ) ; } SiteNodeController . logger . info ( ( ( ( "Mapping<seq2seq4repair_space>content<seq2seq4repair_space>" + ( contentVO . getId ( ) ) ) + "<seq2seq4repair_space>to<seq2seq4repair_space>" ) + ( copiedContent . getId ( ) ) ) ) ; contentIdsMapping . put ( contentVO . getId ( ) , copiedContent . getId ( ) ) ; copiedContent . setName ( visualFormatter . replaceAccordingToMappings ( replaceMap , contentVO . getName ( ) ) ) ; copiedContent . setExpireDateTime ( contentVO . getExpireDateTime ( ) ) ; copiedContent . setIsBranch ( contentVO . getIsBranch ( ) ) ; copiedContent . setIsProtected ( contentVO . getIsProtected ( ) ) ;

Fix:
ContentVO rootContentNewRepo = ContentController . getContentController ( ) . getWritableRootContentVO ( db , newRepositoryId , principal . getName ( ) , false ) ;