<commit_before>/*
 *  Licensed to the Apache Software Foundation (ASF) under one
 *  or more contributor license agreements.  See the NOTICE file
 *  distributed with this work for additional information
 *  regarding copyright ownership.  The ASF licenses this file
 *  to you under the Apache License, Version 2.0 (the
 *  "License"); you may not use this file except in compliance
 *  with the License.  You may obtain a copy of the License at
 *  
 *    http://www.apache.org/licenses/LICENSE-2.0
 *  
 *  Unless required by applicable law or agreed to in writing,
 *  software distributed under the License is distributed on an
 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 *  KIND, either express or implied.  See the License for the
 *  specific language governing permissions and limitations
 *  under the License. 
 *  
 */
package org.apache.directory.server.xdbm.tools;


import org.apache.directory.server.core.entry.DefaultServerEntry;
import org.apache.directory.server.core.entry.ServerEntryUtils;
import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
import org.apache.directory.server.schema.registries.Registries;
import org.apache.directory.server.xdbm.Store;
import org.apache.directory.shared.ldap.name.LdapDN;


/**
 * A utility class for loading example LDIF data.
 *
 * @author <a href="mailto:<EMAIL>">Apache Directory Project</a>
 * @version $Rev$, $Date$
 */
public class StoreUtils
{

    /**
     * Initializes and loads a store with the example data shown in
     * <a href="http://cwiki.apache.org/confluence/display/DIRxSRVx11/Structure+and+Organization">
     * Structure and Organization</a>
     *
     * TODO might want to make this load an LDIF instead in the future
     * TODO add alias entries
     * TODO correct size of spaces in user provided DN
     * 
     * @param store the store object to be initialized
     * @param registries oid registries
     * @throws Exception on access exceptions
     */
    public static void loadExampleData( Store store, Registries registries ) throws Exception
    {
        store.setSuffixDn( "o=Good Times Co." );
        
        DefaultServerEntry contextEntry = new DefaultServerEntry( registries, new LdapDN( "o=Good Times Co." ) );
        contextEntry.add( "objectClass", "organization" );
        store.setContextEntry( contextEntry );
        
        AttributeTypeRegistry attributeRegistry = registries.getAttributeTypeRegistry();
        
        store.init( registries.getOidRegistry(), attributeRegistry );
        
        LdapDN dn = new LdapDN( "ou=Sales,o=Good Times Co." );
        dn.normalize( attributeRegistry.getNormalizerMapping() );
        DefaultServerEntry entry = new DefaultServerEntry( registries, dn );
        entry.add( "objectClass", "top", "organizationalUnit" );
        entry.add( "ou", "Sales" );
        store.add( dn, ServerEntryUtils.toAttributesImpl( entry ) );

        dn = new LdapDN( "ou=Board of Directors,o=Good Times Co." );
        dn.normalize( attributeRegistry.getNormalizerMapping() );
        entry = new DefaultServerEntry( registries, dn );
        entry.add( "objectClass", "top", "organizationalUnit" );
        entry.add( "ou", "Board of Directors" );
        store.add( dn, ServerEntryUtils.toAttributesImpl( entry ) );
        
        dn = new LdapDN( "ou=Engineering,o=Good Times Co." );
        dn.normalize( attributeRegistry.getNormalizerMapping() );
        entry = new DefaultServerEntry( registries, dn );
        entry.add( "objectClass", "top", "organizationalUnit" );
        entry.add( "ou", "Engineering" );
        store.add( dn, ServerEntryUtils.toAttributesImpl( entry ) );
        
        dn = new LdapDN( "cn=JOnny WAlkeR,ou=Sales,o=Good Times Co." );
        dn.normalize( attributeRegistry.getNormalizerMapping() );
        entry = new DefaultServerEntry( registries, dn );
        entry.add( "objectClass", "top", "person", "organizationalPerson" );
        entry.add( "ou", "Sales" );
        entry.add( "cn",  "JOnny WAlkeR");
        store.add( dn, ServerEntryUtils.toAttributesImpl( entry ) );
        
        dn = new LdapDN( "cn=JIM BEAN,ou=Sales,o=Good Times Co." );
        dn.normalize( attributeRegistry.getNormalizerMapping() );
        entry = new DefaultServerEntry( registries, dn );
        entry.add( "objectClass", "top", "person", "organizationalPerson" );
        entry.add( "ou", "Sales" );
        entry.add( "cn",  "JIM BEAN");
        store.add( dn, ServerEntryUtils.toAttributesImpl( entry ) );
        
        dn = new LdapDN( "cn=<NAME>,ou=Engineering,o=Good Times Co." );
        dn.normalize( attributeRegistry.getNormalizerMapping() );
        entry = new DefaultServerEntry( registries, dn );
        entry.add( "objectClass", "top", "person", "organizationalPerson" );
        entry.add( "ou", "Engineering" );
        entry.add( "cn",  "<NAME>");
        store.add( dn, ServerEntryUtils.toAttributesImpl( entry ) );

        // still need to add aliases
    }
}<commit_msg>added aliases present in the doc<commit_after>/*
 *  Licensed to the Apache Software Foundation (ASF) under one
 *  or more contributor license agreements.  See the NOTICE file
 *  distributed with this work for additional information
 *  regarding copyright ownership.  The ASF licenses this file
 *  to you under the Apache License, Version 2.0 (the
 *  "License"); you may not use this file except in compliance
 *  with the License.  You may obtain a copy of the License at
 *  
 *    http://www.apache.org/licenses/LICENSE-2.0
 *  
 *  Unless required by applicable law or agreed to in writing,
 *  software distributed under the License is distributed on an
 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 *  KIND, either express or implied.  See the License for the
 *  specific language governing permissions and limitations
 *  under the License. 
 *  
 */
package org.apache.directory.server.xdbm.tools;


import org.apache.directory.server.core.entry.DefaultServerEntry;
import org.apache.directory.server.core.entry.ServerEntryUtils;
import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
import org.apache.directory.server.schema.registries.Registries;
import org.apache.directory.server.xdbm.Store;
import org.apache.directory.shared.ldap.name.LdapDN;


/**
 * A utility class for loading example LDIF data.
 *
 * @author <a href="mailto:<EMAIL>">Apache Directory Project</a>
 * @version $Rev$, $Date$
 */
public class StoreUtils
{

    /**
     * Initializes and loads a store with the example data shown in
     * <a href="http://cwiki.apache.org/confluence/display/DIRxSRVx11/Structure+and+Organization">
     * Structure and Organization</a>
     *
     * TODO might want to make this load an LDIF instead in the future
     * TODO correct size of spaces in user provided DN
     * 
     * @param store the store object to be initialized
     * @param registries oid registries
     * @throws Exception on access exceptions
     */
    public static void loadExampleData( Store store, Registries registries ) throws Exception
    {
        store.setSuffixDn( "o=Good Times Co." );
        
        DefaultServerEntry contextEntry = new DefaultServerEntry( registries, new LdapDN( "o=Good Times Co." ) );
        contextEntry.add( "objectClass", "organization" );
        store.setContextEntry( contextEntry );
        
        AttributeTypeRegistry attributeRegistry = registries.getAttributeTypeRegistry();
        
        store.init( registries.getOidRegistry(), attributeRegistry );
        
        LdapDN dn = new LdapDN( "ou=Sales,o=Good Times Co." );
        dn.normalize( attributeRegistry.getNormalizerMapping() );
        DefaultServerEntry entry = new DefaultServerEntry( registries, dn );
        entry.add( "objectClass", "top", "organizationalUnit" );
        entry.add( "ou", "Sales" );
        store.add( dn, ServerEntryUtils.toAttributesImpl( entry ) );

        dn = new LdapDN( "ou=Board of Directors,o=Good Times Co." );
        dn.normalize( attributeRegistry.getNormalizerMapping() );
        entry = new DefaultServerEntry( registries, dn );
        entry.add( "objectClass", "top", "organizationalUnit" );
        entry.add( "ou", "Board of Directors" );
        store.add( dn, ServerEntryUtils.toAttributesImpl( entry ) );
        
        dn = new LdapDN( "ou=Engineering,o=Good Times Co." );
        dn.normalize( attributeRegistry.getNormalizerMapping() );
        entry = new DefaultServerEntry( registries, dn );
        entry.add( "objectClass", "top", "organizationalUnit" );
        entry.add( "ou", "Engineering" );
        store.add( dn, ServerEntryUtils.toAttributesImpl( entry ) );
        
        dn = new LdapDN( "cn=JOhnny WAlkeR,ou=Sales,o=Good Times Co." );
        dn.normalize( attributeRegistry.getNormalizerMapping() );
        entry = new DefaultServerEntry( registries, dn );
        entry.add( "objectClass", "top", "person", "organizationalPerson" );
        entry.add( "ou", "Sales" );
        entry.add( "cn",  "JOhnny WAlkeR");
        store.add( dn, ServerEntryUtils.toAttributesImpl( entry ) );
        
        dn = new LdapDN( "cn=JIM BEAN,ou=Sales,o=Good Times Co." );
        dn.normalize( attributeRegistry.getNormalizerMapping() );
        entry = new DefaultServerEntry( registries, dn );
        entry.add( "objectClass", "top", "person", "organizationalPerson" );
        entry.add( "ou", "Sales" );
        entry.add( "cn",  "JIM BEAN");
        store.add( dn, ServerEntryUtils.toAttributesImpl( entry ) );
        
        dn = new LdapDN( "cn=<NAME>,ou=Engineering,o=Good Times Co." );
        dn.normalize( attributeRegistry.getNormalizerMapping() );
        entry = new DefaultServerEntry( registries, dn );
        entry.add( "objectClass", "top", "person", "organizationalPerson" );
        entry.add( "ou", "Engineering" );
        entry.add( "cn",  "<NAME>");
        store.add( dn, ServerEntryUtils.toAttributesImpl( entry ) );

        // aliases
        dn = new LdapDN( "commonName=<NAME>,ou=Board of Directors,o=Good Times Co." );
        dn.normalize( attributeRegistry.getNormalizerMapping() );
        entry = new DefaultServerEntry( registries, dn );
        entry.add( "objectClass", "top", "alias", "extensibleObject" );
        entry.add( "ou", "Board of Directors" );
        entry.add( "commonName",  "<NAME>");
        entry.add( "aliasedObjectName", "cn=<NAME>,ou=Sales,o=Good Times Co." );
        store.add( dn, ServerEntryUtils.toAttributesImpl( entry ) );

        dn = new LdapDN( "192.168.127.12=<NAME>,ou=Engineering,o=Good Times Co." );
        dn.normalize( attributeRegistry.getNormalizerMapping() );
        entry = new DefaultServerEntry( registries, dn );
        entry.add( "objectClass", "top", "alias", "extensibleObject" );
        entry.add( "ou", "Engineering" );
        entry.add( "192.168.127.12",  "<NAME>");
        entry.add( "aliasedObjectName", "cn=<NAME>,ou=Sales,o=Good Times Co." );
        store.add( dn, ServerEntryUtils.toAttributesImpl( entry ) );
    }
}
{'fraction_non_alphanumeric': 0.11947463768115942, 'fraction_numerical': 0.0030797101449275364, 'mean_word_length': 3.127476635514019, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4558578', 'n_tokens_mistral': 3293, 'n_tokens_neox': 3202, 'n_words': 889}