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 mo...@apache.org on 2005/05/19 17:59:41 UTC

cvs commit: jakarta-jetspeed/src/java/org/apache/jetspeed/util/template JetspeedTool.java

morciuch    2005/05/19 08:59:40

  Modified:    src/java/org/apache/jetspeed/util/template JetspeedTool.java
  Log:
  Applied missed patch for parameter styles object model change (see issue http://issues.apache.org/jira/browse/JS1-543)
  
  Revision  Changes    Path
  1.44      +73 -61    jakarta-jetspeed/src/java/org/apache/jetspeed/util/template/JetspeedTool.java
  
  Index: JetspeedTool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/util/template/JetspeedTool.java,v
  retrieving revision 1.43
  retrieving revision 1.44
  diff -u -r1.43 -r1.44
  --- JetspeedTool.java	4 May 2005 20:26:37 -0000	1.43
  +++ JetspeedTool.java	19 May 2005 15:59:40 -0000	1.44
  @@ -843,6 +843,46 @@
                           new PortalResource(entry, param),
                           JetspeedSecurity.PERMISSION_CUSTOMIZE);
   
  +				// If security does not allow access to specific parameter, allow to provide a fallback parameter
  +				if (canAccess == false)
  +                {
  +                    ParameterStyle ps = param.getParameterStyle();
  +                    String parmNameNoAccess = null;
  +                    if (ps == null)
  +                    {
  +                        parmNameNoAccess =
  +                            portlet.getPortletConfig().getInitParameter(
  +                                parmName + ".style.no-access");
  +                    }
  +                    else
  +                    {
  +                        StyleOption noaccess = ps.getOption("no-access");
  +                        if (noaccess != null)
  +                        {
  +                            parmNameNoAccess = noaccess.getValue();
  +                        }
  +                    }
  +                    if (parmNameNoAccess != null)
  +                    {
  +                        if (logger.isDebugEnabled())
  +                        {
  +                            logger.debug(
  +                                "JetspeedTool: access to parm ["
  +                                    + parmName
  +                                    + "] disallowed, redirecting to parm ["
  +                                    + parmNameNoAccess
  +                                    + "]");
  +                        }
  +                        parmName = parmNameNoAccess;
  +						param = entry.getParameter(parmName);
  +						if (param == null)
  +						{
  +							throw new Exception(
  +								"No access parameter [" + parmName + "] was not found");
  +						}
  +                    }
  +                }
  +
                   // Set parameter options        
                   Map portletParms = null;
                   String parmStyle = null;
  @@ -857,20 +897,24 @@
                   }
                   else
                   {
  -                	parmStyle = ps.getName();
  -                	portletParms = new Hashtable();
  -                	for (Iterator it = ps.getOptions().iterator(); it.hasNext();)
  -                	{ 
  -                		StyleOption so = (StyleOption) it.next();
  -                		portletParms.put(parmName + ".style." + so.getName(), so.getValue());
  -                	}
  -                	String template = ps.getTemplate(); 
  -                	if (StringUtils.isNotEmpty(template))
  -                	{
  -						portletParms.put(
  -							parmName.concat(".style.template"),
  -							template);
  -                	}
  +                    parmStyle = ps.getName();
  +                    portletParms = new Hashtable();
  +                    for (Iterator it = ps.getOptions().iterator();
  +                        it.hasNext();
  +                        )
  +                    {
  +                        StyleOption so = (StyleOption) it.next();
  +                        portletParms.put(
  +                            parmName + ".style." + so.getName(),
  +                            so.getValue());
  +                    }
  +                    String template = ps.getTemplate();
  +                    if (StringUtils.isNotEmpty(template))
  +                    {
  +                        portletParms.put(
  +                            parmName.concat(".style.template"),
  +                            template);
  +                    }
                   }
   
                   // Support for template name style
  @@ -910,52 +954,20 @@
                       }
                   }
   
  -                if (canAccess)
  -                {
  -                    if (parmStyle != null)
  -                    {
  -                        result =
  -                            ParameterLoader.getInstance().eval(
  -                                data,
  -                                parmStyle,
  -                                parmName,
  -                                parmValue,
  -                                portletParms);
  -                    }
  -                    else
  -                    {
  -                        throw new Exception("Parameter style name was not specified");
  -                    }
  -                }
  -                else
  -                {
  -                    // If security does not allow access to specific parameter, allow to provide a fallback parameter
  -                    String parmNameNoAccess =
  -                        portlet.getPortletConfig().getInitParameter(
  -                            parmName + ".style.no-access");
  -                    if (parmNameNoAccess != null)
  -                    {
  -                        if (logger.isDebugEnabled())
  -                        {
  -                            logger.debug(
  -                                "JetspeedTool: access to parm ["
  -                                    + parmName
  -                                    + "] disallowed, redirecting to parm ["
  -                                    + parmNameNoAccess
  -                                    + "]");
  -                        }
  -                        String parmStyleNoAccess =
  -                            portlet.getPortletConfig().getInitParameter(
  -                                parmNameNoAccess + ".style");
  -                        result =
  -                            ParameterLoader.getInstance().eval(
  -                                data,
  -                                parmStyleNoAccess,
  -                                parmNameNoAccess,
  -                                parmValue,
  -                                portletParms);
  -                    }
  -                }
  +				if (parmStyle != null)
  +				{
  +					result =
  +						ParameterLoader.getInstance().eval(
  +							data,
  +							parmStyle,
  +							parmName,
  +							parmValue,
  +							portletParms);
  +				}
  +				else
  +				{
  +					throw new Exception("Parameter style name was not specified");
  +				}
               }
           }
           catch (Exception e)
  
  
  

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