The actual patch files:
Scott
> -----Original Message-----
> From: Glen Carl [mailto:[EMAIL PROTECTED]]
> Sent: Friday, January 03, 2003 2:36 PM
> To: Jetspeed Developers List
> Subject: Re: [PATCH] Root portlet set's skin not recognized by children
>
> Sounds very good to me. I think the new methods are a better approach. I
> look forward to trying out your new patch. Thank you for your effort and
> consideration. Please update bug 14909 when you apply your patch,
> since David was planning to work on this after Jan. 6. I think David
> will be happy too.
> Glen
>
> Weaver, Scott wrote:
> > Glen,
> >
> > I had to totally re-think my approach to this issue, as the patch I
> submitted does not pass the 4 test cases provided. However, my new
> solution does. The only thing that might stop it from being committed is
> the fact that I had to add 2 methods to the Portlets interface and in turn
> to the PsmlPortlets class:
> >
> > Portlets getParentPortlets();
> >
> > void setParentPortlets(Portlets portlets);
> >
> > This allows a Portlets collection to access its parent Portlets
> collection. Now for a simple recursive look-up can be performed to locate
> the proper skin or use the system default if no skins are defined.
> >
> > I have been using this patch all day and everything seems fine. The
> modification is not very invasive as the only class that really needed to
> implement the 2 methods was PsmlPortlets.
> >
> > Let me know if this approach sounds acceptable and I will post the
> patch.
> >
> > Scott
> >
> >
> >>-----Original Message-----
> >>From: Glen Carl [mailto:[EMAIL PROTECTED]]
> >>Sent: Tuesday, December 31, 2002 2:13 PM
> >>To: Jetspeed Developers List
> >>Subject: Re: [PATCH] Root portlet set's skin not recognized by children
> >>
> >>Scott,
> >>Below is info from bugzilla, my proposed fix and my test results on Dec.
> >>16, 2002. However, Dec. 26, 2002 David said test case 1 did not work
> >>with my proposed fix. I have not had a chance to verify. It is possible
> >>your fix is better, and you may want to run through the test cases to
> >>verify the algorithm matches what is specified in bugzilla.
> >>Thanks,
> >>Glen
> >>
> >> From bugzilla bug 14909,
> >>When resolving the skin to use on a portlet, the skin is found using the
> >>global setting, but doesn't check the parent. The algorithm should:
> >>- first check the current portlet(set), if no skin then
> >> - fallback to its parent, if no skin then
> >> - fallback to global setting
> >>
> >>proposed changes to fix issue with portlet skin use.
> >> /services/portaltoolkit/JetspeedPortalToolkitService.java
> >>protected PortletConfig getPortletConfig( Portlets portlets )
> >> if (portlets.getSkin()!=null)
> >> {
> >> pc.setPortletSkin( getSkin( portlets.getSkin() ) );
> >> }
> >> remove else
> >> remove {
> >> remove pc.setPortletSkin( getSkin( this.defaultSkin ) );
> >> remove }
> >>
> >>
> >>I ran the following tests.
> >> >
> >> > 1) no skin ref in PSML
> >> > RESULT: uses default skin
> >> >
> >> > 2) skin set a top level, no skin setting for children portlets
> >> > RESULT: children portlets use the top level skin setting
> >> >
> >> > 3) skin set at top level, and skin set in child portlet
> >> > RESULT: uses skin assigned for child portlet
> >> >
> >> > 4) no skin at top level, and skin set in child portlet
> >> > RESULT: uses skin assigned for child portlet, and all other portlets
> >>use
> >> > default
> >>
> >>
> >>--
> >>To unsubscribe, e-mail: <mailto:jetspeed-dev-
> >>[EMAIL PROTECTED]>
> >>For additional commands, e-mail: <mailto:jetspeed-dev-
> >>[EMAIL PROTECTED]>
>
>
> --
> To unsubscribe, e-mail: <mailto:jetspeed-dev-
> [EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:jetspeed-dev-
> [EMAIL PROTECTED]>
Index: Portlets.java
===================================================================
RCS file:
/home/cvspublic/jakarta-jetspeed/src/java/org/apache/jetspeed/om/profile/Portlets.java,v
retrieving revision 1.5
diff -u -r1.5 Portlets.java
--- Portlets.java 27 Sep 2002 16:54:07 -0000 1.5
+++ Portlets.java 3 Jan 2003 19:50:53 -0000
@@ -128,4 +128,16 @@
* @param securityRef New value of property securityRef.
*/
public void setSecurityRef(SecurityReference securityRef);
+
+ /**
+ * @return Portlets parent <code>Portlets</code> object for this Portlets
+collection
+ * <code>null</code> if it is the root.
+ */
+ public Portlets getParentPortlets();
+
+ /**
+ * @param Portlets Sets the parent <code>Portlets</code> collection for this
+Portlets collection
+ *
+ */
+ public void setParentPortlets(Portlets parent);
}
Index: PsmlPortlets.java
===================================================================
RCS file:
/home/cvspublic/jakarta-jetspeed/src/java/org/apache/jetspeed/om/profile/psml/PsmlPortlets.java,v
retrieving revision 1.7
diff -u -r1.7 PsmlPortlets.java
--- PsmlPortlets.java 27 Sep 2002 16:54:22 -0000 1.7
+++ PsmlPortlets.java 3 Jan 2003 20:04:32 -0000
@@ -65,6 +65,7 @@
import org.apache.jetspeed.om.profile.Portlets;
import org.apache.jetspeed.om.profile.Reference;
import org.apache.jetspeed.om.profile.Security;
+import org.apache.jetspeed.om.profile.Skin;
/**
* Base simple bean-like implementation of the Portlets interface
@@ -86,7 +87,9 @@
private Vector refs = new Vector();
/** Holds value of property securityRef. */
- private SecurityReference securityRef = null;
+ private SecurityReference securityRef = null;
+
+ private Portlets parentPortlets;
public PsmlPortlets()
{ }
@@ -376,5 +379,37 @@
return cloned;
} // clone
+
+ /**
+ * Returns the parent.
+ * @return Portlets
+ */
+ public Portlets getParentPortlets()
+ {
+ return parentPortlets;
+ }
+
+ /**
+ * Sets the parent.
+ * @param parent The parent to set
+ */
+ public void setParentPortlets(Portlets parent)
+ {
+ this.parentPortlets = parent;
+ }
+
+ /**
+ * @see org.apache.jetspeed.om.profile.IdentityElement#getSkin()
+ */
+ public Skin getSkin()
+ {
+ Skin useSkin = super.getSkin();
+ if(useSkin == null && parentPortlets != null)
+ {
+ useSkin = parentPortlets.getSkin();
+ }
+
+ return useSkin;
+ }
}
Index: JetspeedPortalToolkitService.java
===================================================================
RCS file:
/home/cvspublic/jakarta-jetspeed/src/java/org/apache/jetspeed/services/portaltoolkit/JetspeedPortalToolkitService.java,v
retrieving revision 1.25
diff -u -r1.25 JetspeedPortalToolkitService.java
--- JetspeedPortalToolkitService.java 20 Nov 2002 16:32:38 -0000 1.25
+++ JetspeedPortalToolkitService.java 3 Jan 2003 19:58:07 -0000
@@ -429,6 +429,10 @@
for (Iterator it = portlets.getPortletsIterator(); it.hasNext(); )
{
Portlets subset = (Portlets)it.next();
+ // Set this subset's parent Portlets collection.
+ subset.setParentPortlets(portlets);
+
+
Map constraints = getParameters(subset.getLayout());
int position = getPosition( subset.getLayout() );
set.addPortlet( getSet( subset, theCount ),
@@ -531,14 +535,16 @@
pc.setName( portlets.getName() );
pc.setInitParameters( getParameters( portlets ) );
- if (portlets.getSkin()!=null)
- {
- pc.setPortletSkin( getSkin( portlets.getSkin() ) );
- }
- else
- {
- pc.setPortletSkin( getSkin( this.defaultSkin ) );
- }
+ //Invocation of new skin-locating algorithim
+ pc.setPortletSkin( getSkin( findSkin(portlets) ) );
+// if (portlets.getSkin()!=null)
+// {
+// pc.setPortletSkin( getSkin( portlets.getSkin() ) );
+// }
+// else
+// {
+// pc.setPortletSkin( getSkin( this.defaultSkin ) );
+// }
pc.setSecurityRef( portlets.getSecurityRef() );
pc.setMetainfo( getMetaData( portlets ) );
@@ -766,5 +772,33 @@
return null;
}
}
+
+ /**
+ * Helps locate a skin, recursively if neccesary.
+ * <ul>
+ * <li>First: return the name of the skin defined for this <code>Portlets</code>
+ * collection.</li>
+ * <li> If the this <code>Portlets</code> collection has no skin defined, it's
+ * parent is checked, then it's parent's parent and so on until either a skin
+ * is found.</li>
+ * <li> If the previous two attempts fail the, the system default skin is
+used</li>
+ * @param Portlets portlets Portlets collection whose skin needs to be located.
+ */
+ protected String findSkin(Portlets portlets)
+ {
+ if(portlets.getSkin() != null)
+ {
+ return portlets.getSkin().getName();
+ }
+ else if(portlets.getParentPortlets() != null)
+ {
+ return findSkin(portlets.getParentPortlets());
+ }
+ else
+ {
+ return this.defaultSkin;
+ }
+ }
+
}
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
