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 2003/06/16 22:24:14 UTC
cvs commit: jakarta-jetspeed/webapp/WEB-INF/templates/vm/screens/html preview.vm
morciuch 2003/06/16 13:24:14
Modified: src/java/org/apache/jetspeed/util/template JetspeedTool.java
webapp/WEB-INF/templates/jsp/screens/html preview.jsp
webapp/WEB-INF/templates/vm GlobalMacros.vm
webapp/WEB-INF/templates/vm/portlets/html
customizer-portletset-add.vm search.vm
webapp/WEB-INF/templates/vm/screens/html preview.vm
Log:
Reimplemented JetspeedTool.getPortletFromRegistry (see Bugzilla bug# 20822).
Revision Changes Path
1.33 +91 -1 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.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- JetspeedTool.java 4 Jun 2003 15:59:13 -0000 1.32
+++ JetspeedTool.java 16 Jun 2003 20:24:14 -0000 1.33
@@ -56,9 +56,12 @@
import org.apache.ecs.ConcreteElement;
import org.apache.ecs.StringElement;
+
import org.apache.turbine.util.Log;
import org.apache.turbine.util.RunData;
import org.apache.turbine.services.pull.ApplicationTool;
+import org.apache.turbine.services.localization.Localization;
+
import org.apache.jetspeed.portal.Portlet;
import org.apache.jetspeed.portal.PortletSet;
import org.apache.jetspeed.portal.PortletControl;
@@ -81,6 +84,7 @@
import org.apache.jetspeed.services.Registry;
import org.apache.jetspeed.services.JetspeedSecurity;
import org.apache.jetspeed.portal.security.portlets.PortletWrapper;
+import org.apache.jetspeed.util.JetspeedClearElement;
import java.util.Enumeration;
import java.util.Stack;
@@ -586,6 +590,92 @@
* @param controlName
* Optional control name to use in displaying the portlet
* @return the rendered content of the portlet
+ */
+ public ConcreteElement getPortletFromRegistry(RunData data)
+ {
+
+ ConcreteElement result = null;
+ Portlet p = null;
+ String portletName = data.getParameters().getString("p");
+ String controlName = data.getParameters().getString("c");
+
+ try
+ {
+
+ // Retrieve registry entry
+ PortletEntry entry = (PortletEntry) Registry.getEntry(Registry.PORTLET, portletName);
+
+ // Verify security for the parameter
+ boolean canAccess = JetspeedSecurity.checkPermission((JetspeedUser) data.getUser(),
+ new PortalResource(entry),
+ JetspeedSecurity.PERMISSION_CUSTOMIZE);
+
+ if (canAccess)
+ {
+ // Always set portlet id to "preview" so each preview request gets it from the cache.
+ // At least, I think that's how it works.
+ p = PortletFactory.getPortlet(portletName, "preview");
+ PortletControl control = controlName == null ? PortalToolkit.getControl((String) null)
+ : PortalToolkit.getControl(controlName);
+ if (control != null)
+ {
+ JetspeedRunData jdata = (JetspeedRunData) rundata;
+ // Use the profile's skin
+ p.getPortletConfig().setPortletSkin(PortalToolkit.getSkin(jdata.getProfile().getDocument().getPortlets().getSkin()));
+ control.setPortlet(p);
+ control.init();
+ result = control.getContent(rundata);
+ }
+ else if (p != null)
+ {
+ result = p.getContent(rundata);
+ }
+ }
+ else
+ {
+ result = new JetspeedClearElement(Localization.getString("SECURITY_NO_ACCESS_TO_PORTLET"));
+ }
+ }
+ catch (Exception e)
+ {
+ Log.error(e);
+ result = new ConcreteElement();
+ }
+
+ if (result == null)
+ {
+ //the customizer already streamed its content, return a stub
+ result = new ConcreteElement();
+ }
+
+ return result;
+ }
+
+ /**
+ * Return the content of a portlet using the portlet's name. This portlet is sought in
+ * the registry. This is useful when you want to get portlet's content without
+ * actually having the portlet in user's profile (for example, to preview a portlet
+ * before adding it to the profile).
+ * <P>
+ * If a control name is specified to the portlet description, returns the defined
+ * portlet and control, otherwise use the default control.
+ * <P>
+ * Issues to resolve:
+ * <UL>
+ * <LI>is new portlet instance created everytime someone previews the same portlet?</LI>
+ * <LI>should use the same skin as the current pane</LI>
+ * <LI>if TitlePortletControl is used, the action icons (max, min, etc) are not functional.
+ * Also, customize icon should not be present.</LI>
+ * <LI> interactive portlets (such as DatabaseBrowser) lose functionality (such as sorting
+ * in DatabaseBrowser).</LI>
+ * </UL>
+ *
+ * @param portletName
+ * Name of the portlet as defined in registry
+ * @param controlName
+ * Optional control name to use in displaying the portlet
+ * @return the rendered content of the portlet
+ * @deprecated Do not use this method because it's not secure. It will be removed after Beta 5.
*/
public ConcreteElement getPortletFromRegistry(String portletName, String controlName)
{
1.2 +1 -2 jakarta-jetspeed/webapp/WEB-INF/templates/jsp/screens/html/preview.jsp
Index: preview.jsp
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/webapp/WEB-INF/templates/jsp/screens/html/preview.jsp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- preview.jsp 10 Jun 2003 17:48:09 -0000 1.1
+++ preview.jsp 16 Jun 2003 20:24:14 -0000 1.2
@@ -6,12 +6,11 @@
<%
JetspeedRunData rundata = (JetspeedRunData) request.getAttribute("rundata");
String portlet = rundata.getRequest().getParameter("p");
-String control = rundata.getRequest().getParameter("c");
if (portlet != null)
{
JetspeedTool jt = new JetspeedTool(rundata);
%>
- <%=jt.getPortletFromRegistry(portlet, control)%>
+ <%=jt.getPortletFromRegistry(rundata)%>
<%
}
else
1.11 +4 -0 jakarta-jetspeed/webapp/WEB-INF/templates/vm/GlobalMacros.vm
Index: GlobalMacros.vm
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/webapp/WEB-INF/templates/vm/GlobalMacros.vm,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- GlobalMacros.vm 21 Apr 2003 17:48:12 -0000 1.10
+++ GlobalMacros.vm 16 Jun 2003 20:24:14 -0000 1.11
@@ -141,3 +141,7 @@
## #macro (bodyOnLoad) onload="loadscript();" #end
#macro ( bodyOnLoad ) #end
+#macro (previewLink $portletName)
+ $jslink.setTemplate("preview").addQueryData("p",$PortletName).addQueryData("c","ClearPortletControl")
+#end
+
1.18 +1 -2 jakarta-jetspeed/webapp/WEB-INF/templates/vm/portlets/html/customizer-portletset-add.vm
Index: customizer-portletset-add.vm
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/webapp/WEB-INF/templates/vm/portlets/html/customizer-portletset-add.vm,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- customizer-portletset-add.vm 13 May 2003 16:00:25 -0000 1.17
+++ customizer-portletset-add.vm 16 Jun 2003 20:24:14 -0000 1.18
@@ -79,8 +79,7 @@
## Display checkbox for portlet selection
<td valign="top" align="left">
#if ($config.getBoolean("customizer.preview.enable", false) == true)
- ##<a target="_blank" href="$jslink.setRole("user","preview.psml").addQueryData("previewedPortletName",$portlet.Name).addQueryData("previewedControlName","ClearPortletControl")">#if ($portlet.Title) $portlet.Title #else $portlet.Name #end</a>
- <a target="_blank" href="$jslink.setTemplate("preview").addQueryData("p",$portlet.Name).addQueryData("c","ClearPortletControl")">#if ($portlet.Title) $portlet.Title #else $portlet.Name #end</a>
+ <a target="_blank" href="#previewLink($portlet.Name)">#if ($portlet.Title) $portlet.Title #else $portlet.Name #end</a>
#else
#if ($portlet.Title) $portlet.Title #else $portlet.Name #end
#end
1.3 +1 -1 jakarta-jetspeed/webapp/WEB-INF/templates/vm/portlets/html/search.vm
Index: search.vm
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/webapp/WEB-INF/templates/vm/portlets/html/search.vm,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- search.vm 16 Jun 2003 19:05:01 -0000 1.2
+++ search.vm 16 Jun 2003 20:24:14 -0000 1.3
@@ -36,7 +36,7 @@
<td class="$!{skin.ContentStyleClass}" align="left">
#if ($result.Type == "portlet")
<a id="preview_$listIndex"
- href="$jslink.setTemplate("preview").addQueryData("p",$result.Key).addQueryData("c","ClearPortletControl")"
+ href="#previewLink($resultKey)"
target="_blank">
<IMG border="0" SRC="$clink.setURI("images/html/is_portlet.gif")">
<span class="$!{skin.ContentStyleClass}">$result.Title</span>
1.2 +2 -4 jakarta-jetspeed/webapp/WEB-INF/templates/vm/screens/html/preview.vm
Index: preview.vm
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/webapp/WEB-INF/templates/vm/screens/html/preview.vm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- preview.vm 17 Sep 2002 20:11:55 -0000 1.1
+++ preview.vm 16 Jun 2003 20:24:14 -0000 1.2
@@ -2,7 +2,5 @@
## Turbine Velocity Screen to show just the content of a single portal element
## as specified by the request "p" parameter
## $Header$
-#set($portlet = $data.getRequest().getParameter("p"))
-#set($control = ($data.getRequest().getParameter("c")))
-$jetspeed.getPortletFromRegistry($!portlet,$!control)
+$jetspeed.getPortletFromRegistry($data)
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org