directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1695215 - in /directory/studio/trunk/plugins/openldap.acl.editor/src: main/java/org/apache/directory/studio/openldap/config/acl/model/ test/java/org/apache/directory/studio/openldap/config/acl/model/
Date Tue, 11 Aug 2015 06:09:47 GMT
Author: elecharny
Date: Tue Aug 11 06:09:47 2015
New Revision: 1695215

URL: http://svn.apache.org/r1695215
Log:
o Added the AclAttributeVal class that is used in the AclWhatClauseAttributes class
o Added a constructor in the AclAttribute which does not take a connection parameter
o Renamed the isVal/isMatchingRule to hasVal/hasMatchingRule
o Use the AclAttributeVal in the AclWhatClauseAttributes class, with accessors to feed it
o Fixed the ACL parser tests

Added:
    directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclAttributeVal.java
Modified:
    directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclAttribute.java
    directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhatClauseAttributes.java
    directory/studio/trunk/plugins/openldap.acl.editor/src/test/java/org/apache/directory/studio/openldap/config/acl/model/OpenLdapAclParserTest.java

Modified: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclAttribute.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclAttribute.java?rev=1695215&r1=1695214&r2=1695215&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclAttribute.java
(original)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclAttribute.java
Tue Aug 11 06:09:47 2015
@@ -23,7 +23,7 @@ import org.apache.directory.api.ldap.mod
 import org.apache.directory.api.ldap.model.schema.ObjectClass;
 import org.apache.directory.api.ldap.model.schema.SchemaManager;
 import org.apache.directory.api.util.Strings;
-import org.apache.directory.studio.connection.core.Connection;
+import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
 import org.apache.directory.studio.openldap.config.OpenLdapConfigurationPlugin;
 
 /**
@@ -75,14 +75,14 @@ public class AclAttribute
     private boolean isChildren = false;
     
     /** The Connection to the LDAP server */
-    private Connection connection;
+    private IBrowserConnection connection;
     
     /**
      * Create a new AclAttribute with no name
      * 
      * @param connection The Connection on the LDAP Server 
      */
-    public AclAttribute( Connection connection )
+    public AclAttribute( IBrowserConnection connection )
     {
         this.connection = connection;
         setName( "" );
@@ -94,7 +94,19 @@ public class AclAttribute
      * 
      * @param name The AlcAttribute name
      */
-    public AclAttribute( String name, Connection connection )
+    public AclAttribute( String name )
+    {
+        this.connection = null;
+        setName( name );
+    }
+    
+    
+    /**
+     * Create a new AclAttribute with specific name
+     * 
+     * @param name The AlcAttribute name
+     */
+    public AclAttribute( String name, IBrowserConnection connection )
     {
         this.connection = connection;
         setName( name );

Added: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclAttributeVal.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclAttributeVal.java?rev=1695215&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclAttributeVal.java
(added)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclAttributeVal.java
Tue Aug 11 06:09:47 2015
@@ -0,0 +1,128 @@
+/*
+ *   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.openldap.config.acl.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * A class used to store the WhatClause attributes with a qualifier (either '!' or '@').
+ * We store either an AttributeType, or an ObjectClass (prefixed with '@' or '¬'), or
one
+ * of the two special values : 'entry' and 'children'
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class AclAttributeVal
+{
+    /** The list of AclAttributes */
+    List<AclAttribute> aclAttributes = new ArrayList<AclAttribute>();
+    
+    /** The attribute style*/
+    private AclAttributeStyleEnum style;
+    
+    /** The val flag */
+    private boolean val;
+    
+    /** The MatchingRule flag */
+    private boolean matchingRule;
+    
+    /** The value */
+    private String value;
+
+    /**
+     * @return the aclAttributes
+     */
+    public List<AclAttribute> getAclAttributes()
+    {
+        return aclAttributes;
+    }
+
+    /**
+     * @param aclAttributes the aclAttributes to set
+     */
+    public void setAclAttributes( List<AclAttribute> aclAttributes )
+    {
+        this.aclAttributes = aclAttributes;
+    }
+
+    /**
+     * @return the style
+     */
+    public AclAttributeStyleEnum getStyle()
+    {
+        return style;
+    }
+
+    /**
+     * @param style the style to set
+     */
+    public void setStyle( AclAttributeStyleEnum style )
+    {
+        this.style = style;
+    }
+
+    /**
+     * @return the val
+     */
+    public boolean hasVal()
+    {
+        return val;
+    }
+
+    /**
+     * @param val the val to set
+     */
+    public void setVal( boolean val )
+    {
+        this.val = val;
+    }
+
+    /**
+     * @return the matchingRule
+     */
+    public boolean hasMatchingRule()
+    {
+        return matchingRule;
+    }
+
+    /**
+     * @param matchingRule the matchingRule to set
+     */
+    public void setMatchingRule( boolean matchingRule )
+    {
+        this.matchingRule = matchingRule;
+    }
+
+    /**
+     * @return the value
+     */
+    public String getValue()
+    {
+        return value;
+    }
+
+    /**
+     * @param value the value to set
+     */
+    public void setValue( String value )
+    {
+        this.value = value;
+    }
+}

Modified: directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhatClauseAttributes.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhatClauseAttributes.java?rev=1695215&r1=1695214&r2=1695215&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhatClauseAttributes.java
(original)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/main/java/org/apache/directory/studio/openldap/config/acl/model/AclWhatClauseAttributes.java
Tue Aug 11 06:09:47 2015
@@ -34,27 +34,36 @@ import java.util.List;
  * attr :: attributeType | '!' objectClass | '@' objectClass | 'entry' | 'children'
  * val-e ::= 'val' matchingRule style '=' attrval | e
  * matchingRule ::= '/matchingRule' | e
- * style ::= 'exact' | 'base' | 'baseobject' | 'regex' | 'one' | 'onelevel' | 'sub' | 'subtree'
| 'children'
+ * style ::= '.exact' | '.base' | '.baseobject' | '.regex' | '.one' | '.onelevel' | '.sub'
| '.subtree' | '.children'
  * attrval ::= STRING 
  * </pre>
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 public class AclWhatClauseAttributes
 {
-    /** The attributes list */
-    private List<String> attributes = new ArrayList<String>();
-
-
+    /** The attributeVal element */
+    private AclAttributeVal aclAttributeVal;
+    
+    
+    /**
+     * Creates an instance of AclWhatClauseAttributes
+     */
+    public AclWhatClauseAttributes()
+    {
+        aclAttributeVal = new AclAttributeVal();
+    }
+    
+    
     /**
      * Gets the attributes list.
      *
      * @return the attributes list
      */
-    public List<String> getAttributes()
+    public List<AclAttribute> getAttributes()
     {
-        List<String> copyAttributes = new ArrayList<String>( attributes.size()
);
+        List<AclAttribute> copyAttributes = new ArrayList<AclAttribute>( aclAttributeVal.getAclAttributes().size()
);
         
-        copyAttributes.addAll( attributes );
+        copyAttributes.addAll( aclAttributeVal.getAclAttributes() );
         
         return copyAttributes;
     }
@@ -67,18 +76,18 @@ public class AclWhatClauseAttributes
      */
     public void addAttribute( String attribute )
     {
-        attributes.add( attribute );
+        aclAttributeVal.getAclAttributes().add( new AclAttribute( attribute, null ) );
     }
 
 
     /**
      * Adds a {@link Collection} of attributes.
      * 
-     * @param c the {@link Collection} of attributes
+     * @param attributes the {@link Collection} of attributes
      */
-    public void addAllAttributes( Collection<String> c )
+    public void addAllAttributes( Collection<AclAttribute> attributes )
     {
-        attributes.addAll( c );
+        aclAttributeVal.getAclAttributes().addAll(  attributes );
     }
 
 
@@ -87,9 +96,85 @@ public class AclWhatClauseAttributes
      */
     public void clearAttributes()
     {
-        attributes.clear();
+        aclAttributeVal.getAclAttributes().clear();
+    }
+    
+    
+    /**
+     * @return true if the AclWhatClauseAttributes has a val flag
+     */
+    public boolean hasVal()
+    {
+        return aclAttributeVal.hasVal();
+    }
+    
+    
+    /**
+     * Set the val flag
+     * 
+     * @param val The val flag value
+     */
+    public void setVal( boolean val )
+    {
+        aclAttributeVal.setVal( val );
+    }
+    
+    
+    /**
+     * @return true if the AclWhatClauseAttributes has a MatchingRule flag
+     */
+    public boolean hasMatchingRule()
+    {
+        return aclAttributeVal.hasMatchingRule();
+    }
+    
+    
+    /**
+     * set the matchingRule flag
+     */
+    public void setMatchingRule( boolean matchingRule )
+    {
+        aclAttributeVal.setMatchingRule( matchingRule );
+    }
+
+    
+    /**
+     * @return The AclAttribute style
+     */
+    public AclAttributeStyleEnum getStyle()
+    {
+        return aclAttributeVal.getStyle();
     }
 
+    
+    /**
+     * @param style The AttributeVal style
+     */
+    public void setStyle( AclAttributeStyleEnum style )
+    {
+        aclAttributeVal.setStyle( style );
+    }
+
+    
+    /**
+     * @return The AclAttribute value
+     */
+    public String getValue()
+    {
+        return aclAttributeVal.getValue();
+    }
+
+    
+    /**
+     * Sets the AclWhatClauseAttributes value
+     * 
+     * @param value The AttributeVal value
+     */
+    public void setValue( String value )
+    {
+        aclAttributeVal.setValue( value );
+    }
+    
 
     /**
      * {@inheritDoc}
@@ -102,12 +187,12 @@ public class AclWhatClauseAttributes
         sb.append( "attrs" );
 
         // Attributes
-        if ( ( attributes != null ) && ( attributes.size() > 0 ) )
+        if ( ( aclAttributeVal.getAclAttributes() != null ) && ( aclAttributeVal.getAclAttributes().size()
> 0 ) )
         {
             sb.append( '=' );
             boolean isFirst = true;
             
-            for ( String attribute : attributes )
+            for ( AclAttribute attribute : aclAttributeVal.getAclAttributes() )
             {
                 if ( isFirst )
                 {
@@ -121,6 +206,26 @@ public class AclWhatClauseAttributes
                 sb.append( attribute );
             }
         }
+        
+        // The val
+        if ( aclAttributeVal.hasVal() )
+        {
+            sb.append( " val" );
+            
+            if ( aclAttributeVal.hasMatchingRule() )
+            {
+                sb.append( "/matchingRule" );
+            }
+            
+            if ( aclAttributeVal.getStyle() != AclAttributeStyleEnum.NONE )
+            {
+                sb.append( '.' );
+                sb.append( aclAttributeVal.getStyle().getName() );
+            }
+            
+            sb.append( '=' );
+            sb.append( aclAttributeVal.getValue() );
+        }
 
         return sb.toString();
     }

Modified: directory/studio/trunk/plugins/openldap.acl.editor/src/test/java/org/apache/directory/studio/openldap/config/acl/model/OpenLdapAclParserTest.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.acl.editor/src/test/java/org/apache/directory/studio/openldap/config/acl/model/OpenLdapAclParserTest.java?rev=1695215&r1=1695214&r2=1695215&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.acl.editor/src/test/java/org/apache/directory/studio/openldap/config/acl/model/OpenLdapAclParserTest.java
(original)
+++ directory/studio/trunk/plugins/openldap.acl.editor/src/test/java/org/apache/directory/studio/openldap/config/acl/model/OpenLdapAclParserTest.java
Tue Aug 11 06:09:47 2015
@@ -30,6 +30,7 @@ import static org.junit.Assert.fail;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.directory.studio.openldap.config.acl.model.AclAttribute;
 import org.junit.Ignore;
 import org.junit.Test;
 
@@ -529,9 +530,9 @@ public class OpenLdapAclParserTest
         assertNotNull( whatClause );
         AclWhatClauseAttributes whatClauseAttributes = whatClause.getAttributesClause();
         assertNotNull( whatClauseAttributes );
-        List<String> attributesList = whatClauseAttributes.getAttributes();
+        List<AclAttribute> attributesList = whatClauseAttributes.getAttributes();
         assertEquals( 1, attributesList.size() );
-        assertTrue( attributesList.contains( attribute ) );
+        assertEquals( attribute, attributesList.get( 0 ).getName() );
     }
 
 
@@ -552,9 +553,9 @@ public class OpenLdapAclParserTest
         assertNotNull( whatClause );
         AclWhatClauseAttributes whatClauseAttributes = whatClause.getAttributesClause();
         assertNotNull( whatClauseAttributes );
-        List<String> attributesList = whatClauseAttributes.getAttributes();
+        List<AclAttribute> attributesList = whatClauseAttributes.getAttributes();
         assertEquals( 1, attributesList.size() );
-        assertTrue( attributesList.contains( attribute ) );
+        assertEquals( attribute, attributesList.get( 0 ).getName() );
     }
 
 
@@ -575,9 +576,9 @@ public class OpenLdapAclParserTest
         assertNotNull( whatClause );
         AclWhatClauseAttributes whatClauseAttributes = whatClause.getAttributesClause();
         assertNotNull( whatClauseAttributes );
-        List<String> attributesList = whatClauseAttributes.getAttributes();
+        List<AclAttribute> attributesList = whatClauseAttributes.getAttributes();
         assertEquals( 1, attributesList.size() );
-        assertTrue( attributesList.contains( attribute ) );
+        assertEquals( attribute, attributesList.get( 0 ).getName() );
     }
 
 
@@ -602,11 +603,11 @@ public class OpenLdapAclParserTest
         assertNotNull( whatClause );
         AclWhatClauseAttributes whatClauseAttributes = whatClause.getAttributesClause();
         assertNotNull( whatClauseAttributes );
-        List<String> attributesList = whatClauseAttributes.getAttributes();
+        List<AclAttribute> attributesList = whatClauseAttributes.getAttributes();
         assertEquals( 3, attributesList.size() );
-        assertTrue( attributesList.contains( attribute1 ) );
-        assertTrue( attributesList.contains( attribute2 ) );
-        assertTrue( attributesList.contains( attribute3 ) );
+        assertEquals( attribute1, attributesList.get( 0 ).getName() );
+        assertEquals( attribute2, attributesList.get( 1 ).getName() );
+        assertEquals( attribute3, attributesList.get( 2 ).getName() );
     }
 
 
@@ -631,11 +632,11 @@ public class OpenLdapAclParserTest
         assertNotNull( whatClause );
         AclWhatClauseAttributes whatClauseAttributes = whatClause.getAttributesClause();
         assertNotNull( whatClauseAttributes );
-        List<String> attributesList = whatClauseAttributes.getAttributes();
+        List<AclAttribute> attributesList = whatClauseAttributes.getAttributes();
         assertEquals( 3, attributesList.size() );
-        assertTrue( attributesList.contains( attribute1 ) );
-        assertTrue( attributesList.contains( attribute2 ) );
-        assertTrue( attributesList.contains( attribute3 ) );
+        assertEquals( attribute1, attributesList.get( 0 ).getName() );
+        assertEquals( attribute2, attributesList.get( 1 ).getName() );
+        assertEquals( attribute3, attributesList.get( 2 ).getName() );
     }
 
 
@@ -824,9 +825,9 @@ public class OpenLdapAclParserTest
         assertEquals( dnPattern, whatClauseDn.getPattern() );
         AclWhatClauseAttributes whatClauseAttributes = whatClause.getAttributesClause();
         assertNotNull( whatClauseAttributes );
-        List<String> attributesList = whatClauseAttributes.getAttributes();
+        List<AclAttribute> attributesList = whatClauseAttributes.getAttributes();
         assertEquals( 1, attributesList.size() );
-        assertTrue( attributesList.contains( attribute ) );
+        assertEquals( attribute, attributesList.get( 0 ).getName() );
     }
 
 
@@ -856,9 +857,9 @@ public class OpenLdapAclParserTest
         assertEquals( filter, whatClauseFilter.getFilter() );
         AclWhatClauseAttributes whatClauseAttributes = whatClause.getAttributesClause();
         assertNotNull( whatClauseAttributes );
-        List<String> attributesList = whatClauseAttributes.getAttributes();
+        List<AclAttribute> attributesList = whatClauseAttributes.getAttributes();
         assertEquals( 1, attributesList.size() );
-        assertTrue( attributesList.contains( attribute ) );
+        assertEquals( attribute, attributesList.get( 0 ).getName() );
     }
 
 
@@ -883,9 +884,9 @@ public class OpenLdapAclParserTest
         assertEquals( filter, whatClauseFilter.getFilter() );
         AclWhatClauseAttributes whatClauseAttributes = whatClause.getAttributesClause();
         assertNotNull( whatClauseAttributes );
-        List<String> attributesList = whatClauseAttributes.getAttributes();
+        List<AclAttribute> attributesList = whatClauseAttributes.getAttributes();
         assertEquals( 1, attributesList.size() );
-        assertTrue( attributesList.contains( attribute ) );
+        assertEquals( attribute, attributesList.get( 0 ).getName() );
     }
 
 



Mime
View raw message