Java Code Examples for org.apache.directory.api.ldap.model.ldif.LdifReader#next()
The following examples show how to use
org.apache.directory.api.ldap.model.ldif.LdifReader#next() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JarLdifSchemaLoader.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public List<Entry> loadObjectClasses( Schema... schemas ) throws LdapException, IOException { List<Entry> objectClassList = new ArrayList<>(); if ( schemas == null ) { return objectClassList; } for ( Schema schema : schemas ) { // get objectClasses directory, check if exists, return if not String start = getSchemaDirectoryString( schema ) + SchemaConstants.OBJECT_CLASSES_PATH + "/" + "m-oid="; String end = "." + LDIF_EXT; for ( String resourcePath : RESOURCE_MAP.keySet() ) { if ( resourcePath.startsWith( start ) && resourcePath.endsWith( end ) ) { URL resource = getResource( resourcePath, "objectClass LDIF file" ); LdifReader reader = new LdifReader( resource.openStream() ); LdifEntry entry = reader.next(); reader.close(); objectClassList.add( entry.getEntry() ); } } } return objectClassList; }
Example 2
Source File: InMemorySchemaPartition.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
/** * Partition initialization - loads schema entries from the files on classpath. * * @see org.apache.directory.server.core.partition.impl.avl.AvlPartition#doInit() */ @Override protected void doInit() throws Exception { if (initialized) return; LOG.debug("Initializing schema partition " + getId()); suffixDn.apply(schemaManager); super.doInit(); // load schema final Map<String, Boolean> resMap = ResourceMap.getResources(Pattern.compile("schema[/\\Q\\\\E]ou=schema.*")); for (String resourcePath : new TreeSet<String>(resMap.keySet())) { if (resourcePath.endsWith(".ldif")) { URL resource = DefaultSchemaLdifExtractor.getUniqueResource(resourcePath, "Schema LDIF file"); LdifReader reader = new LdifReader(resource.openStream()); LdifEntry ldifEntry = reader.next(); reader.close(); Entry entry = new DefaultEntry(schemaManager, ldifEntry.getEntry()); // add mandatory attributes if (entry.get(SchemaConstants.ENTRY_CSN_AT) == null) { entry.add(SchemaConstants.ENTRY_CSN_AT, defaultCSNFactory.newInstance().toString()); } if (entry.get(SchemaConstants.ENTRY_UUID_AT) == null) { entry.add(SchemaConstants.ENTRY_UUID_AT, UUID.randomUUID().toString()); } AddOperationContext addContext = new AddOperationContext(null, entry); super.add(addContext); } } }
Example 3
Source File: InMemorySchemaPartition.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
/** * Partition initialization - loads schema entries from the files on classpath. * * @see org.apache.directory.server.core.partition.impl.avl.AvlPartition#doInit() */ @Override protected void doInit() throws Exception { if (initialized) return; LOG.debug("Initializing schema partition " + getId()); suffixDn.apply(schemaManager); super.doInit(); // load schema final Map<String, Boolean> resMap = ResourceMap.getResources(Pattern.compile("schema[/\\Q\\\\E]ou=schema.*")); for (String resourcePath : new TreeSet<String>(resMap.keySet())) { if (resourcePath.endsWith(".ldif")) { URL resource = DefaultSchemaLdifExtractor.getUniqueResource(resourcePath, "Schema LDIF file"); LdifReader reader = new LdifReader(resource.openStream()); LdifEntry ldifEntry = reader.next(); reader.close(); Entry entry = new DefaultEntry(schemaManager, ldifEntry.getEntry()); // add mandatory attributes if (entry.get(SchemaConstants.ENTRY_CSN_AT) == null) { entry.add(SchemaConstants.ENTRY_CSN_AT, defaultCSNFactory.newInstance().toString()); } if (entry.get(SchemaConstants.ENTRY_UUID_AT) == null) { entry.add(SchemaConstants.ENTRY_UUID_AT, UUID.randomUUID().toString()); } AddOperationContext addContext = new AddOperationContext(null, entry); super.add(addContext); } } }
Example 4
Source File: LdifSchemaLoader.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public List<Entry> loadMatchingRuleUses( Schema... schemas ) throws LdapException, IOException { List<Entry> matchingRuleUseList = new ArrayList<>(); if ( schemas == null ) { return matchingRuleUseList; } for ( Schema schema : schemas ) { File matchingRuleUsesDirectory = new File( getSchemaDirectory( schema ), SchemaConstants.MATCHING_RULE_USE_PATH ); if ( !matchingRuleUsesDirectory.exists() ) { return matchingRuleUseList; } File[] matchingRuleUseFiles = matchingRuleUsesDirectory.listFiles( ldifFilter ); if ( matchingRuleUseFiles != null ) { for ( File ldifFile : matchingRuleUseFiles ) { LdifReader reader = new LdifReader( ldifFile ); LdifEntry entry = reader.next(); reader.close(); matchingRuleUseList.add( entry.getEntry() ); } } } return matchingRuleUseList; }
Example 5
Source File: InMemorySchemaPartition.java From bouncr with Eclipse Public License 1.0 | 5 votes |
/** * Partition initialization - loads schema entries from the files on classpath. * * @see org.apache.directory.server.core.partition.impl.avl.AvlPartition#doInit() */ @Override protected void doInit() throws InvalidNameException, Exception { if (initialized) return; LOG.debug("Initializing schema partition " + getId()); suffixDn.apply(schemaManager); super.doInit(); // load schema final Map<String, Boolean> resMap = ResourceMap.getResources(Pattern.compile("schema[/\\Q\\\\E]ou=schema.*")); for (String resourcePath : new TreeSet<>(resMap.keySet())) { if (resourcePath.endsWith(".ldif")) { URL resource = DefaultSchemaLdifExtractor.getUniqueResource(resourcePath, "Schema LDIF file"); LdifReader reader = new LdifReader(resource.openStream()); LdifEntry ldifEntry = reader.next(); reader.close(); Entry entry = new DefaultEntry(schemaManager, ldifEntry.getEntry()); // add mandatory attributes if (entry.get(SchemaConstants.ENTRY_CSN_AT) == null) { entry.add(SchemaConstants.ENTRY_CSN_AT, defaultCSNFactory.newInstance().toString()); } if (entry.get(SchemaConstants.ENTRY_UUID_AT) == null) { entry.add(SchemaConstants.ENTRY_UUID_AT, UUID.randomUUID().toString()); } AddOperationContext addContext = new AddOperationContext(null, entry); super.add(addContext); } } }
Example 6
Source File: LdifSchemaLoader.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public List<Entry> loadSyntaxes( Schema... schemas ) throws LdapException, IOException { List<Entry> syntaxList = new ArrayList<>(); if ( schemas == null ) { return syntaxList; } for ( Schema schema : schemas ) { File syntaxesDirectory = new File( getSchemaDirectory( schema ), SchemaConstants.SYNTAXES_PATH ); if ( !syntaxesDirectory.exists() ) { return syntaxList; } File[] syntaxFiles = syntaxesDirectory.listFiles( ldifFilter ); if ( syntaxFiles != null ) { for ( File ldifFile : syntaxFiles ) { LdifReader reader = new LdifReader( ldifFile ); LdifEntry entry = reader.next(); reader.close(); syntaxList.add( entry.getEntry() ); } } } return syntaxList; }
Example 7
Source File: LdifSchemaLoader.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public List<Entry> loadMatchingRules( Schema... schemas ) throws LdapException, IOException { List<Entry> matchingRuleList = new ArrayList<>(); 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 ); if ( matchingRuleFiles != null ) { for ( File ldifFile : matchingRuleFiles ) { LdifReader reader = new LdifReader( ldifFile ); LdifEntry entry = reader.next(); reader.close(); matchingRuleList.add( entry.getEntry() ); } } } return matchingRuleList; }
Example 8
Source File: LdifSchemaLoader.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public List<Entry> loadObjectClasses( Schema... schemas ) throws LdapException, IOException { List<Entry> objectClassList = new ArrayList<>(); if ( schemas == null ) { return objectClassList; } for ( Schema schema : schemas ) { // get objectClasses directory, check if exists, return if not File objectClassesDirectory = new File( getSchemaDirectory( schema ), SchemaConstants.OBJECT_CLASSES_PATH ); if ( !objectClassesDirectory.exists() ) { return objectClassList; } // get list of objectClass LDIF files from directory and load File[] objectClassFiles = objectClassesDirectory.listFiles( ldifFilter ); if ( objectClassFiles != null ) { for ( File ldifFile : objectClassFiles ) { LdifReader reader = new LdifReader( ldifFile ); LdifEntry entry = reader.next(); reader.close(); objectClassList.add( entry.getEntry() ); } } } return objectClassList; }
Example 9
Source File: LdifSchemaLoader.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public List<Entry> loadSyntaxCheckers( Schema... schemas ) throws LdapException, IOException { List<Entry> syntaxCheckerList = new ArrayList<>(); 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 ); if ( syntaxCheckerFiles != null ) { for ( File ldifFile : syntaxCheckerFiles ) { LdifReader reader = new LdifReader( ldifFile ); LdifEntry entry = reader.next(); reader.close(); syntaxCheckerList.add( entry.getEntry() ); } } } return syntaxCheckerList; }
Example 10
Source File: LdifSchemaLoader.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public List<Entry> loadComparators( Schema... schemas ) throws LdapException, IOException { List<Entry> comparatorList = new ArrayList<>(); 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 ); if ( comparators != null ) { for ( File ldifFile : comparators ) { LdifReader reader = new LdifReader( ldifFile ); LdifEntry entry = reader.next(); reader.close(); comparatorList.add( entry.getEntry() ); } } } return comparatorList; }
Example 11
Source File: JarLdifSchemaLoader.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public List<Entry> loadComparators( Schema... schemas ) throws LdapException, IOException { List<Entry> comparatorList = new ArrayList<>(); if ( schemas == null ) { return comparatorList; } for ( Schema schema : schemas ) { String start = getSchemaDirectoryString( schema ) + SchemaConstants.COMPARATORS_PATH + "/" + "m-oid="; String end = "." + LDIF_EXT; for ( String resourcePath : RESOURCE_MAP.keySet() ) { if ( resourcePath.startsWith( start ) && resourcePath.endsWith( end ) ) { URL resource = getResource( resourcePath, "comparator LDIF file" ); LdifReader reader = new LdifReader( resource.openStream() ); LdifEntry entry = reader.next(); reader.close(); comparatorList.add( entry.getEntry() ); } } } return comparatorList; }
Example 12
Source File: JarLdifSchemaLoader.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public List<Entry> loadDitStructureRules( Schema... schemas ) throws LdapException, IOException { List<Entry> ditStructureRuleList = new ArrayList<>(); if ( schemas == null ) { return ditStructureRuleList; } for ( Schema schema : schemas ) { String start = getSchemaDirectoryString( schema ) + SchemaConstants.DIT_STRUCTURE_RULES_PATH + "/" + "m-oid="; String end = "." + LDIF_EXT; for ( String resourcePath : RESOURCE_MAP.keySet() ) { if ( resourcePath.startsWith( start ) && resourcePath.endsWith( end ) ) { URL resource = getResource( resourcePath, "ditStructureRule LDIF file" ); LdifReader reader = new LdifReader( resource.openStream() ); LdifEntry entry = reader.next(); reader.close(); ditStructureRuleList.add( entry.getEntry() ); } } } return ditStructureRuleList; }
Example 13
Source File: JarLdifSchemaLoader.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public List<Entry> loadDitContentRules( Schema... schemas ) throws LdapException, IOException { List<Entry> ditContentRulesList = new ArrayList<>(); if ( schemas == null ) { return ditContentRulesList; } for ( Schema schema : schemas ) { String start = getSchemaDirectoryString( schema ) + SchemaConstants.DIT_CONTENT_RULES_PATH + "/" + "m-oid="; String end = "." + LDIF_EXT; for ( String resourcePath : RESOURCE_MAP.keySet() ) { if ( resourcePath.startsWith( start ) && resourcePath.endsWith( end ) ) { URL resource = getResource( resourcePath, "ditContentRule LDIF file" ); LdifReader reader = new LdifReader( resource.openStream() ); LdifEntry entry = reader.next(); reader.close(); ditContentRulesList.add( entry.getEntry() ); } } } return ditContentRulesList; }
Example 14
Source File: JarLdifSchemaLoader.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public List<Entry> loadNameForms( Schema... schemas ) throws LdapException, IOException { List<Entry> nameFormList = new ArrayList<>(); if ( schemas == null ) { return nameFormList; } for ( Schema schema : schemas ) { String start = getSchemaDirectoryString( schema ) + SchemaConstants.NAME_FORMS_PATH + "/" + "m-oid="; String end = "." + LDIF_EXT; for ( String resourcePath : RESOURCE_MAP.keySet() ) { if ( resourcePath.startsWith( start ) && resourcePath.endsWith( end ) ) { URL resource = getResource( resourcePath, "nameForm LDIF file" ); LdifReader reader = new LdifReader( resource.openStream() ); LdifEntry entry = reader.next(); reader.close(); nameFormList.add( entry.getEntry() ); } } } return nameFormList; }
Example 15
Source File: JarLdifSchemaLoader.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public List<Entry> loadMatchingRuleUses( Schema... schemas ) throws LdapException, IOException { List<Entry> matchingRuleUseList = new ArrayList<>(); if ( schemas == null ) { return matchingRuleUseList; } for ( Schema schema : schemas ) { String start = getSchemaDirectoryString( schema ) + SchemaConstants.MATCHING_RULE_USE_PATH + "/" + "m-oid="; String end = "." + LDIF_EXT; for ( String resourcePath : RESOURCE_MAP.keySet() ) { if ( resourcePath.startsWith( start ) && resourcePath.endsWith( end ) ) { URL resource = getResource( resourcePath, "matchingRuleUse LDIF file" ); LdifReader reader = new LdifReader( resource.openStream() ); LdifEntry entry = reader.next(); reader.close(); matchingRuleUseList.add( entry.getEntry() ); } } } return matchingRuleUseList; }
Example 16
Source File: JarLdifSchemaLoader.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public List<Entry> loadAttributeTypes( Schema... schemas ) throws LdapException, IOException { List<Entry> attributeTypeList = new ArrayList<>(); if ( schemas == null ) { return attributeTypeList; } for ( Schema schema : schemas ) { // check that the attributeTypes directory exists for the schema String start = getSchemaDirectoryString( schema ) + SchemaConstants.ATTRIBUTE_TYPES_PATH + "/" + "m-oid="; String end = "." + LDIF_EXT; // get list of attributeType LDIF schema files in attributeTypes for ( String resourcePath : RESOURCE_MAP.keySet() ) { if ( resourcePath.startsWith( start ) && resourcePath.endsWith( end ) ) { URL resource = getResource( resourcePath, "attributeType LDIF file" ); LdifReader reader = new LdifReader( resource.openStream() ); LdifEntry entry = reader.next(); reader.close(); attributeTypeList.add( entry.getEntry() ); } } } return attributeTypeList; }
Example 17
Source File: JarLdifSchemaLoader.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public List<Entry> loadSyntaxes( Schema... schemas ) throws LdapException, IOException { List<Entry> syntaxList = new ArrayList<>(); if ( schemas == null ) { return syntaxList; } for ( Schema schema : schemas ) { String start = getSchemaDirectoryString( schema ) + SchemaConstants.SYNTAXES_PATH + "/" + "m-oid="; String end = "." + LDIF_EXT; for ( String resourcePath : RESOURCE_MAP.keySet() ) { if ( resourcePath.startsWith( start ) && resourcePath.endsWith( end ) ) { URL resource = getResource( resourcePath, "syntax LDIF file" ); LdifReader reader = new LdifReader( resource.openStream() ); LdifEntry entry = reader.next(); reader.close(); syntaxList.add( entry.getEntry() ); } } } return syntaxList; }
Example 18
Source File: JarLdifSchemaLoader.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public List<Entry> loadMatchingRules( Schema... schemas ) throws LdapException, IOException { List<Entry> matchingRuleList = new ArrayList<>(); if ( schemas == null ) { return matchingRuleList; } for ( Schema schema : schemas ) { String start = getSchemaDirectoryString( schema ) + SchemaConstants.MATCHING_RULES_PATH + "/" + "m-oid="; String end = "." + LDIF_EXT; for ( String resourcePath : RESOURCE_MAP.keySet() ) { if ( resourcePath.startsWith( start ) && resourcePath.endsWith( end ) ) { URL resource = getResource( resourcePath, "matchingRules LDIF file" ); LdifReader reader = new LdifReader( resource.openStream() ); LdifEntry entry = reader.next(); reader.close(); matchingRuleList.add( entry.getEntry() ); } } } return matchingRuleList; }
Example 19
Source File: InMemorySchemaPartition.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
/** * Partition initialization - loads schema entries from the files on classpath. * * @see org.apache.directory.server.core.partition.impl.avl.AvlPartition#doInit() */ @Override protected void doInit() throws Exception { if (initialized) return; LOG.debugf("Initializing schema partition %s", getId()); suffixDn.apply(schemaManager); super.doInit(); // load schema final Map<String, Boolean> resMap = ResourceMap.getResources(Pattern.compile("schema[/\\Q\\\\E]ou=schema.*")); for (String resourcePath : new TreeSet<String>(resMap.keySet())) { if (resourcePath.endsWith(".ldif")) { URL resource = DefaultSchemaLdifExtractor.getUniqueResource(resourcePath, "Schema LDIF file"); LdifReader reader = new LdifReader(resource.openStream()); LdifEntry ldifEntry = reader.next(); reader.close(); Entry entry = new DefaultEntry(schemaManager, ldifEntry.getEntry()); // add mandatory attributes if (entry.get(SchemaConstants.ENTRY_CSN_AT) == null) { entry.add(SchemaConstants.ENTRY_CSN_AT, defaultCSNFactory.newInstance().toString()); } if (entry.get(SchemaConstants.ENTRY_UUID_AT) == null) { entry.add(SchemaConstants.ENTRY_UUID_AT, UUID.randomUUID().toString()); } AddOperationContext addContext = new AddOperationContext(null, entry); super.add(addContext); } } }
Example 20
Source File: JarLdifSchemaLoader.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public List<Entry> loadSyntaxCheckers( Schema... schemas ) throws LdapException, IOException { List<Entry> syntaxCheckerList = new ArrayList<>(); if ( schemas == null ) { return syntaxCheckerList; } for ( Schema schema : schemas ) { String start = getSchemaDirectoryString( schema ) + SchemaConstants.SYNTAX_CHECKERS_PATH + "/" + "m-oid="; String end = "." + LDIF_EXT; for ( String resourcePath : RESOURCE_MAP.keySet() ) { if ( resourcePath.startsWith( start ) && resourcePath.endsWith( end ) ) { URL resource = getResource( resourcePath, "syntaxChecker LDIF file" ); LdifReader reader = new LdifReader( resource.openStream() ); LdifEntry entry = reader.next(); reader.close(); syntaxCheckerList.add( entry.getEntry() ); } } } return syntaxCheckerList; }