Author: chris.laprun(a)jboss.com
Date: 2009-05-05 10:10:01 -0400 (Tue, 05 May 2009)
New Revision: 13294
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/CustomizationManagerService.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/CustomizationManager.java
Log:
- JBPORTAL-2384:
+ Really avoid creating dashboard until needed.
+ Fixed incorrect behavior for copy to dashboard link where the link wouldn't appear
if the dashboard didn't already exist.
+ Problem with new behavior: copy to dashboard is now also present on default/default
which wasn't the case before... This
doesn't have any side effect has copy will not copy if the page already exists in
dashboard.
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java 2009-05-05
13:00:39 UTC (rev 13293)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java 2009-05-05
14:10:01 UTC (rev 13294)
@@ -1,6 +1,6 @@
/******************************************************************************
* JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * Copyright 2009, Red Hat Middleware, LLC, and individual *
* contributors as indicated by the @authors tag. See the *
* copyright.txt in the distribution for a full listing of *
* individual contributors. *
@@ -20,6 +20,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
* 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
******************************************************************************/
+
package org.jboss.portal.core.aspects.controller;
import org.apache.log4j.Logger;
@@ -39,7 +40,6 @@
import
org.jboss.portal.core.model.instance.command.action.InvokePortletInstanceRenderCommand;
import org.jboss.portal.core.model.instance.command.render.RenderPortletInstanceCommand;
import org.jboss.portal.core.model.portal.Page;
-import org.jboss.portal.core.model.portal.Portal;
import org.jboss.portal.core.model.portal.PortalObject;
import org.jboss.portal.core.model.portal.PortalObjectContainer;
import org.jboss.portal.core.model.portal.PortalObjectId;
@@ -66,10 +66,10 @@
import org.jboss.portal.theme.page.WindowContext;
import org.jboss.portal.theme.page.WindowResult;
+import java.security.Principal;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
-import java.security.Principal;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -227,6 +227,8 @@
rd.setAttribute("org.jboss.portal.header.LOGIN_URL", portalURL);
}
+ CustomizationManager cm = controller.getCustomizationManager();
+
// Edit dashboard page || Copy to dashboard link
boolean isDashboard = false;
if (cc instanceof RenderPageCommand)
@@ -247,12 +249,11 @@
}
else
{
- //
- CustomizationManager cm = controller.getCustomizationManager();
- if ((user != null) && (cm.hasDashboard(user)))
+ // Copy to dashboard link: only if page doesn't already exist in the
dashboard
+ if ((user != null))
{
- Portal dashboard = cm.getDashboard(user);
- if (dashboard.getChild(pageName) == null)
+ // if the page exists in dashboard, its id will be
dashboardId.getChildId(pageName)...
+ if
(controller.getPortalObjectContainer().getObject(cm.getDashboardIdFor(user).getChildId(pageName))
== null)
{
ImportPageToDashboardCommand iptdc = new
ImportPageToDashboardCommand(page.getId());
rd.setAttribute("org.jboss.portal.header.COPY_TO_DASHBOARD_URL", new
PortalURLImpl(iptdc, controllerCtx, null, null));
@@ -265,13 +266,9 @@
//
if (!isDashboard && user != null)
{
- Portal dashboard = controller.getCustomizationManager().getDashboard(user);
- if (dashboard != null)
- {
- ViewPortalCommand vdc = new ViewPortalCommand(dashboard.getId());
- rd.setAttribute("org.jboss.portal.header.DASHBOARD_URL", new
PortalURLImpl(vdc, controllerCtx, null, null));
- }
-
+ PortalObjectId dashboardId = cm.getDashboardIdFor(user);
+ ViewPortalCommand vdc = new ViewPortalCommand(dashboardId);
+ rd.setAttribute("org.jboss.portal.header.DASHBOARD_URL", new
PortalURLImpl(vdc, controllerCtx, null, null));
}
//
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/CustomizationManagerService.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/CustomizationManagerService.java 2009-05-05
13:00:39 UTC (rev 13293)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/CustomizationManagerService.java 2009-05-05
14:10:01 UTC (rev 13294)
@@ -1,6 +1,6 @@
/******************************************************************************
* JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * Copyright 2009, Red Hat Middleware, LLC, and individual *
* contributors as indicated by the @authors tag. See the *
* copyright.txt in the distribution for a full listing of *
* individual contributors. *
@@ -20,6 +20,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
* 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
******************************************************************************/
+
package org.jboss.portal.core.impl.model;
import org.jboss.logging.Logger;
@@ -266,17 +267,17 @@
public boolean hasDashboard(User user)
{
- Context dashboardContext = portalObjectContainer.getContext(dashboardContextId);
+ Context dashboardContext = portalObjectContainer.getContext(dashboardContextId);
- //
- String userId = getUserId(user);
+ //
+ String userId = getUserId(user);
- //
- Portal dashboardPortal = dashboardContext.getPortal(userId);
-
- return dashboardPortal != null;
+ //
+ Portal dashboardPortal = dashboardContext.getPortal(userId);
+
+ return dashboardPortal != null;
}
-
+
public Portal getDashboard(User user) throws IllegalArgumentException
{
//
@@ -363,6 +364,20 @@
}
}
+ public PortalObjectId getDashboardIdFor(User user)
+ {
+ if (user != null)
+ {
+ String userId = getUserId(user);
+
+ Context dashboardContext =
portalObjectContainer.getContext(dashboardContextId);
+
+ return dashboardContext.getId().getChildId(userId);
+ }
+
+ return null;
+ }
+
private String getUserId(User user)
{
return user.getUserName();
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/CustomizationManager.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/CustomizationManager.java 2009-05-05
13:00:39 UTC (rev 13293)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/CustomizationManager.java 2009-05-05
14:10:01 UTC (rev 13294)
@@ -1,6 +1,6 @@
/******************************************************************************
* JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * Copyright 2009, Red Hat Middleware, LLC, and individual *
* contributors as indicated by the @authors tag. See the *
* copyright.txt in the distribution for a full listing of *
* individual contributors. *
@@ -20,11 +20,13 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
* 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
******************************************************************************/
+
package org.jboss.portal.core.model;
import org.jboss.portal.core.model.instance.Instance;
import org.jboss.portal.core.model.portal.Portal;
import org.jboss.portal.core.model.portal.PortalObject;
+import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.portal.Window;
import org.jboss.portal.identity.User;
@@ -73,15 +75,23 @@
*/
boolean isDashboard(PortalObject object, User user);
- /**
- * Returns true if a dashboard exists for the user
- */
+ /** Returns true if a dashboard exists for the user */
boolean hasDashboard(User user);
-
+
/**
* Destroys the dashboard of a specified user.
*
* @param userId
*/
void destroyDashboard(String userId);
+
+ /**
+ * Retrieves the identifier for the specified user's dashboard. Note that this
doesn't imply that the dashboard
+ * actually exists. In particular, this allows for creation of URLs targeting the
user's dashboard without having to
+ * actually create the associated dashboard until it is really needed.
+ *
+ * @param user the user whose dashboard we want to get the id
+ * @return the identifier for the specified user's dashboard (whether that
dashboard exists or not)
+ */
+ PortalObjectId getDashboardIdFor(User user);
}