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 pa...@apache.org on 2002/06/30 07:23:19 UTC

cvs commit: jakarta-jetspeed/src/java/org/apache/jetspeed/services/portaltoolkit JetspeedPortalToolkitService.java

paulsp      2002/06/29 22:23:19

  Modified:    src/java/org/apache/jetspeed/services/portletfactory
                        JetspeedPortletFactoryService.java
               src/java/org/apache/jetspeed/modules/actions/portlets
                        CustomizeSetAction.java
               src/java/org/apache/jetspeed/portal PortletConfig.java
                        BasePortletConfig.java
               src/java/org/apache/jetspeed/modules/actions/controllers
                        MultiColumnControllerAction.java
               src/java/org/apache/jetspeed/modules/localization
                        JetspeedLocalization_en.properties
               webapp/WEB-INF/templates/vm/portlets/html
                        customizer-portletset-layout.vm
               webapp/WEB-INF/templates/vm/controllers/html
                        multicolumn-customize.vm
               src/java/org/apache/jetspeed/services/portaltoolkit
                        JetspeedPortalToolkitService.java
  Log:
  o Customizer
    o Now displays the skin from the PSML for portlet Sets
    o Now allows the Security ID (<security-ref parent=""> from the PSML to be
      edited for the portlet set
    o Now displays the skin from the PSML for each portlet
    o Now displays the Security ID (<security-ref parent=""> from the PSML for each portlet
  
  o The Getters/Setter and the SecurityRef field added to PortletConfig
  
  o SecurityRef is set when a PortletConfig is instanciated
  
  o Cleaned up some JavaDoc and imports
  
  Revision  Changes    Path
  1.13      +4 -2      jakarta-jetspeed/src/java/org/apache/jetspeed/services/portletfactory/JetspeedPortletFactoryService.java
  
  Index: JetspeedPortletFactoryService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/portletfactory/JetspeedPortletFactoryService.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- JetspeedPortletFactoryService.java	15 May 2002 14:54:20 -0000	1.12
  +++ JetspeedPortletFactoryService.java	30 Jun 2002 05:23:19 -0000	1.13
  @@ -152,7 +152,7 @@
           pc.getInitParameters().putAll(getParameters(entry));
           
           pc.setPortletSkin( PortalToolkit.getSkin( entry.getSkin() ) );
  -        
  +     
           return getPortlet( regEntry.getClassname(), pc, entry.getId() );
       }
   
  @@ -389,6 +389,8 @@
           pc.setMetainfo( getMetaData( entry ) );
           pc.setURL( entry.getURL() );
           pc.setCachedOnURL( entry.isCachedOnURL() );
  +        pc.setSecurityRef( entry.getSecurityRef());
  +
           if (runDataService != null)
           {
               JetspeedRunData rundata = runDataService.getCurrentRunData();
  
  
  
  1.18      +63 -15    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.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- CustomizeSetAction.java	28 Jun 2002 05:37:28 -0000	1.17
  +++ CustomizeSetAction.java	30 Jun 2002 05:23:19 -0000	1.18
  @@ -64,11 +64,14 @@
   import org.apache.jetspeed.services.PortalToolkit;
   import org.apache.jetspeed.services.TemplateLocator;
   import org.apache.jetspeed.services.rundata.JetspeedRunData;
  +import org.apache.jetspeed.om.BaseSecurityReference;
  +import org.apache.jetspeed.om.SecurityReference;
   import org.apache.jetspeed.om.profile.Profile;
   import org.apache.jetspeed.om.registry.RegistryEntry;
   import org.apache.jetspeed.om.registry.PortletEntry;
   import org.apache.jetspeed.om.registry.PortletInfoEntry;
   import org.apache.jetspeed.om.registry.MediaTypeEntry;
  +import org.apache.jetspeed.om.profile.Layout;
   import org.apache.jetspeed.om.profile.Portlets;
   import org.apache.jetspeed.om.profile.psml.PsmlPortlets;
   import org.apache.jetspeed.om.profile.Entry;
  @@ -85,22 +88,17 @@
   import org.apache.jetspeed.services.idgenerator.JetspeedIdGenerator;
   import org.apache.jetspeed.services.JetspeedSecurity;
   import org.apache.jetspeed.services.security.PortalResource;
  -
  -import org.apache.jetspeed.om.profile.Layout;
  -
   import org.apache.jetspeed.util.AutoProfile;
   
  -
   // Turbine stuff
   import org.apache.turbine.util.Log;
   import org.apache.turbine.util.RunData;
   import org.apache.turbine.services.template.TurbineTemplate;
  -//import org.apache.turbine.services.uniqueid.TurbineUniqueId;
  -
   
   // Velocity Stuff
   import org.apache.velocity.context.Context;
   
  +// Java imports
   import java.util.ArrayList;
   import java.util.Vector;
   import java.util.List;
  @@ -173,8 +171,6 @@
             rundata.getUser().setTemp("mode",mode);
           }
   
  -        System.out.println("In CustomizeSetAction.buildNormalContext(), Mode = " + mode);  
  -        
           String template = (String)context.get("template");
   
           if (template!=null)
  @@ -202,10 +198,12 @@
           context.put("action","portlets.CustomizeSetAction");        
           context.put("controllers", buildInfoList(rundata, Registry.PORTLET_CONTROLLER, mediaType));
           context.put("skins", buildList(rundata, Registry.SKIN));
  +        context.put("securitys", buildList(rundata, Registry.SECURITY));
       
           String CtrlName = set.getController().getConfig().getName();
           context.put("currentController", CtrlName);
   
  +        context.put("currentSecurityRef", set.getPortletConfig().getSecurityRef());
   
          /** 
           * Special handling for wml profiles
  @@ -223,7 +221,8 @@
           }
           else
           {
  -          context.put("currentSkin", set.getPortletConfig().getPortletSkin().getName());
  +          if (set.getPortletConfig().getSkin() != null)
  +            context.put("currentSkin", set.getPortletConfig().getPortletSkin().getName());
             if (((String) jdata.getSession().getAttribute ("customizedPaneName")).equalsIgnoreCase("*"))
               context.put("allowproperties", "false");
             else  
  @@ -300,6 +299,7 @@
           doMetainfo(rundata,context);
           doSkin(rundata,context);
           doLayout(rundata,context);
  +        doSecurity(rundata,context);
           
           Profile profile = ((JetspeedRunData)rundata).getProfile();
           try
  @@ -514,7 +514,12 @@
           
       }
   
  -    /** Updates the customized portlet entry */
  +    /**
  +     * Set the skin in the PSML and the current PortletConfig
  +     * using the HTML parameter "skin".  If the parmeter is
  +     * missing or 'blank', then the skin is set to null.
  +     *
  +     */
       public void doSkin(RunData rundata, Context context)
       {
           // we should first retrieve the portlet to customize and its parameters
  @@ -524,8 +529,9 @@
           try
           {            
               String skin = rundata.getParameters().getString("skin");
  -            
  -            if (skin!=null)
  +            Profile profile = ((JetspeedRunData)rundata).getProfile();
  +            Portlets portlets = profile.getDocument().getPortletsById(set.getID());
  +            if ((skin!=null) && (skin.trim().length() > 0))
               {
                   PortletSkin s = PortalToolkit.getSkin(skin);
   
  @@ -533,9 +539,6 @@
                   {
                       set.getPortletConfig().setPortletSkin(s);
   
  -                    Profile profile = ((JetspeedRunData)rundata).getProfile();
  -                    Portlets portlets = profile.getDocument().getPortletsById(set.getID());
  -
                       Skin psmlSkin = portlets.getSkin();
                       if (psmlSkin == null)
                       {
  @@ -543,7 +546,52 @@
                       }
                       portlets.getSkin().setName(skin);
                   }
  +                else
  +                {
  +                    Log.warn( "Unable to update skin for portlet set " + set.getID() + " because skin " + skin + " does not exist.");
  +                    return;
  +                }
  +            }
  +            else
  +            {
  +                // By setting the skin to null, the parent's skin will be used.
  +                set.getPortletConfig().setPortletSkin( (PortletSkin) null);
  +                portlets.setSkin( null);
  +            }
  +
  +        }
  +        catch (Exception e)
  +        {
  +            Log.error(e);
  +        }        
  +    }
  +    
  +    /**
  +     * Set the SecuirtyRef in the PSML and the current PortletConfig
  +     * using the HTML parameter "securityRef".  If the parmeter is
  +     * missing or 'blank', then the SecuriyReference is set to null.
  +     *
  +     */
  +    public void doSecurity(RunData rundata, Context context)
  +    {
  +        // we should first retrieve the portlet to customize and its parameters
  +        // definition
  +        PortletSet set = (PortletSet)((JetspeedRunData)rundata).getCustomized();
  +        
  +        try
  +        {            
  +            String securityRefName = rundata.getParameters().getString("securityRef");
  +            SecurityReference securityRef = null;
  +            Profile profile = ((JetspeedRunData)rundata).getProfile();
  +            Portlets portlets = profile.getDocument().getPortletsById(set.getID());
  +
  +            if ((securityRefName !=null) && (securityRefName.trim().length() > 0))
  +            {
  +                securityRef = new BaseSecurityReference();
  +                securityRef.setParent( securityRefName);
               }
  +            set.getPortletConfig().setSecurityRef(securityRef);
  +            portlets.setSecurityRef(securityRef);
           }
           catch (Exception e)
           {
  
  
  
  1.49      +30 -9     jakarta-jetspeed/src/java/org/apache/jetspeed/portal/PortletConfig.java
  
  Index: PortletConfig.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/PortletConfig.java,v
  retrieving revision 1.48
  retrieving revision 1.49
  diff -u -r1.48 -r1.49
  --- PortletConfig.java	14 May 2002 06:32:58 -0000	1.48
  +++ PortletConfig.java	30 Jun 2002 05:23:19 -0000	1.49
  @@ -58,9 +58,10 @@
   import java.util.Map;
   
   //jetspeed support
  +import org.apache.jetspeed.capability.CapabilityMap;
  +import org.apache.jetspeed.om.SecurityReference;
   import org.apache.jetspeed.util.Config;
   import org.apache.jetspeed.util.MetaData;
  -import org.apache.jetspeed.capability.CapabilityMap;
   
   /**
   Defines a configuration for Portlets.  A PortletConfig provides information
  @@ -98,14 +99,19 @@
       */
       public void setLayout(Map constraints);
   
  -     /**
  -    Returns the portlet current PortletSet
  -    */
  +    /**
  +     * Returns the current skin mapping.  This method is used for configuration.  Use
  +     * getPortletSkin() to find skin use by the Layout engine.
  +     *
  +     * @return Current skin mapping or null if no skin is defined in PSML.
  +     */
       public Map getSkin();
   
       /**
  -    Set the context (PortletSet) for this portlet
  -    */
  +     * Set the context (PortletSet) for this portlet
  +     *
  +     * @deprecated use setPortletSkin instead
  +     */
       public void setSkin(Map skin);
   
       /**
  @@ -189,9 +195,14 @@
       public void setSkin(String name, String value);
   
       /**
  -     * Retrieves the Skin object that should be used for this portlet
  +     * Retrieves the Skin object that should be used for this portlet. If 
  +     * the current portlet does not have a skin, then skin is retrieve from
  +     * the parent portlet set of the system default is now skins are defined
  +     * in the portlet set.
  +     *
  +     * getSkin() can be used for configuration.
        *
  -     * @return the Skin object that should be used
  +     * @return the Skin object that should be used.
        */
       public PortletSkin getPortletSkin();
       
  @@ -229,5 +240,15 @@
       public String getPortletId();
       public void setPageId(String pageId);
       public String getPageId();
  +    
  +    /** Getter for property securityRef.
  +     * @return Value of property securityRef.
  +     */
  +    public SecurityReference getSecurityRef();
  +    
  +    /** Setter for property securityRef.
  +     * @param securityRef New value of property securityRef.
  +     */
  +    public void setSecurityRef(SecurityReference securityRef);
       
   }
  
  
  
  1.10      +41 -15    jakarta-jetspeed/src/java/org/apache/jetspeed/portal/BasePortletConfig.java
  
  Index: BasePortletConfig.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/BasePortletConfig.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- BasePortletConfig.java	14 May 2002 06:32:58 -0000	1.9
  +++ BasePortletConfig.java	30 Jun 2002 05:23:19 -0000	1.10
  @@ -55,16 +55,17 @@
   package org.apache.jetspeed.portal;
   
   //standard java stuff
  -import java.net.*;
  -import java.util.*;
  +import java.util.Hashtable;
  +import java.util.Map;
   
   //turbine support
  -import org.apache.turbine.util.*;
   import org.apache.turbine.services.servlet.TurbineServlet;
   
   //jetspeed support
  -import org.apache.jetspeed.util.*;
  -import org.apache.jetspeed.capability.*;
  +import org.apache.jetspeed.capability.CapabilityMap;
  +import org.apache.jetspeed.om.SecurityReference;
  +import org.apache.jetspeed.util.BaseConfig;
  +import org.apache.jetspeed.util.MetaData;
   
   /**
    * Defines a configuration for Portlets.  A PortletConfig provides information
  @@ -86,6 +87,7 @@
       private boolean cachedOnURL = true;
       private String pageId;
       private String portletId;
  +    private SecurityReference securityRef = null;
   
       /**
       Init this PortletConfig providing the basic info.
  @@ -138,19 +140,22 @@
           //obsolete
       }
   
  -     /**
  -    Returns the portlet current PortletSet
  -     @deprecated use getSkin instead
  -    */
  +    /**
  +     * Returns the current skin mapping.  This method is used for configuration.  Use
  +     * getPortletSkin() to find skin use by the Layout engine.
  +     *
  +     * @return Current skin mapping or null if no skin is defined in PSML.
  +     */
       public Map getSkin()
       {
           return this.skin;
       }
   
       /**
  -     Set the context (PortletSet) for this portlet
  -     @deprecated use setPortletSkin instead
  -    */
  +     * Set the context (PortletSet) for this portlet
  +     *
  +     * @deprecated use setPortletSkin instead
  +     */
       public void setSkin(Map skin)
       {
           //obsolete
  @@ -309,9 +314,14 @@
       }
   
       /**
  -     * Retrieves the Skin object that should be used for this portlet
  +     * Retrieves the Skin object that should be used for this portlet. If 
  +     * the current portlet does not have a skin, then skin is retrieve from
  +     * the parent portlet set of the system default is now skins are defined
  +     * in the portlet set.
        *
  -     * @return the Skin object that should be used
  +     * getSkin() can be used for configuration.
  +     *
  +     * @return the Skin object that should be used.
        */
       public PortletSkin getPortletSkin()
       { 
  @@ -388,4 +398,20 @@
           return this.portletId;
       }
   
  +    /** Getter for property securityRef.
  +     * @return Value of property securityRef.
  +     */
  +    public SecurityReference getSecurityRef()
  +    {
  +        return this.securityRef;
  +    }
  +    
  +    /** Setter for property securityRef.
  +     * @param securityRef New value of property securityRef.
  +     */
  +    public void setSecurityRef(SecurityReference securityRef)
  +    {
  +        this.securityRef = securityRef;
  +    }
  +    
   }
  
  
  
  1.12      +1 -1      jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/controllers/MultiColumnControllerAction.java
  
  Index: MultiColumnControllerAction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/controllers/MultiColumnControllerAction.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- MultiColumnControllerAction.java	14 Apr 2002 16:49:09 -0000	1.11
  +++ MultiColumnControllerAction.java	30 Jun 2002 05:23:19 -0000	1.12
  @@ -369,7 +369,7 @@
       public void doSave(RunData data, Context context)
       {
           Profile profile = ((JetspeedRunData)data).getProfile();
  -
  +System.out.println("In " + this.getClass().getName() + ".doSave()");
           List[] columns = (List[])data.getUser().getTemp("columns");
   
           for (int col=0; col < columns.length; col++)
  
  
  
  1.17      +1 -0      jakarta-jetspeed/src/java/org/apache/jetspeed/modules/localization/JetspeedLocalization_en.properties
  
  Index: JetspeedLocalization_en.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/modules/localization/JetspeedLocalization_en.properties,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- JetspeedLocalization_en.properties	4 Jun 2002 14:58:25 -0000	1.16
  +++ JetspeedLocalization_en.properties	30 Jun 2002 05:23:19 -0000	1.17
  @@ -166,6 +166,7 @@
   CUSTOMIZER_SAVEAPPLY=Save and Apply
   CUSTOMIZER_SELECTE=Select
   CUSTOMIZER_SELECTEDPANE=Selected Pane
  +CUSTOMIZER_SECURITY_REF=Security ID
   CUSTOMIZER_SKIN=Skin
   CUSTOMIZER_TITLE=Title
   CUSTOMIZER_TYPE=Type
  
  
  
  1.7       +31 -0     jakarta-jetspeed/webapp/WEB-INF/templates/vm/portlets/html/customizer-portletset-layout.vm
  
  Index: customizer-portletset-layout.vm
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/webapp/WEB-INF/templates/vm/portlets/html/customizer-portletset-layout.vm,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- customizer-portletset-layout.vm	7 May 2002 14:17:06 -0000	1.6
  +++ customizer-portletset-layout.vm	30 Jun 2002 05:23:19 -0000	1.7
  @@ -72,6 +72,7 @@
           #else
             <select name="skin" onChange="document.skins.submit()">
           #end      
  +          <option value="">-- Default--
           #foreach ($skin in $skins)
             <option value="$skin.Name" #if ($skin.Name == $currentSkin) SELECTED #end>
              #if ($skin.Title) $skin.Title #else $skin.Name #end
  @@ -88,6 +89,36 @@
         </td>
         #end
         <td>&nbsp;</td>
  +      #if ($securitys)
  +      <td>&nbsp;</td>
  +      <td valign="middle">
  +        $l10n.CUSTOMIZER_SECURITY_REF :
  +      </td>
  +      <td valign="middle">
  +        <form name="securityRefs" action="$jslink.Template" method="post">
  +        #if ($action) <input name="$jslink.ActionKey" type="hidden" value="$action" > #end
  +        <input type="hidden" name="eventSubmit_doSecurity" value="securityRef">        ## No Controller-Selection for WML Profiles
  +        #if (($!mtype=="wml") || ($!mtype=="WML"))
  +          <select name="securityRef" onChange="document.securityRefs.submit()" disabled>
  +        #else
  +          <select name="securityRef" onChange="document.securityRefs.submit()">
  +        #end      
  +          <option value="">-- Default--
  +        #foreach ($security in $securitys)
  +          <option value="$security.Name" #if ($security.Name == $currentSecurityRef.Parent) SELECTED #end>
  +           #if ($security.Title) $security.Title #else $security.Name #end
  +        #end
  +        </select>
  +
  +        ## No submit-Button for WML Profiles
  +        #if (($!mtype=="wml") || ($!mtype=="WML"))
  +##        <input type="submit" value="OK" disabled>
  +        #else
  +##        <input type="submit" value="OK">
  +        #end
  +        </form>
  +      </td>
  +      #end
       </tr>
     </table>
   </center>
  
  
  
  1.10      +37 -0     jakarta-jetspeed/webapp/WEB-INF/templates/vm/controllers/html/multicolumn-customize.vm
  
  Index: multicolumn-customize.vm
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/webapp/WEB-INF/templates/vm/controllers/html/multicolumn-customize.vm,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- multicolumn-customize.vm	7 May 2002 14:17:06 -0000	1.9
  +++ multicolumn-customize.vm	30 Jun 2002 05:23:19 -0000	1.10
  @@ -61,6 +61,43 @@
                   <b>$title</b>
                 </td>
               </tr>
  +            <tr>
  +## Set $portletSkin.  If no skin exists for the portlet, then set to "-- Default --"
  +#if ($portlet.Skin)
  +  #set ($tempSkin = $portlet.Skin)
  +  #if ($tempSkin)
  +    #set ($portletSkin = $tempSkin.Name)
  +  #else
  +    #set ($portletSkin = "-- Default --")
  +  #end
  +#else
  +  #set ($portletSkin = "-- Default --")
  +#end
  +
  +## Set $portletSecurityRef.  If no Security Reference exists for the portlet, then set to "-- Default --"
  +#if ($portlet.SecurityRef)
  +  #set ($tempSecurityRef = $portlet.SecurityRef)
  +  #if ($tempSecurityRef)
  +    #set ($portletSecurityRef = $tempSecurityRef.Parent)
  +  #else
  +    #set ($portletSecurityRef = "-- Default --")
  +  #end
  +#else
  +  #set ($portletSecurityRef = "-- Default --")
  +#end
  +              <td#if(${skin.ContentStyleClass}) class="${skin.ContentStyleClass}" #end #if(${skin.BackgroundColor}) style="background-color: ${skin.BackgroundColor}" #end align="center">
  +                <table width="100%">
  +                  <tr>
  +                    <td width="50%">
  +                      $l10n.CUSTOMIZER_SKIN : $portletSkin
  +                    </td>
  +                    <td width="50%">
  +                       $l10n.CUSTOMIZER_SECURITY_REF : $portletSecurityRef
  +                    </td>
  +                  </tr>
  +                </table>
  +              </td>
  +            </tr>
             </table>
             </td></tr>
             </table>
  
  
  
  1.21      +2 -1      jakarta-jetspeed/src/java/org/apache/jetspeed/services/portaltoolkit/JetspeedPortalToolkitService.java
  
  Index: JetspeedPortalToolkitService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/portaltoolkit/JetspeedPortalToolkitService.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- JetspeedPortalToolkitService.java	13 May 2002 00:57:16 -0000	1.20
  +++ JetspeedPortalToolkitService.java	30 Jun 2002 05:23:19 -0000	1.21
  @@ -509,6 +509,7 @@
               pc.setPortletSkin( getSkin( portlets.getSkin() ) );
           }
           
  +        pc.setSecurityRef( portlets.getSecurityRef() );
           pc.setMetainfo( getMetaData( portlets ) );
           
           return pc;
  
  
  

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