You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by pa...@apache.org on 2007/07/06 17:05:35 UTC
svn commit: r553917 - in
/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor:
./ controller/ model/schemachecker/ view/widget/
Author: pamarcelot
Date: Fri Jul 6 08:05:33 2007
New Revision: 553917
URL: http://svn.apache.org/viewvc?view=rev&rev=553917
Log:
Added the SchemaChecker Model.
Added:
directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/
directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/DuplicateAliasError.java
directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/DuplicateMandatoryOptionalAttributeError.java
directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/DuplicateOidError.java
directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/NonExistingATSuperiorError.java
directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/NonExistingMatchingRuleError.java
directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/NonExistingOCSuperiorError.java
directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/NonExistingSyntaxError.java
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/model/schemachecker/SchemaError.java
directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/SchemaWarning.java
Modified:
directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/Activator.java
directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/FakeLoader.java
directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/SchemaHandler.java
directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/widget/SchemaSourceViewerConfiguration.java
Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/Activator.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/Activator.java?view=diff&rev=553917&r1=553916&r2=553917
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/Activator.java (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/Activator.java Fri Jul 6 08:05:33 2007
@@ -21,6 +21,7 @@
import org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaHandler;
+import org.apache.directory.studio.apacheds.schemaeditor.model.schemachecker.SchemaChecker;
import org.apache.directory.studio.apacheds.schemaeditor.view.widget.SchemaCodeScanner;
import org.apache.directory.studio.apacheds.schemaeditor.view.widget.SchemaTextAttributeProvider;
import org.eclipse.jface.text.rules.ITokenScanner;
@@ -43,14 +44,17 @@
private static Activator plugin;
/** the Schema Code Scanner */
- private static ITokenScanner schemaCodeScanner;
+ private ITokenScanner schemaCodeScanner;
/** The Schema Text Attribute Provider */
- private static SchemaTextAttributeProvider schemaTextAttributeProvider;
+ private SchemaTextAttributeProvider schemaTextAttributeProvider;
/** The SchemaHandler */
private SchemaHandler schemaHandler;
+ /** The SchemaCheker */
+ private SchemaChecker schemaChecker;
+
/**
* Creates a new instance of Activator.
@@ -59,6 +63,7 @@
{
plugin = this;
schemaHandler = SchemaHandler.getInstance();
+ schemaChecker = new SchemaChecker();
}
@@ -70,7 +75,9 @@
{
super.start( context );
- FakeLoader.loadSchemas();
+ FakeLoader.loadSchemas(); // TODO Remove after testing
+
+ schemaChecker.enableModificationsListening();
}
@@ -109,12 +116,24 @@
/**
+ * Gets the SchemaChecker
+ *
+ * @return
+ * the SchemaChecker
+ */
+ public SchemaChecker getSchemaChecker()
+ {
+ return schemaChecker;
+ }
+
+
+ /**
* Returns the Schema Code Scanner.
*
* @return
* the Schema Code Scanner
*/
- public static ITokenScanner getSchemaCodeScanner()
+ public ITokenScanner getSchemaCodeScanner()
{
if ( schemaCodeScanner == null )
{
@@ -131,7 +150,7 @@
* @return
* the Schema Text Attribute Provider
*/
- private static SchemaTextAttributeProvider getSchemaTextAttributeProvider()
+ private SchemaTextAttributeProvider getSchemaTextAttributeProvider()
{
if ( schemaTextAttributeProvider == null )
{
Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/FakeLoader.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/FakeLoader.java?view=diff&rev=553917&r1=553916&r2=553917
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/FakeLoader.java (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/FakeLoader.java Fri Jul 6 08:05:33 2007
@@ -38,7 +38,7 @@
at1.setSchema( schema1.getName() );
schema1.addAttributeType( at1 );
- AttributeTypeImpl at2 = new AttributeTypeImpl("1.2.3.4.2");
+ AttributeTypeImpl at2 = new AttributeTypeImpl("1.2.3.4.1");
at2.setNames( new String[] { "at2", "attributeType2" } );
at2.setSchema( schema1.getName() );
schema1.addAttributeType( at2 );
Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/SchemaHandler.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/SchemaHandler.java?view=diff&rev=553917&r1=553916&r2=553917
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/SchemaHandler.java (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/controller/SchemaHandler.java Fri Jul 6 08:05:33 2007
@@ -21,10 +21,9 @@
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
+import org.apache.commons.collections.MultiMap;
import org.apache.commons.collections.map.MultiValueMap;
import org.apache.directory.shared.ldap.schema.SchemaObject;
import org.apache.directory.studio.apacheds.schemaeditor.model.AttributeTypeImpl;
@@ -63,18 +62,18 @@
private List<SyntaxImpl> syntaxesList;
//
- // The Maps (for fast searching)
+ // The MultiMap (for fast searching)
//
- /** The schemas Map */
- private Map<String, Schema> schemasMap;
- /** The attribute types Map */
- private Map<String, AttributeTypeImpl> attributeTypesMap;
- /** The matching rules Map */
- private Map<String, MatchingRuleImpl> matchingRulesMap;
- /** The object classes Map */
- private Map<String, ObjectClassImpl> objectClassesMap;
- /** The syntaxes Map */
- private Map<String, SyntaxImpl> syntaxesMap;
+ /** The schemas MultiMap */
+ private MultiMap schemasMap;
+ /** The attribute types MultiMap */
+ private MultiMap attributeTypesMap;
+ /** The matching rules MultiMap */
+ private MultiMap matchingRulesMap;
+ /** The object classes MultiMap */
+ private MultiMap objectClassesMap;
+ /** The syntaxes MultiMap */
+ private MultiMap syntaxesMap;
//
// The Listeners Lists
@@ -98,11 +97,11 @@
syntaxesList = new ArrayList<SyntaxImpl>();
// Maps
- schemasMap = new HashMap<String, Schema>();
- attributeTypesMap = new HashMap<String, AttributeTypeImpl>();
- matchingRulesMap = new HashMap<String, MatchingRuleImpl>();
- objectClassesMap = new HashMap<String, ObjectClassImpl>();
- syntaxesMap = new HashMap<String, SyntaxImpl>();
+ schemasMap = new MultiValueMap();
+ attributeTypesMap = new MultiValueMap();
+ matchingRulesMap = new MultiValueMap();
+ objectClassesMap = new MultiValueMap();
+ syntaxesMap = new MultiValueMap();
// Listeners
schemaHandlerListeners = new ArrayList<SchemaHandlerListener>();
@@ -199,7 +198,30 @@
*/
public AttributeTypeImpl getAttributeType( String id )
{
- return attributeTypesMap.get( id.toLowerCase() );
+ List<?> list = getAttributeTypeList( id.toLowerCase() );
+
+ if ( ( list != null ) && ( list.size() >= 1 ) )
+ {
+ return ( AttributeTypeImpl ) list.get( 0 );
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+
+ /**
+ * Get the attribute type(s) List identified by an OID, or an alias.
+ *
+ * @param id
+ * an OID or an alias
+ * @return
+ * the corresponding attribute type(s) List or null if no one is found
+ */
+ public List<?> getAttributeTypeList( String id )
+ {
+ return ( List<?> ) attributeTypesMap.get( id.toLowerCase() );
}
@@ -213,7 +235,30 @@
*/
public MatchingRuleImpl getMatchingRule( String id )
{
- return matchingRulesMap.get( id.toLowerCase() );
+ List<?> list = getMatchingRuleList( id.toLowerCase() );
+
+ if ( ( list != null ) && ( list.size() >= 1 ) )
+ {
+ return ( MatchingRuleImpl ) list.get( 0 );
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+
+ /**
+ * Gets a matching rule(s) List identified by an OID, or an alias.
+ *
+ * @param id
+ * an OID or an alias
+ * @return
+ * the corresponding matching rule(s) List, or null if no one is found
+ */
+ public List<?> getMatchingRuleList( String id )
+ {
+ return ( List<?> ) matchingRulesMap.get( id.toLowerCase() );
}
@@ -227,7 +272,30 @@
*/
public ObjectClassImpl getObjectClass( String id )
{
- return objectClassesMap.get( id.toLowerCase() );
+ List<?> list = getObjectClassList( id.toLowerCase() );
+
+ if ( ( list != null ) && ( list.size() >= 1 ) )
+ {
+ return ( ObjectClassImpl ) list.get( 0 );
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+
+ /**
+ * Gets an object class(es) List identified by an OID, or an alias.
+ *
+ * @param id
+ * an OID or an alias
+ * @return
+ * the corresponding object class(es) List, or null if no one is found
+ */
+ public List<?> getObjectClassList( String id )
+ {
+ return ( List<?> ) objectClassesMap.get( id.toLowerCase() );
}
@@ -241,7 +309,30 @@
*/
public Schema getSchema( String name )
{
- return schemasMap.get( name.toLowerCase() );
+ List<?> list = getSchemaList( name.toLowerCase() );
+
+ if ( ( list != null ) && ( list.size() >= 1 ) )
+ {
+ return ( Schema ) list.get( 0 );
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+
+ /**
+ * Gets a schema(s) List identified by a name.
+ *
+ * @param name
+ * a name
+ * @return
+ * the corresponding schema(s) List, or null if no one is found
+ */
+ public List<?> getSchemaList( String name )
+ {
+ return ( List<?> ) schemasMap.get( name.toLowerCase() );
}
@@ -255,7 +346,30 @@
*/
public SyntaxImpl getSyntax( String id )
{
- return syntaxesMap.get( id.toLowerCase() );
+ List<?> list = getSyntaxList( id.toLowerCase() );
+
+ if ( ( list != null ) && ( list.size() >= 1 ) )
+ {
+ return ( SyntaxImpl ) list.get( 0 );
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+
+ /**
+ * Gets a syntax(es) List identified by an OID, or an alias.
+ *
+ * @param id
+ * an OID or an alias
+ * @return
+ * the corresponding syntax(es) List, or null if no one is found
+ */
+ public List<?> getSyntaxList( String id )
+ {
+ return ( List<?> ) syntaxesMap.get( id.toLowerCase() );
}
Added: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/DuplicateAliasError.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/DuplicateAliasError.java?view=auto&rev=553917
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/DuplicateAliasError.java (added)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/DuplicateAliasError.java Fri Jul 6 08:05:33 2007
@@ -0,0 +1,106 @@
+/*
+ * 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 DuplicateAliasError.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class DuplicateAliasError implements SchemaError
+{
+ /** The source object */
+ private SchemaObject source;
+
+ /** The duplicated alias */
+ private String alias;
+
+ /** The duplicate */
+ private SchemaObject duplicate;
+
+
+ /**
+ * Creates a new instance of DuplicateAliasError.
+ *
+ * @param source
+ * the source object
+ * @param alias
+ * the duplicated alias
+ * @param duplicate
+ * the duplicate object
+ */
+ public DuplicateAliasError( SchemaObject source, String alias, SchemaObject duplicate )
+ {
+ this.source = source;
+ this.alias = alias;
+ this.duplicate = duplicate;
+ }
+
+
+ /**
+ * Gets the source object.
+ *
+ * @return
+ * the source object
+ */
+ public SchemaObject getSource()
+ {
+ return source;
+ }
+
+
+ /**
+ * Gets the duplicated alias.
+ *
+ * @return
+ * the duplicated alias
+ */
+ public String getAlias()
+ {
+ return alias;
+ }
+
+
+ /**
+ * Gets the duplicate object.
+ *
+ * @return
+ * the duplicate object
+ */
+ public SchemaObject getDuplicate()
+ {
+ return duplicate;
+ }
+
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString()
+ {
+ return "[DuplicateAliasError - Source: " + getSource() + " - Alias: " + getAlias() + " - Duplicate: "
+ + getDuplicate() + "]";
+ }
+}
Added: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/DuplicateMandatoryOptionalAttributeError.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/DuplicateMandatoryOptionalAttributeError.java?view=auto&rev=553917
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/DuplicateMandatoryOptionalAttributeError.java (added)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/DuplicateMandatoryOptionalAttributeError.java Fri Jul 6 08:05:33 2007
@@ -0,0 +1,87 @@
+/*
+ * 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 DuplicateMandatoryOptionalAttributeError.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class DuplicateMandatoryOptionalAttributeError implements SchemaError
+{
+ /** The source object */
+ private SchemaObject source;
+
+ /** The duplicated alias */
+ private String alias;
+
+
+ /**
+ * Creates a new instance of DuplicateMandatoryOptionalAttributeError.
+ *
+ * @param source
+ * the source object
+ * @param alias
+ * the duplicated alias
+ */
+ public DuplicateMandatoryOptionalAttributeError( SchemaObject source, String alias )
+ {
+ this.source = source;
+ this.alias = alias;
+ }
+
+
+ /**
+ * Gets the source object.
+ *
+ * @return
+ * the source object
+ */
+ public SchemaObject getSource()
+ {
+ return source;
+ }
+
+
+ /**
+ * Gets the duplicated alias.
+ *
+ * @return
+ * the duplicated alias
+ */
+ public String getAlias()
+ {
+ return alias;
+ }
+
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString()
+ {
+ return "[DuplicateMandatoryOptionalAttributeError - Source: " + getSource() + " - Alias: " + getAlias() + "]";
+ }
+}
Added: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/DuplicateOidError.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/DuplicateOidError.java?view=auto&rev=553917
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/DuplicateOidError.java (added)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/DuplicateOidError.java Fri Jul 6 08:05:33 2007
@@ -0,0 +1,106 @@
+/*
+ * 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 DuplicateOidError.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class DuplicateOidError implements SchemaError
+{
+ /** The source object */
+ private SchemaObject source;
+
+ /** The duplicated OID */
+ private String oid;
+
+ /** The duplicate */
+ private SchemaObject duplicate;
+
+
+ /**
+ * Creates a new instance of DuplicateAliasError.
+ *
+ * @param source
+ * the source object
+ * @param oid
+ * the duplicated alias
+ * @param duplicate
+ * the duplicate object
+ */
+ public DuplicateOidError( SchemaObject source, String oid, SchemaObject duplicate )
+ {
+ this.source = source;
+ this.oid = oid;
+ this.duplicate = duplicate;
+ }
+
+
+ /**
+ * Gets the source object.
+ *
+ * @return
+ * the source object
+ */
+ public SchemaObject getSource()
+ {
+ return source;
+ }
+
+
+ /**
+ * Gets the duplicated OID.
+ *
+ * @return
+ * the duplicated OID
+ */
+ public String getOid()
+ {
+ return oid;
+ }
+
+
+ /**
+ * Gets the duplicate object.
+ *
+ * @return
+ * the duplicate object
+ */
+ public SchemaObject getDuplicate()
+ {
+ return duplicate;
+ }
+
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString()
+ {
+ return "[DuplicateOidError - Source: " + getSource() + " - OID: " + getOid() + " - Duplicate: "
+ + getDuplicate() + "]";
+ }
+}
Added: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/NonExistingATSuperiorError.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/NonExistingATSuperiorError.java?view=auto&rev=553917
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/NonExistingATSuperiorError.java (added)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/NonExistingATSuperiorError.java Fri Jul 6 08:05:33 2007
@@ -0,0 +1,87 @@
+/*
+ * 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 NonExistingATSuperiorError.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class NonExistingATSuperiorError implements SchemaError
+{
+ /** The source object */
+ private SchemaObject source;
+
+ /** The superior's alias */
+ private String supAlias;
+
+
+ /**
+ * Creates a new instance of NonExistingATSuperiorError.
+ *
+ * @param source
+ * the source object
+ * @param supAlias
+ * the superior's alias
+ */
+ public NonExistingATSuperiorError( SchemaObject source, String supAlias )
+ {
+ this.source = source;
+ this.supAlias = supAlias;
+ }
+
+
+ /**
+ * Gets the source object.
+ *
+ * @return
+ * the source object
+ */
+ public SchemaObject getSource()
+ {
+ return source;
+ }
+
+
+ /**
+ * Gets the superior's alias.
+ *
+ * @return
+ * the superior's alias
+ */
+ public String getSuperiorAlias()
+ {
+ return supAlias;
+ }
+
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString()
+ {
+ return "[NonExistingATSuperiorError - Source: " + getSource() + " - supAlias: " + getSuperiorAlias() + "]";
+ }
+}
Added: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/NonExistingMatchingRuleError.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/NonExistingMatchingRuleError.java?view=auto&rev=553917
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/NonExistingMatchingRuleError.java (added)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/NonExistingMatchingRuleError.java Fri Jul 6 08:05:33 2007
@@ -0,0 +1,115 @@
+/*
+ * 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 NonExistingMatchingRuleError.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class NonExistingMatchingRuleError implements SchemaError
+{
+ /**
+ * This enum represents the different types of NonExistingMatchingRuleError.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+ public enum NonExistingMatchingRuleErrorEnum
+ {
+ EQUALITY, ORDERING, SUBSTRING
+ }
+
+ /** The source object */
+ private SchemaObject source;
+
+ /** The matching rule's alias */
+ private String mrAlias;
+
+ /** The type */
+ private NonExistingMatchingRuleErrorEnum type;
+
+
+ /**
+ * Creates a new instance of NonExistingMatchingRuleError.
+ *
+ * @param source
+ * the source object
+ * @param mrAlias
+ * the matching rule alias
+ */
+ public NonExistingMatchingRuleError( SchemaObject source, String mrAlias, NonExistingMatchingRuleErrorEnum type )
+ {
+ this.source = source;
+ this.mrAlias = mrAlias;
+ this.type = type;
+ }
+
+
+ /**
+ * Gets the source object.
+ *
+ * @return
+ * the source object
+ */
+ public SchemaObject getSource()
+ {
+ return source;
+ }
+
+
+ /**
+ * Gets the matching rule alias.
+ *
+ * @return
+ * the matching rule alias
+ */
+ public String getMatchingRuleAlias()
+ {
+ return mrAlias;
+ }
+
+
+ /**
+ * Gets the type of NonExistingMatchingRuleError.
+ *
+ * @return
+ * the type of NonExistingMatchingRuleError
+ */
+ public NonExistingMatchingRuleErrorEnum getType()
+ {
+ return type;
+ }
+
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString()
+ {
+ return "[NonExistingMatchingRuleError - Source: " + getSource() + " - mrAlias: " + getMatchingRuleAlias()
+ + " - Type: " + getType() + "]";
+ }
+}
\ No newline at end of file
Added: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/NonExistingOCSuperiorError.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/NonExistingOCSuperiorError.java?view=auto&rev=553917
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/NonExistingOCSuperiorError.java (added)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/NonExistingOCSuperiorError.java Fri Jul 6 08:05:33 2007
@@ -0,0 +1,87 @@
+/*
+ * 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 NonExistingOCSuperiorError.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class NonExistingOCSuperiorError implements SchemaError
+{
+ /** The source object */
+ private SchemaObject source;
+
+ /** The superior's alias */
+ private String supAlias;
+
+
+ /**
+ * Creates a new instance of NonExistingATSuperiorError.
+ *
+ * @param source
+ * the source object
+ * @param supAlias
+ * the superior's alias
+ */
+ public NonExistingOCSuperiorError( SchemaObject source, String supAlias )
+ {
+ this.source = source;
+ this.supAlias = supAlias;
+ }
+
+
+ /**
+ * Gets the source object.
+ *
+ * @return
+ * the source object
+ */
+ public SchemaObject getSource()
+ {
+ return source;
+ }
+
+
+ /**
+ * Gets the superior's alias.
+ *
+ * @return
+ * the superior's alias
+ */
+ public String getSuperiorAlias()
+ {
+ return supAlias;
+ }
+
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString()
+ {
+ return "[NonExistingOCSuperiorError - Source: " + getSource() + " - supAlias: " + getSuperiorAlias() + "]";
+ }
+}
Added: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/NonExistingSyntaxError.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/NonExistingSyntaxError.java?view=auto&rev=553917
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/NonExistingSyntaxError.java (added)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/NonExistingSyntaxError.java Fri Jul 6 08:05:33 2007
@@ -0,0 +1,87 @@
+/*
+ * 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 NonExistingSyntaxError.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class NonExistingSyntaxError implements SchemaError
+{
+ /** The source object */
+ private SchemaObject source;
+
+ /** The syntax's oid */
+ private String oid;
+
+
+ /**
+ * Creates a new instance of NonExistingSyntaxError.
+ *
+ * @param source
+ * the source object
+ * @param oid
+ * the matching rule alias
+ */
+ public NonExistingSyntaxError( SchemaObject source, String oid )
+ {
+ this.source = source;
+ this.oid = oid;
+ }
+
+
+ /**
+ * Gets the source object.
+ *
+ * @return
+ * the source object
+ */
+ public SchemaObject getSource()
+ {
+ return source;
+ }
+
+
+ /**
+ * Gets the syntax OID.
+ *
+ * @return
+ * the syntax OID
+ */
+ public String getSyntaxOid()
+ {
+ return oid;
+ }
+
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString()
+ {
+ return "[NonExistingSyntaxError - Source: " + getSource() + " - OID: " + getSyntaxOid() + "]";
+ }
+}
\ No newline at end of file
Added: 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?view=auto&rev=553917
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/SchemaChecker.java (added)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/SchemaChecker.java Fri Jul 6 08:05:33 2007
@@ -0,0 +1,560 @@
+/*
+ * 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 java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.commons.collections.MultiMap;
+import org.apache.commons.collections.map.MultiValueMap;
+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;
+import org.apache.directory.studio.apacheds.schemaeditor.controller.SchemaHandlerListener;
+import org.apache.directory.studio.apacheds.schemaeditor.model.AttributeTypeImpl;
+import org.apache.directory.studio.apacheds.schemaeditor.model.MatchingRuleImpl;
+import org.apache.directory.studio.apacheds.schemaeditor.model.ObjectClassImpl;
+import org.apache.directory.studio.apacheds.schemaeditor.model.Schema;
+import org.apache.directory.studio.apacheds.schemaeditor.model.SyntaxImpl;
+import org.apache.directory.studio.apacheds.schemaeditor.model.schemachecker.NonExistingMatchingRuleError.NonExistingMatchingRuleErrorEnum;
+
+
+/**
+ * This class represents the SchemaChecker.
+ * <p>
+ * It is used to check the schema integrity.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SchemaChecker
+{
+ /** The SchemaHandler */
+ private SchemaHandler schemaHandler;
+
+ /** The errors List */
+ private List<SchemaError> errorsList;
+
+ /** The errors MultiMap */
+ private MultiMap errorsMap;
+
+ /** The warnings List */
+ private List<SchemaWarning> warningsList;
+
+ /** The warnings MultiMap */
+ private MultiMap warningsMap;
+
+ /** The 'listening to modifications' flag*/
+ private boolean listeningToModifications = false;
+
+ /** The SchemaHandlerListener */
+ private SchemaHandlerListener schemaHandlerListener = new SchemaHandlerListener()
+ {
+ public void attributeTypeAdded( AttributeTypeImpl at )
+ {
+ // TODO Auto-generated method stub
+ System.out.println( "AT Added" );
+ checkAttributeType( at );
+ }
+
+
+ public void attributeTypeModified( AttributeTypeImpl at )
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ public void attributeTypeRemoved( AttributeTypeImpl at )
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ public void matchingRuleAdded( MatchingRuleImpl mr )
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ public void matchingRuleModified( MatchingRuleImpl mr )
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ public void matchingRuleRemoved( MatchingRuleImpl mr )
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ public void objectClassAdded( ObjectClassImpl oc )
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ public void objectClassModified( ObjectClassImpl oc )
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ public void objectClassRemoved( ObjectClassImpl oc )
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ public void schemaAdded( Schema schema )
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ public void schemaRemoved( Schema schema )
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ public void syntaxAdded( SyntaxImpl syntax )
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ public void syntaxModified( SyntaxImpl syntax )
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ public void syntaxRemoved( SyntaxImpl syntax )
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ };
+
+
+ /**
+ * Creates a new instance of SchemaChecker.
+ */
+ public SchemaChecker()
+ {
+ schemaHandler = Activator.getDefault().getSchemaHandler();
+ errorsList = new ArrayList<SchemaError>();
+ errorsMap = new MultiValueMap();
+ warningsList = new ArrayList<SchemaWarning>();
+ warningsMap = new MultiValueMap();
+ }
+
+
+ /**
+ * Enables modifications listening.
+ */
+ public void enableModificationsListening()
+ {
+ if ( !listeningToModifications )
+ {
+ schemaHandler.addListener( schemaHandlerListener );
+ listeningToModifications = true;
+ checkWholeSchema();
+ }
+ }
+
+
+ /**
+ * Disables modifications listening.
+ */
+ public void disableModificationsListening()
+ {
+ if ( listeningToModifications )
+ {
+ schemaHandler.removeListener( schemaHandlerListener );
+ listeningToModifications = false;
+ clearErrorsAndWarnings();
+ }
+ }
+
+
+ /**
+ * Returns true if the SchemaChecker is listening to modifications,
+ * false if not.
+ *
+ * @return
+ * true if the SchemaChecker is listening to modifications,
+ * false if not
+ */
+ public boolean isListeningToModifications()
+ {
+ return listeningToModifications;
+ }
+
+
+ /**
+ * Clears all the errors and warnings.
+ */
+ private void clearErrorsAndWarnings()
+ {
+ errorsList.clear();
+ errorsMap.clear();
+ warningsList.clear();
+ warningsMap.clear();
+ }
+
+
+ /**
+ * Checks the whole schema.
+ */
+ private void checkWholeSchema()
+ {
+ List<Schema> schemas = schemaHandler.getSchemas();
+ for ( Schema schema : schemas )
+ {
+ List<AttributeTypeImpl> ats = schema.getAttributeTypes();
+ for ( AttributeTypeImpl at : ats )
+ {
+ checkAttributeType( at );
+ }
+
+ List<ObjectClassImpl> ocs = schema.getObjectClasses();
+ for ( ObjectClassImpl oc : ocs )
+ {
+ checkObjectClass( oc );
+ }
+ }
+ }
+
+
+ /**
+ * Checks the given attribute type.
+ *
+ * @param at
+ * an attribute type
+ */
+ private void checkAttributeType( AttributeTypeImpl at )
+ {
+ removeSchemaObject( at );
+
+ // Checking OID
+ String oid = at.getOid();
+ if ( ( oid != null ) && ( !"".equals( oid ) ) )
+ {
+ List<?> list = getSchemaElementList( oid );
+ if ( ( list != null ) && ( list.size() >= 2 ) )
+ {
+ int counter = 0;
+ Object o = list.get( counter );
+ while ( ( at.equals( o ) ) && ( counter < ( list.size() - 1 ) ) )
+ {
+ counter++;
+ o = list.get( counter );
+ }
+ SchemaError error = new DuplicateOidError( at, oid, ( SchemaObject ) o );
+ errorsList.add( error );
+ errorsMap.put( at, error );
+ }
+ }
+
+ // Checking aliases
+ String[] aliases = at.getNames();
+ if ( ( aliases != null ) && ( aliases.length >= 1 ) )
+ {
+ for ( String alias : aliases )
+ {
+ List<?> list = getSchemaElementList( alias );
+ if ( ( list != null ) && ( list.size() >= 2 ) )
+ {
+ int counter = 0;
+ Object o = list.get( counter );
+ while ( ( at.equals( o ) ) && ( counter < ( list.size() - 1 ) ) )
+ {
+ counter++;
+ o = list.get( counter );
+ }
+ SchemaError error = new DuplicateAliasError( at, oid, ( SchemaObject ) o );
+ errorsList.add( error );
+ errorsMap.put( at, error );
+ }
+ }
+ }
+
+ // Checking superior
+ String superior = at.getSuperiorName();
+ if ( ( superior != null ) && ( !"".equals( superior ) ) )
+ {
+ if ( schemaHandler.getAttributeType( superior ) == null )
+ {
+ SchemaError error = new NonExistingATSuperiorError( at, superior );
+ errorsList.add( error );
+ errorsMap.put( at, error );
+ }
+ }
+
+ // Checking syntax
+ String syntaxOid = at.getSyntaxOid();
+ if ( ( syntaxOid != null ) && ( !"".equals( syntaxOid ) ) )
+ {
+ if ( schemaHandler.getSyntax( syntaxOid ) == null )
+ {
+ SchemaError error = new NonExistingSyntaxError( at, syntaxOid );
+ errorsList.add( error );
+ errorsMap.put( at, error );
+ }
+ }
+
+ // Equality matching rule
+ String equality = at.getEqualityName();
+ if ( ( equality != null ) && ( !"".equals( equality ) ) )
+ {
+ if ( schemaHandler.getMatchingRule( equality ) == null )
+ {
+ SchemaError error = new NonExistingMatchingRuleError( at, equality,
+ NonExistingMatchingRuleErrorEnum.EQUALITY );
+ errorsList.add( error );
+ errorsMap.put( at, error );
+ }
+ }
+
+ // Ordering matching rule
+ String ordering = at.getOrderingName();
+ if ( ( ordering != null ) && ( !"".equals( ordering ) ) )
+ {
+ if ( schemaHandler.getMatchingRule( ordering ) == null )
+ {
+ SchemaError error = new NonExistingMatchingRuleError( at, ordering,
+ NonExistingMatchingRuleErrorEnum.ORDERING );
+ errorsList.add( error );
+ errorsMap.put( at, error );
+ }
+ }
+
+ // Substring matching rule
+ String substring = at.getSubstrName();
+ if ( ( substring != null ) && ( !"".equals( substring ) ) )
+ {
+ if ( schemaHandler.getMatchingRule( substring ) == null )
+ {
+ SchemaError error = new NonExistingMatchingRuleError( at, substring,
+ NonExistingMatchingRuleErrorEnum.SUBSTRING );
+ errorsList.add( error );
+ errorsMap.put( at, error );
+ }
+ }
+ }
+
+
+ /**
+ * Checks the given object class.
+ *
+ * @param oc
+ * an object class
+ */
+ private void checkObjectClass( ObjectClassImpl oc )
+ {
+ removeSchemaObject( oc );
+
+ // Checking OID
+ String oid = oc.getOid();
+ if ( ( oid != null ) && ( !"".equals( oid ) ) )
+ {
+ List<?> list = getSchemaElementList( oid );
+ if ( ( list != null ) && ( list.size() >= 2 ) )
+ {
+ int counter = 0;
+ Object o = list.get( counter );
+ while ( ( oc.equals( o ) ) && ( counter < ( list.size() - 1 ) ) )
+ {
+ counter++;
+ o = list.get( counter );
+ }
+ SchemaError error = new DuplicateOidError( oc, oid, ( SchemaObject ) o );
+ errorsList.add( error );
+ errorsMap.put( oc, error );
+ }
+ }
+
+ // Checking aliases
+ String[] aliases = oc.getNames();
+ if ( ( aliases != null ) && ( aliases.length >= 1 ) )
+ {
+ for ( String alias : aliases )
+ {
+ List<?> list = getSchemaElementList( alias );
+ if ( ( list != null ) && ( list.size() >= 2 ) )
+ {
+ int counter = 0;
+ Object o = list.get( counter );
+ while ( ( oc.equals( o ) ) && ( counter < ( list.size() - 1 ) ) )
+ {
+ counter++;
+ o = list.get( counter );
+ }
+ SchemaError error = new DuplicateAliasError( oc, oid, ( SchemaObject ) o );
+ errorsList.add( error );
+ errorsMap.put( oc, error );
+ }
+ }
+ }
+
+ // Checking superiors
+ String[] superiors = oc.getSuperClassesNames();
+ if ( ( superiors != null ) && ( superiors.length >= 1 ) )
+ {
+ for ( String superior : superiors )
+ {
+ if ( schemaHandler.getObjectClass( superior ) == null )
+ {
+ SchemaError error = new NonExistingOCSuperiorError( oc, superior );
+ errorsList.add( error );
+ errorsMap.put( oc, error );
+ }
+ }
+ }
+
+ // Checking mandatory and optional attributes
+ String[] mandatoryATs = oc.getMustNamesList();
+ String[] optionalATs = oc.getMayNamesList();
+ if ( ( mandatoryATs != null ) && ( optionalATs != null ) )
+ {
+ List<String> mandatoryATsList = Arrays.asList( mandatoryATs );
+ List<String> optionalATsList = Arrays.asList( optionalATs );
+
+ for ( String mandatoryAT : mandatoryATsList )
+ {
+ if ( optionalATsList.contains( mandatoryAT ) )
+ {
+ SchemaError error = new DuplicateMandatoryOptionalAttributeError( oc, mandatoryAT );
+ errorsList.add( error );
+ errorsMap.put( oc, error );
+ }
+ }
+
+ }
+ }
+
+
+ /**
+ * Remove the errors and warnings for the given schema element.
+ *
+ * @param element
+ * a schema element
+ */
+ private void removeSchemaObject( SchemaObject element )
+ {
+ // Removing old errors and warnings
+ List<?> errors = ( List<?> ) errorsMap.get( element );
+ if ( ( errors != null ) && ( errors.size() >= 1 ) )
+ {
+ for ( Object error : errors )
+ {
+ errorsList.remove( error );
+ }
+ }
+ errorsMap.remove( element );
+ List<?> warnings = ( List<?> ) warningsMap.get( element );
+ if ( ( warnings != null ) && ( warnings.size() >= 1 ) )
+ {
+ for ( Object warning : warnings )
+ {
+ warningsList.remove( warning );
+ }
+ }
+ warningsMap.remove( element );
+ }
+
+
+ @SuppressWarnings("unchecked")
+ private List<?> getSchemaElementList( String id )
+ {
+ List results = new ArrayList<Object>();
+
+ // Attribute types
+ List<?> atList = schemaHandler.getAttributeTypeList( id );
+ if ( ( atList != null ) && ( atList.size() >= 1 ) )
+ {
+ results.addAll( atList );
+ }
+
+ // Object classes
+ List<?> ocList = schemaHandler.getObjectClassList( id );
+ 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;
+ }
+
+
+ /**
+ * Gets the errors.
+ *
+ * @return
+ * the errors
+ */
+ public List<SchemaError> getErrors()
+ {
+ return errorsList;
+ }
+
+
+ /**
+ * Gets the warnings.
+ *
+ * @return
+ * the warnings
+ */
+ public List<SchemaWarning> getWarnings()
+ {
+ return warningsList;
+ }
+}
Added: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/SchemaError.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/SchemaError.java?view=auto&rev=553917
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/SchemaError.java (added)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/SchemaError.java Fri Jul 6 08:05:33 2007
@@ -0,0 +1,31 @@
+/*
+ * 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;
+
+
+/**
+ * Common interface for the all the schema errors.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface SchemaError
+{
+}
Added: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/SchemaWarning.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/SchemaWarning.java?view=auto&rev=553917
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/SchemaWarning.java (added)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/schemachecker/SchemaWarning.java Fri Jul 6 08:05:33 2007
@@ -0,0 +1,31 @@
+/*
+ * 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;
+
+
+/**
+ * Common interface for all the schema warnings.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface SchemaWarning
+{
+}
Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/widget/SchemaSourceViewerConfiguration.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/widget/SchemaSourceViewerConfiguration.java?view=diff&rev=553917&r1=553916&r2=553917
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/widget/SchemaSourceViewerConfiguration.java (original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/view/widget/SchemaSourceViewerConfiguration.java Fri Jul 6 08:05:33 2007
@@ -46,7 +46,7 @@
reconciler.setDocumentPartitioning( getConfiguredDocumentPartitioning( sourceViewer ) );
// Creating the damager/repairer for code
- DefaultDamagerRepairer dr = new DefaultDamagerRepairer( Activator.getSchemaCodeScanner() );
+ DefaultDamagerRepairer dr = new DefaultDamagerRepairer( Activator.getDefault().getSchemaCodeScanner() );
reconciler.setDamager( dr, IDocument.DEFAULT_CONTENT_TYPE );
reconciler.setRepairer( dr, IDocument.DEFAULT_CONTENT_TYPE );