/** * {@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> 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; }
/** * {@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> 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; }
reader.close(); matchingRuleList.add( entry.getEntry() );
reader.close(); matchingRuleUseList.add( entry.getEntry() );
reader.close(); ditContentRulesList.add( entry.getEntry() );
reader.close(); ditStructureRuleList.add( entry.getEntry() );
/** * {@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; }
reader.close(); objectClassList.add( entry.getEntry() );
reader.close(); attributeTypeList.add( entry.getEntry() );
/** * Verifies that an entry exists in the directory with the * specified attributes. * * @param entry the entry to verify * @throws NamingException if there are problems accessing the entry */ protected void verify( LdifEntry entry ) throws Exception { Entry readEntry = rootDSE.lookup( entry.getDn() ); for ( EntryAttribute readAttribute:readEntry ) { String id = readAttribute.getId(); EntryAttribute origAttribute = entry.getEntry().get( id ); for ( Value<?> value:origAttribute ) { if ( ! readAttribute.contains( value ) ) { LOG.error( "Failed to verify entry addition of {}. {} attribute in original " + "entry missing from read entry.", entry.getDn(), id ); throw new AssertionFailedError( "Failed to verify entry addition of " + entry.getDn() ); } } } }
/** * 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() ) ); } } }
/** * Verifies that an entry exists in the directory with the specified attributes. * * @param entry the entry to verify * @throws NamingException if there are problems accessing the entry */ protected void verify( LdifEntry entry ) throws Exception { Entry readEntry = rootDSE.lookup( entry.getDn() ); for ( EntryAttribute readAttribute : readEntry ) { String id = readAttribute.getId(); EntryAttribute origAttribute = entry.getEntry().get( id ); for ( Value<?> value : origAttribute ) { if ( !readAttribute.contains( value ) ) { logger.error( "Failed to verify entry addition of " + entry.getDn() + ". " + id + " attribute in original " + "entry missing from read entry." ); throw new AssertionFailedError( "Failed to verify entry addition of " + entry.getDn() ); } } } }
private static void injectEntry(LdifEntry entry) throws Exception { if (entry.isChangeAdd()) { service.getAdminSession().add( new DefaultServerEntry(service.getSchemaManager(), entry.getEntry())); } else if (entry.isChangeModify()) { service.getAdminSession().modify(entry.getDn(), entry.getModificationItems()); } else { String message = I18n.err(I18n.ERR_117, entry.getChangeType()); throw new NamingException(message); } }
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); } } }
private static void injectEntry(LdifEntry entry) throws Exception { if (entry.isChangeAdd()) { service.getAdminSession().add( new DefaultServerEntry(service.getSchemaManager(), entry.getEntry())); } else if (entry.isChangeModify()) { service.getAdminSession().modify(entry.getDn(), entry.getModificationItems()); } else { String message = I18n.err(I18n.ERR_117, entry.getChangeType()); throw new NamingException(message); } } }