Author: bpapez
Date: Mon Jul  2 16:31:47 2007
New Revision: 17862

URL: https://svndev.jahia.net/websvn/listing.php?sc=3D1&rev=3D17862&repname=
=3Djahia
Log:
minor refactorings (similar to Jahia 4)

Modified:
    trunk/core/src/java/org/jahia/hibernate/model/JahiaAcl.java
    trunk/core/src/java/org/jahia/services/acl/JahiaAbstractACL.java

Modified: trunk/core/src/java/org/jahia/hibernate/model/JahiaAcl.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/trunk/core/src/java/o=
rg/jahia/hibernate/model/JahiaAcl.java&rev=3D17862&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/core/src/java/org/jahia/hibernate/model/JahiaAcl.java (original)
+++ trunk/core/src/java/org/jahia/hibernate/model/JahiaAcl.java Mon Jul  2 =
16:31:47 2007
@@ -498,9 +498,6 @@
         }
         Vector groupList =3D getNameList (groupTable, entry);
 =

-        userTable =3D null;
-        groupTable =3D null;
-
         // add in the result all users from every group that also have this
         // access except for users that have excplicitely a NO access
         for (int i =3D 0; i < groupList.size (); i++) {
@@ -514,7 +511,7 @@
             Enumeration membersEnum =3D group.members ();
 =

             if (membersEnum !=3D null) {
-                Principal p =3D null;
+                Principal p;
 =

                 while (membersEnum.hasMoreElements ()) {
                     p =3D (Principal) membersEnum.nextElement ();
@@ -547,14 +544,9 @@
                                 }
                             }
                         }
-                        user =3D null;
                     }
                 }
-                p =3D null;
             }
-            groupname =3D null;
-            group =3D null;
-            membersEnum =3D null;
         }
         return new Vector(result);
     }
@@ -687,13 +679,8 @@
                         logger.warn("Try to clone unclonable object", e);
                     }
                 }
-                localEntry =3D null;
-                entry =3D null;
             }
         } // while
-
-        name =3D null;
-        keys =3D null;
     }
 =

     /**
@@ -705,93 +692,82 @@
      * @return a vector of user/group name.
      */
     private Vector getNameList(Map HashMap, JahiaAclEntry entry) {
-        Vector result;
 =

-        if (entry =3D=3D null) {
+        if (entry =3D=3D null) =

             return getKeysFromHashMap(HashMap);
-        } else {
-            result =3D new Vector();
-            Iterator keys =3D HashMap.keySet().iterator();
-            while (keys.hasNext()) {
-                String name =3D (String) keys.next();
-                JahiaAclEntry HashMapEntry =3D (JahiaAclEntry) HashMap.get=
(name);
-                if (HashMapEntry.hasSameBitsActivated(entry)) {
-                    result.add(name);
-                }
-            }
-        }
+
+        Vector result =3D new Vector();
+               Iterator keys =3D HashMap.keySet().iterator();
+               while (keys.hasNext()) {
+                       String name =3D (String) keys.next();
+                       JahiaAclEntry HashMapEntry =3D (JahiaAclEntry) 
HashMap.get(name);
+                       if (HashMapEntry.hasSameBitsActivated(entry)) {
+                               result.add(name);
+                       }
+               }
+
         return result;
     }
 =

     /**
-     * Search recursively the user permission in the ACL.
-     *
-     * @param user
-     * @param permission
-     * @param table
-     *
-     * @return Return 1 if the user has the requested permission, 0 if the=
 user
-     *         has no permission and -1 if the user was not found.
-     *
-     * @todo This code has to be reviewed
-     */
+        * Search recursively the user permission in the ACL.
+        * =

+        * @param user
+        * @param permission
+        * @param table
+        * =

+        * @return Return 1 if the user has the requested permission, 0 if the 
us=
er
+        *         has no permission and -1 if the user was not found.
+        * =

+        * @todo This code has to be reviewed
+        */
     private int getUserPermissionInGroupHashMap (JahiaUser user, int permi=
ssion, Map table) {
         int result =3D -1;
 =

         // Check if the user has the requested permission in one of the gr=
oup entries.
-        Iterator names =3D table.keySet ().iterator();
-        while (names.hasNext() ) {
-            String groupname =3D (String) names.next();
+        for (Iterator keys =3D table.keySet().iterator(); keys.hasNext();)=
 {
+            String groupname =3D (String) keys.next();
             JahiaGroup group =3D ServicesRegistry.getInstance ().
                     getJahiaGroupManagerService ().lookupGroup (groupname);
 =

-            if (group !=3D null) {
-                //System.out.println (group.toString());
-
                 // Check if the user is member of the group
-
-                if (group.isMember (user)) {
-                    //System.out.println ("FH : user ["+user.getUsername()=
+"::"+user.getName()+"] is member of group ["+group.getName()+"::"+group.ge=
tGroupname()+"]");
-
-                    // if it's the first time the user is found in a group=
, set by default
-                    // the "deny" permission. If the user has the permissi=
on, it will be
-                    // given later.
-                    if (result < 0) {
-                        result =3D 0;
-                    }
-
-                    // Get the permission entries for the group and check =
it.
-                    JahiaAclEntry entry =3D (JahiaAclEntry) table.get (gro=
upname);
-                    if (entry.getPermission (permission) =3D=3D
-                            JahiaAclEntry.ACL_YES) {
-                        result =3D 1;
-                    }
-                    entry =3D null;
-                } else {
-                    //System.out.println ("FH : user ["+user.getUsername()=
+"::"+user.getName()+"] is not member of group ["+group.getName()+"::"+grou=
p.getGroupname()+"]");
-                }
+                       if (group !=3D null && group.isMember(user)) {
+                               // if it's the first time the user is found in 
a group, set by
+                               // default the "deny" permission. If the user 
has the =

+                               // permission, it will be given later.
+                               if (result < 0) {
+                                       result =3D 0;
+                               }
+
+                               // Get the permission entries for the group and 
check it.
+                               JahiaAclEntry entry =3D (JahiaAclEntry) 
table.get(groupname);
+                               if (entry.getPermission(permission) =3D=3D 
JahiaAclEntry.ACL_YES) {
+                                       result =3D 1;
+                               }
+                               if (result =3D=3D 1) {
+                                       if (logger.isDebugEnabled())
+                                               logger.debug("Permission for " 
+ user.getName()
+                                                               + " found in 
group " + group.getName());
+                                       break;
+                               }                    =

             } // if
-
-            groupname =3D null;
-            group =3D null;
-        } // while
-        names =3D null;
+        } // for
 =

         return result;
     }
 =

     /**
-     * Search recursively the user permission in the ACL.
-     *
-     * @param user
-     * @param permission
-     * @param table
-     *
-     * @return Return 1 if the user has the requested permission, 0 if the=
 user
-     *         has no permission and -1 if the user was not found.
-     *
-     * @todo This code has to be reviewed
-     */
+        * Search recursively the user permission in the ACL.
+        * =

+        * @param user
+        * @param permission
+        * @param table
+        * =

+        * @return Return 1 if the user has the requested permission, 0 if the 
us=
er
+        *         has no permission and -1 if the user was not found.
+        * =

+        * @todo This code has to be reviewed
+        */
     private int getUserPermissionInHashMap (JahiaUser user, int permission=
, Map table) {
         int result =3D -1; // start as if the user was not found.
 =

@@ -808,7 +784,6 @@
                     break;
             }
         }
-        entry =3D null;
 =

         return result;
     }
@@ -928,7 +903,6 @@
          * to retrieve the siteID from the content object.
          **/
         ProcessingContext processingContext =3D Jahia.getThreadParamBean();
-        JahiaGroup adminGroup =3D null;
         int contextSiteID =3D -1;
         if (processingContext !=3D null) {
             contextSiteID =3D processingContext.getSiteID();
@@ -949,8 +923,6 @@
                 result =3D (entry.getPermission(permission) =3D=3D
                         JahiaAclEntry.ACL_YES);
             }
-            table =3D null;
-            entry =3D null;
         }
 =

         return result;

Modified: trunk/core/src/java/org/jahia/services/acl/JahiaAbstractACL.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/trunk/core/src/java/o=
rg/jahia/services/acl/JahiaAbstractACL.java&rev=3D17862&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/core/src/java/org/jahia/services/acl/JahiaAbstractACL.java (origi=
nal)
+++ trunk/core/src/java/org/jahia/services/acl/JahiaAbstractACL.java Mon Ju=
l  2 16:31:47 2007
@@ -77,7 +77,7 @@
         return sharedActionsNames;
     }
     =

-    protected static final char[] getSharedActions() {
+    protected static char[] getSharedActions() {
         if (sharedActions =3D=3D null) {
             sharedActionsNames =3D Collections.unmodifiableList(Arrays.asL=
ist(new String[]{"Read", "Write", "Admin"}));
             sharedActions =3D new char[]{'r', 'w', 'A'};            =

@@ -87,7 +87,7 @@
         return sharedActions;
     }
     =

-    protected static final char[] getUppercaseSharedActions() {
+    protected static char[] getUppercaseSharedActions() {
         if (uppercaseSharedActions =3D=3D null)
             getSharedActions(); // init list        =

         return uppercaseSharedActions;        =

@@ -748,8 +748,8 @@
                     hasPermission =3D true;
                 } else {
                     int size =3D v.size ();
-                    String grpName =3D null;
-                    JahiaGroup grp =3D null;
+                    String grpName;
+                    JahiaGroup grp;
                     for (int i =3D 0; i < size; i++) {
                         grpName =3D (String) v.get (i);
                         grp =3D ServicesRegistry.getInstance ()
@@ -828,8 +828,8 @@
                     hasPermission =3D true;
                 } else {
                     int size =3D v.size ();
-                    String grpName =3D null;
-                    JahiaGroup grp =3D null;
+                    String grpName;
+                    JahiaGroup grp;
                     for (int i =3D 0; i < size; i++) {
                         grpName =3D (String) v.get (i);
                         grp =3D ServicesRegistry.getInstance ()

_______________________________________________
cvs_list mailing list
[email protected]
http://lists.jahia.org/cgi-bin/mailman/listinfo/cvs_list

Reply via email to