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-2/portal/src/java/org/apache/jetspeed/profiler/impl ProfilerValveImpl.java
Date Fri, 15 Oct 2004 07:05:09 GMT
taylor      2004/10/15 00:05:09

  Modified:    portal/src/java/org/apache/jetspeed/profiler/impl
                        ProfilerValveImpl.java
  Log:
  patch from Randy Watler
  implementation of using a named profile locator specified in the docset metadata to find
'docsets'
  here we build the locator collections for finding pages and docsets and ...
  
  Revision  Changes    Path
  1.16      +29 -7     jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/impl/ProfilerValveImpl.java
  
  Index: ProfilerValveImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/profiler/impl/ProfilerValveImpl.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- ProfilerValveImpl.java	8 Oct 2004 06:49:37 -0000	1.15
  +++ ProfilerValveImpl.java	15 Oct 2004 07:05:09 -0000	1.16
  @@ -16,7 +16,11 @@
   package org.apache.jetspeed.profiler.impl;
   
   import java.io.IOException;
  +import java.security.Principal;
  +import java.util.HashMap;
  +import java.util.Map;
   
  +import javax.security.auth.Subject;
   import javax.servlet.http.HttpServletRequest;
   
   import org.apache.commons.logging.Log;
  @@ -27,10 +31,14 @@
   import org.apache.jetspeed.pipeline.valve.AbstractValve;
   import org.apache.jetspeed.pipeline.valve.PageProfilerValve;
   import org.apache.jetspeed.pipeline.valve.ValveContext;
  +import org.apache.jetspeed.profiler.impl.JetspeedProfiledPageContext;
   import org.apache.jetspeed.profiler.ProfileLocator;
   import org.apache.jetspeed.profiler.ProfiledPageContext;
   import org.apache.jetspeed.profiler.Profiler;
  +import org.apache.jetspeed.profiler.ProfilerException;
   import org.apache.jetspeed.request.RequestContext;
  +import org.apache.jetspeed.security.SecurityHelper;
  +import org.apache.jetspeed.security.UserPrincipal;
   
   /**
    * ProfilerValveImpl
  @@ -63,16 +71,29 @@
       {
           try
           {
  -            // perform profiling to get profiled page context using
  -            // the profiler and page manager
  -            ProfileLocator locator = profiler.getProfile(request, ProfileLocator.PAGE_LOCATOR);
  -            ProfiledPageContext profiledPageContext = pageManager.getProfiledPageContext(locator);
  -            if ((profiledPageContext == null) || (profiledPageContext.getPage() == null)
|| (profiledPageContext.getLocator() == null)) 
  +            // get profiler locators for request subject/principal using the profiler
  +            Subject subject = request.getSubject();
  +            if (subject == null)
  +                throw new ProfilerException("Missing subject for request: " + request.getPath());
  +            Principal principal = SecurityHelper.getBestPrincipal(subject, UserPrincipal.class);
  +            if (principal == null)
  +                throw new ProfilerException("Missing principal for request: " + request.getPath());
  +            String [] locatorNames = profiler.getLocatorNamesForPrincipal(principal);
  +            if ((locatorNames == null) || (locatorNames.length == 0))
  +                locatorNames = new String[]{ProfileLocator.PAGE_LOCATOR};
  +            Map locators = (Map) new HashMap(16);
  +            for (int i = 0; (i < locatorNames.length); i++)
  +                locators.put(locatorNames[i], profiler.getProfile(request,locatorNames[i]));
  +
  +            // get profiled page context using the profiler and page manager
  +            ProfiledPageContext profiledPageContext = profiler.createProfiledPageContext(locators);
  +            pageManager.computeProfiledPageContext(profiledPageContext);
  +            if (profiledPageContext.getPage() == null)
                   throw new NodeNotFoundException("Unable to profile request: " + request.getPath());
   
               // set request page and profile locator
               request.setPage(profiledPageContext.getPage());
  -            request.setProfileLocator(profiledPageContext.getLocator());
  +            request.setProfileLocators(profiledPageContext.getLocators());
   
               // return profiled page context in request attribute
               HttpServletRequest httpRequest = request.getRequest();
  @@ -95,6 +116,7 @@
           }
           catch (Exception e)
           {
  +            log.error("Exception in request pipeline: " + e.getMessage(), e);
               throw new PipelineException(e.toString(), e);
           }
       }
  
  
  

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


Mime
View raw message