Package org.apache.directory.api.ldap.model.schema

Examples of org.apache.directory.api.ldap.model.schema.MutableObjectClass


            try
            {
                if ( attributeName.equalsIgnoreCase( SchemaConstants.OBJECT_CLASSES_AT ) )
                {
                    MutableObjectClass ocd = ocdPparser.parseObjectClassDescription( value );
                    ocd.addExtension( RAW_SCHEMA_DEFINITION_LDIF_VALUE, ldifValues );
                    addObjectClass( ocd );
                }
                else if ( attributeName.equalsIgnoreCase( SchemaConstants.ATTRIBUTE_TYPES_AT ) )
                {
                    AttributeType atd = atdParser.parseAttributeTypeDescription( value );
                    atd.addExtension( RAW_SCHEMA_DEFINITION_LDIF_VALUE, ldifValues );
                    addAttributeType( atd );
                }
                else if ( attributeName.equalsIgnoreCase( SchemaConstants.LDAP_SYNTAXES_AT ) )
                {
                    LdapSyntax lsd = lsdParser.parseLdapSyntaxDescription( value );
                    if ( StringUtils.isEmpty( lsd.getDescription() )
                        && Utils.getOidDescription( lsd.getOid() ) != null )
                    {
                        lsd.setDescription( Utils.getOidDescription( lsd.getOid() ) );
                    }
                    lsd.addExtension( RAW_SCHEMA_DEFINITION_LDIF_VALUE, ldifValues );
                    addLdapSyntax( lsd );
                }
                else if ( attributeName.equalsIgnoreCase( SchemaConstants.MATCHING_RULES_AT ) )
                {
                    MatchingRule mrd = mrdParser.parseMatchingRuleDescription( value );
                    mrd.addExtension( RAW_SCHEMA_DEFINITION_LDIF_VALUE, ldifValues );
                    addMatchingRule( mrd );
                }
                else if ( attributeName.equalsIgnoreCase( SchemaConstants.MATCHING_RULE_USE_AT ) )
                {
                    MatchingRuleUse mrud = mrudParser.parseMatchingRuleUseDescription( value );
                    mrud.addExtension( RAW_SCHEMA_DEFINITION_LDIF_VALUE, ldifValues );
                    addMatchingRuleUse( mrud );
                }
                else if ( attributeName.equalsIgnoreCase( SchemaConstants.CREATE_TIMESTAMP_AT ) )
                {
                    setCreateTimestamp( value );
                }
                else if ( attributeName.equalsIgnoreCase( SchemaConstants.MODIFY_TIMESTAMP_AT ) )
                {
                    setModifyTimestamp( value );
                }
            }
            catch ( Exception e )
            {
                // TODO: exception handling
                System.out.println( "Error reading schema: " + attributeName + " = " + value ); //$NON-NLS-1$ //$NON-NLS-2$
                System.out.println( e.getMessage() );
            }
        }

        for ( AttributeType atd : getAttributeTypeDescriptions() )
        {
            // assume all received syntaxes in attributes are valid -> create pseudo syntaxes if missing
            String syntaxOid = atd.getSyntaxOid();
            if ( syntaxOid != null && !hasLdapSyntaxDescription( syntaxOid ) )
            {
                LdapSyntax lsd = new LdapSyntax( syntaxOid );
                lsd.setDescription( Utils.getOidDescription( syntaxOid ) );
                addLdapSyntax( lsd );
            }

            // assume all received matching rules in attributes are valid -> create pseudo matching rules if missing
            String emr = atd.getEqualityOid();
            String omr = atd.getOrderingOid();
            String smr = atd.getSubstringOid();
            checkMatchingRules( emr, omr, smr );
        }

        // set extensibleObject may attributes
        MutableObjectClass extensibleObjectOcd = this
            .getObjectClassDescription( SchemaConstants.EXTENSIBLE_OBJECT_OC );
        Collection<AttributeType> userAtds = SchemaUtils.getUserAttributeDescriptions( this );
        Collection<String> atdNames = SchemaUtils.getNames( userAtds );
        List<String> atdNames2 = new ArrayList<String>( atdNames );
        extensibleObjectOcd.setMayAttributeTypeOids( atdNames2 );
    }
View Full Code Here


        else
        {
            // DUMMY
            List<String> names = new ArrayList<String>();
            names.add( nameOrOid );
            MutableObjectClass ocd = new MutableObjectClass( nameOrOid );
            ocd.setNames( names );
            ocd.setExtensions( DUMMY_EXTENSIONS );
            return ocd;
        }
    }
View Full Code Here

                    }
                }
                // OBJECT CLASS
                else if ( selectedElement instanceof ObjectClassWrapper )
                {
                    MutableObjectClass objectClass = ( ( ObjectClassWrapper ) selectedElement ).getObjectClass();

                    RenameObjectClassDialog dialog = new RenameObjectClassDialog( objectClass.getNames() );
                    if ( dialog.open() == RenameObjectClassDialog.OK )
                    {
                        ObjectClass modifiedObjectClass = PluginUtils.getClone( objectClass );
                        modifiedObjectClass.setNames( dialog.getAliases() );
                        Activator.getDefault().getSchemaHandler()
View Full Code Here

    {
        List<TreeNode> children = new ArrayList<TreeNode>();

        if ( parentElement instanceof ObjectClass )
        {
            MutableObjectClass oc = ( MutableObjectClass ) parentElement;

            children = createTypeHierarchyObjectClass( oc );
        }
        else if ( parentElement instanceof AttributeType )
        {
View Full Code Here

        {
            for ( Object parent : parents )
            {
                if ( parent instanceof ObjectClass )
                {
                    MutableObjectClass parentOC = ( MutableObjectClass ) parent;
                    ObjectClassWrapper duplicatedOCW = ( ObjectClassWrapper ) duplicateTreeNode( ocw );

                    ObjectClassWrapper ocw2 = new ObjectClassWrapper( parentOC );
                    duplicatedOCW.setParent( ocw2 );
                    ocw2.addChild( duplicatedOCW );
View Full Code Here

                    childNode = new AttributeTypeWrapper( at, node );
                    node.addChild( childNode );
                }
                else if ( child instanceof ObjectClass )
                {
                    MutableObjectClass oc = ( MutableObjectClass ) child;
                    childNode = new ObjectClassWrapper( oc, node );
                    node.addChild( childNode );
                }

                // Recursively creating the hierarchy for all children
View Full Code Here

     * {@inheritDoc}
     */
    public boolean performFinish()
    {
        // Creating the new object class
        MutableObjectClass newOC = new MutableObjectClass( generalPage.getOidValue() );
        newOC.setSchemaName( generalPage.getSchemaValue() );
        newOC.setNames( generalPage.getAliasesValue() );
        newOC.setDescription( generalPage.getDescriptionValue() );
        newOC.setSuperiorOids( contentPage.getSuperiorsNameValue() );
        newOC.setType( contentPage.getClassTypeValue() );
        newOC.setObsolete( contentPage.getObsoleteValue() );
        newOC.setMustAttributeTypeOids( mandatoryAttributesPage.getMandatoryAttributeTypesNames() );
        newOC.setMayAttributeTypeOids( optionalAttributesPage.getOptionalAttributeTypesNames() );

        // Adding the new object class
        Activator.getDefault().getSchemaHandler().addObjectClass( newOC );

        // Saving the Dialog Settings OID History
        PluginUtils.saveDialogSettingsHistory( PluginConstants.DIALOG_SETTINGS_OID_HISTORY, newOC.getOid() );

        return true;
    }
View Full Code Here

                {
                    targetSchema.removeObjectClass( oc );
                }

                // create object class
                MutableObjectClass clonedObjectClass = new MutableObjectClass( sourceObjectClass.getOid() );
                clonedObjectClass.setOid( sourceObjectClass.getOid() );
                clonedObjectClass.setNames( sourceObjectClass.getNames() );
                clonedObjectClass.setDescription( sourceObjectClass.getDescription() );
                clonedObjectClass.setSuperiorOids( sourceObjectClass.getSuperiorOids() );
                clonedObjectClass.setType( sourceObjectClass.getType() );
                clonedObjectClass.setObsolete( sourceObjectClass.isObsolete() );
                clonedObjectClass.setMustAttributeTypeOids( sourceObjectClass.getMustAttributeTypeOids() );
                clonedObjectClass.setMayAttributeTypeOids( sourceObjectClass.getMayAttributeTypeOids() );
                clonedObjectClass.setSchemaName( targetSchema.getSchemaName() );

                // merge dependencies: super object classes and must/may attributes
                if ( mergeDependencies )
                {
                    List<String> superClassesNames = clonedObjectClass.getSuperiorOids();
                    if ( superClassesNames != null )
                    {
                        for ( String superClassName : superClassesNames )
                        {
                            if ( superClassName != null )
                            {
                                ObjectClass superSourceObjectClass = Activator.getDefault().getSchemaHandler()
                                    .getObjectClass( superClassName );
                                ObjectClass superTargetObjectClass = targetProject.getSchemaHandler()
                                    .getObjectClass( superClassName );
                                if ( superSourceObjectClass != null )
                                {
                                    if ( superTargetObjectClass == null )
                                    {
                                        mergeObjectClass( superSourceObjectClass, targetProject, targetSchema,
                                            processedObjects, errorMessages, replaceUnknownSyntax, mergeDependencies,
                                            pullUpAttributes );
                                    }
                                    else
                                    {
                                        // pull-up may and must attributes to this OC if super already exists in target
                                        if ( pullUpAttributes )
                                        {
                                            pullUpAttributes( clonedObjectClass, superSourceObjectClass,
                                                superTargetObjectClass );
                                        }
                                    }
                                }
                            }
                        }
                    }

                    List<String> mustNamesList = clonedObjectClass.getMustAttributeTypeOids();
                    List<String> mayNamesList = clonedObjectClass.getMayAttributeTypeOids();
                    List<String> attributeNames = new ArrayList<String>();
                    if ( mustNamesList != null )
                    {
                        attributeNames.addAll( mustNamesList );
                    }
View Full Code Here

        }

        List<?> ocs = parser.getObjectClassTypes();
        for ( int i = 0; i < ocs.size(); i++ )
        {
            MutableObjectClass oc = convertObjectClass( ( ObjectClass ) ocs.get( i ) );
            oc.setSchemaName( schemaName );
            schema.addObjectClass( oc );
        }

        return schema;
    }
View Full Code Here

     * @return
     *      the corresponding ObjectClassImpl
     */
    private static final MutableObjectClass convertObjectClass( ObjectClass oc )
    {
        MutableObjectClass newOC = new MutableObjectClass( oc.getOid() );
        newOC.setNames( oc.getNames() );
        newOC.setDescription( oc.getDescription() );
        newOC.setSuperiorOids( oc.getSuperiorOids() );
        newOC.setType( oc.getType() );
        newOC.setObsolete( oc.isObsolete() );
        newOC.setMustAttributeTypeOids( oc.getMustAttributeTypeOids() );
        newOC.setMayAttributeTypeOids( oc.getMayAttributeTypeOids() );

        return newOC;
    }
View Full Code Here

TOP

Related Classes of org.apache.directory.api.ldap.model.schema.MutableObjectClass

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.