You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2006/10/27 21:41:48 UTC

svn commit: r468510 - in /cocoon/trunk/blocks/cocoon-portal: cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/acting/ cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/ cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profi...

Author: cziegeler
Date: Fri Oct 27 12:41:47 2006
New Revision: 468510

URL: http://svn.apache.org/viewvc?view=rev&rev=468510
Log:
Continue profile handling cleanup

Modified:
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/acting/SaveAction.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/PortalUser.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/ProfileManager.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/AbstractPortalUser.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/StaticProfileManager.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/scratchpad/Profile.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/scratchpad/ProfileImpl.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/UserService.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/DefaultUserService.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-portlet-impl/src/main/java/org/apache/cocoon/portal/pluto/TestProfileManager.java

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/acting/SaveAction.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/acting/SaveAction.java?view=diff&rev=468510&r1=468509&r2=468510
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/acting/SaveAction.java (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/acting/SaveAction.java Fri Oct 27 12:41:47 2006
@@ -43,7 +43,7 @@
             this.getLogger().debug("Portal Save Action called.");
         }
 
-        this.portalService.getProfileManager().saveUserProfiles(null);
+        this.portalService.getProfileManager().saveUserProfiles();
         return EMPTY_MAP;
     }
 

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/PortalUser.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/PortalUser.java?view=diff&rev=468510&r1=468509&r2=468510
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/PortalUser.java (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/PortalUser.java Fri Oct 27 12:41:47 2006
@@ -79,8 +79,8 @@
     String getAuthType();
 
     /**
-     * Return the default layout key for this user.
-     * @return The default layout key or null if the portal wide default should be used.
+     * Return the default profile name for this user.
+     * @return The default profile name or null if the portal wide default should be used.
      */
-    String getDefaultLayoutKey();
+    String getDefaultProfileName();
 }

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/ProfileManager.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/ProfileManager.java?view=diff&rev=468510&r1=468509&r2=468510
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/ProfileManager.java (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/ProfileManager.java Fri Oct 27 12:41:47 2006
@@ -65,12 +65,10 @@
     CopletDefinition getCopletDefinition(String copletDataId);
 
     /**
-     * Save the profile. Usually this just calls {@link #saveUserCopletInstanceDatas(String)}
-     * and {@link #saveUserLayout(String)}, but implementations are free to
-     * implement this method in a different way.
-     * @param layoutKey
+     * Save the user profile.
+     * This saves the curent user profile. It usually saves the layout and coplet instances.
      */
-    void saveUserProfiles(String profileName);
+    void saveUserProfiles();
 
     /**
      * Get all coplet instances for the current user.

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/AbstractPortalUser.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/AbstractPortalUser.java?view=diff&rev=468510&r1=468509&r2=468510
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/AbstractPortalUser.java (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/AbstractPortalUser.java Fri Oct 27 12:41:47 2006
@@ -124,9 +124,9 @@
     }
 
     /**
-     * @see org.apache.cocoon.portal.om.PortalUser#getDefaultLayoutKey()
+     * @see org.apache.cocoon.portal.om.PortalUser#getDefaultProfileName()
      */
-    public String getDefaultLayoutKey() {
+    public String getDefaultProfileName() {
         return null;
     }
 

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java?view=diff&rev=468510&r1=468509&r2=468510
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java Fri Oct 27 12:41:47 2006
@@ -100,24 +100,9 @@
     }
 
     /**
-     * @see org.apache.cocoon.portal.profile.ProfileManager#saveUserProfiles(String)
+     * @see org.apache.cocoon.portal.profile.ProfileManager#saveUserProfiles()
      */
-    public void saveUserProfiles(String layoutKey) {
-        this.saveUserCopletInstanceDatas(layoutKey);
-        this.saveUserLayout(layoutKey);
-    }
-
-    /**
-     * @see org.apache.cocoon.portal.profile.ProfileManager#saveUserCopletInstanceDatas(java.lang.String)
-     */
-    public void saveUserCopletInstanceDatas(String layoutKey) {
-        // override in subclass
-    }
-
-    /**
-     * @see org.apache.cocoon.portal.profile.ProfileManager#saveUserLayout(String)
-     */
-    public void saveUserLayout(String layoutKey) {
+    public void saveUserProfiles() {
         // override in subclass
     }
 

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java?view=diff&rev=468510&r1=468509&r2=468510
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java Fri Oct 27 12:41:47 2006
@@ -130,26 +130,16 @@
         this.loader = (ProfileLS)this.manager.lookup(ProfileLS.ROLE);
     }
 
-    protected ProfileImpl getUserProfile(String layoutKey) {
-        if ( layoutKey == null ) {
-            layoutKey = this.portalService.getUserService().getDefaultLayoutKey();
-        }
-
-        return (ProfileImpl)this.portalService.getUserService().getAttribute(KEY_PREFIX + layoutKey);
+    protected ProfileImpl getUserProfile() {
+        return (ProfileImpl)this.portalService.getUserService().getAttribute(KEY_PREFIX + "profile");
     }
 
     protected void removeUserProfiles() {
-        // TODO: remove all profiles - we have to rememember all used layout keys
-        final String layoutKey = this.portalService.getUserService().getDefaultLayoutKey();
-
-        this.portalService.getUserService().removeAttribute(KEY_PREFIX + layoutKey);
+        this.portalService.getUserService().removeAttribute(KEY_PREFIX + "profile");
     }
 
-    protected void storeUserProfile(String layoutKey, Profile profile) {
-        if ( layoutKey == null ) {
-            layoutKey = this.portalService.getUserService().getDefaultLayoutKey();
-        }
-        this.portalService.getUserService().setAttribute(KEY_PREFIX + layoutKey, profile);
+    protected void storeUserProfile(Profile profile) {
+        this.portalService.getUserService().setAttribute(KEY_PREFIX + "profile", profile);
     }
 
     /**
@@ -166,7 +156,7 @@
      * @see org.apache.cocoon.portal.profile.impl.AbstractProfileManager#logout(org.apache.cocoon.portal.om.PortalUser)
      */
     protected void logout(PortalUser user) {
-        final Profile profile = this.getUserProfile(null);
+        final Profile profile = this.getUserProfile();
         if ( profile != null ) {
 
             Iterator iter = profile.getCopletInstances().iterator();
@@ -185,7 +175,7 @@
      * @see org.apache.cocoon.portal.profile.ProfileManager#getCopletInstance(java.lang.String)
      */
     public CopletInstance getCopletInstance(String copletID) {
-        final Profile profile = this.getUserProfile(null);
+        final Profile profile = this.getUserProfile();
         if ( profile != null ) {
             return profile.searchCopletInstance(copletID);
         }
@@ -196,7 +186,7 @@
      * @see org.apache.cocoon.portal.profile.ProfileManager#getCopletDefinition(java.lang.String)
      */
     public CopletDefinition getCopletDefinition(String copletDataId) {
-        final ProfileImpl profile = this.getUserProfile(null);
+        final ProfileImpl profile = this.getUserProfile();
         if ( profile != null ) {
             return profile.searchCopletDefinition(copletDataId);
         }
@@ -207,7 +197,7 @@
      * @see org.apache.cocoon.portal.profile.ProfileManager#getCopletInstances(org.apache.cocoon.portal.om.CopletDefinition)
      */
     public List getCopletInstances(CopletDefinition data) {
-        final Profile profile = this.getUserProfile(null);
+        final Profile profile = this.getUserProfile();
         if ( profile != null ) {
             final List coplets = new ArrayList();
             final Iterator iter = profile.getCopletInstances().iterator();
@@ -227,7 +217,7 @@
      * @see Receiver
      */
     public void inform(CopletInstanceAddedEvent event) {
-        final ProfileImpl profile = this.getUserProfile(null);
+        final ProfileImpl profile = this.getUserProfile();
         profile.add(event.getTarget());
     }
 
@@ -247,7 +237,7 @@
      * @see Receiver
      */
     public void inform(CopletInstanceRemovedEvent event) {
-        final ProfileImpl profile = this.getUserProfile(null);
+        final ProfileImpl profile = this.getUserProfile();
         profile.remove(event.getTarget());
     }
 
@@ -256,7 +246,7 @@
      * @see Receiver
      */
     public void inform(LayoutAddedEvent event) {
-        final ProfileImpl profile = this.getUserProfile(null);
+        final ProfileImpl profile = this.getUserProfile();
         profile.add(event.getTarget());
     }
 
@@ -265,7 +255,7 @@
      * @see Receiver
      */
     public void inform(LayoutInstanceAddedEvent event) {
-        final ProfileImpl profile = this.getUserProfile(null);
+        final ProfileImpl profile = this.getUserProfile();
         profile.add(event.getTarget());
     }
 
@@ -274,35 +264,32 @@
      * @see Receiver
      */
     public void inform(LayoutRemovedEvent event) {
-        final ProfileImpl profile = this.getUserProfile(null);
+        final ProfileImpl profile = this.getUserProfile();
         profile.remove(event.getTarget());
     }
 
+    /**
+     * @see org.apache.cocoon.portal.profile.ProfileManager#getLayout(java.lang.String)
+     */
     public Layout getLayout(String layoutId) {
-        final String layoutKey = this.portalService.getUserService().getDefaultLayoutKey();
-
-        Profile profile = this.getUserProfile(layoutKey);
+        Profile profile = this.getUserProfile();
         if ( profile == null ) {
-            try {
-                profile = this.loadProfile(layoutKey);
-            } catch (Exception e) {
-                throw new ProfileException("Unable to load profile: " + layoutKey, e);
-            }
+            profile = this.loadProfile();
         }
         if ( profile == null ) {
-            throw new ProfileException("Unable to load profile: " + layoutKey);
+            throw new ProfileException("Unable to get standard profile with layout key '" + this.portalService.getUserService().getDefaultProfileName() + "' for user " + this.portalService.getUserService().getUser());
         }
         if ( layoutId != null ) {
             return profile.searchLayout(layoutId);
         }
         return profile.getRootLayout();
     }
-    
+
     /**
      * @see org.apache.cocoon.portal.profile.ProfileManager#getCopletDefinitions()
      */
     public Collection getCopletDefinitions() {
-        final ProfileImpl profile = this.getUserProfile(null);
+        final ProfileImpl profile = this.getUserProfile();
         if ( profile != null ) {
             return profile.getCopletDefinitions();
         }
@@ -313,7 +300,7 @@
      * @see org.apache.cocoon.portal.profile.ProfileManager#getCopletInstances()
      */
     public Collection getCopletInstances() {
-        final Profile profile = this.getUserProfile(null);
+        final Profile profile = this.getUserProfile();
         if ( profile != null ) {
             return profile.getCopletInstances();
         }
@@ -321,40 +308,48 @@
     }
 
     /**
-     * Load the profile
-     */
-    protected Profile loadProfile(final String layoutKey) 
-    throws Exception {
-        final PortalUser info = this.portalService.getUserService().getUser();
-        ProfileImpl profile = new ProfileImpl(layoutKey);
+     * Load the profile.
+     * This loads the profile for the current user. First the default profile is read. This might
+     * contain links to other profiles which are then loaded recursively.
+     */
+    protected Profile loadProfile() 
+    throws ProfileException {
+        final String layoutKey = this.portalService.getUserService().getDefaultProfileName();
+        final PortalUser user = this.portalService.getUserService().getUser();
+        ProfileImpl profile = new ProfileImpl();
 
-        // first "load" the global data
-        profile.setCopletTypes( this.getGlobalCopletTypes(layoutKey) );
-        profile.setCopletDefinitions( this.getGlobalDatas(info, profile, layoutKey) );
-
-        // now load the user/group specific data
-        if ( !this.getCopletInstanceDatas(profile, info, CATEGORY_USER, layoutKey) ) {
-            if ( info.getGroups().size() == 0 || !this.getCopletInstanceDatas(profile, info, CATEGORY_GROUP, layoutKey)) {
-                if ( !this.getCopletInstanceDatas(profile, info, CATEGORY_GLOBAL, layoutKey) ) {
-                    throw new ProcessingException("No profile for copletinstancedatas found.");
+        try {
+            // first "load" the global data
+            profile.setCopletTypes( this.getGlobalCopletTypes(layoutKey) );
+            profile.setCopletDefinitions( this.getGlobalDatas(user, profile, layoutKey) );
+    
+            // now load the user/group specific data
+            if ( !this.getCopletInstanceDatas(profile, user, CATEGORY_USER, layoutKey) ) {
+                if ( user.getGroups().size() == 0 || !this.getCopletInstanceDatas(profile, user, CATEGORY_GROUP, layoutKey)) {
+                    if ( !this.getCopletInstanceDatas(profile, user, CATEGORY_GLOBAL, layoutKey) ) {
+                        throw new ProcessingException("No profile for copletinstancedatas found.");
+                    }
                 }
             }
-        }
 
-        if ( !this.getLayout(profile, info, CATEGORY_USER, layoutKey) ) {
-            if ( info.getGroups().size() == 0 || !this.getLayout(profile, info, CATEGORY_GROUP, layoutKey)) {
-                if ( !this.getLayout(profile, info, CATEGORY_GLOBAL, layoutKey) ) {
-                    throw new ProcessingException("No profile for layout found.");
+            if ( !this.getLayout(profile, user, CATEGORY_USER, layoutKey) ) {
+                if ( user.getGroups().size() == 0 || !this.getLayout(profile, user, CATEGORY_GROUP, layoutKey)) {
+                    if ( !this.getLayout(profile, user, CATEGORY_GLOBAL, layoutKey) ) {
+                        throw new ProcessingException("No profile for layout found.");
+                    }
                 }
             }
+        } catch (ProfileException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new ProfileException("Unable to load profile '" + layoutKey + "' for user " + user + ".", e);
         }
-
         final Profile processedProfile = this.processProfile(profile);
-        this.storeUserProfile(layoutKey, processedProfile);
+        this.storeUserProfile(processedProfile);
         return processedProfile;
     }
 
-    protected Map getGlobalCopletTypes(final String     layoutKey)
+    protected Map getGlobalCopletTypes(final String profileName)
     throws Exception {
         // if we already have loaded the profile and don't check
         // for changes, just return the profile
@@ -366,7 +361,7 @@
                 ProfileLS.PROFILETYPE_COPLETTYPE,
                 null,
                 true,
-                layoutKey);
+                profileName);
 
         SourceValidity newValidity = null;
         // if we have a profile, check for reloading
@@ -459,7 +454,8 @@
         }
     }
 
-    private boolean isSourceNotFoundException(Throwable t) {
+    private boolean isSourceNotFoundException(Throwable e) {
+        Throwable t = e;
         while (t != null) {
             if (t instanceof SourceNotFoundException) {
                 return true;
@@ -521,8 +517,11 @@
                            String   profileType,
                            PortalUser info,
                            boolean  load,
-                           String   layoutKey)
+                           String   profileName)
     throws ParameterException {
+        if ( profileName == null ) {
+            profileName = this.portalService.getUserService().getDefaultProfileName();
+        }
         final StringBuffer config = new StringBuffer(profileType);
         config.append('-');
         config.append(category);
@@ -538,7 +537,7 @@
         key.put("baseuri", uri);
         key.put("separator", "?");
         key.put("portal", this.portalService.getPortalName());
-        key.put("layout", layoutKey);
+        key.put("layout", profileName);
         key.put("type", category);
         if ( CATEGORY_GROUP.equals(category) ) {
             // TODO Groups is a collection!
@@ -552,19 +551,21 @@
     }
 
     /**
-     * @see org.apache.cocoon.portal.profile.impl.AbstractProfileManager#saveUserCopletInstanceDatas(java.lang.String)
+     * @see org.apache.cocoon.portal.profile.ProfileManager#saveUserProfiles()
      */
-    public void saveUserCopletInstanceDatas(String layoutKey) {
+    public void saveUserProfiles() {
+        this.saveCopletInstances();
+        this.saveLayoutInstances();
+    }
+
+    protected void saveCopletInstances() {
         try {
-            if (layoutKey == null) {
-                layoutKey = this.portalService.getUserService().getDefaultLayoutKey();
-            }
-            final ProfileImpl profile = this.getUserProfile(layoutKey);
+            final ProfileImpl profile = this.getUserProfile();
             final Map key = this.buildKey(CATEGORY_USER,
                                           ProfileLS.PROFILETYPE_COPLETINSTANCE,
                                           this.portalService.getUserService().getUser(),
                                           false,
-                                          layoutKey);
+                                          null);
             this.loader.saveProfile(key, ProfileLS.PROFILETYPE_COPLETINSTANCE, profile.getCopletInstances());
         } catch (Exception e) {
             // TODO
@@ -575,18 +576,15 @@
     /**
      * @see org.apache.cocoon.portal.profile.impl.AbstractProfileManager#saveUserLayout(java.lang.String)
      */
-    public void saveUserLayout(String layoutKey) {
+    public void saveLayoutInstances() {
         try {
-            if (layoutKey == null) {
-                layoutKey = this.portalService.getUserService().getDefaultLayoutKey();
-            }
-            final Profile profile = this.getUserProfile(layoutKey);
+            final Profile profile = this.getUserProfile();
             final Map key = this.buildKey(CATEGORY_USER,
-                                          ProfileLS.PROFILETYPE_LAYOUT, 
+                                          ProfileLS.PROFILETYPE_LAYOUTINSTANCE, 
                                           this.portalService.getUserService().getUser(),
                                           false,
-                                          layoutKey);
-            this.loader.saveProfile(key, ProfileLS.PROFILETYPE_LAYOUT, profile.getRootLayout());
+                                          null);
+            this.loader.saveProfile(key, ProfileLS.PROFILETYPE_LAYOUTINSTANCE, profile.getRootLayout());
         } catch (Exception e) {
             // TODO
             throw new ProfileException("Exception during save profile", e);
@@ -610,7 +608,7 @@
         if ( this.copletTypes.objects == null ) {
             try {
                 // first "load" the global data
-                this.getGlobalCopletTypes(this.portalService.getUserService().getDefaultLayoutKey());
+                this.getGlobalCopletTypes(this.portalService.getUserService().getDefaultProfileName());
             } catch (Exception e) {
                 throw new ProfileException("Unable to load global base datas.", e);
             }            
@@ -623,7 +621,7 @@
      */
     public LayoutInstance getLayoutInstance(Layout layout) {
         LayoutInstance result = null;
-        final Profile profile = this.getUserProfile(null);
+        final Profile profile = this.getUserProfile();
         if ( profile != null ) {
             result = profile.searchLayoutInstance(layout);
         }

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/StaticProfileManager.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/StaticProfileManager.java?view=diff&rev=468510&r1=468509&r2=468510
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/StaticProfileManager.java (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/StaticProfileManager.java Fri Oct 27 12:41:47 2006
@@ -62,7 +62,7 @@
     public Layout getLayout(String layoutID) {
         ProfileLS adapter = null;
         try {
-            final String layoutKey = this.portalService.getUserService().getDefaultLayoutKey();
+            final String layoutKey = this.portalService.getUserService().getDefaultProfileName();
 
             String serviceKey = LAYOUTKEY_PREFIX + layoutKey;
             Object[] objects = (Object[]) this.portalService.getUserService().getAttribute(serviceKey);

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/scratchpad/Profile.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/scratchpad/Profile.java?view=diff&rev=468510&r1=468509&r2=468510
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/scratchpad/Profile.java (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/scratchpad/Profile.java Fri Oct 27 12:41:47 2006
@@ -32,8 +32,6 @@
  */
 public interface Profile {
 
-    String getProfileName();
-
     Collection getCopletInstances();
     Collection getLayoutObjects();
 

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/scratchpad/ProfileImpl.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/scratchpad/ProfileImpl.java?view=diff&rev=468510&r1=468509&r2=468510
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/scratchpad/ProfileImpl.java (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/scratchpad/ProfileImpl.java Fri Oct 27 12:41:47 2006
@@ -40,9 +40,6 @@
  */
 public class ProfileImpl implements Profile {
 
-    /** The name (unique key) of this profile. */
-    protected final String profileName;
-
     /** A map of all coplet types. */
     protected Map copletTypes;
 
@@ -64,10 +61,6 @@
     /** The root element of the layout. */
     protected Layout rootLayout;
 
-    public ProfileImpl(String profileName) {
-        this.profileName = profileName;
-    }
-
     /**
      * Set the root layout for this profile.
      */
@@ -126,13 +119,6 @@
      */
     public Collection getLayoutObjects() {
         return this.layouts;
-    }
-
-    /**
-     * @see org.apache.cocoon.portal.scratchpad.Profile#getProfileName()
-     */
-    public String getProfileName() {
-        return this.profileName;
     }
 
     /**

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/UserService.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/UserService.java?view=diff&rev=468510&r1=468509&r2=468510
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/UserService.java (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/UserService.java Fri Oct 27 12:41:47 2006
@@ -87,7 +87,7 @@
     Collection getTemporaryAttributeNames();
 
     /**
-     * Return the default layout key for the specific user.
+     * Return the default profile name for the current user.
      */
-    String getDefaultLayoutKey();
+    String getDefaultProfileName();
 }

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/DefaultUserService.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/DefaultUserService.java?view=diff&rev=468510&r1=468509&r2=468510
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/DefaultUserService.java (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/DefaultUserService.java Fri Oct 27 12:41:47 2006
@@ -45,8 +45,8 @@
     /** The attribute prefix used to prefix attributes in the session and request. */
     protected String attributeName;
 
-    /** The default layout key. */
-    protected String defaultLayoutKey;
+    /** The default profile name. */
+    protected String defaultProfileName;
 
     /**
      * @see org.apache.cocoon.portal.impl.AbstractComponent#initialize()
@@ -54,7 +54,8 @@
     public void initialize() throws Exception {
         super.initialize();
         this.attributeName = DefaultUserService.class.getName() + '/' + this.portalService.getPortalName();
-        this.defaultLayoutKey = this.portalService.getConfiguration("default-layout-key", "portal");
+        // FIXME - We should use a better default than 'portal'
+        this.defaultProfileName = this.portalService.getConfiguration("default-profile-name", "portal");
     }
 
     /**
@@ -208,12 +209,12 @@
     }
 
     /**
-     * @see org.apache.cocoon.portal.services.UserService#getDefaultLayoutKey()
+     * @see org.apache.cocoon.portal.services.UserService#getDefaultProfileName()
      */
-    public String getDefaultLayoutKey() {
-        String key = this.getUser().getDefaultLayoutKey();
+    public String getDefaultProfileName() {
+        String key = this.getUser().getDefaultProfileName();
         if ( key == null ) {
-            return this.defaultLayoutKey;
+            return this.defaultProfileName;
         }
         return key;
     }

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-portlet-impl/src/main/java/org/apache/cocoon/portal/pluto/TestProfileManager.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-portlet-impl/src/main/java/org/apache/cocoon/portal/pluto/TestProfileManager.java?view=diff&rev=468510&r1=468509&r2=468510
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-portlet-impl/src/main/java/org/apache/cocoon/portal/pluto/TestProfileManager.java (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-portlet-impl/src/main/java/org/apache/cocoon/portal/pluto/TestProfileManager.java Fri Oct 27 12:41:47 2006
@@ -32,6 +32,7 @@
 import org.apache.cocoon.portal.om.CopletLayout;
 import org.apache.cocoon.portal.om.Item;
 import org.apache.cocoon.portal.om.PortalUser;
+import org.apache.cocoon.portal.profile.ProfileException;
 import org.apache.cocoon.portal.profile.impl.GroupBasedProfileManager;
 import org.apache.cocoon.portal.scratchpad.Profile;
 import org.apache.cocoon.portal.scratchpad.ProfileImpl;
@@ -56,63 +57,68 @@
  */
 public class TestProfileManager extends GroupBasedProfileManager {
 
-    protected Profile loadProfile(final String layoutKey) 
-    throws Exception {
+    protected Profile loadProfile() 
+    throws ProfileException {
         final PortalUser info = this.portalService.getUserService().getUser();
+        final String layoutKey = this.portalService.getUserService().getDefaultProfileName();
         if ( info.getUserName().equals("test") ) {
-            // if the request parameter 'portletName' is available we only
-            // display the portlets specified with the parameter. Otherwise
-            // we show all portlets
-            final List portletNames = new ArrayList();
-            final HttpServletRequest r = this.portalService.getProcessInfoProvider().getRequest();
-            final String[] values = r.getParameterValues("portletName");
-            if ( values != null && values.length > 0 ) {
-                for(int i=0; i<values.length; i++) {
-                    portletNames.add(StringUtils.replaceChars(values[i], '/', '.'));
+            try {
+                // if the request parameter 'portletName' is available we only
+                // display the portlets specified with the parameter. Otherwise
+                // we show all portlets
+                final List portletNames = new ArrayList();
+                final HttpServletRequest r = this.portalService.getProcessInfoProvider().getRequest();
+                final String[] values = r.getParameterValues("portletName");
+                if ( values != null && values.length > 0 ) {
+                    for(int i=0; i<values.length; i++) {
+                        portletNames.add(StringUtils.replaceChars(values[i], '/', '.'));
+                    }
                 }
-            }
-            final ProfileImpl profile = new ProfileImpl(layoutKey);
-
-            // first "load" the global data
-            profile.setCopletTypes( this.getGlobalCopletTypes( layoutKey) );
-            profile.setCopletDefinitions( this.getGlobalDatas( info, profile, layoutKey) );
-
-            // create root layout
-            CompositeLayout rootLayout = new CompositeLayout("root", "row");
-
-            // create coplet instances and layouts
-            final List instances = new ArrayList();
-            final Iterator i = this.deployedCopletDefinitions.values().iterator();
-            while ( i.hasNext() ) {
-                final CopletDefinition cd = (CopletDefinition)i.next();
-                // check for portlets
-                if ( "portlet".equals(cd.getCopletType().getCopletAdapterName()) ) {
-                    final String id = StringUtils.replaceChars(cd.getId() + "-1", '_', '-');
-                    final CopletInstance cid = new CopletInstance(id);
-                    cid.setCopletDefinition(cd);
-                    instances.add(cid);
-                    if ( portletNames.size() == 0 || portletNames.contains(cd.getId())) {
-                        final CopletLayout copletLayout = new CopletLayout(null, "coplet");
-                        copletLayout.setCopletInstanceId(cid.getId());
-                        final Item item = new Item();
-                        item.setLayout(copletLayout);
-                        rootLayout.addItem(item);
+                final ProfileImpl profile = new ProfileImpl();
+    
+                // first "load" the global data
+                profile.setCopletTypes( this.getGlobalCopletTypes( layoutKey) );
+                profile.setCopletDefinitions( this.getGlobalDatas( info, profile, layoutKey) );
+    
+                // create root layout
+                CompositeLayout rootLayout = new CompositeLayout("root", "row");
+    
+                // create coplet instances and layouts
+                final List instances = new ArrayList();
+                final Iterator i = this.deployedCopletDefinitions.values().iterator();
+                while ( i.hasNext() ) {
+                    final CopletDefinition cd = (CopletDefinition)i.next();
+                    // check for portlets
+                    if ( "portlet".equals(cd.getCopletType().getCopletAdapterName()) ) {
+                        final String id = StringUtils.replaceChars(cd.getId() + "-1", '_', '-');
+                        final CopletInstance cid = new CopletInstance(id);
+                        cid.setCopletDefinition(cd);
+                        instances.add(cid);
+                        if ( portletNames.size() == 0 || portletNames.contains(cd.getId())) {
+                            final CopletLayout copletLayout = new CopletLayout(null, "coplet");
+                            copletLayout.setCopletInstanceId(cid.getId());
+                            final Item item = new Item();
+                            item.setLayout(copletLayout);
+                            rootLayout.addItem(item);
+                        }
                     }
                 }
+                profile.setCopletInstances(instances);
+                this.prepareObject(profile, instances);
+    
+                this.prepareObject(profile, rootLayout);
+                profile.setRootLayout(rootLayout);
+    
+                final Profile processedProfile = this.processProfile(profile);    
+                this.storeUserProfile(processedProfile);
+                return processedProfile;
+            } catch (ProfileException e) {
+                throw e;
+            } catch (Exception e) {
+                throw new ProfileException("Unable to load profile for '" + layoutKey + "'.", e);
             }
-            profile.setCopletInstances(instances);
-            this.prepareObject(profile, instances);
-
-            this.prepareObject(profile, rootLayout);
-            profile.setRootLayout(rootLayout);
-
-            final Profile processedProfile = this.processProfile(profile);
-            this.storeUserProfile(layoutKey, processedProfile);
-
-            this.storeUserProfile(layoutKey, processedProfile);
-            return processedProfile;
         }
-        return super.loadProfile(layoutKey);
+        return super.loadProfile();
     }
 
     /**
@@ -148,7 +154,7 @@
                             item.setLayout(copletLayout);
                             rootLayout.addItem(item);
                             try {
-                                 this.prepareObject(this.getUserProfile(null), copletLayout);
+                                 this.prepareObject(this.getUserProfile(), copletLayout);
                             } catch (LayoutException le) {
                                 // ignore this
                             }