taylor 2003/01/06 00:32:06
Modified: src/java/org/apache/jetspeed/om/profile Portlets.java
src/java/org/apache/jetspeed/om/profile/psml
PsmlPortlets.java
src/java/org/apache/jetspeed/services/portaltoolkit
JetspeedPortalToolkitService.java
Log:
- Patch from Scott Weaver for bug fix #14909
Scott submitted a new Skin fallback algorithm
Revision Changes Path
1.6 +14 -1
jakarta-jetspeed/src/java/org/apache/jetspeed/om/profile/Portlets.java
Index: Portlets.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/om/profile/Portlets.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Portlets.java 27 Sep 2002 16:54:07 -0000 1.5
+++ Portlets.java 6 Jan 2003 08:32:06 -0000 1.6
@@ -128,4 +128,17 @@
* @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);
}
1.8 +36 -1
jakarta-jetspeed/src/java/org/apache/jetspeed/om/profile/psml/PsmlPortlets.java
Index: PsmlPortlets.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/om/profile/psml/PsmlPortlets.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- PsmlPortlets.java 27 Sep 2002 16:54:22 -0000 1.7
+++ PsmlPortlets.java 6 Jan 2003 08:32:06 -0000 1.8
@@ -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
@@ -88,6 +89,8 @@
/** Holds value of property securityRef. */
private SecurityReference securityRef = null;
+ private Portlets parentPortlets;
+
public PsmlPortlets()
{ }
@@ -377,4 +380,36 @@
} // 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;
+ }
+
}
1.26 +36 -9
jakarta-jetspeed/src/java/org/apache/jetspeed/services/portaltoolkit/JetspeedPortalToolkitService.java
Index: JetspeedPortalToolkitService.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/portaltoolkit/JetspeedPortalToolkitService.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- JetspeedPortalToolkitService.java 20 Nov 2002 16:32:38 -0000 1.25
+++ JetspeedPortalToolkitService.java 6 Jan 2003 08:32:06 -0000 1.26
@@ -429,6 +429,9 @@
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 +534,8 @@
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) ) );
pc.setSecurityRef( portlets.getSecurityRef() );
pc.setMetainfo( getMetaData( portlets ) );
@@ -766,5 +763,35 @@
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]>