private void processLDIF(Connection conn,String path) throws UpgradeException {
  ChangeRecordReader reader=null;
  try {
    if (DEBUG.messageEnabled()) {
      DEBUG.message("Processing LDIF file under " + path);
    }
    Map<String,String> tags=new HashMap<String,String>(2);
    tags.put("@SM_CONFIG_ROOT_SUFFIX@",baseDN);
    tags.put("@DB_NAME@","userRoot");
    String content=AMSetupServlet.readFile(path);
    String tagSwapped=StringUtils.tagSwap(content,tags);
    reader=new LDIFChangeRecordReader(new ByteArrayInputStream(tagSwapped.getBytes(Charset.forName("UTF-8"))));
    ChangeRecordWriter writer=new ConnectionChangeRecordWriter(conn);
    while (reader.hasNext()) {
      writer.writeChangeRecord(reader.readChangeRecord());
    }
  }
 catch (  IOException ioe) {
    DEBUG.error("An error occurred while processing " + path,ioe);
    throw new UpgradeException(ioe);
  }
 finally {
    IOUtils.closeIfNotNull(reader);
  }
}

private void processLDIF ( Connection conn , String path ) throws UpgradeException { ChangeRecordReader reader = null ; try { if ( DEBUG . messageEnabled ( ) ) { DEBUG . message ( "Processing LDIF file under " + path ) ; } Map < String , String > tags = new HashMap < String , String > ( 2 ) ; tags . put ( "@SM_CONFIG_ROOT_SUFFIX@" , baseDN ) ; tags . put ( "@DB_NAME@" , "userRoot" ) ; String content = AMSetupServlet . readFile ( path ) ; String tagSwapped = StringUtils . tagSwap ( content , tags ) ; reader = new LDIFChangeRecordReader ( new ByteArrayInputStream ( tagSwapped . getBytes ( Charset . forName ( "UTF-8" ) ) ) ) ; ChangeRecordWriter writer = new ConnectionChangeRecordWriter ( conn ) ; while ( reader . hasNext ( ) ) { writer . writeChangeRecord ( reader . readChangeRecord ( ) ) ; } } catch ( IOException ioe ) { DEBUG . error ( "An error occurred while processing " + path , ioe ) ; throw new UpgradeException ( ioe ) ; } finally { IOUtils . closeIfNotNull ( reader ) ; } }
reads in the ldif file , and writes the changerecords on the ldap connection .
