Author: thomas.heute(a)jboss.com
Date: 2007-04-17 09:06:55 -0400 (Tue, 17 Apr 2007)
New Revision: 6984
Removed:
trunk/core/src/bin/portal-core-war/images/catalog/T.gif
trunk/core/src/bin/portal-core-war/images/catalog/minus.gif
trunk/core/src/bin/portal-core-war/images/catalog/plus.gif
Modified:
trunk/core/src/bin/portal-core-war/images/catalog/bullet.gif
trunk/core/src/main/org/jboss/portal/core/portlet/catalog/CatalogPortlet.java
trunk/core/src/resources/portal-core-war/WEB-INF/jsp/catalog/index.jsp
Log:
Sliglthy improved the navigation portlet.
Shows only the pages accessible for the user.
Deleted: trunk/core/src/bin/portal-core-war/images/catalog/T.gif
===================================================================
(Binary files differ)
Modified: trunk/core/src/bin/portal-core-war/images/catalog/bullet.gif
===================================================================
(Binary files differ)
Deleted: trunk/core/src/bin/portal-core-war/images/catalog/minus.gif
===================================================================
(Binary files differ)
Deleted: trunk/core/src/bin/portal-core-war/images/catalog/plus.gif
===================================================================
(Binary files differ)
Modified: trunk/core/src/main/org/jboss/portal/core/portlet/catalog/CatalogPortlet.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/portlet/catalog/CatalogPortlet.java 2007-04-17
12:38:25 UTC (rev 6983)
+++
trunk/core/src/main/org/jboss/portal/core/portlet/catalog/CatalogPortlet.java 2007-04-17
13:06:55 UTC (rev 6984)
@@ -25,43 +25,49 @@
import org.jboss.portal.api.node.PortalNode;
import org.jboss.portal.api.node.PortalNodeURL;
import org.jboss.portal.core.aspects.controller.node.PortalObjectNode;
+import org.jboss.portal.core.model.portal.PortalObjectPermission;
+import org.jboss.portal.security.spi.auth.PortalAuthorizationManagerFactory;
import org.jboss.portlet.JBossPortlet;
import org.jboss.portlet.JBossRenderRequest;
import org.jboss.portlet.JBossRenderResponse;
import javax.portlet.PortletException;
import javax.portlet.PortletRequestDispatcher;
-import javax.portlet.WindowState;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
* @version $Revision$
*/
public class CatalogPortlet
extends JBossPortlet
{
-// private PortalPermissionFactory permissionFactory;
+ /** . */
+ private static final String RESOURCE_PREFIX = "PAGENAME_";
+ private PortalAuthorizationManagerFactory portalAuthorizationManagerFactory;
+
public void init() throws PortletException
{
-// permissionFactory = (PortalPermissionFactory)
getPortletContext().getAttribute("PortalPermissionFactory");
+ portalAuthorizationManagerFactory = (PortalAuthorizationManagerFactory)
getPortletContext().getAttribute("PortalAuthorizationManagerFactory");
- //
-// if(permissionFactory == null)
-// {
-// throw new PortletException("No portal permission factory");
-// }
+ if(portalAuthorizationManagerFactory == null)
+ {
+ throw new PortletException("No portal authorization manager
factory");
+ }
}
public void destroy()
{
super.destroy();
- //
-// permissionFactory = null;
+ portalAuthorizationManagerFactory = null;
}
public void render(JBossRenderRequest req, JBossRenderResponse resp) throws
IOException
@@ -69,7 +75,7 @@
resp.setContentType("text/html");
PortalNode current = req.getPortalNode();
- WindowState ws = req.getWindowState();
+// WindowState ws = req.getWindowState();
// if(WindowState.MAXIMIZED.equals(ws))
// {
// resp.setTitle("Sitemap");
@@ -89,9 +95,19 @@
// {
resp.setTitle("Pages");
PortalNode parent = current.getParent();
+
+ HashMap parentsMap = new HashMap();
+ PortalNode node = parent.getParent();
+ while (node.getType() != PortalNode.TYPE_PORTAL)
+ {
+ parentsMap.put(localize(req.getLocale(), node.getName()),
resp.createRenderURL(node));
+ node = node.getParent();
+ }
+ req.setAttribute("parents", parentsMap);
+
try
{
- req.setAttribute("parentNode", parent);
+ req.setAttribute("parentNode", localize(req.getLocale(),
parent.getName()));
HashMap parentChildMap = new HashMap();
HashMap parentSiblingMap = new HashMap();
@@ -114,16 +130,20 @@
if (child instanceof PortalObjectNode)
{
PortalObjectNode pn = (PortalObjectNode)child;
- //allowed =
permissionFactory.checkPermission("portalobject", pn.getHandle(),
"view");
- /*allowed =
getPortalAuthorizationManager().hasPermission(pn.getRef(), "view",
- PermissionTypes.PAGE);*/
- //For Now-allow
- allowed = true;
+ PortalObjectPermission perm = new
PortalObjectPermission(pn.getObjectId(), PortalObjectPermission.VIEW_MASK);
+ if
(portalAuthorizationManagerFactory.getManager().checkPermission(perm))
+ {
+ allowed = true;
+ }
+ else
+ {
+ allowed = false;
+ }
}
if (allowed)
{
PortalNodeURL childURL = resp.createRenderURL(child);
- parentChildMap.put(child.getName(), childURL);
+ parentChildMap.put(localize(req.getLocale(), child.getName()),
childURL);
}
}
}
@@ -135,16 +155,20 @@
if (parentSibling instanceof PortalObjectNode)
{
PortalObjectNode pn = (PortalObjectNode)parentSibling;
- //allowed =
permissionFactory.checkPermission("portalobject", pn.getHandle(),
"view");
- /*allowed =
getPortalAuthorizationManager().hasPermission(pn.getRef(), "view",
- PermissionTypes.PAGE);*/
- //For Now-allow
- allowed = true;
+ PortalObjectPermission perm = new
PortalObjectPermission(pn.getObjectId(), PortalObjectPermission.VIEW_MASK);
+ if
(portalAuthorizationManagerFactory.getManager().checkPermission(perm))
+ {
+ allowed = true;
+ }
+ else
+ {
+ allowed = false;
+ }
}
if (allowed)
{
PortalNodeURL parentSiblingURL =
resp.createRenderURL(parentSibling);
- parentSiblingMap.put(parentSibling.getName(), parentSiblingURL);
+ parentSiblingMap.put(localize(req.getLocale(),
parentSibling.getName()), parentSiblingURL);
}
}
}
@@ -161,10 +185,17 @@
}
// }
}
-
-// private PortalAuthorizationManager getPortalAuthorizationManager()
-// {
-// String type = PortalAuthorizationManagerFactory.JACC;
-// return PortalAuthorizationManagerFactory.getPortalAuthorizationManager(type);
-// }
+
+ private String localize(Locale locale, String name)
+ {
+ try
+ {
+ ResourceBundle rb = ResourceBundle.getBundle("conf.bundles.Resource",
locale, Thread.currentThread().getContextClassLoader());
+ name = rb.getString(RESOURCE_PREFIX + name);
+ }
+ catch (MissingResourceException e)
+ {
+ }
+ return name;
+ }
}
Modified: trunk/core/src/resources/portal-core-war/WEB-INF/jsp/catalog/index.jsp
===================================================================
--- trunk/core/src/resources/portal-core-war/WEB-INF/jsp/catalog/index.jsp 2007-04-17
12:38:25 UTC (rev 6983)
+++ trunk/core/src/resources/portal-core-war/WEB-INF/jsp/catalog/index.jsp 2007-04-17
13:06:55 UTC (rev 6984)
@@ -9,22 +9,15 @@
<%
String contextPath = request.getContextPath();
- PortalNode parent = (PortalNode) request.getAttribute("parentNode");
+ String parent = (String) request.getAttribute("parentNode");
+ HashMap parents = (HashMap) request.getAttribute("parents");
HashMap parentChildMap = (HashMap) request.getAttribute("pchild");
HashMap parentSiblingMap = (HashMap) request.getAttribute("psib");
%>
<style>
<!--
- #foldheader {
- margin-left: - 20px;
- padding: 3px 0 3px 0px;
- cursor: pointer;
- cursor: hand;
- list-style-image: url( <%= contextPath %>/images/catalog/bullet.gif );
- }
-
- #foldinglist {
+ .foldinglist {
list-style-position: outside;
margin-left: 10px;
padding: 3px 0 3px 0px;
@@ -32,7 +25,7 @@
list-style-image: url( <%= contextPath %>/images/catalog/bullet.gif )
}
- #pagenosub {
+ .pagenosub {
margin-left: - 20px;
list-style-image: url( <%= contextPath %>/images/catalog/bullet.gif )
}
@@ -42,28 +35,40 @@
-->
</style>
-<ul>
- <li id="foldheader"><div
class="portlet-form-field-label"><%= parent.getName()
%></div></li>
- <ul id="foldinglist">
- <%
- for(Iterator i = parentChildMap.keySet().iterator(); i.hasNext();)
- {
- String childName = (String) i.next();
- PortalNodeURL childURL = (PortalNodeURL) parentChildMap.get(childName);
- %>
- <li id="foldinglist"><div
class="portlet-form-field-label"><a
- href="<%= childURL.toString() %>"><%= childName
%></a></div></li>
- <%
- }
- %>
- </ul>
+<%
+String output = new String();
+for (Iterator i = parents.keySet().iterator(); i.hasNext();)
+{
+ String name = (String) i.next();
+ PortalNodeURL nodeURL = (PortalNodeURL) parents.get(name);
+ output = "<a href=\"" + nodeURL.toString() +
"\">" + name + "</a> > " + output;
+}
+output += parent;
+%>
+
+<div class="portlet-form-field-label"><%= output
%></div></li>
+
+<ul id="foldinglist">
+ <li class="pagenosub">
+ <div class="portlet-form-field-label"><%= parent
%></div></li>
+ </li>
<%
+ for(Iterator i = parentChildMap.keySet().iterator(); i.hasNext();)
+ {
+ String childName = (String) i.next();
+ PortalNodeURL childURL = (PortalNodeURL) parentChildMap.get(childName);
+ %>
+ <li class="foldinglist"><div
class="portlet-form-field-label"><a
+ href="<%= childURL.toString() %>"><%= childName
%></a></div></li>
+ <%
+ }
+
for(Iterator j = parentSiblingMap.keySet().iterator(); j.hasNext();)
{
String siblingName = (String) j.next();
PortalNodeURL siblingURL = (PortalNodeURL) parentSiblingMap.get(siblingName);
%>
- <li id="pagenosub">
+ <li class="pagenosub">
<div class="portlet-form-field-label"><a href="<%=
siblingURL.toString() %>"><%= siblingName
%></a></div></li>
<%
}