directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r758668 - in /directory/sandbox/seelmann/trunk: ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/ ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/ ldapbrowser-co...
Date Thu, 26 Mar 2009 14:43:20 GMT
Author: seelmann
Date: Thu Mar 26 14:42:36 2009
New Revision: 758668

URL: http://svn.apache.org/viewvc?rev=758668&view=rev
Log:
Fix for DIRSTUDIO-479 (Object classes of an entry should always be present)

Removed:
    directory/sandbox/seelmann/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/schema/Subschema.java
Modified:
    directory/sandbox/seelmann/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/DeleteAction.java
    directory/sandbox/seelmann/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/RenameEntryDialog.java
    directory/sandbox/seelmann/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/OpenBestEditorAction.java
    directory/sandbox/seelmann/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/AttributeTypeWizardPage.java
    directory/sandbox/seelmann/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/NewEntryAttributesWizardPage.java
    directory/sandbox/seelmann/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/NewEntryDnWizardPage.java
    directory/sandbox/seelmann/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/SearchRunnable.java
    directory/sandbox/seelmann/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/IEntry.java
    directory/sandbox/seelmann/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/AbstractEntry.java
    directory/sandbox/seelmann/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/Attribute.java
    directory/sandbox/seelmann/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/AttributeInfo.java
    directory/sandbox/seelmann/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/DelegateEntry.java
    directory/sandbox/seelmann/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/DummyEntry.java
    directory/sandbox/seelmann/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/schema/SchemaUtils.java
    directory/sandbox/seelmann/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/OpenBestEditorAction.java

Modified: directory/sandbox/seelmann/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/DeleteAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/DeleteAction.java?rev=758668&r1=758667&r2=758668&view=diff
==============================================================================
--- directory/sandbox/seelmann/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/DeleteAction.java (original)
+++ directory/sandbox/seelmann/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/actions/DeleteAction.java Thu Mar 26 14:42:36 2009
@@ -466,7 +466,7 @@
     protected void appendValuesWarnMessage( StringBuffer message, Collection<IValue> values )
     {
         Map<AttributeTypeDescription, Integer> attributeNameToSelectedValuesCountMap = new HashMap<AttributeTypeDescription, Integer>();
-        Set<String> selectedObjectClasses = new HashSet<String>();
+        Set<ObjectClassDescription> selectedObjectClasses = new HashSet<ObjectClassDescription>();
         for ( IValue value : values )
         {
             String type = value.getAttribute().getType();
@@ -490,7 +490,8 @@
             // check if a required objectClass is selected
             if ( value.getAttribute().isObjectClassAttribute() )
             {
-                selectedObjectClasses.add( value.getStringValue() );
+                selectedObjectClasses.add( value.getAttribute().getEntry().getBrowserConnection().getSchema()
+                    .getObjectClassDescription( value.getStringValue() ) );
             }
 
             // check if ALL values of objectClass or a MUST attribute are selected
@@ -530,14 +531,11 @@
             IEntry entry = values.iterator().next().getAttribute().getEntry();
             Schema schema = entry.getBrowserConnection().getSchema();
             // get remaining attributes
-            String[] ocValues = entry.getSubschema().getObjectClassNames();
-            Set<String> remainingObjectClassesSet = new HashSet<String>( Arrays.asList( ocValues ) );
-            remainingObjectClassesSet.removeAll( selectedObjectClasses );
+            Collection<ObjectClassDescription> remainingObjectClasses = entry.getObjectClassDescriptions();
+            remainingObjectClasses.removeAll( selectedObjectClasses );
             Set<AttributeTypeDescription> remainingAttributeSet = new HashSet<AttributeTypeDescription>();
-            for ( String oc : remainingObjectClassesSet )
+            for ( ObjectClassDescription ocd : remainingObjectClasses )
             {
-                ObjectClassDescription ocd = schema.getObjectClassDescription( oc );
-                if ( ocd != null )
                 {
                     Collection<String> mustAttrs = SchemaUtils.getMustAttributeTypeDescriptionNamesTransitive( ocd,
                         schema );

Modified: directory/sandbox/seelmann/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/RenameEntryDialog.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/RenameEntryDialog.java?rev=758668&r1=758667&r2=758668&view=diff
==============================================================================
--- directory/sandbox/seelmann/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/RenameEntryDialog.java (original)
+++ directory/sandbox/seelmann/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/dialogs/RenameEntryDialog.java Thu Mar 26 14:42:36 2009
@@ -21,13 +21,18 @@
 package org.apache.directory.studio.ldapbrowser.common.dialogs;
 
 
+import java.util.Collection;
+
+import org.apache.commons.lang.ArrayUtils;
 import org.apache.directory.shared.ldap.name.Rdn;
+import org.apache.directory.shared.ldap.schema.parsers.AttributeTypeDescription;
 import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator;
 import org.apache.directory.studio.connection.ui.widgets.BaseWidgetUtils;
 import org.apache.directory.studio.ldapbrowser.common.widgets.DnBuilderWidget;
 import org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyEvent;
 import org.apache.directory.studio.ldapbrowser.common.widgets.WidgetModifyListener;
 import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
+import org.apache.directory.studio.ldapbrowser.core.model.schema.SchemaUtils;
 import org.eclipse.jface.dialogs.Dialog;
 import org.eclipse.jface.dialogs.IDialogConstants;
 import org.eclipse.swt.SWT;
@@ -142,7 +147,9 @@
         dnBuilderWidget = new DnBuilderWidget( true, false );
         dnBuilderWidget.addWidgetModifyListener( this );
         dnBuilderWidget.createContents( composite );
-        dnBuilderWidget.setInput( entry.getBrowserConnection(), entry.getSubschema().getAllAttributeNames(), entry
+        Collection<AttributeTypeDescription> allAtds = SchemaUtils.getAllAttributeTypeDescriptions( entry );
+        String[] allAttributeNames = SchemaUtils.getNames( allAtds ).toArray( ArrayUtils.EMPTY_STRING_ARRAY );
+        dnBuilderWidget.setInput( entry.getBrowserConnection(), allAttributeNames, entry
             .getRdn(), null );
 
         applyDialogFont( composite );

Modified: directory/sandbox/seelmann/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/OpenBestEditorAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/OpenBestEditorAction.java?rev=758668&r1=758667&r2=758668&view=diff
==============================================================================
--- directory/sandbox/seelmann/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/OpenBestEditorAction.java (original)
+++ directory/sandbox/seelmann/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/entryeditor/OpenBestEditorAction.java Thu Mar 26 14:42:36 2009
@@ -21,13 +21,13 @@
 package org.apache.directory.studio.ldapbrowser.common.widgets.entryeditor;
 
 
-import java.util.Set;
+import java.util.Collection;
 
 import org.apache.directory.shared.ldap.schema.parsers.AttributeTypeDescription;
 import org.apache.directory.studio.ldapbrowser.core.BrowserCoreConstants;
+import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
 import org.apache.directory.studio.ldapbrowser.core.model.IValue;
 import org.apache.directory.studio.ldapbrowser.core.model.schema.SchemaUtils;
-import org.apache.directory.studio.ldapbrowser.core.model.schema.Subschema;
 import org.apache.directory.studio.valueeditors.IValueEditor;
 import org.apache.directory.studio.valueeditors.ValueEditorManager;
 import org.eclipse.jface.dialogs.MessageDialog;
@@ -157,8 +157,8 @@
                 }
 
                 // validate if value is allowed
-                Subschema subschema = value.getAttribute().getEntry().getSubschema();
-                Set<AttributeTypeDescription> allAtds = subschema.getAllAttributeTypeDescriptions();
+                IEntry entry = value.getAttribute().getEntry();
+                Collection<AttributeTypeDescription> allAtds = SchemaUtils.getAllAttributeTypeDescriptions( entry );
                 AttributeTypeDescription atd = value.getAttribute().getAttributeTypeDescription();
                 if ( !allAtds.contains( atd ) )
                 {

Modified: directory/sandbox/seelmann/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/AttributeTypeWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/AttributeTypeWizardPage.java?rev=758668&r1=758667&r2=758668&view=diff
==============================================================================
--- directory/sandbox/seelmann/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/AttributeTypeWizardPage.java (original)
+++ directory/sandbox/seelmann/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/AttributeTypeWizardPage.java Thu Mar 26 14:42:36 2009
@@ -121,10 +121,13 @@
         Collection<String> atdNames = SchemaUtils.getNames( atds );
         possibleAttributeTypes = atdNames.toArray( new String[atdNames.size()] );
         Arrays.sort( possibleAttributeTypes );
-        possibleAttributeTypesSubschemaOnly = initialEntry.getSubschema().getAllAttributeNames();
+        
+        Collection<AttributeTypeDescription> allAtds = SchemaUtils.getAllAttributeTypeDescriptions( initialEntry );
+        Collection<String> names = SchemaUtils.getNames( allAtds );
+        possibleAttributeTypesSubschemaOnly  = names.toArray(new String[0]);
         Arrays.sort( possibleAttributeTypesSubschemaOnly );
 
-        Set<String> set = new HashSet<String>( Arrays.asList( initialEntry.getSubschema().getAllAttributeNames() ) );
+        Set<String> set = new HashSet<String>( Arrays.asList( possibleAttributeTypesSubschemaOnly ) );
         IAttribute[] existingAttributes = initialEntry.getAttributes();
         for ( int i = 0; existingAttributes != null && i < existingAttributes.length; i++ )
         {

Modified: directory/sandbox/seelmann/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/NewEntryAttributesWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/NewEntryAttributesWizardPage.java?rev=758668&r1=758667&r2=758668&view=diff
==============================================================================
--- directory/sandbox/seelmann/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/NewEntryAttributesWizardPage.java (original)
+++ directory/sandbox/seelmann/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/NewEntryAttributesWizardPage.java Thu Mar 26 14:42:36 2009
@@ -23,6 +23,7 @@
 
 import java.util.Collection;
 
+import org.apache.directory.shared.ldap.schema.parsers.AttributeTypeDescription;
 import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator;
 import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants;
 import org.apache.directory.studio.ldapbrowser.common.widgets.entryeditor.EntryEditorWidget;
@@ -185,10 +186,10 @@
                 // remove empty must attributes
                 // necessary when navigating back, modifying object classes
                 // and DN and navigation forward again.
-                String[] oldMust = newEntry.getSubschema().getMustAttributeNames();
-                for ( int i = 0; i < oldMust.length; i++ )
+                Collection<AttributeTypeDescription> oldMusts = SchemaUtils.getMustAttributeTypeDescriptions( newEntry );
+                for ( AttributeTypeDescription oldMust : oldMusts )
                 {
-                    IAttribute attribute = newEntry.getAttribute( oldMust[i] );
+                    IAttribute attribute = newEntry.getAttribute( oldMust.getNumericOid() );
                     if ( attribute != null )
                     {
                         IValue[] values = attribute.getValues();
@@ -207,12 +208,13 @@
                 }
 
                 // add must attributes
-                String[] newMust = newEntry.getSubschema().getMustAttributeNames();
-                for ( int i = 0; i < newMust.length; i++ )
+                Collection<AttributeTypeDescription> newMusts = SchemaUtils.getMustAttributeTypeDescriptions( newEntry );
+                for ( AttributeTypeDescription newMust : newMusts )
                 {
-                    if ( newEntry.getAttributeWithSubtypes( newMust[i] ) == null )
+                    if ( newEntry.getAttributeWithSubtypes( newMust.getNumericOid() ) == null )
                     {
-                        IAttribute att = new Attribute( newEntry, newMust[i] );
+                        String friendlyIdentifier = SchemaUtils.getFriendlyIdentifier( newMust );
+                        IAttribute att = new Attribute( newEntry, friendlyIdentifier );
                         newEntry.addAttribute( att );
                         att.addEmptyValue();
                     }

Modified: directory/sandbox/seelmann/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/NewEntryDnWizardPage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/NewEntryDnWizardPage.java?rev=758668&r1=758667&r2=758668&view=diff
==============================================================================
--- directory/sandbox/seelmann/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/NewEntryDnWizardPage.java (original)
+++ directory/sandbox/seelmann/trunk/ldapbrowser-common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/NewEntryDnWizardPage.java Thu Mar 26 14:42:36 2009
@@ -22,6 +22,7 @@
 
 
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.Iterator;
 
 import javax.naming.InvalidNameException;
@@ -31,6 +32,7 @@
 import org.apache.directory.shared.ldap.name.AttributeTypeAndValue;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.name.Rdn;
+import org.apache.directory.shared.ldap.schema.parsers.AttributeTypeDescription;
 import org.apache.directory.studio.connection.core.DnUtils;
 import org.apache.directory.studio.connection.ui.RunnableContextRunner;
 import org.apache.directory.studio.connection.ui.widgets.BaseWidgetUtils;
@@ -48,7 +50,7 @@
 import org.apache.directory.studio.ldapbrowser.core.model.impl.Attribute;
 import org.apache.directory.studio.ldapbrowser.core.model.impl.DummyEntry;
 import org.apache.directory.studio.ldapbrowser.core.model.impl.Value;
-import org.apache.directory.studio.ldapbrowser.core.model.schema.Subschema;
+import org.apache.directory.studio.ldapbrowser.core.model.schema.SchemaUtils;
 import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.jface.fieldassist.ComboContentAdapter;
 import org.eclipse.jface.fieldassist.ContentProposalAdapter;
@@ -180,8 +182,8 @@
         }
         else
         {
-            Subschema subschema = newEntry.getSubschema();
-            String[] attributeNames = subschema.getAllAttributeNames();
+            Collection<AttributeTypeDescription> atds = SchemaUtils.getAllAttributeTypeDescriptions( newEntry );
+            String[] attributeNames = SchemaUtils.getNames( atds ).toArray(ArrayUtils.EMPTY_STRING_ARRAY);
 
             LdapDN parentDn = null;
             if ( wizard.getSelectedEntry() != null && newEntry.getDn().equals( wizard.getSelectedEntry().getDn() )

Modified: directory/sandbox/seelmann/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/SearchRunnable.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/SearchRunnable.java?rev=758668&r1=758667&r2=758668&view=diff
==============================================================================
--- directory/sandbox/seelmann/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/SearchRunnable.java (original)
+++ directory/sandbox/seelmann/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/SearchRunnable.java Thu Mar 26 14:42:36 2009
@@ -673,6 +673,15 @@
             Attribute attribute = attributeEnumeration.next();
             String attributeDescription = attribute.getID();
             NamingEnumeration<?> valueEnumeration = attribute.getAll();
+            if ( SchemaConstants.OBJECT_CLASS_AT.equalsIgnoreCase( attributeDescription ) )
+            {
+                if ( entry.getAttribute( attributeDescription ) != null )
+                {
+                    entry.deleteAttribute( entry.getAttribute( attributeDescription ) );
+                }
+                entry.addAttribute( new org.apache.directory.studio.ldapbrowser.core.model.impl.Attribute( entry,
+                    attributeDescription ) );
+            }
             while ( valueEnumeration.hasMore() )
             {
                 Object o = valueEnumeration.next();
@@ -716,6 +725,10 @@
                             entry.setReferral( true );
                             entry.setHasChildrenHint( false );
                         }
+                        
+                        IAttribute ocAttribute = entry.getAttribute( attributeDescription );
+                        Value ocValue = new Value( ocAttribute, value );
+                        ocAttribute.addValue( ocValue );
                     }
                 }
             }

Modified: directory/sandbox/seelmann/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/IEntry.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/IEntry.java?rev=758668&r1=758667&r2=758668&view=diff
==============================================================================
--- directory/sandbox/seelmann/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/IEntry.java (original)
+++ directory/sandbox/seelmann/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/IEntry.java Thu Mar 26 14:42:36 2009
@@ -22,13 +22,14 @@
 
 
 import java.io.Serializable;
+import java.util.Collection;
 
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.name.Rdn;
+import org.apache.directory.shared.ldap.schema.parsers.ObjectClassDescription;
 import org.apache.directory.shared.ldap.util.LdapURL;
 import org.apache.directory.studio.connection.core.ConnectionPropertyPageProvider;
 import org.apache.directory.studio.connection.core.jobs.StudioBulkRunnableWithProgress;
-import org.apache.directory.studio.ldapbrowser.core.model.schema.Subschema;
 import org.apache.directory.studio.ldapbrowser.core.propertypageproviders.EntryPropertyPageProvider;
 import org.eclipse.core.runtime.IAdaptable;
 
@@ -270,15 +271,6 @@
 
 
     /**
-     * Returns the subschema of the entry.
-     * 
-     * @return The subschema of the entry or null if the attributes aren't
-     *         initialized
-     */
-    public abstract Subschema getSubschema();
-
-
-    /**
      * Indicates whether the entry's children are initialized.
      * 
      * True means that the entry's children are completely initialized
@@ -368,16 +360,16 @@
      * @param moreChildrenRunnable the runnable used to fetch the top page of children
      */
     public abstract void setTopPageChildrenRunnable( StudioBulkRunnableWithProgress topPageChildrenRunnable );
-    
-    
+
+
     /**
      * Gets the runnable used to fetch the next page of children.
      * 
      * @return the runnable used to fetch the next page of children, null if none
      */
     public abstract StudioBulkRunnableWithProgress getNextPageChildrenRunnable();
-    
-    
+
+
     /**
      * Sets the runnable used to fetch the next page of children.
      * 
@@ -434,4 +426,12 @@
      */
     public abstract LdapURL getUrl();
 
+
+    /**
+     * Gets the object class descriptions of this entry.
+     * 
+     * @return the object class descriptions of this entry
+     */
+    public Collection<ObjectClassDescription> getObjectClassDescriptions();
+
 }

Modified: directory/sandbox/seelmann/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/AbstractEntry.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/AbstractEntry.java?rev=758668&r1=758667&r2=758668&view=diff
==============================================================================
--- directory/sandbox/seelmann/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/AbstractEntry.java (original)
+++ directory/sandbox/seelmann/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/AbstractEntry.java Thu Mar 26 14:42:36 2009
@@ -22,14 +22,14 @@
 
 
 import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
+import java.util.Collection;
+import java.util.HashSet;
 import java.util.LinkedHashSet;
 import java.util.List;
-import java.util.Map;
 
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.name.Rdn;
+import org.apache.directory.shared.ldap.schema.parsers.ObjectClassDescription;
 import org.apache.directory.shared.ldap.util.LdapURL;
 import org.apache.directory.studio.connection.core.Connection;
 import org.apache.directory.studio.connection.core.jobs.StudioBulkRunnableWithProgress;
@@ -48,7 +48,7 @@
 import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
 import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
 import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
-import org.apache.directory.studio.ldapbrowser.core.model.schema.Subschema;
+import org.apache.directory.studio.ldapbrowser.core.model.schema.Schema;
 import org.apache.directory.studio.ldapbrowser.core.utils.Utils;
 import org.eclipse.search.ui.ISearchPageScoreComputer;
 
@@ -79,6 +79,8 @@
 
     private volatile int flags;
 
+    protected IAttribute objectClassAttribute;
+
 
     /**
      * Creates a new instance of AbstractEntry.
@@ -150,27 +152,40 @@
      */
     public void addAttribute( IAttribute attributeToAdd ) throws IllegalArgumentException
     {
-        String oidString = attributeToAdd.getAttributeDescription().toOidString( getBrowserConnection().getSchema() );
-        AttributeInfo ai = getBrowserConnectionImpl().getAttributeInfo( this );
-        if ( ai == null )
-        {
-            ai = new AttributeInfo();
-            getBrowserConnectionImpl().setAttributeInfo( this, ai );
-        }
-
         if ( !equals( attributeToAdd.getEntry() ) )
         {
             throw new IllegalArgumentException( BrowserCoreMessages.model__attributes_entry_is_not_myself );
         }
-        else if ( ai.attributeMap.containsKey( oidString.toLowerCase() ) )
+
+        if ( attributeToAdd.isObjectClassAttribute() )
         {
-            throw new IllegalArgumentException( BrowserCoreMessages.model__attribute_already_exists );
+            if ( objectClassAttribute != null )
+            {
+                throw new IllegalArgumentException( BrowserCoreMessages.model__attribute_already_exists );
+            }
+
+            objectClassAttribute = attributeToAdd;
         }
         else
         {
+            String oidString = attributeToAdd.getAttributeDescription()
+                .toOidString( getBrowserConnection().getSchema() );
+            AttributeInfo ai = getBrowserConnectionImpl().getAttributeInfo( this );
+            if ( ai == null )
+            {
+                ai = new AttributeInfo();
+                getBrowserConnectionImpl().setAttributeInfo( this, ai );
+            }
+
+            if ( ai.attributeMap.containsKey( oidString.toLowerCase() ) )
+            {
+                throw new IllegalArgumentException( BrowserCoreMessages.model__attribute_already_exists );
+            }
+
             ai.attributeMap.put( oidString.toLowerCase(), attributeToAdd );
-            entryModified( new AttributeAddedEvent( getBrowserConnectionImpl(), this, attributeToAdd ) );
         }
+
+        entryModified( new AttributeAddedEvent( getBrowserConnectionImpl(), this, attributeToAdd ) );
     }
 
 
@@ -179,23 +194,38 @@
      */
     public void deleteAttribute( IAttribute attributeToDelete ) throws IllegalArgumentException
     {
-        String oidString = attributeToDelete.getAttributeDescription().toOidString( getBrowserConnection().getSchema() );
-        AttributeInfo ai = getBrowserConnectionImpl().getAttributeInfo( this );
-        if ( ai != null && ai.attributeMap != null && ai.attributeMap.containsKey( oidString.toLowerCase() ) )
+        if ( attributeToDelete.isObjectClassAttribute() )
         {
-            IAttribute attribute = ( IAttribute ) ai.attributeMap.get( oidString.toLowerCase() );
-            ai.attributeMap.remove( oidString.toLowerCase() );
-            if ( ai.attributeMap.isEmpty() )
+            if ( objectClassAttribute == null )
             {
-                getBrowserConnectionImpl().setAttributeInfo( this, null );
+                throw new IllegalArgumentException( BrowserCoreMessages.model__attribute_does_not_exist + ": "
+                    + attributeToDelete );
             }
-            entryModified( new AttributeDeletedEvent( getBrowserConnectionImpl(), this, attribute ) );
+
+            objectClassAttribute = null;
         }
         else
         {
-            throw new IllegalArgumentException( BrowserCoreMessages.model__attribute_does_not_exist + ": "
-                + attributeToDelete );
+            String oidString = attributeToDelete.getAttributeDescription().toOidString(
+                getBrowserConnection().getSchema() );
+            AttributeInfo ai = getBrowserConnectionImpl().getAttributeInfo( this );
+            if ( ai != null && ai.attributeMap != null && ai.attributeMap.containsKey( oidString.toLowerCase() ) )
+            {
+                attributeToDelete = ( IAttribute ) ai.attributeMap.get( oidString.toLowerCase() );
+                ai.attributeMap.remove( oidString.toLowerCase() );
+                if ( ai.attributeMap.isEmpty() )
+                {
+                    getBrowserConnectionImpl().setAttributeInfo( this, null );
+                }
+            }
+            else
+            {
+                throw new IllegalArgumentException( BrowserCoreMessages.model__attribute_does_not_exist + ": "
+                    + attributeToDelete );
+            }
         }
+
+        entryModified( new AttributeDeletedEvent( getBrowserConnectionImpl(), this, attributeToDelete ) );
     }
 
 
@@ -237,7 +267,8 @@
         AttributeInfo ai = getBrowserConnectionImpl().getAttributeInfo( this );
         if ( ai != null )
         {
-            return Arrays.asList( getSubschema().getObjectClassNames() ).contains( SchemaConstants.ALIAS_OC );
+            return getObjectClassDescriptions().contains(
+                getBrowserConnection().getSchema().getObjectClassDescription( SchemaConstants.ALIAS_OC ) );
         }
 
         return false;
@@ -273,7 +304,8 @@
         AttributeInfo ai = getBrowserConnectionImpl().getAttributeInfo( this );
         if ( ai != null )
         {
-            return Arrays.asList( getSubschema().getObjectClassNames() ).contains( SchemaConstants.REFERRAL_OC );
+            return getObjectClassDescriptions().contains(
+                getBrowserConnection().getSchema().getObjectClassDescription( SchemaConstants.REFERRAL_OC ) );
         }
 
         return false;
@@ -309,7 +341,8 @@
         AttributeInfo ai = getBrowserConnectionImpl().getAttributeInfo( this );
         if ( ai != null )
         {
-            return Arrays.asList( getSubschema().getObjectClassNames() ).contains( SchemaConstants.SUBENTRY_OC );
+            return getObjectClassDescriptions().contains(
+                getBrowserConnection().getSchema().getObjectClassDescription( SchemaConstants.SUBENTRY_OC ) );
         }
 
         return false;
@@ -424,15 +457,19 @@
      */
     public IAttribute[] getAttributes()
     {
+        Collection<IAttribute> attributes = new HashSet<IAttribute>();
+
         AttributeInfo ai = getBrowserConnectionImpl().getAttributeInfo( this );
-        if ( ai == null || ai.attributeMap == null )
+        if ( ai != null && ai.attributeMap != null )
         {
-            return null;
+            attributes.addAll( ai.attributeMap.values() );
         }
-        else
+        if ( objectClassAttribute != null )
         {
-            return ( IAttribute[] ) ai.attributeMap.values().toArray( new IAttribute[0] );
+            attributes.add( objectClassAttribute );
         }
+
+        return attributes.toArray( new IAttribute[0] );
     }
 
 
@@ -441,16 +478,23 @@
      */
     public IAttribute getAttribute( String attributeDescription )
     {
-        AttributeInfo ai = getBrowserConnectionImpl().getAttributeInfo( this );
-        if ( ai == null || ai.attributeMap == null )
+        AttributeDescription ad = new AttributeDescription( attributeDescription );
+        String oidString = ad.toOidString( getBrowserConnection().getSchema() );
+        if ( oidString.equals( SchemaConstants.OBJECT_CLASS_AT_OID ) )
         {
-            return null;
+            return objectClassAttribute;
         }
         else
         {
-            AttributeDescription ad = new AttributeDescription( attributeDescription );
-            String oidString = ad.toOidString( getBrowserConnection().getSchema() );
-            return ( IAttribute ) ai.attributeMap.get( oidString.toLowerCase() );
+            AttributeInfo ai = getBrowserConnectionImpl().getAttributeInfo( this );
+            if ( ai == null || ai.attributeMap == null )
+            {
+                return null;
+            }
+            else
+            {
+                return ( IAttribute ) ai.attributeMap.get( oidString.toLowerCase() );
+            }
         }
     }
 
@@ -460,64 +504,35 @@
      */
     public AttributeHierarchy getAttributeWithSubtypes( String attributeDescription )
     {
-        AttributeInfo ai = getBrowserConnectionImpl().getAttributeInfo( this );
-        if ( ai == null || ai.attributeMap == null )
+        List<IAttribute> attributeList = new ArrayList<IAttribute>();
+
+        IAttribute myAttribute = getAttribute( attributeDescription );
+        if ( myAttribute != null )
         {
-            return null;
+            attributeList.add( myAttribute );
         }
-        else
-        {
-            List<IAttribute> attributeList = new ArrayList<IAttribute>();
-
-            IAttribute myAttribute = getAttribute( attributeDescription );
-            if ( myAttribute != null )
-            {
-                attributeList.add( myAttribute );
-            }
-
-            AttributeDescription ad = new AttributeDescription( attributeDescription );
-            Map<String, IAttribute> clonedAttributeMap = new HashMap<String, IAttribute>( ai.attributeMap );
-            for ( IAttribute attribute : clonedAttributeMap.values() )
-            {
-                AttributeDescription other = attribute.getAttributeDescription();
-                if ( other.isSubtypeOf( ad, getBrowserConnection().getSchema() ) )
-                {
-                    attributeList.add( attribute );
-                }
-            }
 
-            if ( attributeList.isEmpty() )
-            {
-                return null;
-            }
-            else
+        AttributeDescription ad = new AttributeDescription( attributeDescription );
+        IAttribute[] allAttributes = getAttributes();
+        for ( IAttribute attribute : allAttributes )
+        {
+            AttributeDescription other = attribute.getAttributeDescription();
+            if ( other.isSubtypeOf( ad, getBrowserConnection().getSchema() ) )
             {
-                IAttribute[] attributes = attributeList.toArray( new IAttribute[attributeList.size()] );
-                AttributeHierarchy ah = new AttributeHierarchy( this, attributeDescription, attributes );
-                return ah;
+                attributeList.add( attribute );
             }
         }
-    }
-
 
-    /**
-     * {@inheritDoc}
-     */
-    public Subschema getSubschema()
-    {
-        AttributeInfo ai = getBrowserConnectionImpl().getAttributeInfo( this );
-        if ( ai == null )
+        if ( attributeList.isEmpty() )
         {
-            ai = new AttributeInfo();
-            getBrowserConnectionImpl().setAttributeInfo( this, ai );
+            return null;
         }
-        if ( ai.subschema == null || ai.subschema.getObjectClassNames() == null
-            || ai.subschema.getObjectClassNames().length == 0 )
+        else
         {
-            ai.subschema = new Subschema( this );
+            IAttribute[] attributes = attributeList.toArray( new IAttribute[attributeList.size()] );
+            AttributeHierarchy ah = new AttributeHierarchy( this, attributeDescription, attributes );
+            return ah;
         }
-
-        return ai.subschema;
     }
 
 
@@ -824,4 +839,21 @@
         return Utils.getLdapURL( this );
     }
 
+
+    /**
+     * {@inheritDoc}
+     */
+    public Collection<ObjectClassDescription> getObjectClassDescriptions()
+    {
+        Collection<ObjectClassDescription> ocds = new ArrayList<ObjectClassDescription>();
+        String[] ocNames = getAttribute( SchemaConstants.OBJECT_CLASS_AT ).getStringValues();
+        Schema schema = getBrowserConnection().getSchema();
+        for ( String ocName : ocNames )
+        {
+            ObjectClassDescription ocd = schema.getObjectClassDescription( ocName );
+            ocds.add( ocd );
+        }
+        return ocds;
+    }
+
 }

Modified: directory/sandbox/seelmann/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/Attribute.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/Attribute.java?rev=758668&r1=758667&r2=758668&view=diff
==============================================================================
--- directory/sandbox/seelmann/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/Attribute.java (original)
+++ directory/sandbox/seelmann/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/Attribute.java Thu Mar 26 14:42:36 2009
@@ -22,6 +22,7 @@
 
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
 
@@ -131,15 +132,8 @@
         }
         else
         {
-            String[] mustAttributeNames = getEntry().getSubschema().getMustAttributeNames();
-            for ( String must : mustAttributeNames )
-            {
-                if ( must.equalsIgnoreCase( getType() ) )
-                {
-                    return true;
-                }
-            }
-            return false;
+            Collection<AttributeTypeDescription> mustAtds = SchemaUtils.getMustAttributeTypeDescriptions( entry );
+            return mustAtds.contains( getAttributeTypeDescription() );
         }
     }
 

Modified: directory/sandbox/seelmann/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/AttributeInfo.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/AttributeInfo.java?rev=758668&r1=758667&r2=758668&view=diff
==============================================================================
--- directory/sandbox/seelmann/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/AttributeInfo.java (original)
+++ directory/sandbox/seelmann/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/AttributeInfo.java Thu Mar 26 14:42:36 2009
@@ -26,7 +26,6 @@
 import java.util.Map;
 
 import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
-import org.apache.directory.studio.ldapbrowser.core.model.schema.Subschema;
 
 
 /**
@@ -49,9 +48,6 @@
     /** The attribute map. */
     protected volatile Map<String, IAttribute> attributeMap = new LinkedHashMap<String, IAttribute>();
 
-    /** The subschema. */
-    protected volatile Subschema subschema = null;
-
 
     /**
      * Creates a new instance of AttributeInfo.

Modified: directory/sandbox/seelmann/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/DelegateEntry.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/DelegateEntry.java?rev=758668&r1=758667&r2=758668&view=diff
==============================================================================
--- directory/sandbox/seelmann/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/DelegateEntry.java (original)
+++ directory/sandbox/seelmann/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/DelegateEntry.java Thu Mar 26 14:42:36 2009
@@ -21,8 +21,11 @@
 package org.apache.directory.studio.ldapbrowser.core.model.impl;
 
 
+import java.util.Collection;
+
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.name.Rdn;
+import org.apache.directory.shared.ldap.schema.parsers.ObjectClassDescription;
 import org.apache.directory.shared.ldap.util.LdapURL;
 import org.apache.directory.studio.connection.core.jobs.StudioBulkRunnableWithProgress;
 import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin;
@@ -44,7 +47,6 @@
 import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
 import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
 import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
-import org.apache.directory.studio.ldapbrowser.core.model.schema.Subschema;
 import org.apache.directory.studio.ldapbrowser.core.utils.Utils;
 import org.eclipse.search.ui.ISearchPageScoreComputer;
 
@@ -446,22 +448,6 @@
     /**
      * {@inheritDoc}
      */
-    public Subschema getSubschema()
-    {
-        if ( getDelegate() != null )
-        {
-            return getDelegate().getSubschema();
-        }
-        else
-        {
-            return null;
-        }
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
     public boolean hasMoreChildren()
     {
         if ( getDelegate() != null )
@@ -916,4 +902,21 @@
         return getDn() == null ? e.getDn() == null : ( getDn().equals( e.getDn() ) && getBrowserConnection().equals(
             e.getBrowserConnection() ) );
     }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public Collection<ObjectClassDescription> getObjectClassDescriptions()
+    {
+        if ( getDelegate() != null )
+        {
+            return getDelegate().getObjectClassDescriptions();
+        }
+        else
+        {
+            return null;
+        }
+    }
+
 }

Modified: directory/sandbox/seelmann/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/DummyEntry.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/DummyEntry.java?rev=758668&r1=758667&r2=758668&view=diff
==============================================================================
--- directory/sandbox/seelmann/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/DummyEntry.java (original)
+++ directory/sandbox/seelmann/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/DummyEntry.java Thu Mar 26 14:42:36 2009
@@ -22,7 +22,7 @@
 
 
 import java.util.ArrayList;
-import java.util.Arrays;
+import java.util.Collection;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
@@ -30,6 +30,7 @@
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.name.Rdn;
+import org.apache.directory.shared.ldap.schema.parsers.ObjectClassDescription;
 import org.apache.directory.shared.ldap.util.LdapURL;
 import org.apache.directory.studio.connection.core.jobs.StudioBulkRunnableWithProgress;
 import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin;
@@ -41,7 +42,7 @@
 import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
 import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
 import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
-import org.apache.directory.studio.ldapbrowser.core.model.schema.Subschema;
+import org.apache.directory.studio.ldapbrowser.core.model.schema.Schema;
 import org.apache.directory.studio.ldapbrowser.core.utils.Utils;
 
 
@@ -288,15 +289,6 @@
 
 
     /**
-     * {@inheritDoc}
-     */
-    public Subschema getSubschema()
-    {
-        return new Subschema( this );
-    }
-
-
-    /**
      * This implementation always returns false.
      */
     public boolean hasMoreChildren()
@@ -346,7 +338,8 @@
      */
     public boolean isAlias()
     {
-        return Arrays.asList( getSubschema().getObjectClassNames() ).contains( SchemaConstants.ALIAS_OC );
+        return getObjectClassDescriptions().contains(
+            getBrowserConnection().getSchema().getObjectClassDescription( SchemaConstants.ALIAS_OC ) );
     }
 
 
@@ -382,7 +375,8 @@
      */
     public boolean isReferral()
     {
-        return Arrays.asList( getSubschema().getObjectClassNames() ).contains( SchemaConstants.REFERRAL_OC );
+        return getObjectClassDescriptions().contains(
+            getBrowserConnection().getSchema().getObjectClassDescription( SchemaConstants.REFERRAL_OC ) );
     }
 
 
@@ -391,7 +385,8 @@
      */
     public boolean isSubentry()
     {
-        return Arrays.asList( this.getSubschema().getObjectClassNames() ).contains( SchemaConstants.SUBENTRY_OC );
+        return getObjectClassDescriptions().contains(
+            getBrowserConnection().getSchema().getObjectClassDescription( SchemaConstants.SUBENTRY_OC ) );
     }
 
 
@@ -509,4 +504,18 @@
         return null;
     }
 
+
+    public Collection<ObjectClassDescription> getObjectClassDescriptions()
+    {
+        Collection<ObjectClassDescription> ocds = new ArrayList<ObjectClassDescription>();
+        String[] ocNames = getAttribute( SchemaConstants.OBJECT_CLASS_AT ).getStringValues();
+        Schema schema = getBrowserConnection().getSchema();
+        for ( String ocName : ocNames )
+        {
+            ObjectClassDescription ocd = schema.getObjectClassDescription( ocName );
+            ocds.add( ocd );
+        }
+        return ocds;
+    }
+
 }

Modified: directory/sandbox/seelmann/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/schema/SchemaUtils.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/schema/SchemaUtils.java?rev=758668&r1=758667&r2=758668&view=diff
==============================================================================
--- directory/sandbox/seelmann/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/schema/SchemaUtils.java (original)
+++ directory/sandbox/seelmann/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/schema/SchemaUtils.java Thu Mar 26 14:42:36 2009
@@ -122,31 +122,31 @@
         OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( SchemaConstants.MODIFY_TIMESTAMP_AT_OID.toLowerCase() );
         OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( SchemaConstants.MODIFIERS_NAME_AT.toLowerCase() );
         OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( SchemaConstants.MODIFIERS_NAME_AT_OID.toLowerCase() );
-        
+
         OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( SchemaConstants.SUBSCHEMA_SUBENTRY_AT.toLowerCase() );
         OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( SchemaConstants.SUBSCHEMA_SUBENTRY_AT_OID.toLowerCase() );
         OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( SchemaConstants.STRUCTURAL_OBJECT_CLASS_AT.toLowerCase() );
         OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( SchemaConstants.STRUCTURAL_OBJECT_CLASS_AT_OID.toLowerCase() );
         OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( SchemaConstants.GOVERNING_STRUCTURE_RULE_AT.toLowerCase() );
         OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( SchemaConstants.GOVERNING_STRUCTURE_RULE_AT_OID.toLowerCase() );
-        
+
         OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( SchemaConstants.ENTRY_UUID_AT.toLowerCase() );
         OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( SchemaConstants.ENTRY_UUID_AT_OID.toLowerCase() );
         OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( SchemaConstants.ENTRY_CSN_AT.toLowerCase() );
         OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( SchemaConstants.ENTRY_DN_AT.toLowerCase() );
         OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( SchemaConstants.ENTRY_DN_AT_OID.toLowerCase() );
-        
+
         OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( SchemaConstants.HAS_SUBORDINATES_AT.toLowerCase() );
         OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( SchemaConstants.HAS_SUBORDINATES_AT_OID.toLowerCase() );
         OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( SchemaConstants.NUM_SUBORDINATES_AT.toLowerCase() );
         OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( SchemaConstants.SUBORDINATE_COUNT_AT.toLowerCase() );
-        
+
         OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( SchemaConstants.VENDOR_NAME_AT.toLowerCase() );
         OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( SchemaConstants.VENDOR_NAME_AT_OID.toLowerCase() );
         OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( SchemaConstants.VENDOR_VERSION_AT.toLowerCase() );
         OPERATIONAL_ATTRIBUTES_OIDS_AND_NAMES.add( SchemaConstants.VENDOR_VERSION_AT_OID.toLowerCase() );
     }
-    
+
     private static final Comparator<String> nameAndOidComparator = new Comparator<String>()
     {
         public int compare( String s1, String s2 )
@@ -226,7 +226,7 @@
     /**
      * Gets the identifiers of the given schema descriptions.
      * 
-     * @param asd the the schema description
+     * @param asd the schema descriptions
      * 
      * @return the identifiers
      */
@@ -252,6 +252,24 @@
 
 
     /**
+     * Gets the friendly identifier of the given schema description.
+     * This is the first name, if there is no name the numeric OID is returned.
+     * 
+     * @param asd the schema description
+     * 
+     * @return the friendly identifier
+     */
+    public static String getFriendlyIdentifier( AbstractSchemaDescription asd )
+    {
+        if ( asd.getNames() != null && !asd.getNames().isEmpty() )
+        {
+            return asd.getNames().get( 0 );
+        }
+        return asd.getNumericOid();
+    }
+
+
+    /**
      * Gets all operational attribute type descriptions.
      * 
      * @param schema the schema
@@ -337,6 +355,70 @@
     }
 
 
+    /**
+     * Gets the must attribute type descriptions of all object class descriptions of the given entry.
+     * 
+     * param entry the entry
+     * 
+     * @return the must attribute type descriptions of all object class descriptions of the given entry.
+     */
+    public static Collection<AttributeTypeDescription> getMustAttributeTypeDescriptions( IEntry entry )
+    {
+        Schema schema = entry.getBrowserConnection().getSchema();
+        Collection<AttributeTypeDescription> atds = new HashSet<AttributeTypeDescription>();
+        for ( ObjectClassDescription ocd : entry.getObjectClassDescriptions() )
+        {
+            Collection<String> musts = getMustAttributeTypeDescriptionNamesTransitive( ocd, schema );
+            for ( String must : musts )
+            {
+                AttributeTypeDescription atd = schema.getAttributeTypeDescription( must );
+                atds.add( atd );
+            }
+        }
+        return atds;
+    }
+
+
+    /**
+     * Gets the may attribute type descriptions of all object class descriptions of the given entry.
+     * 
+     * @param entry the entry
+     * 
+     * @return the may attribute type descriptions of all object class descriptions of the given entry.
+     */
+    public static Collection<AttributeTypeDescription> getMayAttributeTypeDescriptions( IEntry entry )
+    {
+        Schema schema = entry.getBrowserConnection().getSchema();
+        Collection<AttributeTypeDescription> atds = new HashSet<AttributeTypeDescription>();
+        for ( ObjectClassDescription ocd : entry.getObjectClassDescriptions() )
+        {
+            Collection<String> mays = getMayAttributeTypeDescriptionNamesTransitive( ocd, schema );
+            for ( String may : mays )
+            {
+                AttributeTypeDescription atd = schema.getAttributeTypeDescription( may );
+                atds.add( atd );
+            }
+        }
+        return atds;
+    }
+
+
+    /**
+     * Gets all attribute type descriptions of all object class descriptions of the given entry.
+     * 
+     * @param entry the entry
+     * 
+     * @return all attribute type descriptions of all object class descriptions of the given entry.
+     */
+    public static Collection<AttributeTypeDescription> getAllAttributeTypeDescriptions( IEntry entry )
+    {
+        Collection<AttributeTypeDescription> atds = new HashSet<AttributeTypeDescription>();
+        atds.addAll( getMustAttributeTypeDescriptions( entry ) );
+        atds.addAll( getMayAttributeTypeDescriptions( entry ) );
+        return atds;
+    }
+
+
     ////////////////////////////////////////////////////////
     /**
      * Checks the pre-defined and user-defined binary syntax OIDs. If this
@@ -938,18 +1020,19 @@
             }
 
             // check must-attributes
-            String[] mustAttributeNames = entry.getSubschema().getMustAttributeNames();
-            for ( String must : mustAttributeNames )
+            Collection<AttributeTypeDescription> mustAtds = getMustAttributeTypeDescriptions( entry );
+            for ( AttributeTypeDescription mustAtd : mustAtds )
             {
-                AttributeHierarchy ah = entry.getAttributeWithSubtypes( must );
+                AttributeHierarchy ah = entry.getAttributeWithSubtypes( mustAtd.getNumericOid() );
                 if ( ah == null )
                 {
-                    messages.add( NLS.bind( Messages.getString( "SchemaUtils.MandatoryAttributeIsMissing" ), must ) ); //$NON-NLS-1$
+                    messages.add( NLS.bind( Messages.getString( "SchemaUtils.MandatoryAttributeIsMissing" ), //$NON-NLS-1$ 
+                        getLowerCaseIdentifiers( mustAtd ) ) );
                 }
             }
 
             // check unallowed attributes
-            Set<AttributeTypeDescription> allAtds = entry.getSubschema().getAllAttributeTypeDescriptions();
+            Collection<AttributeTypeDescription> allAtds = getAllAttributeTypeDescriptions( entry );
             for ( IAttribute attribute : entry.getAttributes() )
             {
                 if ( !attribute.isOperationalAttribute() )

Modified: directory/sandbox/seelmann/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/OpenBestEditorAction.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/OpenBestEditorAction.java?rev=758668&r1=758667&r2=758668&view=diff
==============================================================================
--- directory/sandbox/seelmann/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/OpenBestEditorAction.java (original)
+++ directory/sandbox/seelmann/trunk/ldapbrowser-ui/src/main/java/org/apache/directory/studio/ldapbrowser/ui/editors/searchresult/OpenBestEditorAction.java Thu Mar 26 14:42:36 2009
@@ -21,14 +21,14 @@
 package org.apache.directory.studio.ldapbrowser.ui.editors.searchresult;
 
 
-import java.util.Set;
+import java.util.Collection;
 
 import org.apache.directory.shared.ldap.schema.parsers.AttributeTypeDescription;
 import org.apache.directory.studio.ldapbrowser.core.BrowserCoreConstants;
 import org.apache.directory.studio.ldapbrowser.core.model.AttributeHierarchy;
+import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
 import org.apache.directory.studio.ldapbrowser.core.model.IValue;
 import org.apache.directory.studio.ldapbrowser.core.model.schema.SchemaUtils;
-import org.apache.directory.studio.ldapbrowser.core.model.schema.Subschema;
 import org.apache.directory.studio.valueeditors.IValueEditor;
 import org.apache.directory.studio.valueeditors.ValueEditorManager;
 import org.eclipse.jface.dialogs.MessageDialog;
@@ -159,8 +159,8 @@
             if ( attributeHierarchy.size() == 1 && attributeHierarchy.getAttribute().getValueSize() == 0 )
             {
                 // validate if value is allowed
-                Subschema subschema = attributeHierarchy.getAttribute().getEntry().getSubschema();
-                Set<AttributeTypeDescription> allAtds = subschema.getAllAttributeTypeDescriptions();
+                IEntry entry = attributeHierarchy.getAttribute().getEntry();
+                Collection<AttributeTypeDescription> allAtds = SchemaUtils.getAllAttributeTypeDescriptions( entry );
                 AttributeTypeDescription atd = attributeHierarchy.getAttribute().getAttributeTypeDescription();
                 if ( !allAtds.contains( atd ) )
                 {



Mime
View raw message