directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r1211420 - in /directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor: model/ model/io/ view/wizards/
Date Wed, 07 Dec 2011 13:01:22 GMT
Author: pamarcelot
Date: Wed Dec  7 13:01:21 2011
New Revision: 1211420

URL: http://svn.apache.org/viewvc?rev=1211420&view=rev
Log:
Fix for DIRSTUDIO-752 (Improve fault tolerance when reading an online schema from a connection).

Added:
    directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/SchemaConnectorException.java
Modified:
    directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/Project.java
    directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/ApacheDsSchemaConnector.java
    directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/GenericSchemaConnector.java
    directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/ProjectsExporter.java
    directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/ProjectsImporter.java
    directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/SchemaConnector.java
    directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/messages.properties
    directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/messages_de.properties
    directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/messages_fr.properties
    directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/CommitChangesDifferencesWizardPage.java
    directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewProjectWizard.java
    directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/messages.properties
    directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/messages_de.properties
    directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/messages_fr.properties

Modified: directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/Project.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/Project.java?rev=1211420&r1=1211419&r2=1211420&view=diff
==============================================================================
--- directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/Project.java
(original)
+++ directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/Project.java
Wed Dec  7 13:01:21 2011
@@ -26,6 +26,7 @@ import org.apache.directory.studio.commo
 import org.apache.directory.studio.connection.core.Connection;
 import org.apache.directory.studio.schemaeditor.controller.SchemaHandler;
 import org.apache.directory.studio.schemaeditor.model.io.SchemaConnector;
+import org.apache.directory.studio.schemaeditor.model.io.SchemaConnectorException;
 
 
 /**
@@ -66,8 +67,8 @@ public class Project
     /** The SchemaHandler */
     private SchemaHandler schemaHandler;
 
-    /** The backup of the Online Schema */
-    private List<Schema> schemaBackup;
+    /** The initial schema of the Online Schema */
+    private List<Schema> initialSchema;
 
     /** The flag for Online Schema Fetch */
     private boolean hasOnlineSchemaBeenFetched = false;
@@ -246,24 +247,27 @@ public class Project
     {
         if ( ( !hasOnlineSchemaBeenFetched ) && ( connection != null ) &&
( schemaConnector != null ) )
         {
-            schemaBackup = schemaConnector.importSchema( connection, monitor );
-            for ( Schema schema : schemaBackup )
+            try
             {
-                schema.setProject( this );
+                schemaConnector.importSchema( this, monitor );
+            }
+            catch ( SchemaConnectorException e )
+            {
+                monitor.reportError( e );
             }
 
-            if ( schemaBackup != null )
+            // Adding each schema to the schema handler
+            if ( initialSchema != null )
             {
-                monitor.beginTask( Messages.getString( "Project.AddingSchemaToProject" ),
schemaBackup.size() ); //$NON-NLS-1$
-                for ( Schema schema : schemaBackup )
+                monitor.beginTask( Messages.getString( "Project.AddingSchemaToProject" ),
initialSchema.size() ); //$NON-NLS-1$
+                for ( Schema schema : initialSchema )
                 {
                     getSchemaHandler().addSchema( schema );
                 }
             }
 
-            // TODO Add error Handling
-            monitor.done();
             hasOnlineSchemaBeenFetched = true;
+            monitor.done();
         }
     }
 
@@ -281,26 +285,24 @@ public class Project
 
 
     /**
-     * Gets the Schema Backup.
+     * Gets the initial schema.
      *
-     * @return
-     *      the Schema Backup
+     * @return the initial schema
      */
-    public List<Schema> getSchemaBackup()
+    public List<Schema> getInitialSchema()
     {
-        return schemaBackup;
+        return initialSchema;
     }
 
 
     /**
-     * Sets the Schema Backup
+     * Sets the initial schema.
      *
-     * @param schemaBackup
-     *      the Schema Backup
+     * @param initialSchema the initial schema
      */
-    public void setSchemaBackup( List<Schema> schemaBackup )
+    public void setInitialSchema( List<Schema> initialSchema )
     {
-        this.schemaBackup = schemaBackup;
+        this.initialSchema = initialSchema;
     }
 
 

Modified: directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/ApacheDsSchemaConnector.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/ApacheDsSchemaConnector.java?rev=1211420&r1=1211419&r2=1211420&view=diff
==============================================================================
--- directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/ApacheDsSchemaConnector.java
(original)
+++ directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/ApacheDsSchemaConnector.java
Wed Dec  7 13:01:21 2011
@@ -40,6 +40,7 @@ import org.apache.directory.studio.conne
 import org.apache.directory.studio.connection.core.Connection.AliasDereferencingMethod;
 import org.apache.directory.studio.connection.core.Connection.ReferralHandlingMethod;
 import org.apache.directory.studio.connection.core.io.ConnectionWrapper;
+import org.apache.directory.studio.schemaeditor.model.Project;
 import org.apache.directory.studio.schemaeditor.model.Schema;
 
 
@@ -79,23 +80,13 @@ public class ApacheDsSchemaConnector ext
     /**
      * {@inheritDoc}
      */
-    public void exportSchema( Connection connection, StudioProgressMonitor monitor )
-    {
-        // TODO Auto-generated method stub
-
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public List<Schema> importSchema( Connection connection, StudioProgressMonitor
monitor )
+    public void importSchema( Project project, StudioProgressMonitor monitor )
+        throws SchemaConnectorException
     {
+        monitor.beginTask( Messages.getString( "ApacheDsSchemaConnector.FetchingSchema" ),
1 ); //$NON-NLS-1$
         List<Schema> schemas = new ArrayList<Schema>();
-
-        ConnectionWrapper wrapper = connection.getConnectionWrapper();
-
-        monitor.beginTask( Messages.getString( "GenericSchemaConnector.FetchingSchema" ),
1 ); //$NON-NLS-1$
+        project.setInitialSchema( schemas );
+        ConnectionWrapper wrapper = project.getConnection().getConnectionWrapper();
 
         // Looking for all the defined schemas
         SearchControls constraintSearch = new SearchControls();
@@ -122,21 +113,20 @@ public class ApacheDsSchemaConnector ext
                     {
                         while ( ne.hasMore() )
                         {
-                            String value = ( String ) ne.next();
-                            schemas.add( getSchema( wrapper, value, monitor ) );
+                            Schema schema = getSchema( wrapper, ( String ) ne.next(), monitor
);
+                            schema.setProject( project );
+                            schemas.add( schema );
                         }
                     }
                 }
             }
-            catch ( NamingException e )
+            catch ( Exception e )
             {
-                monitor.reportError( e );
+                throw new SchemaConnectorException( e );
             }
         }
 
         monitor.worked( 1 );
-
-        return schemas;
     }
 
 
@@ -906,4 +896,14 @@ public class ApacheDsSchemaConnector ext
             return Boolean.parseBoolean( ( String ) at.get() );
         }
     }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void exportSchema( Project project, StudioProgressMonitor monitor )
+        throws SchemaConnectorException
+    {
+        // TODO Auto-generated method stub
+    }
 }

Modified: directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/GenericSchemaConnector.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/GenericSchemaConnector.java?rev=1211420&r1=1211419&r2=1211420&view=diff
==============================================================================
--- directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/GenericSchemaConnector.java
(original)
+++ directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/GenericSchemaConnector.java
Wed Dec  7 13:01:21 2011
@@ -44,7 +44,10 @@ import org.apache.directory.studio.conne
 import org.apache.directory.studio.connection.core.Connection.ReferralHandlingMethod;
 import org.apache.directory.studio.connection.core.Utils;
 import org.apache.directory.studio.connection.core.io.ConnectionWrapper;
+import org.apache.directory.studio.schemaeditor.PluginUtils;
+import org.apache.directory.studio.schemaeditor.model.Project;
 import org.apache.directory.studio.schemaeditor.model.Schema;
+import org.eclipse.osgi.util.NLS;
 
 
 /**
@@ -61,56 +64,48 @@ public class GenericSchemaConnector exte
     /**
      * {@inheritDoc}
      */
-    public void exportSchema( Connection connection, StudioProgressMonitor monitor )
+    public void importSchema( Project project, StudioProgressMonitor monitor )
+        throws SchemaConnectorException
     {
-        // TODO Auto-generated method stub
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public List<Schema> importSchema( Connection connection, StudioProgressMonitor
monitor )
-    {
-        List<Schema> schemas = new ArrayList<Schema>();
-
-        ConnectionWrapper wrapper = connection.getConnectionWrapper();
-
         monitor.beginTask( Messages.getString( "GenericSchemaConnector.FetchingSchema" ),
1 ); //$NON-NLS-1$
+        List<Schema> schemas = new ArrayList<Schema>();
+        project.setInitialSchema( schemas );
+        ConnectionWrapper wrapper = project.getConnection().getConnectionWrapper();
 
         SearchControls constraintSearch = new SearchControls();
         constraintSearch.setSearchScope( SearchControls.OBJECT_SCOPE );
         constraintSearch.setReturningAttributes( new String[]
             { "attributeTypes", "objectClasses", "ldapSyntaxes", "matchingRules" } );
-        String schemaDn = getSubschemaSubentry( connection, monitor );
+        String schemaDn = getSubschemaSubentry( wrapper, monitor );
         NamingEnumeration<SearchResult> answer = wrapper.search( schemaDn, "(objectclass=subschema)",
constraintSearch,
             DEREF_ALIAS_METHOD, HANDLE_REFERALS_METHOD, null, ( StudioProgressMonitor ) monitor,
null );
         if ( answer != null )
         {
             try
             {
+                // Looping the results
                 while ( answer.hasMore() )
                 {
-                    SearchResult searchResult = ( SearchResult ) answer.next();
-                    try
-                    {
-                        schemas.add( getSchema( wrapper, searchResult, monitor ) );
-                    }
-                    catch ( Exception e )
-                    {
-                        monitor.reportError( e );
-                    }
+                    // Creating the schema
+                    Schema schema = new Schema( "schema" ); //$NON-NLS-1$
+                    schema.setProject( project );
+                    schemas.add( schema );
+
+                    getSchema( schema, wrapper, ( SearchResult ) answer.next(), monitor );
                 }
+
             }
-            catch ( NamingException e )
+            catch ( SchemaConnectorException e )
             {
-                monitor.reportError( e );
+                throw e;
+            }
+            catch ( Exception e )
+            {
+                throw new SchemaConnectorException( e );
             }
         }
 
         monitor.worked( 1 );
-
-        return schemas;
     }
 
 
@@ -119,14 +114,12 @@ public class GenericSchemaConnector exte
      */
     public boolean isSuitableConnector( Connection connection, StudioProgressMonitor monitor
)
     {
-        return getSubschemaSubentry( connection, monitor ) != null;
+        return getSubschemaSubentry( connection.getConnectionWrapper(), monitor ) != null;
     }
 
 
-    private static String getSubschemaSubentry( Connection connection, StudioProgressMonitor
monitor )
+    private static String getSubschemaSubentry( ConnectionWrapper wrapper, StudioProgressMonitor
monitor )
     {
-        ConnectionWrapper wrapper = connection.getConnectionWrapper();
-
         SearchControls constraintSearch = new SearchControls();
         constraintSearch.setSearchScope( SearchControls.OBJECT_SCOPE );
         constraintSearch.setReturningAttributes( new String[]
@@ -177,11 +170,11 @@ public class GenericSchemaConnector exte
     }
 
 
-    private static Schema getSchema( ConnectionWrapper wrapper, SearchResult searchResult,
-        StudioProgressMonitor monitor ) throws NamingException, ParseException
+    private static void getSchema( Schema schema, ConnectionWrapper wrapper, SearchResult
searchResult,
+        StudioProgressMonitor monitor ) throws NamingException, SchemaConnectorException
     {
-        // Creating the schema
-        Schema schema = new Schema( "schema" ); //$NON-NLS-1$
+        // The counter for parser exceptions
+        int parseErrorCount = 0;
 
         Attribute attributeTypesAttribute = searchResult.getAttributes().get( "attributeTypes"
);
         if ( attributeTypesAttribute != null )
@@ -192,33 +185,44 @@ public class GenericSchemaConnector exte
                 while ( ne.hasMoreElements() )
                 {
                     String value = ( String ) ne.nextElement();
-                    AttributeTypeDescriptionSchemaParser parser = new AttributeTypeDescriptionSchemaParser();
-                    parser.setQuirksMode( true );
-                    AttributeType atd = parser.parseAttributeTypeDescription( value );
-
-                    AttributeType impl = new AttributeType( atd.getOid() );
-                    impl.setNames( atd.getNames().toArray( new String[0] ) );
-                    impl.setDescription( atd.getDescription() );
-                    impl.setSuperiorOid( atd.getSuperiorOid() );
-                    impl.setUsage( atd.getUsage() );
-                    impl.setSyntaxOid( atd.getSyntaxOid() );
-                    impl.setSyntaxLength( atd.getSyntaxLength() );
-                    impl.setObsolete( atd.isObsolete() );
-                    impl.setCollective( atd.isCollective() );
-                    impl.setSingleValued( atd.isSingleValued() );
-                    impl.setUserModifiable( atd.isUserModifiable() );
-                    impl.setEqualityOid( atd.getEqualityOid() );
-                    impl.setOrderingOid( atd.getOrderingOid() );
-                    impl.setSubstringOid( atd.getSubstringOid() );
-                    impl.setSchemaName( schema.getSchemaName() );
 
-                    // Active Directory hack
-                    if ( impl.getSyntaxOid() != null && "OctetString".equalsIgnoreCase(
impl.getSyntaxOid() ) ) //$NON-NLS-1$
+                    try
                     {
-                        impl.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.40" );
-                    }
+                        AttributeTypeDescriptionSchemaParser parser = new AttributeTypeDescriptionSchemaParser();
+                        parser.setQuirksMode( true );
+
+                        AttributeType atd = parser.parseAttributeTypeDescription( value );
+
+                        AttributeType impl = new AttributeType( atd.getOid() );
+                        impl.setNames( atd.getNames().toArray( new String[0] ) );
+                        impl.setDescription( atd.getDescription() );
+                        impl.setSuperiorOid( atd.getSuperiorOid() );
+                        impl.setUsage( atd.getUsage() );
+                        impl.setSyntaxOid( atd.getSyntaxOid() );
+                        impl.setSyntaxLength( atd.getSyntaxLength() );
+                        impl.setObsolete( atd.isObsolete() );
+                        impl.setCollective( atd.isCollective() );
+                        impl.setSingleValued( atd.isSingleValued() );
+                        impl.setUserModifiable( atd.isUserModifiable() );
+                        impl.setEqualityOid( atd.getEqualityOid() );
+                        impl.setOrderingOid( atd.getOrderingOid() );
+                        impl.setSubstringOid( atd.getSubstringOid() );
+                        impl.setSchemaName( schema.getSchemaName() );
+
+                        // Active Directory hack
+                        if ( impl.getSyntaxOid() != null && "OctetString".equalsIgnoreCase(
impl.getSyntaxOid() ) ) //$NON-NLS-1$
+                        {
+                            impl.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.40" );
+                        }
 
-                    schema.addAttributeType( impl );
+                        schema.addAttributeType( impl );
+                    }
+                    catch ( ParseException e )
+                    {
+                        // Logging the exception and incrementing the counter
+                        PluginUtils.logError( "Unable to parse the attribute type.", e );
+                        parseErrorCount++;
+                    }
                 }
             }
         }
@@ -232,21 +236,31 @@ public class GenericSchemaConnector exte
                 while ( ne.hasMoreElements() )
                 {
                     String value = ( String ) ne.nextElement();
-                    ObjectClassDescriptionSchemaParser parser = new ObjectClassDescriptionSchemaParser();
-                    parser.setQuirksMode( true );
-                    ObjectClass ocd = parser.parseObjectClassDescription( value );
-
-                    ObjectClass impl = new ObjectClass( ocd.getOid() );
-                    impl.setNames( ocd.getNames().toArray( new String[0] ) );
-                    impl.setDescription( ocd.getDescription() );
-                    impl.setSuperiorOids( ocd.getSuperiorOids() );
-                    impl.setType( ocd.getType() );
-                    impl.setObsolete( ocd.isObsolete() );
-                    impl.setMustAttributeTypeOids( ocd.getMustAttributeTypeOids() );
-                    impl.setMayAttributeTypeOids( ocd.getMayAttributeTypeOids() );
-                    impl.setSchemaName( schema.getSchemaName() );
 
-                    schema.addObjectClass( impl );
+                    try
+                    {
+                        ObjectClassDescriptionSchemaParser parser = new ObjectClassDescriptionSchemaParser();
+                        parser.setQuirksMode( true );
+                        ObjectClass ocd = parser.parseObjectClassDescription( value );
+
+                        ObjectClass impl = new ObjectClass( ocd.getOid() );
+                        impl.setNames( ocd.getNames().toArray( new String[0] ) );
+                        impl.setDescription( ocd.getDescription() );
+                        impl.setSuperiorOids( ocd.getSuperiorOids() );
+                        impl.setType( ocd.getType() );
+                        impl.setObsolete( ocd.isObsolete() );
+                        impl.setMustAttributeTypeOids( ocd.getMustAttributeTypeOids() );
+                        impl.setMayAttributeTypeOids( ocd.getMayAttributeTypeOids() );
+                        impl.setSchemaName( schema.getSchemaName() );
+
+                        schema.addObjectClass( impl );
+                    }
+                    catch ( ParseException e )
+                    {
+                        // Logging the exception and incrementing the counter
+                        PluginUtils.logError( "Unable to parse the object class.", e );
+                        parseErrorCount++;
+                    }
                 }
             }
         }
@@ -260,22 +274,33 @@ public class GenericSchemaConnector exte
                 while ( ne.hasMoreElements() )
                 {
                     String value = ( String ) ne.nextElement();
-                    LdapSyntaxDescriptionSchemaParser parser = new LdapSyntaxDescriptionSchemaParser();
-                    parser.setQuirksMode( true );
-                    LdapSyntax lsd = parser.parseLdapSyntaxDescription( value );
-
-                    LdapSyntax impl = new LdapSyntax( lsd.getOid() );
-                    impl.setDescription( lsd.getDescription() );
-                    impl.setNames( new String[]
-                        { lsd.getDescription() } );
-                    //impl.setObsolete( lsd.isObsolete() );
-                    impl.setHumanReadable( true );
-                    impl.setSchemaName( schema.getSchemaName() );
 
-                    schema.addSyntax( impl );
+                    try
+                    {
+                        LdapSyntaxDescriptionSchemaParser parser = new LdapSyntaxDescriptionSchemaParser();
+                        parser.setQuirksMode( true );
+                        LdapSyntax lsd = parser.parseLdapSyntaxDescription( value );
+
+                        LdapSyntax impl = new LdapSyntax( lsd.getOid() );
+                        impl.setDescription( lsd.getDescription() );
+                        impl.setNames( new String[]
+                            { lsd.getDescription() } );
+                        //impl.setObsolete( lsd.isObsolete() );
+                        impl.setHumanReadable( true );
+                        impl.setSchemaName( schema.getSchemaName() );
+
+                        schema.addSyntax( impl );
+                    }
+                    catch ( ParseException e )
+                    {
+                        // Logging the exception and incrementing the counter
+                        PluginUtils.logError( "Unable to parse the syntax.", e );
+                        parseErrorCount++;
+                    }
                 }
             }
         }
+
         // if online: assume all received syntaxes in attributes are valid -> create dummy
syntaxes if missing
         for ( AttributeType at : schema.getAttributeTypes() )
         {
@@ -301,21 +326,32 @@ public class GenericSchemaConnector exte
                 while ( ne.hasMoreElements() )
                 {
                     String value = ( String ) ne.nextElement();
-                    MatchingRuleDescriptionSchemaParser parser = new MatchingRuleDescriptionSchemaParser();
-                    parser.setQuirksMode( true );
-                    MatchingRule mrd = parser.parseMatchingRuleDescription( value );
-
-                    MatchingRule impl = new MatchingRule( mrd.getOid() );
-                    impl.setDescription( mrd.getDescription() );
-                    impl.setNames( mrd.getNames().toArray( new String[0] ) );
-                    impl.setObsolete( mrd.isObsolete() );
-                    impl.setSyntaxOid( mrd.getSyntaxOid() );
-                    impl.setSchemaName( schema.getSchemaName() );
 
-                    schema.addMatchingRule( impl );
+                    try
+                    {
+                        MatchingRuleDescriptionSchemaParser parser = new MatchingRuleDescriptionSchemaParser();
+                        parser.setQuirksMode( true );
+                        MatchingRule mrd = parser.parseMatchingRuleDescription( value );
+
+                        MatchingRule impl = new MatchingRule( mrd.getOid() );
+                        impl.setDescription( mrd.getDescription() );
+                        impl.setNames( mrd.getNames().toArray( new String[0] ) );
+                        impl.setObsolete( mrd.isObsolete() );
+                        impl.setSyntaxOid( mrd.getSyntaxOid() );
+                        impl.setSchemaName( schema.getSchemaName() );
+
+                        schema.addMatchingRule( impl );
+                    }
+                    catch ( ParseException e )
+                    {
+                        // Logging the exception and incrementing the counter
+                        PluginUtils.logError( "Unable to parse the matching rule.", e );
+                        parseErrorCount++;
+                    }
                 }
             }
         }
+
         // if online: assume all received matching rules in attributes are valid -> create
dummy matching rules if missing
         for ( AttributeType at : schema.getAttributeTypes() )
         {
@@ -325,7 +361,22 @@ public class GenericSchemaConnector exte
             checkMatchingRules( schema, equalityName, orderingName, substrName );
         }
 
-        return schema;
+        // Showing an error
+        if ( parseErrorCount > 0 )
+        {
+            if ( parseErrorCount == 1 )
+            {
+                throw new SchemaConnectorException(
+                    Messages.getString( "GenericSchemaConnector.OneSchemaElementCouldNotBeParsedError"
) ); //$NON-NLS-1$
+
+            }
+            else
+            {
+                throw new SchemaConnectorException( NLS.bind(
+                    Messages.getString( "GenericSchemaConnector.MultipleSchemaElementsCouldNotBeParsedError"
), //$NON-NLS-1$
+                    parseErrorCount ) );
+            }
+        }
     }
 
 
@@ -345,4 +396,13 @@ public class GenericSchemaConnector exte
         }
     }
 
+
+    /**
+     * {@inheritDoc}
+     */
+    public void exportSchema( Project project, StudioProgressMonitor monitor )
+        throws SchemaConnectorException
+    {
+        // TODO Auto-generated method stub
+    }
 }

Modified: directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/ProjectsExporter.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/ProjectsExporter.java?rev=1211420&r1=1211419&r2=1211420&view=diff
==============================================================================
--- directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/ProjectsExporter.java
(original)
+++ directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/ProjectsExporter.java
Wed Dec  7 13:01:21 2011
@@ -136,7 +136,7 @@ public class ProjectsExporter
 
                 // Schema Backup
                 Element schemaBackupElement = element.addElement( SCHEMA_BACKUP_TAG );
-                List<Schema> backupSchemas = project.getSchemaBackup();
+                List<Schema> backupSchemas = project.getInitialSchema();
                 if ( backupSchemas != null )
                 {
                     XMLSchemaFileExporter.addSchemas( backupSchemas.toArray( new Schema[0]
), schemaBackupElement );

Modified: directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/ProjectsImporter.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/ProjectsImporter.java?rev=1211420&r1=1211419&r2=1211420&view=diff
==============================================================================
--- directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/ProjectsImporter.java
(original)
+++ directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/ProjectsImporter.java
Wed Dec  7 13:01:21 2011
@@ -242,7 +242,7 @@ public class ProjectsImporter
                         throw new ProjectsImportException( Messages.getString( "ProjectsImporter.NotConvertableSchema"
) ); //$NON-NLS-1$
                     }
 
-                    project.setSchemaBackup( Arrays.asList( schemas ) );
+                    project.setInitialSchema( Arrays.asList( schemas ) );
                 }
             }
         }

Modified: directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/SchemaConnector.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/SchemaConnector.java?rev=1211420&r1=1211419&r2=1211420&view=diff
==============================================================================
--- directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/SchemaConnector.java
(original)
+++ directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/SchemaConnector.java
Wed Dec  7 13:01:21 2011
@@ -20,11 +20,9 @@
 package org.apache.directory.studio.schemaeditor.model.io;
 
 
-import java.util.List;
-
 import org.apache.directory.studio.common.core.jobs.StudioProgressMonitor;
 import org.apache.directory.studio.connection.core.Connection;
-import org.apache.directory.studio.schemaeditor.model.Schema;
+import org.apache.directory.studio.schemaeditor.model.Project;
 
 
 /**
@@ -50,29 +48,31 @@ public interface SchemaConnector
 
 
     /**
-     * Imports the Schema of the LDAP Server using the given connection and
+     * Imports the Schema of the LDAP Server using the given project and
      * progress monitor.
      *
-     * @param connection
-     *      the connection
+     * @param project
+     *      the project
      * @param monitor
      *      the progress monitor
-     * @return
-     *      the list of schemas of the LDAP Server
+     * @throws SchemaConnectorException
      */
-    public List<Schema> importSchema( Connection connection, StudioProgressMonitor
monitor );
+    public void importSchema( Project project, StudioProgressMonitor monitor )
+        throws SchemaConnectorException;
 
 
     /**
      * Exports the Schema to the LDAP Server using the given connection and
      * progress monitor.
      *
-     * @param connection
-     *      the connection
+     * @param project
+     *      the project
      * @param monitor
      *      the progress monitor
+     * @throws SchemaConnectorException
      */
-    public void exportSchema( Connection connection, StudioProgressMonitor monitor );
+    public void exportSchema( Project project, StudioProgressMonitor monitor )
+        throws SchemaConnectorException;
 
 
     /**

Added: directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/SchemaConnectorException.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/SchemaConnectorException.java?rev=1211420&view=auto
==============================================================================
--- directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/SchemaConnectorException.java
(added)
+++ directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/SchemaConnectorException.java
Wed Dec  7 13:01:21 2011
@@ -0,0 +1,55 @@
+/*
+ *  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.schemaeditor.model.io;
+
+
+/**
+ * This class represents the SchemaConnectorException.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class SchemaConnectorException extends Exception
+{
+    private static final long serialVersionUID = 1L;
+
+
+    public SchemaConnectorException()
+    {
+        super();
+    }
+
+
+    public SchemaConnectorException( String message, Throwable throwable )
+    {
+        super( message, throwable );
+    }
+
+
+    public SchemaConnectorException( String message )
+    {
+        super( message );
+    }
+
+
+    public SchemaConnectorException( Throwable throwable )
+    {
+        super( throwable );
+    }
+}

Modified: directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/messages.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/messages.properties?rev=1211420&r1=1211419&r2=1211420&view=diff
==============================================================================
--- directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/messages.properties
(original)
+++ directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/messages.properties
Wed Dec  7 13:01:21 2011
@@ -15,7 +15,10 @@
 # specific language governing permissions and limitations
 # under the License.
 
+ApacheDsSchemaConnector.FetchingSchema=Fetching Schema
 GenericSchemaConnector.FetchingSchema=Fetching Schema
+GenericSchemaConnector.OneSchemaElementCouldNotBeParsedError=One schema element could not
be parsed correctly and has been ignored.
+GenericSchemaConnector.MultipleSchemaElementsCouldNotBeParsedError={0} schema elements could
not be parsed correctly and have been ignored.
 OpenLdapSchemaFileImporter.ErrorMessage=Line\: {0}, column\: {1}, cause\: {2}
 OpenLdapSchemaFileImporter.NotReadCorrectly=The file "{0}" can not be read correctly.
 ProjectsImporter.NoSchemaConnectorIDFound=The parser was not able to find the SchemaConnector
with ID "{0}".

Modified: directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/messages_de.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/messages_de.properties?rev=1211420&r1=1211419&r2=1211420&view=diff
==============================================================================
--- directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/messages_de.properties
(original)
+++ directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/messages_de.properties
Wed Dec  7 13:01:21 2011
@@ -15,7 +15,10 @@
 # specific language governing permissions and limitations
 # under the License.
 
+ApacheDsSchemaConnector.FetchingSchema=Lese Schema 
 GenericSchemaConnector.FetchingSchema=Lese Schema 
+GenericSchemaConnector.OneSchemaElementCouldNotBeParsedError=TODO:One schema element could
not be parsed correctly and has been ignored.
+GenericSchemaConnector.MultipleSchemaElementsCouldNotBeParsedError=TODO:{0} schema elements
could not be parsed correctly and have been ignored.
 OpenLdapSchemaFileImporter.ErrorMessage=Zeile\: {0}, Spalte\: {1}, Grund\: {2}
 OpenLdapSchemaFileImporter.NotReadCorrectlyBegin=Die Datei "{0}" konnte nicht korrekt gelesen
werden.
 ProjectsImporter.NoSchemaConnectorIDFound=Der Parser war nicht in der Lage, den SchemaConnector
mit der OID "{0}" zu finden.

Modified: directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/messages_fr.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/messages_fr.properties?rev=1211420&r1=1211419&r2=1211420&view=diff
==============================================================================
--- directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/messages_fr.properties
(original)
+++ directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/model/io/messages_fr.properties
Wed Dec  7 13:01:21 2011
@@ -15,7 +15,10 @@
 # specific language governing permissions and limitations
 # under the License.
 
+ApacheDsSchemaConnector.FetchingSchema=R\u00E9cup\u00E9ration du sch\u00E9ma
 GenericSchemaConnector.FetchingSchema=R\u00E9cup\u00E9ration du sch\u00E9ma
+GenericSchemaConnector.OneSchemaElementCouldNotBeParsedError=Un \u00E9l\u00E9ment de sch\u00E9ma
n'a pu \u00EAtre correctement lu et a \u00E9t\u00E9 ignor\u00E9.
+GenericSchemaConnector.MultipleSchemaElementsCouldNotBeParsedError={0} \u00E9l\u00E9ments
de sch\u00E9ma n'ont pu \u00EAtre correctement lus et ont \u00E9t\u00E9 ignor\u00E9s.
 OpenLdapSchemaFileImporter.ErrorMessage=Ligne : {0}, colonne : {1}, cause : {2}
 OpenLdapSchemaFileImporter.NotReadCorrectly=Le fichier "{0}" ne peut pas \u00EAtre lu.
 ProjectsImporter.NoSchemaConnectorIDFound=Le parseur n'a pas \u00E9t\u00E9 capable de trouver
le SchemaConnector avec l'ID "{0}".

Modified: directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/CommitChangesDifferencesWizardPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/CommitChangesDifferencesWizardPage.java?rev=1211420&r1=1211419&r2=1211420&view=diff
==============================================================================
--- directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/CommitChangesDifferencesWizardPage.java
(original)
+++ directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/CommitChangesDifferencesWizardPage.java
Wed Dec  7 13:01:21 2011
@@ -82,7 +82,7 @@ public class CommitChangesDifferencesWiz
     {
         Project project = Activator.getDefault().getProjectsHandler().getOpenProject();
 
-        differencesWidget.setInput( DifferenceEngine.getDifferences( project.getSchemaBackup(),
project
+        differencesWidget.setInput( DifferenceEngine.getDifferences( project.getInitialSchema(),
project
             .getSchemaHandler().getSchemas() ) );
     }
 

Modified: directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewProjectWizard.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewProjectWizard.java?rev=1211420&r1=1211419&r2=1211420&view=diff
==============================================================================
--- directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewProjectWizard.java
(original)
+++ directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/NewProjectWizard.java
Wed Dec  7 13:01:21 2011
@@ -96,7 +96,6 @@ public class NewProjectWizard extends Wi
 
             RunnableContextRunner.execute( new StudioConnectionRunnableWithProgress()
             {
-
                 public void run( StudioProgressMonitor monitor )
                 {
                     // Getting the correct SchemaConnector for this connection
@@ -145,7 +144,7 @@ public class NewProjectWizard extends Wi
 
                 public String getName()
                 {
-                    return null;
+                    return Messages.getString( "NewProjectWizard.FetchingSchema" ); //$NON-NLS-1$;
                 }
 
 
@@ -157,7 +156,7 @@ public class NewProjectWizard extends Wi
 
                 public String getErrorMessage()
                 {
-                    return null;
+                    return Messages.getString( "NewProjectWizard.ErrorWhileFetchingSchema"
); //$NON-NLS-1$;
                 }
 
 

Modified: directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/messages.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/messages.properties?rev=1211420&r1=1211419&r2=1211420&view=diff
==============================================================================
--- directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/messages.properties
(original)
+++ directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/messages.properties
Wed Dec  7 13:01:21 2011
@@ -270,6 +270,8 @@ NewObjectClassOptionalAttributesPage.Non
 NewObjectClassOptionalAttributesPage.OptionalAttributeTypes=Optional Attribute Types
 NewObjectClassOptionalAttributesPage.Remove=Remove
 NewObjectClassOptionalAttributesPage.SpecifiyOptionalAttributeTypesForObjectClass=Please
specify the optional attribute types for the object class.
+NewProjectWizard.FetchingSchema=Fetching Schema
+NewProjectWizard.ErrorWhileFetchingSchema=An error occurred when fetching the schema:
 NewProjectWizardConnectionSelectionPage.ChooseConnection=Choose a connection:
 NewProjectWizardConnectionSelectionPage.CreateSchemaProject=Create a Schema project.
 NewProjectWizardConnectionSelectionPage.ErrorNoConnectionSelected=A connection must be selected.

Modified: directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/messages_de.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/messages_de.properties?rev=1211420&r1=1211419&r2=1211420&view=diff
==============================================================================
--- directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/messages_de.properties
(original)
+++ directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/messages_de.properties
Wed Dec  7 13:01:21 2011
@@ -279,6 +279,8 @@ NewObjectClassOptionalAttributesPage.Non
 NewObjectClassOptionalAttributesPage.OptionalAttributeTypes=Optionale Attribute-Typen
 NewObjectClassOptionalAttributesPage.Remove=L\u00F6schen
 NewObjectClassOptionalAttributesPage.SpecifiyOptionalAttributeTypesForObjectClass=Bitte die
optionalen Attribute f\u00FCr die Objektlasse ausw\u00E4hlen.
+NewProjectWizard.FetchingSchema=TODO:Fetching Schema
+NewProjectWizard.ErrorWhileFetchingSchema=TODO:An error occurred when fetching the schema:
 NewProjectWizardConnectionSelectionPage.ChooseConnection=Verbindung ausw\u00E4hlen:
 NewProjectWizardConnectionSelectionPage.CreateSchemaProject=Schema Projekt erstellen.
 NewProjectWizardConnectionSelectionPage.ErrorNoConnectionSelected=Eine Verbindung muss ausgew\u00E4hlt
werden.

Modified: directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/messages_fr.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/messages_fr.properties?rev=1211420&r1=1211419&r2=1211420&view=diff
==============================================================================
--- directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/messages_fr.properties
(original)
+++ directory/studio/trunk/plugins/schemaeditor/src/main/java/org/apache/directory/studio/schemaeditor/view/wizards/messages_fr.properties
Wed Dec  7 13:01:21 2011
@@ -285,6 +285,9 @@ NewObjectClassOptionalAttributesPage.Opt
 NewObjectClassOptionalAttributesPage.Remove=Supprimer
 NewObjectClassOptionalAttributesPage.SpecifiyOptionalAttributeTypesForObjectClass=Veuillez
sp\u00E9cifier les types d'attribut optionnels pour la classe d'objet.
 
+NewProjectWizard.FetchingSchema=R\u00E9cup\u00E9ration du sch\u00E9ma
+NewProjectWizard.ErrorWhileFetchingSchema=Une erreur est survenue lors de la r\u00E9cup\u00E9ration
du sch\u00E9ma :
+
 NewProjectWizardConnectionSelectionPage.ChooseConnection=Choisissez une connexion:
 NewProjectWizardConnectionSelectionPage.CreateSchemaProject=Cr\u00E9er un nouveau projet
de sch\u00E9ma.
 NewProjectWizardConnectionSelectionPage.ErrorNoConnectionSelected=Une connexion doit \u00EAtre
s\u00E9lectionn\u00E9e.



Mime
View raw message