Package org.apache.directory.shared.ldap.ldif

Examples of org.apache.directory.shared.ldap.ldif.LdifReader


        try
        {
            in = new FileReader( selected );

            for ( LdifEntry entry:new LdifReader( in ) )
            {
                String updn = entry.getDn().getUpName();
               
                LdapDN ndn = new LdapDN( StringTools.deepTrimToLower( updn ) );
View Full Code Here


     * @param ldif the ldif containing entries to add to the server.
     * @throws NamingException if there is a problem adding the entries from the LDIF
     */
    public static void injectEntries( DirectoryService service, String ldif ) throws Exception
    {
        LdifReader reader = new LdifReader();
        List<LdifEntry> entries = reader.parseLdif( ldif );

        for ( LdifEntry entry : entries )
        {
            if ( entry.isChangeAdd() )
            {
View Full Code Here

                    Class<?> clazz = Class.forName( className );
                    URL url = clazz.getResource( ldifFile );
                    URI uri = url.toURI();
                    File file = new File( uri );

                    LdifReader ldifReader = new LdifReader( file );
   
                    for ( LdifEntry entry : ldifReader )
                    {
                        service.getAdminSession().add(
                            new DefaultServerEntry( service.getRegistries(), entry.getEntry() ) );
                        LOG.debug( "Successfully injected LDIF enry for test {}: {}", settings.getDescription(), entry );
                    }
                }
                catch ( Exception e )
                {
                    LOG.error( "Cannot inject the following entry : {}. Error : {}.", ldifFile, e.getMessage() );
                }
            }
        }
        ldifs =  settings.getLdifs( ldifs );
       
        if ( ldifs.size() != 0 )
        {
            for ( String ldif:ldifs )
            {
                try
                {
                    StringReader in = new StringReader( ldif );
                    LdifReader ldifReader = new LdifReader( in );
                   
                    for ( LdifEntry entry : ldifReader )
                    {
                        service.getAdminSession().add(
                            new DefaultServerEntry( service.getRegistries(), entry.getEntry() ) );
View Full Code Here

            "m-typeObjectClass: STRUCTURAL\n" +
            "m-obsolete: FALSE\n" +
            "m-description: A ship\n";

        StringReader in = new StringReader( numberOfGunsAttrLdif + "\n\n" + shipOCLdif );
        LdifReader ldifReader = new LdifReader( in );
        LdifEntry numberOfGunsAttrEntry = ldifReader.next();
        LdifEntry shipOCEntry = ldifReader.next();
        assertFalse( ldifReader.hasNext() );
       
        // should be fine with unique OID
        service.getAdminSession().add(
            new DefaultServerEntry( service.getSchemaManager(), numberOfGunsAttrEntry.getEntry() ) );
View Full Code Here

            "m-typeObjectClass: STRUCTURAL\n" +
            "m-obsolete: FALSE\n" +
            "m-description: A ship\n";

        StringReader in = new StringReader( numberOfGunsAttrLdif + "\n\n" + shipOCLdif );
        LdifReader ldifReader = new LdifReader( in );
        LdifEntry numberOfGunsAttrEntry = ldifReader.next();
        LdifEntry shipOCEntry = ldifReader.next();
        assertFalse( ldifReader.hasNext() );
       
        // should be fine with unique OID
        service.getAdminSession().add(
            new DefaultServerEntry( service.getSchemaManager(), numberOfGunsAttrEntry.getEntry() ) );
View Full Code Here

                loadEntries( f, entries );
            }
        }
        else
        {
            LdifReader reader = new LdifReader();
            entries.addAll( reader.parseLdifFile( ldifFile.getAbsolutePath() ) );
            reader.close();
        }
    }
View Full Code Here

        InputStream in = null;

        try {
            in = ldif.openStream();

            for (final LdifEntry ldifEntry : new LdifReader(in)) {
                final DN dn = ldifEntry.getDn();

                if (ldifEntry.isEntry()) {
                    final Entry entry = ldifEntry.getEntry();
                    try {
View Full Code Here

        InputStream in = null;

        try {
            in = ldif.openStream();

            for (final LdifEntry ldifEntry : new LdifReader(in)) {
                final DN dn = ldifEntry.getDn();

                if (ldifEntry.isEntry()) {
                    final Entry entry = ldifEntry.getEntry();
                    try {
View Full Code Here

            entryippon.add("dc", "ippon");
            service.getAdminSession().add(entryippon);

            System.out.printf("Importing some data ... %n", ipponPartition.getSuffixDn());
            InputStream is = this.getClass().getResource("ipponTestLdapExport.ldif").openStream();
            LdifReader ldifReader = new LdifReader(is);
            for (LdifEntry entry : ldifReader) {
                injectEntry(entry, service);
            }
            is.close();
View Full Code Here

TOP

Related Classes of org.apache.directory.shared.ldap.ldif.LdifReader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.