/** * Anonymize a Delete change * * @param ldifEntry The entry to anonymize * @return The anonymized entry * @throws LdapException If the anonymization failed */ private LdifEntry anonymizeChangeDelete( LdifEntry ldifEntry ) throws LdapException { Dn entryDn = ldifEntry.getDn(); // Process the DN, there is nothing more in the entry Dn anonymizedDn = anonymizeDn( entryDn ); ldifEntry.setDn( anonymizedDn ); return ldifEntry; }
+ "\\s*,\\s*ou=schema\\s*", Pattern.CASE_INSENSITIVE ); String dn = ldifEntry.getDn().getName();
+ "\\s*,\\s*ou=schema\\s*", Pattern.CASE_INSENSITIVE ); String dn = ldifEntry.getDn().getName();
/** * Anonymize a Delete change * * @param ldifEntry The entry to anonymize * @return The anonymized entry * @throws LdapException If the anonymization failed */ private LdifEntry anonymizeChangeDelete( LdifEntry ldifEntry ) throws LdapException { Dn entryDn = ldifEntry.getDn(); // Process the DN, there is nothing more in the entry Dn anonymizedDn = anonymizeDn( entryDn ); ldifEntry.setDn( anonymizedDn ); return ldifEntry; }
/** * Anonymize a Delete change * * @param ldifEntry The entry to anonymize * @return The anonymized entry * @throws LdapException If the anonymization failed */ private LdifEntry anonymizeChangeDelete( LdifEntry ldifEntry ) throws LdapException { Dn entryDn = ldifEntry.getDn(); // Process the DN, there is nothing more in the entry Dn anonymizedDn = anonymizeDn( entryDn ); ldifEntry.setDn( anonymizedDn ); return ldifEntry; }
+ "\\s*,\\s*ou=schema\\s*", Pattern.CASE_INSENSITIVE ); String dn = ldifEntry.getDn().getName();
log.debug("attempting modify of {}", ldifEntry); conn.modify(ldifEntry.getDn(), ldifEntry.getModificationArray()); } else if (ldifEntry.isChangeDelete()) { if (log.isDebugEnabled()) { log.debug("attempting delete of {}", ldifEntry); conn.delete(ldifEntry.getDn()); } else if (ldifEntry.isChangeModDn()) { if (log.isDebugEnabled()) { log.debug("attempting DN move of {}", ldifEntry); conn.moveAndRename(ldifEntry.getDn(), new Dn(ldifEntry.getNewRdn(), ldifEntry.getNewSuperior()), ldifEntry.isDeleteOldRdn()); } else if (ldifEntry.isChangeModRdn()) { if (log.isDebugEnabled()) { log.debug("attempting RDN move of {}", ldifEntry); conn.rename(ldifEntry.getDn(), new Rdn(ldifEntry.getNewRdn()), ldifEntry.isDeleteOldRdn());
String dn = ldifEntry.getDn().getName();
t.setKey( ldifEntry.getDn() ); t.setValue( ( E ) ( ldifEntry.getOffset() + ":" + ldifEntry.getLengthBeforeParsing() ) );
protected List<LdifEntry> loadLdif(LdifReader ldifReader) throws Exception { List<LdifEntry> entries = new ArrayList<LdifEntry>(); for (LdifEntry ldifEntry : ldifReader) { Dn dn = ldifEntry.getDn(); if (ldifEntry.isEntry()) { org.apache.directory.api.ldap.model.entry.Entry items = ldifEntry.getEntry(); rootDSE.add(new DefaultEntry(directoryService.getSchemaManager(), items)); LOG.info("Added entry {}", dn); entries.add(ldifEntry); } } return entries; }
/** * Converts the configuration bean to a list of LDIF entries. */ private void convertConfigurationBeanToLdifEntries() throws ConfigurationException { try { if ( entries == null ) { entries = new ArrayList<LdifEntry>(); // Building the default config root entry 'ou=config' LdifEntry configRootEntry = new LdifEntry(); configRootEntry.setDn( new Dn( SchemaConstants.OU_AT + "=" + "config" ) ); addObjectClassAttribute( schemaManager, configRootEntry, "organizationalUnit" ); addAttributeTypeValues( SchemaConstants.OU_AT, "config", configRootEntry ); entries.add( configRootEntry ); // Building entries from the directory service beans List<AdsBaseBean> directoryServiceBeans = configBean.getDirectoryServiceBeans(); for ( AdsBaseBean adsBaseBean : directoryServiceBeans ) { addBean( configRootEntry.getDn(), schemaManager, adsBaseBean, entries ); } } } catch ( Exception e ) { throw new ConfigurationException( "Unable to convert the configuration bean to LDIF entries", e ); } }
private void checkPartition(LdifEntry ldifEntry) throws Exception { Dn dn = ldifEntry.getDn(); Dn parent = dn.getParent(); try { directoryService.getAdminSession().exists(parent); } catch (Exception e) { System.out.println("Creating new partition for DN=" + dn + "\n"); AvlPartition partition = new AvlPartition(directoryService.getSchemaManager()); partition.setId(dn.getName()); partition.setSuffixDn(dn); directoryService.addPartition(partition); } }
/** * 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(); } } } }
String dn = ldifEntry.getDn().getName();
String dn = ldifEntry.getDn().getName();
String dn = ldifEntry.getDn().getName();
Dn entryDn = ldifEntry.getDn();
Dn entryDn = ldifEntry.getDn();
Dn entryDn = ldifEntry.getDn();
/** * 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 ); } }