portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woon...@apache.org
Subject svn commit: r921343 - in /portals/jetspeed-2/applications/j2-admin/trunk/src/main: java/org/apache/jetspeed/portlets/spaces/ webapp/WEB-INF/view/spaces/
Date Wed, 10 Mar 2010 13:34:08 GMT
Author: woonsan
Date: Wed Mar 10 13:34:08 2010
New Revision: 921343

URL: http://svn.apache.org/viewvc?rev=921343&view=rev
Log:
JS2-1057: Checking accesses in space navigator and page navigator as follows (currently):
- a space can be created by admin user or admin role.
- a space can be edited by admin user, admin role or the space owner user.
- a page can be created by admin user, admin role or the space owner user.
- a page can be edited by admin user, admin role or the space owner user.

Modified:
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/PageNavigator.java
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/SpaceNavigator.java
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/spaces/page-navigator.jsp
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/spaces/space-navigator.jsp

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/PageNavigator.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/PageNavigator.java?rev=921343&r1=921342&r2=921343&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/PageNavigator.java
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/PageNavigator.java
Wed Mar 10 13:34:08 2010
@@ -17,6 +17,7 @@
 package org.apache.jetspeed.portlets.spaces;
 
 import java.io.IOException;
+import java.security.Principal;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -144,13 +145,25 @@ public class PageNavigator extends Gener
             request.getPortletSession().removeAttribute("links");
             request.getPortletSession().removeAttribute(SpaceNavigator.ATTRIBUTE_SPACE);
         }
-        SpaceChangeContext scc = SpaceNavigator.changeSpace(request, spacesService, newSpace);
     
-        request.setAttribute(SpaceNavigator.ATTRIBUTE_SPACE, scc.getSpace());
-        request.setAttribute(SpaceNavigator.ATTRIBUTE_SPACES, scc.getSpaces());        
+        
+        SpaceChangeContext scc = SpaceNavigator.changeSpace(request, spacesService, newSpace);
+        SpaceBean spaceBean = scc.getSpace();
+        List<SpaceBean> spaceBeans = scc.getSpaces();
+        request.setAttribute(SpaceNavigator.ATTRIBUTE_SPACE, spaceBean);
+        request.setAttribute(SpaceNavigator.ATTRIBUTE_SPACES, spaceBeans);        
         request.setAttribute(SpacesManager.MSG_TOPIC_PAGE_NAV, this);        
-        request.setAttribute("spaceMenuElements", getSpaceMenuElements(scc.getSpace(), request));
-        request.setAttribute("spaceLinkElements", getSpaceLinkMenuElements(scc.getSpace(),
request));
+        request.setAttribute("spaceMenuElements", getSpaceMenuElements(spaceBean, request));
+        request.setAttribute("spaceLinkElements", getSpaceLinkMenuElements(spaceBean, request));
         request.setAttribute("templatePages", getTemplatePageNodes(request));
+        
+        boolean pageEditable = false;
+        Principal principal = request.getUserPrincipal();
+        if (principal != null)
+        {
+            pageEditable = (admin.isUserInAdminRole(request) || admin.isAdminUser(request)
|| principal.getName().equals(spaceBean.getOwner()));
+        }
+        request.setAttribute("pageEditable", pageEditable ? Boolean.TRUE : Boolean.FALSE);
+        
         super.doView(request, response);
     }
     

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/SpaceNavigator.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/SpaceNavigator.java?rev=921343&r1=921342&r2=921343&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/SpaceNavigator.java
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/SpaceNavigator.java
Wed Mar 10 13:34:08 2010
@@ -17,6 +17,7 @@
 package org.apache.jetspeed.portlets.spaces;
 
 import java.io.IOException;
+import java.security.Principal;
 import java.util.LinkedList;
 import java.util.List;
 
@@ -31,8 +32,6 @@ import javax.portlet.RenderResponse;
 
 import org.apache.jetspeed.CommonPortletServices;
 import org.apache.jetspeed.administration.PortalAdministration;
-import org.apache.jetspeed.administration.PortalConfiguration;
-import org.apache.jetspeed.administration.PortalConfigurationConstants;
 import org.apache.jetspeed.om.folder.Folder;
 import org.apache.jetspeed.request.RequestContext;
 import org.apache.jetspeed.spaces.Space;
@@ -55,21 +54,15 @@ public class SpaceNavigator extends Gene
     public static final String SPACE_EDIT_PATH_PREF = "spaceEditPath";
     public static final String SPACE_EDIT_PATH_DEFAULT = "/spaces.psml";
     
-    private PortalConfiguration portalConfig;
 	private Spaces spacesService;
     private PortalAdministration admin;
-
+    
+    @Override
     public void init(PortletConfig config) throws PortletException
     {
         super.init(config);
         PortletContext context = getPortletContext();
         
-        portalConfig = (PortalConfiguration) context.getAttribute(CommonPortletServices.CPS_PORTAL_CONFIGURATION);
-        if (portalConfig == null)
-        {
-            throw new PortletException("Could not get instance of portal config component");
-        }
-        
         spacesService = (Spaces) context.getAttribute(CommonPortletServices.CPS_SPACES_SERVICE);
         if (spacesService == null)
         {
@@ -83,7 +76,7 @@ public class SpaceNavigator extends Gene
         }
     }
 
-    @SuppressWarnings("unchecked")
+    @Override
     public void doView(RenderRequest request, RenderResponse response)
             throws PortletException, IOException
     {    
@@ -94,14 +87,33 @@ public class SpaceNavigator extends Gene
             request.getPortletSession().removeAttribute(SpaceNavigator.ATTRIBUTE_SPACE);
         }
         SpaceChangeContext scc = changeSpace(request, spacesService, spaceName);
-        request.setAttribute(SpaceNavigator.ATTRIBUTE_SPACE, scc.getSpace());
-        request.setAttribute(SpaceNavigator.ATTRIBUTE_SPACES, scc.getSpaces());
-        request.setAttribute(SpaceNavigator.ATTRIBUTE_IS_SPACES_ADMIN, isSpacesAdmin(request,
scc.getSpace()) ? Boolean.TRUE : Boolean.FALSE);
+        SpaceBean spaceBean = scc.getSpace();
+        List<SpaceBean> spaceBeans = scc.getSpaces();
+        request.setAttribute(SpaceNavigator.ATTRIBUTE_SPACE, spaceBean);
+        request.setAttribute(SpaceNavigator.ATTRIBUTE_SPACES, spaceBeans);
+        
+        boolean spaceCreatable = false;
+        boolean spaceEditable = false;
+        Principal principal = request.getUserPrincipal();
+        if (principal != null)
+        {
+            if (admin.isUserInAdminRole(request) || admin.isAdminUser(request))
+            {
+                spaceCreatable = spaceEditable = true;
+            }
+            else if (principal.getName().equals(spaceBean.getOwner()))
+            {
+                spaceEditable = true;
+            }
+        }
+        request.setAttribute("spaceEditable", spaceEditable ? Boolean.TRUE : Boolean.FALSE);
+        request.setAttribute("spaceCreatable", spaceCreatable ? Boolean.TRUE : Boolean.FALSE);
+
         super.doView(request, response);
     }
     
-    public void processAction(ActionRequest actionRequest, ActionResponse actionResponse)
throws PortletException,
-    IOException
+    @Override
+    public void processAction(ActionRequest actionRequest, ActionResponse actionResponse)
throws PortletException, IOException
     {
         String navAction = actionRequest.getParameter("navAction");
         Space space = null;
@@ -168,21 +180,6 @@ public class SpaceNavigator extends Gene
         return space;
     }
     
-    protected boolean isSpacesAdmin(PortletRequest request, SpaceBean spaceBean)
-    {
-        if (request.isUserInRole(portalConfig.getString(PortalConfigurationConstants.ROLES_DEFAULT_ADMIN,
"admin")))
-        {
-            return true;
-        }
-        
-        if (request.getUserPrincipal() != null && request.getUserPrincipal().getName().equals(spaceBean.getOwner()))
-        {
-            return true;
-        }
-        
-        return false;
-    }
-    
     protected static SpaceBean findSpace(List<SpaceBean> spaces, String spaceName)
     {
         for (SpaceBean s : spaces)
@@ -350,6 +347,5 @@ public class SpaceNavigator extends Gene
         }
         return base.concat(path);
     }
-
     
 }
\ No newline at end of file

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/spaces/page-navigator.jsp
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/spaces/page-navigator.jsp?rev=921343&r1=921342&r2=921343&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/spaces/page-navigator.jsp
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/spaces/page-navigator.jsp
Wed Mar 10 13:34:08 2010
@@ -96,8 +96,6 @@ private void printMenuItem(MenuElement e
 
 <portlet:defineObjects/>
 <fmt:setBundle basename="org.apache.jetspeed.portlets.spaces.resources.SpacesResources"
/>
-<c:set var="authenticated" value="${not empty renderRequest.userPrincipal}"/>
-<c:set var="pageEditable" value="${authenticated}"/>
 
 <%
 RequestContext rc = (RequestContext) request.getAttribute(RequestContext.REQUEST_PORTALENV);
@@ -203,9 +201,112 @@ for (MenuElement element : linkElements)
   </span>
 </span>
 
-<script language="javascript">
-YUI().use('jetui-portal', 'io', 'json', 'node', 'plugin', 'event-mouseenter', 'node-menunav',
function(Y) {
+<div id="<portlet:namespace/>folderSelectorOverlay" style="BACKGROUND-COLOR: #eee;
BORDER-LEFT: #fff solid 2px; BORDER-TOP: #fff solid 2px; BORDER-RIGHT: #aaa solid 2px; BORDER-BOTTOM:
#aaa solid 2px; DISPLAY: none; PADDING: 10px">
+  <div class="yui-widget-hd">
+    <table border="0" width="100%" cellpadding="0" cellspacing="0">
+      <tr>
+        <td><h2>Destination folder:</h2></td>
+        <td align="right"><a id="<portlet:namespace/>folderSelectorOverlayClose"
href="#"><img border="0" alt="<fmt:message key='spaces.pages.label.close'/>" src="<%=contextPath%>/decorations/images/close.gif"/></a></td>
+      </tr>
+    </table>
+  </div>
+  <div class="yui-widget-bd"></div>
+  <div class="yui-widget-ft" align="center"><a id="<portlet:namespace/>folderSelectorOverlayCloseButton"
href="#"><fmt:message key="spaces.pages.label.close"/></a></div>
+</div>
 
+<script language="javascript">
+YUI().use('jetui-portal', 'io', 'json', 'node', 'plugin', 'event-mouseenter', 'node-menunav',
'overlay', 'anim', function(Y) {
+    
+    var folderSelectorOverlay = null;
+    
+    function AnimPlugin(config) {
+        AnimPlugin.superclass.constructor.apply(this, arguments);
+    }
+    
+    AnimPlugin.NS = "fx";
+    AnimPlugin.NAME = "animPlugin";
+    AnimPlugin.ATTRS = {
+        duration : { value: 0.1 },
+        animVisible : {
+            valueFn : function() {
+                var host = this.get("host");
+                var boundingBox = host.get("boundingBox");
+                var anim = new Y.Anim({
+                    node: boundingBox,
+                    to: { opacity: 1 },
+                    duration: this.get("duration")
+                });
+                if (!host.get("visible")) {
+                    boundingBox.setStyle("opacity", 0);
+                }
+                anim.on("destroy", function() {
+                    if (Y.UA.ie) {
+                        this.get("node").setStyle("opacity", 1);
+                    } else {
+                        this.get("node").setStyle("opacity", "");
+                    }
+                });
+                return anim;
+            }
+        },
+        animHidden : {
+            valueFn : function() {
+                return new Y.Anim({
+                    node: this.get("host").get("boundingBox"),
+                    to: { opacity: 0 },
+                    duration: this.get("duration")
+                });
+            }
+        }
+    }
+    
+    Y.extend(AnimPlugin, Y.Plugin.Base, {
+        initializer : function(config) {
+            this._bindAnimVisible();
+            this._bindAnimHidden();
+            this.after("animVisibleChange", this._bindAnimVisible);
+            this.after("animHiddenChange", this._bindAnimHidden);
+            this.doBefore("_uiSetVisible", this._uiAnimSetVisible);
+        },
+        destructor : function() {
+            this.get("animVisible").destroy();
+            this.get("animHidden").destroy();
+        },
+        _uiAnimSetVisible : function(val) {
+            if (this.get("host").get("rendered")) {
+                if (val) {
+                    this.get("animHidden").stop();
+                    this.get("animVisible").run();
+                } else {
+                    this.get("animVisible").stop();
+                    this.get("animHidden").run();
+                }
+                return new Y.Do.Prevent("AnimPlugin prevented default show/hide");
+            }
+        },
+        _uiSetVisible : function(val) {
+            var host = this.get("host");
+            var hiddenClass = host.getClassName("hidden");
+            if (!val) {
+                host.get("boundingBox").addClass(hiddenClass);
+            } else {
+                host.get("boundingBox").removeClass(hiddenClass);
+            }
+        },
+        _bindAnimVisible : function() {
+            var animVisible = this.get("animVisible");
+            animVisible.on("start", Y.bind(function() {
+                this._uiSetVisible(true);
+            }, this));
+        },
+        _bindAnimHidden : function() {
+            var animHidden = this.get("animHidden");
+            animHidden.after("end", Y.bind(function() {
+                this._uiSetVisible(false);
+            }, this));
+        }
+    });
+    
     var onMenuItemClick = function(e) {
         var a = e.target;
         var menuitem = a.get("parentNode");
@@ -327,6 +428,32 @@ YUI().use('jetui-portal', 'io', 'json', 
         if (!curNodeListItem) {
             return;
         }
+        /*
+        var point = [ e.pageX, e.pageY ];
+        var windowWidth = window.innerWidth;
+        var windowHeight = window.innerHeight;
+        
+        if (!folderSelectorOverlay) {
+            Y.Node.getDOMNode(Y.Node.one("#<portlet:namespace/>folderSelectorOverlay")).style.display
= "";
+            folderSelectorOverlay = new Y.Overlay({
+                contentBox: "#<portlet:namespace/>folderSelectorOverlay",
+                xy: [windowWidth, windowHeight],
+                visible: false,
+                plugins : [{fn:AnimPlugin, cfg:{duration:0.1}}]
+            });
+        }
+
+        var inheritDecoName = "<%=theme.getPageLayoutDecoration().getName()%>";
+        folderSelectorOverlay.set("bodyContent", "hello, world!");
+        folderSelectorOverlay.set("zIndex", 16777271);
+        var portal = (JETUI_YUI ? JETUI_YUI.getPortalInstance() : null);
+        if (portal) {
+            portal.setScreenMask(true);
+        }
+        folderSelectorOverlay.render();
+        folderSelectorOverlay.move(point);
+        folderSelectorOverlay.show();
+        */
         e.halt();
     };
     
@@ -336,6 +463,15 @@ YUI().use('jetui-portal', 'io', 'json', 
         }
         e.halt();
     };
+
+    var closeFolderSelectorOverlay = function(e) {
+        folderSelectorOverlay.hide();
+        var portal = (JETUI_YUI ? JETUI_YUI.getPortalInstance() : null);
+        if (portal) {
+            portal.setScreenMask(false);
+        }
+        e.halt();
+    };
     
     var pageNavMenu = Y.Node.one("#<portlet:namespace/>pageNavMenu");
     pageNavMenu.all("A").each(function(v, k) {
@@ -371,6 +507,7 @@ YUI().use('jetui-portal', 'io', 'json', 
     Y.Node.one("#<portlet:namespace/>nodePopupMenu_delete").on("click", onDeleteClick);
     Y.Node.one("#<portlet:namespace/>nodePopupMenu_move").on("click", onMoveClick);
     Y.Node.one("#<portlet:namespace/>nodePopupMenu_copy").on("click", onCopyClick);
-    
+    Y.Node.one("#<portlet:namespace/>folderSelectorOverlayClose").on("click", closeFolderSelectorOverlay);
+    Y.Node.one("#<portlet:namespace/>folderSelectorOverlayCloseButton").on("click",
closeFolderSelectorOverlay);
 });
 </script>

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/spaces/space-navigator.jsp
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/spaces/space-navigator.jsp?rev=921343&r1=921342&r2=921343&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/spaces/space-navigator.jsp
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/spaces/space-navigator.jsp
Wed Mar 10 13:34:08 2010
@@ -15,12 +15,12 @@ See the License for the specific languag
 limitations under the License.
 
 --%>
-<%@page import="java.util.List"%>
-<%@page import="java.text.DecimalFormat"%>
-<%@page import="java.text.NumberFormat"%>
-<%@page import="org.apache.jetspeed.portlets.spaces.SpaceBean"%>
-<%@page import="org.apache.jetspeed.om.page.Page"%>
-<%@page import="org.apache.jetspeed.CommonPortletServices"%>
+<%@ page import="java.util.List"%>
+<%@ page import="java.text.DecimalFormat"%>
+<%@ page import="java.text.NumberFormat"%>
+<%@ page import="org.apache.jetspeed.portlets.spaces.SpaceBean"%>
+<%@ page import="org.apache.jetspeed.om.page.Page"%>
+<%@ page import="org.apache.jetspeed.CommonPortletServices"%>
 <%@ page contentType="text/html" %>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
@@ -48,14 +48,18 @@ limitations under the License.
           <a style="${extStyle}" href="<portlet:actionURL><portlet:param name='space'
value='${spaceItem.name}'/></portlet:actionURL>" title="${spaceItem.title}">${spaceItem.title}</a>
         </li>
       </c:forEach>
-      <c:if test="${isSpacesAdmin}">
+      <c:if test="${spaceEditable or spaceCreatable}">
         <li class="separator"></li>
+      </c:if>
+      <c:if test="${spaceEditable}">
         <li>
           <a href="<portlet:actionURL><portlet:param name='navAction' value='editSpace'/><portlet:param
name='space' value='${space.name}'/></portlet:actionURL>" title="<fmt:message
key='spaces.label.edit.current'/>"><fmt:message key='spaces.label.edit.current'/></a>
         </li>
-        <li>
-          <a href="<portlet:actionURL><portlet:param name='navAction' value='addSpace'/></portlet:actionURL>"
title="<fmt:message key='spaces.label.add'/>"><fmt:message key='spaces.label.add'/></a>
-        </li>
+      </c:if>
+      <c:if test="${spaceCreatable}">
+      <li>
+        <a href="<portlet:actionURL><portlet:param name='navAction' value='addSpace'/></portlet:actionURL>"
title="<fmt:message key='spaces.label.add'/>"><fmt:message key='spaces.label.add'/></a>
+      </li>
       </c:if>
     </ul>
   </li>



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message