[jboss-svn-commits] JBoss Portal SVN: r5400 - trunk/core/src/main/org/jboss/portal/core/controller
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Oct 10 10:13:09 EDT 2006
Author: julien at jboss.com
Date: 2006-10-10 10:13:06 -0400 (Tue, 10 Oct 2006)
New Revision: 5400
Modified:
trunk/core/src/main/org/jboss/portal/core/controller/ViewDashboardCommand.java
Log:
added default page creation on no existing dashboard when user access it
Modified: trunk/core/src/main/org/jboss/portal/core/controller/ViewDashboardCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/ViewDashboardCommand.java 2006-10-10 14:02:18 UTC (rev 5399)
+++ trunk/core/src/main/org/jboss/portal/core/controller/ViewDashboardCommand.java 2006-10-10 14:13:06 UTC (rev 5400)
@@ -27,9 +27,16 @@
import org.jboss.portal.core.controller.ControllerException;
import org.jboss.portal.core.controller.ControllerSecurityException;
import org.jboss.portal.core.model.portal.Page;
+import org.jboss.portal.core.model.portal.Portal;
+import org.jboss.portal.core.model.portal.DuplicatePortalObjectException;
+import org.jboss.portal.core.model.portal.PortalObject;
+import org.jboss.portal.core.model.portal.Window;
import org.jboss.portal.security.spi.auth.PortalAuthorizationManager;
import org.jboss.portal.security.PortalSecurityException;
+import java.util.Map;
+import java.util.Iterator;
+
/**
* @author <a href="mailto:julien at jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
@@ -43,6 +50,9 @@
/** . */
private Page dashboardPage;
+ /** . */
+ private String userId;
+
public ViewDashboardCommand(String portalId)
{
super(portalId);
@@ -58,29 +68,53 @@
super.create();
//
- String userId = getControllerContext().getServerInvocation().getServerContext().getClientRequest().getRemoteUser();
+ userId = getControllerContext().getServerInvocation().getServerContext().getClientRequest().getRemoteUser();
+ }
+
+ public void enforceSecurity(PortalAuthorizationManager pam) throws ControllerSecurityException, PortalSecurityException
+ {
if (userId == null)
{
throw new ControllerSecurityException("User needs to be authenticated to view a dashboard");
}
+ }
- //
+ public void execute() throws ControllerException
+ {
dashboardPage = portal.getPage(userId);
+
+ // Create if not exist
if (dashboardPage == null)
{
- throw new IllegalArgumentException();
+ try
+ {
+ dashboardPage = portal.createPage(userId);
+ Page templatePage = (Page)portal.getParent().getChild("default").getChild("default");
+ for (Iterator i = templatePage.getChildren().iterator();i.hasNext();)
+ {
+ PortalObject child = (PortalObject)i.next();
+ if (child.getType() == PortalObject.TYPE_WINDOW)
+ {
+ Window window = (Window)child;
+ Window newWindow = dashboardPage.createWindow(window.getName());
+ newWindow.setInstanceRef(window.getInstanceRef());
+ for (Iterator j = window.getDeclaredProperties().entrySet().iterator();j.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry)j.next();
+ String name = (String)entry.getKey();
+ String value = (String)entry.getValue();
+ newWindow.setDeclaredProperty(name, value);
+ }
+ }
+ }
+ }
+ catch (DuplicatePortalObjectException e)
+ {
+ throw new ControllerException(e);
+ }
}
}
- public void enforceSecurity(PortalAuthorizationManager pam) throws ControllerSecurityException, PortalSecurityException
- {
- // We don't enforce security here but intead rely on the execution of the next render page command
- }
-
- public void execute() throws ControllerException
- {
- }
-
public Page getDashboardPage()
{
return dashboardPage;
More information about the jboss-svn-commits
mailing list