directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r570172 - in /directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor: ./ model/ model/io/
Date Mon, 27 Aug 2007 16:04:48 GMT
Author: pamarcelot
Date: Mon Aug 27 09:04:47 2007
New Revision: 570172

URL: http://svn.apache.org/viewvc?rev=570172&view=rev
Log:
Updated Activator to start listening on the ProjectsHandler in the start(...) method.
Improved ProjectImporter and ProjectExporter to import/export the Schema Backup

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/model/Project.java
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/io/OnlineSchemaImporter.java
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/io/ProjectsExporter.java
    directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/io/ProjectsImporter.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?rev=570172&r1=570171&r2=570172&view=diff
==============================================================================
--- 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
Mon Aug 27 09:04:47 2007
@@ -76,39 +76,6 @@
     {
         plugin = this;
         projectsHandler = ProjectsHandler.getInstance();
-        projectsHandler.addListener( new ProjectsHandlerListener()
-        {
-            public void openProjectChanged( Project oldProject, Project newProject )
-            {
-                closeProjectEditors();
-
-                if ( newProject == null )
-                {
-                    schemaHandler = null;
-                    schemaChecker = null;
-                }
-                else
-                {
-                    // Registering the SchemaHandler and SchemaChecker
-                    schemaHandler = newProject.getSchemaHandler();
-                    schemaChecker = newProject.getSchemaChecker();
-                }
-
-                PluginUtils.saveProjects();
-            }
-
-
-            public void projectAdded( Project project )
-            {
-                PluginUtils.saveProjects();
-            }
-
-
-            public void projectRemoved( Project project )
-            {
-                PluginUtils.saveProjects();
-            }
-        } );
     }
 
 
@@ -151,6 +118,40 @@
 
         // Loading the projects
         PluginUtils.loadProjects();
+
+        projectsHandler.addListener( new ProjectsHandlerListener()
+        {
+            public void openProjectChanged( Project oldProject, Project newProject )
+            {
+                closeProjectEditors();
+
+                if ( newProject == null )
+                {
+                    schemaHandler = null;
+                    schemaChecker = null;
+                }
+                else
+                {
+                    // Registering the SchemaHandler and SchemaChecker
+                    schemaHandler = newProject.getSchemaHandler();
+                    schemaChecker = newProject.getSchemaChecker();
+                }
+
+                PluginUtils.saveProjects();
+            }
+
+
+            public void projectAdded( Project project )
+            {
+                PluginUtils.saveProjects();
+            }
+
+
+            public void projectRemoved( Project project )
+            {
+                PluginUtils.saveProjects();
+            }
+        } );
     }
 
 

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/Project.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/Project.java?rev=570172&r1=570171&r2=570172&view=diff
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/Project.java
(original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/Project.java
Mon Aug 27 09:04:47 2007
@@ -270,6 +270,7 @@
                 getSchemaHandler().addSchema( schema );
             }
 
+            // TODO Add error Handling
             monitor.done();
             hasOnlineSchemaBeenFetched = true;
         }
@@ -285,6 +286,30 @@
     public boolean hasOnlineSchemaBeenFetched()
     {
         return hasOnlineSchemaBeenFetched;
+    }
+
+
+    /**
+     * Gets the Schema Backup.
+     *
+     * @return
+     *      the Schema Backup
+     */
+    public List<Schema> getSchemaBackup()
+    {
+        return schemaBackup;
+    }
+
+
+    /**
+     * Sets the Schema Backup
+     *
+     * @param schemaBackup
+     *      the Schema Backup
+     */
+    public void setSchemaBackup( List<Schema> schemaBackup )
+    {
+        this.schemaBackup = schemaBackup;
     }
 
 

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/io/OnlineSchemaImporter.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/io/OnlineSchemaImporter.java?rev=570172&r1=570171&r2=570172&view=diff
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/io/OnlineSchemaImporter.java
(original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/io/OnlineSchemaImporter.java
Mon Aug 27 09:04:47 2007
@@ -82,6 +82,7 @@
      * @param monitor 
      * @throws NamingException 
      */
+    @SuppressWarnings("unchecked")
     public static List<Schema> getOnlineSchema( JNDIConnectionWrapper wrapper, StudioProgressMonitor
monitor )
         throws NamingException
     {
@@ -118,6 +119,7 @@
     }
 
 
+    @SuppressWarnings("unchecked")
     private static Schema getSchema( JNDIConnectionWrapper wrapper, String name, StudioProgressMonitor
monitor )
         throws NamingException
     {

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/io/ProjectsExporter.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/io/ProjectsExporter.java?rev=570172&r1=570171&r2=570172&view=diff
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/io/ProjectsExporter.java
(original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/io/ProjectsExporter.java
Mon Aug 27 09:04:47 2007
@@ -20,6 +20,8 @@
 package org.apache.directory.studio.apacheds.schemaeditor.model.io;
 
 
+import java.util.List;
+
 import javax.xml.transform.Transformer;
 import javax.xml.transform.TransformerConfigurationException;
 import javax.xml.transform.TransformerException;
@@ -52,6 +54,7 @@
     private static final String NAME_TAG = "name";
     private static final String TYPE_TAG = "type";
     private static final String CONNECTION_TAG = "connection";
+    private static final String SCHEMA_BACKUP_TAG = "schemaBackup";
 
 
     /**
@@ -131,10 +134,20 @@
                 element.addAttribute( TYPE_TAG, type.toString() );
             }
 
-            // Connection Name
+            // If project is an Apache Directory Server Online Schema Project
             if ( type.equals( ProjectType.APACHE_DIRECTORY_SERVER ) )
             {
+                // Connection Name
                 element.addAttribute( CONNECTION_TAG, project.getConnection().getName() );
+
+                // Schema Backup
+                Element schemaBackupElement = element.addElement( SCHEMA_BACKUP_TAG );
+                List<Schema> backupSchemas = project.getSchemaBackup();
+                if ( backupSchemas != null )
+                {
+                    XMLSchemaFileExporter.addSchemas( backupSchemas.toArray( new Schema[0]
), schemaBackupElement );
+                }
+
             }
 
             // Schemas

Modified: directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/io/ProjectsImporter.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/io/ProjectsImporter.java?rev=570172&r1=570171&r2=570172&view=diff
==============================================================================
--- directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/io/ProjectsImporter.java
(original)
+++ directory/studio/trunk/studio-apacheds-schemaeditor/src/main/java/org/apache/directory/studio/apacheds/schemaeditor/model/io/ProjectsImporter.java
Mon Aug 27 09:04:47 2007
@@ -21,6 +21,7 @@
 
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
 
@@ -50,6 +51,7 @@
     private static final String SCHEMAS_TAG = "schemas";
     private static final String TYPE_TAG = "type";
     private static final String CONNECTION_TAG = "connection";
+    private static final String SCHEMA_BACKUP_TAG = "schemaBackup";
 
 
     /**
@@ -167,13 +169,36 @@
             }
         }
 
-        // Connection
+        // If project is an Apache Directory Server Online Schema Project
         if ( project.getType().equals( ProjectType.APACHE_DIRECTORY_SERVER ) )
         {
+            // Connection
             Attribute connectionAttribute = element.attribute( CONNECTION_TAG );
             if ( ( connectionAttribute != null ) && ( !connectionAttribute.getValue().equals(
"" ) ) )
             {
                 project.setConnection( PluginUtils.getConnection( connectionAttribute.getText()
) );
+            }
+
+            // SchemaBackup
+            Element schemaBackupElement = element.element( SCHEMA_BACKUP_TAG );
+            if ( schemaBackupElement != null )
+            {
+                Element schemasElement = schemaBackupElement.element( SCHEMAS_TAG );
+                if ( schemasElement != null )
+                {
+                    Schema[] schemas = null;
+                    try
+                    {
+                        schemas = XMLSchemaFileImporter.readSchemas( schemasElement, path
);
+                    }
+                    catch ( XMLSchemaFileImportException e )
+                    {
+                        throw new ProjectsImportException(
+                            "The parser was not able to convert the schemas of the project."
);
+                    }
+
+                    project.setSchemaBackup( Arrays.asList( schemas ) );
+                }
             }
         }
 



Mime
View raw message