/** * {@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; }
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); } }
/** * Compute a reverse LDIF of a DeleteRequest. We have to get the previous * entry in order to restore it. * * @param dn The deleted entry DN * @param deletedEntry The entry which has been deleted * @return A reverse LDIF */ public static LdifEntry reverseDel( DN dn, Entry deletedEntry ) throws LdapException { LdifEntry entry = new LdifEntry(); entry.setDn( dn ); entry.setChangeType( ChangeType.Add ); for ( EntryAttribute attribute : deletedEntry ) { entry.addAttribute( attribute ); } return entry; }
/** * 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() ); } } } }
if ( isLDIFSafe( entry.getDn().getName() ) ) sb.append( stripLineToNChars( "dn: " + entry.getDn(), length ) ); sb.append( stripLineToNChars( "dn:: " + encodeBase64( entry.getDn().getName() ), length ) ); String changeType = entry.getChangeType().toString().toLowerCase(); if ( entry.getChangeType() != ChangeType.Modify ) switch ( entry.getChangeType() ) if ( entry.getEntry() != null ) if ( ( entry.getEntry() == null ) ) for ( EntryAttribute attribute:entry.getEntry() ) if ( entry.getEntry() != null ) EntryAttribute newRdn = new DefaultClientAttribute( "newrdn", entry.getNewRdn() ); sb.append( convertToLdif( newRdn, length ) ); if ( entry.isDeleteOldRdn() ) if ( ! StringTools.isEmpty( entry.getNewSuperior() ) ) EntryAttribute newSuperior = new DefaultClientAttribute( "newsuperior", entry.getNewSuperior() ); sb.append( convertToLdif( newSuperior, length ) );
DN dnEntry = otherEntry.getDn();
if ( ldifEntry.get( SchemaConstants.ENTRY_UUID_AT ) == null ) ldifEntry.addAttribute( SchemaConstants.ENTRY_UUID_AT, entryUuid.toString() ); String ldifString = "version: 1\n" + ldifEntry.toString();
/** * Parse an AttributeType/AttributeValue * * @param entry The entry where to store the value * @param line The line to parse * @param lowerLine The same line, lowercased * @throws LdapLdifException If anything goes wrong */ public void parseAttributeValue( LdifEntry entry, String line, String lowerLine ) throws LdapLdifException, LdapException { int colonIndex = line.indexOf( ':' ); String attributeType = lowerLine.substring( 0, colonIndex ); // We should *not* have a DN twice if ( attributeType.equals( "dn" ) ) { LOG.error( I18n.err( I18n.ERR_12002 ) ); throw new LdapLdifException( I18n.err( I18n.ERR_12003 ) ); } Object attributeValue = parseValue( line, colonIndex ); // Update the entry entry.addAttribute( attributeType, attributeValue ); }
/** * 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() ); } } } }
/** * {@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; }
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); } } }
/** * {@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; }
reader.close(); matchingRuleList.add( entry.getEntry() );
reader.close(); matchingRuleUseList.add( entry.getEntry() );
reader.close(); ditContentRulesList.add( entry.getEntry() );
/** * {@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(); ditStructureRuleList.add( entry.getEntry() );