/** * {@inheritDoc} */ public List<Entry> loadNameForms( Schema... schemas ) throws Exception { List<Entry> nameFormList = new ArrayList<Entry>(); if ( schemas == null ) { return nameFormList; } for ( Schema schema : schemas ) { File nameFormsDirectory = new File( getSchemaDirectory( schema ), SchemaConstants.NAME_FORMS_PATH ); if ( !nameFormsDirectory.exists() ) { return nameFormList; } File[] nameFormFiles = nameFormsDirectory.listFiles( ldifFilter ); for ( File ldifFile : nameFormFiles ) { LdifReader reader = new LdifReader( ldifFile ); LdifEntry entry = reader.next(); reader.close(); nameFormList.add( entry.getEntry() ); } } return nameFormList; }
public static void injectLdifFiles(String... ldifFiles) throws Exception { if (ldifFiles != null && ldifFiles.length > 0) { for (String ldifFile : ldifFiles) { InputStream is = null; try { is = ApimanLdapServer.class.getClassLoader().getResourceAsStream(ldifFile); if (is == null) { throw new FileNotFoundException("LDIF file '" + ldifFile + "' not found."); } else { try { LdifReader ldifReader = new LdifReader(is); for (LdifEntry entry : ldifReader) { injectEntry(entry); } ldifReader.close(); } catch (Exception e) { throw new RuntimeException(e); } } } finally { IOUtils.closeQuietly(is); } } } }
Iterator list = new LdifReader( in );
LdifReader ldifReader = new LdifReader( source ); boolean first = true; LdifEntry ldifEntry = null; while ( ldifReader.hasNext() ) ldifEntry = ldifReader.next(); ldifReader.close();
/** * Inject an ldif String into the server. DN must be relative to the root. * * @param ldif the entries to inject * @throws NamingException if the entries cannot be added */ protected void injectEntries( String ldif ) throws Exception { LdifReader reader = new LdifReader(); List<LdifEntry> entries = reader.parseLdif( ldif ); for ( LdifEntry entry : entries ) { rootDSE.add( new DefaultServerEntry( rootDSE.getDirectoryService().getRegistries(), entry.getEntry() ) ); } }
String name = parseDn( line ); control = parseControl( line.substring( "control:".length() ) ); entry.setControl( control ); controlSeen = true; operation = parseChangeType( line ); parseChange( entry, iter, operation ); changeTypeSeen = true; parseAttributeValue( entry, line, lowerLine ); type = LDIF_ENTRY;
parseAttributeValue( entry, line, lowerLine ); parseModify( entry, iter ); return; case ChangeType.MODDN_ORDINAL: parseModRdn( entry, iter ); Object attributeValue = parseValue( line, colonIndex ); entry.setNewSuperior( attributeValue instanceof String ? ( String ) attributeValue : StringTools.utf8ToString( ( byte[] ) attributeValue ) );
List<LdifEntry> entries = parseLdif( reader );
Attribute attribute = LdifReader.parseAttributeValue( addedLine ); Attribute oldAttribute = attributes.get( attribute.getID() );
LdifReader ldifReader = new LdifReader( in ); List<LdifEntry> entries = new ArrayList<LdifEntry>();
public static void injectLdifFiles(String... ldifFiles) throws Exception { if (ldifFiles != null && ldifFiles.length > 0) { for (String ldifFile : ldifFiles) { InputStream is = null; try { is = LdapTestParent.class.getClassLoader().getResourceAsStream(ldifFile); if (is == null) { throw new FileNotFoundException("LDIF file '" + ldifFile + "' not found."); } else { try { LdifReader ldifReader = new LdifReader(is); for (LdifEntry entry : ldifReader) { injectEntry(entry); } ldifReader.close(); } catch (Exception e) { throw new RuntimeException(e); } } } finally { IOUtils.closeQuietly(is); } } } }
/** * Inject an ldif String into the server. DN must be relative to the * root. * @param ldif the entries to inject * @throws NamingException if the entries cannot be added */ protected void injectEntries( String ldif ) throws Exception { LdifReader reader = new LdifReader(); List<LdifEntry> entries = reader.parseLdif( ldif ); for ( LdifEntry entry : entries ) { rootDSE.add( new DefaultServerEntry( rootDSE.getDirectoryService().getRegistries(), entry.getEntry() ) ); } } }
new FileInputStream( file ), Charset.forName( encoding ) ) ); return parseLdif( reader );
/** * {@inheritDoc} */ public List<Entry> loadMatchingRules( Schema... schemas ) throws Exception { List<Entry> matchingRuleList = new ArrayList<Entry>(); if ( schemas == null ) { return matchingRuleList; } for ( Schema schema : schemas ) { File matchingRulesDirectory = new File( getSchemaDirectory( schema ), SchemaConstants.MATCHING_RULES_PATH ); if ( !matchingRulesDirectory.exists() ) { return matchingRuleList; } File[] matchingRuleFiles = matchingRulesDirectory.listFiles( ldifFilter ); for ( File ldifFile : matchingRuleFiles ) { LdifReader reader = new LdifReader( ldifFile ); LdifEntry entry = reader.next(); reader.close(); matchingRuleList.add( entry.getEntry() ); } } return matchingRuleList; }
for ( LdifEntry entry : new LdifReader( in ) )
/** * {@inheritDoc} */ public List<Entry> loadDitContentRules( Schema... schemas ) throws Exception { List<Entry> ditContentRuleList = new ArrayList<Entry>(); if ( schemas == null ) { return ditContentRuleList; } for ( Schema schema : schemas ) { File ditContentRulesDirectory = new File( getSchemaDirectory( schema ), SchemaConstants.DIT_CONTENT_RULES_PATH ); if ( !ditContentRulesDirectory.exists() ) { return ditContentRuleList; } File[] ditContentRuleFiles = ditContentRulesDirectory.listFiles( ldifFilter ); for ( File ldifFile : ditContentRuleFiles ) { LdifReader reader = new LdifReader( ldifFile ); LdifEntry entry = reader.next(); reader.close(); ditContentRuleList.add( entry.getEntry() ); } } return ditContentRuleList; }
LdifReader ldifReader = new LdifReader( in ); List<LdifEntry> entries = new ArrayList<LdifEntry>();
/** * {@inheritDoc} */ public List<Entry> loadDitStructureRules( Schema... schemas ) throws Exception { List<Entry> ditStructureRuleList = new ArrayList<Entry>(); if ( schemas == null ) { return ditStructureRuleList; } for ( Schema schema : schemas ) { File ditStructureRulesDirectory = new File( getSchemaDirectory( schema ), SchemaConstants.DIT_STRUCTURE_RULES_PATH ); if ( !ditStructureRulesDirectory.exists() ) { return ditStructureRuleList; } File[] ditStructureRuleFiles = ditStructureRulesDirectory.listFiles( ldifFilter ); for ( File ldifFile : ditStructureRuleFiles ) { LdifReader reader = new LdifReader( ldifFile ); LdifEntry entry = reader.next(); reader.close(); ditStructureRuleList.add( entry.getEntry() ); } } return ditStructureRuleList; }
public void importLdif(InputStream in) throws Exception { /** the context root for the rootDSE */ CoreSession rootDSE = service.getAdminSession(); for (LdifEntry ldifEntry : new LdifReader(in)) { DefaultServerEntry entry = new DefaultServerEntry(rootDSE.getDirectoryService().getSchemaManager(), ldifEntry.getEntry()); if (!rootDSE.exists(entry.getDn())) { rootDSE.add(entry); } } }
/** * {@inheritDoc} */ public List<Entry> loadComparators( Schema... schemas ) throws Exception { List<Entry> comparatorList = new ArrayList<Entry>(); if ( schemas == null ) { return comparatorList; } for ( Schema schema : schemas ) { File comparatorsDirectory = new File( getSchemaDirectory( schema ), SchemaConstants.COMPARATORS_PATH ); if ( !comparatorsDirectory.exists() ) { return comparatorList; } File[] comparators = comparatorsDirectory.listFiles( ldifFilter ); for ( File ldifFile : comparators ) { LdifReader reader = new LdifReader( ldifFile ); LdifEntry entry = reader.next(); reader.close(); comparatorList.add( entry.getEntry() ); } } return comparatorList; }