You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by gg...@apache.org on 2002/09/27 19:02:20 UTC

cvs commit: jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/portlets CustomizeAction.java CustomizeSetAction.java

ggolden     2002/09/27 10:02:20

  Modified:    src/java/org/apache/jetspeed/modules/actions/portlets
                        CustomizeAction.java CustomizeSetAction.java
  Log:
  The customizers, including the Portlet customizer, now work on a clone of the
  current Profile / PSMLDocument rather than on the current ones.  This is to
  assure that if, due to new account creation and caching, there are two different
  Profiles that use the same PSMLDocument, only the one being edited will be
  modified.  Also, as someone is modifying a Profile, other users won't see the
  results until the modification is saved.  If the modification is cancled, nothing
  changes.
  
  Some support was added to the JetspeedRunData and the Customize.java for this.
  
  The JetspeedPortletInstance was changed to be aware of the clone used in customization, and to make a clone if needed before modifying the current psml.
  
  Revision  Changes    Path
  1.14      +43 -16    jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/portlets/CustomizeAction.java
  
  Index: CustomizeAction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/portlets/CustomizeAction.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- CustomizeAction.java	13 Aug 2002 22:24:53 -0000	1.13
  +++ CustomizeAction.java	27 Sep 2002 17:02:20 -0000	1.14
  @@ -62,7 +62,6 @@
   import org.apache.jetspeed.portal.PortletSkin;
   import org.apache.jetspeed.portal.portlets.VelocityPortlet;
   import org.apache.jetspeed.services.persistence.PersistenceManager;
  -import org.apache.jetspeed.services.persistence.PortalPersistenceException;
   import org.apache.jetspeed.services.Registry;
   import org.apache.jetspeed.services.rundata.JetspeedRunData;
   import org.apache.jetspeed.om.BaseSecurityReference;
  @@ -79,6 +78,8 @@
   import org.apache.jetspeed.services.security.PortalResource;
   import org.apache.jetspeed.portal.PortletInstance;
   import org.apache.jetspeed.util.MetaData;
  +import org.apache.jetspeed.services.statemanager.SessionState;
  +import org.apache.jetspeed.modules.actions.controls.Customize;
   
   // Turbine stuff
   import org.apache.turbine.util.Log;
  @@ -157,7 +158,10 @@
               }
           }
                       
  -        rundata.getSession().setAttribute("parameters", params);        
  +        // get the customization state for this page
  +        SessionState customizationState = ((JetspeedRunData)rundata).getPageSessionState();
  +        customizationState.setAttribute("customize-parameters", params);
  +
           // populate the customizer context
           context.put("parameters", params);
           context.put("portlet", p);
  @@ -167,7 +171,7 @@
           if (p.getPortletConfig().getSkin() != null)
               context.put("current_skin", p.getPortletConfig().getPortletSkin().getName());
   
  -        Profile profile = ((JetspeedRunData)rundata).getProfile();
  +        Profile profile = ((JetspeedRunData)rundata).getCustomizedProfile();
           String currentTitle = profile.getDocument().getEntryById(p.getID()).getTitle();
           if (currentTitle == null && p.getPortletConfig().getMetainfo() != null) 
           {
  @@ -180,21 +184,23 @@
       /** Clean up the customization state */
       public void doCancel(RunData rundata, Context context)
       {
  -        rundata.getSession().removeAttribute("parameters");
           ((JetspeedRunData)rundata).setCustomized(null);
           if (((JetspeedRunData)rundata).getCustomized()==null)
           {
  -            rundata.setScreenTemplate("Home");
  +            Customize.exit(rundata);
           }
       }
   
       /** Updates the customized portlet entry */
       public void doUpdate(RunData rundata, Context context)
       {
  +        // get the customization state for this page
  +        SessionState customizationState = ((JetspeedRunData)rundata).getPageSessionState();
  +
           // we should first retrieve the portlet to customize and its parameters
           // definition
           Portlet p = ((JetspeedRunData)rundata).getCustomized();
  -        List params = (List)rundata.getSession().getAttribute("parameters");
  +        Vector params = (Vector) customizationState.getAttribute("customize-parameters");
           String newSecurityParent = rundata.getParameters().getString("_security_ref");
           String newSkinName = (String) rundata.getParameters().getString("_skin");
           String newTitle = (String) rundata.getParameters().getString("current_title");
  @@ -209,7 +215,7 @@
               return;
           }
           PortletConfig pc = p.getPortletConfig();
  -        Profile profile = ((JetspeedRunData)rundata).getProfile();
  +        Profile profile = ((JetspeedRunData)rundata).getCustomizedProfile();
           Entry entry = profile.getDocument().getEntryById(p.getID());
   
           // Only update the security ref if the parent changed
  @@ -233,6 +239,10 @@
                       securityRef = new BaseSecurityReference();
                       securityRef.setParent( newSecurityParent);
                   }
  +                // Note: setting the portlet's config may not be a good idea -
  +                // it might be used as the Portlet for other PSMLDocument Entries that
  +                // have a different idea of security - and the caching of Portlets does
  +                // NOT include security -ggolden.
                   pc.setSecurityRef(securityRef);
                   entry.setSecurityRef(securityRef);
                   madePcChange = true;
  @@ -265,6 +275,10 @@
                       skin = PortalToolkit.getSkin(newSkinName);
                       if (skin != null)
                       {
  +                        // Note: setting the portlet's config may not be a good idea -
  +                        // it might be used as the Portlet for other PSMLDocument Entries that
  +                        // have a different idea of skin - and the caching of Portlets does
  +                        // NOT include skin -ggolden.
                           pc.setPortletSkin(skin);
                           
                           Skin psmlSkin = entry.getSkin();
  @@ -281,6 +295,10 @@
                   }
                   else
                   {
  +                    // Note: setting the portlet's config may not be a good idea -
  +                    // it might be used as the Portlet for other PSMLDocument Entries that
  +                    // have a different idea of skin - and the caching of Portlets does
  +                    // NOT include skin -ggolden.
                       pc.setPortletSkin( null);
                       entry.setSkin(null);
                   }
  @@ -312,6 +330,10 @@
   
                   if ((newTitle.trim().length() > 0))
                   {
  +                    // Note: setting the portlet's config may not be a good idea -
  +                    // it might be used as the Portlet for other PSMLDocument Entries that
  +                    // have a different idea of title - and the caching of Portlets does
  +                    // NOT include title -ggolden.
                       if (md == null) {
                           md = new MetaData();
                           pc.setMetainfo(md);
  @@ -350,7 +372,16 @@
                       if (!newValue.equals(p.getPortletConfig().getInitParameter(name)))
                       {
                           instance.setAttribute(name,newValue);
  -                        pc.setInitParameter(name,newValue);
  +                        // Note: setting the portlet's config *IS NOT* a good idea -
  +                        // it might be used as the Portlet for other PSMLDocument Entries that
  +                        // used to have the same parameters as this one (Portlets *ARE* cached on
  +                        // their parameters), so changing the parameters like this changes them for
  +                        // all and make the Portlet *NOT MATCH* the cache handle.
  +                        // It's ok not to do this here, since when this PSML is next rendered,
  +                        // it will look for a portlet with the new set of parameters, and will
  +                        // find / create a new one if needed - ggolden
  +
  +                        //pc.setInitParameter(name,newValue);
                           madePsChange = true;
                       }
                   }
  @@ -359,14 +390,10 @@
               // save all the changes
               if ((madePsChange == true) || (madePcChange == true))
               {
  -                try
  -                {
  -                    PersistenceManager.store(instance);
  -                }
  -                catch(PortalPersistenceException e)
  -                {
  -                    Log.error("Exception occured while saving instance",e);
  -                }
  +                // Note: no need to use the PersistenceManager's store(instance), which
  +                // ends up writing the modified PSMLDocument to the service: Customize.size()
  +                // takes care of this for us. -ggolden
  +                Customize.save(rundata);
               }
               //FIXME: this hack is due to the corrupted lifecycle of the portlet in the
               //current API when caching is activated
  
  
  
  1.31      +30 -39    jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/portlets/CustomizeSetAction.java
  
  Index: CustomizeSetAction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/portlets/CustomizeSetAction.java,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- CustomizeSetAction.java	23 Sep 2002 18:56:22 -0000	1.30
  +++ CustomizeSetAction.java	27 Sep 2002 17:02:20 -0000	1.31
  @@ -95,6 +95,7 @@
   import org.apache.jetspeed.util.PortletSessionState;
   import org.apache.jetspeed.util.template.JetspeedLink;
   import org.apache.jetspeed.util.template.JetspeedLinkFactory;
  +import org.apache.jetspeed.services.statemanager.SessionState;
   
   
   // Turbine stuff
  @@ -145,27 +146,16 @@
                                         Context context,
                                         RunData rundata) throws Exception
       {
  -    
  -       /**
  -        * Reload profile for customization (if necessary)
  -        * --------------------------------------------------------------------------
  -        * last modified: 12/10/01
  -        * Andreas Kempf, Siemens ICM S CP OP, Munich
  -        * mailto: A.Kempf@web.de
  -        */
  -        AutoProfile.doIt (rundata, true);
  -        
           JetspeedRunData jdata = (JetspeedRunData) rundata;
  -        Profile profile = jdata.getProfile();
  -        String mediaType = jdata.getProfile().getMediaType ();
  +        SessionState customizationState = jdata.getPageSessionState();
  +        Profile profile = jdata.getCustomizedProfile();
  +        String mediaType = profile.getMediaType ();
   
           // set velocity variable of mediatype (displayed in the customizer menu)
           context.put("mtype", profile.getMediaType());
   
           // make the list of already used panes/portlets available through the 'runs' reference
           context.put("runs", AutoProfile.getPortletList(rundata));
  -        // ---------------------------------------------------------------------
  -        
           
           // we should first retrieve the portlet to customize
           PortletSet set = (PortletSet) (jdata).getCustomized();
  @@ -174,7 +164,7 @@
           String mode = rundata.getParameters().getString("mode");
           if (mode == null)
           {
  -          mode = (String) rundata.getUser().getTemp("mode");
  +          mode = (String) customizationState.getAttribute("customize-mode");
             if ((mode == null) || (mode.equalsIgnoreCase("addset")) || (mode.equalsIgnoreCase("general")))
             {
               mode = "layout";
  @@ -188,7 +178,7 @@
               mode = "layout";
             }
   
  -          rundata.getUser().setTemp("mode", mode);
  +          customizationState.setAttribute("customize-mode", mode);
           }
   
           String template = (String) context.get("template");
  @@ -213,10 +203,12 @@
               return;
           }
   
  -
  +        // get the customization state for this page
  +        String customizedPaneName = (String) customizationState.getAttribute("customize-paneName");
  +        if (customizedPaneName == null) customizedPaneName = "*";
          
           // generic context stuff
  -        context.put("panename", (String) jdata.getSession().getAttribute ("customizedPaneName"));
  +        context.put("panename", customizedPaneName);
           context.put("skin", set.getPortletConfig().getPortletSkin());
           context.put("set", set);
           context.put("action", "portlets.CustomizeSetAction");        
  @@ -249,7 +241,7 @@
             {
               context.put("currentSkin", set.getPortletConfig().getPortletSkin().getName());
             }
  -          if (((String) jdata.getSession().getAttribute ("customizedPaneName")).equalsIgnoreCase("*"))
  +          if (customizedPaneName.equalsIgnoreCase("*"))
             {
               context.put("allowproperties", "false");
             }
  @@ -265,7 +257,7 @@
           // do not allow panes for wml profiles
           if ((!mediaType.equalsIgnoreCase("wml")) && (set.getController() instanceof PortletSetController))
           {
  -          if (((String) jdata.getSession().getAttribute ("customizedPaneName")).equalsIgnoreCase("*"))
  +          if (customizedPaneName.equalsIgnoreCase("*"))
             {
               context.put("allowpane", "true");
             }
  @@ -437,7 +429,8 @@
       {
           //((JetspeedRunData)rundata).setCustomized(null);
           //rundata.setScreenTemplate("Home");
  -        rundata.getUser().setTemp("mode", "layout");
  +        SessionState customizationState = ((JetspeedRunData)rundata).getPageSessionState();
  +        customizationState.setAttribute("customize-mode", "layout");
       }
   
       /** Save the general informations for this set */
  @@ -448,7 +441,7 @@
           doLayout(rundata, context);
           doSecurity(rundata, context);
           
  -        Profile profile = ((JetspeedRunData) rundata).getProfile();
  +        Profile profile = ((JetspeedRunData) rundata).getCustomizedProfile();
           try
           {
               String mtype = rundata.getParameters().getString("mtype");
  @@ -480,7 +473,7 @@
           
           if (set != null)
           {
  -            Portlets portlets = ((JetspeedRunData) rundata).getProfile()
  +            Portlets portlets = ((JetspeedRunData) rundata).getCustomizedProfile()
                                                              .getDocument()
                                                              .getPortletsById(set.getID());
               
  @@ -494,7 +487,8 @@
               }
           }
   
  -        rundata.getUser().setTemp("mode", "layout");
  +        SessionState customizationState = ((JetspeedRunData)rundata).getPageSessionState();
  +        customizationState.setAttribute("customize-mode", "layout");
       }
       
      public void doPrevious(RunData rundata, Context context) throws Exception
  @@ -607,8 +601,6 @@
            * mailto: A.Kempf@web.de
            */
           //boolean isWML = AutoProfile.doIt (rundata, true).getMediaType().equalsIgnoreCase("wml");
  -        AutoProfile.doIt (rundata, true);
  -
           PortletSet set = (PortletSet) ((JetspeedRunData) rundata).getCustomized();
           
           maintainUserSelections(rundata);
  @@ -624,7 +616,7 @@
           
           if ((pnames != null) && (set != null))
           {
  -            Portlets portlets = ((JetspeedRunData) rundata).getProfile()
  +            Portlets portlets = ((JetspeedRunData) rundata).getCustomizedProfile()
                                                              .getDocument()
                                                              .getPortletsById(set.getID());
   
  @@ -670,8 +662,8 @@
           }
           // --------------------------------------------------------------------------
   
  -
  -        rundata.getUser().setTemp("mode", "layout");
  +        SessionState customizationState = ((JetspeedRunData)rundata).getPageSessionState();
  +        customizationState.setAttribute("customize-mode", "layout");
   
           /** 
            * Save changed wml profile
  @@ -681,7 +673,7 @@
            * mailto: A.Kempf@web.de
           if (isWML)
           {
  -          ((JetspeedRunData)rundata).getProfile().store();
  +          ((JetspeedRunData)rundata).getCustomizedProfile().store();
             //rundata.save();
           }
            */
  @@ -691,8 +683,6 @@
       /** Add new Reference in the customized set */
       public void doAddref(RunData rundata, Context context) throws Exception
       {
  -        AutoProfile.doIt (rundata, true);
  -
           PortletSet set = (PortletSet) ((JetspeedRunData) rundata).getCustomized();
           String[] refNames = rundata.getParameters().getStrings("refname");
           
  @@ -703,7 +693,7 @@
           
           if ((refNames != null) && (set != null))
           {
  -            Portlets portlets = ((JetspeedRunData) rundata).getProfile()
  +            Portlets portlets = ((JetspeedRunData) rundata).getCustomizedProfile()
                                                              .getDocument()
                                                              .getPortletsById(set.getID());
   
  @@ -714,7 +704,8 @@
                 portlets.addReference(ref);
               }
           }
  -        rundata.getUser().setTemp("mode", "layout");
  +        SessionState customizationState = ((JetspeedRunData)rundata).getPageSessionState();
  +        customizationState.setAttribute("customize-mode", "layout");
       }
       
       /** Sets the metainfo for this entry */
  @@ -725,7 +716,7 @@
   
           if (set != null)
           {
  -            Portlets portlets = ((JetspeedRunData) rundata).getProfile()
  +            Portlets portlets = ((JetspeedRunData) rundata).getCustomizedProfile()
                                                              .getDocument()
                                                              .getPortletsById(set.getID());
               
  @@ -760,7 +751,7 @@
               
               if (controller != null)
               {
  -                Profile profile = ((JetspeedRunData) rundata).getProfile();
  +                Profile profile = ((JetspeedRunData) rundata).getCustomizedProfile();
                   PortletController pc = PortalToolkit.getController(controller);
   
                   if (pc != null)
  @@ -814,7 +805,7 @@
           try
           {            
               String skin = rundata.getParameters().getString("skin");
  -            Profile profile = ((JetspeedRunData) rundata).getProfile();
  +            Profile profile = ((JetspeedRunData) rundata).getCustomizedProfile();
               Portlets portlets = profile.getDocument().getPortletsById(set.getID());
               if ((skin != null) && (skin.trim().length() > 0))
               {
  @@ -868,7 +859,7 @@
           {            
               String securityRefName = rundata.getParameters().getString("securityRef");
               SecurityReference securityRef = null;
  -            Profile profile = ((JetspeedRunData) rundata).getProfile();
  +            Profile profile = ((JetspeedRunData) rundata).getCustomizedProfile();
               Portlets portlets = profile.getDocument().getPortletsById(set.getID());
   
               if ((securityRefName != null) && (securityRefName.trim().length() > 0))
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>