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); } } } }
/** * {@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; }
/** * {@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; }
/** * {@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; }
LdifReader reader = new LdifReader( resource.openStream() ); LdifEntry entry = reader.next(); reader.close();
LdifReader reader = new LdifReader( resource.openStream() ); LdifEntry entry = reader.next(); reader.close();
LdifReader reader = new LdifReader( resource.openStream() ); LdifEntry entry = reader.next(); reader.close();
/** * {@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; }
/** * {@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; }
/** * {@inheritDoc} */ public List<Entry> loadSyntaxCheckers( Schema... schemas ) throws Exception { List<Entry> syntaxCheckerList = new ArrayList<Entry>(); if ( schemas == null ) { return syntaxCheckerList; } for ( Schema schema : schemas ) { File syntaxCheckersDirectory = new File( getSchemaDirectory( schema ), SchemaConstants.SYNTAX_CHECKERS_PATH ); if ( !syntaxCheckersDirectory.exists() ) { return syntaxCheckerList; } File[] syntaxCheckerFiles = syntaxCheckersDirectory.listFiles( ldifFilter ); for ( File ldifFile : syntaxCheckerFiles ) { LdifReader reader = new LdifReader( ldifFile ); LdifEntry entry = reader.next(); reader.close(); syntaxCheckerList.add( entry.getEntry() ); } } return syntaxCheckerList; }
/** * {@inheritDoc} */ public List<Entry> loadNormalizers( Schema... schemas ) throws Exception { List<Entry> normalizerList = new ArrayList<Entry>(); if ( schemas == null ) { return normalizerList; } for ( Schema schema : schemas ) { File normalizersDirectory = new File( getSchemaDirectory( schema ), SchemaConstants.NORMALIZERS_PATH ); if ( !normalizersDirectory.exists() ) { return normalizerList; } File[] normalizerFiles = normalizersDirectory.listFiles( ldifFilter ); for ( File ldifFile : normalizerFiles ) { LdifReader reader = new LdifReader( ldifFile ); LdifEntry entry = reader.next(); reader.close(); normalizerList.add( entry.getEntry() ); } } return normalizerList; }
LdifReader reader = new LdifReader( resource.openStream() ); LdifEntry entry = reader.next(); reader.close();
LdifReader reader = new LdifReader( resource.openStream() ); LdifEntry entry = reader.next(); reader.close();
LdifReader reader = new LdifReader( resource.openStream() ); LdifEntry entry = reader.next(); reader.close();
LdifReader reader = new LdifReader( in ); LdifEntry entry = reader.next(); reader.close();
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() ) ); } }
/** * 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() ) ); } } }
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); } } }
/** * Imports the LDIF entries packaged with the Eve JNDI provider jar into * the newly created system partition to prime it up for operation. Note * that only ou=system entries will be added - entries for other partitions * cannot be imported and will blow chunks. * * @throws NamingException if there are problems reading the ldif file and * adding those entries to the system partition * @param in the input stream with the ldif */ protected void importLdif( InputStream in ) throws NamingException { try { for ( LdifEntry ldifEntry:new LdifReader( in ) ) { rootDSE.add( new DefaultServerEntry( rootDSE.getDirectoryService().getRegistries(), ldifEntry.getEntry() ) ); } } catch ( Exception e ) { String msg = "failed while trying to parse system ldif file"; NamingException ne = new LdapConfigurationException( msg ); ne.setRootCause( e ); throw ne; } }