Package org.apache.directory.shared.ldap.entry

Examples of org.apache.directory.shared.ldap.entry.ServerEntry


    public Object lookup( Name name ) throws NamingException
    {
        Object obj;
        DN target = buildTarget( DN.fromName( name ) );

        ServerEntry serverEntry = null;

        try
        {
            if ( name.size() == 0 )
            {
                serverEntry = doGetRootDSEOperation( target );
            }
            else
            {
                serverEntry = doLookupOperation( target );
            }
        }
        catch ( Exception e )
        {
            JndiUtils.wrap( e );
        }

        try
        {
            obj = DirectoryManager.getObjectInstance( null, name, this, env,
                ServerEntryUtils.toBasicAttributes( serverEntry ) );
        }
        catch ( Exception e )
        {
            String msg = I18n.err( I18n.ERR_497, target );
            NamingException ne = new NamingException( msg );
            ne.setRootCause( e );
            throw ne;
        }

        if ( obj != null )
        {
            return obj;
        }

        // First lets test and see if the entry is a serialized java object
        if ( serverEntry.get( JavaLdapSupport.JCLASSNAME_ATTR ) != null )
        {
            // Give back serialized object and not a context
            return JavaLdapSupport.deserialize( serverEntry );
        }
View Full Code Here


            return;
        }
       
        assertHasEntry( nextInterceptor, opContext, msg, opContext.getDn() );

        ServerEntry entry = opContext.lookup( opContext.getDn(), ByPassConstants.LOOKUP_BYPASS );
        List<Modification> items = opContext.getModItems();

        for ( Modification item : items )
        {
            if ( item.getOperation() == ModificationOperation.ADD_ATTRIBUTE )
            {
                EntryAttribute modAttr = item.getAttribute();
                EntryAttribute entryAttr = entry.get( modAttr.getId() );

                if ( entryAttr != null )
                {
                    for ( Value<?> value:modAttr )
                    {
View Full Code Here

            return;
        }

        DN target = buildTarget( DN.fromName( name ) );

        ServerEntry serverEntry = null;
       
        try
        {
            serverEntry = ServerEntryUtils.toServerEntry( AttributeUtils.toCaseInsensitive( attrs ), target,
                getDirectoryService().getSchemaManager() );
        }
        catch ( LdapInvalidAttributeTypeException liate )
        {
            throw new InvalidAttributesException( liate.getMessage() );
        }

        // No object binding so we just add the attributes
        if ( null == obj )
        {
            ServerEntry clone = ( ServerEntry ) serverEntry.clone();
            try
            {
                doAddOperation( target, clone );
            }
            catch ( Exception e )
            {
                JndiUtils.wrap( e );
            }
            return;
        }

        // First, use state factories to do a transformation
        DirStateFactory.Result res = DirectoryManager.getStateToBind( obj, name, this, getEnvironment(), attrs );
        ServerEntry outServerEntry = null;
       
        try
        {
            outServerEntry = ServerEntryUtils.toServerEntry(
                res.getAttributes(), target, getDirectoryService().getSchemaManager() );
        }
        catch ( LdapInvalidAttributeTypeException le )
        {
            throw new InvalidAttributesException( le.getMessage() );
        }

        if ( outServerEntry != serverEntry )
        {
            ServerEntry clone = ( ServerEntry ) serverEntry.clone();

            if ( ( outServerEntry != null ) && ( outServerEntry.size() > 0 ) )
            {
                for ( EntryAttribute attribute : outServerEntry )
                {
                    try
                    {
                        clone.put( attribute );
                    }
                    catch ( LdapException e )
                    {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                }
            }

            try
            {
                // setup the op context
                doAddOperation( target, clone );
            }
            catch ( Exception e )
            {
                JndiUtils.wrap( e );
            }
           
            return;
        }

        // Check for Referenceable
        if ( obj instanceof Referenceable )
        {
            throw new NamingException( I18n.err( I18n.ERR_493 ) );
        }

        // Store different formats
        if ( obj instanceof Reference )
        {
            // Store as ref and add outAttrs
            throw new NamingException( I18n.err( I18n.ERR_494 ) );
        }
        else if ( obj instanceof Serializable )
        {
            // Serialize and add outAttrs
            ServerEntry clone = ( ServerEntry ) serverEntry.clone();

            if ( outServerEntry != null && outServerEntry.size() > 0 )
            {
                for ( EntryAttribute attribute : outServerEntry )
                {
                    try
                    {
                        clone.put( attribute );
                    }
                    catch ( LdapException le )
                    {
                        throw new InvalidAttributesException( le.getMessage() );
                    }
                }
            }

            try
            {
                // Serialize object into entry attributes and add it.
                JavaLdapSupport.serialize( serverEntry, obj, getDirectoryService().getSchemaManager() );
               
                // setup the op context
                doAddOperation( target, clone );
            }
            catch ( Exception e )
            {
                JndiUtils.wrap( e );
            }
        }
        else if ( obj instanceof DirContext )
        {
            // Grab attributes and merge with outAttrs
            ServerEntry entry = null;
           
            try
            {
                entry = ServerEntryUtils.toServerEntry( ( ( DirContext ) obj ).getAttributes( "" ), target,
                    getDirectoryService().getSchemaManager() );
            }
            catch ( LdapInvalidAttributeTypeException liate )
            {
                throw new InvalidAttributeIdentifierException( liate.getMessage() );
            }

            if ( ( outServerEntry != null ) && ( outServerEntry.size() > 0 ) )
            {
                for ( EntryAttribute attribute : outServerEntry )
                {
                    try
                    {
                        entry.put( attribute );
                    }
                    catch ( LdapException le )
                    {
                        throw new InvalidAttributeValueException( le.getMessage() );
                    }
View Full Code Here

        }

        // Add the new context to the server which as a side effect adds
        try
        {
            ServerEntry serverEntry = ServerEntryUtils.toServerEntry( attributes,
                target, getDirectoryService().getSchemaManager() );
            doAddOperation( target, serverEntry );
        }
        catch ( Exception e )
        {
View Full Code Here

                   
                    cursor.beforeFirst();
                    if ( cursor.next() ) // there should be only one!
                    {
                        log.debug( "Class {} found under {} search context.", name, base );
                        ServerEntry classEntry = cursor.get();

                        if ( cursor.next() )
                        {
                            ServerEntry other = cursor.get();
                            log.warn( "More than one class found on classpath at locations: {} \n\tand {}",
                                classEntry, other );
                        }

                        return classEntry.get( "javaClassByteCode" ).getBytes();
View Full Code Here

            // TODO we should cache this information and register with the event
            // service to get notified if this changes so we can update the cached
            // copy - there's absolutely no reason why we should be performing this
            // lookup every time!!!
           
            ServerEntry configEntry = null;
           
            try
            {
                configEntry = directoryService.getAdminSession().lookup( defaultSearchDn );
            }
            catch ( LdapException e )
            {
                log.debug( "No configuration data found for class loader default search contexts." );
            }
           
            if ( configEntry != null )
            {
                List<DN> searchContexts = new ArrayList<DN>();
                EntryAttribute attr = configEntry.get( "classLoaderDefaultSearchContext" );
               
                for ( Value<?> val : attr )
                {
                    DN dn = new DN( val.getString() );
                    dn.normalize( directoryService.getSchemaManager().getNormalizerMapping() );
View Full Code Here

    }
   
   
    public ServerEntry getAttributes( Schema schema, SchemaManager schemaManager ) throws LdapException
    {
        ServerEntry entry = new DefaultServerEntry( schemaManager );

        entry.put( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, MetaSchemaConstants.META_SCHEMA_OC );
        entry.put( SchemaConstants.CN_AT, schema.getSchemaName() );
        entry.put( SchemaConstants.CREATORS_NAME_AT, schema.getOwner() );
        entry.put( SchemaConstants.CREATE_TIMESTAMP_AT, DateUtils.getGeneralizedTime() );
       
        if ( schema.isDisabled() )
        {
            entry.put( MetaSchemaConstants.M_DISABLED_AT, "TRUE" );
        }
       
        String[] dependencies = schema.getDependencies();
       
        if ( dependencies != null && dependencies.length > 0 )
        {
            EntryAttribute attr = new DefaultServerAttribute( schemaManager.lookupAttributeTypeRegistry( MetaSchemaConstants.M_DEPENDENCIES_AT ) );
           
            for ( String dependency:dependencies )
            {
                attr.add( dependency );
            }
           
            entry.put( attr );
        }
       
        return entry;
    }
View Full Code Here

    }
   
   
    public ServerEntry getAttributes( SyntaxChecker syntaxChecker, Schema schema, SchemaManager schemaManager )
    {
        ServerEntry entry = new DefaultServerEntry( schemaManager );

        entry.put( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, MetaSchemaConstants.META_SYNTAX_CHECKER_OC );
        entry.put( MetaSchemaConstants.M_OID_AT, syntaxChecker.getOid() );
        entry.put( MetaSchemaConstants.M_FQCN_AT, syntaxChecker.getClass().getName() );
        entry.put( SchemaConstants.CREATORS_NAME_AT, schema.getOwner() );
        entry.put( SchemaConstants.CREATE_TIMESTAMP_AT, DateUtils.getGeneralizedTime() );
       
        return entry;
    }
View Full Code Here

    }

   
    public ServerEntry getAttributes( LdapSyntax syntax, Schema schema, SchemaManager schemaManager ) throws LdapException
    {
        ServerEntry entry = new DefaultServerEntry( schemaManager );

        entry.put( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, MetaSchemaConstants.META_SYNTAX_OC );
        entry.put( MetaSchemaConstants.X_HUMAN_READABLE_AT, getBoolean( syntax.isHumanReadable() ) );
        entry.put( SchemaConstants.CREATORS_NAME_AT, schema.getOwner() );
        entry.put( SchemaConstants.CREATE_TIMESTAMP_AT, DateUtils.getGeneralizedTime() );
        injectCommon( syntax, entry, schemaManager );
       
        return entry;
    }
View Full Code Here

    }

   
    public ServerEntry getAttributes( String oid, Normalizer normalizer, Schema schema, SchemaManager schemaManager )
    {
        ServerEntry entry = new DefaultServerEntry( schemaManager );

        entry.put( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, MetaSchemaConstants.META_NORMALIZER_OC );
        entry.put( MetaSchemaConstants.M_OID_AT, oid );
        entry.put( MetaSchemaConstants.M_FQCN_AT, normalizer.getClass().getName() );
        entry.put( SchemaConstants.CREATORS_NAME_AT, schema.getOwner() );
        entry.put( SchemaConstants.CREATE_TIMESTAMP_AT, DateUtils.getGeneralizedTime() );
        return entry;
    }
View Full Code Here

TOP

Related Classes of org.apache.directory.shared.ldap.entry.ServerEntry

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.