portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From morci...@apache.org
Subject cvs commit: jakarta-jetspeed/webapp/WEB-INF/templates/vm/portlets/html customizer-portletset-addref.vm
Date Tue, 10 May 2005 19:28:18 GMT
morciuch    2005/05/10 12:28:18

  Modified:    src/java/org/apache/jetspeed/modules/actions/portlets
                        CustomizeSetAction.java
               webapp/WEB-INF/templates/vm/portlets/html
                        customizer-portletset-addref.vm
  Log:
  Filtering for portlet set customizer reference selection (see issue http://issues.apache.org/jira/browse/JS1-544)
  
  Revision  Changes    Path
  1.53      +743 -518  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.52
  retrieving revision 1.53
  diff -u -r1.52 -r1.53
  --- CustomizeSetAction.java	21 Mar 2005 18:21:36 -0000	1.52
  +++ CustomizeSetAction.java	10 May 2005 19:28:17 -0000	1.53
  @@ -13,79 +13,76 @@
    * See the License for the specific language governing permissions and
    * limitations under the License.
    */
  - 
  +
   package org.apache.jetspeed.modules.actions.portlets;
   
   // Jetspeed imports
  -import org.apache.jetspeed.portal.PortletSet;
  -import org.apache.jetspeed.portal.PortletSkin;
  -import org.apache.jetspeed.portal.PortletController;
  -import org.apache.jetspeed.portal.PortletSetController;
  -import org.apache.jetspeed.portal.portlets.VelocityPortlet;
  -import org.apache.jetspeed.services.Profiler;
  -import org.apache.jetspeed.services.Registry;
  -import org.apache.jetspeed.services.PortalToolkit;
  -import org.apache.jetspeed.services.TemplateLocator;
  -import org.apache.jetspeed.services.rundata.JetspeedRunData;
  +import java.text.MessageFormat;
  +import java.util.ArrayList;
  +import java.util.Collections;
  +import java.util.Comparator;
  +import java.util.HashMap;
  +import java.util.Iterator;
  +import java.util.LinkedList;
  +import java.util.List;
  +import java.util.Map;
  +import java.util.TreeMap;
  +
  +import org.apache.commons.lang.StringUtils;
   import org.apache.jetspeed.om.BaseSecurityReference;
   import org.apache.jetspeed.om.SecurityReference;
  +import org.apache.jetspeed.om.profile.Control;
  +import org.apache.jetspeed.om.profile.Controller;
  +import org.apache.jetspeed.om.profile.Entry;
  +import org.apache.jetspeed.om.profile.MetaInfo;
  +import org.apache.jetspeed.om.profile.PSMLDocument;
  +import org.apache.jetspeed.om.profile.Portlets;
   import org.apache.jetspeed.om.profile.Profile;
  -import org.apache.jetspeed.om.profile.ProfileLocator;
   import org.apache.jetspeed.om.profile.ProfileException;
  +import org.apache.jetspeed.om.profile.ProfileLocator;
   import org.apache.jetspeed.om.profile.QueryLocator;
  -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.base.BaseCategory;
  -import org.apache.jetspeed.om.profile.Portlets;
  -import org.apache.jetspeed.om.profile.psml.PsmlPortlets;
  -import org.apache.jetspeed.om.profile.Entry;
  -import org.apache.jetspeed.om.profile.psml.PsmlEntry;
   import org.apache.jetspeed.om.profile.Reference;
  -import org.apache.jetspeed.om.profile.psml.PsmlReference;
   import org.apache.jetspeed.om.profile.Skin;
  -import org.apache.jetspeed.om.profile.psml.PsmlSkin;
  -import org.apache.jetspeed.om.profile.MetaInfo;
  -import org.apache.jetspeed.om.profile.psml.PsmlMetaInfo;
  -import org.apache.jetspeed.om.profile.Controller;
  -import org.apache.jetspeed.om.profile.psml.PsmlController;
  -import org.apache.jetspeed.om.profile.Control;
   import org.apache.jetspeed.om.profile.psml.PsmlControl;
  -import org.apache.jetspeed.om.profile.PSMLDocument;
  +import org.apache.jetspeed.om.profile.psml.PsmlController;
  +import org.apache.jetspeed.om.profile.psml.PsmlEntry;
  +import org.apache.jetspeed.om.profile.psml.PsmlMetaInfo;
  +import org.apache.jetspeed.om.profile.psml.PsmlPortlets;
  +import org.apache.jetspeed.om.profile.psml.PsmlReference;
  +import org.apache.jetspeed.om.profile.psml.PsmlSkin;
  +import org.apache.jetspeed.om.registry.PortletEntry;
  +import org.apache.jetspeed.om.registry.PortletInfoEntry;
  +import org.apache.jetspeed.om.registry.RegistryEntry;
  +import org.apache.jetspeed.om.registry.base.BaseCategory;
  +import org.apache.jetspeed.om.security.Group;
   import org.apache.jetspeed.om.security.JetspeedUser;
  +import org.apache.jetspeed.om.security.Role;
  +import org.apache.jetspeed.portal.PortletController;
  +import org.apache.jetspeed.portal.PortletSet;
  +import org.apache.jetspeed.portal.PortletSetController;
  +import org.apache.jetspeed.portal.PortletSkin;
  +import org.apache.jetspeed.portal.portlets.VelocityPortlet;
  +import org.apache.jetspeed.services.JetspeedSecurity;
  +import org.apache.jetspeed.services.PortalToolkit;
  +import org.apache.jetspeed.services.Profiler;
  +import org.apache.jetspeed.services.Registry;
  +import org.apache.jetspeed.services.TemplateLocator;
   import org.apache.jetspeed.services.customlocalization.CustomLocalization;
   import org.apache.jetspeed.services.idgenerator.JetspeedIdGenerator;
  -import org.apache.jetspeed.services.JetspeedSecurity;
   import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
   import org.apache.jetspeed.services.logging.JetspeedLogger;
  +import org.apache.jetspeed.services.resources.JetspeedResources;
  +import org.apache.jetspeed.services.rundata.JetspeedRunData;
   import org.apache.jetspeed.services.security.PortalResource;
  +import org.apache.jetspeed.services.statemanager.SessionState;
   import org.apache.jetspeed.util.AutoProfile;
   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;
  -import org.apache.jetspeed.services.resources.JetspeedResources;
  -
  -// Turbine stuff
   import org.apache.turbine.util.DynamicURI;
   import org.apache.turbine.util.RunData;
  -
  -
  -// Velocity Stuff
   import org.apache.velocity.context.Context;
   
  -// Java imports
  -import java.util.ArrayList;
  -import java.util.Map;
  -import java.util.HashMap;
  -import java.util.TreeMap;
  -import java.util.LinkedList;
  -import java.util.List;
  -import java.util.Iterator;
  -import java.util.Collections;
  -import java.util.Comparator;
  -import java.text.MessageFormat;
  -
   /**
    * This action implements the default portletset behavior customizer 
    * 
  @@ -98,40 +95,49 @@
   public class CustomizeSetAction extends VelocityPortletAction
   {
   
  -    private static final String USER_SELECTIONS = "session.portlets.user.selections";
  +    private static final String USER_SELECTIONS =
  +        "session.portlets.user.selections";
       private static final String UI_PORTLETS_SELECTED = "portletsSelected";
       private static final String PORTLET_LIST = "session.portlets.list";
       private static final String ALL_PORTLET_LIST = "session.all.portlets.list";
  -    private static final String PORTLET_LIST_PAGE_SIZE = "session.portlets.page.size";
  -    private static final String HIDE_EMPTY_CATEGORIES = "customizer.hide.empty.categories";
  -    
  +    private static final String PORTLET_LIST_PAGE_SIZE =
  +        "session.portlets.page.size";
  +    private static final String HIDE_EMPTY_CATEGORIES =
  +        "customizer.hide.empty.categories";
  +
       public static final String FILTER_FIELDS = "filter_fields";
       public static final String FILTER_VALUES = "filter_values";
   
  +	public static final String FILTER_TYPE = "filter_type";
  +	public static final String FILTER_VALUE = "filter_value";
  +
       /**
        * Static initialization of the logger for this class
  -     */    
  -    private static final JetspeedLogger logger = JetspeedLogFactoryService.getLogger(CustomizeSetAction.class.getName());    
  -    
  +     */
  +    private static final JetspeedLogger logger =
  +        JetspeedLogFactoryService.getLogger(CustomizeSetAction.class.getName());
  +
       /** 
        * Subclasses must override this method to provide default behavior 
        * for the portlet action
        */
  -    protected void buildNormalContext(VelocityPortlet portlet, 
  -                                      Context context,
  -                                      RunData rundata) throws Exception
  +    protected void buildNormalContext(
  +        VelocityPortlet portlet,
  +        Context context,
  +        RunData rundata)
  +        throws Exception
       {
           JetspeedRunData jdata = (JetspeedRunData) rundata;
           SessionState customizationState = jdata.getPageSessionState();
           Profile profile = jdata.getCustomizedProfile();
  -        String mediaType = profile.getMediaType ();
  +        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();
   
  @@ -139,21 +145,24 @@
           String mode = rundata.getParameters().getString("mode");
           if (mode == null)
           {
  -          mode = (String) customizationState.getAttribute("customize-mode");
  -          if ((mode == null) || (mode.equalsIgnoreCase("addset")) || (mode.equalsIgnoreCase("general")))
  -          {
  -            mode = "layout";
  -          }
  -          
  +            mode = (String) customizationState.getAttribute("customize-mode");
  +            if ((mode == null)
  +                || (mode.equalsIgnoreCase("addset"))
  +                || (mode.equalsIgnoreCase("general")))
  +            {
  +                mode = "layout";
  +            }
  +
           }
           else
           {
  -          if ((mediaType.equalsIgnoreCase("wml")) && (!mode.equalsIgnoreCase("add")))
  -          {
  -            mode = "layout";
  -          }
  +            if ((mediaType.equalsIgnoreCase("wml"))
  +                && (!mode.equalsIgnoreCase("add")))
  +            {
  +                mode = "layout";
  +            }
   
  -          customizationState.setAttribute("customize-mode", mode);
  +            customizationState.setAttribute("customize-mode", mode);
           }
   
           String template = (String) context.get("template");
  @@ -161,28 +170,32 @@
           if (template != null)
           {
               int idx = template.lastIndexOf(".");
  -            
  +
               if (idx > 0)
               {
                   template = template.substring(0, idx);
               }
  -            
  +
               StringBuffer buffer = new StringBuffer(template);
               buffer.append("-").append(mode).append(".vm");
  -            
  -            template = TemplateLocator.locatePortletTemplate(rundata, buffer.toString());
  +
  +            template =
  +                TemplateLocator.locatePortletTemplate(
  +                    rundata,
  +                    buffer.toString());
               context.put("feature", template);
   
           }
  -    
  +
           if (set == null)
           {
               return;
           }
   
           // get the customization state for this page
  -        String customizedPaneName = (String) customizationState.getAttribute("customize-paneName");
  -        if (customizedPaneName == null) 
  +        String customizedPaneName =
  +            (String) customizationState.getAttribute("customize-paneName");
  +        if (customizedPaneName == null)
           {
               customizedPaneName = "*";
           }
  @@ -191,58 +204,62 @@
           context.put("panename", customizedPaneName);
           context.put("skin", set.getPortletConfig().getPortletSkin());
           context.put("set", set);
  -        context.put("action", "portlets.CustomizeSetAction");        
  -        context.put("controllers", buildInfoList(rundata, Registry.PORTLET_CONTROLLER, mediaType));
  +        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));
           context.put("customizer", portlet);
  -    
  +
           String controllerName = set.getController().getConfig().getName();
           context.put("currentController", controllerName);
   
  -        context.put("currentSecurityRef", set.getPortletConfig().getSecurityRef());
  +        context.put(
  +            "currentSecurityRef",
  +            set.getPortletConfig().getSecurityRef());
   
  -       /** 
  -        * Special handling for wml profiles
  -        * no skins, no properties menuentry, no panes 
  -        * --------------------------------------------------------------------------
  -        * last modified: 12/10/01
  -        * Andreas Kempf, Siemens ICM S CP OP, Munich
  -        * mailto: A.Kempf@web.de
  -        */
  +        /** 
  +         * Special handling for wml profiles
  +         * no skins, no properties menuentry, no panes 
  +         * --------------------------------------------------------------------------
  +         * last modified: 12/10/01
  +         * Andreas Kempf, Siemens ICM S CP OP, Munich
  +         * mailto: A.Kempf@web.de
  +         */
   
           if (mediaType.equalsIgnoreCase("wml"))
           {
  -          context.put("currentSkin", "Not for wml!");
  -          context.put("allowproperties", "false");
  +            context.put("currentSkin", "Not for wml!");
  +            context.put("allowproperties", "false");
           }
           else
           {
  -          if (set.getPortletConfig().getSkin() != null)
  -          {
  -            context.put("currentSkin", set.getPortletConfig().getPortletSkin().getName());
  -          }
  -          context.put("allowproperties", "true");
  +            if (set.getPortletConfig().getSkin() != null)
  +            {
  +                context.put(
  +                    "currentSkin",
  +                    set.getPortletConfig().getPortletSkin().getName());
  +            }
  +            context.put("allowproperties", "true");
           }
   
  -
           context.put("allowpane", "false");
  -        
  +
           // do not allow panes for wml profiles
  -        if ((!mediaType.equalsIgnoreCase("wml")) && (set.getController() instanceof PortletSetController))
  +        if ((!mediaType.equalsIgnoreCase("wml"))
  +            && (set.getController() instanceof PortletSetController))
           {
  -          if (customizedPaneName != null)
  -          {
  -            context.put("allowpane", "true");
  -          }
  +            if (customizedPaneName != null)
  +            {
  +                context.put("allowpane", "true");
  +            }
           }
           else
           {
               context.put("allowportlet", "true");
           }
           // --------------------------------------------------------------------------
  -            
  -
   
           if ("add".equals(mode)) // build context for add mode
           {
  @@ -254,45 +271,121 @@
                   PortletSessionState.clearAttribute(rundata, USER_SELECTIONS);
                   PortletSessionState.clearAttribute(rundata, PORTLET_LIST);
               }
  -            
  +
               ArrayList allPortlets = new ArrayList();
  -            List portlets  = buildPortletList(rundata, set, mediaType, allPortlets);
  -            Map userSelections = getUserSelections(rundata); 
  +            List portlets =
  +                buildPortletList(rundata, set, mediaType, allPortlets);
  +            Map userSelections = getUserSelections(rundata);
               // Build a list of categories from the available portlets
  -            List categories = buildCategoryList(rundata, mediaType, allPortlets);
  +            List categories =
  +                buildCategoryList(rundata, mediaType, allPortlets);
               context.put("categories", categories);
  -            
  +
               context.put("parents", PortletFilter.buildParentList(allPortlets));
               addFiltersToContext(rundata, context);
  -            
  -            int size = getSize(portlet);               
  +
  +            int size = getSize(portlet);
               int end = Math.min(start + size, portlets.size());
  -                
  +
               if (start > 0)
               {
                   context.put("prev", String.valueOf(Math.max(start - size, 0)));
               }
  -                
  +
               if (start + size < portlets.size())
               {
                   context.put("next", String.valueOf(start + size));
               }
  -                
  +
               context.put("browser", portlets.subList(start, end));
               context.put("size", new Integer(size));
               context.put(UI_PORTLETS_SELECTED, userSelections);
  -            
  -			context.put("portlets", portlets);
  +
  +            context.put("portlets", portlets);
           }
           else if ("addref".equals(mode))
           {
  +            //String filterType = rundata.getParameters().getString("filter_type");
  +            //String filterValue = rundata.getParameters().getString("filter_value");
  +            String filterType =
  +                (String) PortletSessionState.getAttributeWithFallback(
  +                    portlet,
  +                    rundata,
  +                    FILTER_TYPE);
  +            String filterValue =
  +                (String) PortletSessionState.getAttributeWithFallback(
  +                    portlet,
  +                    rundata,
  +                    FILTER_VALUE);
  +
               Iterator psmlIterator = null;
  -            psmlIterator = Profiler.query(new QueryLocator(QueryLocator.QUERY_ALL));
  -            
  +            if (StringUtils.isEmpty(filterType)
  +                || StringUtils.isEmpty(filterValue))
  +            {
  +                psmlIterator =
  +                    Profiler.query(new QueryLocator(QueryLocator.QUERY_ALL));
  +            }
  +            else
  +            {
  +                PortletSessionState.setAttribute(
  +                    portlet,
  +                    rundata,
  +                    FILTER_TYPE,
  +                    filterType);
  +				PortletSessionState.setAttribute(
  +					portlet,
  +					rundata,
  +					FILTER_VALUE,
  +					filterValue);
  +				context.put(FILTER_TYPE, filterType);
  +				context.put(FILTER_VALUE, filterValue);
  +				
  +                QueryLocator ql = null;
  +                if (filterType.equalsIgnoreCase("filter_type_user"))
  +                {
  +                    try
  +                    {
  +                        JetspeedUser user =
  +                            JetspeedSecurity.getUser(filterValue);
  +                        ql = new QueryLocator(QueryLocator.QUERY_USER);
  +                        ql.setUser(user);
  +                        psmlIterator = Profiler.query(ql);
  +                    }
  +                    catch (Exception e)
  +                    {
  +                    }
  +                }
  +                else if (filterType.equalsIgnoreCase("filter_type_role"))
  +                {
  +                    try
  +                    {
  +                        Role role = JetspeedSecurity.getRole(filterValue);
  +                        ql = new QueryLocator(QueryLocator.QUERY_ROLE);
  +                        ql.setRole(role);
  +                        psmlIterator = Profiler.query(ql);
  +                    }
  +                    catch (Exception e)
  +                    {
  +                    }
  +                }
  +                else if (filterType.equalsIgnoreCase("filter_type_group"))
  +                {
  +                    try
  +                    {
  +                        Group group = JetspeedSecurity.getGroup(filterValue);
  +                        ql = new QueryLocator(QueryLocator.QUERY_GROUP);
  +                        ql.setGroup(group);
  +                        psmlIterator = Profiler.query(ql);
  +                    }
  +                    catch (Exception e)
  +                    {
  +                    }
  +                }
  +            }
  +
               // Set Start and End
  -            int start = rundata.getParameters().getInt("start", 0);                
  +            int start = rundata.getParameters().getInt("start", 0);
               int size = getSize(portlet);
  - 
   
               // Only include entries in compatibale with the Media-type/Country/Language
               List psmlList = new LinkedList();
  @@ -301,26 +394,35 @@
               while (psmlIterator.hasNext())
               {
                   refProfile = (Profile) psmlIterator.next();
  -                
  +
                   if (refProfile.getMediaType() != null)
                   {
  -                    if (profile.getMediaType().equals(refProfile.getMediaType()) == false)
  +                    if (profile
  +                        .getMediaType()
  +                        .equals(refProfile.getMediaType())
  +                        == false)
                       {
                           continue;
                       }
                   }
  -                
  +
                   if (profile.getLanguage() != null)
                   {
                       if (refProfile.getLanguage() != null)
                       {
  -                        if (profile.getLanguage().equals(refProfile.getLanguage()) == true)
  +                        if (profile
  +                            .getLanguage()
  +                            .equals(refProfile.getLanguage())
  +                            == true)
                           {
                               if (profile.getCountry() != null)
                               {
                                   if (refProfile.getCountry() != null)
                                   {
  -                                    if (profile.getCountry().equals(refProfile.getCountry()) == false)
  +                                    if (profile
  +                                        .getCountry()
  +                                        .equals(refProfile.getCountry())
  +                                        == false)
                                       {
                                           // Profile and Ref are different countries
                                           continue;
  @@ -351,13 +453,13 @@
                           continue;
                       }
                   }
  -                
  +
                   if (profile.getPath().equals(refProfile.getPath()) == true)
                   {
                       // Do not allow Profile to reference it self
                       continue;
                   }
  -                
  +
                   // Only add profiles to list that will be displayed
                   if (profileCounter >= (start + size))
                   {
  @@ -369,23 +471,23 @@
                   }
                   profileCounter++;
               }
  -               
  +
               // Add Start to context
               if (start > 0)
               {
                   context.put("prev", String.valueOf(Math.max(start - size, 0)));
               }
  -                
  +
               // Set end to context
               if ((size == psmlList.size()) && (psmlIterator.hasNext()))
               {
                   context.put("next", String.valueOf(start + size));
               }
  -            
  +
               context.put("psml", psmlList.iterator());
           }
           else // build context for layout mode
  -        {
  +            {
               // nothing specific to do
           }
   
  @@ -396,8 +498,9 @@
           int size = 15;
           try
           {
  -            size = Integer.parseInt(portlet.getPortletConfig()
  -                                           .getInitParameter("size"));
  +            size =
  +                Integer.parseInt(
  +                    portlet.getPortletConfig().getInitParameter("size"));
           }
           catch (Exception e)
           {
  @@ -411,7 +514,8 @@
       {
           //((JetspeedRunData)rundata).setCustomized(null);
           //rundata.setScreenTemplate("Home");
  -        SessionState customizationState = ((JetspeedRunData) rundata).getPageSessionState();
  +        SessionState customizationState =
  +            ((JetspeedRunData) rundata).getPageSessionState();
           customizationState.setAttribute("customize-mode", "layout");
       }
   
  @@ -422,7 +526,7 @@
           doSkin(rundata, context);
           doLayout(rundata, context);
           doSecurity(rundata, context);
  -        
  +
           Profile profile = ((JetspeedRunData) rundata).getCustomizedProfile();
           try
           {
  @@ -440,38 +544,45 @@
           }
   
       }
  -    
  +
       /** Save customizations and get out of customization state */
       public void doApply(RunData rundata, Context context)
       {
           doSave(rundata, context);
       }
  -    
  +
       /** Add a new portlets element in the customized set */
       public void doAddset(RunData rundata, Context context)
       {
  -        PortletSet set = (PortletSet) ((JetspeedRunData) rundata).getCustomized();
  +        PortletSet set =
  +            (PortletSet) ((JetspeedRunData) rundata).getCustomized();
           String title = rundata.getParameters().getString("title", "My Pane");
  -        
  +
           if (set != null)
           {
  -            Portlets portlets = ((JetspeedRunData) rundata).getCustomizedProfile()
  -                                                           .getDocument()
  -                                                           .getPortletsById(set.getID());
  -            
  +            Portlets portlets =
  +                ((JetspeedRunData) rundata)
  +                    .getCustomizedProfile()
  +                    .getDocument()
  +                    .getPortletsById(set.getID());
  +
               if (portlets != null)
               {
                   Portlets p = new PsmlPortlets();
                   p.setMetaInfo(new PsmlMetaInfo());
                   p.getMetaInfo().setTitle(title);
                   p.setId(JetspeedIdGenerator.getNextPeid());
  -                SecurityReference defaultRef = PortalToolkit.getDefaultSecurityRef(
  -                    ((JetspeedRunData) rundata).getCustomizedProfile());
  +                SecurityReference defaultRef =
  +                    PortalToolkit.getDefaultSecurityRef(
  +                        ((JetspeedRunData) rundata).getCustomizedProfile());
                   if (defaultRef != null)
                   {
                       if (logger.isDebugEnabled())
                       {
  -                        logger.debug("CustomizeSetAction: setting default portlet set security to [" + defaultRef.getParent() + "]");
  +                        logger.debug(
  +                            "CustomizeSetAction: setting default portlet set security to ["
  +                                + defaultRef.getParent()
  +                                + "]");
                       }
                       p.setSecurityRef(defaultRef);
                   }
  @@ -479,107 +590,125 @@
               }
           }
   
  -        SessionState customizationState = ((JetspeedRunData) rundata).getPageSessionState();
  +        SessionState customizationState =
  +            ((JetspeedRunData) rundata).getPageSessionState();
           customizationState.setAttribute("customize-mode", "layout");
       }
  -    
  -   public void doPrevious(RunData rundata, Context context) throws Exception
  -   {
  -       int queryStart = rundata.getParameters().getInt("previous", 0);
  -       String mtype = rundata.getParameters().getString("mtype", null);
  -       maintainUserSelections(rundata);
  -       JetspeedLink link = JetspeedLinkFactory.getInstance(rundata);
  -       DynamicURI duri = null;
  -       if (mtype == null)
  -       {
  -           duri = link.setTemplate("Customize").addQueryData("start", String.valueOf(queryStart));
  -       }
  -       else
  -       {
  -           duri = link.setTemplate("Customize").
  -               addQueryData("start", String.valueOf(queryStart)).
  -               addQueryData("mtype", mtype);
  -       }
  -       JetspeedLinkFactory.putInstance(link);
  -       rundata.setRedirectURI(duri.toString());
  -       return;
  -   }
  -
  -   public void doNext(RunData rundata, Context context) throws Exception
  -   {
  -       int queryStart = rundata.getParameters().getInt("next", 0);
  -       String mtype = rundata.getParameters().getString("mtype", null);
  -       maintainUserSelections(rundata);
  -       JetspeedLink link = JetspeedLinkFactory.getInstance(rundata);
  -       DynamicURI duri = null;
  -       if (mtype == null)
  -       {
  -           duri = link.setTemplate("Customize").addQueryData("start", String.valueOf(queryStart));
  -       }
  -       else
  -       {
  -           duri = link.setTemplate("Customize").
  -               addQueryData("start", String.valueOf(queryStart)).
  -               addQueryData("mtype", mtype);
  -       }
  -       JetspeedLinkFactory.putInstance(link);
  -       rundata.setRedirectURI(duri.toString());
  -       return;
  -   }
  -
  -   protected void maintainUserSelections(RunData rundata) throws Exception
  -   {
  -       int size = rundata.getParameters().getInt("size", 0);
  -       int previous = rundata.getParameters().getInt("previous", -1);
  -       int start = 0;
  -       if (previous >= 0)
  -       {
  -           start = previous + size;
  -       }
  -
  -       String[] pnames = rundata.getParameters().getStrings("pname");
  -       //System.out.println("start = "+start+" size = "+size);
  -       //System.out.println("pnames = "+rundata.getParameters());
  -       Map userSelections = getUserSelections(rundata);
  -       List portlets = (List) PortletSessionState.getAttribute(rundata, PORTLET_LIST, null);
  -       if (portlets != null)
  -       {
  -           int end = Math.min(start + size, portlets.size());
  -           int pnamesIndex = 0;
  -           //Go through all the portlets on this page and figure out which ones have been 
  -           //checked and which ones unchecked and accordingly update the userSelectionMap
  -           for (int portletIndex = start; portletIndex < end; portletIndex++)
  -           {
  -               PortletEntry entry = (PortletEntry) portlets.get(portletIndex);
  -               if (pnames != null 
  -                   && pnamesIndex < pnames.length 
  -                   && pnames[pnamesIndex].equals(entry.getName()))
  -               {
  +
  +    public void doPrevious(RunData rundata, Context context) throws Exception
  +    {
  +        int queryStart = rundata.getParameters().getInt("previous", 0);
  +        String mtype = rundata.getParameters().getString("mtype", null);
  +        maintainUserSelections(rundata);
  +        JetspeedLink link = JetspeedLinkFactory.getInstance(rundata);
  +        DynamicURI duri = null;
  +        if (mtype == null)
  +        {
  +            duri =
  +                link.setTemplate("Customize").addQueryData(
  +                    "start",
  +                    String.valueOf(queryStart));
  +        }
  +        else
  +        {
  +            duri =
  +                link
  +                    .setTemplate("Customize")
  +                    .addQueryData("start", String.valueOf(queryStart))
  +                    .addQueryData("mtype", mtype);
  +        }
  +        JetspeedLinkFactory.putInstance(link);
  +        rundata.setRedirectURI(duri.toString());
  +        return;
  +    }
  +
  +    public void doNext(RunData rundata, Context context) throws Exception
  +    {
  +        int queryStart = rundata.getParameters().getInt("next", 0);
  +        String mtype = rundata.getParameters().getString("mtype", null);
  +        maintainUserSelections(rundata);
  +        JetspeedLink link = JetspeedLinkFactory.getInstance(rundata);
  +        DynamicURI duri = null;
  +        if (mtype == null)
  +        {
  +            duri =
  +                link.setTemplate("Customize").addQueryData(
  +                    "start",
  +                    String.valueOf(queryStart));
  +        }
  +        else
  +        {
  +            duri =
  +                link
  +                    .setTemplate("Customize")
  +                    .addQueryData("start", String.valueOf(queryStart))
  +                    .addQueryData("mtype", mtype);
  +        }
  +        JetspeedLinkFactory.putInstance(link);
  +        rundata.setRedirectURI(duri.toString());
  +        return;
  +    }
  +
  +    protected void maintainUserSelections(RunData rundata) throws Exception
  +    {
  +        int size = rundata.getParameters().getInt("size", 0);
  +        int previous = rundata.getParameters().getInt("previous", -1);
  +        int start = 0;
  +        if (previous >= 0)
  +        {
  +            start = previous + size;
  +        }
  +
  +        String[] pnames = rundata.getParameters().getStrings("pname");
  +        //System.out.println("start = "+start+" size = "+size);
  +        //System.out.println("pnames = "+rundata.getParameters());
  +        Map userSelections = getUserSelections(rundata);
  +        List portlets =
  +            (List) PortletSessionState.getAttribute(
  +                rundata,
  +                PORTLET_LIST,
  +                null);
  +        if (portlets != null)
  +        {
  +            int end = Math.min(start + size, portlets.size());
  +            int pnamesIndex = 0;
  +            //Go through all the portlets on this page and figure out which ones have been 
  +            //checked and which ones unchecked and accordingly update the userSelectionMap
  +            for (int portletIndex = start; portletIndex < end; portletIndex++)
  +            {
  +                PortletEntry entry = (PortletEntry) portlets.get(portletIndex);
  +                if (pnames != null
  +                    && pnamesIndex < pnames.length
  +                    && pnames[pnamesIndex].equals(entry.getName()))
  +                {
                       userSelections.put(entry.getName(), entry);
                       pnamesIndex++;
  -               }
  -               else
  -               {
  +                }
  +                else
  +                {
                       userSelections.remove(entry.getName());
  -               }
  -           }
  -           PortletSessionState.setAttribute(rundata, USER_SELECTIONS, userSelections);
  -           /*
  -           Iterator it = userSelections.keySet().iterator();           
  -           System.out.print("User Selections: ");
  -           while (it.hasNext())
  -           {
  -               System.out.print(", "+it.next());
  -           }
  -           System.out.println("\n");
  -           */
  -       }
  -       else
  -       {
  -           throw new Exception("Master Portlet List is null!");
  -       }
  +                }
  +            }
  +            PortletSessionState.setAttribute(
  +                rundata,
  +                USER_SELECTIONS,
  +                userSelections);
  +            /*
  +            Iterator it = userSelections.keySet().iterator();           
  +            System.out.print("User Selections: ");
  +            while (it.hasNext())
  +            {
  +                System.out.print(", "+it.next());
  +            }
  +            System.out.println("\n");
  +            */
  +        }
  +        else
  +        {
  +            throw new Exception("Master Portlet List is null!");
  +        }
   
  -   }
  +    }
   
       /** Add new portlets in the customized set */
       public void doAdd(RunData rundata, Context context) throws Exception
  @@ -593,8 +722,9 @@
            * mailto: A.Kempf@web.de
            */
           //boolean isWML = AutoProfile.doIt (rundata, true).getMediaType().equalsIgnoreCase("wml");
  -        PortletSet set = (PortletSet) ((JetspeedRunData) rundata).getCustomized();
  -        
  +        PortletSet set =
  +            (PortletSet) ((JetspeedRunData) rundata).getCustomized();
  +
           maintainUserSelections(rundata);
           Map userSelections = getUserSelections(rundata);
           String[] pnames = new String[userSelections.size()];
  @@ -603,68 +733,73 @@
   
           // Create a ClearPortletControl
           Control ctrl = new PsmlControl();
  -        ctrl.setName ("ClearPortletControl");
  +        ctrl.setName("ClearPortletControl");
   
  -        
           if ((pnames != null) && (set != null))
           {
  -            Portlets portlets = ((JetspeedRunData) rundata).getCustomizedProfile()
  -                                                           .getDocument()
  -                                                           .getPortletsById(set.getID());
  +            Portlets portlets =
  +                ((JetspeedRunData) rundata)
  +                    .getCustomizedProfile()
  +                    .getDocument()
  +                    .getPortletsById(set.getID());
   
               List usedPortlets = AutoProfile.getPortletList(rundata);
               boolean addIt;
               int cc;
               Entry usedEntry;
  -                                          
  +
               for (int i = 0; i < pnames.length; i++)
               {
  -                PortletEntry entry = (PortletEntry) Registry.getEntry(Registry.PORTLET, pnames[i]);
  +                PortletEntry entry =
  +                    (PortletEntry) Registry.getEntry(
  +                        Registry.PORTLET,
  +                        pnames[i]);
   
                   // add only new portlets!
                   if ((entry != null) && (portlets != null))
                   {
  -                
  +
                       addIt = true;
  - /*
  -                    for (cc=0; cc<usedPortlets.size(); cc++)
  -                    {
  -                      usedEntry = (Entry) usedPortlets.get(cc);
  -                      if (entry.getName().equals(usedEntry.getParent()))
  -                      {
  -                        addIt = false;
  -                        break;
  -                      }
  -                      
  -                    }
  -*/
  +                    /*
  +                                       for (cc=0; cc<usedPortlets.size(); cc++)
  +                                       {
  +                                         usedEntry = (Entry) usedPortlets.get(cc);
  +                                         if (entry.getName().equals(usedEntry.getParent()))
  +                                         {
  +                                           addIt = false;
  +                                           break;
  +                                         }
  +                                         
  +                                       }
  +                    */
                       if (addIt)
                       {
  -                      Entry p = new PsmlEntry();
  -                      // add the ClearPortletControl to wml entries      
  -                      //if (isWML)
  -                      //  p.setControl (ctrl);
  -                    
  -                      p.setParent(pnames[i]);
  -                      p.setId(JetspeedIdGenerator.getNextPeid());
  -//                      SecurityReference defaultRef = PortalToolkit.getDefaultSecurityRef(
  -//                          ((JetspeedRunData) rundata).getCustomizedProfile());
  -//                      if (defaultRef != null)
  -//                      {
  -//                          if (Log.getLogger().isDebugEnabled())
  -//                          {
  -//                              Log.debug("CustomizeSetAction: setting default portlet security to [" + defaultRef.getParent() + "]");
  -//                          }
  -//                          p.setSecurityRef(defaultRef);
  -//                      }
  -                      portlets.addEntry(p);
  +                        Entry p = new PsmlEntry();
  +                        // add the ClearPortletControl to wml entries      
  +                        //if (isWML)
  +                        //  p.setControl (ctrl);
  +
  +                        p.setParent(pnames[i]);
  +                        p.setId(JetspeedIdGenerator.getNextPeid());
  +                        //                      SecurityReference defaultRef = PortalToolkit.getDefaultSecurityRef(
  +                        //                          ((JetspeedRunData) rundata).getCustomizedProfile());
  +                        //                      if (defaultRef != null)
  +                        //                      {
  +                        //                          if (Log.getLogger().isDebugEnabled())
  +                        //                          {
  +                        //                              Log.debug("CustomizeSetAction: setting default portlet security to [" + defaultRef.getParent() + "]");
  +                        //                          }
  +                        //                          p.setSecurityRef(defaultRef);
  +                        //                      }
  +                        portlets.addEntry(p);
                       }
                   }
               }
           }
           // --------------------------------------------------------------------------
   
  -        SessionState customizationState = ((JetspeedRunData) rundata).getPageSessionState();
  +        SessionState customizationState =
  +            ((JetspeedRunData) rundata).getPageSessionState();
           customizationState.setAttribute("customize-mode", "layout");
   
           /** 
  @@ -679,43 +814,48 @@
             //rundata.save();
           }
            */
  -        
  +
       }
   
       /** Add new Reference in the customized set */
       public void doAddref(RunData rundata, Context context) throws Exception
       {
  -        PortletSet set = (PortletSet) ((JetspeedRunData) rundata).getCustomized();
  +        PortletSet set =
  +            (PortletSet) ((JetspeedRunData) rundata).getCustomized();
           String[] refNames = rundata.getParameters().getStrings("refname");
  -        
  +
           // Create a ClearPortletControl
           Control ctrl = new PsmlControl();
  -        ctrl.setName ("ClearPortletControl");
  +        ctrl.setName("ClearPortletControl");
   
  -        
           if ((refNames != null) && (set != null))
           {
  -            Portlets portlets = ((JetspeedRunData) rundata).getCustomizedProfile()
  -                                                           .getDocument()
  -                                                           .getPortletsById(set.getID());
  +            Portlets portlets =
  +                ((JetspeedRunData) rundata)
  +                    .getCustomizedProfile()
  +                    .getDocument()
  +                    .getPortletsById(set.getID());
   
               for (int i = 0; i < refNames.length; i++)
               {
  -                SecurityReference sref = getSecurityReference(rundata, refNames[i]);
  +                SecurityReference sref =
  +                    getSecurityReference(rundata, refNames[i]);
                   if (sref != null)
                   {
                       Reference ref = new PsmlReference();
  -                    ref.setPath(refNames[i]);              
  +                    ref.setPath(refNames[i]);
                       ref.setSecurityRef(sref);
                       portlets.addReference(ref);
                   }
                   else
                   {
  -                    String tmpl = CustomLocalization.getString("CUSTOMIZER_ADD_REF_ERROR", rundata);
  -                    Object[] args = {
  -                        refNames[i]
  -                    };
  -                    String message = MessageFormat.format(tmpl, args).toString();
  +                    String tmpl =
  +                        CustomLocalization.getString(
  +                            "CUSTOMIZER_ADD_REF_ERROR",
  +                            rundata);
  +                    Object[] args = { refNames[i] };
  +                    String message =
  +                        MessageFormat.format(tmpl, args).toString();
   
                       rundata.addMessage(message.concat("<br>"));
                       if (logger.isWarnEnabled())
  @@ -725,7 +865,8 @@
                   }
               }
           }
  -        SessionState customizationState = ((JetspeedRunData) rundata).getPageSessionState();
  +        SessionState customizationState =
  +            ((JetspeedRunData) rundata).getPageSessionState();
           customizationState.setAttribute("customize-mode", "layout");
       }
   
  @@ -735,7 +876,9 @@
        * @param path the psml locator path
        * @return the security reference of the referenced resource     
        */
  -    protected SecurityReference getSecurityReference(RunData rundata, String path)
  +    protected SecurityReference getSecurityReference(
  +        RunData rundata,
  +        String path)
       {
           try
           {
  @@ -758,8 +901,8 @@
                                                            JetspeedSecurity.PERMISSION_VIEW))
                       {
                       */
  -                        return rootSet.getSecurityRef();    
  -        //            }
  +                    return rootSet.getSecurityRef();
  +                    //            }
                   }
               }
           }
  @@ -769,20 +912,23 @@
           }
           return null;
       }
  -    
  +
       /** Sets the metainfo for this entry */
       public void doMetainfo(RunData rundata, Context context)
       {
  -        PortletSet set = (PortletSet) ((JetspeedRunData) rundata).getCustomized();
  +        PortletSet set =
  +            (PortletSet) ((JetspeedRunData) rundata).getCustomized();
           String title = rundata.getParameters().getString("title");
           String description = rundata.getParameters().getString("description");
   
           if (set != null)
           {
  -            Portlets portlets = ((JetspeedRunData) rundata).getCustomizedProfile()
  -                                                           .getDocument()
  -                                                           .getPortletsById(set.getID());
  -            
  +            Portlets portlets =
  +                ((JetspeedRunData) rundata)
  +                    .getCustomizedProfile()
  +                    .getDocument()
  +                    .getPortletsById(set.getID());
  +
               if (portlets != null)
               {
                   MetaInfo meta = portlets.getMetaInfo();
  @@ -791,14 +937,14 @@
                       meta = new PsmlMetaInfo();
                       portlets.setMetaInfo(meta);
                   }
  -            
  +
                   if (title != null)
                   {
                       meta.setTitle(title);
                       set.setTitle(title);
                   }
   
  -                if(description != null)
  +                if (description != null)
                   {
                       meta.setDescription(description);
                       set.setDescription(description);
  @@ -812,22 +958,25 @@
       {
           // we should first retrieve the portlet to customize and its parameters
           // definition
  -        PortletSet set = (PortletSet) ((JetspeedRunData) rundata).getCustomized();
  -        
  +        PortletSet set =
  +            (PortletSet) ((JetspeedRunData) rundata).getCustomized();
  +
           try
  -        {            
  +        {
               String controller = rundata.getParameters().getString("controller");
  -            
  +
               if (controller != null)
               {
  -                Profile profile = ((JetspeedRunData) rundata).getCustomizedProfile();
  +                Profile profile =
  +                    ((JetspeedRunData) rundata).getCustomizedProfile();
                   PortletController pc = PortalToolkit.getController(controller);
   
                   if (pc != null)
                   {
                       set.setController(pc);
   
  -                    Portlets portlets = profile.getDocument().getPortletsById(set.getID());
  +                    Portlets portlets =
  +                        profile.getDocument().getPortletsById(set.getID());
   
                       Controller c = portlets.getController();
                       if (c == null)
  @@ -836,8 +985,9 @@
                           portlets.setController(c);
                       }
                       c.setName(controller);
  -                    
  -                    String linkedControl = pc.getConfig().getInitParameter("control");
  +
  +                    String linkedControl =
  +                        pc.getConfig().getInitParameter("control");
   
                       if (linkedControl != null)
                       {
  @@ -856,7 +1006,7 @@
           {
               logger.error("Exception", e);
           }
  -        
  +
       }
   
       /**
  @@ -876,14 +1026,17 @@
       {
           // we should first retrieve the portlet to customize and its parameters
           // definition
  -        PortletSet set = (PortletSet) ((JetspeedRunData) rundata).getCustomized();
  -        
  +        PortletSet set =
  +            (PortletSet) ((JetspeedRunData) rundata).getCustomized();
  +
           try
  -        {            
  +        {
               String skin = rundata.getParameters().getString("skin");
  -            Profile profile = ((JetspeedRunData) rundata).getCustomizedProfile();
  -            Portlets portlets = profile.getDocument().getPortletsById(set.getID());
  -            
  +            Profile profile =
  +                ((JetspeedRunData) rundata).getCustomizedProfile();
  +            Portlets portlets =
  +                profile.getDocument().getPortletsById(set.getID());
  +
               // skin is neither null nor zero-length
               if ((skin != null) && (skin.trim().length() > 0))
               {
  @@ -902,58 +1055,69 @@
                   }
                   else
                   {
  -                    logger.warn("Unable to update skin for portlet set " 
  -                             + set.getID() + " because skin " + skin 
  -                             + " does not exist.");
  +                    logger.warn(
  +                        "Unable to update skin for portlet set "
  +                            + set.getID()
  +                            + " because skin "
  +                            + skin
  +                            + " does not exist.");
                       return;
                   }
               }
               else
               {
  -              // skin is either null or zero-length
  -              String custPortletSetID = portlets.getId();
  -              String rootPortletSetID = profile.getRootSet().getID();
  -              
  -              // set system default skin for root PSML element
  -              if (custPortletSetID != null && rootPortletSetID != null &&
  -                  custPortletSetID.equals(rootPortletSetID))
  -              {
  -                // get system default skin
  -                String defaultSkinName = JetspeedResources.getString("services.PortalToolkit.default.skin");
  -                PortletSkin defaultSkin = PortalToolkit.getSkin(defaultSkinName);
  -                
  -                if (defaultSkin != null)
  -                {
  -                  set.getPortletConfig().setPortletSkin((PortletSkin) defaultSkin);
  -                  Skin psmlSkin = portlets.getSkin();
  -                  
  -                  if (psmlSkin == null)
  -                  {
  -                    portlets.setSkin(new PsmlSkin());
  -                  }
  -                
  -                  portlets.getSkin().setName(defaultSkin.getName());
  +                // skin is either null or zero-length
  +                String custPortletSetID = portlets.getId();
  +                String rootPortletSetID = profile.getRootSet().getID();
  +
  +                // set system default skin for root PSML element
  +                if (custPortletSetID != null
  +                    && rootPortletSetID != null
  +                    && custPortletSetID.equals(rootPortletSetID))
  +                {
  +                    // get system default skin
  +                    String defaultSkinName =
  +                        JetspeedResources.getString(
  +                            "services.PortalToolkit.default.skin");
  +                    PortletSkin defaultSkin =
  +                        PortalToolkit.getSkin(defaultSkinName);
  +
  +                    if (defaultSkin != null)
  +                    {
  +                        set.getPortletConfig().setPortletSkin(
  +                            (PortletSkin) defaultSkin);
  +                        Skin psmlSkin = portlets.getSkin();
  +
  +                        if (psmlSkin == null)
  +                        {
  +                            portlets.setSkin(new PsmlSkin());
  +                        }
  +
  +                        portlets.getSkin().setName(defaultSkin.getName());
  +                    }
  +                    else
  +                    {
  +                        logger.warn(
  +                            "Unable to set default skin for root portlet set "
  +                                + set.getID()
  +                                + " because skin "
  +                                + skin
  +                                + " does not exist.");
  +                        return;
  +                    }
                   }
                   else
                   {
  -                    logger.warn("Unable to set default skin for root portlet set " 
  -                             + set.getID() + " because skin " + skin 
  -                             + " does not exist.");
  -                    return;
  +                    // By setting the skin to null, the parent's skin will be used.
  +                    set.getPortletConfig().setPortletSkin((PortletSkin) null);
  +                    portlets.setSkin(null);
                   }
  -              }
  -              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)
           {
               logger.error(e);
  -        }        
  +        }
       }
   
       /**
  @@ -966,16 +1130,21 @@
       {
           // we should first retrieve the portlet to customize and its parameters
           // definition
  -        PortletSet set = (PortletSet) ((JetspeedRunData) rundata).getCustomized();
  -        
  +        PortletSet set =
  +            (PortletSet) ((JetspeedRunData) rundata).getCustomized();
  +
           try
  -        {            
  -            String securityRefName = rundata.getParameters().getString("securityRef");
  +        {
  +            String securityRefName =
  +                rundata.getParameters().getString("securityRef");
               SecurityReference securityRef = null;
  -            Profile profile = ((JetspeedRunData) rundata).getCustomizedProfile();
  -            Portlets portlets = profile.getDocument().getPortletsById(set.getID());
  +            Profile profile =
  +                ((JetspeedRunData) rundata).getCustomizedProfile();
  +            Portlets portlets =
  +                profile.getDocument().getPortletsById(set.getID());
   
  -            if ((securityRefName != null) && (securityRefName.trim().length() > 0))
  +            if ((securityRefName != null)
  +                && (securityRefName.trim().length() > 0))
               {
                   securityRef = new BaseSecurityReference();
                   securityRef.setParent(securityRefName);
  @@ -986,54 +1155,65 @@
           catch (Exception e)
           {
               logger.error("Exception", e);
  -        }        
  +        }
       }
  -    
   
       // Create a list of all available portlets
  -    public static List buildPortletList(RunData data, PortletSet set, String mediaType, List allPortlets)
  +    public static List buildPortletList(
  +        RunData data,
  +        PortletSet set,
  +        String mediaType,
  +        List allPortlets)
       {
  -        List list = new ArrayList();                                                                 
  +        List list = new ArrayList();
           Iterator i = Registry.get(Registry.PORTLET).listEntryNames();
  -        
  +
           while (i.hasNext())
           {
  -            PortletEntry entry = (PortletEntry) Registry.getEntry(Registry.PORTLET,
  -                                                                 (String) i.next());
  -            
  +            PortletEntry entry =
  +                (PortletEntry) Registry.getEntry(
  +                    Registry.PORTLET,
  +                    (String) i.next());
  +
               Iterator medias;
               //Make a master portlet list, we will eventually us this to build a category list
               allPortlets.add(entry);
               // MODIFIED: Selection now takes care of the specified mediatype!
  -            if (JetspeedSecurity.checkPermission((JetspeedUser) data.getUser(), 
  -                                                 new PortalResource(entry), 
  -                                                 JetspeedSecurity.PERMISSION_VIEW)
  -              && ((!entry.isHidden()) 
  -                && (!entry.getType().equals(PortletEntry.TYPE_ABSTRACT))
  -                && entry.hasMediaType(mediaType)))
  +            if (JetspeedSecurity
  +                .checkPermission(
  +                    (JetspeedUser) data.getUser(),
  +                    new PortalResource(entry),
  +                    JetspeedSecurity.PERMISSION_VIEW)
  +                && ((!entry.isHidden())
  +                    && (!entry.getType().equals(PortletEntry.TYPE_ABSTRACT))
  +                    && entry.hasMediaType(mediaType)))
               {
                   list.add(entry);
               }
           }
  -        
  -        String[] filterFields = (String[]) PortletSessionState.getAttribute(data, FILTER_FIELDS);
  -        String[] filterValues = (String[]) PortletSessionState.getAttribute(data, FILTER_VALUES);
  +
  +        String[] filterFields =
  +            (String[]) PortletSessionState.getAttribute(data, FILTER_FIELDS);
  +        String[] filterValues =
  +            (String[]) PortletSessionState.getAttribute(data, FILTER_VALUES);
           list = PortletFilter.filterPortlets(list, filterFields, filterValues);
  -        
  -        Collections.sort(list,
  -                new Comparator() {
  -                    public int compare(Object o1, Object o2)
  -                    {
  -                        String t1 = (((PortletEntry) o1).getTitle() != null)
  -                            ? ((PortletEntry) o1).getTitle().toLowerCase()
  -                            : ((PortletEntry) o1).getName().toLowerCase();
  -                        String t2 = (((PortletEntry) o2).getTitle() != null)
  -                            ? ((PortletEntry) o2).getTitle().toLowerCase()
  -                            : ((PortletEntry) o2).getName().toLowerCase();
  -                                                   
  -                        return t1.compareTo(t2);
  -                    }
  -                });
  +
  +        Collections.sort(list, new Comparator()
  +        {
  +            public int compare(Object o1, Object o2)
  +            {
  +                String t1 =
  +                    (((PortletEntry) o1).getTitle() != null)
  +                        ? ((PortletEntry) o1).getTitle().toLowerCase()
  +                        : ((PortletEntry) o1).getName().toLowerCase();
  +                String t2 =
  +                    (((PortletEntry) o2).getTitle() != null)
  +                        ? ((PortletEntry) o2).getTitle().toLowerCase()
  +                        : ((PortletEntry) o2).getName().toLowerCase();
  +
  +                return t1.compareTo(t2);
  +            }
  +        });
           //this is used only by maintainUserSelection - which does not need the 
           //portlet list to be regenrated       
           PortletSessionState.setAttribute(data, PORTLET_LIST, list);
  @@ -1042,141 +1222,165 @@
   
       public static Map getUserSelections(RunData data)
       {
  -        Map userSelections = (Map) PortletSessionState.getAttribute(data, USER_SELECTIONS, null);
  +        Map userSelections =
  +            (Map) PortletSessionState.getAttribute(data, USER_SELECTIONS, null);
           if (userSelections == null)
           {
               userSelections = new HashMap();
  -            PortletSessionState.setAttribute(data, USER_SELECTIONS, userSelections);
  +            PortletSessionState.setAttribute(
  +                data,
  +                USER_SELECTIONS,
  +                userSelections);
           }
           return userSelections;
       }
  -    
  -    public static List buildInfoList(RunData data, String regName, String mediaType)
  +
  +    public static List buildInfoList(
  +        RunData data,
  +        String regName,
  +        String mediaType)
       {
           List list = new ArrayList();
  -        
  -        String mime = ((JetspeedRunData) data).getCapability()
  -                                              .getPreferredType()
  -                                              .toString();
  -                                             
  +
  +        String mime =
  +            ((JetspeedRunData) data)
  +                .getCapability()
  +                .getPreferredType()
  +                .toString();
  +
           Iterator m = Registry.get(Registry.MEDIA_TYPE).listEntryNames();
  -//        String mediaName = "html";
  -//        
  -//        while(m.hasNext())
  -//        {
  -//            MediaTypeEntry me = (MediaTypeEntry)
  -//                Registry.getEntry(Registry.MEDIA_TYPE,(String)m.next());
  -//            
  -//            if (me!=null)
  -//            {
  -//                if (mime.equals(me.getMimeType()))
  -//                {
  -//                    mediaName = me.getName();
  -//                    break;
  -//                }
  -//            }
  -//        }
  -                    
  +        //        String mediaName = "html";
  +        //        
  +        //        while(m.hasNext())
  +        //        {
  +        //            MediaTypeEntry me = (MediaTypeEntry)
  +        //                Registry.getEntry(Registry.MEDIA_TYPE,(String)m.next());
  +        //            
  +        //            if (me!=null)
  +        //            {
  +        //                if (mime.equals(me.getMimeType()))
  +        //                {
  +        //                    mediaName = me.getName();
  +        //                    break;
  +        //                }
  +        //            }
  +        //        }
  +
           Iterator i = Registry.get(regName).listEntryNames();
  -        
  +
           while (i.hasNext())
           {
  -            PortletInfoEntry entry = (PortletInfoEntry) Registry.getEntry(regName,
  -                                                                 (String) i.next());
  -            
  +            PortletInfoEntry entry =
  +                (PortletInfoEntry) Registry.getEntry(
  +                    regName,
  +                    (String) i.next());
  +
               // MODIFIED: Selection now takes care of the specified mediatype!
  -            if (JetspeedSecurity.checkPermission((JetspeedUser) data.getUser(), 
  -                                                  new PortalResource(entry), 
  -                                                  JetspeedSecurity.PERMISSION_CUSTOMIZE)
  -               && ((!entry.isHidden())
  -                 && entry.hasMediaType(mediaType)))
  +            if (JetspeedSecurity
  +                .checkPermission(
  +                    (JetspeedUser) data.getUser(),
  +                    new PortalResource(entry),
  +                    JetspeedSecurity.PERMISSION_CUSTOMIZE)
  +                && ((!entry.isHidden()) && entry.hasMediaType(mediaType)))
               {
                   list.add(entry);
               }
           }
  -        
  -        Collections.sort(list,
  -                new Comparator() {
  -                    public int compare(Object o1, Object o2)
  -                    {
  -                        String t1 = (((RegistryEntry) o1).getTitle() != null)
  -                            ? ((RegistryEntry) o1).getTitle()
  -                            : ((RegistryEntry) o1).getName();
  -                        String t2 = (((RegistryEntry) o2).getTitle() != null)
  -                            ? ((RegistryEntry) o2).getTitle()
  -                            : ((RegistryEntry) o2).getName();
  -                        
  -                        return t1.compareTo(t2);
  -                    }
  -                });
  -        
  +
  +        Collections.sort(list, new Comparator()
  +        {
  +            public int compare(Object o1, Object o2)
  +            {
  +                String t1 =
  +                    (((RegistryEntry) o1).getTitle() != null)
  +                        ? ((RegistryEntry) o1).getTitle()
  +                        : ((RegistryEntry) o1).getName();
  +                String t2 =
  +                    (((RegistryEntry) o2).getTitle() != null)
  +                        ? ((RegistryEntry) o2).getTitle()
  +                        : ((RegistryEntry) o2).getName();
  +
  +                return t1.compareTo(t2);
  +            }
  +        });
  +
           return list;
       }
  -    
  +
       public static List buildList(RunData data, String regName)
       {
           List list = new ArrayList();
  -        
  -        Iterator i = Registry.get(regName).listEntryNames();        
  +
  +        Iterator i = Registry.get(regName).listEntryNames();
           while (i.hasNext())
           {
               RegistryEntry entry = Registry.getEntry(regName, (String) i.next());
  -            
  -            if (JetspeedSecurity.checkPermission((JetspeedUser) data.getUser(),
  -                                                 new PortalResource(entry),
  -                                                 JetspeedSecurity.PERMISSION_CUSTOMIZE)
  -               && (!entry.isHidden()))
  +
  +            if (JetspeedSecurity
  +                .checkPermission(
  +                    (JetspeedUser) data.getUser(),
  +                    new PortalResource(entry),
  +                    JetspeedSecurity.PERMISSION_CUSTOMIZE)
  +                && (!entry.isHidden()))
               {
                   list.add(entry);
               }
           }
  -        
  -        Collections.sort(list,
  -                new Comparator() {
  -                    public int compare(Object o1, Object o2)
  -                    {
  -                        String t1 = (((RegistryEntry) o1).getTitle() != null)
  -                            ? ((RegistryEntry) o1).getTitle()
  -                            : ((RegistryEntry) o1).getName();
  -                        String t2 = (((RegistryEntry) o2).getTitle() != null)
  -                            ? ((RegistryEntry) o2).getTitle()
  -                            : ((RegistryEntry) o2).getName();
  -                        
  -                        return t1.compareTo(t2);
  -                    }
  -                });
  -        
  +
  +        Collections.sort(list, new Comparator()
  +        {
  +            public int compare(Object o1, Object o2)
  +            {
  +                String t1 =
  +                    (((RegistryEntry) o1).getTitle() != null)
  +                        ? ((RegistryEntry) o1).getTitle()
  +                        : ((RegistryEntry) o1).getName();
  +                String t2 =
  +                    (((RegistryEntry) o2).getTitle() != null)
  +                        ? ((RegistryEntry) o2).getTitle()
  +                        : ((RegistryEntry) o2).getName();
  +
  +                return t1.compareTo(t2);
  +            }
  +        });
  +
           return list;
       }
  -    
  +
       /**
        * Builds a list of all portlet categories
        * @param RunData current requests RunData object
        * @param List portlets All available portlets
  -     */    
  -    public static List buildCategoryList(RunData data, String mediaType, List portlets)
  +     */
  +    public static List buildCategoryList(
  +        RunData data,
  +        String mediaType,
  +        List portlets)
       {
  -        boolean hideEmpties = JetspeedResources.getBoolean(HIDE_EMPTY_CATEGORIES, true);
  +        boolean hideEmpties =
  +            JetspeedResources.getBoolean(HIDE_EMPTY_CATEGORIES, true);
           TreeMap catMap = new TreeMap();
           Iterator pItr = portlets.iterator();
           while (pItr.hasNext())
           {
  -            PortletEntry entry =  (PortletEntry) pItr.next();
  +            PortletEntry entry = (PortletEntry) pItr.next();
               if (hideEmpties)
               {
  -                if (JetspeedSecurity.checkPermission((JetspeedUser) data.getUser(), 
  -                                         new PortalResource(entry), 
  -                                         JetspeedSecurity.PERMISSION_VIEW)
  -                    && ((!entry.isHidden()) 
  -                    && (!entry.getType().equals(PortletEntry.TYPE_ABSTRACT))
  -                    && entry.hasMediaType(mediaType)))
  +                if (JetspeedSecurity
  +                    .checkPermission(
  +                        (JetspeedUser) data.getUser(),
  +                        new PortalResource(entry),
  +                        JetspeedSecurity.PERMISSION_VIEW)
  +                    && ((!entry.isHidden())
  +                        && (!entry.getType().equals(PortletEntry.TYPE_ABSTRACT))
  +                        && entry.hasMediaType(mediaType)))
                   {
                       Iterator cItr = entry.listCategories();
                       while (cItr.hasNext())
                       {
                           BaseCategory cat = (BaseCategory) cItr.next();
                           catMap.put(cat.getName(), cat);
  -                    }            
  +                    }
                   }
               }
               else
  @@ -1186,26 +1390,30 @@
                   {
                       BaseCategory cat = (BaseCategory) cItr.next();
                       catMap.put(cat.getName(), cat);
  -                }            
  +                }
               }
           }
  -        
  +
           //BaseCategory allCat = new BaseCategory();
  -          //      allCat.setName("All Portlets");
  -            //    catMap.put(allCat.getName(), allCat);
  +        //      allCat.setName("All Portlets");
  +        //    catMap.put(allCat.getName(), allCat);
           return new ArrayList(catMap.values());
  -        
  +
       }
  -    
  +
       /**
        * Adds a filter over the available portlets list based on category
        */
  -    public void doFiltercategory(RunData rundata, Context context) throws Exception
  +    public void doFiltercategory(RunData rundata, Context context)
  +        throws Exception
       {
  -        String filterCat = rundata.getParameters().getString("filter_category", "All Portlets");
  +        String filterCat =
  +            rundata.getParameters().getString(
  +                "filter_category",
  +                "All Portlets");
           PortletSessionState.setAttribute(rundata, "filter_category", filterCat);
           maintainUserSelections(rundata);
  -        
  +
           String mtype = rundata.getParameters().getString("mtype", null);
           JetspeedLink link = JetspeedLinkFactory.getInstance(rundata);
           DynamicURI duri = null;
  @@ -1215,35 +1423,43 @@
           }
           else
           {
  -            duri = link.setTemplate("Customize").addQueryData("start", "0").addQueryData("mtype", mtype);
  +            duri =
  +                link.setTemplate("Customize").addQueryData(
  +                    "start",
  +                    "0").addQueryData(
  +                    "mtype",
  +                    mtype);
           }
           JetspeedLinkFactory.putInstance(link);
           rundata.setRedirectURI(duri.toString());
           return;
       }
  -    
  +
       /**
        * Adds a filter over the available portlets list based on category
        */
       public void doFilter(RunData rundata, Context context) throws Exception
       {
  -        String[] filterFields = rundata.getParameters().getStrings("filter_field");
  +        String[] filterFields =
  +            rundata.getParameters().getStrings("filter_field");
           String[] filterValues = new String[filterFields.length];
  -        for(int i=0; i<filterFields.length; i++)
  +        for (int i = 0; i < filterFields.length; i++)
           {
               String filterField = filterFields[i];
  -            if(filterField != null)
  +            if (filterField != null)
               {
  -                String filterValue = rundata.getParameters().getString(filterField + ":filter_value");
  +                String filterValue =
  +                    rundata.getParameters().getString(
  +                        filterField + ":filter_value");
                   filterValues[i] = filterValue;
               }
  -         }
  -        
  +        }
  +
           PortletSessionState.setAttribute(rundata, FILTER_FIELDS, filterFields);
           PortletSessionState.setAttribute(rundata, FILTER_VALUES, filterValues);
  -         
  +
           maintainUserSelections(rundata);
  -    
  +
           String mtype = rundata.getParameters().getString("mtype", null);
           JetspeedLink link = JetspeedLinkFactory.getInstance(rundata);
           DynamicURI duri = null;
  @@ -1253,27 +1469,36 @@
           }
           else
           {
  -            duri = link.setTemplate("Customize").addQueryData("start", "0").addQueryData("mtype", mtype);
  +            duri =
  +                link.setTemplate("Customize").addQueryData(
  +                    "start",
  +                    "0").addQueryData(
  +                    "mtype",
  +                    mtype);
           }
           JetspeedLinkFactory.putInstance(link);
           rundata.setRedirectURI(duri.toString());
           return;
       }
  -    
  +
       private void addFiltersToContext(RunData data, Context context)
       {
  -        String[] filterFields = (String[]) PortletSessionState.getAttribute(data, FILTER_FIELDS);
  -        String[] filterValues = (String[]) PortletSessionState.getAttribute(data, FILTER_VALUES);
  -        if(filterFields != null && filterValues != null && filterFields.length == filterValues.length)
  +        String[] filterFields =
  +            (String[]) PortletSessionState.getAttribute(data, FILTER_FIELDS);
  +        String[] filterValues =
  +            (String[]) PortletSessionState.getAttribute(data, FILTER_VALUES);
  +        if (filterFields != null
  +            && filterValues != null
  +            && filterFields.length == filterValues.length)
           {
  -            for(int i=0; i<filterFields.length; i++)
  +            for (int i = 0; i < filterFields.length; i++)
               {
                   String field = filterFields[i];
                   String value = filterValues[i];
  -        
  +
                   context.put(field + "_filter_value", value);
               }
           }
       }
  -        
  +
   }
  
  
  
  1.4       +10 -0     jakarta-jetspeed/webapp/WEB-INF/templates/vm/portlets/html/customizer-portletset-addref.vm
  
  Index: customizer-portletset-addref.vm
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/webapp/WEB-INF/templates/vm/portlets/html/customizer-portletset-addref.vm,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- customizer-portletset-addref.vm	29 Aug 2004 22:27:27 -0000	1.3
  +++ customizer-portletset-addref.vm	10 May 2005 19:28:18 -0000	1.4
  @@ -14,6 +14,16 @@
   limitations under the License.
   *#
   
  +<form method="post">
  +<b>${l10n.BROWSER_PSML_FILTER_STRING_VM}</b> <input type="Text" name="filter_value" value="$!filter_value"/>
  +<select name="filter_type">
  +  <option value="filter_type_user" #if ($filter_type == "filter_type_user") selected #end>${l10n.BROWSER_PSML_USER_VM}</option>
  +  <option value="filter_type_role" #if ($filter_type == "filter_type_role") selected #end>${l10n.BROWSER_PSML_ROLE_VM}</option>  
  +  <option value="filter_type_group" #if ($filter_type == "filter_type_group") selected #end>${l10n.BROWSER_PSML_GROUP_VM}</option>    
  +</select>
  +<input type="submit" name="eventSubmit_doFilterref" value="${l10n.BROWSER_PSML_FILTER_VM}"/>
  +</form>
  +
   #set ($mtype = $!data.Parameters.getString("mtype"))
   #if ($!mtype) 
       <form action="$jslink.Template.addQueryData('mtype', $mtype)" method="post">
  
  
  

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


Mime
View raw message