[jboss-svn-commits] JBoss Portal SVN: r5391 - trunk/core/src/main/org/jboss/portal/core/controller/command
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Oct 10 05:28:45 EDT 2006
Author: julien at jboss.com
Date: 2006-10-10 05:28:42 -0400 (Tue, 10 Oct 2006)
New Revision: 5391
Modified:
trunk/core/src/main/org/jboss/portal/core/controller/command/MoveWindowCommand.java
trunk/core/src/main/org/jboss/portal/core/controller/command/WindowCommand.java
Log:
reuse the isDashboard() on WindowCommand from the MoveWindowCommand
Modified: trunk/core/src/main/org/jboss/portal/core/controller/command/MoveWindowCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/command/MoveWindowCommand.java 2006-10-10 09:16:31 UTC (rev 5390)
+++ trunk/core/src/main/org/jboss/portal/core/controller/command/MoveWindowCommand.java 2006-10-10 09:28:42 UTC (rev 5391)
@@ -27,13 +27,9 @@
import org.jboss.portal.core.controller.ControllerCommand;
import org.jboss.portal.core.model.portal.PortalObject;
import org.jboss.portal.core.model.portal.Window;
-import org.jboss.portal.core.model.portal.PortalObjectPermission;
import org.jboss.portal.theme.page.WindowContext;
import org.jboss.portal.theme.navigation.PageNavigationalState;
import org.jboss.portal.theme.ThemeConstants;
-import org.jboss.portal.security.spi.auth.PortalAuthorizationManagerFactory;
-import org.jboss.portal.security.spi.auth.PortalAuthorizationManager;
-import org.jboss.portal.security.PortalSecurityException;
import java.util.Iterator;
@@ -100,54 +96,43 @@
}
}
- try
+ //
+ if (isDashboard())
{
- PortalAuthorizationManagerFactory pamf = getControllerContext().getController().getPortalAuthorizationManagerFactory();
- PortalAuthorizationManager pam = pamf.getManager();
- PortalObjectPermission perm = new PortalObjectPermission(targetId, PortalObjectPermission.DASHBOARD_MASK);
-
- //
- if (pam.checkPermission(perm))
+ for (Iterator i = page.getChildren().iterator(); i.hasNext();)
{
- for (Iterator i = page.getChildren().iterator(); i.hasNext();)
+ PortalObject child = (PortalObject)i.next();
+ if (child.getType() == PortalObject.TYPE_WINDOW)
{
- PortalObject child = (PortalObject)i.next();
- if (child.getType() == PortalObject.TYPE_WINDOW)
+ Window window = (Window)child;
+ String windowId = window.getId();
+ String regionId = window.getDeclaredProperty(ThemeConstants.PORTAL_PROP_REGION);
+ String posAsString = window.getDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER);
+ if (regionId != null && posAsString != null)
{
- Window window = (Window)child;
- String windowId = window.getId();
- String regionId = window.getDeclaredProperty(ThemeConstants.PORTAL_PROP_REGION);
- String posAsString = window.getDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER);
- if (regionId != null && posAsString != null)
+ try
{
- try
+ int pos = Integer.parseInt(posAsString);
+ if (targetId.equals(windowId))
{
- int pos = Integer.parseInt(posAsString);
- if (targetId.equals(windowId))
- {
- window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_REGION, toRegion);
- window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER, Integer.toString(toPos));
- }
- else if (fromRegion.equals(regionId) && fromPos < pos)
- {
- window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER, Integer.toString(toPos - 1));
- }
- else if (toRegion.equals(regionId) && toPos <= pos)
- {
- window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER, Integer.toString(toPos + 1));
- }
+ window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_REGION, toRegion);
+ window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER, Integer.toString(toPos));
}
- catch (NumberFormatException e)
+ else if (fromRegion.equals(regionId) && fromPos < pos)
{
+ window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER, Integer.toString(toPos - 1));
}
+ else if (toRegion.equals(regionId) && toPos <= pos)
+ {
+ window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER, Integer.toString(toPos + 1));
+ }
}
+ catch (NumberFormatException e)
+ {
+ }
}
}
}
}
- catch (PortalSecurityException e)
- {
- log.error("", e);
- }
}
}
Modified: trunk/core/src/main/org/jboss/portal/core/controller/command/WindowCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/command/WindowCommand.java 2006-10-10 09:16:31 UTC (rev 5390)
+++ trunk/core/src/main/org/jboss/portal/core/controller/command/WindowCommand.java 2006-10-10 09:28:42 UTC (rev 5391)
@@ -25,12 +25,14 @@
import org.jboss.portal.core.model.portal.Page;
import org.jboss.portal.core.model.portal.Window;
import org.jboss.portal.core.model.portal.PortalObject;
+import org.jboss.portal.core.model.portal.PortalObjectPermission;
import org.jboss.portal.core.model.instance.Instance;
import org.jboss.portal.core.model.instance.InstanceDefinition;
import org.jboss.portal.core.controller.ControllerException;
import org.jboss.portal.core.controller.ResourceNotFoundException;
import org.jboss.portal.core.controller.ControllerSecurityException;
import org.jboss.portal.security.spi.auth.PortalAuthorizationManager;
+import org.jboss.portal.security.spi.auth.PortalAuthorizationManagerFactory;
import org.jboss.portal.security.PortalSecurityException;
/**
@@ -107,15 +109,43 @@
throw new ResourceNotFoundException(window.getInstanceRef());
}
- // Get the user customization
- String customizationId = getControllerContext().getServerInvocation().getServerContext().getClientRequest().getRemoteUser();
- if (customizationId != null)
+ // Get the user customization id
+ String userId = getControllerContext().getServerInvocation().getServerContext().getClientRequest().getRemoteUser();
+ if (userId != null)
{
- instance = ((InstanceDefinition)instance).getCustomization(customizationId);
+ instance = instance.getCustomization(userId);
+
+ //
+ if (isDashboard())
+ {
+ String dashboardId = userId + targetId;
+ instance = instance.getCustomization(dashboardId);
+ }
}
}
+ private Boolean dashboard;
+ protected boolean isDashboard()
+ {
+ if (dashboard == null)
+ {
+ try
+ {
+ PortalAuthorizationManagerFactory pamf = getControllerContext().getController().getPortalAuthorizationManagerFactory();
+ PortalAuthorizationManager pam = pamf.getManager();
+ PortalObjectPermission perm = new PortalObjectPermission(targetId, PortalObjectPermission.DASHBOARD_MASK);
+ dashboard = Boolean.valueOf(pam.checkPermission(perm));
+ }
+ catch (PortalSecurityException e)
+ {
+ dashboard = Boolean.FALSE;
+ }
+ }
+ return dashboard.booleanValue();
+ }
+
+
/**
* We only enforce security at instance and component level.
*
More information about the jboss-svn-commits
mailing list