Source:
public com.google.gerrit.common.data.ProjectAccess call ( ) throws com.google.gerrit.common.errors.InvalidNameException , com.google.gerrit.common.errors.NoSuchGroupException , com.google.gerrit.server.project.NoSuchProjectException , com.google.gwtorm.client.OrmConcurrencyException , java.io.IOException , org.eclipse.jgit.errors.ConfigInvalidException { final com.google.gerrit.server.project.ProjectControl projectControl = projectControlFactory.controlFor ( projectName ) ; final com.google.gerrit.server.git.MetaDataUpdate md ; try { md = metaDataUpdateFactory.create ( projectName ) ; } catch ( org.eclipse.jgit.errors.RepositoryNotFoundException notFound ) { throw new com.google.gerrit.server.project.NoSuchProjectException ( projectName ) ; } try { com.google.gerrit.server.git.ProjectConfig config = com.google.gerrit.server.git.ProjectConfig.read ( md , base ) ; java.util.Set < java.lang.String > toDelete = com.google.gerrit.httpd.rpc.project.ChangeProjectAccess.scanSectionNames ( config ) ; for ( com.google.gerrit.common.data.AccessSection section : com.google.gerrit.httpd.rpc.project.ChangeProjectAccess.mergeSections ( sectionList ) ) { final java.lang.String name = section.getRefPattern ( ) ; if ( ! ( projectControl.controlForRef ( name ) . isOwner ( ) ) ) { continue ; } if ( name.startsWith ( AccessSection.REGEX_PREFIX ) ) { if ( ! ( org.eclipse.jgit.lib.Repository.isValidRefName ( com.google.gerrit.server.project.RefControl.shortestExample ( name ) ) ) ) { throw new com.google.gerrit.common.errors.InvalidNameException ( ) ; } } else if ( name.equals ( AccessSection.ALL ) ) { } else if ( name.endsWith ( "/*" ) ) { java.lang.String prefix = name.substring ( 0 , ( ( name.length ( ) ) - 2 ) ) ; if ( ! ( org.eclipse.jgit.lib.Repository.isValidRefName ( prefix ) ) ) { throw new com.google.gerrit.common.errors.InvalidNameException ( ) ; } } else if ( ! ( org.eclipse.jgit.lib.Repository.isValidRefName ( name ) ) ) { throw new com.google.gerrit.common.errors.InvalidNameException ( ) ; } for ( com.google.gerrit.common.data.Permission permission : section.getPermissions ( ) ) { for ( com.google.gerrit.common.data.PermissionRule rule : permission.getRules ( ) ) { lookupGroup ( rule ) ; } } config.replace ( section ) ; toDelete.remove ( section.getRefPattern ( ) ) ; } for ( java.lang.String name : toDelete ) { if ( projectControl.controlForRef ( name ) . isOwner ( ) ) { config.remove ( config.getAccessSection ( name ) ) ; } } if ( ( ( message ) != null ) && ( ! ( message.isEmpty ( ) ) ) ) { if ( ! ( message.endsWith ( "\n" ) ) ) { message += "\n" ; } md.setMessage ( message ) ; } else { md.setMessage ( "Modify access rules\n" ) ; } if ( config.commit ( md ) ) { projectCache.evict ( config.getProject ( ) ) ; return projectAccessFactory.create ( projectName ) . call ( ) ; } else { throw new com.google.gwtorm.client.OrmConcurrencyException ( ( "Cannot update " + ( projectName ) ) ) ; } } finally { md.close ( ) ; } }

Target:
private void replace ( com.google.gerrit.server.git.ProjectConfig config , java.util.Set < java.lang.String > toDelete , com.google.gerrit.common.data.AccessSection section ) throws com.google.gerrit.common.errors.NoSuchGroupException { for ( com.google.gerrit.common.data.Permission permission : section.getPermissions ( ) ) { for ( com.google.gerrit.common.data.PermissionRule rule : permission.getRules ( ) ) { lookupGroup ( rule ) ; } } config.replace ( section ) ; toDelete.remove ( section.getName ( ) ) ; }