directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r656628 - in /directory/studio/trunk/apacheds-configuration/src/main: java/org/apache/directory/studio/apacheds/configuration/ java/org/apache/directory/studio/apacheds/configuration/model/v152/ resources/org/apache/directory/studio/apached...
Date Thu, 15 May 2008 12:34:37 GMT
Author: pamarcelot
Date: Thu May 15 05:34:37 2008
New Revision: 656628

URL: http://svn.apache.org/viewvc?rev=656628&view=rev
Log:
o Removed the old default-server.xml file.
o Updated the ContentDescriber class to mark and reset the input stream and reader before
and after testing each version.
o Updated the isValid() methods of the Apache DS 1.5.2 ServerXmlIO.

Removed:
    directory/studio/trunk/apacheds-configuration/src/main/resources/org/apache/directory/studio/apacheds/configuration/default-server.xml
Modified:
    directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/ApacheDSConfigurationContentDescriber.java
    directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/v152/ServerXmlIOV152.java

Modified: directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/ApacheDSConfigurationContentDescriber.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/ApacheDSConfigurationContentDescriber.java?rev=656628&r1=656627&r2=656628&view=diff
==============================================================================
--- directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/ApacheDSConfigurationContentDescriber.java
(original)
+++ directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/ApacheDSConfigurationContentDescriber.java
Thu May 15 05:34:37 2008
@@ -99,11 +99,31 @@
         ServerXmlIO[] serverXmlIOs = ApacheDSConfigurationPlugin.getDefault().getServerXmlIOs();
         for ( ServerXmlIO validationServerXmlIO : serverXmlIOs )
         {
+            // Marking the reader
+            try
+            {
+                contents.mark( -1 );
+            }
+            catch ( IOException e1 )
+            {
+                return false;
+            }
+
             // Checking if the ServerXmlIO is valid
             if ( validationServerXmlIO.isValid( contents ) )
             {
                 return true;
             }
+
+            // Reseting the reader to the mark
+            try
+            {
+                contents.reset();
+            }
+            catch ( IOException e )
+            {
+                return false;
+            }
         }
 
         return false;
@@ -125,11 +145,24 @@
         ServerXmlIO[] serverXmlIOs = ApacheDSConfigurationPlugin.getDefault().getServerXmlIOs();
         for ( ServerXmlIO validationServerXmlIO : serverXmlIOs )
         {
+            // Marking the input stream
+            contents.mark( -1 );
+
             // Checking if the ServerXmlIO is valid
             if ( validationServerXmlIO.isValid( contents ) )
             {
                 return true;
             }
+
+            // Reseting the input stream to the mark
+            try
+            {
+                contents.reset();
+            }
+            catch ( IOException e )
+            {
+                return false;
+            }
         }
 
         return false;

Modified: directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/v152/ServerXmlIOV152.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/v152/ServerXmlIOV152.java?rev=656628&r1=656627&r2=656628&view=diff
==============================================================================
--- directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/v152/ServerXmlIOV152.java
(original)
+++ directory/studio/trunk/apacheds-configuration/src/main/java/org/apache/directory/studio/apacheds/configuration/model/v152/ServerXmlIOV152.java
Thu May 15 05:34:37 2008
@@ -65,8 +65,16 @@
      */
     public boolean isValid( InputStream is )
     {
-        // TODO Auto-generated method stub
-        return true;
+        try
+        {
+            SAXReader saxReader = new SAXReader();
+
+            return isValid( saxReader.read( is ) );
+        }
+        catch ( Exception e )
+        {
+            return false;
+        }
     }
 
 
@@ -75,8 +83,43 @@
      */
     public boolean isValid( Reader reader )
     {
-        // TODO Auto-generated method stub
-        return true;
+        try
+        {
+            SAXReader saxReader = new SAXReader();
+
+            return isValid( saxReader.read( reader ) );
+        }
+        catch ( Exception e )
+        {
+            return false;
+        }
+    }
+
+
+    /**
+     * Checks if the Document is valid.
+     *
+     * @param document
+     *      the Document
+     * @return
+     *      true if the Document is valid, false if not
+     */
+    private boolean isValid( Document document )
+    {
+        Element rootElement = document.getRootElement();
+
+        if ( rootElement != null )
+        {
+            // Checking if the root element is named 'beans'
+            if ( "beans".equalsIgnoreCase( rootElement.getName() ) )
+            {
+                // Looking for the 'apacheDS' element
+                Element apacheDSElement = rootElement.element( "apacheDS" );
+                return ( apacheDSElement != null );
+            }
+        }
+
+        return false;
     }
 
 



Mime
View raw message