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/security JetspeedDBSecurityService.java
Date Tue, 17 Jul 2001 16:44:56 GMT
taylor      01/07/17 09:44:56

  Modified:    src/java/org/apache/jetspeed/services Profiler.java
                        PsmlManager.java
               src/java/org/apache/jetspeed/services/jsp/tags
                        JetspeedPaneTag.java
               src/java/org/apache/jetspeed/services/profiler
                        JetspeedProfilerService.java ProfilerService.java
               src/java/org/apache/jetspeed/services/psmlmanager
                        CastorPsmlManagerService.java
                        PsmlManagerService.java
               src/java/org/apache/jetspeed/services/security
                        JetspeedDBSecurityService.java
  Log:
  - modified JetspeedPaneTag to use new profile interfaces
  - implemented new profiler getProfile methods
  - deprecated old profiler methods
  - implemented new profiler createProfile method
  - implemented CastorPSMLManagerService methods: createDocument, getDocument
  
  Revision  Changes    Path
  1.10      +37 -30    jakarta-jetspeed/src/java/org/apache/jetspeed/services/Profiler.java
  
  Index: Profiler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/Profiler.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Profiler.java	2001/07/09 07:35:37	1.9
  +++ Profiler.java	2001/07/17 16:44:35	1.10
  @@ -74,10 +74,17 @@
    * @see org.apache.jetspeed.services.profiler.Profiler
    * @see org.apache.jetspeed.services.profiler.ProfilerService
    * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
  - * @version $Id: Profiler.java,v 1.9 2001/07/09 07:35:37 taylor Exp $
  + * @version $Id: Profiler.java,v 1.10 2001/07/17 16:44:35 taylor Exp $
    */
   public class Profiler
   {
  +    public final static String PARAM_MEDIA_TYPE         = "media-type";
  +    public final static String PARAM_ROLE               = "role";
  +    public final static String PARAM_GROUP              = "group";
  +    public final static String PARAM_PAGE               = "page";
  +    public final static String PARAM_USER               = "user";
  +    public final static String PARAM_ANON               = "anon";
  +    public final static String DEFAULT_PROFILE          = "default";
   
       /** 
        * Commodity method for getting a reference to the service
  @@ -91,7 +98,12 @@
       }
       
       /**
  -     * @see ProfilerService#getProfile
  +     *  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 device capability map for the current request.
  +     * @return a Profile object if found by the manager or null
        */
       public static Profile getProfile(RunData rundata, CapabilityMap cm)
           throws ProfileException
  @@ -117,35 +129,19 @@
           return getService().getProfile( data, mt );
       }
   
  -    /**
  -     * @see ProfilerService#createUserProfile
  -     * @deprecated
  -     */
  -    public static Profile createUserProfile(RunData rundata, User user)
  -        throws IOException, ProfileException
  -    {
  -        return getService().createUserProfile( rundata, user );
  -    }
  -
       /**
  -     * @see ProfilerService#createUserProfile
  -     * @deprecated
  +     *  get the Profile object using a profile locator
  +     *
  +     * @param rundata The rundata object for the current request.
  +     * @param locator The locator containing criteria describing the profile.
  +     * @return a new Profile object
        */
  -    public static Profile createUserProfile(RunData rundata, User user, MimeType mt)
  -        throws IOException, ProfileException
  +    public static Profile getProfile(RunData data, ProfileLocator locator)
  +        throws ProfileException
       {
  -        return getService().createUserProfile( rundata, user, mt );
  +        return getService().getProfile( data, locator );
       }
   
  -    /**
  -     * @see ProfilerService#removeUserProfile
  -     * @deprecated
  -     */
  -    public static void removeUserProfile(RunData rundata, User user)
  -        throws IOException, ProfileException
  -    {
  -        getService().removeUserProfile( rundata, user );
  -    }
   
       /**
        * @see ProfilerService#makeDynamicURI
  @@ -158,16 +154,27 @@
   
       /**
        * @see ProfilerService#createProfile
  +     */
  +    public static Profile createProfile( RunData data, Profile profile )
  +        throws ProfileException
  +    {
  +        return getService().createProfile( data, profile );
  +    }
  +
  +    /**
  +     * @see ProfilerService#createProfile
        */
  -    public static Profile createProfile( ProfileLocator locator )
  +    public static Profile createProfile( RunData data, Profile profile, MimeType mt )
  +        throws ProfileException
       {
  -        return getService().createProfile( locator );
  +        return getService().createProfile( data, profile, mt );
       }
   
       /**
        * @see ProfilerService#removeProfile
        */
  -    public void removeProfile(ProfileLocator locator)
  +    public static void removeProfile(ProfileLocator locator)
  +        throws ProfileException
       {
           getService().removeProfile( locator );
       }
  @@ -175,7 +182,7 @@
       /**
        * @see ProfilerService#list
        */
  -    public Iterator list( ProfileLocator locator )
  +    public static Iterator list( ProfileLocator locator )
       {
           return getService().list( locator );
       }
  
  
  
  1.4       +24 -14    jakarta-jetspeed/src/java/org/apache/jetspeed/services/PsmlManager.java
  
  Index: PsmlManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/PsmlManager.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PsmlManager.java	2001/07/09 17:08:42	1.3
  +++ PsmlManager.java	2001/07/17 16:44:36	1.4
  @@ -58,6 +58,7 @@
   import org.apache.jetspeed.om.profile.PSMLDocument;
   import org.apache.turbine.services.TurbineServices;
   import org.apache.jetspeed.om.profile.ProfileLocator;
  +import org.apache.jetspeed.om.profile.Profile;
   import java.util.Iterator;
   import java.util.List;
   
  @@ -65,7 +66,7 @@
    * Static accessor for the PsmlManagerService
    *
    * @author <a href="mailto:raphael@apache.org">RaphaŽl Luta</a>
  - * @version $Id: PsmlManager.java,v 1.3 2001/07/09 17:08:42 taylor Exp $
  + * @version $Id: PsmlManager.java,v 1.4 2001/07/17 16:44:36 taylor Exp $
    */
   public class PsmlManager
   {
  @@ -104,6 +105,17 @@
           return getService().getDocument(locator);
       }
   
  +    /** Given a ordered list of locators, find the first document matching
  +     *  a profile locator, starting from the beginning of the list and working
  +     *  to the end.
  +     *
  +     * @param locator The ordered list of profile locators.
  +     */
  +    public static PSMLDocument getDocument( List locators )
  +    {
  +        return getService().getDocument(locators);
  +    }
  +
       /** Save the PSML document on disk, using its name as filepath
        * 
        * @param doc the document to save
  @@ -126,32 +138,30 @@
   
       /** Create a new document.
        *
  -     * @param locator The description of the new profile to be created.
  +     * @param profile The description and default value for the new document.
        * @return The newly created document.
        */
  -    public static PSMLDocument createDocument( ProfileLocator locator )
  +    public static PSMLDocument createDocument( Profile profile )
       {
  -        return getService().createDocument( locator );
  +        return getService().createDocument( profile );
       }
   
  -    /** Get a list of profiles given a profile locator criteria.
  +    /** Removes a document.
        *
  -     * @param locator The profile locator criteria.
  +     * @param locator The description of the profile resource to be removed.
        */
  -    public static Iterator list( ProfileLocator locator )
  +    public static void removeDocument( ProfileLocator locator )
       {
  -        return getService().list( locator );
  +        getService().removeDocument( locator );
       }
   
  -    /** Given a ordered list of locators, find the first document matching
  -     *  a profile locator, starting from the beginning of the list and working
  -     *  to the end.
  +    /** Query for a collection of profiles given a profile locator criteria.
        *
  -     * @param locator The ordered list of profile locators.
  +     * @param locator The profile locator criteria.
        */
  -    public static PSMLDocument fallback( List locators )
  +    public static Iterator query( ProfileLocator locator )
       {
  -        return getService().fallback( locators );
  +        return getService().query( locator );
       }
   
   }
  
  
  
  1.3       +30 -18    jakarta-jetspeed/src/java/org/apache/jetspeed/services/jsp/tags/JetspeedPaneTag.java
  
  Index: JetspeedPaneTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/jsp/tags/JetspeedPaneTag.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JetspeedPaneTag.java	2001/06/04 17:30:29	1.2
  +++ JetspeedPaneTag.java	2001/07/17 16:44:41	1.3
  @@ -70,6 +70,10 @@
   import org.apache.jetspeed.services.PsmlManager;
   import org.apache.jetspeed.services.resources.JetspeedResources;
   import org.apache.jetspeed.services.rundata.JetspeedRunData;
  +import org.apache.jetspeed.services.Profiler;
  +import org.apache.jetspeed.om.profile.PSMLDocument;
  +import org.apache.jetspeed.om.profile.Profile;
  +import org.apache.jetspeed.om.profile.ProfileException;
   
   /**
    * Supporting class for the pane tag.
  @@ -77,7 +81,7 @@
    * current JSP page
    *
    * @author <a href="mailto:raphael@apache.org">RaphaŽl Luta</a>
  - * @version $Id: JetspeedPaneTag.java,v 1.2 2001/06/04 17:30:29 raphael Exp $
  + * @version $Id: JetspeedPaneTag.java,v 1.3 2001/07/17 16:44:41 taylor Exp $
    */
   public class JetspeedPaneTag extends TagSupport 
   {
  @@ -99,7 +103,7 @@
        *
        * @return SKIP_BODY, as it is intended to be a single tag.
        */
  -    public int doStartTag() throws JspException 
  +    public int doStartTag() throws JspException                   
       {
           JetspeedRunData data = (JetspeedRunData)pageContext.getAttribute(JspService.RUNDATA, PageContext.REQUEST_SCOPE);
           
  @@ -115,26 +119,34 @@
   
               ConcreteElement result = new ConcreteElement();
           
  -            if ((name == null) || "default".equals(name) || "".equals(name))
  +            if (null != data)
               {
  -                result = data.getProfile().getRootSet().getContent(data);
  -            }
  -            else
  -            {
  -                //FIXME: this is a hack because Profiler does not allow us currently to
  -                //explicitely choose a PSML resource but handles both resource selection
  -                //and resource loading
  -                String path = JetspeedResources.getString( JetspeedResources.PSML_BASE_URL_KEY )
  -                                    + name
  -                                    + ".psml";
  -                PSMLDocument doc = PsmlManager.getDocument(path);
  -                if (doc != null)
  +                Profile profile = data.getProfile();
  +                try
  +                {
  +                    if (null == profile)
  +                    {
  +                        profile = Profiler.getProfile(data);
  +                        data.setProfile(profile);
  +                    }
  +                
  +                    if ((name == null) ||  Profiler.DEFAULT_PROFILE.equals(name) || "".equals(name))
  +                        ;
  +                    else
  +                        profile.setName(name);
  +         
  +                    PSMLDocument doc = profile.getDocument();
  +                    if (null != doc)
  +                    {
  +                        result = PortalToolkit.getSet(doc.getPortlets()).getContent(data);
  +                    }
  +                }
  +                catch (ProfileException e)
                   {
  -                    result = PortalToolkit.getSet(doc.getPortlets())
  -                                          .getContent(data);
  +                    Log.error(e);
                   }
               }
  -        
  +
               // Check whether this is an "old" screen (that returns a ConcreteElement)
               // or a "new" one that returns null.
               if ( result != null )
  
  
  
  1.11      +333 -538  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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- JetspeedProfilerService.java	2001/07/09 07:35:40	1.10
  +++ JetspeedProfilerService.java	2001/07/17 16:44:44	1.11
  @@ -60,15 +60,12 @@
   import java.util.Enumeration;
   import java.util.Locale;
   import java.util.Iterator;
  +import java.util.List;
  +import java.util.LinkedList;
   
  -// java.io
  -import java.io.File;
  -import java.io.IOException;
  -
   // java.net
   import java.net.URL;
   import java.net.MalformedURLException;
  -import java.lang.reflect.Method;
   import javax.servlet.ServletConfig;
   
   //turbine.util
  @@ -85,10 +82,13 @@
   import org.apache.turbine.services.localization.LocaleDetector;
   import org.apache.turbine.services.resources.TurbineResources;
   import org.apache.turbine.services.template.TurbineTemplate;
  +import org.apache.turbine.services.resources.ResourceService;
  +import org.apache.turbine.util.security.DataBackendException;
   
   // turbine.om
   import org.apache.turbine.om.security.User;
  -
  +import org.apache.turbine.om.security.Role;
  +import org.apache.turbine.om.security.Group;
   // jetspeed.om
   import org.apache.jetspeed.om.profile.*;
   import org.apache.jetspeed.om.newregistry.RegistryException;
  @@ -103,6 +103,8 @@
   import org.apache.jetspeed.services.resources.JetspeedResources;
   import org.apache.jetspeed.services.rundata.JetspeedRunData;
   import org.apache.jetspeed.services.Registry;
  +import org.apache.jetspeed.services.JetspeedSecurity;
  +import org.apache.jetspeed.services.PsmlManager;
   
   // jetspeed.util
   import org.apache.jetspeed.util.MimeType;
  @@ -124,66 +126,47 @@
    *    <dt>security</dt><dd>Use security flag</dd>
    *    <dt>language</dt><dd>Use language configuration flag</dd>
    *
  - *    <dt>templatRoot</dt><dd>The webapp rel. path to the root template directory</dd>
    * </dl>
    * </p>
    *
    * @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.10 2001/07/09 07:35:40 taylor Exp $
  + * @version $Id: JetspeedProfilerService.java,v 1.11 2001/07/17 16:44:44 taylor Exp $
    */
   
   public class JetspeedProfilerService  extends TurbineBaseService
       implements ProfilerService
   {
   
  -    public final static String PARAM_MEDIA_TYPE         = "media-type";
  -    public final static String PARAM_ROLE               = "role";
  -    public final static String PARAM_GROUP              = "group";
  -    public final static String PARAM_PAGE               = "page";
  -    public final static String PARAM_USER               = "user";
  -    public final static String TEMP_USER                = "temp_user";
       // configuration keys
  -    private final static String CONFIG_ROOT             = ".root";
       private final static String CONFIG_RESOURCE_DEFAULT = ".resource.default";
       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_NAMECACHE        = ".namecache";
   
  -    // resource path constants
  -    private static final String PATH_GROUP              = "group/";
  -    private static final String PATH_ROLE               = "role/";
  -    private static final String PATH_USER               = "user/";
  -    private static final String PATH_ANON               = "anon/";
  -    protected static final String PATH_SEPARATOR        = "/";
  -    private static final String PATH_EXTENSION_DELIMITER = ".";
  +    // 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;
   
  -    // session profile key
  -    private static final String KEY_SESSION_PROFILE = "jps.profile";
  -
  +    private final static String PATH_EXTENSION_DELIMITER = ".";
       // messages
       private final static String MSG_MISSING_PARAMETER =
           "JetspeedProfilerService initialization failed. Missing parameter:";
   
   
       // configuration parameters
  -     String root;                   // the root psml resource directory
  -     String resourceDefault;        // the default name for a resource
  -     String resourceExt;            // the default extension for a resource
  -     boolean useSecurity = false;   // use security features
  -     boolean useLanguage = true;    // use extended language mapping features
  -     boolean useNameCache = true;   // use the cache to check existence of resources
  -
  -     // template configuration parameters
  +    String root;                   // the root psml resource directory
  +    String resourceDefault;        // the default name for a resource
  +    String resourceExt;            // the default extension for a resource
   
  +    boolean useSecurity = false;   // use security features
  +    boolean useLanguage = true;    // use extended language mapping features
   
       // lookup a media type based on mime-type
       private Map mediaMap = null;
   
  -    // fallback map of resources
  -    private Map resourceMap = null;
  -
       /**
        * This is the early initialization method called by the 
        * Turbine <code>Service</code> framework
  @@ -198,14 +181,19 @@
   
           initConfiguration();        
           initMediaTypeMap();
  -        initFallback();
   
           // initialization done
           setInit(true);
   
        }
  -
   
  +    /**
  +     * This is the lateinitialization method called by the 
  +     * Turbine <code>Service</code> framework
  +     *
  +     * @exception throws a <code>InitializationException</code> if the service
  +     * fails to initialize
  +     */
       public void init() throws InitializationException {
           Log.note( "Late init for JetspeedProfilerService called" );        
           while( !getInit() ) {
  @@ -219,15 +207,14 @@
           }
       }
   
  -
       /**
        * This is the shutdown method called by the 
        * Turbine <code>Service</code> framework
        */
  -    public void shutdown() {
  +    public void shutdown() 
  +    {
       }
   
  -
       /**
        *  get the Profile object using the Rundata state and capability map
        *  this is the mapping functionality of the profiler
  @@ -239,8 +226,90 @@
       public Profile getProfile(RunData rundata, CapabilityMap cm)
           throws ProfileException
       {
  -        Profile profile = getResourceURL(rundata, cm, true);
  -        return profile;
  +        try
  +        {
  +            Profile profile = new BaseProfile();
  +            User user = rundata.getUser();
  +     
  +            // get the media type from the capability map or rundata
  +            profile.setMediaType(getMediaType(rundata, cm));
  +     
  +            //  Is it a group, role, or user resource?
  +            //  It can only be one
  +            String param = rundata.getParameters().getString( Profiler.PARAM_GROUP );
  +            if (null != param)  
  +            {   
  +                // GROUP Resource
  +                profile.setGroup( JetspeedSecurity.getGroup(param) );
  +            }
  +            else
  +            {
  +                param = rundata.getParameters().getString( Profiler.PARAM_ROLE );
  +                if (null != param) 
  +                { 
  +                    // ROLE Resource
  +                    profile.setRole( JetspeedSecurity.getRole(param) );
  +                }
  +                else  // it must be a user resource or anonymous resource
  +                {
  +                    // accessing another user's resource
  +                    param = rundata.getParameters().getString( Profiler.PARAM_USER );
  +                    if (null != param) 
  +                    { 
  +                        // USER Resource
  +                        // TODO: Check for anonymous user flag, since we could be configuring the anonymous user
  +                        if (param.equals(Profiler.PARAM_ANON))
  +                            profile.setAnonymous(true);
  +                        else
  +                            profile.setUser( JetspeedSecurity.getUser(param) );
  +                    }
  +                    else
  +                    {
  +                        // is it a anonymous access?
  +                        if (user.hasLoggedIn())
  +                        {
  +                            profile.setUser( rundata.getUser() );
  +                        }
  +                        else  // anonymous
  +                        {
  +                            profile.setAnonymous(true);
  +                        }
  +                    }
  +                }
  +     
  +                // get resource name
  +                StringBuffer resource = new StringBuffer();
  +                param = rundata.getParameters().getString( Profiler.PARAM_PAGE );
  +                if (null == param) {
  +                   // the default resource
  +                    resource.append( resourceDefault );
  +                    resource.append( resourceExt );
  +                }
  +                else
  +                {   // a specific resource
  +                    resource.append( param );
  +                    if ( -1 == param.indexOf( PATH_EXTENSION_DELIMITER ) )
  +                        resource.append( resourceExt );
  +                }
  +                profile.setName( resource.toString() );
  +     
  +                // LANGUAGE
  +                if (useLanguage && rundata != null)
  +                    getLanguageSettings(profile, rundata);
  +            }
  +     
  +            PSMLDocument doc = fallback( profile, rundata );
  +            if (null != doc)
  +            {
  +                profile.setDocument( doc );
  +                return profile;
  +            }
  +        }
  +        catch (Exception e)
  +        {
  +            throw new ProfileException(e.toString());
  +        }
  +        return null;
       }
   
       /**
  @@ -278,391 +347,184 @@
           throws ProfileException
       {
           CapabilityMap cm = CapabilityMapFactory.getCapabilityMap(mt.toString());
  -        return getResourceURL(data, cm, false);
  +        return getProfile(data, cm);
       }
   
  -     /**
  -      * sets a profile as the current profile for this session
  -      *
  -      * @param rundata the rundata object for the current request
  -      * @param profile the profile object to set in the session context
  -      */
  -    public void setSessionProfile(RunData rundata, Profile profile)
  -    {
  -        // store the current profile in the session
  -        rundata.getUser().setTemp(KEY_SESSION_PROFILE, profile);
  -    }
  -
  -     /**
  -      * gets the current profile for this session
  -      *
  -      * @param rundata the rundata object for the current request
  -      * @param profile the profile object to set in the session context
  -      */
  -    public Profile getSessionProfile(RunData rundata)
  -        throws ProfileException
  -    {
  -        // store the current profile in the session
  -        Profile profile = (Profile)rundata.getUser().getTemp(KEY_SESSION_PROFILE);
  -        if (null == profile)
  -            profile = getProfile(rundata);
  -
  -        return profile;
  -    }
  -
  -    public Profile createUserProfile(RunData rundata, User user)
  -        throws IOException, ProfileException
  -    {
  -        return createUserProfile(rundata, user, null);
  -    }
  -
       /**
  -     *  create a user profile and its resources (psml) for a new user
  +     *  get the Profile object using a profile locator
        *
  -     * @param rundata the rundata object for the current request
  -     * @param newUser the new user to create
  -     * @throws IOException when the filecopy fails
  +     * @param rundata The rundata object for the current request.
  +     * @param locator The locator containing criteria describing the profile.
        * @return a new Profile object
        */
  -    public Profile createUserProfile(RunData rundata, User newUser, MimeType mimeType)
  -        throws IOException, ProfileException
  +    public Profile getProfile(RunData data, ProfileLocator locator)
  +        throws ProfileException
       {
  -        User currentUser = rundata.getUser();
  -        BaseProfile profile = new BaseProfile();
  -
  -        try
  -        {
  -            rundata.setUser(newUser);
  -
  -            CapabilityMap cm;
  -            if (null == mimeType)
  -                cm = CapabilityMapFactory.getCapabilityMap( rundata );
  -            else
  -                cm = CapabilityMapFactory.getCapabilityMap(mimeType.toString());
  -    
  -            // FIXME: this needs to be handled better for users/groups/roles
  -            // rundata.getParameters().add(TEMP_USER, userName);
  -
  -            String mediaType = getMediaType(rundata, cm);
  -
  -            // get the target profile
  -            String path = getPath(rundata, mediaType, profile);
  -            String resource = getResource(rundata, profile);
  -            String finalPath = root + path + resource;
  -            String realPath = TurbineServlet.getRealPath(finalPath);
  -            File file = new File(realPath);
  -            if (!file.exists())
  -            {
  -                // copy from first psml resource found in fallback path
  -                Profile sourceProfile = getResourceURL(rundata, cm, true);
  -                String  sourceURL = sourceProfile.getURL();
  -                String sourceReal = null;
  -                try
  -                {
  -                    sourceReal = new URL(sourceURL).getFile();
  -                }
  -                catch (MalformedURLException e)
  -                {
  -                    if (sourceURL.startsWith("file:"))
  -                        sourceReal = sourceURL.substring(5);
  -                    else
  -                        sourceReal = sourceURL;
  -                }
  -    
  -                // make the directories and then copy it
  -                String parent = file.getParent();
  -                File filePath = new File(parent);
  -                filePath.mkdirs();
  -                FileCopy.copy( sourceReal, realPath );
  -            }
  -            URL url = TurbineServlet.getResource( finalPath );
  -            if (url != null)
  -                profile.setURL(url.toString());
  -            else
  -                profile.setURL(finalPath);
  -            this.setSessionProfile(rundata, profile);     
  -        }
  -        catch (Exception e)
  -        {
  -        }
  -        finally
  -        {
  -            rundata.setUser(currentUser);
  -        }
  -        return profile;
  +        PSMLDocument doc =  fallback( locator, data );
  +        return null;
       }
   
  -    /**
  -     * Gets a resource's URL based on RunData and the CapabilityMap
  +    /*
  +     * Gets the language and country parameters from the request using the Turbine locale detector.
        *
  -     * @parameter rundata, the <code>RunData</code> turbine request context information
  -     * @param cm the <code>CapabilityMap</code> of the current requesting device
  +     * @param profile The profile object which is modified with the new language settings.
  +     * @param rundata The request specific state.
        */
  -    protected Profile getResourceURL(RunData rundata, CapabilityMap cm, boolean fallback)
  -        throws ProfileException
  +    protected void getLanguageSettings( Profile profile, RunData rundata )
       {
  -        // get the media type from the capability map or rundata
  -        String mediaType = getMediaType(rundata, cm);
  -
  -        BaseProfile profile = new BaseProfile();
  -
  -        // get the target profile: by group/role/user
  -        String path = getPath(rundata, mediaType, profile);
  -        String resource = getResource(rundata, profile);
  -
  -        // apply fallback to language resources and default resources
  -        String finalPath;
  -        String original = path + resource;
  -        if (fallback)
  -        {
  -            while( (finalPath = fallback(rundata, path, resource)) == "") {
  -                int pt = path.lastIndexOf(PATH_SEPARATOR);
  -                if (-1 == pt)
  -                {
  -                    path = "";  // look in psml root
  -                    finalPath = fallback(rundata, path, resource);
  -                    if (finalPath == "")
  -                    {
  -                        String errorMessage = "Failed to find resource for " + original;
  -                        throw new ProfileException(errorMessage);
  -                    }
  -                    break; // found default resource in root
  -                }
  -                int length = path.length();
  -                if (pt == length - 1 && length > 1)
  -                {
  -                    //pt = pt - 1;
  -                    path = path.substring(0, pt);
  -                    pt = path.lastIndexOf(PATH_SEPARATOR);
  -                }
  -                path = path.substring(0, pt);
  -            }
  -        }
  -        else
  +        Locale locale = (Locale)rundata.getUser().getTemp("locale");
  +        if (locale == null)
           {
  -            finalPath = fallback(rundata, path, resource);
  -            if (finalPath.length() == 0)
  +            // Get the locale store it in the user object
  +            locale = LocaleDetector.getLocale(rundata);
  +            if (locale == null)
               {
  -                finalPath = root + original;
  -                String realPath = TurbineServlet.getRealPath( finalPath );
  -                if (realPath != null)
  -                    profile.setURL(realPath);
  -                else
  -                    profile.setURL(finalPath);
  -                return profile;
  +                locale = new Locale(
  +                                TurbineResources.getString("locale.default.language", "en"),
  +                                TurbineResources.getString("locale.default.country", "US"));
               }
  +            rundata.getUser().setTemp("locale", locale);
           }
  -        // TODO: ACL security
  -
  -        String realPath = TurbineServlet.getRealPath( finalPath );
  -        if (realPath != null)
  -            profile.setURL(realPath);
  -        else
  -            profile.setURL(finalPath);
  -
  -        return profile;
  +        String language = locale.getLanguage();
  +        String country = locale.getCountry();
  +        profile.setLanguage( locale.getLanguage() );
  +        profile.setCountry( locale.getCountry() );
       }
   
  -    /**
  -     * Gets a resource's URL path based on RunData
  -     * Builds the path to the resource based on user/group/role and media type
  +    /*
  +     * A basic profiler fallback algorithm that starts from the most specific parameters,
  +     * going to the least specific parameters. The PsmlManager implementation is passed
  +     * a list of ProfileLocators ordered from most specific  to least specific.
        *
  -     * @parameter rundata, the <code>RunData</code> turbine request context information
  -     * @return a String, the path to the resource relative to the base
  +     * @param locator The profile locator criteria used to locate a profile.
  +     * @param rundata The request specific state.
  +     * @return The found psml document, or null if not found.
        */
  -    protected String getPath(RunData rundata, String mediaType, BaseProfile profile)
  +    protected PSMLDocument fallbackList( ProfileLocator original, RunData rundata )
       {
  -        if (null == rundata)
  -        {
  -            if (mediaType != null)
  -                return PATH_ANON + mediaType + PATH_SEPARATOR;
  -            return PATH_ANON;
  -        }
  -
  -        User user = rundata.getUser();
  -
  -        StringBuffer path = new StringBuffer( "" );
  -
  -        //   is it a group, role, or user resource?
  -        String param = rundata.getParameters().getString( PARAM_GROUP );
  -        if (null != param)  { // specific group resource?
  -            path.append(PATH_GROUP);
  -            path.append(param);
  -            profile.setGroup(param);
  -        }
  -        else
  +        try
           {
  -            param = rundata.getParameters().getString( PARAM_ROLE );
  -            if (null != param) { // is it a specific role resource?
  -                path.append(PATH_ROLE);
  -                path.append(param);
  -                profile.setRole(param);
  +            List locators = new LinkedList();
  +            ProfileLocator locator = (ProfileLocator)original.clone();
  +    
  +            locators.add( locator.clone() );
  +            
  +            // remove country
  +            if (null != original.getCountry())
  +            {
  +                locator.setCountry(null);
  +                locators.add( locator.clone() );
               }
  -            else  // it is a user resource
  +    
  +            // remove language
  +            if (null != original.getLanguage())
               {
  -                // is it a anonymous access?
  -                if (user.hasLoggedIn())
  -                {
  -                    String userName = rundata.getUser().getUserName();
  -                    path.append(PATH_USER);
  -                    path.append(userName);
  -                    path.append(PATH_SEPARATOR);
  -                }
  -                else  // anonymous
  -                {
  -                   path.append( PATH_ANON );
  -                }
  -
  +                locator.setLanguage(null);
  +                locators.add( locator.clone() );
               }
  -        }
  -
  -        // get path to media type
  -        if (mediaType != null || mediaType.length() > 0) {
  -            int length = path.length();
  -            if (0 == length)
  -                path.append(PATH_SEPARATOR);
  -            else {
  -                String endchar = path.substring(length-1);
  -                if (!endchar.equals(PATH_SEPARATOR))
  -                    path.append(PATH_SEPARATOR);
  +    
  +            // fallback mediaType
  +            if (null != original.getMediaType())
  +            {
  +                locator.setMediaType(null);
  +                locators.add( locator.clone() );
               }
  -            path.append(mediaType);
  -            path.append(PATH_SEPARATOR);
  -        }
  +    
  +            if (null != original.getGroup())
  +            {
  +                locator.setGroup(null);
  +                locators.add( locator.clone() );
  +            }
  +            else if (null != original.getRole())
  +            {
  +                locator.setRole(null);
  +                locators.add( locator.clone() );
  +            }
  +            else if (null != original.getUser())
  +            {
  +                locator.setUser(null);
  +                locators.add( locator.clone() );
  +            }
  +            PSMLDocument doc = PsmlManager.getDocument( locators );
  +            return doc;
   
  -        return path.toString();
  +        }
  +        catch (CloneNotSupportedException e)
  +        {
  +            Log.error("Could not clone profile locator object", e);
  +        }
  +        return null;
       }
   
  -    /**
  -     * Gets a resource name from the rundata
  -     * If the name is not specified, the default resource name is used.
  +    /*
  +     * A basic profiler fallback algorithm that starts from the most specific parameters,
  +     * going to the least specific parameters. The PsmlManager implementation is passed
  +     * a list of ProfileLocators ordered from most specific  to least specific.
  +     * 
  +     * This is alternate fallback algorithm.
        *
  -     * @parameter rundata, the <code>RunData</code> turbine request context information
  -     * @return a String, the path to the resource relative to the base
  +     * @param locator The profile locator criteria used to locate a profile.
  +     * @param rundata The request specific state.
        */
  -    protected String getResource( RunData rundata, BaseProfile profile )
  +    protected PSMLDocument fallback( ProfileLocator locator, RunData rundata )
       {
  -        // is it the default resource a specified resource?
  -        // first check for a specific resource profile in the request
  -        // if not found use the default resource mane
  -        StringBuffer resource = new StringBuffer();
  -        if (null == rundata)
  +        PSMLDocument doc = PsmlManager.getDocument( locator );
  +        if (null != doc)
  +            return doc;
  +
  +        // remove country
  +        if (null != locator.getCountry())
           {
  -            resource.append( resourceDefault );
  -            resource.append( resourceExt );
  -            return resource.toString();
  +            locator.setCountry(null);
  +            doc = PsmlManager.getDocument( locator );
  +            if (null != doc)
  +                return doc;
           }
  -
  -        String param = rundata.getParameters().getString( PARAM_PAGE );
   
  -        if (null == param) {
  -           // the default resource
  -            resource.append( resourceDefault );
  -            resource.append( resourceExt );
  -        }
  -        else
  -        {   // a specific resource
  -            resource.append( param );
  -            if ( -1 == param.indexOf( PATH_EXTENSION_DELIMITER ) )
  -                resource.append( resourceExt );
  -            profile.setName( param );
  +        // remove language
  +        if (null != locator.getLanguage())
  +        {
  +            locator.setLanguage(null);
  +            doc = PsmlManager.getDocument( locator );
  +            if (null != doc)
  +                return doc;
           }
  -        return resource.toString();
  -    }
  -
  -    /**
  -     * apply fallback algorithm to finding resources from most specific
  -     * to least specific starting at media type specific, fallback to a specific
  -     * user/role/group, fallback to generic user/role/group, and finally root
  -     *
  -     * @parameter path to the resource
  -     * @return a String the modified path to the resource based on fallback
  -     */
  -    protected String fallback(RunData rundata, String path, String resource)
  -    {
  -        StringBuffer fullPath = new StringBuffer( root );
   
  -        fullPath.append(path);
  -        if (path.length() > 0 && !path.endsWith(PATH_SEPARATOR))
  -            fullPath.append(PATH_SEPARATOR);
  +        // fallback mediaType
  +        if (null != locator.getMediaType())
  +        {
  +            locator.setMediaType(null);
  +            doc = PsmlManager.getDocument( locator );
  +            if (null != doc)
  +                return doc;
  +        }
   
  -        // search for language specific resources at each level
  -        if (useLanguage && rundata != null) {
  -            //String language = rundata.getRequest().getHeader("Accept-Language");
  -            Locale locale = (Locale)rundata.getUser().getTemp("locale");
  -            if (locale == null)
  -            {
  -                  // Get the locale store it in the user object
  -                  locale = LocaleDetector.getLocale(rundata);
  -                  if (locale == null)
  -                  {
  -                      locale = new Locale(
  -                               TurbineResources.getString("locale.default.language", "en"),
  -                               TurbineResources.getString("locale.default.country", "US"));
  -                  }
  -                  rundata.getUser().setTemp("locale", locale);
  -            }
  -            String language = locale.getLanguage();
  -            String country = locale.getCountry();
  -            int count = 0;
  -            StringBuffer langPath = new StringBuffer();
  -            langPath.append( fullPath.toString() );
  -            if ((language != null) && (language.length() > 0))
  -            {
  -                langPath.append(language).append(PATH_SEPARATOR);
  -                count++;
  -            }
  -            if ((country != null) && (country.length() > 0))
  -            {
  -                langPath.append(country).append(PATH_SEPARATOR);
  -                count++;
  -            }
  -            String basePath = langPath.toString();
  -            String realPath, workingPath;
  -
  -            for ( ; count > 0 ; count--)
  -            {
  -               workingPath = basePath + resource;
  -               realPath = TurbineServlet.getRealPath( workingPath );
  -               if (resourceExists(realPath))
  -                   return workingPath;
  -                int pt = basePath.lastIndexOf(PATH_SEPARATOR);
  -                int length = basePath.length();
  -                if (-1 == pt)
  -                    break;
  -                if (pt == length - 1 && length > 1)
  -                {
  -                    //pt = pt - 1;
  -                    basePath = basePath.substring(0, pt);
  -                    pt = basePath.lastIndexOf(PATH_SEPARATOR);
  -                }
  -                basePath = basePath.substring(0, pt);
  -                basePath = basePath + PATH_SEPARATOR;
  -            }
  +        if (null != locator.getGroup())
  +        {
  +            locator.setGroup(null);
  +            doc = PsmlManager.getDocument( locator );
  +            if (null != doc)
  +                return doc;
  +        }
  +        else if (null != locator.getRole())
  +        {
  +            locator.setRole(null);
  +            doc = PsmlManager.getDocument( locator );
  +            if (null != doc)
  +                return doc;
           }
  +        else if (null != locator.getUser())
  +        {
  +            locator.setUser(null);
  +            doc = PsmlManager.getDocument( locator );
  +            if (null != doc)
  +                return doc;
  +        }
   
  -        fullPath.append(resource);
  -        String realPath = TurbineServlet.getRealPath( fullPath.toString() );
  -    
  -        if (resourceExists(realPath))
  -            return fullPath.toString();  // found as is
  +        return doc;
   
  -        return "";
       }
   
  -    /**
  -     * checks for the existence of a resource given a key
  -     *
  -     * @parameter key the resource name.
  -     */
  -    public boolean resourceExists(String resourceKey)
  -    {
  -        if (useNameCache == true)
  -        {
  -            return resourceMap.containsKey(resourceKey);
  -        }
  -        return (new File(resourceKey).exists());
  -    }
   
       /**
        * initialize the mime-type-to-media-type map
  @@ -682,20 +544,19 @@
       }
   
       /**
  -     * lookup the media type from the CapabilitMap
  -     * first the RunData is checked for an explicit media-type request
  +     * Lookup the media type from the CapabilitMap.
  +     * First the RunData is checked for an explicit media-type request.
        *
  -     * @param cm the <code>CapabilityMap</code> of the current requesting device
  -     * @parameter rundata, the <code>RunData</code> turbine request context information
  -     * @return a String, the unique name of the media type
  +     * @param cm The <code>CapabilityMap</code> of the current requesting device.
  +     * @parameter rundata, The <code>RunData</code> turbine request context information.
  +     * @return a String, the unique name of the media type.
        */
       protected String getMediaType(RunData rundata, CapabilityMap cm)
       {
  -
           String paramMediaType;
           if (null != rundata)
           {
  -            paramMediaType = rundata.getParameters().getString( PARAM_MEDIA_TYPE );
  +            paramMediaType = rundata.getParameters().getString( Profiler.PARAM_MEDIA_TYPE );
               if (null != paramMediaType)
                   return paramMediaType;
           }
  @@ -723,192 +584,126 @@
        */
       private void initConfiguration() throws InitializationException
       {
  -        // get configuration parameters from Turbine Resources
  -        root = JetspeedResources.getString(TurbineServices.SERVICE_PREFIX
  -                                               + ProfilerService.SERVICE_NAME
  -                                               + CONFIG_ROOT);
  -        if (root == null)
  -            throw new InitializationException(
  -                MSG_MISSING_PARAMETER  + CONFIG_ROOT);
  -        if (!root.endsWith(PATH_SEPARATOR))
  -            root = root + PATH_SEPARATOR;
  -
  -        resourceDefault = JetspeedResources.getString(TurbineServices.SERVICE_PREFIX
  -                                               + ProfilerService.SERVICE_NAME
  -                                               + CONFIG_RESOURCE_DEFAULT);
  -        if (resourceDefault == null)
  -            throw new InitializationException(
  -                MSG_MISSING_PARAMETER  + CONFIG_RESOURCE_DEFAULT);
  -
  -
  -        resourceExt = JetspeedResources.getString(TurbineServices.SERVICE_PREFIX
  -                                               + ProfilerService.SERVICE_NAME
  -                                               + CONFIG_RESOURCE_EXT);
  -        if (resourceExt == null)
  -            throw new InitializationException(
  -                MSG_MISSING_PARAMETER  + CONFIG_RESOURCE_EXT);
  +        // get configuration parameters from Jetspeed Resources
  +        ResourceService serviceConf = ((TurbineServices)TurbineServices.getInstance())
  +                                                     .getResources(ProfilerService.SERVICE_NAME);
  +
  +        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))
               resourceExt = PATH_EXTENSION_DELIMITER + resourceExt;
   
  -        useSecurity = JetspeedResources.getBoolean(TurbineServices.SERVICE_PREFIX
  -                                               + ProfilerService.SERVICE_NAME
  -                                               + CONFIG_SECURITY,
  -                                               false);
  -
  -        useLanguage = JetspeedResources.getBoolean(TurbineServices.SERVICE_PREFIX
  -                                               + ProfilerService.SERVICE_NAME
  -                                               + CONFIG_LANGUAGE,
  -                                               true);
  -        useNameCache = JetspeedResources.getBoolean(TurbineServices.SERVICE_PREFIX
  -                                               + ProfilerService.SERVICE_NAME
  -                                               + CONFIG_NAMECACHE,
  -                                               true);
  +        useSecurity = serviceConf.getBoolean( CONFIG_SECURITY, DEFAULT_CONFIG_SECURITY );
  +        useLanguage = serviceConf.getBoolean( CONFIG_LANGUAGE, DEFAULT_CONFIG_LANGUAGE );
       }
  -
  -    /**
  -     * Build the fallback map to accelerate fallback searches
  -     * The fallback map will need to be refreshed for resources that
  -     * are either added or deleted
  -     *
  -     * @parameter path to the resource
  -     * @return a String the modified path to the resource based on fallback
  -     */
  -    public void initFallback()
  -    {
  -        resourceMap = new HashMap();
   
  -        // traverse starting from the root directory and add resources
  -        String realRootPath = TurbineServlet.getRealPath( root );
  -        if (null != realRootPath)
  -            traverseResources( realRootPath, "", resourceMap );
  -
  -    }
  -
  -    /**
  -     * Used by initFallback to recursively traverse the resources
  -     *
  -     * @parameter path the file path with file name of the resource
  -     * @parameter name just the name of the resource
  -     */
  -    private void traverseResources(String path, String name, Map map)
  -    {
  -        File file = new File(path);
  -        if(file.isFile()) {
  -
  -            // add it to the map
  -            map.put( path, null );
  -
  -        } else if(file.isDirectory()) {
  -
  -            if(!path.endsWith(File.separator))
  -                path += File.separator;
  -
  -            String list[] = file.list();
  -
  -            // Process all files recursivly
  -            for(int ix = 0; list != null && ix < list.length; ix++)
  -                traverseResources(path + list[ix], list[ix], map);
  -        }
  -    }
  -
  -    /**
  -     * To add a fallback resource to the fallback resource map at runtime
  -     *
  -     * @parameter path to the resource
  -     * @return true if added, false if the resource already existed
  -     */
  -
  -    public boolean addFallbackResource( String path )
  -    {
  -        return false; // TODO: write me (synchronized)
  -    }
  -
  -    /**
  -     * To delete a fallback resource from the fallback resource map at runtime
  -     *
  -     * @parameter path to the resource
  -     * @return true if deleted, false if the resource didn't exist
  -     */
  -    public boolean deleteFallbackResource( String path )
  -    {
  -        return true; // TODO: write me (synchronized)
  -    }
  -
  -     /**
  -      * Builds a dynamic URI based on teh current profiler group/role/page
  -      *
  -      * @param rundata the rundata object for the current request
  -      * @return new dynamic URI with full path
  -      */
  +   /**
  +    * Builds a dynamic URI based on the current profiler group/role/page
  +    *
  +    * @param data The rundata object for the current request.
  +    * @param locator The description of the profile.
  +    * @return A new dynamic URI representing all profile parameters from the locator.
  +    */
       public DynamicURI makeDynamicURI( RunData data, ProfileLocator locator )
           throws ProfileException
       {
           DynamicURI uri = new DynamicURI( data );
  -        BaseProfile profile = (BaseProfile)getSessionProfile(data);
  -        String group = profile.getGroup();
  +        Group group = locator.getGroup();
           if (null != group)
  -            uri.addPathInfo(PARAM_GROUP, group);
  +            uri.addPathInfo(Profiler.PARAM_GROUP, group.getName());
           else {
  -            String role = profile.getRole();
  +            Role role = locator.getRole();
               if (null != role)
  -                uri.addPathInfo(PARAM_ROLE, role);
  +                uri.addPathInfo(Profiler.PARAM_ROLE, role.getName());
           }
  -        String page = profile.getName();
  +        String page = locator.getName();
           if (null != page)
  -            uri.addPathInfo(PARAM_PAGE, page);
  +            uri.addPathInfo(Profiler.PARAM_PAGE, page);
   
           return uri;
       }
   
  -   /**
  -     *  Removes a user profile and all of its resources (psml) for a given user.
  +    /**
  +     * Create a new profile. The profile parameter's document will be cloned.
        *
  -     * @deprecated
  -     * @param rundata the rundata object for the current request
  -     * @param user the new user to create
  +     * @param rundata The rundata object for the current request.
  +     * @param profile The description of the new profile to be created.
  +     * @return The newly created profile.
        */
  -    public void removeUserProfile(RunData rundata, User user)
  -        throws IOException, ProfileException
  +    public Profile createProfile( RunData data, Profile profile )
  +            throws ProfileException
       {
  -         StringBuffer path = new StringBuffer(root);
  -         path.append(PATH_USER);
  -         path.append(user.getUserName());
  +        if (null == profile.getDocument())
  +        {
  +            // locate the default resource
   
  -        String finalPath = path.toString();
  -        String realPath = TurbineServlet.getRealPath(finalPath);
  -        DirectoryUtils.rmdir(realPath);
  -   }
  +            // TODO: make this configurable
   
  -    /** Create a new profile.
  +            try
  +            {
  +                ProfileLocator locator = new BaseProfileLocator();
  +                locator.setUser( JetspeedSecurity.getUser("turbine") );
  +                locator.setMediaType("html");
  +                PSMLDocument doc = fallback(locator, data);
  +                if (doc != null)
  +                    profile.setDocument(doc);
  +            }
  +            catch (Exception e)
  +            {
  +                throw new ProfileException(e.toString());
  +            }
  +        }
  +        try
  +        {
  +            PSMLDocument doc = PsmlManager.createDocument(profile);
  +            Profile newProfile = (Profile)profile.clone();
  +            newProfile.setDocument(doc);
  +            return newProfile;
  +        }
  +        catch (CloneNotSupportedException e)
  +        {
  +            Log.error("Could not clone profile locator object: ", e);
  +        }
  +        return null;
  +
  +    }
  +
  +   /** Create a new profile.
        *
  -     * @param The description of the new profile to be created.
  +     * @deprecated Should be removed when old customizer is removed.
  +     *
  +     * @param rundata The rundata object for the current request.
  +     * @param profile The description of the new profile to be created.
  +     * @param mt The specific mime type, which is converted to a mediatype.
        * @return The newly created profile.
        */
  -    public Profile createProfile( ProfileLocator locator )
  +    public Profile createProfile( RunData data, Profile profile, MimeType mt )
  +        throws ProfileException
       {
  -        // TODO: implement
  -        return null;
  +        CapabilityMap cm = CapabilityMapFactory.getCapabilityMap(mt.toString());
  +        profile.setMediaType( getMediaType(data, cm) );
  +        return createProfile(data, profile);
       }
   
      /**
        *  Removes a profile.
        *
  -     * @param The profile locator criteria.
  +     * @param locator The profile locator criteria.
        */
       public void removeProfile( ProfileLocator locator )
  -    {
  -        // IMPLEMENT ME:
  +    {        
  +        PsmlManager.removeDocument(locator);
       }
   
       /** Get a list of profiles given a profile locator criteria.
        *
  -     * @param The profile locator criteria.
  +     * @param locator The profile locator criteria.
  +     * @return The list of profiles matching the locator criteria.
        */
       public Iterator list( ProfileLocator locator )
       {
  -        // TODO: implement
  -        return null;
  +        return PsmlManager.query( locator );
       }
   
  -}
  +}
  \ No newline at end of file
  
  
  
  1.9       +32 -38    jakarta-jetspeed/src/java/org/apache/jetspeed/services/profiler/ProfilerService.java
  
  Index: ProfilerService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/profiler/ProfilerService.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ProfilerService.java	2001/07/09 07:35:41	1.8
  +++ ProfilerService.java	2001/07/17 16:44:45	1.9
  @@ -70,7 +70,7 @@
    * 
    * @see org.apache.jetspeed.om.profile.Profile
    * @author <a href="mailto:david@bluesunrise.com">David Sean Taylor</a>
  - * @version $Id: ProfilerService.java,v 1.8 2001/07/09 07:35:41 taylor Exp $
  + * @version $Id: ProfilerService.java,v 1.9 2001/07/17 16:44:45 taylor Exp $
    */
   
   public interface ProfilerService extends Service
  @@ -83,8 +83,9 @@
        *  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
  -     * @return a Profile object if found by the manager or null
  +     * @param rundata The rundata object for the current request.
  +     * @param cm  The device capability map.
  +     * @return A Profile object if found by the manager or null.
        */
       public Profile getProfile(RunData rundata, CapabilityMap cm)
           throws ProfileException;
  @@ -93,8 +94,8 @@
        * 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
  -     * @return a new Profile object
  +     * @param rundata The rundata object for the current request.
  +     * @return A new Profile object.
        */
       public Profile getProfile(RunData rundata)
                   throws ProfileException;
  @@ -110,64 +111,57 @@
           throws ProfileException;
   
       /**
  -     *  create a user profile and its resources (psml) for a new user
  +     *  get the Profile object using a profile locator
        *
  -     * @param rundata the rundata object for the current request
  -     * @param user the new user to create
  -     * @deprecated
  +     * @param rundata The rundata object for the current request.
  +     * @param locator The locator containing criteria describing the profile.
        * @return a new Profile object
        */
  -    public Profile createUserProfile(RunData rundata, User user)
  -        throws IOException, ProfileException;
  +    public Profile getProfile(RunData data, ProfileLocator locator)
  +        throws ProfileException;
   
       /**
  -     *  create a user profile and its resources (psml) for a new user
  -     *  for a specific mimetype
  +     * Creates a dynamic URI
        *
        * @param rundata the rundata object for the current request
  -     * @param user the new user to create
  -     * @param mt the specific mimeType to create a profile for
  -     * @deprecated
  -     * @return a new Profile object
  +     * @param locator The description of the profile.
  +     * @return A new dynamic URI representing all profile parameters from the locator.
        */
  -    public Profile createUserProfile(RunData rundata, User user, MimeType mt)
  -        throws IOException, ProfileException;
  +    public DynamicURI makeDynamicURI( RunData data, ProfileLocator locator )
  +        throws ProfileException;
   
  -   /**
  -     *  Removes a user profile and all of its resources (psml) for a given user.
  +    /**
  +     * Create a new profile. The profile parameter's document will be cloned.
        *
  -     * @param rundata the rundata object for the current request
  -     * @deprecated
  -     * @param user the new user to be removed
  +     * @param rundata The rundata object for the current request.
  +     * @param profile The description of the new profile to be created.
  +     * @return The newly created profile.
        */
  -    public void removeUserProfile(RunData rundata, User user)
  -        throws IOException, ProfileException;
  -
  -     /**
  -      * Creates a dynamic URI
  -      *
  -      * @param rundata the rundata object for the current request
  -      */
  -     public DynamicURI makeDynamicURI( RunData data, ProfileLocator locator )
  +    public Profile createProfile( RunData data, Profile profile )
           throws ProfileException;
   
       /** Create a new profile.
        *
  -     * @param The description of the new profile to be created.
  +     * @param rundata The rundata object for the current request.
  +     * @param profile The description of the new profile to be created.
  +     * @param mt The specific mime type, which is converted to a mediatype.
        * @return The newly created profile.
        */
  -    public Profile createProfile( ProfileLocator locator );
  +    public Profile createProfile( RunData data, Profile profile, MimeType mt )
  +        throws ProfileException;
   
      /**
        *  Removes a profile.
        *
  -     * @param The profile locator criteria.
  +     * @param locator The profile locator criteria.
        */
  -    public void removeProfile( ProfileLocator locator );
  +    public void removeProfile( ProfileLocator locator )
  +        throws ProfileException;
   
       /** Get a list of profiles given a profile locator criteria.
        *
  -     * @param The profile locator criteria.
  +     * @param locator The profile locator criteria.
  +     * @return The list of profiles matching the locator criteria.
        */
       public Iterator list( ProfileLocator locator );
   
  
  
  
  1.5       +219 -26   jakarta-jetspeed/src/java/org/apache/jetspeed/services/psmlmanager/CastorPsmlManagerService.java
  
  Index: CastorPsmlManagerService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/psmlmanager/CastorPsmlManagerService.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- CastorPsmlManagerService.java	2001/07/09 17:08:49	1.4
  +++ CastorPsmlManagerService.java	2001/07/17 16:44:49	1.5
  @@ -57,11 +57,11 @@
   //Jetspeed stuff
   import org.apache.jetspeed.cache.disk.JetspeedDiskCache;
   import org.apache.jetspeed.om.profile.ProfileLocator;
  +import org.apache.jetspeed.util.FileCopy;
   
   //Castor defined API
   import org.apache.jetspeed.xml.api.portletmarkup.Portlets;
  -import org.apache.jetspeed.om.profile.PSMLDocument;
  -import org.apache.jetspeed.om.profile.BasePSMLDocument;
  +import org.apache.jetspeed.om.profile.*;
   
   //turbine stuff
   import org.apache.turbine.util.Log;
  @@ -70,7 +70,9 @@
   import org.apache.turbine.services.TurbineServices;
   import org.apache.turbine.services.servlet.TurbineServlet;
   import org.apache.turbine.services.resources.ResourceService;
  -
  +import org.apache.turbine.om.security.User;
  +import org.apache.turbine.om.security.Role;
  +import org.apache.turbine.om.security.Group;
   //castor support
   import org.exolab.castor.xml.MarshalException;
   import org.exolab.castor.xml.ValidationException;
  @@ -100,11 +102,31 @@
    * This service is responsible for loading and saving PSML documents.
    *
    * @author <a href="mailto:raphael@apache.org">RaphaŽl Luta</a>
  - * @version $Id: CastorPsmlManagerService.java,v 1.4 2001/07/09 17:08:49 taylor Exp $
  + * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
  + * @version $Id: CastorPsmlManagerService.java,v 1.5 2001/07/17 16:44:49 taylor Exp $
    */
   public class CastorPsmlManagerService extends TurbineBaseService
       implements PsmlManagerService
   {
  +    // resource path constants
  +    private static final String PATH_GROUP              = "group";
  +    private static final String PATH_ROLE               = "role";
  +    private static final String PATH_USER               = "user";
  +    private static final String PATH_ANON               = "anon";
  +
  +    // configuration keys
  +    private final static String CONFIG_ROOT             = ".root";
  +
  +    // default configuration values
  +    public final static String DEFAULT_ROOT             = "/WEB-INF/psml";
  +
  +    // default resource
  +    public final static String DEFAULT_RESOURCE         = "default.psml";
  +
  +    // the root psml resource directory
  +    private String root;
  +    // base store directory
  +    private File rootDir = null;
   
       /** The documents loaded by this manager */
       private Map documents = new HashMap();
  @@ -124,9 +146,22 @@
        */
       public void init( ServletConfig conf ) throws InitializationException
       {
  +        // get configuration parameters from Jetspeed Resources
           ResourceService serviceConf = ((TurbineServices)TurbineServices.getInstance())
                                                        .getResources(PsmlManagerService.SERVICE_NAME);
  -            
  +        // get the PSML Root Directory
  +        this.root = serviceConf.getString( CONFIG_ROOT, DEFAULT_ROOT );
  +        this.rootDir = new File(root);
  +
  +        if (!rootDir.isAbsolute())
  +        {
  +            this.rootDir = new File(conf.getServletContext().getRealPath(root));
  +        }
  +        if (!rootDir.exists())
  +        {
  +            rootDir.mkdirs();
  +        }
  +
           // create the serializer output format        
           this.format = new OutputFormat();
           format.setIndenting(true);
  @@ -141,7 +176,7 @@
   
   
       /** Late init method from Turbine Service model */
  -    public void init( ) throws InitializationException
  +    public void init() throws InitializationException
       {
           while( !getInit() )
           {
  @@ -183,7 +218,7 @@
               Log.error( message );
               throw new IllegalArgumentException( message );
           }
  -        
  +
           PSMLDocument doc = null;
           WeakReference ref = null;
   
  @@ -218,8 +253,44 @@
        */
       public PSMLDocument getDocument( ProfileLocator locator )
       {
  -        // IMPLEMENT ME:
  -        return null;
  +        if (locator == null)
  +        {
  +            String message = "PSMLManager: Must specify a name";
  +            Log.error( message );
  +            throw new IllegalArgumentException( message );
  +        }
  +        File base = this.rootDir;
  +        String path = mapLocatorToFile(locator);
  +        //Log.note("PSML-Man: calculated resource:" + path);
  +        File file = new File(base, path);
  +        String name = file.getAbsolutePath();
  +
  +        PSMLDocument doc = null;
  +        WeakReference ref = null;
  +
  +        synchronized (documents)
  +        {
  +            ref = (WeakReference)documents.get(name);
  +        }
  +        
  +        if (ref != null)
  +        {
  +            doc = (PSMLDocument)ref.get();
  +        }
  +        
  +        if (doc == null)
  +        {
  +            doc = loadDocument(name);
  +            if (null == doc)
  +                return null;
  +
  +            synchronized (documents)
  +            {
  +                // store the document in the hash and reference it to the watcher
  +                documents.put(name, new WeakReference(doc));
  +            }
  +        }
  +        return doc;
       }
   
       /** 
  @@ -228,10 +299,9 @@
        * @param fileOrUrl a String representing either an absolute URL or an
        * absolute filepath
        */
  -    public PSMLDocument loadDocument(String fileOrUrl)
  +    private PSMLDocument loadDocument(String fileOrUrl)
       {
  -        PSMLDocument doc = new BasePSMLDocument();
  -        doc.setName(fileOrUrl);
  +        PSMLDocument doc = null;
   
           if (fileOrUrl!=null)
           {
  @@ -240,6 +310,11 @@
               // we'll assume the name is the the location of the file
               
               File f = getFile(fileOrUrl);
  +            if (null == f)
  +                return null;
  +
  +            doc = new BasePSMLDocument();
  +            doc.setName(fileOrUrl);
   
               // now that we have a file reference, try to load the serialized PSML
               Portlets portlets = null;
  @@ -425,6 +500,7 @@
           {
               return f;
           }
  +/*
           else        
           {
               // try as a relative path
  @@ -444,8 +520,10 @@
                   Log.error("PSMLManager: unabel to retrieve file from diskcache for "+fileOrUrl,e);
               }
           }
  -        
  +
           return f;
  +*/
  +        return null;
       }    
       
       protected class DocumentWatcher extends Thread
  @@ -527,35 +605,150 @@
   
       /** Create a new document.
        *
  -     * @param The description of the new profile to be created.
  +     * @param profile The description and default value for the new document.
        * @return The newly created document;
        */
  -    public PSMLDocument createDocument( ProfileLocator locator )
  +    public PSMLDocument createDocument( Profile profile )
       {
  -        // TODO: implement
  -        return null;
  +        File base = this.rootDir;
  +        String path = mapLocatorToFile((ProfileLocator)profile);
  +        //Log.note("PSML-Man: calculated resource:" + path);
  +        File file = new File(base, path);
  +        String name = file.getAbsolutePath();
  +        PSMLDocument template = profile.getDocument();
  +        PSMLDocument doc = new BasePSMLDocument( name, template.getPortlets() );
  +        try
  +        {
  +            String parent = file.getParent();
  +            File filePath = new File(parent);
  +            filePath.mkdirs();
  +            FileCopy.copy( template.getName(), name );
  +            saveDocument(doc);
  +        }
  +        catch (Exception e)
  +        {
  +            Log.error("Failed to save document: " + e);
  +        }
  +        return doc;
       }
   
  -    /** Get a list of profiles given a profile locator criteria.
  +    /** Given a ordered list of locators, find the first document matching
  +     *  a profile locator, starting from the beginning of the list and working
  +     *  to the end.
        *
  -     * @param The profile locator criteria.
  +     * @param locator The ordered list of profile locators.
        */
  -    public Iterator list( ProfileLocator locator )
  +    public PSMLDocument getDocument( List locators )
       {
  -        // TODO: implement
  +        // IMPLEMENT ME:
           return null;
       }
   
  -    /** Given a ordered list of locators, find the first document matching
  -     *  a profile locator, starting from the beginning of the list and working
  -     *  to the end.
  +    /** Query for a collection of profiles given a profile locator criteria.
        *
  -     * @param locator The ordered list of profile locators.
  +     * @param locator The profile locator criteria.
        */
  -    public PSMLDocument fallback( List locators )
  +    public Iterator query( ProfileLocator locator )
       {
           // IMPLEMENT ME:
           return null;
  +    }
  +
  +    /** Removes a document.
  +     *
  +     * @param locator The description of the profile resource to be removed.
  +     */
  +    public void removeDocument( ProfileLocator locator )
  +    {
  +        
  +    }
  +
  +    /**
  +     * Maps a ProfileLocator to a file.
  +     * 
  +     * @param locator The profile locator describing the PSML resource to be found.
  +     * @return the String path of the file.
  +     */
  +    protected String mapLocatorToFile(ProfileLocator locator)
  +    {
  +        StringBuffer path = new StringBuffer();
  +
  +        // move the base dir is either user or role is specified
  +        Role role = locator.getRole();
  +        Group group = locator.getGroup();
  +        User user = locator.getUser();
  +
  +        // Is it an anonymous, user, group, or role resource?
  +        if (locator.getAnonymous())
  +        {
  +            path.append(PATH_ANON);
  +        }
  +        else if (user != null)
  +        {
  +            path.append(PATH_USER);
  +            String name = user.getUserName();
  +            if (null != name && name.length() > 0)
  +            {
  +                path.append(File.separator)
  +                    .append(name);
  +            }
  +        }
  +        else if (group != null)
  +        {
  +            path.append(PATH_GROUP);
  +            String name = group.getName();
  +            if (null != name && name.length() > 0)
  +            {
  +                path.append(File.separator)
  +                    .append(name);
  +            }
  +        }
  +        else if (null != role)
  +        {
  +            path.append(PATH_ROLE);
  +            String name = role.getName();
  +            if (null != name && name.length() > 0)
  +            {
  +                path.append(File.separator)
  +                    .append(name);
  +            }
  +        }
  +        else
  +        {
  +            path.append(PATH_ANON);
  +        }
  +
  +        // Media
  +        if (null != locator.getMediaType())
  +        {
  +            path.append(File.separator)
  +                .append(locator.getMediaType());
  +        }
  +        // Language
  +        if (null != locator.getLanguage())
  +        {
  +            path.append(File.separator)
  +                .append(locator.getLanguage());
  +        }
  +        // Country
  +        if (null != locator.getCountry())
  +        {
  +            path.append(File.separator)
  +                .append(locator.getCountry());
  +        }
  +        // Resource Name
  +        if (null != locator.getName())
  +        {
  +            path.append(File.separator)
  +                .append(locator.getName());
  +        }
  +        else
  +        {
  +            path.append(File.separator)
  +                .append(DEFAULT_RESOURCE);
  +        }
  +
  +        return  path.toString();
       }
   
   }
  
  
  
  1.4       +20 -13    jakarta-jetspeed/src/java/org/apache/jetspeed/services/psmlmanager/PsmlManagerService.java
  
  Index: PsmlManagerService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/psmlmanager/PsmlManagerService.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PsmlManagerService.java	2001/07/09 17:08:51	1.3
  +++ PsmlManagerService.java	2001/07/17 16:44:50	1.4
  @@ -59,12 +59,13 @@
   import org.apache.turbine.services.Service;
   import org.apache.jetspeed.om.profile.PSMLDocument;
   import org.apache.jetspeed.om.profile.ProfileLocator;
  +import org.apache.jetspeed.om.profile.Profile;
   
   /**
    * This service is responsible for loading and saving PSML documents.
    *
    * @author <a href="mailto:raphael@apache.org">RaphaŽl Luta</a>
  - * @version $Id: PsmlManagerService.java,v 1.3 2001/07/09 17:08:51 taylor Exp $
  + * @version $Id: PsmlManagerService.java,v 1.4 2001/07/17 16:44:50 taylor Exp $
    */
   public interface PsmlManagerService extends Service
   {
  @@ -89,6 +90,13 @@
        */
       public PSMLDocument getDocument( ProfileLocator locator );
   
  +    /** Given a ordered list of locators, find the first document matching
  +     *  a profile locator, starting from the beginning of the list and working
  +     *  to the end.
  +     *
  +     * @param locator The ordered list of profile locators.
  +     */
  +    public PSMLDocument getDocument( List locators );
   
       /** Save the PSML document on disk, using its name as filepath
        * 
  @@ -98,7 +106,8 @@
       public boolean saveDocument(PSMLDocument doc);
       
       /** Save the PSML document on disk to the specififed fileOrUrl
  -     * 
  +     *
  +     * @deprecated
        * @param fileOrUrl a String representing either an absolute URL
        * or an absolute filepath
        * @param doc the document to save
  @@ -108,23 +117,21 @@
   
       /** Create a new document.
        *
  -     * @param The description of the new profile to be created.
  -     * @return The newly created document;
  +     * @param
  +     * @return The newly created document.
        */
  -    public PSMLDocument createDocument( ProfileLocator locator );
  +    public PSMLDocument createDocument( Profile profile );
   
  -    /** Get a list of profiles given a profile locator criteria.
  +    /** Remove a document.
        *
  -     * @param The profile locator criteria.
  +     * @param locator The description of the profile to be removed.
        */
  -    public Iterator list( ProfileLocator locator );
  +    public void removeDocument( ProfileLocator locator );
   
  -    /** Given a ordered list of locators, find the first document matching
  -     *  a profile locator, starting from the beginning of the list and working
  -     *  to the end.
  +    /** Query for a collection of profiles given a profile locator criteria.
        *
  -     * @param locator The ordered list of profile locators.
  +     * @param locator The profile locator criteria.
        */
  -    public PSMLDocument fallback( List locators );
  +    public Iterator query( ProfileLocator locator );
   }
   
  
  
  
  1.7       +21 -6     jakarta-jetspeed/src/java/org/apache/jetspeed/services/security/JetspeedDBSecurityService.java
  
  Index: JetspeedDBSecurityService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/security/JetspeedDBSecurityService.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- JetspeedDBSecurityService.java	2001/07/06 23:34:37	1.6
  +++ JetspeedDBSecurityService.java	2001/07/17 16:44:53	1.7
  @@ -68,6 +68,9 @@
   import org.apache.turbine.util.security.EntityExistsException;
   
   import org.apache.jetspeed.om.profile.Profile;
  +import org.apache.jetspeed.om.profile.ProfileLocator;
  +import org.apache.jetspeed.om.profile.BaseProfile;
  +import org.apache.jetspeed.om.profile.BaseProfileLocator;
   import org.apache.jetspeed.om.profile.ProfileException;
   import org.apache.jetspeed.services.Profiler;
   
  @@ -77,7 +80,7 @@
    *
    * @author <a href="mailto:david@bluesunrise.com">David Sean Taylor</a>
    * @author <a href="mailto:sgala@hisitech.com">Santiago Gala</a>
  - * @version $Id: JetspeedDBSecurityService.java,v 1.6 2001/07/06 23:34:37 taylor Exp $
  + * @version $Id: JetspeedDBSecurityService.java,v 1.7 2001/07/17 16:44:53 taylor Exp $
    */
   
   
  @@ -176,9 +179,18 @@
                 getGroup(JetspeedSecurity.JETSPEED_GROUP), 
                 getRole(JetspeedSecurity.JETSPEED_ROLE_USER));
   
  -        user.setHasLoggedIn(new Boolean (true));        
  -        
  -        Profiler.createUserProfile(data, user);
  +        try
  +        {
  +            Profile profile = new BaseProfile();
  +            profile.setUser(user);
  +            profile.setMediaType("html");
  +            Profiler.createProfile(data, profile);
  +        }
  +        catch (Exception e)
  +        {
  +            removeUser(user);
  +            throw e;
  +        }
       }
   
      /**
  @@ -190,11 +202,14 @@
        * @exception Can throw database exceptions or profiler exceptions
        *            
        */ 
  -    public void removeUser( User user, RunData data ) 
  +    public void removeUser( User user, RunData data )
           throws Exception
       {
           removeUser(user);
   
  -        Profiler.removeUserProfile(data, user);
  +        ProfileLocator locator = new BaseProfileLocator();
  +        locator.setUser(user);
  +        locator.setName("*");
  +        Profiler.removeProfile(locator);
       }
   }
  
  
  

---------------------------------------------------------------------
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