You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by er...@apache.org on 2006/12/28 22:54:27 UTC

svn commit: r490840 - in /directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/org/apache/directory/ldapstudio/aciitemeditor/widgets: ACIItemProtectedItemsComposite.java ACIItemUserClassesComposite.java

Author: ersiner
Date: Thu Dec 28 13:54:27 2006
New Revision: 490840

URL: http://svn.apache.org/viewvc?view=rev&rev=490840
Log:
Added try-catch blocks for DUMMY ACI parsing used in protectedItem and userClass determination.
When an error found, only relevant information is attached to the exception throws instead of attaching the DUMMY ACI string which does not have anything related with the original ACI being built.

Modified:
    directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemProtectedItemsComposite.java
    directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemUserClassesComposite.java

Modified: directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemProtectedItemsComposite.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemProtectedItemsComposite.java?view=diff&rev=490840&r1=490839&r2=490840
==============================================================================
--- directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemProtectedItemsComposite.java (original)
+++ directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemProtectedItemsComposite.java Thu Dec 28 13:54:27 2006
@@ -143,7 +143,7 @@
             classToDisplayMap.put( ProtectedItem.SelfValue.class, "Self Value" );
             classToDisplayMap.put( ProtectedItem.RangeOfValues.class, "Range of Values" );
             classToDisplayMap.put( ProtectedItem.MaxValueCount.class, "Max. Value Count" );
-            classToDisplayMap.put( ProtectedItem.MaxImmSub.class, "Max. Number of immediate Subordinates" );
+            classToDisplayMap.put( ProtectedItem.MaxImmSub.class, "Max. Number of Immediate Subordinates" );
             classToDisplayMap.put( ProtectedItem.RestrictedBy.class, "Restricted by" );
             classToDisplayMap.put( ProtectedItem.Classes.class, "Classes" );
         }
@@ -172,7 +172,7 @@
         }
         
         /**
-         * Creates a new protected item object. Therefor it uses the 
+         * Creates a new protected item object. Therefore it uses the 
          * dummy ACI, injects the protected item and its value, parses
          * the ACI and extracts the protected item from the parsed bean.
          *
@@ -186,7 +186,16 @@
             spec = spec.replaceAll( "#item#", type );
             spec = spec.replaceAll( "#value#", protectedItemValue );
             ACIItemParser parser = new ACIItemParser(null);
-            ItemFirstACIItem aci = ( ItemFirstACIItem ) parser.parse( spec );
+            ItemFirstACIItem aci = null;
+            try
+            {
+                aci = ( ItemFirstACIItem ) parser.parse( spec );
+            }
+            catch ( ParseException e)
+            {
+                throw new ParseException("Invalid protected item \"" + type 
+                    + "\" with value \"" + protectedItemValue + "\"", 0);
+            }
             ProtectedItem item = ( ProtectedItem ) aci.getProtectedItems().iterator().next();
             return item;
         }

Modified: directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemUserClassesComposite.java
URL: http://svn.apache.org/viewvc/directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemUserClassesComposite.java?view=diff&rev=490840&r1=490839&r2=490840
==============================================================================
--- directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemUserClassesComposite.java (original)
+++ directory/sandbox/seelmann/trunk/ldapstudio-aciitemeditor/src/org/apache/directory/ldapstudio/aciitemeditor/widgets/ACIItemUserClassesComposite.java Thu Dec 28 13:54:27 2006
@@ -132,7 +132,7 @@
         
         private static final String DUMMY = 
             "{ identificationTag \"id1\", precedence 1, authenticationLevel simple, "
-            + "itemOrUserFirst userFirst: { userClasses  { #item# #value# }, "
+            + "itemOrUserFirst userFirst: { userClasses  { #class# #value# }, "
             + "userPermissions { { protectedItems { entry }, grantsAndDenials { grantRead } } }"
             + " } }";
         
@@ -155,12 +155,21 @@
         
         public UserClass getUserClass() throws ParseException
         {
-            String type = classToItemMap.get( userClassClass );
+            String clazz = classToItemMap.get( userClassClass );
             String spec = DUMMY;
-            spec = spec.replaceAll( "#item#", type );
+            spec = spec.replaceAll( "#class#", clazz );
             spec = spec.replaceAll( "#value#", userClassValue );
             ACIItemParser parser = new ACIItemParser(null);
-            UserFirstACIItem aci = ( UserFirstACIItem ) parser.parse( spec );
+            UserFirstACIItem aci = null;
+            try
+            {
+                aci = ( UserFirstACIItem ) parser.parse( spec );
+            }
+            catch ( ParseException e )
+            {
+                throw new ParseException("Invalid user class \"" + clazz 
+                    + "\" with value \"" + userClassValue + "\"", 0);
+            }
             UserClass userClass = ( UserClass ) aci.getUserClasses().iterator().next();
             return userClass;
         }