public void importLdif ( InputStream ldifData ) throws IOException { final File ldifFile = getOuterRule ( ) . newFile ( "scribble_import.ldif" ) ; try ( final Writer writer = new OutputStreamWriter ( new FileOutputStream ( ldifFile ) , Charsets . UTF_8 ) ) { IOUtils . copy ( ldifData , writer ) ; } final String pathToLdifFile = ldifFile . getAbsolutePath ( ) ; final CoreSession session = this . getDirectoryService ( ) . getAdminSession ( ) ; final LdifFileLoader loader = new LdifFileLoader ( session , pathToLdifFile ) ; loader . execute ( ) ; }
Imports directory content that is defined in LDIF format and provided as input stream . The method writes the stream content into a temporary file .