From portal-commits at lists.jboss.org Tue Apr 17 09:06:56 2007 Content-Type: multipart/mixed; boundary="===============4692017098939051192==" MIME-Version: 1.0 From: portal-commits at lists.jboss.org To: portal-commits at lists.jboss.org Subject: [portal-commits] JBoss Portal SVN: r6984 - in trunk/core/src: main/org/jboss/portal/core/portlet/catalog and 1 other directories. Date: Tue, 17 Apr 2007 09:06:55 -0400 Message-ID: --===============4692017098939051192== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D (Binary files differ) Modified: trunk/core/src/bin/portal-core-war/images/catalog/bullet.gif =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D (Binary files differ) Deleted: trunk/core/src/bin/portal-core-war/images/catalog/minus.gif =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D (Binary files differ) Deleted: trunk/core/src/bin/portal-core-war/images/catalog/plus.gif =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D (Binary files differ) Modified: trunk/core/src/main/org/jboss/portal/core/portlet/catalog/Catalog= Portlet.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/core/src/main/org/jboss/portal/core/portlet/catalog/CatalogPortle= t.java 2007-04-17 12:38:25 UTC (rev 6983) +++ trunk/core/src/main/org/jboss/portal/core/portlet/catalog/CatalogPortle= t.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.PortalAuthorizationManagerFactor= y; 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 Julien Viet + * @author Thomas Heute * @version $Revision$ */ public class CatalogPortlet extends JBossPortlet { -// private PortalPermissionFactory permissionFactory; + /** . */ + private static final String RESOURCE_PREFIX =3D "PAGENAME_"; = + private PortalAuthorizationManagerFactory portalAuthorizationManagerFac= tory; + = public void init() throws PortletException { -// permissionFactory =3D (PortalPermissionFactory) getPortletContext(= ).getAttribute("PortalPermissionFactory"); + portalAuthorizationManagerFactory =3D (PortalAuthorizationManagerFac= tory) getPortletContext().getAttribute("PortalAuthorizationManagerFactory"); = - // -// if(permissionFactory =3D=3D null) -// { -// throw new PortletException("No portal permission factory"); -// } + if(portalAuthorizationManagerFactory =3D=3D null) + { + throw new PortletException("No portal authorization manager facto= ry"); + } } = public void destroy() { super.destroy(); = - // -// permissionFactory =3D null; + portalAuthorizationManagerFactory =3D null; } = public void render(JBossRenderRequest req, JBossRenderResponse resp) th= rows IOException @@ -69,7 +75,7 @@ resp.setContentType("text/html"); = PortalNode current =3D req.getPortalNode(); - WindowState ws =3D req.getWindowState(); +// WindowState ws =3D req.getWindowState(); // if(WindowState.MAXIMIZED.equals(ws)) // { // resp.setTitle("Sitemap"); @@ -89,9 +95,19 @@ // { resp.setTitle("Pages"); PortalNode parent =3D current.getParent(); + = + HashMap parentsMap =3D new HashMap(); + PortalNode node =3D parent.getParent(); + while (node.getType() !=3D PortalNode.TYPE_PORTAL) + { + parentsMap.put(localize(req.getLocale(), node.getName()), resp.cr= eateRenderURL(node)); + node =3D node.getParent(); + } + req.setAttribute("parents", parentsMap); + = try { - req.setAttribute("parentNode", parent); + req.setAttribute("parentNode", localize(req.getLocale(), parent.g= etName())); = HashMap parentChildMap =3D new HashMap(); HashMap parentSiblingMap =3D new HashMap(); @@ -114,16 +130,20 @@ if (child instanceof PortalObjectNode) { PortalObjectNode pn =3D (PortalObjectNode)child; - //allowed =3D permissionFactory.checkPermission= ("portalobject", pn.getHandle(), "view"); - /*allowed =3D getPortalAuthorizationManager().h= asPermission(pn.getRef(), "view", - PermissionTypes.PAGE);*/ - //For Now-allow - allowed =3D true; + PortalObjectPermission perm =3D new PortalObjec= tPermission(pn.getObjectId(), PortalObjectPermission.VIEW_MASK); + if (portalAuthorizationManagerFactory.getManage= r().checkPermission(perm)) + { + allowed =3D true; + } + else + { + allowed =3D false; + } } if (allowed) { PortalNodeURL childURL =3D resp.createRenderURL= (child); - parentChildMap.put(child.getName(), childURL); + parentChildMap.put(localize(req.getLocale(), ch= ild.getName()), childURL); } } } @@ -135,16 +155,20 @@ if (parentSibling instanceof PortalObjectNode) { PortalObjectNode pn =3D (PortalObjectNode)parentSibli= ng; - //allowed =3D permissionFactory.checkPermission("port= alobject", pn.getHandle(), "view"); - /*allowed =3D getPortalAuthorizationManager().hasPerm= ission(pn.getRef(), "view", - PermissionTypes.PAGE);*/ - //For Now-allow - allowed =3D true; + PortalObjectPermission perm =3D new PortalObjectPermi= ssion(pn.getObjectId(), PortalObjectPermission.VIEW_MASK); + if (portalAuthorizationManagerFactory.getManager().ch= eckPermission(perm)) + { + allowed =3D true; + } + else + { + allowed =3D false; + } } if (allowed) { PortalNodeURL parentSiblingURL =3D resp.createRenderU= RL(parentSibling); - parentSiblingMap.put(parentSibling.getName(), parentS= iblingURL); + parentSiblingMap.put(localize(req.getLocale(), parent= Sibling.getName()), parentSiblingURL); } } } @@ -161,10 +185,17 @@ } // } } - -// private PortalAuthorizationManager getPortalAuthorizationManager() -// { -// String type =3D PortalAuthorizationManagerFactory.JACC; -// return PortalAuthorizationManagerFactory.getPortalAuthorizationMan= ager(type); -// } + = + private String localize(Locale locale, String name) + { + try + { + ResourceBundle rb =3D ResourceBundle.getBundle("conf.bundles.Reso= urce", locale, Thread.currentThread().getContextClassLoader()); + name =3D rb.getString(RESOURCE_PREFIX + name); + } + catch (MissingResourceException e) + { + } + return name; + } } Modified: trunk/core/src/resources/portal-core-war/WEB-INF/jsp/catalog/inde= x.jsp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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 =3D request.getContextPath(); - PortalNode parent =3D (PortalNode) request.getAttribute("parentNode"); + String parent =3D (String) request.getAttribute("parentNode"); + HashMap parents =3D (HashMap) request.getAttribute("parents"); HashMap parentChildMap =3D (HashMap) request.getAttribute("pchild"); HashMap parentSiblingMap =3D (HashMap) request.getAttribute("psib"); %> = -