portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject cvs commit: jakarta-jetspeed/src/java/org/apache/jetspeed/services/profiler JetspeedProfilerService.java
Date Sun, 10 Feb 2002 08:00:12 GMT
taylor      02/02/10 00:00:12

  Modified:    src/java/org/apache/jetspeed/modules/actions
                        JetspeedSessionValidator.java
               src/java/org/apache/jetspeed/services/profiler
                        JetspeedProfilerService.java
  Log:
  - removed extra getProfile from JetspeedSessionValidator
  - added role-based fallback to profiler
  
  Revision  Changes    Path
  1.13      +1 -12     jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/JetspeedSessionValidator.java
  
  Index: JetspeedSessionValidator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/JetspeedSessionValidator.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- JetspeedSessionValidator.java	9 Jan 2002 12:14:20 -0000	1.12
  +++ JetspeedSessionValidator.java	10 Feb 2002 08:00:11 -0000	1.13
  @@ -82,7 +82,7 @@
   @author <a href="mailto:ingo@raleigh.ibm.com">Ingo Schuster</a>
   @author <a href="mailto:raphael@apache.org">RaphaŽl Luta</a>
   @author <a href="mailto:sgala@apache.org">Santiago Gala</a>
  -@version $Id: JetspeedSessionValidator.java,v 1.12 2002/01/09 12:14:20 kimptoc Exp $
  +@version $Id: JetspeedSessionValidator.java,v 1.13 2002/02/10 08:00:11 taylor Exp $
   */
   public class JetspeedSessionValidator extends TemplateSessionValidator
   {
  @@ -165,17 +165,6 @@
               jdata.setPortlet(paramPortlet);
           }
           
  -        // get the profile and store it in the RunData
  -        Profile newProfile = Profiler.getProfile(jdata);
  -        Profile currentProfile = jdata.getProfile();
  -        
  -        if ((currentProfile == null)
  -         || (!currentProfile.equals(newProfile)))
  -        {
  -            // the profile changed due to the request parameters,
  -            // change it in the RunData
  -            jdata.setProfile(newProfile);
  -        }
       }
   
       /**
  
  
  
  1.21      +60 -3     jakarta-jetspeed/src/java/org/apache/jetspeed/services/profiler/JetspeedProfilerService.java
  
  Index: JetspeedProfilerService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/profiler/JetspeedProfilerService.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- JetspeedProfilerService.java	3 Jan 2002 19:00:46 -0000	1.20
  +++ JetspeedProfilerService.java	10 Feb 2002 08:00:12 -0000	1.21
  @@ -84,11 +84,14 @@
   import org.apache.turbine.services.template.TurbineTemplate;
   import org.apache.turbine.services.resources.ResourceService;
   import org.apache.turbine.util.security.DataBackendException;
  +import org.apache.turbine.util.security.AccessControlList;
   
   // turbine.om
   import org.apache.turbine.om.security.User;
   import org.apache.turbine.om.security.Role;
   import org.apache.turbine.om.security.Group;
  +import org.apache.turbine.util.security.RoleSet;
  +
   // jetspeed.om
   import org.apache.jetspeed.om.profile.*;
   import org.apache.jetspeed.om.registry.RegistryException;
  @@ -131,7 +134,7 @@
    *
    * @author <a href="mailto:david@bluesunrise.com">David Sean Taylor</a>
    * @author <a href="mailto:sgala@hisitech.com">Santiago Gala</a>
  - * @version $Id: JetspeedProfilerService.java,v 1.20 2002/01/03 19:00:46 sgala Exp $
  + * @version $Id: JetspeedProfilerService.java,v 1.21 2002/02/10 08:00:12 taylor Exp $
    */
   
   public class JetspeedProfilerService  extends TurbineBaseService
  @@ -143,12 +146,14 @@
       private final static String CONFIG_RESOURCE_EXT     = ".resource.ext";
       private final static String CONFIG_SECURITY         = ".security";
       private final static String CONFIG_LANGUAGE         = ".language";
  -
  +    private final static String CONFIG_ROLE_FALLBACK    = ".rolefallback";
  +                                          
       // default configuration values
       private final static String DEFAULT_CONFIG_RESOURCE_DEFAULT = "default";
       private final static String DEFAULT_CONFIG_RESOURCE_EXT = ".psml";
       private final static boolean DEFAULT_CONFIG_SECURITY = false;
       private final static boolean DEFAULT_CONFIG_LANGUAGE = true;
  +    private final static boolean DEFAULT_CONFIG_ROLE_FALLBACK = true;
   
       private final static String PATH_EXTENSION_DELIMITER = ".";
       // messages
  @@ -164,8 +169,9 @@
       // MODIFIED: A. Kempf
       String parentAccount = null;   // the parent account which is used to create profiles
   
  -    boolean useSecurity = false;   // use security features
  +    boolean useSecurity = true;   // use security features
       boolean useLanguage = true;    // use extended language mapping features
  +    boolean useRoleFallback = true;
   
       // lookup a media type based on mime-type
       private Map mediaMap = null;
  @@ -254,6 +260,50 @@
       public Profile getProfile(RunData rundata, CapabilityMap cm)
           throws ProfileException
       {
  +        Profile profile = fallbackProfile(rundata, cm);
  +        if (null == profile && useRoleFallback) 
  +        {
  +            User user = rundata.getUser();
  +            if (user != null)
  +            {
  +                try
  +                {
  +                    AccessControlList acl = rundata.getACL();
  +                    RoleSet roles = acl.getRoles(JetspeedSecurity.getGroup(JetspeedSecurity.JETSPEED_GROUP));

  +                    if (roles != null)
  +                    {
  +                        Iterator it = roles.elements();
  +                        while (it.hasNext())
  +                        {
  +                            // note: this is an unordered list. will need to change db
schema to order it
  +                            Role role = (Role)it.next();
  +                            rundata.getParameters().setString( Profiler.PARAM_ROLE, role.getName()
);
  +                            profile = fallbackProfile(rundata, cm);
  +                            if (profile != null)
  +                                break;
  +                        }
  +                    }
  +                }
  +                catch (Exception e)
  +                {
  +                    throw new ProfileException(e.toString());
  +                }
  +            }
  +        }
  +        return profile;
  +    }
  +
  +    /**
  +     *  get the Profile object using the Rundata state and capability map
  +     *  this is the mapping functionality of the profiler
  +     *
  +     * @param rundata the rundata object for the current request
  +     * @param cm the <code>CapabilityMap</code> of the current requesting device
  +     * @return a new Profile object
  +     */
  +    private Profile fallbackProfile(RunData rundata, CapabilityMap cm)
  +        throws ProfileException
  +    {
           try
           {
               Profile profile = new BaseProfile();
  @@ -621,7 +671,11 @@
           ResourceService serviceConf = ((TurbineServices)TurbineServices.getInstance())
                                                        .getResources(ProfilerService.SERVICE_NAME);
   
  +
  +        resourceDefault = serviceConf.getString( CONFIG_RESOURCE_DEFAULT );
  +        resourceDefault = serviceConf.getString( "services.Profiler.resource.default" );
           resourceDefault = serviceConf.getString( CONFIG_RESOURCE_DEFAULT, DEFAULT_CONFIG_RESOURCE_DEFAULT
);
  +        
   
           resourceExt = serviceConf.getString( CONFIG_RESOURCE_EXT, DEFAULT_CONFIG_RESOURCE_EXT
);
           if (-1 == resourceExt.indexOf(PATH_EXTENSION_DELIMITER))
  @@ -629,6 +683,9 @@
   
           useSecurity = serviceConf.getBoolean( CONFIG_SECURITY, DEFAULT_CONFIG_SECURITY
);
           useLanguage = serviceConf.getBoolean( CONFIG_LANGUAGE, DEFAULT_CONFIG_LANGUAGE
);
  +
  +        useRoleFallback = serviceConf.getBoolean( CONFIG_ROLE_FALLBACK, DEFAULT_CONFIG_ROLE_FALLBACK
);
  +
       }
   
      /**
  
  
  

--
To unsubscribe, e-mail:   <mailto:jetspeed-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:jetspeed-dev-help@jakarta.apache.org>


Mime
View raw message