xlawrence    2005/07/15 12:10:46 CEST

  Modified files:
    core/src/java/org/jahia/hibernate/model JahiaAcl.java 
    core/src/java/org/jahia/services/acl JahiaAbstractACL.java 
                                         JahiaBaseACL.java 
  Log:
  Added / changed implementation of method "getGroupEntry". Some methods in 
class JahiaAcl are still not implemented and now print out a "not implemented" 
fatal message and throw a RuntimeException with the same message.
  
  Revision  Changes    Path
  1.6       +79 -39    
jahia/core/src/java/org/jahia/hibernate/model/JahiaAcl.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/hibernate/model/JahiaAcl.java.diff?r1=1.5&r2=1.6&f=h
  1.7       +1 -3      
jahia/core/src/java/org/jahia/services/acl/JahiaAbstractACL.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/services/acl/JahiaAbstractACL.java.diff?r1=1.6&r2=1.7&f=h
  1.5       +2 -2      
jahia/core/src/java/org/jahia/services/acl/JahiaBaseACL.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/services/acl/JahiaBaseACL.java.diff?r1=1.4&r2=1.5&f=h
  
  
  
  Index: JahiaAcl.java
  ===================================================================
  RCS file: 
/home/cvs/repository/jahia/core/src/java/org/jahia/hibernate/model/JahiaAcl.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- JahiaAcl.java     12 Jul 2005 13:52:55 -0000      1.5
  +++ JahiaAcl.java     15 Jul 2005 10:10:45 -0000      1.6
  @@ -2,25 +2,37 @@
   
   import org.apache.commons.lang.builder.EqualsBuilder;
   import org.apache.commons.lang.builder.HashCodeBuilder;
  -import org.apache.commons.logging.Log;
  -import org.apache.commons.logging.LogFactory;
   import org.apache.commons.collections.FastHashMap;
  -import org.jahia.services.acl.*;
  +import org.jahia.services.acl.ACLInfo;
  +import org.jahia.services.acl.ACLResourceInterface;
  +import org.jahia.services.acl.JahiaBaseACL;
  +import org.jahia.services.acl.ParentACLFinder;
   import org.jahia.services.usermanager.JahiaUser;
   import org.jahia.services.usermanager.JahiaGroup;
   import org.jahia.services.usermanager.JahiaGroupManagerService;
   import org.jahia.registries.ServicesRegistry;
   
   import java.io.Serializable;
  -import java.util.*;
  +
   import java.security.Principal;
   import java.security.acl.Group;
   
  +import java.util.Enumeration;
  +import java.util.Hashtable;
  +import java.util.Iterator;
  +import java.util.List;
  +import java.util.Map;
  +import java.util.Set;
  +import java.util.Vector;
  +import org.jahia.services.acl.JahiaACLEntry;
  +
  +
   /**
    * @hibernate.class table="jahia_acl" lazy="false"
    * @hibernate.cache usage="read-write"
    */
  -public class JahiaAcl implements Serializable,Cloneable, ParentACLFinder, 
ACLResourceInterface,ACLInfo {
  +public class JahiaAcl implements Serializable, Cloneable, ParentACLFinder, 
  +        ACLResourceInterface, ACLInfo {
   // ------------------------------ FIELDS ------------------------------
   
       /**
  @@ -32,7 +44,10 @@
        * nullable persistent field
        */
       private Integer inheritance;
  -    private Log log = LogFactory.getLog(JahiaAcl.class);
  +    
  +    private static org.apache.log4j.Logger logger =
  +            org.apache.log4j.Logger.getLogger (JahiaAcl.class);
  +    
       private Map groupEntries;
   
       /**
  @@ -281,7 +296,7 @@
   
       public String toString() {
           return new StringBuffer(getClass().getName())
  -                .append("id="+getId())
  +                .append("id=").append(getId())
                   .toString();
       }
   
  @@ -379,7 +394,6 @@
                   Hashtable groupTable = new Hashtable ();
                   recursePermissions (userTable, groupTable);
   
  -
                   // Check if the user is explicitely mentioned in the ACL, 
look up
                   // recursively the user in the tree.
                   result = getUserPermissionInHashtable (user, permission, 
userTable);
  @@ -473,7 +487,7 @@
   
           Vector result = getNameList (userTable, entry);
           for (int k = 0; k < result.size (); k++) {
  -            log.debug ("Name=" + (String) result.get (k));
  +            logger.debug ("Name=" + (String) result.get (k));
               final org.jahia.hibernate.model.JahiaAcl parent = getParent ();
               if (parent != null) {
                   JahiaUser user = ServicesRegistry
  @@ -482,7 +496,7 @@
                           .lookupUser ((String) result.get (k));
                   JahiaAclEntry parentEntry = (JahiaAclEntry) 
parent.getUserEntries().get(user.getName()) ;
                   if (parentEntry != null) {
  -                    log.debug ("parentAclEntry=" + parentEntry.toString ());
  +                    logger.debug ("parentAclEntry=" + parentEntry.toString 
());
                   }
               }
           }
  @@ -498,16 +512,16 @@
               JahiaGroup group = ServicesRegistry.getInstance ().
                       getJahiaGroupManagerService ().lookupGroup (groupname);
               if (group == null) {
  -                log.warn("Group " + groupname + " not found in manager 
service but present in ACL " + getId());
  +                logger.warn("Group " + groupname + " not found in manager 
service but present in ACL " + getId());
                   continue;
               }
  -            Enumeration enum = group.members ();
  +            Enumeration membersEnum = group.members ();
   
  -            if (enum != null) {
  +            if (membersEnum != null) {
                   Principal p = null;
   
  -                while (enum.hasMoreElements ()) {
  -                    p = (Principal) enum.nextElement ();
  +                while (membersEnum.hasMoreElements ()) {
  +                    p = (Principal) membersEnum.nextElement ();
                       if (!(p instanceof Group)) {
                           JahiaUser user = (JahiaUser) p;
                           if ((user != null) && (!result.contains 
(user.getName ()))) {
  @@ -544,7 +558,7 @@
               }
               groupname = null;
               group = null;
  -            enum = null;
  +            membersEnum = null;
           }
           return result;
       }
  @@ -677,7 +691,7 @@
                       try {
                           table.put(name, localEntry.clone());
                       } catch (CloneNotSupportedException e) {
  -                        log.warn("Try to clone uncloeable object", e);
  +                        logger.warn("Try to clone unclonable object", e);
                       }
                   }
                   localEntry = null;
  @@ -826,44 +840,70 @@
           }
       }
   
  -    public ACLResourceInterface getParent(ACLResourceInterface aclResource) {
  -        return null;  //To change body of implemented methods use File | 
Settings | File Templates.
  -    }
  -
       public JahiaBaseACL getACL() {
  -        return null;  //To change body of implemented methods use File | 
Settings | File Templates.
  +        try {
  +            return new JahiaBaseACL(getAclID());
  +        } catch (Throwable t) {
  +            // this should never happen
  +            return null;
  +        }
       }
   
       public int getAclID() {
  -        return 0;  //To change body of implemented methods use File | 
Settings | File Templates.
  +        return id.intValue(); 
       }
  -
  -    public List getUsernameList(ParentACLFinder parentACLFinder, 
ACLResourceInterface aclResource, JahiaACLEntry entry) {
  -        return null;  //To change body of created methods use File | 
Settings | File Templates.
  +    
  +    public ACLResourceInterface getParent(ACLResourceInterface aclResource) {
  +        logger.fatal("Not implemented !");
  +        throw new RuntimeException("Not implemented !");
  +//        return null;  //To change body of implemented methods use File | 
Settings | File Templates.
       }
  -
  -    public JahiaAclEntry getGroupEntry(JahiaGroup group) {
  -        return null;  //To change body of created methods use File | 
Settings | File Templates.
  +    
  +    public List getUsernameList(ParentACLFinder parentACLFinder, 
ACLResourceInterface aclResource, JahiaACLEntry entry) {
  +        logger.fatal("Not implemented !");
  +        throw new RuntimeException("Not implemented !");
  +//        return null;  //To change body of created methods use File | 
Settings | File Templates.
       }
  -
  +    
       public List getGroupnameList(ParentACLFinder parentACLFinder, 
ACLResourceInterface aclResource, JahiaACLEntry entry) {
  -        return null;  //To change body of created methods use File | 
Settings | File Templates.
  +        logger.fatal("Not implemented !");
  +        throw new RuntimeException("Not implemented !");
  +//        return null;  //To change body of created methods use File | 
Settings | File Templates.
       }
  -
  +    
       public List getGroupnameListNoAdmin(ParentACLFinder parentACLFinder, 
ACLResourceInterface aclResource, JahiaACLEntry entry) {
  -        return null;  //To change body of created methods use File | 
Settings | File Templates.
  +        throw new RuntimeException("Not implemented !");
  +//        return null;  //To change body of created methods use File | 
Settings | File Templates.
       }
  -
  +    
       public boolean getPermission(ParentACLFinder parentACLFinder, 
ACLResourceInterface aclResource, JahiaUser user, int permission) {
  -        return false;  //To change body of created methods use File | 
Settings | File Templates.
  +        logger.fatal("Not implemented !");
  +        throw new RuntimeException("Not implemented !");
  +//        return false;  //To change body of created methods use File | 
Settings | File Templates.
       }
  -
  +    
       public boolean getPermission(ParentACLFinder parentACLFinder, 
ACLResourceInterface aclResource, JahiaGroup group, int permission) {
  -        return false;  //To change body of created methods use File | 
Settings | File Templates.
  +        boolean result = false;
  +        
  +        if (group != null) {
  +            Hashtable table = new Hashtable();
  +            recursePermissions(null, table);
  +            JahiaACLEntry entry = (JahiaACLEntry) table.get(group.getName());
  +            if (entry != null) {
  +                result = (entry.getPermission(permission) ==
  +                        JahiaACLEntry.ACL_YES);
  +            }
  +            table = null;
  +            entry = null;
  +        }
  +        
  +        return result;
       }
  -
  +    
       public List getUsernameListAlsoGroupUsers(ParentACLFinder 
parentACLFinder, ACLResourceInterface aclResource, JahiaACLEntry entry) {
  -        return null;  //To change body of created methods use File | 
Settings | File Templates.
  +        logger.fatal("Not implemented !");
  +        throw new RuntimeException("Not implemented !");
  +//        return null;  //To change body of created methods use File | 
Settings | File Templates.
       }
   }
   
  
  
  
  Index: JahiaAbstractACL.java
  ===================================================================
  RCS file: 
/home/cvs/repository/jahia/core/src/java/org/jahia/services/acl/JahiaAbstractACL.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- JahiaAbstractACL.java     22 Jun 2005 12:33:09 -0000      1.6
  +++ JahiaAbstractACL.java     15 Jul 2005 10:10:45 -0000      1.7
  @@ -38,8 +38,6 @@
    * ----- END LICENSE BLOCK -----
    */
   
  -
  -
   package org.jahia.services.acl;
   
   import org.jahia.exceptions.JahiaException;
  @@ -418,7 +416,7 @@
       public JahiaAclEntry getGroupEntry (JahiaGroup group)
               throws JahiaACLException {
           testProxy ();
  -        return mACL.getGroupEntry (group);
  +        return (JahiaAclEntry) mACL.getGroupEntries().get(group.getName());
       }
   
   
  
  
  
  Index: JahiaBaseACL.java
  ===================================================================
  RCS file: 
/home/cvs/repository/jahia/core/src/java/org/jahia/services/acl/JahiaBaseACL.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- JahiaBaseACL.java 22 Jun 2005 12:33:09 -0000      1.4
  +++ JahiaBaseACL.java 15 Jul 2005 10:10:45 -0000      1.5
  @@ -69,7 +69,7 @@
        * @return A vector of string {"Read", "Write", "Admin"}
        */
       public Vector getBitdesc () {
  -        Vector bits = new Vector ();
  +        final Vector bits = new Vector ();
   
           bits.add ("Read");
           bits.add ("Write");
  @@ -91,7 +91,7 @@
       public Object clone () {
   
           try {
  -            JahiaBaseACL baseACL = new JahiaBaseACL ();
  +            final JahiaBaseACL baseACL = new JahiaBaseACL ();
               baseACL.mACL = (JahiaAcl) mACL.clone ();
               return baseACL;
           } catch (JahiaException ex) {
  

Reply via email to