portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woon...@apache.org
Subject svn commit: r926730 - in /portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces: NodeBean.java PageNavigator.java SpaceBean.java SpaceNavigator.java SpacesList.java SpacesManager.java UserSpaceBeanList.java
Date Tue, 23 Mar 2010 18:55:35 GMT
Author: woonsan
Date: Tue Mar 23 18:55:35 2010
New Revision: 926730

URL: http://svn.apache.org/viewvc?rev=926730&view=rev
Log:
JS2-1142, JS2-1141: Fixing the problem that folder.metadata is not copied from the template
folder.
Also, changes to share space beans and to check if the session cache is for the current user
or not.

Added:
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/UserSpaceBeanList.java
  (with props)
Modified:
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/NodeBean.java
    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/SpaceBean.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/java/org/apache/jetspeed/portlets/spaces/SpacesList.java
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/SpacesManager.java

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/NodeBean.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/NodeBean.java?rev=926730&r1=926729&r2=926730&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/NodeBean.java
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/NodeBean.java
Tue Mar 23 18:55:35 2010
@@ -28,6 +28,7 @@ public class NodeBean implements Seriali
 	private String name;
 	private String path;
 	private String title;
+    private String shortTitle;
 	
 	public NodeBean()
 	{
@@ -38,6 +39,7 @@ public class NodeBean implements Seriali
 		setName(node.getName());
     	setPath(node.getPath());
     	setTitle(node.getTitle());
+        setShortTitle(node.getShortTitle());
 	}
 	
 	public String getName() 
@@ -70,6 +72,16 @@ public class NodeBean implements Seriali
 		this.title = title;
 	}
 	
+    public String getShortTitle() 
+    {
+        return shortTitle;
+    }
+    
+    public void setShortTitle(String shortTitle) 
+    {
+        this.shortTitle = shortTitle;
+    }
+	
 	@Override
 	public boolean equals(Object o)
 	{

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=926730&r1=926729&r2=926730&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
Tue Mar 23 18:55:35 2010
@@ -28,6 +28,7 @@ import javax.portlet.PortletConfig;
 import javax.portlet.PortletContext;
 import javax.portlet.PortletException;
 import javax.portlet.PortletRequest;
+import javax.portlet.PortletSession;
 import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
 import javax.servlet.http.HttpServletRequest;
@@ -148,8 +149,8 @@ public class PageNavigator extends Gener
         String newSpace = (String)PortletMessaging.consume(request, SpacesManager.MSG_TOPIC_PAGE_NAV,
SpacesManager.MSG_SPACE_CHANGE);
         if (newSpace != null)
         {
-            request.getPortletSession().removeAttribute(SpaceNavigator.ATTRIBUTE_SPACES);
-            request.getPortletSession().removeAttribute(SpaceNavigator.ATTRIBUTE_SPACE);
+            request.getPortletSession().removeAttribute(SpaceNavigator.ATTRIBUTE_SPACES,
PortletSession.APPLICATION_SCOPE);
+            request.getPortletSession().removeAttribute(SpaceNavigator.ATTRIBUTE_SPACE, PortletSession.APPLICATION_SCOPE);
         }
         
         SpaceChangeContext scc = SpaceNavigator.changeSpace(request, spacesService, newSpace);
@@ -185,7 +186,7 @@ public class PageNavigator extends Gener
         String type = actionRequest.getParameter("type");
         String templatePage = StringUtils.defaultString(actionRequest.getParameter("templatePage"),
null);
         
-        SpaceBean space = (SpaceBean) actionRequest.getPortletSession().getAttribute(SpaceNavigator.ATTRIBUTE_SPACE);
+        SpaceBean space = (SpaceBean) actionRequest.getPortletSession().getAttribute(SpaceNavigator.ATTRIBUTE_SPACE,
PortletSession.APPLICATION_SCOPE);
         
         if (space == null)
         {

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/SpaceBean.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/SpaceBean.java?rev=926730&r1=926729&r2=926730&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/SpaceBean.java
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/SpaceBean.java
Tue Mar 23 18:55:35 2010
@@ -50,6 +50,7 @@ public class SpaceBean extends NodeBean
     	setPath(s.getPath());
     	setOwner(s.getOwner());
     	setTitle(s.getTitle());
+    	setShortTitle(s.getShortTitle());
     	setDescription(s.getDescription());
     	setTheme(s.getTheme());
     	setSecurityConstraint(s.getSecurityConstraint());

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=926730&r1=926729&r2=926730&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
Tue Mar 23 18:55:35 2010
@@ -17,7 +17,6 @@
 package org.apache.jetspeed.portlets.spaces;
 
 import java.io.IOException;
-import java.util.LinkedList;
 import java.util.List;
 
 import javax.portlet.ActionRequest;
@@ -26,6 +25,7 @@ import javax.portlet.PortletConfig;
 import javax.portlet.PortletContext;
 import javax.portlet.PortletException;
 import javax.portlet.PortletRequest;
+import javax.portlet.PortletSession;
 import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
 
@@ -83,8 +83,8 @@ public class SpaceNavigator extends Gene
         String spaceName = (String)PortletMessaging.consume(request, SpacesManager.MSG_TOPIC_SPACE_NAV,
SpacesManager.MSG_SPACE_CHANGE);
         if (spaceName != null)
         {
-            request.getPortletSession().removeAttribute(SpaceNavigator.ATTRIBUTE_SPACES);
-            request.getPortletSession().removeAttribute(SpaceNavigator.ATTRIBUTE_SPACE);
+            request.getPortletSession().removeAttribute(SpaceNavigator.ATTRIBUTE_SPACES,
PortletSession.APPLICATION_SCOPE);
+            request.getPortletSession().removeAttribute(SpaceNavigator.ATTRIBUTE_SPACE, PortletSession.APPLICATION_SCOPE);
         }
         SpaceChangeContext scc = changeSpace(request, spacesService, spaceName);
         SpaceBean spaceBean = scc.getSpace();
@@ -186,20 +186,37 @@ public class SpaceNavigator extends Gene
         return null;
     }
     
+    protected static UserSpaceBeanList createSpaceBeanList(Spaces spacesService, String userName,
String env)
+    {
+        // TODO: use environment
+        List<Space> sl = spacesService.listSpaces();
+        UserSpaceBeanList spaces = new UserSpaceBeanList(userName);
+        
+        for (Space s : sl)
+        {
+            spaces.add(new SpaceBean(s));
+        }
+        
+        return spaces;
+    }
+    
+    @SuppressWarnings("unchecked")
     protected static SpaceChangeContext changeSpace(RenderRequest request, Spaces spacesService,
String spaceName) throws PortletException
     {
-        List<SpaceBean> spaces = (List<SpaceBean>)request.getPortletSession().getAttribute(SpaceNavigator.ATTRIBUTE_SPACES);
+        String userName = (request.getUserPrincipal() != null ? request.getUserPrincipal().getName()
: null);
+        UserSpaceBeanList spaces = (UserSpaceBeanList) request.getPortletSession().getAttribute(SpaceNavigator.ATTRIBUTE_SPACES,
PortletSession.APPLICATION_SCOPE);
+        
+        // Validating the spaces cache in session if it was for the same user
+        if (spaces != null && !StringUtils.equals(spaces.getUserName(), userName))
+        {
+            request.getPortletSession().removeAttribute(SpaceNavigator.ATTRIBUTE_SPACES,
PortletSession.APPLICATION_SCOPE);
+            spaces = null;
+        }
         
         if (spaces == null)
         {
             // TODO: use environment
-            List<Space> sl = spacesService.listSpaces();
-            spaces = new LinkedList<SpaceBean>();
-            
-            for (Space s : sl)
-            {
-            	spaces.add(new SpaceBean(s));
-            }
+            spaces = createSpaceBeanList(spacesService, userName, null);
             
             if (request.getUserPrincipal() != null)
             {
@@ -230,11 +247,11 @@ public class SpaceNavigator extends Gene
             	}
             }
             
-            request.getPortletSession().setAttribute(SpaceNavigator.ATTRIBUTE_SPACES, spaces);
       
+            request.getPortletSession().setAttribute(SpaceNavigator.ATTRIBUTE_SPACES, spaces,
PortletSession.APPLICATION_SCOPE);        
         }
         
         boolean changed = false;
-        SpaceBean space = (SpaceBean) request.getPortletSession().getAttribute(SpaceNavigator.ATTRIBUTE_SPACE);
+        SpaceBean space = (SpaceBean) request.getPortletSession().getAttribute(SpaceNavigator.ATTRIBUTE_SPACE,
PortletSession.APPLICATION_SCOPE);
         
         if (space == null && spaceName != null)
         {
@@ -292,7 +309,7 @@ public class SpaceNavigator extends Gene
         
         if (changed)
         {
-            request.getPortletSession().setAttribute(SpaceNavigator.ATTRIBUTE_SPACE, space);
+            request.getPortletSession().setAttribute(SpaceNavigator.ATTRIBUTE_SPACE, space,
PortletSession.APPLICATION_SCOPE);
         }
         
     	return new SpaceChangeContext(space, spaces);

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/SpacesList.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/SpacesList.java?rev=926730&r1=926729&r2=926730&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/SpacesList.java
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/SpacesList.java
Tue Mar 23 18:55:35 2010
@@ -17,17 +17,17 @@
 package org.apache.jetspeed.portlets.spaces;
 
 import java.io.IOException;
-import java.util.LinkedList;
-import java.util.List;
 
 import javax.portlet.ActionRequest;
 import javax.portlet.ActionResponse;
 import javax.portlet.PortletConfig;
 import javax.portlet.PortletContext;
 import javax.portlet.PortletException;
+import javax.portlet.PortletSession;
 import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.jetspeed.CommonPortletServices;
 import org.apache.jetspeed.portlets.toolbox.ThemeBean;
 import org.apache.jetspeed.spaces.Space;
@@ -61,20 +61,25 @@ public class SpacesList extends GenericS
     @SuppressWarnings("unchecked")
     public void doView(RenderRequest request, RenderResponse response)
             throws PortletException, IOException
-    {    
-        List<SpaceBean> spaces = (List<SpaceBean>)request.getPortletSession().getAttribute(SpaceNavigator.ATTRIBUTE_SPACES);
+    {
+        String userName = (request.getUserPrincipal() != null ? request.getUserPrincipal().getName()
: null);
+        UserSpaceBeanList spaces = (UserSpaceBeanList) request.getPortletSession().getAttribute(SpaceNavigator.ATTRIBUTE_SPACES,
PortletSession.APPLICATION_SCOPE);
+        
+        // Validating the spaces cache in session if it was for the same user
+        if (spaces != null && !StringUtils.equals(spaces.getUserName(), userName))
+        {
+            request.getPortletSession().removeAttribute(SpaceNavigator.ATTRIBUTE_SPACES,
PortletSession.APPLICATION_SCOPE);
+            spaces = null;
+        }
+        
         if (spaces == null)
         {
-            List<Space> sl = spacesService.listSpaces();
-            spaces = new LinkedList<SpaceBean>();
-            for (Space s : sl)
-            {
-            	spaces.add(new SpaceBean(s));
-            }            
+            // TODO: use environment
+            spaces = SpaceNavigator.createSpaceBeanList(spacesService, userName, null);
             request.getPortletSession().setAttribute(SpaceNavigator.ATTRIBUTE_SPACES, spaces);
       
         }       
         request.setAttribute(SpaceNavigator.ATTRIBUTE_SPACES, spaces);
-        String space = (String)request.getPortletSession().getAttribute(SpaceNavigator.ATTRIBUTE_SPACE);
       
+        String space = (String)request.getPortletSession().getAttribute(SpaceNavigator.ATTRIBUTE_SPACE,
PortletSession.APPLICATION_SCOPE);        
         request.setAttribute(SpaceNavigator.ATTRIBUTE_SPACE, space);
         try
         {
@@ -108,12 +113,12 @@ public class SpacesList extends GenericS
 					try
 					{
 						spacesService.deleteSpace(space);
-						request.getPortletSession().removeAttribute(SpaceNavigator.ATTRIBUTE_SPACES);
+						request.getPortletSession().removeAttribute(SpaceNavigator.ATTRIBUTE_SPACES, PortletSession.APPLICATION_SCOPE);
 			            PortletMessaging.cancel(request, SpacesManager.MSG_TOPIC_SPACE_LIST, SpacesManager.MSG_SPACE_CHANGE);
 		                PortletMessaging.cancel(request, SpacesManager.MSG_TOPIC_SPACE_NAV, SpacesManager.MSG_SPACE_CHANGE);
 		                PortletMessaging.cancel(request, SpacesManager.MSG_TOPIC_PAGE_NAV, SpacesManager.MSG_SPACE_CHANGE);
-		                request.getPortletSession().removeAttribute(SpaceNavigator.ATTRIBUTE_SPACES);
-		                request.getPortletSession().removeAttribute(SpaceNavigator.ATTRIBUTE_SPACE);
+		                request.getPortletSession().removeAttribute(SpaceNavigator.ATTRIBUTE_SPACES,
PortletSession.APPLICATION_SCOPE);
+		                request.getPortletSession().removeAttribute(SpaceNavigator.ATTRIBUTE_SPACE,
PortletSession.APPLICATION_SCOPE);
 		            	ThemeBean.clearThemesSession(request);		                
 					}
 					catch (SpacesException e)

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=926730&r1=926729&r2=926730&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
Tue Mar 23 18:55:35 2010
@@ -26,6 +26,7 @@ import javax.portlet.ActionResponse;
 import javax.portlet.PortletConfig;
 import javax.portlet.PortletContext;
 import javax.portlet.PortletException;
+import javax.portlet.PortletSession;
 import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
 
@@ -189,6 +190,10 @@ public class SpacesManager extends Gener
     	boolean isNew = (persisted == null || persisted.equals("0") || persisted.equalsIgnoreCase("false"));
         String name = scrapeParameter(actionRequest, "spaceName");
         String title = scrapeParameter(actionRequest, "spaceTitle");
+        if (title == null || "".equals(title.trim()))
+        {
+            title = name;
+        }
         String description = scrapeParameter(actionRequest, "spaceDescription");
         String theme = scrapeParameter(actionRequest, "theme");
         String constraint = scrapeParameter(actionRequest, "securityConstraintRef");
@@ -247,15 +252,7 @@ public class SpacesManager extends Gener
                     throw new PortletException("Space owner is not found: " + owner);
                 }
                 
-                Space space = spacesService.newSpace(spaceName, owner);
-                space.setTheme(theme);
-                space.setTitle((title == null) ? name : title);                
-                space.setDescription((description == null) ? "" : description);
-                if (!constraint.equals(""))
-                {
-                	space.setSecurityConstraint(constraint);
-                }
-                space = spacesService.storeSpaceFromTemplate(space, templateFolder);    
           
+                Space space = spacesService.createSpace(spaceName, owner, templateFolder,
title, title, description, theme, constraint);
                 // redirect
                 String path = admin.getPortalURL(actionRequest, actionResponse, space.getPath());
                 actionResponse.sendRedirect(path);
@@ -276,6 +273,7 @@ public class SpacesManager extends Gener
                 {
             		space.setDescription(description);
             		space.setTitle(title);
+            		space.setShortTitle(title);
 	                space.setTheme(theme);
 	                
 	                if (constraint.equals(""))
@@ -317,8 +315,8 @@ public class SpacesManager extends Gener
             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);
             PortletMessaging.publish(actionRequest, SpacesManager.MSG_TOPIC_PAGE_NAV, SpacesManager.MSG_SPACE_CHANGE,
name);
-            actionRequest.getPortletSession().removeAttribute(SpaceNavigator.ATTRIBUTE_SPACES);
-            actionRequest.getPortletSession().removeAttribute(SpaceNavigator.ATTRIBUTE_SPACE);
           	
+            actionRequest.getPortletSession().removeAttribute(SpaceNavigator.ATTRIBUTE_SPACES,
PortletSession.APPLICATION_SCOPE);
+            actionRequest.getPortletSession().removeAttribute(SpaceNavigator.ATTRIBUTE_SPACE,
PortletSession.APPLICATION_SCOPE);            	
         }
         catch (Exception e)
         {

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/UserSpaceBeanList.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/UserSpaceBeanList.java?rev=926730&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/UserSpaceBeanList.java
(added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/UserSpaceBeanList.java
Tue Mar 23 18:55:35 2010
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.portlets.spaces;
+
+import java.util.Collection;
+import java.util.LinkedList;
+
+/**
+ * UserSpaceBeanList
+ * 
+ * @version $Id$
+ */
+public class UserSpaceBeanList extends LinkedList<SpaceBean>
+{
+    private static final long serialVersionUID = 1L;
+    
+    private String userName;
+    
+    public UserSpaceBeanList(String userName)
+    {
+        super();
+        this.userName = userName;
+    }
+    
+    public UserSpaceBeanList(String userName, Collection<SpaceBean> c)
+    {
+        super(c);
+        this.userName = userName;
+    }
+    
+    public String getUserName()
+    {
+        return userName;
+    }
+}

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/UserSpaceBeanList.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/UserSpaceBeanList.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/UserSpaceBeanList.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



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