/** * Stream will be closed automatically. */ public void importLdif(InputStream is) throws Exception { try (LdifReader reader = new LdifReader(is)) { CoreSession coreSession = directoryService.getAdminSession(); // see LdifFileLoader for (LdifEntry ldifEntry : reader) { String ldif = ldifEntry.toString(); LOG.info(ldif); if (ChangeType.Add == ldifEntry.getChangeType() || /* assume "add" by default */ ChangeType.None == ldifEntry.getChangeType()) { coreSession.add(new DefaultEntry(coreSession.getDirectoryService().getSchemaManager(), ldifEntry.getEntry())); } else if (ChangeType.Modify == ldifEntry.getChangeType()) { coreSession.modify(ldifEntry.getDn(), ldifEntry.getModifications()); } else if (ChangeType.Delete == ldifEntry.getChangeType()) { coreSession.delete(ldifEntry.getDn()); } else { throw new IllegalStateException(); } } } }
changeType = ldifEntry.getChangeType(); controls = ldifEntry.getControls(); entryDn = ldifEntry.getDn(); switch ( ldifEntry.getChangeType() )
changeType = ldifEntry.getChangeType(); controls = ldifEntry.getControls(); entryDn = ldifEntry.getDn(); switch ( ldifEntry.getChangeType() )
changeType = ldifEntry.getChangeType(); controls = ldifEntry.getControls(); entryDn = ldifEntry.getDn(); switch ( ldifEntry.getChangeType() )
String changeType = Strings.toLowerCaseAscii( entry.getChangeType().toString() ); if ( entry.getChangeType() != ChangeType.None ) switch ( entry.getChangeType() ) throw new IllegalArgumentException( I18n.err( I18n.ERR_13431_UNEXPECTED_CHANGETYPE, entry.getChangeType() ) );
String changeType = Strings.toLowerCaseAscii( entry.getChangeType().toString() ); if ( entry.getChangeType() != ChangeType.None ) switch ( entry.getChangeType() ) throw new IllegalArgumentException( I18n.err( I18n.ERR_13431_UNEXPECTED_CHANGETYPE, entry.getChangeType() ) );
String changeType = Strings.toLowerCaseAscii( entry.getChangeType().toString() ); if ( entry.getChangeType() != ChangeType.None ) switch ( entry.getChangeType() ) throw new IllegalArgumentException( I18n.err( I18n.ERR_13431_UNEXPECTED_CHANGETYPE, entry.getChangeType() ) );
String message = I18n.err( I18n.ERR_117, entry.getChangeType() ); LOG.error( message ); reader.close();
switch ( reverse.getChangeType().getChangeType() ) throw new NotImplementedException( I18n.err( I18n.ERR_76, reverse.getChangeType() ) );
CoreSession session = service.getAdminSession(); switch ( entry.getChangeType().getChangeType() ) throw new IllegalStateException( I18n.err( I18n.ERR_476, entry.getChangeType() ) );
/** * injects an LDIF entry in the given DirectoryService * * @param entry the LdifEntry to be injected * @param service the DirectoryService * @throws Exception If the entry cannot be injected */ private static void injectEntry( LdifEntry entry, DirectoryService service ) throws LdapException { if ( entry.isChangeAdd() || entry.isLdifContent() ) { service.getAdminSession().add( new DefaultEntry( service.getSchemaManager(), entry .getEntry() ) ); } else if ( entry.isChangeModify() ) { service.getAdminSession().modify( entry.getDn(), entry.getModifications() ); } else { String message = I18n.err( I18n.ERR_117, entry.getChangeType() ); throw new LdapException( message ); } }