directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1687373 - in /directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages: OptionsPage.java messages.properties messages_de.properties messages_fr.properties
Date Wed, 24 Jun 2015 21:34:37 GMT
Author: elecharny
Date: Wed Jun 24 21:34:37 2015
New Revision: 1687373

URL: http://svn.apache.org/r1687373
Log:
o Added the edit button for the rootDSE table
o Moved the logic that fill the tables in distinct methods, for clarity
o Added teh code that feed the authzRegexp and AuthIdRewrite tables

Modified:
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/OptionsPage.java
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/messages.properties
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/messages_de.properties
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/messages_fr.properties

Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/OptionsPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/OptionsPage.java?rev=1687373&r1=1687372&r2=1687373&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/OptionsPage.java
(original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/OptionsPage.java
Wed Jun 24 21:34:37 2015
@@ -21,7 +21,10 @@ package org.apache.directory.studio.open
 
 
 import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.directory.studio.common.ui.CommonUIUtils;
 import org.apache.directory.studio.common.ui.widgets.BaseWidgetUtils;
@@ -33,6 +36,7 @@ import org.apache.directory.studio.openl
 import org.apache.directory.studio.openldap.common.ui.model.DisallowFeatureEnum;
 import org.apache.directory.studio.openldap.common.ui.model.RequireConditionEnum;
 import org.apache.directory.studio.openldap.common.ui.model.RestrictOperationEnum;
+import org.apache.directory.studio.openldap.config.OpenLdapConfigurationPluginUtils;
 import org.apache.directory.studio.openldap.config.editor.OpenLDAPServerConfigurationEditor;
 import org.apache.directory.studio.openldap.config.editor.wrappers.AllowFeatureDecorator;
 import org.apache.directory.studio.openldap.config.editor.wrappers.AuthIdRewriteDecorator;
@@ -45,6 +49,7 @@ import org.apache.directory.studio.openl
 import org.apache.directory.studio.openldap.config.editor.wrappers.StringValueDecorator;
 import org.apache.directory.studio.openldap.config.editor.wrappers.StringValueWrapper;
 import org.apache.directory.studio.openldap.config.model.OlcGlobal;
+import org.apache.directory.studio.openldap.config.model.database.OlcDatabaseConfig;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.ModifyEvent;
 import org.eclipse.swt.events.ModifyListener;
@@ -121,7 +126,7 @@ import org.eclipse.ui.forms.widgets.Tabl
  * | | +--------------------------+          | | +--------------------------+           |
|
  * | +---------------------------------------+ +----------------------------------------+
|
  * | .---------------------------------------. .----------------------------------------.
|
- * | |V Authorization rewrite rules          | |V Authorisation ID Regexp               |
|
+ * | |V Authentication ID rewrite rules      | |V Authorisation Regexp                  |
|
  * | +---------------------------------------+ +----------------------------------------+
|
  * | | +--------------------------+          | | +--------------------------+           |
|
  * | | | xyz                      | (Add...) | | | xyz                      | (Add...)  |
|
@@ -141,7 +146,7 @@ import org.eclipse.ui.forms.widgets.Tabl
  * | | Root DSE :                                Other :                                |
|
  * | | +--------------------------+              .------------------------------------. |
|
  * | | | xyz                      | (Add...)     | [X] Read Only                      | |
|
- * | | | abcde                    |              | [X] GentleHUP                      | |
|
+ * | | | abcde                    | (Edit)       | [X] GentleHUP                      | |
|
  * | | | aaa                      | (Delete)     | [X] Reverse Lookup                 | |
|
  * | | +--------------------------+              '------------------------------------' |
|
  * | +----------------------------------------------------------------------------------+
|
@@ -496,8 +501,8 @@ public class OptionsPage extends OpenLDA
 
         createFeaturesSection( toolkit, middleLeftComposite );
         createOperationsSection( toolkit, middleRightComposite );
-        createAuthorizationRewriteRuleSection( toolkit, middleLeftComposite );
-        createAuthIdRegexpsSection( toolkit, middleRightComposite );
+        createAuthIdRewriteSection( toolkit, middleLeftComposite );
+        createAuthzRegexpsSection( toolkit, middleRightComposite );
         createMiscellaneousSection( toolkit, lowerComposite );
     }
 
@@ -620,10 +625,10 @@ public class OptionsPage extends OpenLDA
 
 
     /**
-     * Creates the Authorization Rewrite Rules section.
+     * Creates the Authentication ID Rewrite Rules section.
      * <pre>
      * .----------------------------------------.
-     * |V Authorization rewrite rules           |
+     * |V Authentication ID rewrite rules       |
      * +----------------------------------------+
      * | +--------------------------+           |
      * | | xyz                      | (Add...)  |
@@ -637,27 +642,27 @@ public class OptionsPage extends OpenLDA
      * @param toolkit the toolkit
      * @param parent the parent composite
      */
-    private void createAuthorizationRewriteRuleSection( FormToolkit toolkit, Composite parent
)
+    private void createAuthIdRewriteSection( FormToolkit toolkit, Composite parent )
     {
         Section section = createSection( toolkit, parent, 
-            Messages.getString( "OpenLDAPOptionsPage.AuthzRewriteRules" ) );
+            Messages.getString( "OpenLDAPOptionsPage.AuthIdRewrite" ) );
         Composite composite = createSectionComposite( toolkit, section, 2, false );
 
         // The olcAuthIdRewrite parameter table
         authIdRewriteTableWidget = new TableWidget<AuthIdRewriteWrapper>( 
             new AuthIdRewriteDecorator( composite.getShell() ) );
 
-        authIdRewriteTableWidget.createWidgetNoEdit( composite, toolkit );
+        authIdRewriteTableWidget.createOrderedWidgetWithEdit( composite, toolkit );
         authIdRewriteTableWidget.getControl().setLayoutData( new GridData( SWT.FILL, SWT.NONE,
true, false, 2, 1 ) );
         addModifyListener( authIdRewriteTableWidget, authIdRewriteListener );
     }
 
 
     /**
-     * Creates the AuthID Regexp section.
+     * Creates the Authz Regexp section.
      * <pre>
      * .----------------------------------------.
-     * |V Authentication ID Regexp              |
+     * |V Authorization Regexps                 |
      * +----------------------------------------+
      * | +--------------------------+           | 
      * | | xyz                      | (Add...)  |
@@ -671,17 +676,17 @@ public class OptionsPage extends OpenLDA
      * @param toolkit the toolkit
      * @param parent the parent composite
      */
-    private void createAuthIdRegexpsSection( FormToolkit toolkit, Composite parent )
+    private void createAuthzRegexpsSection( FormToolkit toolkit, Composite parent )
     {
         Section section = createSection( toolkit, parent, 
-            Messages.getString( "OpenLDAPOptionsPage.AuthIdRegexps" ) );
+            Messages.getString( "OpenLDAPOptionsPage.AuthzRegexp" ) );
         Composite composite = createSectionComposite( toolkit, section, 2, false );
 
         // The olcAuthzRegexp parameter table
         authzRegexpTableWidget = new TableWidget<AuthzRegexpWrapper>( 
             new AuthzRegexpDecorator( composite.getShell() ) );
 
-        authzRegexpTableWidget.createWidgetNoEdit( composite, toolkit );
+        authzRegexpTableWidget.createOrderedWidgetWithEdit( composite, toolkit );
         authzRegexpTableWidget.getControl().setLayoutData( new GridData( SWT.FILL, SWT.NONE,
true, false, 2, 1 ) );
         addModifyListener( authzRegexpTableWidget, authzRegexpListener );
     }
@@ -700,7 +705,7 @@ public class OptionsPage extends OpenLDA
      * | Root DSE :                                Other :                              
 |
      * | +--------------------------+              .------------------------------------.
|
      * | | xyz                      | (Add...)     | [X] Read Only                      |
|
-     * | | abcde                    |              | [X] GentleHUP                      |
|
+     * | | abcde                    | (Edit)       | [X] GentleHUP                      |
|
      * | | aaa                      | (Delete)     | [X] Reverse Lookup                 |
|
      * | +--------------------------+              '------------------------------------'
|
      * +----------------------------------------------------------------------------------+
@@ -821,106 +826,217 @@ public class OptionsPage extends OpenLDA
         removeDirtyListener( reverseLookupCheckbox );
     }
     
-
-    /**
-     * {@inheritDoc}
-     */
-    public void refreshUI()
+    
+    private void refreshAllowFeatures( OlcGlobal global )
     {
-        removeListeners();
+        List<String> allowedFeatures = global.getOlcAllows();
+        List<AllowFeatureEnum> alloweds = new ArrayList<AllowFeatureEnum>();
 
-        // Getting the global configuration object
-        OlcGlobal global = getConfiguration().getGlobal();
-
-        if ( global != null )
+        if ( allowedFeatures != null )
         {
-            //
-            // Assigning values to UI Controls
-            //
-
-            // Allow Feature Table Widget
-            List<String> allowedFeatures = global.getOlcAllows();
-            List<AllowFeatureEnum> alloweds = new ArrayList<AllowFeatureEnum>();
-
-            if ( allowedFeatures != null )
+            for ( String allowedFeature : allowedFeatures )
             {
-                for ( String allowedFeature : allowedFeatures )
-                {
-                    alloweds.add( AllowFeatureEnum.getFeature( allowedFeature ) );
-                }
+                alloweds.add( AllowFeatureEnum.getFeature( allowedFeature ) );
             }
+        }
 
-            allowFeatureTableWidget.setElements( alloweds );
-
-            // Disallow Feature Table Widget
-            List<String> disallowedFeatures = global.getOlcDisallows();
-            List<DisallowFeatureEnum> disalloweds = new ArrayList<DisallowFeatureEnum>();
+        allowFeatureTableWidget.setElements( alloweds );
+    }
+    
+    
+    private void refreshDisllowFeatures( OlcGlobal global )
+    {
+        List<String> disallowedFeatures = global.getOlcDisallows();
+        List<DisallowFeatureEnum> disalloweds = new ArrayList<DisallowFeatureEnum>();
 
-            if ( disallowedFeatures != null )
+        if ( disallowedFeatures != null )
+        {
+            for ( String disallowedFeature : disallowedFeatures )
             {
-                for ( String disallowedFeature : disallowedFeatures )
-                {
-                    disalloweds.add( DisallowFeatureEnum.getFeature( disallowedFeature )
);
-                }
+                disalloweds.add( DisallowFeatureEnum.getFeature( disallowedFeature ) );
             }
-            
-            disallowFeatureTableWidget.setElements( disalloweds );
+        }
+        
+        disallowFeatureTableWidget.setElements( disalloweds );
+    }
+    
+    
+    private void refreshRequireConditions( OlcGlobal global )
+    {
+        List<String> requireConditions = global.getOlcRequires();
+        List<RequireConditionEnum> requires = new ArrayList<RequireConditionEnum>();
 
-            // Require Condition Table Widget
-            List<String> requireConditions = global.getOlcRequires();
-            List<RequireConditionEnum> requires = new ArrayList<RequireConditionEnum>();
+        if ( requireConditions != null )
+        {
+            for ( String requireCondition : requireConditions )
+            {
+                requires.add( RequireConditionEnum.getCondition( requireCondition ) );
+            }
+        }
+        
+        requireConditionTableWidget.setElements( requires );
+    }
+    
+    
+    private void refreshRestrictOperations( OlcGlobal global )
+    {
+        List<String> restrictOperations = global.getOlcRestrict();
+        List<RestrictOperationEnum> restricts = new ArrayList<RestrictOperationEnum>();
 
-            if ( requireConditions != null )
+        if ( restrictOperations != null )
+        {
+            for ( String restrictOperation : restrictOperations )
             {
-                for ( String requireCondition : requireConditions )
-                {
-                    requires.add( RequireConditionEnum.getCondition( requireCondition ) );
-                }
+                restricts.add( RestrictOperationEnum.getOperation( restrictOperation ) );
             }
-            
-            requireConditionTableWidget.setElements( requires );
+        }
+        
+        restrictOperationTableWidget.setElements( restricts );
+    }
+    
+    
+    /**
+     * The AuthIdRewrite table is ordered, we need to deal with that.
+     */
+    private void refreshAuthIdRewrites( OlcGlobal global )
+    {
+        List<OlcDatabaseConfig> authIdRewrites = getConfiguration().getDatabases();
 
-            // Restrict Operation Condition Table Widget
-            List<String> restrictOperations = global.getOlcRestrict();
-            List<RestrictOperationEnum> restricts = new ArrayList<RestrictOperationEnum>();
+        if ( authIdRewrites != null )
+        {
+            int nbElements = authIdRewrites.size();
+            List<AuthIdRewriteWrapper> rewrites = new ArrayList<AuthIdRewriteWrapper>(
nbElements );
+            int[] valuePrefixes = new int[nbElements];
+            Map<Integer, String> values = new HashMap<Integer, String>(nbElements);
+            int pos = 0;
 
-            if ( restrictOperations != null )
+            // First gather the values
+            for ( OlcDatabaseConfig rewrite : authIdRewrites )
             {
-                for ( String restrictOperation : restrictOperations )
-                {
-                    restricts.add( RestrictOperationEnum.getOperation( restrictOperation
) );
-                }
+                // Parse the prefix, and set the element at the right place
+                int prefix = OpenLdapConfigurationPluginUtils.getOrderingPrefix( rewrite.getOlcDatabase()
);
+                
+                valuePrefixes[pos++] = prefix;
+                values.put( prefix, OpenLdapConfigurationPluginUtils.stripOrderingPrefix(
rewrite.getOlcDatabase() ) );
             }
+
+            // Now, order them
+            Arrays.sort( valuePrefixes );
             
-            restrictOperationTableWidget.setElements( restricts );
+            // Ok, store the elements accordingly to their prefix now
+            for ( int prefix : valuePrefixes )
+            {
+                String value = values.get( prefix );
+                rewrites.add( new AuthIdRewriteWrapper( value ) );
+            }
 
-            // AuthID Rewrite Table Widget
-            List<String> authIdRewrites = global.getOlcAuthIDRewrite();
+            authIdRewriteTableWidget.setElements( rewrites );
+        }
+        else
+        {
+            // Store an empty list
             List<AuthIdRewriteWrapper> rewrites = new ArrayList<AuthIdRewriteWrapper>();
+            
+            authIdRewriteTableWidget.setElements( rewrites );
+        }
+    }
+
+    
+    private void refreshAuthzRegexps( OlcGlobal global )
+    {
+        List<String> authzRegexps = global.getOlcRestrict();
+
+        if ( authzRegexps != null )
+        {
+            int nbElements = authzRegexps.size();
+            List<AuthzRegexpWrapper> regexps = new ArrayList<AuthzRegexpWrapper>(
nbElements );
+            int[] valuePrefixes = new int[nbElements];
+            Map<Integer, String> values = new HashMap<Integer, String>(nbElements);
+            int pos = 0;
 
-            if ( authIdRewrites != null )
+            // First gather the values
+            for ( String rewrite : authzRegexps )
             {
-                for ( String rewrite : authIdRewrites )
-                {
-                    rewrites.add( new AuthIdRewriteWrapper( rewrite ) );
-                }
+                // Parse the prefix, and set the element at the right place
+                int prefix = OpenLdapConfigurationPluginUtils.getOrderingPrefix( rewrite
);
+                
+                valuePrefixes[pos] = prefix;
+                values.put( prefix, OpenLdapConfigurationPluginUtils.stripOrderingPrefix(
rewrite ) );
             }
+
+            // Now, order them
+            Arrays.sort( valuePrefixes );
             
-            authIdRewriteTableWidget.setElements( rewrites );
+            // Ok, store the elements accordingly to their prefix now
+            for ( int prefix : valuePrefixes )
+            {
+                String value = values.get( prefix );
+                regexps.add( new AuthzRegexpWrapper( value ) );
+            }
 
-            // Authz Regexp Table Widget
-            List<String> authzRegexps = global.getOlcRestrict();
+            authzRegexpTableWidget.setElements( regexps );
+        }
+        else
+        {
+            // Store an empty list
             List<AuthzRegexpWrapper> regexps = new ArrayList<AuthzRegexpWrapper>();
+            
+            authzRegexpTableWidget.setElements( regexps );
+        }
+        
+    }
 
-            if ( authzRegexps != null )
+    
+    private void refreshRootDseFiles( OlcGlobal global )
+    {
+        List<String> rootDses = global.getOlcRootDSE();
+        List<StringValueWrapper> roots = new ArrayList<StringValueWrapper>();
+
+        if ( rootDses != null )
+        {
+            for ( String rootDse : rootDses )
             {
-                for ( String regexp : authzRegexps )
-                {
-                    regexps.add( new AuthzRegexpWrapper( regexp ) );
-                }
+                roots.add( new StringValueWrapper( rootDse, true ) );
             }
+        }
+        
+        rootDseTableWidget.setElements( roots );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void refreshUI()
+    {
+        removeListeners();
+
+        // Getting the global configuration object
+        OlcGlobal global = getConfiguration().getGlobal();
+
+        if ( global != null )
+        {
+            //
+            // Assigning values to UI Controls
+            //
+
+            // Allow Feature Table Widget
+            refreshAllowFeatures( global );
+
+            // Disallow Feature Table Widget
+            refreshDisllowFeatures( global );
+
+            // Require Condition Table Widget
+            refreshRequireConditions( global );
+
+            // Restrict Operation Condition Table Widget
+            refreshRestrictOperations( global );
             
-            authzRegexpTableWidget.setElements( regexps );
+            // AuthID Rewrite Table Widget
+            refreshAuthIdRewrites( global );
+
+            // Authz Regexp Table Widget
+            refreshAuthzRegexps( global );
 
             // Update the ArgsFileText
             BaseWidgetUtils.setValue( global.getOlcArgsFile(), argsFileText );
@@ -960,18 +1076,7 @@ public class OptionsPage extends OpenLDA
             }
 
             // Update the RootDSEText
-            List<String> rootDses = global.getOlcRootDSE();
-            List<StringValueWrapper> roots = new ArrayList<StringValueWrapper>();
-
-            if ( rootDses != null )
-            {
-                for ( String rootDse : rootDses )
-                {
-                    roots.add( new StringValueWrapper( rootDse, true ) );
-                }
-            }
-            
-            rootDseTableWidget.setElements( roots );
+            refreshRootDseFiles( global );
             
             // Update the GentleHupCheckbox
             BaseWidgetUtils.setValue( global.getOlcGentleHUP(), gentleHupCheckbox );

Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/messages.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/messages.properties?rev=1687373&r1=1687372&r2=1687373&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/messages.properties
(original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/messages.properties
Wed Jun 24 21:34:37 2015
@@ -146,8 +146,8 @@ OpenLDAPOptionsPage.Title=Options
 # Sections 
 OpenLDAPOptionsPage.FeaturesSection=Features
 OpenLDAPOptionsPage.OperationsSection=Operations
-OpenLDAPOptionsPage.AuthzRewriteRules=Authorization rewrite rules
-OpenLDAPOptionsPage.AuthIdRegexps=Authentication ID Regexps
+OpenLDAPOptionsPage.AuthIdRewrite=Authentication ID rewrite rules
+OpenLDAPOptionsPage.AuthzRegexp=Authorization Regexps
 OpenLDAPOptionsPage.Miscellaneous=Miscellaneous
 
 # parameters

Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/messages_de.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/messages_de.properties?rev=1687373&r1=1687372&r2=1687373&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/messages_de.properties
(original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/messages_de.properties
Wed Jun 24 21:34:37 2015
@@ -146,8 +146,8 @@ OpenLDAPOptionsPage.Title=Options
 # Sections
 OpenLDAPOptionsPage.FeaturesSection=Features
 OpenLDAPOptionsPage.OperationsSection=Operations
-OpenLDAPOptionsPage.AuthzRewriteRules=Authorization rewrite rules
-OpenLDAPOptionsPage.AuthIdRegexps=Authentication ID Regexps
+OpenLDAPOptionsPage.AuthIdRewrite=Authentication ID rewrite rules
+OpenLDAPOptionsPage.AuthzRegexp=Authorization Regexps
 OpenLDAPOptionsPage.Miscellaneous=Miscellaneous
 
 # Parameters

Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/messages_fr.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/messages_fr.properties?rev=1687373&r1=1687372&r2=1687373&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/messages_fr.properties
(original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/pages/messages_fr.properties
Wed Jun 24 21:34:37 2015
@@ -146,8 +146,8 @@ OpenLDAPOptionsPage.Title=Options
 # Sections
 OpenLDAPOptionsPage.FeaturesSection=Fonctionalit\u0E9s
 OpenLDAPOptionsPage.OperationsSection=Operations
-OpenLDAPOptionsPage.AuthzRewriteRules=R\u00E8gles de r\u00E9\u00E9criture d\'Authorization
-OpenLDAPOptionsPage.AuthIdRegexps=Expressions r\u00E9guli\u00E9ress de l\'ID d\'Authentification
+OpenLDAPOptionsPage.AuthIdRewrite=R\u00E8gles de r\u00E9\u00E9criture d'ID d\'Authentification
+OpenLDAPOptionsPage.AuthzRegexp=Expressions r\u00E9guli\u00E9ress d\'Authorisation
 OpenLDAPOptionsPage.Miscellaneous=Divers
 
 # Parameters



Mime
View raw message