portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r918342 - in /portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces: BreadcrumbMenu.java SiteBreadcrumbMenu.java SpaceBean.java SpaceNavigator.java
Date Wed, 03 Mar 2010 07:11:10 GMT
Author: taylor
Date: Wed Mar  3 07:11:10 2010
New Revision: 918342

URL: http://svn.apache.org/viewvc?rev=918342&view=rev
Log:
jetui pipeline configured to use new PageValve, not ProfilerValve

Added:
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/SiteBreadcrumbMenu.java
      - copied, changed from r918326, portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/BreadcrumbMenu.java
Modified:
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/BreadcrumbMenu.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

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/BreadcrumbMenu.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/BreadcrumbMenu.java?rev=918342&r1=918341&r2=918342&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/BreadcrumbMenu.java
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/BreadcrumbMenu.java
Wed Mar  3 07:11:10 2010
@@ -20,7 +20,6 @@
 import java.io.Serializable;
 import java.util.LinkedList;
 import java.util.List;
-import java.util.Locale;
 import java.util.Stack;
 
 import javax.portlet.PortletConfig;
@@ -33,10 +32,6 @@
 import org.apache.jetspeed.administration.PortalAdministration;
 import org.apache.jetspeed.page.PageManager;
 import org.apache.jetspeed.page.document.Node;
-import org.apache.jetspeed.portalsite.Menu;
-import org.apache.jetspeed.portalsite.MenuElement;
-import org.apache.jetspeed.portalsite.MenuOption;
-import org.apache.jetspeed.portalsite.PortalSiteRequestContext;
 import org.apache.jetspeed.request.RequestContext;
 import org.apache.jetspeed.spaces.Spaces;
 import org.apache.portals.bridges.common.GenericServletPortlet;
@@ -49,10 +44,9 @@
  */
 public class BreadcrumbMenu extends GenericServletPortlet
 {
-    public static final String PORTAL_SITE_REQUEST_CONTEXT_ATTR_KEY = "org.apache.jetspeed.portalsite.PortalSiteRequestContext";
-    
     private Spaces spacesService;
     private PortalAdministration admin;
+    protected PageManager pageManager;    
 
     public void init(PortletConfig config) throws PortletException
     {
@@ -66,43 +60,31 @@
                 CommonPortletServices.CPS_PORTAL_ADMINISTRATION);
         if (null == admin) { throw new PortletException(
                 "Failed to find the Portal Administration on portlet initialization"); }
+        pageManager = (PageManager)context.getAttribute(CommonPortletServices.CPS_PAGE_MANAGER_COMPONENT);
+        if (null == pageManager)
+        {
+            throw new PortletException("Failed to find the Page Manager on portlet initialization");
+        }                       
     }
 
     public void doView(RenderRequest request, RenderResponse response)
             throws PortletException, IOException
     {    
         RequestContext rc = (RequestContext) request.getAttribute(RequestContext.REQUEST_PORTALENV);
-
+        Stack<BreadcrumbMenuItem> stack = new Stack<BreadcrumbMenuItem>();
+        Node node = rc.getPage().getPage().getParent();
+        while (node != null)
+        {
+            stack.push(new BreadcrumbMenuItem(node.getTitle(), admin.getPortalURL(request,
response, node.getPath())));
+            node = node.getParent();
+        } 
         List<BreadcrumbMenuItem> breadcrumbs = new LinkedList<BreadcrumbMenuItem>();
-        try
+        while (!stack.empty())
         {
-            Locale preferredLocale = rc.getLocale();
-            PortalSiteRequestContext siteRequestContext = (PortalSiteRequestContext)rc.getAttribute(PORTAL_SITE_REQUEST_CONTEXT_ATTR_KEY);
-            Menu breadcrumbsMenu = siteRequestContext.getMenu("breadcrumbs");
-            if (breadcrumbsMenu != null)
-            {
-                List<MenuElement> breadcrumbsMenuElements = breadcrumbsMenu.getElements();
-                if (breadcrumbsMenuElements != null)
-                {
-	                for (MenuElement breadcrumbMenuElement : breadcrumbsMenuElements)
-	                {
-	                    if (breadcrumbMenuElement instanceof MenuOption)
-	                    {
-	                        MenuOption breadcrumbMenuOption = (MenuOption)breadcrumbMenuElement;
-	                        String title = breadcrumbMenuOption.getTitle(preferredLocale);
-	                        String url = admin.getPortalURL(request, response, breadcrumbMenuOption.getUrl());
-	                        breadcrumbs.add(new BreadcrumbMenuItem(title, url));
-	                    }
-	                }
-                }
-            }
-        }
-        catch (Exception e)
-        {
-            e.printStackTrace();            
+            breadcrumbs.add(stack.pop());
         }
+        breadcrumbs.add(new BreadcrumbMenuItem(rc.getPage().getTitle(), admin.getPortalURL(request,
response, rc.getPage().getPath())));
         request.setAttribute("breadcrumbs", breadcrumbs);
-        
         try
         {
             super.doView(request, response);
@@ -135,4 +117,4 @@
             return path;
         }
     }
-}
\ No newline at end of file
+}

Copied: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/SiteBreadcrumbMenu.java
(from r918326, portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/BreadcrumbMenu.java)
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/SiteBreadcrumbMenu.java?p2=portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/SiteBreadcrumbMenu.java&p1=portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/BreadcrumbMenu.java&r1=918326&r2=918342&rev=918342&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/BreadcrumbMenu.java
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/spaces/SiteBreadcrumbMenu.java
Wed Mar  3 07:11:10 2010
@@ -47,7 +47,7 @@
  * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
  * @version $Id$
  */
-public class BreadcrumbMenu extends GenericServletPortlet
+public class SiteBreadcrumbMenu extends GenericServletPortlet
 {
     public static final String PORTAL_SITE_REQUEST_CONTEXT_ATTR_KEY = "org.apache.jetspeed.portalsite.PortalSiteRequestContext";
     

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=918342&r1=918341&r2=918342&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
Wed Mar  3 07:11:10 2010
@@ -28,6 +28,8 @@
 	private String theme;
 	private String constraint;
 	private boolean persisted = false;
+	private String userHomePath = null;
+	private String userHomeName = null;
 	
     public SpaceBean()
     {
@@ -98,5 +100,24 @@
 	{
 		this.constraint = constraint;
 	}
+
+	public String getUserHome()
+	{
+		return this.userHomeName;
+	}
+
+	public void setUserHomeName(String userHomeName)
+	{
+		this.userHomeName = userHomeName;
+	}
+
+	public String getUserHomePath()
+	{
+		return this.userHomePath;
+	}
 	
+	public void setUserHomePath(String homePath)
+	{
+		this.userHomePath = homePath;
+	}
 }

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=918342&r1=918341&r2=918342&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  3 07:11:10 2010
@@ -37,6 +37,7 @@
 import org.apache.jetspeed.request.RequestContext;
 import org.apache.jetspeed.spaces.Space;
 import org.apache.jetspeed.spaces.Spaces;
+import org.apache.jetspeed.spaces.SpacesException;
 import org.apache.portals.bridges.common.GenericServletPortlet;
 import org.apache.portals.messaging.PortletMessaging;
 
@@ -107,7 +108,7 @@
         String spaceName = actionRequest.getParameter(SpaceNavigator.ATTRIBUTE_SPACE);
         if (spaceName != null)
         {
-            space = getSpaceFromName(spaceName);
+            space = getSpaceFromName(spaceName, actionRequest);
         }
         
         if ("addSpace".equals(navAction))
@@ -143,9 +144,18 @@
         }
     }    
     
-    protected Space getSpaceFromName(String spaceName)
+    protected Space getSpaceFromName(String spaceName, PortletRequest request)
     {
         List<Space> spaces = spacesService.listSpaces();
+        if (request.getUserPrincipal() != null) 
+        {
+            Space home = spacesService.lookupUserSpace(request.getUserPrincipal().getName());
+        	if (home != null)
+        	{
+        		if (home.getName().equals(spaceName)) // FIXME: name unique
+        			return home;
+        	}
+        }
         Space space = null;
         for (Space sp: spaces)
         {
@@ -197,7 +207,7 @@
         return null;
     }
     
-    protected static SpaceChangeContext changeSpace(RenderRequest request, Spaces spacesService,
String spaceName )
+    protected static SpaceChangeContext changeSpace(RenderRequest request, Spaces spacesService,
String spaceName) throws PortletException
     {
         List<SpaceBean> spaces = (List<SpaceBean>)request.getPortletSession().getAttribute(SpaceNavigator.ATTRIBUTE_SPACES);
         if (spaces == null)
@@ -208,6 +218,32 @@
             for (Space s : sl)
             {
             	spaces.add(new SpaceBean(s));
+            }            
+            if (request.getUserPrincipal() != null)
+            {
+            	String username = request.getUserPrincipal().getName();
+            	Space home = spacesService.lookupUserSpace(username);
+            	if (home != null)
+            	{
+            		if (home.getOwner() == null)
+            		{
+	            		try
+	            		{
+		            		home.setOwner(username);
+		            		spacesService.storeSpace(home);
+	            		}
+	            		catch (SpacesException e)
+	            		{
+	            			throw new PortletException(e);
+	            		}
+            		}
+            		SpaceBean userHome = new SpaceBean(home);
+            		userHome.setDescription(home.getDescription());
+            		userHome.setTitle(home.getTitle());
+            		userHome.setUserHomePath(home.getPath());
+            		userHome.setUserHomeName(home.getName());
+                	spaces.add(userHome);                		
+            	}
             }
             request.getPortletSession().setAttribute(SpaceNavigator.ATTRIBUTE_SPACES, spaces);
       
         }        



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