portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woon...@apache.org
Subject svn commit: r907690 - in /portals/jetspeed-2/applications/j2-admin/trunk/src/main: java/org/apache/jetspeed/portlets/spaces/ resources/org/apache/jetspeed/portlets/spaces/resources/ webapp/WEB-INF/ webapp/WEB-INF/view/spaces/
Date Mon, 08 Feb 2010 15:28:26 GMT
Author: woonsan
Date: Mon Feb  8 15:28:26 2010
New Revision: 907690

URL: http://svn.apache.org/viewvc?rev=907690&view=rev
Log:
JS2-1057: Adding "Edit Current Space" menu item in space navigator. Also redirecting after
updating and clean ups in space navigator view page.

Modified:
    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/java/org/apache/jetspeed/portlets/spaces/SpacesManager.java
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/spaces/resources/SpacesResources.properties
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/portlet.xml
    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/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=907690&r1=907689&r2=907690&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
Mon Feb  8 15:28:26 2010
@@ -25,11 +25,14 @@
 import javax.portlet.PortletConfig;
 import javax.portlet.PortletContext;
 import javax.portlet.PortletException;
+import javax.portlet.PortletRequest;
 import javax.portlet.RenderRequest;
 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;
@@ -47,9 +50,11 @@
 {
     public static final String ATTRIBUTE_SPACES = "spaces";
     public static final String ATTRIBUTE_SPACE = "space";
-    public static final String NEW_SPACE_PATH_PREF = "newSpacePath";
-    public static final String NEW_SPACE_PATH_DEFAULT = "/spaces.psml";
-
+    public static final String ATTRIBUTE_IS_SPACES_ADMIN = "isSpacesAdmin";
+    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;
 
@@ -57,6 +62,7 @@
     {
         super.init(config);
         PortletContext context = getPortletContext();
+        portalConfig = (PortalConfiguration) context.getAttribute(CommonPortletServices.CPS_PORTAL_CONFIGURATION);
         spacesService = (Spaces) context.getAttribute(CommonPortletServices.CPS_SPACES_SERVICE);
         if (spacesService == null)
                 throw new PortletException(
@@ -80,37 +86,54 @@
         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)
? Boolean.TRUE : Boolean.FALSE);
         super.doView(request, response);
     }
-        
+    
     public void processAction(ActionRequest actionRequest, ActionResponse actionResponse)
throws PortletException,
     IOException
     {
+        String navAction = actionRequest.getParameter("navAction");
+        Space space = null;
         String spaceName = actionRequest.getParameter(SpaceNavigator.ATTRIBUTE_SPACE);
         if (spaceName != null)
         {
-            Space space = getSpaceFromName(spaceName);
+            space = getSpaceFromName(spaceName);
+        }
+        
+        if ("addSpace".equals(navAction))
+        {
+            // TODO: make this link configurable. We need JetspeedLinks like in Jetspeed-1
+            PortletMessaging.cancel(actionRequest, SpacesManager.MSG_TOPIC_SPACE_LIST, SpacesManager.MSG_SPACE_CHANGE);
+            String spaceEditPath = actionRequest.getPreferences().getValue(SPACE_EDIT_PATH_PREF,
SPACE_EDIT_PATH_DEFAULT);                           
+            String path = admin.getPortalURL(actionRequest, actionResponse, spaceEditPath);
+            actionResponse.sendRedirect(path);
+            return;
+        }
+        else if ("editSpace".equals(navAction) && space != null)
+        {
+            if (space != null)
+            {
+                PortletMessaging.publish(actionRequest, SpacesManager.MSG_TOPIC_SPACE_LIST,
SpacesManager.MSG_SPACE_CHANGE, spaceName);
+                String spaceEditPath = actionRequest.getPreferences().getValue(SPACE_EDIT_PATH_PREF,
SPACE_EDIT_PATH_DEFAULT);                           
+                String path = admin.getPortalURL(actionRequest, actionResponse, spaceEditPath);
+                actionResponse.sendRedirect(path);
+                return;
+            }
+        }
+        else if (space != null)
+        {
             if (space != null)
             {
                 String path = admin.getPortalURL(actionRequest, actionResponse, space.getPath());
                 actionRequest.getPortletSession().setAttribute(SpaceNavigator.ATTRIBUTE_SPACE,
new SpaceBean(space));     
                 PortletMessaging.publish(actionRequest, SpacesManager.MSG_TOPIC_PAGE_NAV,
SpacesManager.MSG_SPACE_CHANGE, spaceName);
                 actionResponse.sendRedirect(path);
+                return;
             }
-            return;
-        }
-        String navAction = actionRequest.getParameter("navAction");
-        if (navAction != null)
-        {
-            // TODO: make this link configurable. We need JetspeedLinks like in Jetspeed-1
-            PortletMessaging.cancel(actionRequest, SpacesManager.MSG_TOPIC_SPACE_LIST, SpacesManager.MSG_SPACE_CHANGE);
-            String newSpacePath = actionRequest.getPreferences().getValue(NEW_SPACE_PATH_PREF,
NEW_SPACE_PATH_DEFAULT);                           
-            String path = admin.getPortalURL(actionRequest, actionResponse, newSpacePath);
-            actionResponse.sendRedirect(path);
-            return;
         }
     }    
-        
+    
     protected Space getSpaceFromName(String spaceName)
     {
         List<Space> spaces = spacesService.listSpaces();
@@ -125,7 +148,12 @@
         }
         return space;
     }
- 
+    
+    protected boolean isSpacesAdmin(PortletRequest request)
+    {
+        return request.isUserInRole(portalConfig.getString(PortalConfigurationConstants.ROLES_DEFAULT_ADMIN,
"admin"));
+    }
+    
     protected static SpaceBean findSpace(List<SpaceBean> spaces, String spaceName)
     {
         for (SpaceBean s : spaces)

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/SpacesManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/SpacesManager.java?rev=907690&r1=907689&r2=907690&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/SpacesManager.java
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/SpacesManager.java
Mon Feb  8 15:28:26 2010
@@ -211,6 +211,9 @@
 		                }		                
 		                spacesService.storeSpace(space);
                     }
+                    // redirect
+                    String path = admin.getPortalURL(actionRequest, actionResponse, space.getPath());
+                    actionResponse.sendRedirect(path);
             	}
                 PortletMessaging.publish(actionRequest, SpacesManager.MSG_TOPIC_SPACE_LIST,
SpacesManager.MSG_SPACE_CHANGE, name);                
                 PortletMessaging.publish(actionRequest, SpacesManager.MSG_TOPIC_SPACE_NAV,
SpacesManager.MSG_SPACE_CHANGE, name);

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/spaces/resources/SpacesResources.properties
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/spaces/resources/SpacesResources.properties?rev=907690&r1=907689&r2=907690&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/spaces/resources/SpacesResources.properties
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/spaces/resources/SpacesResources.properties
Mon Feb  8 15:28:26 2010
@@ -28,6 +28,7 @@
 spaces.label.edit = Edit
 spaces.label.delete = Delete
 spaces.label.add = Add Space
+spaces.label.edit.current = Edit Current Space
 spaces.label.update = Update Space
 
 spaces.pages.label.add = Add Page

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/portlet.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/portlet.xml?rev=907690&r1=907689&r2=907690&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/portlet.xml (original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/portlet.xml Mon
Feb  8 15:28:26 2010
@@ -2368,7 +2368,7 @@
     </portlet-info>
     <portlet-preferences>
       <preference>
-        <name>newSpacePath</name>
+        <name>spaceEditPath</name>
         <value>/spaces.psml</value>
       </preference>
 	</portlet-preferences>    

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=907690&r1=907689&r2=907690&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
Mon Feb  8 15:28:26 2010
@@ -28,36 +28,35 @@
 
 <portlet:defineObjects/>
 <fmt:setBundle basename="org.apache.jetspeed.portlets.spaces.resources.SpacesResources"
/>
-<%
-	SpaceBean current = ((SpaceBean)renderRequest.getAttribute("space"));
-%>
-		<ul id="nav-top">
-			<li><a href="<portlet:actionURL><portlet:param name='space' value='<%=current.getName()%>'/></portlet:actionURL>"
title="<%=current.getTitle() %>"><%=current.getTitle() %></a>
-				<ul id="spaceList">
-<%
-  int count = 0;
-  List<SpaceBean> spaces = (List<SpaceBean>)renderRequest.getAttribute("spaces");
-  
-  for (SpaceBean space : spaces) 
-  {
-      String style = null;
-      String extStyle = null;
-      if (count == 0) style = "first";
-      else if (count == spaces.size() -1) style = "last";
-      if (space.getName().equals(current.getName()))
-      {
-          extStyle = "font-weight: bold";
-      }
-%>     
-<li <% if (style != null) { %>class="<%=style%>" <% } %>><a  <%
if (extStyle != null) { %>style="<%=extStyle%>" <% } %>   href="<portlet:actionURL><portlet:param
name='space' value='<%=space.getName()%>'/></portlet:actionURL>" title="<%=space.getTitle()
%>"><%=space.getTitle() %></a></li>
-<%
-  count++;
-  }
-  if (renderRequest.isUserInRole("admin"))
-  {
-%>
-			<li class="add"><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>
-				</ul>
-			</li>
-<% } %>
-		</ul>
\ No newline at end of file
+<ul id="nav-top">
+  <li>
+    <a href="<portlet:actionURL><portlet:param name='space' value='${space.name}'/></portlet:actionURL>"
title="${space.title}">${space.title}</a>
+    <ul id="spaceList">
+      <c:forEach items="${spaces}" var="spaceItem" varStatus="status">
+        <c:set var="style" value=""/>
+        <c:set var="extStyle" value=""/>
+        <c:if test="${status.first}">
+          <c:set var="style" value="first" />
+        </c:if>
+        <c:if test="${status.last}">
+          <c:set var="style" value="last" />
+        </c:if>
+        <c:if test="${spaceItem.name == space.name}">
+          <c:set var="extStyle" value="font-weight: bold" />
+        </c:if>
+        <li class="${style}">
+          <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}">
+        <li class="separator"></li>
+        <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>
+    </ul>
+  </li>
+</ul>



---------------------------------------------------------------------
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