directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r569395 - in /directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor: model/schemachecker/ view/views/
Date Fri, 24 Aug 2007 14:22:24 GMT
Author: pamarcelot
Date: Fri Aug 24 07:22:23 2007
New Revision: 569395

URL: http://svn.apache.org/viewvc?rev=569395&view=rev
Log:
Improved SchemaChecker by adding a check on the type of the superior of an object class.

Added:
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/ClassTypeHierarchyError.java
Modified:
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/SchemaChecker.java
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/ProblemsViewLabelProvider.java

Added: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/ClassTypeHierarchyError.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/ClassTypeHierarchyError.java?rev=569395&view=auto
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/ClassTypeHierarchyError.java
(added)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/ClassTypeHierarchyError.java
Fri Aug 24 07:22:23 2007
@@ -0,0 +1,85 @@
+/*
+ *  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.studio.apacheds.schemaeditor.model.schemachecker;
+
+
+import org.apache.directory.shared.ldap.schema.SchemaObject;
+
+
+/**
+ * This class represents the ClassTypeHierarchyError.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ClassTypeHierarchyError implements SchemaError
+{
+    /** The source object */
+    private SchemaObject source;
+
+    /** The superior */
+    private SchemaObject superior;
+
+
+    /**
+     * Creates a new instance of ClassTypeHierarchyError.
+     *
+     * @param source
+     *      the source object
+     * @param superior
+     *      the superior object
+     */
+    public ClassTypeHierarchyError( SchemaObject source, SchemaObject duplicate )
+    {
+        this.source = source;
+        this.superior = duplicate;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.studio.apacheds.schemaeditor.model.schemachecker.SchemaError#getSource()
+     */
+    public SchemaObject getSource()
+    {
+        return source;
+    }
+
+
+    /**
+     * Gets the superior object.
+     *
+     * @return
+     *      the superior object
+     */
+    public SchemaObject getSuperior()
+    {
+        return superior;
+    }
+
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#toString()
+     */
+    public String toString()
+    {
+        return "[ClassTypeHierarchyError - Source: " + getSource() + " - Superior: "
+            + getSuperior() + "]";
+    }
+}

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/SchemaChecker.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/SchemaChecker.java?rev=569395&r1=569394&r2=569395&view=diff
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/SchemaChecker.java
(original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/SchemaChecker.java
Fri Aug 24 07:22:23 2007
@@ -25,6 +25,7 @@
 
 import org.apache.commons.collections.MultiMap;
 import org.apache.commons.collections.map.MultiValueMap;
+import org.apache.directory.shared.ldap.schema.ObjectClassTypeEnum;
 import org.apache.directory.shared.ldap.schema.SchemaObject;
 import org.apache.directory.studio.apacheds.schemaeditor.Activator;
 import org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaHandler;
@@ -523,6 +524,8 @@
         String[] superiors = oc.getSuperClassesNames();
         if ( ( superiors != null ) && ( superiors.length >= 1 ) )
         {
+            ObjectClassTypeEnum type = oc.getType();
+
             for ( String superior : superiors )
             {
                 ObjectClassImpl superiorOC = schemaHandler.getObjectClass( superior );
@@ -538,6 +541,33 @@
                 {
                     dependenciesMap.put( superiorOC, oc );
                     dependsOnMap.put( oc, superiorOC );
+
+                    // Checking Type of Superior Hierarchy
+                    ObjectClassTypeEnum superiorOCType = superiorOC.getType();
+                    switch ( type )
+                    {
+                        case ABSTRACT:
+                            if ( ( !superiorOCType.equals( ObjectClassTypeEnum.ABSTRACT )
)
+                                && ( !superiorOC.getOid().equals( "2.5.6.0" ) ) )
+                            {
+                                SchemaError error = new ClassTypeHierarchyError( oc, superiorOC
);
+                                errorsList.add( error );
+                                errorsMap.put( oc, error );
+                            }
+                            break;
+                        case AUXILIARY:
+                            if ( ( superiorOCType.equals( ObjectClassTypeEnum.STRUCTURAL
) )
+                                && ( !superiorOC.getOid().equals( "2.5.6.0" ) ) )
+                            {
+                                SchemaError error = new ClassTypeHierarchyError( oc, superiorOC
);
+                                errorsList.add( error );
+                                errorsMap.put( oc, error );
+                            }
+                            break;
+
+                        default:
+                            break;
+                    }
                 }
             }
         }
@@ -644,20 +674,6 @@
         if ( ( ocList != null ) && ( ocList.size() >= 1 ) )
         {
             results.addAll( ocList );
-        }
-
-        // Matching rules
-        List<?> mrList = schemaHandler.getMatchingRuleList( id );
-        if ( ( mrList != null ) && ( mrList.size() >= 1 ) )
-        {
-            results.addAll( mrList );
-        }
-
-        // Syntaxes
-        List<?> syntaxesList = schemaHandler.getSyntaxList( id );
-        if ( ( syntaxesList != null ) && ( syntaxesList.size() >= 1 ) )
-        {
-            results.addAll( syntaxesList );
         }
 
         return results;

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/ProblemsViewLabelProvider.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/ProblemsViewLabelProvider.java?rev=569395&r1=569394&r2=569395&view=diff
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/ProblemsViewLabelProvider.java
(original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/views/ProblemsViewLabelProvider.java
Fri Aug 24 07:22:23 2007
@@ -20,11 +20,13 @@
 package org.apache.directory.studio.apacheds.schemaeditor.view.views;
 
 
+import org.apache.directory.shared.ldap.schema.ObjectClassTypeEnum;
 import org.apache.directory.shared.ldap.schema.SchemaObject;
 import org.apache.directory.studio.apacheds.schemaeditor.Activator;
 import org.apache.directory.studio.apacheds.schemaeditor.PluginConstants;
 import org.apache.directory.studio.apacheds.schemaeditor.model.AttributeTypeImpl;
 import org.apache.directory.studio.apacheds.schemaeditor.model.ObjectClassImpl;
+import org.apache.directory.studio.apacheds.schemaeditor.model.schemachecker.ClassTypeHierarchyError;
 import org.apache.directory.studio.apacheds.schemaeditor.model.schemachecker.DuplicateAliasError;
 import org.apache.directory.studio.apacheds.schemaeditor.model.schemachecker.DuplicateOidError;
 import org.apache.directory.studio.apacheds.schemaeditor.model.schemachecker.NoAliasWarning;
@@ -96,18 +98,8 @@
             }
             else if ( columnIndex == 1 )
             {
-                String name = errorWrapper.getSchemaError().getSource().getName();
-
-                if ( ( name != null ) && ( !name.equals( "" ) ) )
-                {
-                    return name;
-                }
-                else
-                {
-                    return errorWrapper.getSchemaError().getSource().getOid();
-                }
+                return getDisplayName( errorWrapper.getSchemaError().getSource() );
             }
-
         }
         else if ( element instanceof SchemaWarningWrapper )
         {
@@ -239,7 +231,60 @@
             }
             message.append( " with OID '" + source.getOid() + "' does not have any alias."
);
         }
+        else if ( element instanceof ClassTypeHierarchyError )
+        {
+            ClassTypeHierarchyError classTypeHierarchyError = ( ClassTypeHierarchyError )
element;
+            ObjectClassImpl source = ( ObjectClassImpl ) classTypeHierarchyError.getSource();
+            ObjectClassImpl superior = ( ObjectClassImpl ) classTypeHierarchyError.getSuperior();
+
+            if ( source.getType().equals( ObjectClassTypeEnum.ABSTRACT ) )
+            {
+                message.append( "Abstract object class Ô" + getDisplayName( source ) + "'
can not extend " );
+
+                if ( superior.getType().equals( ObjectClassTypeEnum.STRUCTURAL ) )
+                {
+                    message.append( "Structural object class :'" + getDisplayName( superior
) + "'." );
+                }
+                else if ( superior.getType().equals( ObjectClassTypeEnum.AUXILIARY ) )
+                {
+                    message.append( "Auxiliary object class :'" + getDisplayName( superior
) + "'." );
+                }
+            }
+            else if ( source.getType().equals( ObjectClassTypeEnum.AUXILIARY ) )
+            {
+                message.append( "Auxiliary object class Ô" + getDisplayName( source ) +
"' can not extend " );
+
+                if ( superior.getType().equals( ObjectClassTypeEnum.STRUCTURAL ) )
+                {
+                    message.append( "Structural object class :'" + getDisplayName( superior
) + "'." );
+                }
+            }
+
+        }
 
         return message.toString();
+    }
+
+
+    /**
+     * Gets the displayable name of the given SchemaObject.
+     *
+     * @param so
+     *      the SchemaObject
+     * @return
+     *      the displayable name of the given SchemaObject
+     */
+    private String getDisplayName( SchemaObject so )
+    {
+        String name = so.getName();
+
+        if ( ( name != null ) && ( !name.equals( "" ) ) )
+        {
+            return name;
+        }
+        else
+        {
+            return so.getOid();
+        }
     }
 }



Mime
View raw message