Author: bpapez
Date: Mon Jul 2 16:30:54 2007
New Revision: 17859
URL: https://svndev.jahia.net/websvn/listing.php?sc=3D1&rev=3D17859&repname=
=3Djahia
Log:
minor refactorings (similar to Jahia 4)
Modified:
branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/hibernate/model/Ja=
hiaAcl.java
branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/acl/Jahia=
AbstractACL.java
Modified: branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/hibernate/mo=
del/JahiaAcl.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/java/org/jahia/hibernate/model/JahiaAcl.java&rev=3D17859&r=
epname=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
--- branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/hibernate/model/Ja=
hiaAcl.java (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/hibernate/model/Ja=
hiaAcl.java Mon Jul 2 16:30:54 2007
@@ -538,9 +538,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++) {
@@ -554,7 +551,7 @@
Enumeration membersEnum =3D group.members ();
=
if (membersEnum !=3D null) {
- Principal p =3D null;
+ Principal p;
=
while (membersEnum.hasMoreElements ()) {
p =3D (Principal) membersEnum.nextElement ();
@@ -587,14 +584,9 @@
}
}
}
- user =3D null;
}
}
- p =3D null;
}
- groupname =3D null;
- group =3D null;
- membersEnum =3D null;
}
return new Vector(result);
}
@@ -735,13 +727,8 @@
logger.warn("Try to clone unclonable object", e);
}
}
- localEntry =3D null;
- entry =3D null;
}
} // while
-
- name =3D null;
- keys =3D null;
}
=
/**
@@ -753,77 +740,69 @@
* @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;
- }
+ // Check if the user is member of the group
=
- // 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, se=
t 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 (groupna=
me);
+ 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
+ } // for
=
- groupname =3D null;
- group =3D null;
- } // while
- names =3D null;
=
return result;
}
@@ -856,7 +835,6 @@
break;
}
}
- entry =3D null;
=
return result;
}
@@ -976,7 +954,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();
@@ -997,8 +974,6 @@
result =3D (entry.getPermission(permission) =3D=3D
JahiaAclEntry.ACL_YES);
}
- table =3D null;
- entry =3D null;
}
=
return result;
Modified: branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/acl=
/JahiaAbstractACL.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/java/org/jahia/services/acl/JahiaAbstractACL.java&rev=3D17=
859&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
--- branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/acl/Jahia=
AbstractACL.java (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/acl/Jahia=
AbstractACL.java Mon Jul 2 16:30:54 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