JBoss Portal SVN: r7258 - trunk/server/src/main/org/jboss/portal/server/config.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2007-05-16 08:12:21 -0400 (Wed, 16 May 2007)
New Revision: 7258
Modified:
trunk/server/src/main/org/jboss/portal/server/config/ServerConfigService.java
Log:
JBPORTAL-1400 config.xml was ignored
Modified: trunk/server/src/main/org/jboss/portal/server/config/ServerConfigService.java
===================================================================
--- trunk/server/src/main/org/jboss/portal/server/config/ServerConfigService.java 2007-05-15 21:05:56 UTC (rev 7257)
+++ trunk/server/src/main/org/jboss/portal/server/config/ServerConfigService.java 2007-05-16 12:12:21 UTC (rev 7258)
@@ -112,7 +112,7 @@
return buffer.toString();
}
- protected void createService() throws Exception
+ public void create() throws Exception
{
configResource = new CLResourceLoader().getResource(configLocation);
if (configResource.exists())
@@ -134,7 +134,7 @@
properties.put(DOMAIN_KEY, domain);
}
- protected void destroyService() throws Exception
+ public void destroy() throws Exception
{
properties.clear();
configResource = null;
18 years, 11 months
JBoss Portal SVN: r7257 - docs/trunk/referenceGuide/en/modules.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-05-15 17:05:56 -0400 (Tue, 15 May 2007)
New Revision: 7257
Modified:
docs/trunk/referenceGuide/en/modules/themeandlayouts.xml
Log:
modified doc to include the PortalURL request attributes doc
Modified: docs/trunk/referenceGuide/en/modules/themeandlayouts.xml
===================================================================
--- docs/trunk/referenceGuide/en/modules/themeandlayouts.xml 2007-05-15 21:01:36 UTC (rev 7256)
+++ docs/trunk/referenceGuide/en/modules/themeandlayouts.xml 2007-05-15 21:05:56 UTC (rev 7257)
@@ -185,14 +185,17 @@
<listitem><literal>org.jboss.portal.header.COPY_TO_DASHBOARD_URL</literal>: URL to copy a page from a portal to the personal dashboard, null if the user is on the dashboard.</listitem>
<listitem><literal>org.jboss.portal.header.SIGN_OUT_URL</literal>: URL to log out the portal.</listitem>
</itemizedlist>
+ Every attribute that is an URL attribute is an object implementing the <emphasis>org.jboss.portal.api.PortalURL</emphasis> interface.
+ Therefore it is possible to generate the URL using the <emphasis>toString()</emphasis> method and change various things related
+ to the URL.
With that in hand, if someone just wanted to display the logged-in username and a link to log out, he could write:
<programlisting><![CDATA[
<%@ page import="org.jboss.portal.identity.User" %>
<%
User user = (User) request.getAttribute("org.jboss.portal.header.USER");
- String signOutURL = (String) request.getAttribute("org.jboss.portal.header.SIGN_OUT_URL");
- String loginURL = (String) request.getAttribute("org.jboss.portal.header.LOGIN_URL");
+ PortalURL signOutURL = (PortalURL)request.getAttribute("org.jboss.portal.header.SIGN_OUT_URL");
+ PortalURL loginURL = (PortalURL)request.getAttribute("org.jboss.portal.header.LOGIN_URL");
if (user == null)
18 years, 11 months
JBoss Portal SVN: r7256 - in trunk: core/src/resources/portal-core-war/WEB-INF/jsp/header and 1 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-05-15 17:01:36 -0400 (Tue, 15 May 2007)
New Revision: 7256
Modified:
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java
trunk/core/src/resources/portal-core-war/WEB-INF/jsp/header/header.jsp
trunk/server/src/main/org/jboss/portal/server/request/URLContext.java
Log:
replace page customization String URL by a simple impl?\195?\169mentation of PortalURL which allow to lazy create URLs and also provide more programmatic control over the generated URL
Modified: trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java 2007-05-15 20:27:55 UTC (rev 7255)
+++ trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java 2007-05-15 21:01:36 UTC (rev 7256)
@@ -34,6 +34,7 @@
import org.apache.log4j.Logger;
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
+import org.jboss.portal.api.PortalURL;
import org.jboss.portal.common.servlet.BufferingRequestWrapper;
import org.jboss.portal.common.servlet.BufferingResponseWrapper;
import org.jboss.portal.core.controller.Controller;
@@ -62,6 +63,7 @@
import org.jboss.portal.security.spi.auth.PortalAuthorizationManagerFactory;
import org.jboss.portal.server.ServerInvocationContext;
import org.jboss.portal.server.request.URLContext;
+import org.jboss.portal.server.request.URLFormat;
import org.jboss.portal.theme.ThemeConstants;
import org.jboss.portal.theme.impl.render.dynamic.DynaRenderOptions;
import org.jboss.portal.theme.page.Region;
@@ -183,10 +185,7 @@
if (user == null)
{
- URLContext ctx = controllerCtx.getServerInvocation().getServerContext().getURLContext();
- ctx = URLContext.newInstance(ctx.isSecure(), true);
- String loginURL = controllerCtx.renderURL(cc, ctx, null);
- request.setAttribute("org.jboss.portal.header.LOGIN_URL", loginURL);
+ request.setAttribute("org.jboss.portal.header.LOGIN_URL", new PortalURLImpl(cc, controllerCtx, Boolean.TRUE, null));
}
// Edit dashboard page || Copy to dashboard link
@@ -205,7 +204,7 @@
PortletParametersStateString navState = new PortletParametersStateString();
navState.setValue("editPageSelect", pageName);
InvokePortletInstanceRenderCommand command = new InvokePortletInstanceRenderCommand("DashboardConfigPortletInstance", navState);
- request.setAttribute("org.jboss.portal.header.EDIT_DASHBOARD_URL", controllerCtx.renderURL(command, null, null));
+ request.setAttribute("org.jboss.portal.header.EDIT_DASHBOARD_URL", new PortalURLImpl(command, controllerCtx, null, null));
}
else
{
@@ -217,7 +216,7 @@
if (dashboard.getChild(pageName) == null)
{
ImportPageToDashboardCommand iptdc = new ImportPageToDashboardCommand(page.getId());
- request.setAttribute("org.jboss.portal.header.COPY_TO_DASHBOARD_URL", controllerCtx.renderURL(iptdc, null, null));
+ request.setAttribute("org.jboss.portal.header.COPY_TO_DASHBOARD_URL", new PortalURLImpl(iptdc, controllerCtx, null, null));
}
}
@@ -231,7 +230,7 @@
if (dashboard != null)
{
ViewPortalCommand vdc = new ViewPortalCommand(dashboard.getId());
- request.setAttribute("org.jboss.portal.header.DASHBOARD_URL", controllerCtx.renderURL(vdc, null, null));
+ request.setAttribute("org.jboss.portal.header.DASHBOARD_URL", new PortalURLImpl(vdc, controllerCtx, null, null));
}
}
@@ -254,7 +253,7 @@
if (controller.getPortalAuthorizationManagerFactory().getManager().checkPermission(perm))
{
ViewPageCommand showadmin = new ViewPageCommand(adminPortalId);
- request.setAttribute("org.jboss.portal.header.ADMIN_PORTAL_URL", controllerCtx.renderURL(showadmin, null, null));
+ request.setAttribute("org.jboss.portal.header.ADMIN_PORTAL_URL", new PortalURLImpl(showadmin, controllerCtx, null, null));
}
}
catch (PortalSecurityException e)
@@ -267,15 +266,13 @@
if (admin || isDashboard)
{
// Link to default page of default portal
- ViewPageCommand _rpc = new ViewPageCommand(defaultPortalId);
- request.setAttribute("org.jboss.portal.header.DEFAULT_PORTAL_URL", controllerCtx.renderURL(_rpc, null, null));
+ ViewPageCommand vpc = new ViewPageCommand(defaultPortalId);
+ request.setAttribute("org.jboss.portal.header.DEFAULT_PORTAL_URL", new PortalURLImpl(vpc, controllerCtx, null, null));
}
//
SignOutCommand cmd = new SignOutCommand();
- URLContext urlContext = controllerCtx.getServerInvocation().getServerContext().getURLContext();
- String logoutURL = controllerCtx.renderURL(cmd, urlContext.asNonAuthenticated(), null);
- request.setAttribute("org.jboss.portal.header.SIGN_OUT_URL", logoutURL);
+ request.setAttribute("org.jboss.portal.header.SIGN_OUT_URL", new PortalURLImpl(cmd, controllerCtx, Boolean.FALSE, null));
//
try
@@ -373,4 +370,66 @@
{
this.tabsPath = tabsPath;
}
+
+ private static class PortalURLImpl implements PortalURL
+ {
+
+ /** . */
+ private ControllerCommand command;
+
+ /** . */
+ private ControllerContext context;
+
+ /** . */
+ private Boolean wantAuthenticated;
+
+ /** . */
+ private Boolean wantSecure;
+
+ /** . */
+ private boolean relative;
+
+ /** . */
+ private String value;
+
+
+ public PortalURLImpl(ControllerCommand command, ControllerContext context, Boolean wantAuthenticated, Boolean wantSecure)
+ {
+ this.command = command;
+ this.context = context;
+ this.wantAuthenticated = wantAuthenticated;
+ this.wantSecure = wantSecure;
+ this.relative = false;
+ this.value = null;
+ }
+
+ public void setAuthenticated(Boolean wantAuthenticated)
+ {
+ this.wantAuthenticated = wantAuthenticated;
+ this.value = null;
+ }
+
+ public void setSecure(Boolean wantSecure)
+ {
+ this.wantSecure = wantSecure;
+ this.value = null;
+ }
+
+ public void setRelative(boolean relative)
+ {
+ this.relative = relative;
+ this.value = null;
+ }
+
+ public String toString()
+ {
+ if (value == null)
+ {
+ URLContext urlContext = context.getServerInvocation().getServerContext().getURLContext();
+ urlContext = urlContext.withAuthenticated(wantAuthenticated).withSecured(wantSecure);
+ value = context.renderURL(command, urlContext, URLFormat.newInstance(relative, true));
+ }
+ return value;
+ }
+ }
}
Modified: trunk/core/src/resources/portal-core-war/WEB-INF/jsp/header/header.jsp
===================================================================
--- trunk/core/src/resources/portal-core-war/WEB-INF/jsp/header/header.jsp 2007-05-15 20:27:55 UTC (rev 7255)
+++ trunk/core/src/resources/portal-core-war/WEB-INF/jsp/header/header.jsp 2007-05-15 21:01:36 UTC (rev 7256)
@@ -1,14 +1,15 @@
<%@ page import="org.jboss.portal.identity.User" %>
+<%@ page import="org.jboss.portal.api.PortalURL" %>
<%
- User user = (User) request.getAttribute("org.jboss.portal.header.USER");
- String dashboardURL = (String) request.getAttribute("org.jboss.portal.header.DASHBOARD_URL");
- String loginURL = (String) request.getAttribute("org.jboss.portal.header.LOGIN_URL");
- String defaultPortalURL = (String) request.getAttribute("org.jboss.portal.header.DEFAULT_PORTAL_URL");
- String adminPortalURL = (String) request.getAttribute("org.jboss.portal.header.ADMIN_PORTAL_URL");
- String editDashboardURL = (String) request.getAttribute("org.jboss.portal.header.EDIT_DASHBOARD_URL");
- String copyToDashboardURL = (String) request.getAttribute("org.jboss.portal.header.COPY_TO_DASHBOARD_URL");
- String signOutURL = (String) request.getAttribute("org.jboss.portal.header.SIGN_OUT_URL");
+ User user = (User)request.getAttribute("org.jboss.portal.header.USER");
+ PortalURL dashboardURL = (PortalURL)request.getAttribute("org.jboss.portal.header.DASHBOARD_URL");
+ PortalURL loginURL = (PortalURL)request.getAttribute("org.jboss.portal.header.LOGIN_URL");
+ PortalURL defaultPortalURL = (PortalURL)request.getAttribute("org.jboss.portal.header.DEFAULT_PORTAL_URL");
+ PortalURL adminPortalURL = (PortalURL)request.getAttribute("org.jboss.portal.header.ADMIN_PORTAL_URL");
+ PortalURL editDashboardURL = (PortalURL)request.getAttribute("org.jboss.portal.header.EDIT_DASHBOARD_URL");
+ PortalURL copyToDashboardURL = (PortalURL)request.getAttribute("org.jboss.portal.header.COPY_TO_DASHBOARD_URL");
+ PortalURL signOutURL = (PortalURL)request.getAttribute("org.jboss.portal.header.SIGN_OUT_URL");
%>
<%
Modified: trunk/server/src/main/org/jboss/portal/server/request/URLContext.java
===================================================================
--- trunk/server/src/main/org/jboss/portal/server/request/URLContext.java 2007-05-15 20:27:55 UTC (rev 7255)
+++ trunk/server/src/main/org/jboss/portal/server/request/URLContext.java 2007-05-15 21:01:36 UTC (rev 7256)
@@ -72,6 +72,22 @@
return authenticated;
}
+ public URLContext withSecured(Boolean wantSecure)
+ {
+ if (wantSecure == null)
+ {
+ return this;
+ }
+ else if (Boolean.TRUE == wantSecure)
+ {
+ return asSecured();
+ }
+ else
+ {
+ return asNonSecured();
+ }
+ }
+
public URLContext asSecured()
{
int newMask = mask | SEC_MASK;
@@ -84,6 +100,22 @@
return contexts[newMask];
}
+ public URLContext withAuthenticated(Boolean wantAuthenticated)
+ {
+ if (wantAuthenticated == null)
+ {
+ return this;
+ }
+ else if (Boolean.TRUE == wantAuthenticated)
+ {
+ return asAuthenticated();
+ }
+ else
+ {
+ return asNonAuthenticated();
+ }
+ }
+
public URLContext asAuthenticated()
{
int newMask = mask | AUTH_MASK;
18 years, 11 months
JBoss Portal SVN: r7255 - trunk/core/src/main/org/jboss/portal/core/impl/model/portal.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-05-15 16:27:55 -0400 (Tue, 15 May 2007)
New Revision: 7255
Modified:
trunk/core/src/main/org/jboss/portal/core/impl/model/portal/ObjectNode.java
Log:
fix issues for dashboard permission detection
Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/portal/ObjectNode.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/portal/ObjectNode.java 2007-05-15 20:15:13 UTC (rev 7254)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/portal/ObjectNode.java 2007-05-15 20:27:55 UTC (rev 7255)
@@ -319,8 +319,7 @@
}
//
- String dashboard = object.getDeclaredProperty("dashboard");
- if ("true".equals(dashboard))
+ if ("dashboard".equals(path.getNamespace()))
{
if (actions == null)
{
18 years, 11 months
JBoss Portal SVN: r7254 - in trunk/wsrp/src: resources/portal-wsrp-war/WEB-INF/jsf/consumers and 1 other directory.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2007-05-15 16:15:13 -0400 (Tue, 15 May 2007)
New Revision: 7254
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java
trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/jsf/consumers/editConsumer.xhtml
Log:
- JBPORTAL-1395: Delay synchronization of values from ConsumerBean to persisted consumer.
- Check that given values are well-formed URLs.
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java 2007-05-15 15:22:50 UTC (rev 7253)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java 2007-05-15 20:15:13 UTC (rev 7254)
@@ -25,11 +25,14 @@
import org.jboss.portal.wsrp.WSRPConsumer;
import org.jboss.portal.wsrp.consumer.ConsumerRegistry;
+import org.jboss.portal.wsrp.consumer.EndpointConfigurationInfo;
import org.jboss.portal.wsrp.consumer.ProducerInfo;
import org.jboss.portal.wsrp.consumer.RefreshResult;
import javax.faces.context.FacesContext;
import javax.faces.event.ValueChangeEvent;
+import java.net.MalformedURLException;
+import java.net.URL;
/**
* @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
@@ -42,7 +45,13 @@
private ConsumerRegistry registry;
private Boolean useWSDL = null;
private ConsumerManagerBean manager;
+ private boolean modified;
+ private String serviceDescription;
+ private String markup;
+ private String portletManagement;
+ private String registration;
+ private String wsdl;
public void setRegistry(ConsumerRegistry registry)
{
@@ -88,6 +97,11 @@
else
{
consumer = registry.getConsumer(id);
+ serviceDescription = getProducerInfo().getEndpointConfigurationInfo().getServiceDescriptionURL();
+ markup = getProducerInfo().getEndpointConfigurationInfo().getMarkupURL();
+ portletManagement = getProducerInfo().getEndpointConfigurationInfo().getPortletManagementURL();
+ registration = getProducerInfo().getEndpointConfigurationInfo().getRegistrationURL();
+ wsdl = getProducerInfo().getEndpointConfigurationInfo().getWsdlDefinitionURL();
}
}
@@ -103,51 +117,56 @@
public String getServiceDescription()
{
- return getProducerInfo().getEndpointConfigurationInfo().getServiceDescriptionURL();
+ return serviceDescription;
}
public void setServiceDescription(String sdURL)
{
- getProducerInfo().getEndpointConfigurationInfo().setServiceDescriptionURL(sdURL);
+ serviceDescription = modifyIfNeeded(serviceDescription, sdURL, "sd");
}
public String getMarkup()
{
- return getProducerInfo().getEndpointConfigurationInfo().getMarkupURL();
+ return markup;
}
public void setMarkup(String markupURL)
{
- getProducerInfo().getEndpointConfigurationInfo().setMarkupURL(markupURL);
+ markup = modifyIfNeeded(markup, markupURL, "m");
}
public String getPortletManagement()
{
- return getProducerInfo().getEndpointConfigurationInfo().getPortletManagementURL();
+ return portletManagement;
}
public void setPortletManagement(String pmURL)
{
- getProducerInfo().getEndpointConfigurationInfo().setPortletManagementURL(pmURL);
+ portletManagement = modifyIfNeeded(portletManagement, pmURL, "pm");
}
public String getRegistration()
{
- return getProducerInfo().getEndpointConfigurationInfo().getRegistrationURL();
+ return registration;
}
public void setRegistration(String rURL)
{
- getProducerInfo().getEndpointConfigurationInfo().setRegistrationURL(rURL);
+ registration = modifyIfNeeded(registration, rURL, "r");
}
public String getWsdl()
{
- return getProducerInfo().getEndpointConfigurationInfo().getWsdlDefinitionURL();
+ return wsdl;
}
public void setWsdl(String wsdlURL)
{
+ wsdl = modifyIfNeeded(wsdl, wsdlURL, "wsdl");
+ }
+
+ private void internalSetWsdl(String wsdlURL)
+ {
try
{
getProducerInfo().getEndpointConfigurationInfo().setWsdlDefinitionURL(wsdlURL);
@@ -202,11 +221,23 @@
public String update()
{
- if (consumer != null)
+ if (consumer != null && modified)
{
try
{
- registry.updateProducerInfo(getProducerInfo());
+ // update values
+ ProducerInfo prodInfo = getProducerInfo();
+ EndpointConfigurationInfo endpointInfo = prodInfo.getEndpointConfigurationInfo();
+ endpointInfo.setMarkupURL(markup);
+ endpointInfo.setServiceDescriptionURL(serviceDescription);
+ endpointInfo.setPortletManagementURL(portletManagement);
+ endpointInfo.setRegistrationURL(registration);
+ if (isUseWSDL())
+ {
+ internalSetWsdl(wsdl);
+ }
+
+ registry.updateProducerInfo(prodInfo);
}
catch (Exception e)
{
@@ -280,4 +311,30 @@
// bypass the rest of the life cycle and re-display page
FacesContext.getCurrentInstance().renderResponse();
}
+
+ private String modifyIfNeeded(String oldValue, String newValue, String target)
+ {
+ if ((oldValue != null && !oldValue.equals(newValue)) || (oldValue == null && newValue != null))
+ {
+ URL url;
+ try
+ {
+ // check that the new value is a valid URL
+ url = new URL(newValue);
+
+ oldValue = newValue;
+ modified = true;
+ }
+ catch (MalformedURLException e)
+ {
+ createErrorMessage(target, "'" + newValue + "' is not a valid URL: " + e.getLocalizedMessage());
+ }
+ finally
+ {
+ url = null;
+ }
+ }
+
+ return oldValue;
+ }
}
\ No newline at end of file
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java 2007-05-15 15:22:50 UTC (rev 7253)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java 2007-05-15 20:15:13 UTC (rev 7254)
@@ -239,7 +239,9 @@
private void setConsumerIdInSession(boolean remove)
{
Map sessionMap = FacesContext.getCurrentInstance().getExternalContext().getSessionMap();
- sessionMap.remove("consumer");
+ String consumerBeanName = "consumer"; // must match ConsumerBean name in faces-config.xml
+ sessionMap.remove(consumerBeanName); // force recreation of ConsumerBean
+
if (!remove)
{
sessionMap.put(CONSUMER_ID, selectedId);
Modified: trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/jsf/consumers/editConsumer.xhtml
===================================================================
--- trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/jsf/consumers/editConsumer.xhtml 2007-05-15 15:22:50 UTC (rev 7253)
+++ trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/jsf/consumers/editConsumer.xhtml 2007-05-15 20:15:13 UTC (rev 7254)
@@ -154,7 +154,8 @@
styleClass="portlet-form-button">
<f:param name="id" value="#{consumer.id}"/>
</h:commandLink>
- <h:commandLink action="#{consumersMgr.listConsumers}" value="Cancel" styleClass="portlet-form-button"/>
+ <h:commandLink action="#{consumersMgr.listConsumers}" value="Cancel" immediate="true"
+ styleClass="portlet-form-button"/>
</td>
</tr>
</table>
18 years, 11 months
JBoss Portal SVN: r7253 - trunk/core.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-05-15 11:22:50 -0400 (Tue, 15 May 2007)
New Revision: 7253
Modified:
trunk/core/build.xml
Log:
enable test for core
Modified: trunk/core/build.xml
===================================================================
--- trunk/core/build.xml 2007-05-15 15:02:38 UTC (rev 7252)
+++ trunk/core/build.xml 2007-05-15 15:22:50 UTC (rev 7253)
@@ -555,15 +555,11 @@
</x-sysproperty>
<x-test>
-<!--
<zest todir="${test.reports}" name="org.jboss.portal.test.core.model.portal.PortalObjectContainerTestCase"
outfile="TEST-PortalObjectContainerTestCase">
<parameter name="CacheNaturalId" value="true"/>
<parameter name="Config" value="persistent-jboss-beans.xml"/>
</zest>
--->
-
- <!--
<zest todir="${test.reports}" name="org.jboss.portal.test.core.model.portal.PortalObjectContainerTestCase"
outfile="TEST-PortalObjectContainerTestCase">
<parameter name="CacheNaturalId" value="true"/>
@@ -618,12 +614,8 @@
</zest>
<test todir="${test.reports}"
name="org.jboss.portal.test.core.deployment.JBossApplicationMetaDataFactoryTestCase"/>
--->
-
-<!--
<test todir="${test.reports}"
name="org.jboss.portal.test.core.model.portal.PortalObjectPermissionTestCase"/>
--->
<test todir="${test.reports}"
name="org.jboss.portal.test.core.model.portal.PortalObjectIdTestCase"/>
<test todir="${test.reports}"
18 years, 11 months
JBoss Portal SVN: r7252 - in trunk: core/src/main/org/jboss/portal/core/aspects/controller and 27 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-05-15 11:02:38 -0400 (Tue, 15 May 2007)
New Revision: 7252
Added:
trunk/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectIdUserType.java
trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectPath.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/ContextCommand.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/mapping/
trunk/core/src/main/org/jboss/portal/core/model/portal/command/mapping/DashboardPortalObjectPathMapper.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/mapping/DefaultPortalObjectPathMapper.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/mapping/PortalObjectPathMapper.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/view/ViewContextCommand.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/view/ViewPortalCommand.java
trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectPathTestCase.java
Removed:
trunk/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectIdImpl.java
trunk/core/src/main/org/jboss/portal/core/model/portal/DashboardCommandFactory.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/DashboardCommand.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/view/ViewDashboardCommand.java
Modified:
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/AdminPropertyResolver.java
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectIdConverter.java
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PortalAction.java
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/RenameAction.java
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/dashboard/DashboardBean.java
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/wizard/NewWindowWizard.java
trunk/core-cms/src/main/org/jboss/portal/core/cms/CMSObjectCommandFactoryService.java
trunk/core/build.xml
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxCommandFactory.java
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponseHandler.java
trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicResponseHandler.java
trunk/core/src/main/org/jboss/portal/core/controller/portlet/InvokePortletCommandFactory.java
trunk/core/src/main/org/jboss/portal/core/deployment/jboss/ObjectDeployment.java
trunk/core/src/main/org/jboss/portal/core/impl/api/node/PortalNodeURLFactory.java
trunk/core/src/main/org/jboss/portal/core/impl/model/CustomizationManagerService.java
trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java
trunk/core/src/main/org/jboss/portal/core/impl/model/portal/AbstractPortalObjectContainer.java
trunk/core/src/main/org/jboss/portal/core/impl/model/portal/ObjectNode.java
trunk/core/src/main/org/jboss/portal/core/impl/model/portal/PersistentPortalObjectContainer.java
trunk/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectImpl.java
trunk/core/src/main/org/jboss/portal/core/impl/model/portal/TransientPortalObjectContainer.java
trunk/core/src/main/org/jboss/portal/core/model/portal/DefaultPortalCommandFactory.java
trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectCommandFactory.java
trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectContainer.java
trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectId.java
trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectPermission.java
trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectURLFactory.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/PortalObjectCommand.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowActionCommand.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderPageCommand.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderWindowCommand.java
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/ContextMetaData.java
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PortalObjectMetaData.java
trunk/core/src/main/org/jboss/portal/core/model/portal/portlet/WindowContextImpl.java
trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectContainerTestCase.java
trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectIdTestCase.java
trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectPermissionTestCase.java
trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
trunk/core/src/resources/portal-core-sar/conf/data/default-object.xml
trunk/core/src/resources/portal-core-sar/conf/hibernate/portal/domain.hbm.xml
trunk/core/src/resources/portal-core-sar/dtd/portal-object_2_6.dtd
trunk/jems/src/main/org/jboss/portal/jems/hibernate/StringWrapperUserType.java
Log:
improve dashboard implementation
Modified: trunk/core/build.xml
===================================================================
--- trunk/core/build.xml 2007-05-15 12:35:46 UTC (rev 7251)
+++ trunk/core/build.xml 2007-05-15 15:02:38 UTC (rev 7252)
@@ -555,11 +555,15 @@
</x-sysproperty>
<x-test>
+<!--
<zest todir="${test.reports}" name="org.jboss.portal.test.core.model.portal.PortalObjectContainerTestCase"
outfile="TEST-PortalObjectContainerTestCase">
<parameter name="CacheNaturalId" value="true"/>
<parameter name="Config" value="persistent-jboss-beans.xml"/>
</zest>
+-->
+
+ <!--
<zest todir="${test.reports}" name="org.jboss.portal.test.core.model.portal.PortalObjectContainerTestCase"
outfile="TEST-PortalObjectContainerTestCase">
<parameter name="CacheNaturalId" value="true"/>
@@ -614,10 +618,17 @@
</zest>
<test todir="${test.reports}"
name="org.jboss.portal.test.core.deployment.JBossApplicationMetaDataFactoryTestCase"/>
+-->
+
+<!--
<test todir="${test.reports}"
name="org.jboss.portal.test.core.model.portal.PortalObjectPermissionTestCase"/>
+-->
<test todir="${test.reports}"
name="org.jboss.portal.test.core.model.portal.PortalObjectIdTestCase"/>
+ <test todir="${test.reports}"
+ name="org.jboss.portal.test.core.model.portal.PortalObjectPathTestCase"/>
+
</x-test>
<x-classpath>
<pathelement location="${build.lib}/portal-core-lib.jar"/>
Modified: trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java 2007-05-15 12:35:46 UTC (rev 7251)
+++ trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -49,10 +49,11 @@
import org.jboss.portal.core.model.portal.PortalObject;
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.portal.PortalObjectPermission;
+import org.jboss.portal.core.model.portal.PortalObjectPath;
import org.jboss.portal.core.model.portal.command.action.ImportPageToDashboardCommand;
import org.jboss.portal.core.model.portal.command.render.RenderPageCommand;
-import org.jboss.portal.core.model.portal.command.view.ViewDashboardCommand;
import org.jboss.portal.core.model.portal.command.view.ViewPageCommand;
+import org.jboss.portal.core.model.portal.command.view.ViewPortalCommand;
import org.jboss.portal.core.theme.PageRendition;
import org.jboss.portal.core.aspects.controller.node.Navigation;
import org.jboss.portal.identity.User;
@@ -79,6 +80,12 @@
private static Logger log = Logger.getLogger(PageCustomizerInterceptor.class);
/** . */
+ private static final PortalObjectId defaultPortalId = PortalObjectId.parse("/default/default", PortalObjectPath.CANONICAL_FORMAT);
+
+ /** . */
+ private static PortalObjectId adminPortalId = PortalObjectId.parse("/admin", PortalObjectPath.CANONICAL_FORMAT);
+
+ /** . */
private String targetContextPath;
/** . */
@@ -155,7 +162,6 @@
public String injectDashboardNav(ControllerCommand cc)
{
- StringBuffer sb = new StringBuffer();
ControllerContext controllerCtx = cc.getControllerContext();
ServerInvocationContext serverContext = controllerCtx.getServerInvocation().getServerContext();
ServletContext servletContext = serverContext.getClientRequest().getSession().getServletContext().getContext(targetContextPath);
@@ -219,10 +225,15 @@
}
//
- if (! isDashboard)
+ if (!isDashboard && user != null)
{
- ViewDashboardCommand vdc = new ViewDashboardCommand();
- request.setAttribute("org.jboss.portal.header.DASHBOARD_URL", controllerCtx.renderURL(vdc, null, null));
+ Portal dashboard = controller.getCustomizationManager().getDashboard(user);
+ if (dashboard != null)
+ {
+ ViewPortalCommand vdc = new ViewPortalCommand(dashboard.getId());
+ request.setAttribute("org.jboss.portal.header.DASHBOARD_URL", controllerCtx.renderURL(vdc, null, null));
+ }
+
}
//
@@ -237,12 +248,12 @@
//
if (!admin || isDashboard)
{
- PortalObjectPermission perm = new PortalObjectPermission(new PortalObjectId(new String[]{"admin"}), PortalObjectPermission.VIEW_MASK);
+ PortalObjectPermission perm = new PortalObjectPermission(adminPortalId, PortalObjectPermission.VIEW_MASK);
try
{
if (controller.getPortalAuthorizationManagerFactory().getManager().checkPermission(perm))
{
- ViewPageCommand showadmin = new ViewPageCommand(new PortalObjectId(new String[]{"admin"}));
+ ViewPageCommand showadmin = new ViewPageCommand(adminPortalId);
request.setAttribute("org.jboss.portal.header.ADMIN_PORTAL_URL", controllerCtx.renderURL(showadmin, null, null));
}
}
@@ -256,7 +267,7 @@
if (admin || isDashboard)
{
// Link to default page of default portal
- ViewPageCommand _rpc = new ViewPageCommand(new PortalObjectId(new String[]{"default", "default"}));
+ ViewPageCommand _rpc = new ViewPageCommand(defaultPortalId);
request.setAttribute("org.jboss.portal.header.DEFAULT_PORTAL_URL", controllerCtx.renderURL(_rpc, null, null));
}
Modified: trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxCommandFactory.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxCommandFactory.java 2007-05-15 12:35:46 UTC (rev 7251)
+++ trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxCommandFactory.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -26,6 +26,7 @@
import org.jboss.portal.core.controller.ControllerCommand;
import org.jboss.portal.core.controller.ControllerContext;
import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.portal.PortalObjectPath;
import org.jboss.portal.core.model.portal.command.action.MoveWindowCommand;
import org.jboss.portal.server.ServerInvocation;
@@ -52,7 +53,7 @@
int toPosInt = Integer.parseInt(toPos);
//
- PortalObjectId tmp = PortalObjectId.parse(windowId, PortalObjectId.LEGACY_BASE64_FORMAT);
+ PortalObjectId tmp = PortalObjectId.parse(windowId, PortalObjectPath.LEGACY_BASE64_FORMAT);
//
return new MoveWindowCommand(tmp, fromPosInt, fromRegion, toPosInt, toRegion);
Modified: trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponseHandler.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponseHandler.java 2007-05-15 12:35:46 UTC (rev 7251)
+++ trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponseHandler.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -42,6 +42,7 @@
import org.jboss.portal.core.model.portal.PortalObject;
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.portal.PortalObjectContainer;
+import org.jboss.portal.core.model.portal.PortalObjectPath;
import org.jboss.portal.core.model.portal.navstate.PortalObjectNavigationalStateContext;
import org.jboss.portal.core.model.portal.navstate.WindowNavigationalState;
import org.jboss.portal.core.navstate.NavigationalStateChange;
@@ -301,7 +302,7 @@
//
WindowContext wc = new WindowContext(
- _window.getId().toString(PortalObjectId.LEGACY_BASE64_FORMAT),
+ _window.getId().toString(PortalObjectPath.LEGACY_BASE64_FORMAT),
_window.getProperty(ThemeConstants.PORTAL_PROP_REGION),
0,
windowResult);
Modified: trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicResponseHandler.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicResponseHandler.java 2007-05-15 12:35:46 UTC (rev 7251)
+++ trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicResponseHandler.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -44,6 +44,7 @@
import org.jboss.portal.core.model.portal.PortalObjectContainer;
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.portal.PortalObjectResponseHandler;
+import org.jboss.portal.core.model.portal.PortalObjectPath;
import org.jboss.portal.core.model.portal.command.view.ViewPageCommand;
import org.jboss.portal.core.model.instance.PortletInstanceResponseHandler;
import org.jboss.portal.web.ServletContextDispatcher;
@@ -59,7 +60,8 @@
public class ClassicResponseHandler extends AbstractResponseHandler
{
- private static final PortalObjectId defaultPortalPath = PortalObjectId.parse("/default", PortalObjectId.CANONICAL_FORMAT);
+ /** . */
+ private static final PortalObjectId DEFAULT_PORTAL_PATH = PortalObjectId.parse("/default", PortalObjectPath.CANONICAL_FORMAT);
public HandlerResponse processCommandResponse(
ControllerContext controllerContext,
@@ -136,7 +138,7 @@
if (location == null)
{
PortalObjectContainer portalObjectContainer = controllerContext.getController().getPortalObjectContainer();
- Portal portal = (Portal)portalObjectContainer.getObject(defaultPortalPath);
+ Portal portal = (Portal)portalObjectContainer.getObject(DEFAULT_PORTAL_PATH);
ViewPageCommand renderCmd = new ViewPageCommand(portal.getId());
URLContext urlContext = invocation.getServerContext().getURLContext();
location = controllerContext.renderURL(renderCmd, urlContext.asNonAuthenticated(), null);
Modified: trunk/core/src/main/org/jboss/portal/core/controller/portlet/InvokePortletCommandFactory.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/portlet/InvokePortletCommandFactory.java 2007-05-15 12:35:46 UTC (rev 7251)
+++ trunk/core/src/main/org/jboss/portal/core/controller/portlet/InvokePortletCommandFactory.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -32,6 +32,19 @@
*/
public interface InvokePortletCommandFactory
{
+ /**
+ * Creates a command that will trigger the action url.
+ *
+ * @param portletURL the action url
+ * @return a controller command
+ */
ControllerCommand createInvokeActionCommand(ActionURL portletURL);
+
+ /**
+ * Creates a command that will trigger the render url.
+ *
+ * @param portletURL the render url
+ * @return a controller command
+ */
ControllerCommand createInvokeRenderCommand(RenderURL portletURL);
}
Modified: trunk/core/src/main/org/jboss/portal/core/deployment/jboss/ObjectDeployment.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/deployment/jboss/ObjectDeployment.java 2007-05-15 12:35:46 UTC (rev 7251)
+++ trunk/core/src/main/org/jboss/portal/core/deployment/jboss/ObjectDeployment.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -32,6 +32,7 @@
import org.jboss.portal.core.model.portal.PortalObject;
import org.jboss.portal.core.model.portal.PortalObjectContainer;
import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.portal.PortalObjectPath;
import org.jboss.portal.core.model.content.ContentType;
import org.jboss.portal.core.model.content.spi.ContentProvider;
import org.jboss.portal.core.model.content.spi.handler.ContentHandler;
@@ -134,7 +135,7 @@
//
Element parentRefElt = XML.getUniqueChild(deploymentElt, "parent-ref", false);
- unit.parentRef = parentRefElt == null ? null : PortalObjectId.parse(XML.asString(parentRefElt), PortalObjectId.LEGACY_FORMAT);
+ unit.parentRef = parentRefElt == null ? null : PortalObjectId.parse(XML.asString(parentRefElt), PortalObjectPath.LEGACY_FORMAT);
//
Element ifExistsElt = XML.getUniqueChild(deploymentElt, "if-exists", false);
@@ -210,40 +211,50 @@
}
if (unit.metaData instanceof PortalObjectMetaData)
{
- log.debug("Checking existence of parent portal object '" + unit.parentRef + "'");
- Object o = factory.getPortalObjectContainer().getObject(unit.parentRef);
- if (o instanceof PortalObject)
+
+ PortalObjectContainer portalObjectContainer = factory.getPortalObjectContainer();
+ PortalObjectMetaData portalObjectMD = (PortalObjectMetaData)unit.metaData;
+
+ if (unit.parentRef != null)
{
- PortalObject parent = (PortalObject)o;
- PortalObjectMetaData portalObjectMD = (PortalObjectMetaData)unit.metaData;
- boolean create = true;
- if (parent.getChild(portalObjectMD.getName()) != null)
+ log.debug("Checking existence of parent portal object '" + unit.parentRef + "'");
+ Object o = portalObjectContainer.getObject(unit.parentRef);
+ if (o instanceof PortalObject)
{
- switch (unit.ifExists)
+ PortalObject parent = (PortalObject)o;
+ boolean create = true;
+ if (parent.getChild(portalObjectMD.getName()) != null)
{
- case OVERWRITE_IF_EXISTS:
- parent.destroyChild(portalObjectMD.getName());
- break;
- case KEEP_IF_EXISTS:
- create = false;
- break;
+ switch (unit.ifExists)
+ {
+ case OVERWRITE_IF_EXISTS:
+ parent.destroyChild(portalObjectMD.getName());
+ break;
+ case KEEP_IF_EXISTS:
+ create = false;
+ break;
+ }
}
+ if (create)
+ {
+ log.debug("Building portal object");
+ PortalObject po = portalObjectMD.create(portalObjectBuildContext, parent);
+ unit.ref = po.getId();
+ }
}
- if (create)
+ else if (o == null)
{
- log.debug("Building portal object");
- PortalObject po = portalObjectMD.create(portalObjectBuildContext, parent);
- unit.ref = po.getId();
+ log.warn("Cannot create portal object " + unit.metaData + " because the parent '" + unit.parentRef + "' that the deployment descriptor references does not exist");
}
}
- else if (o == null)
- {
- log.warn("Cannot create portal object " + unit.metaData + " because the parent '" + unit.parentRef + "' that the deployment descriptor references does not exist");
- }
else
{
- // Not normal
- throw new Error("Unexpected instance of PortalObjectMetaData " + o);
+ if (portalObjectContainer.getContext(portalObjectMD.getName()) == null)
+ {
+ log.debug("Building portal object");
+ PortalObject po = portalObjectMD.create(portalObjectBuildContext, null);
+ unit.ref = po.getId();
+ }
}
}
}
Modified: trunk/core/src/main/org/jboss/portal/core/impl/api/node/PortalNodeURLFactory.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/api/node/PortalNodeURLFactory.java 2007-05-15 12:35:46 UTC (rev 7251)
+++ trunk/core/src/main/org/jboss/portal/core/impl/api/node/PortalNodeURLFactory.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -24,13 +24,7 @@
import org.jboss.portal.api.node.PortalNode;
import org.jboss.portal.api.node.PortalNodeURL;
-import org.jboss.portal.portlet.PortletParametersStateString;
-import org.jboss.portal.server.request.URLContext;
-import org.jboss.portal.server.request.URLFormat;
import org.jboss.portal.core.controller.ControllerContext;
-import org.jboss.portal.core.model.portal.command.action.InvokePortletWindowRenderCommand;
-import org.jboss.portal.core.model.portal.command.view.ViewPageCommand;
-import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.impl.api.node.PortalNodeImpl;
/**
Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/CustomizationManagerService.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/CustomizationManagerService.java 2007-05-15 12:35:46 UTC (rev 7251)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/CustomizationManagerService.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -32,9 +32,10 @@
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.portal.Portal;
import org.jboss.portal.core.model.portal.DuplicatePortalObjectException;
-import org.jboss.portal.core.model.portal.PortalContainer;
import org.jboss.portal.core.model.portal.PortalObjectContainer;
import org.jboss.portal.core.model.portal.NoSuchPortalObjectException;
+import org.jboss.portal.core.model.portal.Context;
+import org.jboss.portal.core.model.portal.PortalObjectPath;
import org.jboss.portal.core.impl.model.content.portlet.PortletContent;
import org.jboss.portal.core.model.content.Content;
import org.jboss.portal.security.spi.auth.PortalAuthorizationManagerFactory;
@@ -52,15 +53,15 @@
{
/** . */
+ private static final PortalObjectId TEMPLATE_ID = PortalObjectId.parse("/template", PortalObjectPath.CANONICAL_FORMAT);
+
+ /** . */
private static final Logger log = Logger.getLogger(CustomizationManager.class);
/** . */
private String dashboardContextId;
/** . */
- private PortalObjectId dashboardContextObjectId;
-
- /** . */
private InstanceContainer instanceContainer;
/** . */
@@ -138,17 +139,11 @@
protected void createService() throws Exception
{
super.createService();
-
- //
- dashboardContextObjectId = PortalObjectId.parse(dashboardContextId, PortalObjectId.LEGACY_FORMAT);
}
protected void destroyService() throws Exception
{
- dashboardContextObjectId = null;
-
- //
super.destroyService();
}
@@ -216,12 +211,6 @@
throw new IllegalArgumentException("No null object");
}
- // Anonymous
- if (user == null)
- {
- return false;
- }
-
// todo
// We should test that it is the same than the request user
// as for now we can only test permission for the currently
@@ -239,6 +228,38 @@
log.error("Cannot check dashboard for", e);
return false;
}
+// if (object == null)
+// {
+// throw new IllegalArgumentException("No null object");
+// }
+//
+// //
+// PortalObjectId objectId = object.getId();
+//
+// //
+// if (user != null && "dashboard".equals(objectId.getNamespace()))
+// {
+// String userName = user.getUserName();
+// PortalObjectPath objectPath = objectId.getPath();
+// Iterator i = objectPath.names();
+//
+// //
+// if (i.hasNext())
+// {
+// // Skip empty context name
+// i.next();
+//
+// // Check dashboard id is equals to user name
+// if (i.hasNext())
+// {
+// String dashboardId = (String)i.next();
+// return userName.equals(dashboardId);
+// }
+// }
+// }
+//
+// //
+// return false;
}
public Portal getDashboard(User user) throws IllegalArgumentException
@@ -253,7 +274,7 @@
//
try
{
- PortalContainer dashboardContext = (PortalContainer)portalObjectContainer.getObject(dashboardContextObjectId);
+ Context dashboardContext = (Context)portalObjectContainer.getContext(dashboardContextId);
//
dashboardPortal = dashboardContext.getPortal(userId);
@@ -261,7 +282,7 @@
// Create if not exist
if (dashboardPortal == null)
{
- Portal templatePortal = (Portal)portalObjectContainer.getObject(new PortalObjectId("/template", PortalObjectId.CANONICAL_FORMAT));
+ Portal templatePortal = (Portal)portalObjectContainer.getObject(TEMPLATE_ID);
// Copy the template portal
dashboardPortal = (Portal)templatePortal.copy(dashboardContext, userId, true);
@@ -281,7 +302,7 @@
{
try
{
- PortalContainer dashboardContext = (PortalContainer)portalObjectContainer.getObject(dashboardContextObjectId);
+ Context dashboardContext = (Context)portalObjectContainer.getContext(dashboardContextId);
dashboardContext.destroyChild(userId);
}
catch (NoSuchPortalObjectException e)
Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java 2007-05-15 12:35:46 UTC (rev 7251)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -40,7 +40,6 @@
import org.jboss.portal.core.navstate.NavigationalStateKey;
import org.jboss.portal.core.theme.WindowRendition;
import org.jboss.portal.portlet.PortletParametersStateString;
-import org.jboss.portal.portlet.StateString;
import org.jboss.portal.theme.page.WindowResult;
import org.jboss.portal.Mode;
import org.jboss.portal.common.i18n.LocalizedString;
Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/portal/AbstractPortalObjectContainer.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/portal/AbstractPortalObjectContainer.java 2007-05-15 12:35:46 UTC (rev 7251)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/portal/AbstractPortalObjectContainer.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -26,6 +26,8 @@
import org.jboss.portal.core.model.portal.PortalObjectContainer;
import org.jboss.portal.core.model.portal.PortalObjectPermission;
import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.portal.DuplicatePortalObjectException;
+import org.jboss.portal.core.model.portal.PortalObjectPath;
import org.jboss.portal.core.model.content.ContentType;
import org.jboss.portal.core.model.content.spi.ContentProviderRegistry;
import org.jboss.portal.core.model.content.spi.ContentProvider;
@@ -54,9 +56,6 @@
{
/** . */
- private PortalObjectIdImpl rootId = new PortalObjectIdImpl();
-
- /** . */
private ContentProviderRegistry contentProviderRegistry;
protected AbstractPortalObjectContainer()
@@ -75,28 +74,39 @@
// PortalObjectContainer implementation******************************************************************************
- public PortalObject getRootObject()
+ public PortalObject getContext()
{
- return getObject(rootId);
+ return getContext("");
}
public PortalObject getObject(PortalObjectId id) throws IllegalArgumentException
{
if (id == null)
{
- throw new IllegalArgumentException("No null id accepted " + id);
+ throw new IllegalArgumentException("No null id accepted");
}
- ObjectNode node;
- if (id instanceof PortalObjectIdImpl)
+ ObjectNode node = getObjectNode(id);
+ return node == null ? null : node.getObject();
+ }
+
+ public PortalObject getContext(String namespace)
+ {
+ if (namespace == null)
{
- node = getObjectNode((PortalObjectIdImpl)id);
+ throw new IllegalArgumentException("No null namespace accepted");
}
- else
+ PortalObjectId id = new PortalObjectId(namespace, PortalObjectPath.ROOT_PATH);
+ ObjectNode node = getObjectNode(id);
+ return node == null ? null : node.getObject();
+ }
+
+ public PortalObject createContext(String namespace) throws DuplicatePortalObjectException
+ {
+ if (namespace == null)
{
- PortalObjectIdImpl poid = new PortalObjectIdImpl(id);
- node = getObjectNode(poid);
+ throw new IllegalArgumentException("No null namespace accepted");
}
- return node == null ? null : node.getObject();
+ return createRoot(namespace);
}
public AuthorizationDomain getAuthorizationDomain()
@@ -104,6 +114,8 @@
return this;
}
+ protected abstract PortalObjectImpl createRoot(String namespace) throws DuplicatePortalObjectException;
+
// AuthorizationDomain implementation *******************************************************************************
public String getType()
@@ -135,13 +147,13 @@
public PortalPermission createPermission(String uri, String action) throws PortalSecurityException
{
- PortalObjectIdImpl id = new PortalObjectIdImpl(PortalObjectId.parse(uri, PortalObjectId.CANONICAL_FORMAT));
+ PortalObjectId id = PortalObjectId.parse(uri, PortalObjectPath.CANONICAL_FORMAT);
return new PortalObjectPermission(id, action);
}
public PortalPermission createPermission(String uri, Collection actions) throws PortalSecurityException
{
- PortalObjectIdImpl id = new PortalObjectIdImpl(PortalObjectId.parse(uri, PortalObjectId.CANONICAL_FORMAT));
+ PortalObjectId id = PortalObjectId.parse(uri, PortalObjectPath.CANONICAL_FORMAT);
return new PortalObjectPermission(id, actions);
}
@@ -149,7 +161,7 @@
public PortalPermission getPermission(String roleName, String uri) throws PortalSecurityException
{
- PortalObjectIdImpl id = new PortalObjectIdImpl(PortalObjectId.parse(uri, PortalObjectId.CANONICAL_FORMAT));
+ PortalObjectId id = PortalObjectId.parse(uri, PortalObjectPath.CANONICAL_FORMAT);
ObjectNode on = getObjectNode(id);
if (on != null)
{
@@ -166,7 +178,7 @@
public void removeSecurityBindings(String uri) throws SecurityConfigurationException
{
- PortalObjectIdImpl id = new PortalObjectIdImpl(PortalObjectId.parse(uri, PortalObjectId.CANONICAL_FORMAT));
+ PortalObjectId id = PortalObjectId.parse(uri, PortalObjectPath.CANONICAL_FORMAT);
ObjectNode on = getObjectNode(id);
if (on == null)
{
@@ -177,7 +189,7 @@
public void setSecurityBindings(String uri, Set securityBindings) throws SecurityConfigurationException
{
- PortalObjectIdImpl id = new PortalObjectIdImpl(PortalObjectId.parse(uri, PortalObjectId.CANONICAL_FORMAT));
+ PortalObjectId id = PortalObjectId.parse(uri, PortalObjectPath.CANONICAL_FORMAT);
ObjectNode on = getObjectNode(id);
if (on == null)
{
@@ -188,7 +200,7 @@
public Set getSecurityBindings(String uri)
{
- PortalObjectIdImpl id = new PortalObjectIdImpl(PortalObjectId.parse(uri, PortalObjectId.CANONICAL_FORMAT));
+ PortalObjectId id = PortalObjectId.parse(uri, PortalObjectPath.CANONICAL_FORMAT);
ObjectNode on = getObjectNode(id);
if (on != null)
{
@@ -205,10 +217,10 @@
/**
* Must be subclasses to provide the access to a node.
*
- * @param id the portal object id
+ * @param id the portal object path
* @return a node or null if not found
*/
- protected abstract ObjectNode getObjectNode(PortalObjectIdImpl id);
+ protected abstract ObjectNode getObjectNode(PortalObjectId id);
public class Context
{
Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/portal/ObjectNode.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/portal/ObjectNode.java 2007-05-15 12:35:46 UTC (rev 7251)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/portal/ObjectNode.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -25,6 +25,7 @@
import org.jboss.logging.Logger;
import org.jboss.portal.core.model.portal.DuplicatePortalObjectException;
import org.jboss.portal.core.model.portal.NoSuchPortalObjectException;
+import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.jems.hibernate.ContextObject;
import org.jboss.portal.security.RoleSecurityBinding;
@@ -51,7 +52,7 @@
// Persistent fields
private Long key;
- private String path;
+ private PortalObjectId path;
private String name;
private ObjectNode parent;
private Map children;
@@ -70,14 +71,14 @@
this.children = null;
}
- public ObjectNode(AbstractPortalObjectContainer.Context context, String id, String name)
+ public ObjectNode(AbstractPortalObjectContainer.Context context, PortalObjectId path, String name)
{
if (context == null)
{
throw new IllegalArgumentException("No context provided");
}
this.context = context;
- this.path = id;
+ this.path = path;
this.name = name;
this.children = new HashMap();
this.securityConstraints = new HashMap();
@@ -138,11 +139,11 @@
}
//
- String id = toChildId(name);
+ PortalObjectId childPath = toChildPath(name);
//
- log.debug("Creating child of '" + path + "' with id '" + id + "'");
- ObjectNode childNode = new ObjectNode(context, id, name);
+ log.debug("Creating child of path='" + path + "' with path='" + childPath + "'");
+ ObjectNode childNode = new ObjectNode(context, childPath, name);
childNode.setObject(childObject);
childObject.setObjectNode(childNode);
@@ -195,12 +196,12 @@
child.setParent(null);
}
- public String getPath()
+ public PortalObjectId getPath()
{
return path;
}
- public void setPath(String path)
+ public void setPath(PortalObjectId path)
{
this.path = path;
}
@@ -245,16 +246,9 @@
return path + ":" + name;
}
- protected String toChildId(String name)
+ protected PortalObjectId toChildPath(String name)
{
- if ("".equals(getPath()))
- {
- return name;
- }
- else
- {
- return getPath() + "." + name;
- }
+ return new PortalObjectId(path.getNamespace(), path.getPath().getChild(name));
}
public Map getSecurityConstraints()
Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/portal/PersistentPortalObjectContainer.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/portal/PersistentPortalObjectContainer.java 2007-05-15 12:35:46 UTC (rev 7251)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/portal/PersistentPortalObjectContainer.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -31,7 +31,9 @@
import org.jboss.portal.jems.hibernate.ObjectContextualizer;
import org.jboss.portal.security.impl.JBossAuthorizationDomainRegistry;
import org.jboss.portal.security.spi.auth.PortalAuthorizationManagerFactory;
-import org.jboss.portal.security.spi.provider.AuthorizationDomain;
+import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.portal.DuplicatePortalObjectException;
+import org.jboss.portal.core.model.portal.PortalObjectPath;
import javax.naming.InitialContext;
@@ -177,9 +179,6 @@
//
contextualizer.attach(sessionFactory);
- // todo : move to use the ha singleton stuff
- createRootIfNotExist();
-
// Add ourself as the authorization domain
if (authorizationDomainRegistry != null)
{
@@ -204,18 +203,20 @@
sessionFactory = null;
}
- public boolean createRootIfNotExist() throws Exception
+ protected PortalObjectImpl createRoot(String namespace) throws DuplicatePortalObjectException
{
log.debug("Detecting the existence of the portal object root context");
Session session = sessionFactory.getCurrentSession();
// Create root context if it does not exist
- ObjectNode root = getObjectNode(session, "");
+ ObjectNode root = getObjectNode(session, new PortalObjectId(namespace, PortalObjectPath.ROOT_PATH));
+
+ //
if (root == null)
{
// Bootstrap the root node
log.debug("The root context of the object tree does not exist, about to create it");
- root = new ObjectNode(this.ctx, "", "");
+ root = new ObjectNode(this.ctx, new PortalObjectId(namespace, PortalObjectPath.ROOT_PATH), namespace);
session.save(root);
//
@@ -225,48 +226,48 @@
session.save(ctx);
//
- log.info("Created portal object root context");
- return true;
+ log.info("Created portal object root context for namespace " + namespace);
+
+ //
+ return ctx;
}
else
{
- log.debug("Portal object root context has been found");
- return false;
+ throw new DuplicatePortalObjectException("namespace " + namespace + " already exists");
}
}
-
- protected ObjectNode getObjectNode(PortalObjectIdImpl id)
+ protected ObjectNode getObjectNode(PortalObjectId path)
{
- return getObjectNode(sessionFactory.getCurrentSession(), id.internalId);
+ return getObjectNode(sessionFactory.getCurrentSession(), path);
}
- private ObjectNode getObjectNodeNoCache(Session session, String path)
+ private ObjectNode getObjectNodeNoCache(Session session, PortalObjectId id)
{
Object result;
- if (path.length() == 0)
+ if (id.getPath().getLength() == 0)
{
// For oracle where an empty path is treated as null so we need to add that here
// See also org.jboss.portal.core.hibernate.OracleString
Query query = session.createQuery(LOOKUP_QUERY_FOR_NULL_PATH);
- query.setParameter("path", path);
+ query.setParameter("path", id);
query.setCacheable(true);
result = query.uniqueResult();
}
else
{
Criteria criteria = session.createCriteria(ObjectNode.class);
- criteria.add(Restrictions.naturalId().set("path", path));
+ criteria.add(Restrictions.naturalId().set("path", id));
criteria.setCacheable(true);
result = criteria.uniqueResult();
}
return (ObjectNode)result;
}
- private ObjectNode getObjectNode(Session session, String path)
+ private ObjectNode getObjectNode(Session session, PortalObjectId id)
{
// Get cached pk from natural id
- Long pk = cacheNaturalId ? (Long)cache.get(path) : null;
+ Long pk = cacheNaturalId ? (Long)cache.get(id) : null;
//
ObjectNode objectNode;
@@ -275,7 +276,7 @@
if (pk == null)
{
// No pk
- objectNode = getObjectNodeNoCache(session, path);
+ objectNode = getObjectNodeNoCache(session, id);
}
else
{
@@ -286,7 +287,7 @@
if (objectNode == null)
{
// In that case we try a no cache
- objectNode = getObjectNodeNoCache(session, path);
+ objectNode = getObjectNodeNoCache(session, id);
}
}
@@ -295,11 +296,11 @@
{
if (objectNode != null)
{
- cache.put(path, objectNode.getKey());
+ cache.put(id, objectNode.getKey());
}
else
{
- cache.remove(path);
+ cache.remove(id);
}
}
Deleted: trunk/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectIdImpl.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectIdImpl.java 2007-05-15 12:35:46 UTC (rev 7251)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectIdImpl.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -1,71 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, 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. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * 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.portal;
-
-import org.jboss.portal.core.model.portal.PortalObjectId;
-
-/**
- * A convenient subclass.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class PortalObjectIdImpl extends PortalObjectId
-{
-
- /** . */
- final String internalId;
-
- /** . */
- String canonicalString;
-
- PortalObjectIdImpl()
- {
- super(new String[0]);
- internalId = "";
- }
-
- PortalObjectIdImpl(PortalObjectId that)
- {
- super(that);
-
- //
- this.internalId = LEGACY_FORMAT.toString(that);
- }
-
- PortalObjectIdImpl(String[] names)
- {
- super(names);
-
- //
- this.internalId = LEGACY_FORMAT.toString(names, 0, names.length);
- }
-
- PortalObjectIdImpl(PortalObjectImpl object)
- {
- super(object.getObjectNode().getPath(), LEGACY_FORMAT);
-
- //
- this.internalId = object.getObjectNode().getPath();
- }
-}
Added: trunk/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectIdUserType.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectIdUserType.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectIdUserType.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -0,0 +1,58 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * 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.portal;
+
+import org.jboss.portal.jems.hibernate.StringWrapperUserType;
+import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.portal.PortalObjectPath;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5448 $
+ */
+public class PortalObjectIdUserType extends StringWrapperUserType
+{
+
+ /** . */
+ private static final PortalObjectId EMPTY = new PortalObjectId("", PortalObjectPath.ROOT_PATH);
+
+ public Object fromNull()
+ {
+ return EMPTY;
+ }
+
+ public Object fromString(String name)
+ {
+ return PortalObjectId.parse(name, PortalObjectPath.LEGACY_FORMAT);
+ }
+
+ public String toString(Object value)
+ {
+ return ((PortalObjectId)value).toString(PortalObjectPath.LEGACY_FORMAT);
+ }
+
+ public Class returnedClass()
+ {
+ return PortalObjectId.class;
+ }
+}
Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectImpl.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectImpl.java 2007-05-15 12:35:46 UTC (rev 7251)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectImpl.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -69,7 +69,6 @@
private Map childrenMap;
private Map properties;
private Map unmodifiableProperties;
- private PortalObjectIdImpl id;
private DashboardContext dashboardContext;
public PortalObjectImpl()
@@ -79,7 +78,7 @@
public PortalObjectImpl(boolean initState)
{
- this.declaredPropertyMap = initState ? null : new HashMap();
+ this.declaredPropertyMap = new HashMap();
this.listener = null;
}
@@ -107,11 +106,7 @@
public PortalObjectId getId()
{
- if (id == null)
- {
- id = new PortalObjectIdImpl(this);
- }
- return id;
+ return objectNode.getPath();
}
public void destroyChild(String name) throws NoSuchPortalObjectException
Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/portal/TransientPortalObjectContainer.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/portal/TransientPortalObjectContainer.java 2007-05-15 12:35:46 UTC (rev 7251)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/portal/TransientPortalObjectContainer.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -22,11 +22,15 @@
******************************************************************************/
package org.jboss.portal.core.impl.model.portal;
-import org.jboss.portal.core.model.portal.PortalObjectContainer;
-import org.jboss.portal.security.spi.provider.AuthorizationDomain;
+import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.portal.DuplicatePortalObjectException;
+import org.jboss.portal.core.model.portal.PortalObjectPath;
import java.util.Iterator;
+import java.util.Map;
+import EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
@@ -35,7 +39,7 @@
{
/** . */
- protected ObjectNode root;
+ protected Map roots;
/** . */
protected Context ctx;
@@ -48,17 +52,32 @@
ctx = new Context();
//
- root = new ObjectNode(ctx, "", "");
- ContextImpl ctx = new ContextImpl(false);
- root.setObject(ctx);
- ctx.setObjectNode(root);
+ roots = new ConcurrentHashMap();
}
- protected ObjectNode getObjectNode(PortalObjectIdImpl id)
+
+ protected PortalObjectImpl createRoot(String namespace) throws DuplicatePortalObjectException
{
- ObjectNode node = root;
- for (Iterator i = id.names();node != null && i.hasNext();)
+ if (roots.containsKey(namespace))
{
+ throw new DuplicatePortalObjectException();
+ }
+ else
+ {
+ ObjectNode root = new ObjectNode(ctx, new PortalObjectId(namespace, PortalObjectPath.ROOT_PATH), namespace + ":");
+ ContextImpl ctx = new ContextImpl(false);
+ root.setObject(ctx);
+ ctx.setObjectNode(root);
+ roots.put(namespace, root);
+ return ctx;
+ }
+ }
+
+ protected ObjectNode getObjectNode(PortalObjectId id)
+ {
+ ObjectNode node = (ObjectNode)roots.get(id.getNamespace());
+ for (Iterator i = id.getPath().names();node != null && i.hasNext();)
+ {
String name = (String)i.next();
node = (ObjectNode)node.getChildren().get(name);
}
Deleted: trunk/core/src/main/org/jboss/portal/core/model/portal/DashboardCommandFactory.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/DashboardCommandFactory.java 2007-05-15 12:35:46 UTC (rev 7251)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/DashboardCommandFactory.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -1,41 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, 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. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * 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.portal;
-
-import org.jboss.portal.core.controller.ControllerCommand;
-import org.jboss.portal.core.controller.ControllerContext;
-import org.jboss.portal.core.model.portal.command.view.ViewDashboardCommand;
-import org.jboss.portal.core.controller.command.mapper.AbstractCommandFactory;
-import org.jboss.portal.server.ServerInvocation;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class DashboardCommandFactory extends AbstractCommandFactory
-{
- public ControllerCommand doMapping(ControllerContext controllerContext, ServerInvocation invocation, String host, String contextPath, String requestPath)
- {
- return new ViewDashboardCommand();
- }
-}
Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/DefaultPortalCommandFactory.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/DefaultPortalCommandFactory.java 2007-05-15 12:35:46 UTC (rev 7251)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/DefaultPortalCommandFactory.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -38,7 +38,7 @@
public class DefaultPortalCommandFactory extends AbstractCommandFactory
{
- private PortalObjectId defaultPortalPath = PortalObjectId.parse("/default", PortalObjectId.CANONICAL_FORMAT);
+ private PortalObjectId defaultPortalPath = PortalObjectId.parse("/default", PortalObjectPath.CANONICAL_FORMAT);
private CommandFactory nextFactory;
Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectCommandFactory.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectCommandFactory.java 2007-05-15 12:35:46 UTC (rev 7251)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectCommandFactory.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -31,14 +31,14 @@
import org.jboss.portal.core.model.portal.command.action.InvokePortletWindowRenderCommand;
import org.jboss.portal.core.model.portal.command.action.ImportPageToDashboardCommand;
import org.jboss.portal.core.model.portal.command.view.ViewPageCommand;
+import org.jboss.portal.core.model.portal.command.view.ViewContextCommand;
+import org.jboss.portal.core.model.portal.command.view.ViewPortalCommand;
+import org.jboss.portal.core.model.portal.command.mapping.PortalObjectPathMapper;
import org.jboss.portal.core.model.portal.navstate.WindowNavigationalState;
import org.jboss.portal.core.controller.command.mapper.AbstractCommandFactory;
import org.jboss.portal.core.navstate.NavigationalStateKey;
import org.jboss.portal.portlet.impl.PortletRequestDecoder;
import org.jboss.portal.server.ServerInvocation;
-import org.jboss.portal.server.servlet.PathMapping;
-import org.jboss.portal.server.servlet.PathMappingResult;
-import org.jboss.portal.server.servlet.PathParser;
/**
* This command mapper is used to map portal objects living in a container to <code>org.jboss.portal.core.command.RenderPageCommand</code>
@@ -50,40 +50,20 @@
{
/** . */
- protected PathParser pathParser;
+ private PortalObjectPathMapper mapper;
- /** . */
- protected PortalObjectContainer container;
-
- /** . */
- protected PathMapping mapping;
-
public PortalObjectCommandFactory()
{
- pathParser = new PathParser();
- mapping = new PathMapping()
- {
- public Object getRoot()
- {
- return container.getRootObject();
- }
-
- public Object getChild(Object parent, String name)
- {
- PortalObject po = (PortalObject)parent;
- return po.getChild(name);
- }
- };
}
- public PortalObjectContainer getContainer()
+ public PortalObjectPathMapper getMapper()
{
- return container;
+ return mapper;
}
- public void setContainer(PortalObjectContainer container)
+ public void setMapper(PortalObjectPathMapper mapper)
{
- this.container = container;
+ this.mapper = mapper;
}
public ControllerCommand doMapping(ControllerContext controllerContext, ServerInvocation invocation, String host, String contextPath, String requestPath)
@@ -94,23 +74,11 @@
}
//
- Object target;
- if (requestPath.length() == 0)
- {
- target = container.getRootObject();
- }
- else
- {
- PathMappingResult result = pathParser.map(mapping, requestPath);
- target = result.getTarget();
- }
-
- ControllerCommand cmd = null;
-
- //
+ Object target = mapper.getTarget(controllerContext, requestPath);
ParameterMap queryParams = invocation.getServerContext().getQueryParameterMap();
//
+ ControllerCommand cmd = null;
if (target instanceof Window)
{
Window window = (Window)target;
@@ -158,17 +126,17 @@
}
else
{
- if (target instanceof PortalContainer)
+ if (target instanceof Context)
{
- PortalContainer ctx = (PortalContainer)target;
- target = ctx.getDefaultPortal();
+ Context context = (Context)target;
+ return new ViewContextCommand(context.getId());
}
- if (target instanceof Portal)
+ else if (target instanceof Portal)
{
Portal portal = (Portal)target;
- target = portal.getDefaultPage();
+ return new ViewPortalCommand(portal.getId());
}
- if (target instanceof Page)
+ else
{
Page page = (Page)target;
PortalObjectId id = page.getId();
Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectContainer.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectContainer.java 2007-05-15 12:35:46 UTC (rev 7251)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectContainer.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -33,7 +33,7 @@
public interface PortalObjectContainer
{
/**
- * Return a container object.
+ * Returns a container object.
*
* @param id the portal object id
* @return the specified portal object
@@ -42,12 +42,16 @@
PortalObject getObject(PortalObjectId id) throws IllegalArgumentException;
/**
- * Return the root object of this container.
+ * Returns the default root object.
*
- * @return the root object
+ * @return a root object
*/
- PortalObject getRootObject();
+ PortalObject getContext();
+ PortalObject getContext(String namespace);
+
+ PortalObject createContext(String namespace) throws DuplicatePortalObjectException;
+
/**
* Get the authorization domain.
*
Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectId.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectId.java 2007-05-15 12:35:46 UTC (rev 7251)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectId.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -22,17 +22,15 @@
******************************************************************************/
package org.jboss.portal.core.model.portal;
-import org.jboss.portal.common.util.ParameterValidation;
-import org.jboss.portal.common.util.Tools;
-import org.jboss.portal.common.util.Base64;
-
-import java.util.Iterator;
import java.io.Serializable;
-import java.io.UnsupportedEncodingException;
/**
- * A composite id for a portal object.
+ * A composite id for a portal object in the scope of its container.
*
+ * <ul>
+ * <li>The empty string maps to the empty namespace and the empty path</li>
+ * </ul>
+ *
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
@@ -40,112 +38,45 @@
{
/** . */
- private static final String[] EMPTY_STRINGS = new String[0];
+ private final String namespace;
- /** The composites. */
- private final String[] names;
+ /** . */
+ private final PortalObjectPath path;
- /** Inclusive start index. */
- private final int from;
-
- /** Exclusive stop index. */
- private final int to;
-
- /** The lazy computed hash code. */
+ /** . */
private Integer hashCode;
- /** The lazy computed to string value. */
- private String toString;
-
- public PortalObjectId()
+ public PortalObjectId(String namespace, PortalObjectPath path)
{
- this.names = EMPTY_STRINGS;
- this.from = 0;
- this.to = 0;
+ if (namespace == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (path == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.namespace = namespace;
+ this.path = path;
}
- /**
- * Copy constructor.
- *
- * @param that the id to clone
- * @throws IllegalArgumentException if the argument to clone is null
- */
- public PortalObjectId(PortalObjectId that) throws IllegalArgumentException
+ public String getNamespace()
{
- ParameterValidation.throwIllegalArgExceptionIfNull(that, "PortalObjectId to be copied");
-
- //
- this.names = that.names;
- this.hashCode = that.hashCode;
- this.from = that.from;
- this.to = that.to;
+ return namespace;
}
- /**
- * Build an id directly from its composing names.
- *
- * @param names the id names
- * @throws IllegalArgumentException if any argument is null or not well formed
- */
- public PortalObjectId(String[] names) throws IllegalArgumentException
+ public PortalObjectPath getPath()
{
- ParameterValidation.throwIllegalArgExceptionIfNull(names, "composing names");
-
- //
- this.names = names;
- this.from = 0;
- this.to = names.length;
+ return path;
}
- /**
- * Build an id directly from its composing names.
- *
- * @param names the id names
- * @throws IllegalArgumentException if any argument is null or not well formed
- */
- private PortalObjectId(String[] names, int from, int to) throws IllegalArgumentException
+ public int hashCode()
{
- ParameterValidation.throwIllegalArgExceptionIfNull(names, "composing names");
-
- //
- this.names = names;
- this.from = from;
- this.to = to;
- }
-
- /**
- * Build an id by parsing a string representation.
- *
- * @param value the string representation
- * @param format the string format
- * @throws IllegalArgumentException if any argument is null or not well formed
- */
- public PortalObjectId(String value, Format format) throws IllegalArgumentException
- {
- ParameterValidation.throwIllegalArgExceptionIfNull(format, "Format");
-
- //
- this.names = format.parse(value);
- this.from = 0;
- this.to = names.length;
- }
-
- public int getLength()
- {
- return to - from;
- }
-
- public String getName(int index)
- {
- if (index < from)
+ if (hashCode == null)
{
- throw new IllegalArgumentException();
+ hashCode = new Integer(namespace.hashCode() + path.hashCode());
}
- if (index >= to)
- {
- throw new IllegalArgumentException();
- }
- return names[index - from];
+ return hashCode.intValue();
}
public boolean equals(Object obj)
@@ -157,321 +88,54 @@
if (obj instanceof PortalObjectId)
{
PortalObjectId that = (PortalObjectId)obj;
- String[] thisNames = this.names;
- String[] thatNames = that.names;
-
- //
- int thisLen = this.to - this.from;
- int thatLen = that.to - that.from;
- if (thisLen != thatLen)
- {
- return false;
- }
-
- //
- int thisIdx = this.from;
- int thatIdx = that.from;
- while (thisLen-- > 0)
- {
- if (!thisNames[thisIdx++].equals(thatNames[thatIdx++]))
- {
- return false;
- }
- }
-
- //
- return true;
+ return namespace.equals(that.namespace) && path.equals(that.path);
}
return false;
}
- public int hashCode()
+ public String toString(PortalObjectPath.Format format)
{
- if (hashCode == null)
- {
- int value = 0;
- for (int i = to - 1; i >= from; i--)
- {
- value = value * 41 + names[i].hashCode();
- }
- hashCode = new Integer(value);
- }
- return hashCode.intValue();
+ return toString(namespace, path, format);
}
- /**
- * Lexicographical order based implementation on the names atoms.
- */
- public int compareTo(Object o)
+ public static PortalObjectId parse(String idValue, PortalObjectPath.Format format)
{
- PortalObjectId that = (PortalObjectId)o;
- int index = 0;
- while (index < this.names.length && index < that.names.length)
+ int pos = idValue.indexOf(':');
+
+ //
+ if (pos == -1)
{
- String thisName = this.names[index];
- String thatName = that.names[index];
- int order = thisName.compareTo(thatName);
- if (order != 0)
- {
- return order;
- }
- index++;
+ return parse("", idValue, format);
}
- return that.names.length - this.names.length;
- }
-
- /**
- * Return an iterator over the different names.
- *
- * @return the iterator over the names
- */
- public Iterator names()
- {
- return Tools.iterator(names, from, to);
- }
-
- /** Returns the canonical representation of the id. */
- public String toString()
- {
- if (toString == null)
+ else
{
- toString = CANONICAL_FORMAT.toString(names, from, to);
+ String namespace = idValue.substring(0, pos);
+ String pathValue = idValue.substring(pos + 1);
+ return parse(namespace, pathValue, format);
}
- return toString;
}
- /**
- * Returns a string representation using a specified format
- *
- * @param format the output format
- * @return the string value
- */
- public String toString(Format format)
+ public static PortalObjectId parse(String namespace, String pathValue, PortalObjectPath.Format format)
{
- ParameterValidation.throwIllegalArgExceptionIfNull(format, "Format");
-
- //
- return format.toString(names, from, to);
+ return new PortalObjectId(namespace, PortalObjectPath.parse(pathValue, format));
}
- public static PortalObjectId parse(String value, Format format)
+ public static String toString(String namespace, PortalObjectPath path, PortalObjectPath.Format format)
{
- return new PortalObjectId(value, format);
- }
-
- /** The format of a string representation of an id. */
- public abstract static class Format
- {
- /**
- * @param value
- * @return
- */
- public abstract String[] parse(String value) throws IllegalArgumentException;
-
- /**
- * @param names
- * @return
- */
- public abstract String toString(String[] names, int from, int to) throws IllegalArgumentException;
-
- /**
- * @param id
- * @return
- */
- public final String toString(PortalObjectId id) throws IllegalArgumentException
+ if (namespace.length() > 0)
{
- ParameterValidation.throwIllegalArgExceptionIfNull(id, "PortalObjectId");
-
- //
- return toString(id.names, id.from, id.to);
+ return namespace + ":" + path.toString(format);
}
- }
-
- /** Canonical format, smth like /a/b/c. */
- public static final Format CANONICAL_FORMAT = new Format()
- {
- public String[] parse(String value)
+ else
{
- ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(value, "value", "Format.parse(value)");
- if (value.charAt(0) != '/')
- {
- throw new IllegalArgumentException("Not a canonical value " + value);
- }
- if (value.length() == 1)
- {
- return new String[0];
- }
-
- //
- int length = 1;
- int previous = 1;
- while (true)
- {
- int next = value.indexOf('/', previous);
- if (next == -1)
- {
- break;
- }
- length++;
- previous = next + 1;
- }
-
- //
- String[] names = new String[length];
- length = 0;
- previous = 1;
- while (true)
- {
- int next = value.indexOf('/', previous);
- if (next == -1)
- {
- break;
- }
- names[length++] = value.substring(previous, next);
- previous = next + 1;
- }
- names[length] = value.substring(previous);
-
- //
- return names;
+ return path.toString(format);
}
-
- public String toString(String[] names, int from, int to)
- {
- ParameterValidation.throwIllegalArgExceptionIfNull(names, "name string array");
- if (from == to)
- {
- return "/";
- }
- else
- {
- StringBuffer tmp = new StringBuffer(names.length * 10);
- for (int i = from; i < to; i++)
- {
- String name = names[i];
- if (name == null)
- {
- throw new IllegalArgumentException("No null name expected in the name string array");
- }
- tmp.append('/').append(name);
- }
- return tmp.toString();
- }
- }
- };
-
- /** The internal format when it is persisted, smth like a.b.c */
- public static final Format LEGACY_FORMAT = new LegacyFormat();
-
- public static class LegacyFormat extends Format
- {
-
- /** . */
- private final String[] EMPTY_STRING_ARRAY = new String[0];
-
- public String[] parse(String value)
- {
- ParameterValidation.throwIllegalArgExceptionIfNull(value, "value");
-
- //
- if (value.length() == 0)
- {
- return EMPTY_STRING_ARRAY;
- }
-
- // Count the number of names
- int length = 1;
- for (int next = value.indexOf('.'); next != -1; next = value.indexOf('.', next + 1))
- {
- length++;
- }
-
- //
- String[] names = new String[length];
- length = 0;
- int previous = 0;
- for (int next = value.indexOf('.'); next != -1; previous = next + 1, next = value.indexOf('.', next + 1))
- {
- String name = value.substring(previous, next);
- name = decodeName(name);
- names[length++] = name;
- }
- String name = value.substring(previous);
- name = decodeName(name);
- names[length] = name;
-
- //
- return names;
- }
-
- public String toString(String[] names, int from, int to)
- {
- ParameterValidation.throwIllegalArgExceptionIfNull(names, "name string array");
-
- //
- if (from == to)
- {
- return "";
- }
-
- //
- StringBuffer buffer = new StringBuffer((to - from) * 8);
- for (int i = from; i < to; i++)
- {
- if (i > 0)
- {
- buffer.append('.');
- }
- String name = names[i];
- if (name == null)
- {
- throw new IllegalArgumentException("No null name expected in the name string array");
- }
- name = encodeName(name);
- buffer.append(name);
- }
- return buffer.toString();
- }
-
- protected String decodeName(String name)
- {
- return name;
- }
-
- protected String encodeName(String name)
- {
- return name;
- }
}
- public static final Format LEGACY_BASE64_FORMAT = new LegacyFormat()
+ public int compareTo(Object o)
{
-
- protected String decodeName(String name)
- {
- try
- {
- byte[] bytes = Base64.decode(name);
- return new String(bytes, "UTF-8");
- }
- catch (UnsupportedEncodingException e)
- {
- throw new Error(e);
- }
- }
-
- protected String encodeName(String name)
- {
- try
- {
- byte[] bytes = name.getBytes("UTF-8");
- name = Base64.encodeBytes(bytes);
- return name;
- }
- catch (UnsupportedEncodingException e)
- {
- throw new Error(e);
- }
- }
- };
+ PortalObjectId that = (PortalObjectId)o;
+ int order = namespace.compareTo(that.namespace);
+ return order != 0 ? order : path.compareTo(that.path);
+ }
}
Added: trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectPath.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectPath.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectPath.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -0,0 +1,529 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * 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.portal;
+
+import org.jboss.portal.common.util.ParameterValidation;
+import org.jboss.portal.common.util.Tools;
+import org.jboss.portal.common.util.Base64;
+
+import java.io.Serializable;
+import java.io.UnsupportedEncodingException;
+import java.util.Iterator;
+
+/**
+ * A path for a portal object.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PortalObjectPath implements Comparable, Serializable
+{
+
+ /** . */
+ private static final String[] EMPTY_STRINGS = new String[0];
+
+ /** This statement must be executed before the previous one otherwise the empty string array will be null. */
+ public static final PortalObjectPath ROOT_PATH = new PortalObjectPath();
+
+ /** The composites. */
+ private final String[] names;
+
+ /** Inclusive start index. */
+ private final int from;
+
+ /** Exclusive stop index. */
+ private final int to;
+
+ /** The lazy computed hash code. */
+ private Integer hashCode;
+
+ /** The lazy computed to string value for canonical format. */
+ private String toStringCanonicalFormat;
+
+ /** The lazy computed to string value for legacy format. */
+ private String toStringLegacyFormat;
+
+ /** The lazy created parent that can be useful. */
+ private PortalObjectPath parent;
+
+ public PortalObjectPath create()
+ {
+ return null;
+ }
+
+ public PortalObjectPath()
+ {
+ this.names = EMPTY_STRINGS;
+ this.from = 0;
+ this.to = 0;
+ }
+
+ /**
+ * Copy constructor.
+ *
+ * @param that the id to clone
+ * @throws IllegalArgumentException if the argument to clone is null
+ */
+ public PortalObjectPath(PortalObjectPath that) throws IllegalArgumentException
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(that, "PortalObjectId to be copied");
+
+ //
+ this.names = that.names;
+ this.hashCode = that.hashCode;
+ this.from = that.from;
+ this.to = that.to;
+ }
+
+ /**
+ * Build an id directly from its composing names.
+ *
+ * @param names the id names
+ * @throws IllegalArgumentException if any argument is null or not well formed
+ */
+ public PortalObjectPath(String[] names) throws IllegalArgumentException
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(names, "composing names");
+
+ //
+ this.names = names;
+ this.from = 0;
+ this.to = names.length;
+ }
+
+ /**
+ * Build an id directly from its composing names.
+ *
+ * @param names the id names
+ * @throws IllegalArgumentException if any argument is null or not well formed
+ */
+ private PortalObjectPath(String[] names, int from, int to) throws IllegalArgumentException
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(names, "composing names");
+
+ //
+ this.names = names;
+ this.from = from;
+ this.to = to;
+ }
+
+ /**
+ * Return the parent or null if this is the root id.
+ *
+ * @return the parent
+ */
+ public PortalObjectPath getParent()
+ {
+ if (parent == null && from < to)
+ {
+ parent = new PortalObjectPath(names, from, to - 1);
+ }
+ return parent;
+ }
+
+ public PortalObjectPath getChild(String name)
+ {
+ int length = to - from;
+ String[] childNames = new String[length + 1];
+ System.arraycopy(this.names, from, childNames, 0, length);
+ childNames[length] = name;
+ return new PortalObjectPath(childNames);
+ }
+
+ /**
+ * Build an id by parsing a string representation.
+ *
+ * @param value the string representation
+ * @param format the string format
+ * @throws IllegalArgumentException if any argument is null or not well formed
+ */
+ public PortalObjectPath(String value, PortalObjectPath.Format format) throws IllegalArgumentException
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(format, "Format");
+
+ //
+ this.names = format.parse(value);
+ this.from = 0;
+ this.to = names.length;
+ }
+
+ public int getLength()
+ {
+ return to - from;
+ }
+
+ public String getName(int index)
+ {
+ if (index < from)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (index >= to)
+ {
+ throw new IllegalArgumentException();
+ }
+ return names[index - from];
+ }
+
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ {
+ return true;
+ }
+ if (obj instanceof PortalObjectPath)
+ {
+ PortalObjectPath that = (PortalObjectPath)obj;
+ String[] thisNames = this.names;
+ String[] thatNames = that.names;
+
+ //
+ //
+ int thisLen = this.to - this.from;
+ int thatLen = that.to - that.from;
+ if (thisLen != thatLen)
+ {
+ return false;
+ }
+
+ //
+ int thisIdx = this.from;
+ int thatIdx = that.from;
+ while (thisLen-- > 0)
+ {
+ if (!thisNames[thisIdx++].equals(thatNames[thatIdx++]))
+ {
+ return false;
+ }
+ }
+
+ //
+ return true;
+ }
+ return false;
+ }
+
+ public int hashCode()
+ {
+ if (hashCode == null)
+ {
+ int value = 0;
+ for (int i = to - 1; i >= from; i--)
+ {
+ value = value * 41 + names[i].hashCode();
+ }
+ hashCode = new Integer(value);
+ }
+ return hashCode.intValue();
+ }
+
+ /**
+ * Lexicographical order based implementation on the names atoms.
+ */
+ public int compareTo(Object o)
+ {
+ PortalObjectPath that = (PortalObjectPath)o;
+ int index = 0;
+ while (index < this.names.length && index < that.names.length)
+ {
+ String thisName = this.names[index];
+ String thatName = that.names[index];
+ int order = thisName.compareTo(thatName);
+ if (order != 0)
+ {
+ return order;
+ }
+ index++;
+ }
+ return that.names.length - this.names.length;
+ }
+
+ /**
+ * Return an iterator over the different names.
+ *
+ * @return the iterator over the names
+ */
+ public Iterator names()
+ {
+ return Tools.iterator(names, from, to);
+ }
+
+ /** Returns the canonical representation of the id. */
+ public String toString()
+ {
+ return toString(CANONICAL_FORMAT);
+ }
+
+ /**
+ * Returns a string representation using a specified format
+ *
+ * @param format the output format
+ * @return the string value
+ */
+ public String toString(PortalObjectPath.Format format)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(format, "Format");
+
+ //
+ if (format == LEGACY_FORMAT)
+ {
+ if (toStringLegacyFormat == null)
+ {
+ toStringLegacyFormat = LEGACY_FORMAT.toString(names, from, to);
+ }
+ return toStringLegacyFormat;
+ }
+ else if (format == CANONICAL_FORMAT)
+ {
+ if (toStringCanonicalFormat == null)
+ {
+ toStringCanonicalFormat = CANONICAL_FORMAT.toString(names, from, to);
+ }
+ return toStringCanonicalFormat;
+ }
+
+ //
+ return format.toString(names, from, to);
+ }
+
+ public static PortalObjectPath parse(String value, PortalObjectPath.Format format)
+ {
+ return new PortalObjectPath(value, format);
+ }
+
+ /** The format of a string representation of an id. */
+ public abstract static class Format
+ {
+ /**
+ * @param value
+ * @return
+ */
+ public abstract String[] parse(String value) throws IllegalArgumentException;
+
+ /**
+ * @param names
+ * @return
+ */
+ public abstract String toString(String[] names, int from, int to) throws IllegalArgumentException;
+
+ /**
+ * @param id
+ * @return
+ */
+ public final String toString(PortalObjectPath id) throws IllegalArgumentException
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(id, "PortalObjectId");
+
+ //
+ return toString(id.names, id.from, id.to);
+ }
+ }
+
+ /** Canonical format, smth like /a/b/c. */
+ public static final PortalObjectPath.Format CANONICAL_FORMAT = new PortalObjectPath.Format()
+ {
+ public String[] parse(String value)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(value, "value", "Format.parse(value)");
+ if (value.charAt(0) != '/')
+ {
+ throw new IllegalArgumentException("Not a canonical value " + value);
+ }
+ if (value.length() == 1)
+ {
+ return new String[0];
+ }
+
+ //
+ int length = 1;
+ int previous = 1;
+ while (true)
+ {
+ int next = value.indexOf('/', previous);
+ if (next == -1)
+ {
+ break;
+ }
+ length++;
+ previous = next + 1;
+ }
+
+ //
+ String[] names = new String[length];
+ length = 0;
+ previous = 1;
+ while (true)
+ {
+ int next = value.indexOf('/', previous);
+ if (next == -1)
+ {
+ break;
+ }
+ names[length++] = value.substring(previous, next);
+ previous = next + 1;
+ }
+ names[length] = value.substring(previous);
+
+ //
+ return names;
+ }
+
+ public String toString(String[] names, int from, int to)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(names, "name string array");
+ if (from == to)
+ {
+ return "/";
+ }
+ else
+ {
+ StringBuffer tmp = new StringBuffer(names.length * 10);
+ for (int i = from; i < to; i++)
+ {
+ String name = names[i];
+ if (name == null)
+ {
+ throw new IllegalArgumentException("No null name expected in the name string array");
+ }
+ tmp.append('/').append(name);
+ }
+ return tmp.toString();
+ }
+ }
+ };
+
+ /** The internal format when it is persisted, smth like a.b.c */
+ public static final PortalObjectPath.Format LEGACY_FORMAT = new PortalObjectPath.LegacyFormat();
+
+ public static class LegacyFormat extends PortalObjectPath.Format
+ {
+
+ /** . */
+ private final String[] EMPTY_STRING_ARRAY = new String[0];
+
+ public String[] parse(String value)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(value, "value");
+
+ //
+ if (value.length() == 0)
+ {
+ return EMPTY_STRING_ARRAY;
+ }
+
+ // Count the number of names
+ int length = 1;
+ for (int next = value.indexOf('.'); next != -1; next = value.indexOf('.', next + 1))
+ {
+ length++;
+ }
+
+ //
+ String[] names = new String[length];
+ length = 0;
+ int previous = 0;
+ for (int next = value.indexOf('.'); next != -1; previous = next + 1, next = value.indexOf('.', next + 1))
+ {
+ String name = value.substring(previous, next);
+ name = decodeName(name);
+ names[length++] = name;
+ }
+ String name = value.substring(previous);
+ name = decodeName(name);
+ names[length] = name;
+
+ //
+ return names;
+ }
+
+ public String toString(String[] names, int from, int to)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(names, "name string array");
+
+ //
+ if (from == to)
+ {
+ return "";
+ }
+
+ //
+ StringBuffer buffer = new StringBuffer((to - from) * 8);
+ for (int i = from; i < to; i++)
+ {
+ if (i > 0)
+ {
+ buffer.append('.');
+ }
+ String name = names[i];
+ if (name == null)
+ {
+ throw new IllegalArgumentException("No null name expected in the name string array");
+ }
+ name = encodeName(name);
+ buffer.append(name);
+ }
+ return buffer.toString();
+ }
+
+ protected String decodeName(String name)
+ {
+ return name;
+ }
+
+ protected String encodeName(String name)
+ {
+ return name;
+ }
+ }
+
+ public static final PortalObjectPath.Format LEGACY_BASE64_FORMAT = new PortalObjectPath.LegacyFormat()
+ {
+
+ protected String decodeName(String name)
+ {
+ try
+ {
+ byte[] bytes = Base64.decode(name);
+ return new String(bytes, "UTF-8");
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ throw new Error(e);
+ }
+ }
+
+ protected String encodeName(String name)
+ {
+ try
+ {
+ byte[] bytes = name.getBytes("UTF-8");
+ name = Base64.encodeBytes(bytes);
+ return name;
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ throw new Error(e);
+ }
+ }
+ };
+}
Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectPermission.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectPermission.java 2007-05-15 12:35:46 UTC (rev 7251)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectPermission.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -83,6 +83,9 @@
/** The action names. */
private static final String[] ACTION_NAMES = {VIEW_ACTION, CREATE_ACTION, PERSONALIZE_ACTION, DASHBOARD_ACTION};
+ /** . */
+ private PortalObjectId id;
+
/** The imply mask. */
private int mask;
@@ -102,7 +105,7 @@
public PortalObjectPermission(PortalObjectId id, Collection actions)
{
- super("portalobjectpermission", id.toString(PortalObjectId.CANONICAL_FORMAT));
+ super("portalobjectpermission", id.toString(PortalObjectPath.CANONICAL_FORMAT));
//
if (actions == null)
@@ -111,6 +114,9 @@
}
//
+ this.id = id;
+
+ //
for (Iterator i = actions.iterator(); i.hasNext();)
{
String action = (String)i.next();
@@ -123,12 +129,15 @@
public PortalObjectPermission(PortalObjectId id, String actions)
{
- super("portalobjectpermission", id.toString(PortalObjectId.CANONICAL_FORMAT));
+ super("portalobjectpermission", id.toString(PortalObjectPath.CANONICAL_FORMAT));
if (actions == null)
{
throw new IllegalArgumentException("Actions agurment cannot be null");
}
+ //
+ this.id = id;
+
// Parse the actions into the mask
StringTokenizer tokenizer = new StringTokenizer(actions, ",");
while (tokenizer.hasMoreTokens())
@@ -143,14 +152,20 @@
public PortalObjectPermission(PortalObjectId id, int mask, int recursiveMask)
{
- super("portalobjectpermission", id.toString(PortalObjectId.CANONICAL_FORMAT));
+ super("portalobjectpermission", id.toString(PortalObjectPath.CANONICAL_FORMAT));
+
+ //
+ this.id = id;
this.mask = mask | recursiveMask;
this.recursiveMask = recursiveMask;
}
public PortalObjectPermission(PortalObjectId id, int mask)
{
- super("portalobjectpermission", id.toString(PortalObjectId.CANONICAL_FORMAT));
+ super("portalobjectpermission", id.toString(PortalObjectPath.CANONICAL_FORMAT));
+
+ //
+ this.id = id;
this.mask = mask;
this.recursiveMask = 0;
}
@@ -200,9 +215,14 @@
}
else
{
- String uri = pop.getURI();
+ String namespace = pop.id.getNamespace();
+ PortalObjectPath path = pop.id.getPath();
+
+ //
while (true)
{
+ String uri = PortalObjectId.toString(namespace, path, PortalObjectPath.CANONICAL_FORMAT);
+
// Try to load the permission from the repository
PortalObjectPermission loaded = (PortalObjectPermission)repository.getPermission(roleName, uri);
@@ -212,27 +232,14 @@
return true;
}
- // Do we have terminated our job ?
- if (uri.length() == 1)
- {
- break;
- }
-
// Get the parent uri
- int index = uri.lastIndexOf('/');
- if (index == -1)
+ if (path.getLength() == 0)
{
- // Should not happen if the URI is well formed
return false;
}
- else if (index == 0)
- {
- uri = "/";
- }
- else
- {
- uri = uri.substring(0, index);
- }
+
+ // Get parent path
+ path = path.getParent();
}
}
}
@@ -246,60 +253,90 @@
public boolean implies(Permission permission, Subject caller)
{
- if (permission instanceof PortalObjectPermission && isContainer() == false)
+ if (permission instanceof PortalObjectPermission && !isContainer())
{
PortalObjectPermission that = (PortalObjectPermission)permission;
//
- if (that.isContainer() == false)
+ if (!that.isContainer())
{
- if ((this.mask & DASHBOARD_MASK) == DASHBOARD_MASK)
+ if (!id.getNamespace().equals(that.id.getNamespace()))
{
- if (caller != null)
+ return false;
+ }
+
+ PortalObjectPath thisPath = id.getPath();
+ PortalObjectPath thatPath = that.id.getPath();
+
+ //
+ if ((this.mask & DASHBOARD_MASK) == DASHBOARD_MASK &&
+ caller != null &&
+ thisPath.getLength() < thatPath.getLength())
+ {
+ Set tmp = caller.getPrincipals(UserPrincipal.class);
+ if (tmp.size() > 0)
{
- Set tmp = caller.getPrincipals(UserPrincipal.class);
- if (tmp.size() > 0)
+ Iterator i1 = thisPath.names();
+ Iterator i2 = thatPath.names();
+
+ //
+ while (i1.hasNext())
{
- Iterator i = tmp.iterator();
- UserPrincipal user = (UserPrincipal)i.next();
- String userName = user.getName();
+ String name1 = (String)i1.next();
+ String name2 = (String)i2.next();
+ if (!name1.equals(name2))
+ {
+ return false;
+ }
+ }
- // The index of the expected '/' in that.uri
- int index = this.uri.length();
+ //
+ Iterator i = tmp.iterator();
+ UserPrincipal user = (UserPrincipal)i.next();
+ String userName = user.getName();
+ //
+ return userName.equals(i2.next());
+
//
- if (index == 1)
- {
- index = 0;
- }
- // We must have (this.uri + '/' + userName) a prefix
- // of that.uri
- if (that.uri.length() > index)
- {
- // No '/' means not good
- if (that.uri.charAt(index) == '/')
- {
- // Get the index of where to extract the name to make the comparison
- int from = index + 1;
- int to = that.uri.indexOf('/', from);
- if (to == -1)
- {
- to = that.uri.length();
- }
- //
- String name = that.uri.substring(from, to);
- if (name.equals(userName))
- {
- return true;
- }
- }
- }
- }
+// // The index of the expected '/' in that.uri
+// int index = this.uri.length();
+//
+// //
+// if (index == 1)
+// {
+// index = 0;
+// }
+//
+// // We must have (this.uri + '/' + userName) a prefix
+// // of that.uri
+// if (that.uri.length() > index)
+// {
+// // No '/' means not good
+// if (that.uri.charAt(index) == '/')
+// {
+// // Get the index of where to extract the name to make the comparison
+// int from = index + 1;
+// int to = that.uri.indexOf('/', from);
+// if (to == -1)
+// {
+// to = that.uri.length();
+// }
+//
+// //
+// String name = that.uri.substring(from, to);
+// if (name.equals(userName))
+// {
+// return true;
+// }
+// }
+// }
}
}
+ // Could check namespace and id instead
if (that.uri.equals(this.uri))
{
return (this.mask & that.mask) == that.mask;
@@ -387,4 +424,9 @@
{
return PERMISSION_TYPE;
}
+
+ public PortalObjectId getId()
+ {
+ return id;
+ }
}
Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectURLFactory.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectURLFactory.java 2007-05-15 12:35:46 UTC (rev 7251)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectURLFactory.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -24,14 +24,15 @@
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
-import org.jboss.portal.common.text.FastURLEncoder;
import org.jboss.portal.core.controller.ControllerCommand;
import org.jboss.portal.core.controller.ControllerContext;
import org.jboss.portal.core.model.portal.command.action.InvokePortletWindowActionCommand;
import org.jboss.portal.core.model.portal.command.action.InvokeWindowCommand;
import org.jboss.portal.core.model.portal.command.action.InvokePortletWindowRenderCommand;
-import org.jboss.portal.core.model.portal.command.render.RenderPageCommand;
import org.jboss.portal.core.model.portal.command.PortalObjectCommand;
+import org.jboss.portal.core.model.portal.command.view.ViewPageCommand;
+import org.jboss.portal.core.model.portal.command.view.ViewPortalCommand;
+import org.jboss.portal.core.model.portal.command.mapping.PortalObjectPathMapper;
import org.jboss.portal.core.model.portal.command.action.ImportPageToDashboardCommand;
import org.jboss.portal.core.controller.command.mapper.URLFactoryDelegate;
import org.jboss.portal.portlet.StateString;
@@ -40,8 +41,6 @@
import org.jboss.portal.server.ServerInvocation;
import org.jboss.portal.server.ServerURL;
-import java.util.Iterator;
-
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
@@ -49,12 +48,18 @@
public class PortalObjectURLFactory extends URLFactoryDelegate
{
- /** The fast url encoder. */
- private static final FastURLEncoder urlEncoder = FastURLEncoder.create("UTF8", 0, 1024);
-
/** . */
private String path;
+ /** . */
+ private String namespace;
+
+ /** . */
+ private PortalObjectPathMapper mapper;
+
+ /** . */
+ private String effectiveNamespace;
+
public String getPath()
{
return path;
@@ -65,6 +70,35 @@
this.path = path;
}
+ public String getNamespace()
+ {
+ return namespace;
+ }
+
+ public void setNamespace(String namespace)
+ {
+ this.namespace = namespace;
+ }
+
+ public PortalObjectPathMapper getMapper()
+ {
+ return mapper;
+ }
+
+ public void setMapper(PortalObjectPathMapper mapper)
+ {
+ this.mapper = mapper;
+ }
+
+
+ protected void startService() throws Exception
+ {
+ super.startService();
+
+ //
+ effectiveNamespace = namespace == null ? "" : namespace;
+ }
+
public ServerURL doMapping(ControllerContext controllerContext, ServerInvocation invocation, ControllerCommand cmd)
{
if (cmd == null)
@@ -77,50 +111,64 @@
{
PortalObjectCommand poc = (PortalObjectCommand)cmd;
- // Get base URL
- ServerURL url = getBaseURL(poc.getTargetId());
+ //
+ PortalObjectId targetId = poc.getTargetId();
- // Customize further more
- if (cmd instanceof RenderPageCommand)
+ //
+ String targetNamespace = targetId.getNamespace();
+
+ //
+ if (effectiveNamespace.equals(targetNamespace))
{
- // Nothing for now, we let the statement just to show that it handles page rendering commands
- }
- else if (cmd instanceof InvokeWindowCommand)
- {
- InvokeWindowCommand iwaCmd = (InvokeWindowCommand)cmd;
+ // Get base URL
+ ServerURL url = getBaseURL(targetId);
- Mode mode = iwaCmd.getMode();
- WindowState windowState = iwaCmd.getWindowState();
-
- //
- if (iwaCmd instanceof InvokePortletWindowActionCommand)
+ // Customize further more
+ if (cmd instanceof ViewPageCommand)
{
- StateString interactionState = ((InvokePortletWindowActionCommand)iwaCmd).getInteractionState();
- StateString navigationalState = ((InvokePortletWindowActionCommand)iwaCmd).getNavigationalState();
- PortletRequestEncoder encoder = new PortletRequestEncoder(url.getParameterMap());
- encoder.encodeAction(navigationalState, interactionState, mode, windowState);
+ // Nothing for now, we let the statement just to show that it handles page rendering commands
}
- else
+ else if (cmd instanceof ViewPortalCommand)
{
- StateString navigationalState = ((InvokePortletWindowRenderCommand)iwaCmd).getNavigationalState();
- PortletRequestEncoder encoder = new PortletRequestEncoder(url.getParameterMap());
- encoder.encodeRender(navigationalState, mode, windowState);
+ // Nothing for now, we let the statement just to show that it handles page rendering commands
}
+ else if (cmd instanceof InvokeWindowCommand)
+ {
+ InvokeWindowCommand iwaCmd = (InvokeWindowCommand)cmd;
+
+ Mode mode = iwaCmd.getMode();
+ WindowState windowState = iwaCmd.getWindowState();
+
+ //
+ if (iwaCmd instanceof InvokePortletWindowActionCommand)
+ {
+ StateString interactionState = ((InvokePortletWindowActionCommand)iwaCmd).getInteractionState();
+ StateString navigationalState = ((InvokePortletWindowActionCommand)iwaCmd).getNavigationalState();
+ PortletRequestEncoder encoder = new PortletRequestEncoder(url.getParameterMap());
+ encoder.encodeAction(navigationalState, interactionState, mode, windowState);
+ }
+ else
+ {
+ StateString navigationalState = ((InvokePortletWindowRenderCommand)iwaCmd).getNavigationalState();
+ PortletRequestEncoder encoder = new PortletRequestEncoder(url.getParameterMap());
+ encoder.encodeRender(navigationalState, mode, windowState);
+ }
+ }
+ else if (cmd instanceof ImportPageToDashboardCommand)
+ {
+ url.setParameterValue("action", "import");
+ }
+
+ //
+ return url;
}
- else if (cmd instanceof ImportPageToDashboardCommand)
- {
- url.setParameterValue("action", "import");
- }
-
- //
- return url;
}
//
return null;
}
- private AbstractServerURL getBaseURL(PortalObjectId objectRef)
+ private AbstractServerURL getBaseURL(PortalObjectId id)
{
//
StringBuffer buffer = new StringBuffer();
@@ -131,15 +179,10 @@
buffer.append(path);
}
- // escape spaces
- for (Iterator i = objectRef.names();i.hasNext();)
- {
- String name = (String)i.next();
- name = urlEncoder.encode(name);
- buffer.append('/').append(name);
- }
-
//
+ mapper.appendPath(buffer, id);
+
+ //
AbstractServerURL asu = new AbstractServerURL();
asu.setPortalRequestPath(buffer.toString());
Added: trunk/core/src/main/org/jboss/portal/core/model/portal/command/ContextCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/command/ContextCommand.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/ContextCommand.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -0,0 +1,67 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * 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.portal.command;
+
+import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.portal.Context;
+import org.jboss.portal.core.controller.ControllerException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class ContextCommand extends PortalObjectCommand
+{
+
+ /** . */
+ protected Context root;
+
+ public ContextCommand(PortalObjectId portalId)
+ {
+ super(portalId);
+ }
+
+ /**
+ * Get the requested root.
+ *
+ * @return the requested root
+ */
+ public Context getRoot()
+ {
+ return root;
+ }
+
+ /**
+ * Initialize the command.
+ *
+ * @throws org.jboss.portal.common.invocation.InvocationException
+ *
+ */
+ public void create() throws ControllerException
+ {
+ super.create();
+
+ //
+ root = (Context)getTarget();
+ }
+}
Deleted: trunk/core/src/main/org/jboss/portal/core/model/portal/command/DashboardCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/command/DashboardCommand.java 2007-05-15 12:35:46 UTC (rev 7251)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/DashboardCommand.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -1,33 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, 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. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * 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.portal.command;
-
-import org.jboss.portal.core.controller.ControllerCommand;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public abstract class DashboardCommand extends ControllerCommand
-{
-}
Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/command/PortalObjectCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/command/PortalObjectCommand.java 2007-05-15 12:35:46 UTC (rev 7251)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/PortalObjectCommand.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -41,11 +41,14 @@
public abstract class PortalObjectCommand extends ControllerCommand
{
+ /** . */
protected final PortalObjectId targetId;
+ /** . */
protected PortalObject target;
- private Boolean dashboard;
+ /** . */
+ protected boolean dashboard;
protected PortalObjectCommand(PortalObjectId targetId)
{
@@ -54,6 +57,7 @@
throw new IllegalArgumentException();
}
this.targetId = targetId;
+ this.dashboard = "dashboard".equals(targetId.getNamespace());
}
@@ -108,12 +112,6 @@
*/
public boolean isDashboard()
{
- if (dashboard == null)
- {
- User user = getControllerContext().getUser();
- boolean tmp = context.getController().getCustomizationManager().isDashboard(target, user);
- dashboard = Boolean.valueOf(tmp);
- }
- return dashboard.booleanValue();
+ return dashboard;
}
}
Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowActionCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowActionCommand.java 2007-05-15 12:35:46 UTC (rev 7251)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/action/InvokePortletWindowActionCommand.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -33,7 +33,6 @@
import org.jboss.portal.core.controller.command.info.CommandInfo;
import org.jboss.portal.core.controller.portlet.PortletInvocationFactory;
import org.jboss.portal.core.model.portal.command.response.PortletWindowResponse;
-import org.jboss.portal.core.model.portal.command.action.InvokeWindowCommand;
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.instance.Instance;
import org.jboss.portal.core.model.content.Content;
Added: trunk/core/src/main/org/jboss/portal/core/model/portal/command/mapping/DashboardPortalObjectPathMapper.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/command/mapping/DashboardPortalObjectPathMapper.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/mapping/DashboardPortalObjectPathMapper.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -0,0 +1,144 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * 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.portal.command.mapping;
+
+import org.jboss.portal.core.model.portal.PortalObject;
+import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.portal.Portal;
+import org.jboss.portal.core.model.portal.Context;
+import org.jboss.portal.core.model.portal.PortalObjectContainer;
+import org.jboss.portal.core.model.CustomizationManager;
+import org.jboss.portal.core.controller.ControllerContext;
+import org.jboss.portal.server.servlet.PathMapping;
+import org.jboss.portal.server.servlet.PathParser;
+import org.jboss.portal.server.servlet.PathMappingResult;
+import org.jboss.portal.identity.User;
+import org.jboss.portal.common.text.FastURLEncoder;
+
+import java.util.Iterator;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class DashboardPortalObjectPathMapper implements PortalObjectPathMapper
+{
+
+ /** . */
+ protected PortalObjectContainer container;
+
+ /** . */
+ protected CustomizationManager customizationManager;
+
+ /** . */
+ protected PathParser pathParser = new PathParser();
+
+ public CustomizationManager getCustomizationManager()
+ {
+ return customizationManager;
+ }
+
+ public void setCustomizationManager(CustomizationManager customizationManager)
+ {
+ this.customizationManager = customizationManager;
+ }
+
+ public PortalObjectContainer getContainer()
+ {
+ return container;
+ }
+
+ public void setContainer(PortalObjectContainer container)
+ {
+ this.container = container;
+ }
+
+ public PortalObject getTarget(ControllerContext controllerContext, String path)
+ {
+ User user = controllerContext.getUser();
+
+ //
+ if (user == null)
+ {
+ return container.getContext("dashboard");
+ }
+ else
+ {
+ Portal dashboard = customizationManager.getDashboard(user);
+
+ //
+ if (path.length() == 0 || "/".equals(path))
+ {
+ return dashboard;
+ }
+ else
+ {
+ PathMapping mapping = new DashboardPathMapper(dashboard);
+ PathMappingResult result = pathParser.map(mapping, path);
+ return (PortalObject)result.getTarget();
+ }
+ }
+ }
+
+ public void appendPath(StringBuffer buffer, PortalObjectId id)
+ {
+ Iterator iterator = id.getPath().names();
+
+ // Should always be true, we skip the dashboard name
+ if (iterator.hasNext())
+ {
+ iterator.next();
+ }
+
+ //
+ while (iterator.hasNext())
+ {
+ String name = (String)iterator.next();
+ name = FastURLEncoder.DEFAULT_ENCODER.encode(name);
+ buffer.append('/').append(name);
+ }
+ }
+
+ private static class DashboardPathMapper implements PathMapping
+ {
+
+ /** . */
+ private final Portal dashboard;
+
+ public DashboardPathMapper(Portal dashboard)
+ {
+ this.dashboard = dashboard;
+ }
+
+ public Object getRoot()
+ {
+ return dashboard;
+ }
+
+ public Object getChild(Object parent, String name)
+ {
+ PortalObject po = (PortalObject)parent;
+ return po.getChild(name);
+ }
+ }
+}
Added: trunk/core/src/main/org/jboss/portal/core/model/portal/command/mapping/DefaultPortalObjectPathMapper.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/command/mapping/DefaultPortalObjectPathMapper.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/mapping/DefaultPortalObjectPathMapper.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -0,0 +1,132 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * 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.portal.command.mapping;
+
+import org.jboss.portal.server.servlet.PathMapping;
+import org.jboss.portal.server.servlet.PathMappingResult;
+import org.jboss.portal.server.servlet.PathParser;
+import org.jboss.portal.core.controller.ControllerContext;
+import org.jboss.portal.core.model.portal.PortalObjectContainer;
+import org.jboss.portal.core.model.portal.PortalObject;
+import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.common.text.FastURLEncoder;
+
+import java.util.Iterator;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class DefaultPortalObjectPathMapper implements PortalObjectPathMapper
+{
+
+ /** . */
+ protected String namespace;
+
+ /** . */
+ protected PortalObjectContainer container;
+
+ /** . */
+ protected PathMapping mapping;
+
+ /** . */
+ protected PathParser pathParser = new PathParser();
+
+ /** . */
+ protected String effectiveNamespace;
+
+ public String getNamespace()
+ {
+ return namespace;
+ }
+
+ public void setNamespace(String namespace)
+ {
+ this.namespace = namespace;
+ }
+
+ public PortalObjectContainer getContainer()
+ {
+ return container;
+ }
+
+ public void setContainer(PortalObjectContainer container)
+ {
+ this.container = container;
+ }
+
+ public void start()
+ {
+ effectiveNamespace = namespace == null ? "" : namespace;
+ mapping = new PathMapping()
+ {
+ public Object getRoot()
+ {
+ return container.getContext(namespace != null ? namespace : "");
+ }
+ public Object getChild(Object parent, String name)
+ {
+ PortalObject po = (PortalObject)parent;
+ return po.getChild(name);
+ }
+ };
+ }
+
+ public void stop()
+ {
+ mapping = null;
+ }
+
+ public PortalObject getTarget(ControllerContext controllerContext, String path)
+ {
+ if (path.length() == 0 || "/".equals(path))
+ {
+ return container.getContext(effectiveNamespace);
+ }
+ else
+ {
+ PathMappingResult result = pathParser.map(mapping, path);
+ return (PortalObject)result.getTarget();
+ }
+ }
+
+ public PortalObject getDefaultTarget()
+ {
+ return container.getContext(namespace);
+ }
+
+ public PathMapping createPathMapper(ControllerContext controllerContext)
+ {
+ return mapping;
+ }
+
+ public void appendPath(StringBuffer buffer, PortalObjectId id)
+ {
+ for (Iterator i = id.getPath().names();i.hasNext();)
+ {
+ String name = (String)i.next();
+ name = FastURLEncoder.DEFAULT_ENCODER.encode(name);
+ buffer.append('/').append(name);
+ }
+ }
+}
Added: trunk/core/src/main/org/jboss/portal/core/model/portal/command/mapping/PortalObjectPathMapper.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/command/mapping/PortalObjectPathMapper.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/mapping/PortalObjectPathMapper.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -0,0 +1,40 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * 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.portal.command.mapping;
+
+import org.jboss.portal.core.controller.ControllerContext;
+import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.portal.PortalObject;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface PortalObjectPathMapper
+{
+
+ PortalObject getTarget(ControllerContext controllerContext, String path);
+
+ void appendPath(StringBuffer buffer, PortalObjectId id);
+
+}
Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderPageCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderPageCommand.java 2007-05-15 12:35:46 UTC (rev 7251)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderPageCommand.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -34,6 +34,7 @@
import org.jboss.portal.core.model.portal.PortalObjectPermission;
import org.jboss.portal.core.model.portal.Window;
import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.portal.PortalObjectPath;
import org.jboss.portal.core.model.portal.command.PageCommand;
import org.jboss.portal.identity.User;
import org.jboss.portal.identity.UserProfileModule;
@@ -120,8 +121,7 @@
super.enforceSecurity(pam);
// Check if the user can personalize the page
- PortalObjectId uri = page.getId();
- PortalObjectPermission perm = new PortalObjectPermission(uri, PortalObjectPermission.PERSONALIZE_MASK);
+ PortalObjectPermission perm = new PortalObjectPermission(page.getId(), PortalObjectPermission.PERSONALIZE_MASK);
personalizable = pam.checkPermission(perm);
}
@@ -216,7 +216,7 @@
String region = window.getDeclaredProperty(ThemeConstants.PORTAL_PROP_REGION);
String order = window.getDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER);
WindowContext wc = new WindowContext(
- window.getId().toString(PortalObjectId.LEGACY_BASE64_FORMAT),
+ window.getId().toString(PortalObjectPath.LEGACY_BASE64_FORMAT),
region,
Integer.parseInt(order),
result);
Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderWindowCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderWindowCommand.java 2007-05-15 12:35:46 UTC (rev 7251)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderWindowCommand.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -26,6 +26,7 @@
import org.jboss.portal.core.controller.command.info.ViewCommandInfo;
import org.jboss.portal.core.controller.ControllerException;
import org.jboss.portal.core.controller.ControllerResponse;
+import org.jboss.portal.core.controller.portlet.InvokePortletCommandFactory;
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.portal.command.WindowCommand;
import org.jboss.portal.core.model.portal.content.ContentRendererRegistry;
@@ -63,6 +64,9 @@
/** . */
private static final CommandInfo info = new ViewCommandInfo();
+ /** . */
+ private InvokePortletCommandFactory invokePortletCommandFactory;
+
public RenderWindowCommand(PortalObjectId windowId)
throws IllegalArgumentException
{
Added: trunk/core/src/main/org/jboss/portal/core/model/portal/command/view/ViewContextCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/command/view/ViewContextCommand.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/view/ViewContextCommand.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -0,0 +1,81 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * 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.portal.command.view;
+
+import org.jboss.portal.core.model.portal.command.PageCommand;
+import org.jboss.portal.core.model.portal.command.ContextCommand;
+import org.jboss.portal.core.model.portal.command.response.UpdatePageResponse;
+import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.portal.Portal;
+import org.jboss.portal.core.model.portal.Page;
+import org.jboss.portal.core.controller.command.info.CommandInfo;
+import org.jboss.portal.core.controller.command.info.ViewCommandInfo;
+import org.jboss.portal.core.controller.ControllerResponse;
+import org.jboss.portal.core.controller.ControllerException;
+import org.jboss.portal.core.controller.ControllerSecurityException;
+import org.jboss.portal.security.spi.auth.PortalAuthorizationManager;
+import org.jboss.portal.security.PortalSecurityException;
+import org.jboss.portal.identity.User;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ViewContextCommand extends ContextCommand
+{
+
+ /** . */
+ private static final CommandInfo info = new ViewCommandInfo();
+
+ public ViewContextCommand(PortalObjectId pageId)
+ {
+ super(pageId);
+ }
+
+ public CommandInfo getInfo()
+ {
+ return info;
+ }
+
+ public void enforceSecurity(PortalAuthorizationManager pam) throws ControllerSecurityException, PortalSecurityException
+ {
+ super.enforceSecurity(pam);
+ }
+
+ public ControllerResponse execute() throws ControllerException
+ {
+ if (isDashboard())
+ {
+ User user = context.getUser();
+ Portal portal = context.getController().getCustomizationManager().getDashboard(user);
+ Page page = portal.getDefaultPage();
+ return new UpdatePageResponse(page.getId());
+ }
+ else
+ {
+ Portal portal = root.getDefaultPortal();
+ Page page = portal.getDefaultPage();
+ return new UpdatePageResponse(page.getId());
+ }
+ }
+}
Deleted: trunk/core/src/main/org/jboss/portal/core/model/portal/command/view/ViewDashboardCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/command/view/ViewDashboardCommand.java 2007-05-15 12:35:46 UTC (rev 7251)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/view/ViewDashboardCommand.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -1,112 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, 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. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * 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.portal.command.view;
-
-import org.jboss.portal.core.controller.ControllerException;
-import org.jboss.portal.core.controller.ControllerSecurityException;
-import org.jboss.portal.core.controller.ControllerResponse;
-import org.jboss.portal.core.controller.command.info.CommandInfo;
-import org.jboss.portal.core.controller.command.info.ViewCommandInfo;
-import org.jboss.portal.core.model.portal.command.response.UpdatePageResponse;
-import org.jboss.portal.core.model.portal.command.DashboardCommand;
-import org.jboss.portal.core.model.portal.Page;
-import org.jboss.portal.core.model.portal.Portal;
-import org.jboss.portal.core.model.CustomizationManager;
-import org.jboss.portal.security.PortalSecurityException;
-import org.jboss.portal.security.spi.auth.PortalAuthorizationManager;
-import org.jboss.portal.identity.User;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class ViewDashboardCommand extends DashboardCommand
-{
-
- /** . */
- private static final CommandInfo info = new ViewCommandInfo();
-
- /** . */
- private Portal dashboardPortal;
-
- /** . */
- private Page dashboardPage;
-
- /** . */
- private User user;
-
- public ViewDashboardCommand()
- {
- }
-
- public CommandInfo getInfo()
- {
- return info;
- }
-
- public Portal getDashboardPortal()
- {
- return dashboardPortal;
- }
-
- public Page getDashboardPage()
- {
- return dashboardPage;
- }
-
- /**
- * Initialize the command
- *
- * @throws org.jboss.portal.common.invocation.InvocationException
- *
- */
- public void create() throws ControllerException
- {
- super.create();
-
- //
- CustomizationManager manager = getControllerContext().getController().getCustomizationManager();
-
- //
- user = getControllerContext().getUser();
-
- //
- dashboardPortal = manager.getDashboard(user);
-
- //
- dashboardPage = dashboardPortal.getDefaultPage();
- }
-
- public void enforceSecurity(PortalAuthorizationManager pam) throws ControllerSecurityException, PortalSecurityException
- {
- if (user == null)
- {
- throw new ControllerSecurityException("User needs to be authenticated to view a dashboard");
- }
- }
-
- public ControllerResponse execute() throws ControllerException
- {
- return new UpdatePageResponse(dashboardPage.getId());
- }
-}
\ No newline at end of file
Added: trunk/core/src/main/org/jboss/portal/core/model/portal/command/view/ViewPortalCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/command/view/ViewPortalCommand.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/view/ViewPortalCommand.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -0,0 +1,58 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * 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.portal.command.view;
+
+import org.jboss.portal.core.model.portal.command.PageCommand;
+import org.jboss.portal.core.model.portal.command.PortalCommand;
+import org.jboss.portal.core.model.portal.command.response.UpdatePageResponse;
+import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.controller.command.info.CommandInfo;
+import org.jboss.portal.core.controller.command.info.ViewCommandInfo;
+import org.jboss.portal.core.controller.ControllerResponse;
+import org.jboss.portal.core.controller.ControllerException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ViewPortalCommand extends PortalCommand
+{
+
+ /** . */
+ private static final CommandInfo info = new ViewCommandInfo();
+
+ public ViewPortalCommand(PortalObjectId pageId)
+ {
+ super(pageId);
+ }
+
+ public CommandInfo getInfo()
+ {
+ return info;
+ }
+
+ public ControllerResponse execute() throws ControllerException
+ {
+ return new UpdatePageResponse(portal.getDefaultPage().getId());
+ }
+}
Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/ContextMetaData.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/ContextMetaData.java 2007-05-15 12:35:46 UTC (rev 7251)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/ContextMetaData.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -24,6 +24,7 @@
import org.jboss.portal.core.model.portal.PortalObject;
import org.jboss.portal.core.model.portal.PortalContainer;
+import org.jboss.portal.core.model.portal.PortalObjectContainer;
import org.jboss.portal.core.model.content.spi.ContentProviderRegistry;
import org.jboss.portal.common.util.XML;
import org.w3c.dom.Element;
@@ -39,13 +40,22 @@
protected PortalObject newInstance(BuildContext buildContext, PortalObject parent) throws Exception
{
- if (parent instanceof PortalContainer == false)
- {
- throw new IllegalArgumentException("Not a context");
- }
+// if (parent instanceof PortalContainer == false)
+// {
+// throw new IllegalArgumentException("Not a context");
+// }
+//
+// //
+// return ((PortalContainer)parent).createPortalContainer(getName());
+ // Get portal object container
+ PortalObjectContainer portalObjectContainer = buildContext.getContainer();
+
+ // Get namespace value
+ String namespace = getName();
+
//
- return ((PortalContainer)parent).createPortalContainer(getName());
+ return portalObjectContainer.createContext(namespace);
}
/** Parse the following XML elements : context-name. */
@@ -55,14 +65,14 @@
//
String contextName = XML.asString(XML.getUniqueChild(contextElt, "context-name", true));
- if (contextName != null && contextName.length() > 0 && contextName.indexOf(".") < 0)
+ if (contextName != null && contextName.indexOf(".") < 0 && contextName.indexOf(":") < 0)
{
contextMD.setName(contextName);
}
else
{
throw new IllegalArgumentException("Invalid context-name: '" + contextName
- + "'. Must not be null, empty or contain a '.'");
+ + "'. Must not be null and must not contain a '.' or ':'");
}
//
Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PortalObjectMetaData.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PortalObjectMetaData.java 2007-05-15 12:35:46 UTC (rev 7251)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PortalObjectMetaData.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -28,8 +28,8 @@
import org.jboss.portal.core.model.content.spi.ContentProviderRegistry;
import org.jboss.portal.core.model.portal.PortalObject;
import org.jboss.portal.core.model.portal.PortalObjectContainer;
-import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.portal.PortalObjectPermission;
+import org.jboss.portal.core.model.portal.PortalObjectPath;
import org.jboss.portal.security.RoleSecurityBinding;
import org.jboss.portal.security.SecurityConstants;
import org.jboss.portal.security.metadata.SecurityConstraintsMetaData;
@@ -192,7 +192,7 @@
// Apply the constraint
PortalObjectContainer poc = buildContext.getContainer();
DomainConfigurator domainConfigurator = poc.getAuthorizationDomain().getConfigurator();
- domainConfigurator.setSecurityBindings(object.getId().toString(PortalObjectId.CANONICAL_FORMAT), securityConstraints.getConstraints());
+ domainConfigurator.setSecurityBindings(object.getId().toString(PortalObjectPath.CANONICAL_FORMAT), securityConstraints.getConstraints());
}
}
Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/portlet/WindowContextImpl.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/portlet/WindowContextImpl.java 2007-05-15 12:35:46 UTC (rev 7251)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/portlet/WindowContextImpl.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -24,7 +24,7 @@
import org.jboss.portal.portlet.spi.WindowContext;
import org.jboss.portal.core.model.portal.Window;
-import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.portal.PortalObjectPath;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -46,6 +46,6 @@
public String getId()
{
- return window.getId().toString(PortalObjectId.CANONICAL_FORMAT);
+ return window.getId().toString(PortalObjectPath.CANONICAL_FORMAT);
}
}
Modified: trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectContainerTestCase.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectContainerTestCase.java 2007-05-15 12:35:46 UTC (rev 7251)
+++ trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectContainerTestCase.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -30,6 +30,7 @@
import org.jboss.portal.core.model.portal.Window;
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.portal.PortalObjectContainer;
+import org.jboss.portal.core.model.portal.PortalObjectPath;
import org.jboss.portal.core.model.content.ContentType;
import org.jboss.portal.core.model.content.spi.handler.ContentState;
import org.jboss.portal.test.core.PortalBaseTestCase;
@@ -102,6 +103,10 @@
{
super.setUp();
+ // Create root context
+ TransactionAssert.beginTransaction();
+ container.createContext("");
+ TransactionAssert.commitTransaction();
}
public void tearDown() throws Exception
@@ -113,7 +118,7 @@
public void testRootNodeCreation() throws Exception
{
TransactionAssert.beginTransaction();
- PortalObject root = container.getRootObject();
+ PortalObject root = container.getContext();
assertNotNull(root);
TransactionAssert.commitTransaction();
}
@@ -121,7 +126,7 @@
public void testCRUD() throws Exception
{
TransactionAssert.beginTransaction();
- PortalContainer ctx = (PortalContainer)container.getRootObject();
+ PortalContainer ctx = (PortalContainer)container.getContext();
Portal portal = ctx.createPortal("default");
PortalObjectId portalId = portal.getId();
assertNotNull(portalId);
@@ -178,7 +183,7 @@
//
TransactionAssert.beginTransaction();
- ctx = (PortalContainer)container.getRootObject();
+ ctx = (PortalContainer)container.getContext();
assertNotNull(ctx);
portal = ctx.getPortal("default");
assertNotNull(portal);
@@ -193,7 +198,7 @@
//
TransactionAssert.beginTransaction();
- ctx = (PortalContainer)container.getRootObject();
+ ctx = (PortalContainer)container.getContext();
assertNotNull(ctx);
ctx.destroyChild("default");
portal = ctx.getPortal("default");
@@ -202,7 +207,7 @@
//
TransactionAssert.beginTransaction();
- ctx = (PortalContainer)container.getRootObject();
+ ctx = (PortalContainer)container.getContext();
portal = ctx.getPortal("default");
assertNull(portal);
TransactionAssert.commitTransaction();
@@ -211,7 +216,7 @@
public void testGetChildren() throws Exception
{
TransactionAssert.beginTransaction();
- PortalContainer ctx = (PortalContainer)container.getRootObject();
+ PortalContainer ctx = (PortalContainer)container.getContext();
Portal portal_1 = ctx.createPortal("1");
Page page_1_1 = portal_1.createPage("1");
Page page_1_2 = portal_1.createPage("2");
@@ -223,7 +228,7 @@
//
TransactionAssert.beginTransaction();
- PortalObject o_1 = container.getRootObject().getChild("1");
+ PortalObject o_1 = container.getContext().getChild("1");
PortalObject o_1_1 = o_1.getChild("1");
PortalObject o_1_2 = o_1.getChild("2");
PortalObject o_1_1_1 = o_1_1.getChild("1");
@@ -255,11 +260,11 @@
public void testRecreate() throws Exception
{
- PortalObjectId defaultId = new PortalObjectId(new String[]{"default"});
+ PortalObjectId defaultId = PortalObjectId.parse("/default", PortalObjectPath.CANONICAL_FORMAT);
//
TransactionAssert.beginTransaction();
- PortalContainer ctx = (PortalContainer)container.getRootObject();
+ PortalContainer ctx = (PortalContainer)container.getContext();
Portal portal = ctx.createPortal("default");
assertNotNull(portal);
@@ -285,11 +290,11 @@
*/
public void testCopy() throws Exception
{
- PortalObjectId defaultId = new PortalObjectId(new String[]{"portal"});
+ PortalObjectId defaultId = PortalObjectId.parse("/portal", PortalObjectPath.CANONICAL_FORMAT);
//
TransactionAssert.beginTransaction();
- PortalContainer ctx = (PortalContainer)container.getRootObject();
+ PortalContainer ctx = (PortalContainer)container.getContext();
Portal portal = ctx.createPortal("portal");
portal.setDeclaredProperty("portalname", "portalvalue");
portal.getSupportedWindowStates().add(WindowState.NORMAL);
@@ -307,7 +312,7 @@
//
TransactionAssert.beginTransaction();
- ctx = (PortalContainer)container.getRootObject();
+ ctx = (PortalContainer)container.getContext();
portal = (Portal)container.getObject(defaultId);
portal = (Portal)portal.copy(ctx, "copy", true);
assertNotNull(portal);
Modified: trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectIdTestCase.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectIdTestCase.java 2007-05-15 12:35:46 UTC (rev 7251)
+++ trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectIdTestCase.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -23,6 +23,7 @@
package org.jboss.portal.test.core.model.portal;
import junit.framework.TestCase;
+import org.jboss.portal.core.model.portal.PortalObjectPath;
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.common.util.Tools;
import org.jboss.portal.common.junit.ExtendedAssert;
@@ -33,149 +34,23 @@
*/
public class PortalObjectIdTestCase extends TestCase
{
-
- public void testIAE()
- {
- try
- {
- PortalObjectId.parse("/", null);
- fail();
- }
- catch (IllegalArgumentException e)
- {
- }
- try
- {
- PortalObjectId.parse(null, PortalObjectId.CANONICAL_FORMAT);
- fail();
- }
- catch (IllegalArgumentException e)
- {
- }
- try
- {
- PortalObjectId.parse(null, PortalObjectId.LEGACY_FORMAT);
- fail();
- }
- catch (IllegalArgumentException e)
- {
- }
- try
- {
- new PortalObjectId((String[])null);
- fail();
- }
- catch (IllegalArgumentException e)
- {
- }
- try
- {
- new PortalObjectId((PortalObjectId)null);
- fail();
- }
- catch (IllegalArgumentException e)
- {
- }
- try
- {
- new PortalObjectId(null, PortalObjectId.CANONICAL_FORMAT);
- fail();
- }
- catch (IllegalArgumentException e)
- {
- }
- try
- {
- new PortalObjectId(null, PortalObjectId.LEGACY_FORMAT);
- fail();
- }
- catch (IllegalArgumentException e)
- {
- }
- try
- {
- new PortalObjectId(new String[0]).toString(null);
- fail();
- }
- catch (IllegalArgumentException e)
- {
- }
- }
-
- public void testFormatIAE()
- {
- testFormatIAE(PortalObjectId.CANONICAL_FORMAT);
- testFormatIAE(PortalObjectId.LEGACY_FORMAT);
- }
-
- private void testFormatIAE(PortalObjectId.Format format)
- {
- try
- {
- format.toString(null, 0, 0);
- fail();
- }
- catch (IllegalArgumentException expected)
- {
- }
- try
- {
- format.toString((PortalObjectId)null);
- fail();
- }
- catch (IllegalArgumentException expected)
- {
- }
- try
- {
- format.toString(new String[]{"a",null,"b"}, 0, 3);
- fail();
- }
- catch (IllegalArgumentException expected)
- {
- }
- }
-
public void testCanonicalFormat()
{
- assertEquals(new PortalObjectId(new String[]{}), PortalObjectId.parse("/", PortalObjectId.CANONICAL_FORMAT));
- assertEquals(new PortalObjectId(new String[]{"a"}), PortalObjectId.parse("/a", PortalObjectId.CANONICAL_FORMAT));
- assertEquals(new PortalObjectId(new String[]{"a","b"}), PortalObjectId.parse("/a/b", PortalObjectId.CANONICAL_FORMAT));
+ assertEquals(new PortalObjectId("", new PortalObjectPath(new String[]{})), PortalObjectId.parse("/", PortalObjectPath.CANONICAL_FORMAT));
+ assertEquals(new PortalObjectId("", new PortalObjectPath(new String[]{"a"})), PortalObjectId.parse("/a", PortalObjectPath.CANONICAL_FORMAT));
+ assertEquals(new PortalObjectId("", new PortalObjectPath(new String[]{"a","b"})), PortalObjectId.parse("/a/b", PortalObjectPath.CANONICAL_FORMAT));
+ assertEquals(new PortalObjectId("ns", new PortalObjectPath(new String[]{})), PortalObjectId.parse("ns:/", PortalObjectPath.CANONICAL_FORMAT));
+ assertEquals(new PortalObjectId("ns", new PortalObjectPath(new String[]{"a"})), PortalObjectId.parse("ns:/a", PortalObjectPath.CANONICAL_FORMAT));
+ assertEquals(new PortalObjectId("ns", new PortalObjectPath(new String[]{"a","b"})), PortalObjectId.parse("ns:/a/b", PortalObjectPath.CANONICAL_FORMAT));
}
public void testLegacyFormat()
{
- assertEquals(new PortalObjectId(new String[]{}), PortalObjectId.parse("", PortalObjectId.LEGACY_FORMAT));
- assertEquals(new PortalObjectId(new String[]{"a"}), PortalObjectId.parse("a", PortalObjectId.LEGACY_FORMAT));
- assertEquals(new PortalObjectId(new String[]{"a","b"}), PortalObjectId.parse("a.b", PortalObjectId.LEGACY_FORMAT));
+ assertEquals(new PortalObjectId("", new PortalObjectPath(new String[]{})), PortalObjectId.parse("", PortalObjectPath.LEGACY_FORMAT));
+ assertEquals(new PortalObjectId("", new PortalObjectPath(new String[]{"a"})), PortalObjectId.parse("a", PortalObjectPath.LEGACY_FORMAT));
+ assertEquals(new PortalObjectId("", new PortalObjectPath(new String[]{"a","b"})), PortalObjectId.parse("a.b", PortalObjectPath.LEGACY_FORMAT));
+ assertEquals(new PortalObjectId("ns", new PortalObjectPath(new String[]{})), PortalObjectId.parse("ns:", PortalObjectPath.LEGACY_FORMAT));
+ assertEquals(new PortalObjectId("ns", new PortalObjectPath(new String[]{"a"})), PortalObjectId.parse("ns:a", PortalObjectPath.LEGACY_FORMAT));
+ assertEquals(new PortalObjectId("ns", new PortalObjectPath(new String[]{"a","b"})), PortalObjectId.parse("ns:a.b", PortalObjectPath.LEGACY_FORMAT));
}
-
- public void testEquals()
- {
- assertTrue(new PortalObjectId(new String[]{}).equals(new PortalObjectId(new String[]{})));
- assertFalse(new PortalObjectId(new String[]{}).equals(new PortalObjectId(new String[]{"a"})));
- assertFalse(new PortalObjectId(new String[]{}).equals(new PortalObjectId(new String[]{"a","b"})));
- assertFalse(new PortalObjectId(new String[]{"a"}).equals(new PortalObjectId(new String[]{})));
- assertTrue(new PortalObjectId(new String[]{"a"}).equals(new PortalObjectId(new String[]{"a"})));
- assertFalse(new PortalObjectId(new String[]{"a"}).equals(new PortalObjectId(new String[]{"a","b"})));
- assertFalse(new PortalObjectId(new String[]{"a","b"}).equals(new PortalObjectId(new String[]{})));
- assertFalse(new PortalObjectId(new String[]{"a","b"}).equals(new PortalObjectId(new String[]{"a"})));
- assertTrue(new PortalObjectId(new String[]{"a","b"}).equals(new PortalObjectId(new String[]{"a","b"})));
- }
-
- public void testComparable()
- {
- assertTrue(new PortalObjectId(new String[]{"a"}).compareTo(new PortalObjectId(new String[]{"a"})) == 0);
- assertTrue(new PortalObjectId(new String[]{"a"}).compareTo(new PortalObjectId(new String[]{"b"})) < 0);
- assertTrue(new PortalObjectId(new String[]{"b"}).compareTo(new PortalObjectId(new String[]{"a"})) > 0);
- assertTrue(new PortalObjectId(new String[]{"a"}).compareTo(new PortalObjectId(new String[]{"a","b"})) > 0);
- assertTrue(new PortalObjectId(new String[]{"a","b"}).compareTo(new PortalObjectId(new String[]{"a"})) < 0);
- }
-
- public void testIterator()
- {
- ExtendedAssert.assertEquals(new Object[]{}, Tools.toArray(new PortalObjectId(new String[]{}).names()));
- ExtendedAssert.assertEquals(new Object[]{"a"}, Tools.toArray(new PortalObjectId(new String[]{"a"}).names()));
- ExtendedAssert.assertEquals(new Object[]{"a","b"}, Tools.toArray(new PortalObjectId(new String[]{"a","b"}).names()));
- }
}
Added: trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectPathTestCase.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectPathTestCase.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectPathTestCase.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -0,0 +1,195 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * 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.test.core.model.portal;
+
+import junit.framework.TestCase;
+import org.jboss.portal.core.model.portal.PortalObjectPath;
+import org.jboss.portal.common.junit.ExtendedAssert;
+import org.jboss.portal.common.util.Tools;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PortalObjectPathTestCase extends TestCase
+{
+
+ public void testIAE()
+ {
+ try
+ {
+ PortalObjectPath.parse("/", null);
+ fail();
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ try
+ {
+ PortalObjectPath.parse(null, PortalObjectPath.CANONICAL_FORMAT);
+ fail();
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ try
+ {
+ PortalObjectPath.parse(null, PortalObjectPath.LEGACY_FORMAT);
+ fail();
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ try
+ {
+ new PortalObjectPath((String[])null);
+ fail();
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ try
+ {
+ new PortalObjectPath((PortalObjectPath)null);
+ fail();
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ try
+ {
+ new PortalObjectPath(null, PortalObjectPath.CANONICAL_FORMAT);
+ fail();
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ try
+ {
+ new PortalObjectPath(null, PortalObjectPath.LEGACY_FORMAT);
+ fail();
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ try
+ {
+ new PortalObjectPath(new String[0]).toString(null);
+ fail();
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ }
+
+ public void testFormatIAE()
+ {
+ testFormatIAE(PortalObjectPath.CANONICAL_FORMAT);
+ testFormatIAE(PortalObjectPath.LEGACY_FORMAT);
+ }
+
+ private void testFormatIAE(PortalObjectPath.Format format)
+ {
+ try
+ {
+ format.toString(null, 0, 0);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ format.toString((PortalObjectPath)null);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ format.toString(new String[]{"a",null,"b"}, 0, 3);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+
+ public void testCanonicalFormat()
+ {
+ assertEquals(new PortalObjectPath(new String[]{}), PortalObjectPath.parse("/", PortalObjectPath.CANONICAL_FORMAT));
+ assertEquals(new PortalObjectPath(new String[]{"a"}), PortalObjectPath.parse("/a", PortalObjectPath.CANONICAL_FORMAT));
+ assertEquals(new PortalObjectPath(new String[]{"a","b"}), PortalObjectPath.parse("/a/b", PortalObjectPath.CANONICAL_FORMAT));
+ }
+
+ public void testLegacyFormat()
+ {
+ assertEquals(new PortalObjectPath(new String[]{}), PortalObjectPath.parse("", PortalObjectPath.LEGACY_FORMAT));
+ assertEquals(new PortalObjectPath(new String[]{"a"}), PortalObjectPath.parse("a", PortalObjectPath.LEGACY_FORMAT));
+ assertEquals(new PortalObjectPath(new String[]{"a","b"}), PortalObjectPath.parse("a.b", PortalObjectPath.LEGACY_FORMAT));
+ }
+
+ public void testEquals()
+ {
+ assertTrue(new PortalObjectPath(new String[]{}).equals(new PortalObjectPath(new String[]{})));
+ assertFalse(new PortalObjectPath(new String[]{}).equals(new PortalObjectPath(new String[]{"a"})));
+ assertFalse(new PortalObjectPath(new String[]{}).equals(new PortalObjectPath(new String[]{"a","b"})));
+ assertFalse(new PortalObjectPath(new String[]{"a"}).equals(new PortalObjectPath(new String[]{})));
+ assertTrue(new PortalObjectPath(new String[]{"a"}).equals(new PortalObjectPath(new String[]{"a"})));
+ assertFalse(new PortalObjectPath(new String[]{"a"}).equals(new PortalObjectPath(new String[]{"a","b"})));
+ assertFalse(new PortalObjectPath(new String[]{"a","b"}).equals(new PortalObjectPath(new String[]{})));
+ assertFalse(new PortalObjectPath(new String[]{"a","b"}).equals(new PortalObjectPath(new String[]{"a"})));
+ assertTrue(new PortalObjectPath(new String[]{"a","b"}).equals(new PortalObjectPath(new String[]{"a","b"})));
+ }
+
+ public void testComparable()
+ {
+ assertTrue(new PortalObjectPath(new String[]{"a"}).compareTo(new PortalObjectPath(new String[]{"a"})) == 0);
+ assertTrue(new PortalObjectPath(new String[]{"a"}).compareTo(new PortalObjectPath(new String[]{"b"})) < 0);
+ assertTrue(new PortalObjectPath(new String[]{"b"}).compareTo(new PortalObjectPath(new String[]{"a"})) > 0);
+ assertTrue(new PortalObjectPath(new String[]{"a"}).compareTo(new PortalObjectPath(new String[]{"a","b"})) > 0);
+ assertTrue(new PortalObjectPath(new String[]{"a","b"}).compareTo(new PortalObjectPath(new String[]{"a"})) < 0);
+ }
+
+ public void testIterator()
+ {
+ ExtendedAssert.assertEquals(new Object[]{}, Tools.toArray(new PortalObjectPath(new String[]{}).names()));
+ ExtendedAssert.assertEquals(new Object[]{"a"}, Tools.toArray(new PortalObjectPath(new String[]{"a"}).names()));
+ ExtendedAssert.assertEquals(new Object[]{"a","b"}, Tools.toArray(new PortalObjectPath(new String[]{"a","b"}).names()));
+ }
+
+ public void testGetChild()
+ {
+ assertEquals(new PortalObjectPath(new String[]{"a"}), new PortalObjectPath(new String[]{}).getChild("a"));
+ assertEquals(new PortalObjectPath(new String[]{"a","b"}), new PortalObjectPath(new String[]{"a"}).getChild("b"));
+ }
+
+ public void testGetParent()
+ {
+ assertEquals(null, new PortalObjectPath(new String[]{}).getParent());
+ assertEquals(new PortalObjectPath(new String[]{}), new PortalObjectPath(new String[]{"a"}).getParent());
+ assertEquals(new PortalObjectPath(new String[]{"a"}), new PortalObjectPath(new String[]{"a","b"}).getParent());
+ assertEquals(new PortalObjectPath(new String[]{"a","b"}), new PortalObjectPath(new String[]{"a","b","c"}).getParent());
+ }
+}
Modified: trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectPermissionTestCase.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectPermissionTestCase.java 2007-05-15 12:35:46 UTC (rev 7251)
+++ trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectPermissionTestCase.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -24,6 +24,7 @@
import org.jboss.portal.core.model.portal.PortalObjectPermission;
import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.portal.PortalObjectPath;
import org.jboss.portal.identity.auth.UserPrincipal;
import org.jboss.portal.security.PortalPermission;
import org.jboss.portal.security.PortalPermissionCollection;
@@ -56,8 +57,8 @@
public void testImplies1()
{
- PortalObjectPermission v = new PortalObjectPermission(new PortalObjectId(new String[]{"abc"}), "view");
- PortalObjectPermission vr = new PortalObjectPermission(new PortalObjectId(new String[]{"abc"}), "viewrecursive");
+ PortalObjectPermission v = new PortalObjectPermission(new PortalObjectId("", new PortalObjectPath(new String[]{"abc"})), "view");
+ PortalObjectPermission vr = new PortalObjectPermission(new PortalObjectId("", new PortalObjectPath(new String[]{"abc"})), "viewrecursive");
assertTrue(v.implies(v));
assertTrue(v.implies(vr));
assertTrue(vr.implies(v));
@@ -66,8 +67,8 @@
public void testImplies2()
{
- PortalObjectPermission v = new PortalObjectPermission(new PortalObjectId(new String[]{"abc"}), "view");
- PortalObjectPermission vr = new PortalObjectPermission(new PortalObjectId(new String[]{"abc","def"}), "viewrecursive");
+ PortalObjectPermission v = new PortalObjectPermission(new PortalObjectId("", new PortalObjectPath(new String[]{"abc"})), "view");
+ PortalObjectPermission vr = new PortalObjectPermission(new PortalObjectId("", new PortalObjectPath(new String[]{"abc","def"})), "viewrecursive");
assertTrue(v.implies(v));
assertFalse(v.implies(vr));
assertFalse(vr.implies(v));
@@ -76,8 +77,8 @@
public void testImplies3()
{
- PortalObjectPermission v = new PortalObjectPermission(new PortalObjectId(new String[]{"abc"}), "viewrecursive");
- PortalObjectPermission vr = new PortalObjectPermission(new PortalObjectId(new String[]{"abc","def"}), "view");
+ PortalObjectPermission v = new PortalObjectPermission(new PortalObjectId("", new PortalObjectPath(new String[]{"abc"})), "viewrecursive");
+ PortalObjectPermission vr = new PortalObjectPermission(new PortalObjectId("", new PortalObjectPath(new String[]{"abc","def"})), "view");
assertTrue(v.implies(v));
assertTrue(v.implies(vr));
assertFalse(vr.implies(v));
@@ -86,11 +87,11 @@
public void testDashboard1() throws Exception
{
- PortalObjectPermission v = new PortalObjectPermission(new PortalObjectId(new String[0]), "dashboard");
- PortalObjectPermission v1 = new PortalObjectPermission(new PortalObjectId(new String[]{"abc"}), "view");
- PortalObjectPermission v2 = new PortalObjectPermission(new PortalObjectId(new String[]{"abc","def"}), "view");
- PortalObjectPermission v3 = new PortalObjectPermission(new PortalObjectId(new String[]{"def"}), "view");
- PortalObjectPermission v4 = new PortalObjectPermission(new PortalObjectId(new String[]{"def","ghi"}), "view");
+ PortalObjectPermission v = new PortalObjectPermission(new PortalObjectId("", new PortalObjectPath(new String[0])), "dashboard");
+ PortalObjectPermission v1 = new PortalObjectPermission(new PortalObjectId("", new PortalObjectPath(new String[]{"abc"})), "view");
+ PortalObjectPermission v2 = new PortalObjectPermission(new PortalObjectId("", new PortalObjectPath(new String[]{"abc","def"})), "view");
+ PortalObjectPermission v3 = new PortalObjectPermission(new PortalObjectId("", new PortalObjectPath(new String[]{"def"})), "view");
+ PortalObjectPermission v4 = new PortalObjectPermission(new PortalObjectId("", new PortalObjectPath(new String[]{"def","ghi"})), "view");
Subject abc = new Subject();
abc.getPrincipals().add(new UserPrincipal("abc"));
@@ -128,11 +129,11 @@
public void testDashboard2() throws Exception
{
- PortalObjectPermission v = new PortalObjectPermission(new PortalObjectId(new String[]{"abc"}), "dashboard");
- PortalObjectPermission v1 = new PortalObjectPermission(new PortalObjectId(new String[]{"abc","def"}), "view");
- PortalObjectPermission v2 = new PortalObjectPermission(new PortalObjectId(new String[]{"abc","def","ghi"}), "view");
- PortalObjectPermission v3 = new PortalObjectPermission(new PortalObjectId(new String[]{"jkl"}), "view");
- PortalObjectPermission v4 = new PortalObjectPermission(new PortalObjectId(new String[]{"jkl","mno"}), "view");
+ PortalObjectPermission v = new PortalObjectPermission(new PortalObjectId("", new PortalObjectPath(new String[]{"abc"})), "dashboard");
+ PortalObjectPermission v1 = new PortalObjectPermission(new PortalObjectId("", new PortalObjectPath(new String[]{"abc","def"})), "view");
+ PortalObjectPermission v2 = new PortalObjectPermission(new PortalObjectId("", new PortalObjectPath(new String[]{"abc","def","ghi"})), "view");
+ PortalObjectPermission v3 = new PortalObjectPermission(new PortalObjectId("", new PortalObjectPath(new String[]{"jkl"})), "view");
+ PortalObjectPermission v4 = new PortalObjectPermission(new PortalObjectId("", new PortalObjectPath(new String[]{"jkl","mno"})), "view");
Subject def = new Subject();
def.getPrincipals().add(new UserPrincipal("def"));
@@ -193,13 +194,13 @@
public PortalPermission createPermission(String uri, String action) throws PortalSecurityException
{
- PortalObjectId id = PortalObjectId.parse(uri, PortalObjectId.CANONICAL_FORMAT);
+ PortalObjectId id = PortalObjectId.parse(uri, PortalObjectPath.CANONICAL_FORMAT);
return new PortalObjectPermission(id, action);
}
public PortalPermission createPermission(String uri, Collection actions) throws PortalSecurityException
{
- PortalObjectId id = PortalObjectId.parse(uri, PortalObjectId.CANONICAL_FORMAT);
+ PortalObjectId id = PortalObjectId.parse(uri, PortalObjectPath.CANONICAL_FORMAT);
return new PortalObjectPermission(id, actions);
}
};
@@ -223,9 +224,9 @@
public void execute() throws Exception
{
Principal[] principals = new Principal[]{new SimplePrincipal("admin")};
- assertTrue(implies(new PortalObjectPermission(new PortalObjectId(new String[0]), "view"), principals));
- assertTrue(implies(new PortalObjectPermission(new PortalObjectId(new String[]{"default"}), "view"), principals));
- assertTrue(implies(new PortalObjectPermission(new PortalObjectId(new String[]{"default","default"}), "view"), principals));
+ assertTrue(implies(new PortalObjectPermission(new PortalObjectId("", new PortalObjectPath(new String[0])), "view"), principals));
+ assertTrue(implies(new PortalObjectPermission(new PortalObjectId("", new PortalObjectPath(new String[]{"default"})), "view"), principals));
+ assertTrue(implies(new PortalObjectPermission(new PortalObjectId("", new PortalObjectPath(new String[]{"default","default"})), "view"), principals));
}
});
}
@@ -241,9 +242,9 @@
public void execute() throws Exception
{
Principal[] principals = new Principal[]{new SimplePrincipal("admin")};
- assertTrue(implies(new PortalObjectPermission(new PortalObjectId(new String[0]), "view"), principals));
- assertFalse(implies(new PortalObjectPermission(new PortalObjectId(new String[]{"default"}), "view"), principals));
- assertFalse(implies(new PortalObjectPermission(new PortalObjectId(new String[]{"default","default"}), "view"), principals));
+ assertTrue(implies(new PortalObjectPermission(new PortalObjectId("", new PortalObjectPath(new String[0])), "view"), principals));
+ assertFalse(implies(new PortalObjectPermission(new PortalObjectId("", new PortalObjectPath(new String[]{"default"})), "view"), principals));
+ assertFalse(implies(new PortalObjectPermission(new PortalObjectId("", new PortalObjectPath(new String[]{"default","default"})), "view"), principals));
}
});
}
Modified: trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
===================================================================
--- trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2007-05-15 12:35:46 UTC (rev 7251)
+++ trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2007-05-15 15:02:38 UTC (rev 7252)
@@ -710,17 +710,30 @@
optional-attribute-name="Container"
proxy-type="attribute">portal:container=PortalObject</depends>
</mbean>
+
<mbean
- code="org.jboss.portal.core.model.portal.PortalObjectCommandFactory"
- name="portal:commandFactory=PortalObject"
+ code="org.jboss.portal.core.model.portal.command.mapping.DefaultPortalObjectPathMapper"
+ name="portal:service=PortalObjectPathMapper,type=Default"
xmbean-dd=""
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
<xmbean/>
<depends
optional-attribute-name="Container"
proxy-type="attribute">portal:container=PortalObject</depends>
+ <attribute name="Namespace"><![CDATA[]]></attribute>
</mbean>
<mbean
+ code="org.jboss.portal.core.model.portal.PortalObjectCommandFactory"
+ name="portal:commandFactory=PortalObject"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ <depends
+ optional-attribute-name="Mapper"
+ proxy-type="attribute">portal:service=PortalObjectPathMapper,type=Default</depends>
+ </mbean>
+
+ <mbean
code="org.jboss.portal.core.controller.command.mapper.CommandFactoryDelegate"
name="portal:commandFactory=Delegate,path=portal"
xmbean-dd=""
@@ -757,12 +770,29 @@
proxy-type="attribute">portal:commandFactory=SignOut</depends>
</mbean>
<mbean
- code="org.jboss.portal.core.model.portal.DashboardCommandFactory"
+ code="org.jboss.portal.core.model.portal.command.mapping.DashboardPortalObjectPathMapper"
+ name="portal:service=PortalObjectPathMapper,type=Dashboard"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ <depends
+ optional-attribute-name="CustomizationManager"
+ proxy-type="attribute">portal:service=CustomizationManager</depends>
+ <depends
+ optional-attribute-name="Container"
+ proxy-type="attribute">portal:container=PortalObject</depends>
+ </mbean>
+ <mbean
+ code="org.jboss.portal.core.model.portal.PortalObjectCommandFactory"
name="portal:commandFactory=Dashboard"
xmbean-dd=""
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
<xmbean/>
+ <depends
+ optional-attribute-name="Mapper"
+ proxy-type="attribute">portal:service=PortalObjectPathMapper,type=Dashboard</depends>
</mbean>
+
<mbean
code="org.jboss.portal.core.controller.command.mapper.CommandFactoryDelegate"
name="portal:commandFactory=Delegate,path=dashboard"
@@ -809,14 +839,18 @@
</mbean>
<mbean
code="org.jboss.portal.core.model.portal.PortalObjectURLFactory"
- name="portal:urlFactory=PortalObject"
+ name="portal:urlFactory=PortalObject,type=Default"
xmbean-dd=""
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
<xmbean/>
+ <attribute name="Namespace"><![CDATA[]]></attribute>
<attribute name="Path">/portal</attribute>
<depends
optional-attribute-name="Factory"
proxy-type="attribute">portal:urlFactory=Delegating</depends>
+ <depends
+ optional-attribute-name="Mapper"
+ proxy-type="attribute">portal:service=PortalObjectPathMapper,type=Default</depends>
</mbean>
<mbean
code="org.jboss.portal.core.controller.command.mapper.SimpleURLFactory"
@@ -831,16 +865,19 @@
proxy-type="attribute">portal:urlFactory=Delegating</depends>
</mbean>
<mbean
- code="org.jboss.portal.core.controller.command.mapper.SimpleURLFactory"
- name="portal:urlFactory=Dashboard"
+ code="org.jboss.portal.core.model.portal.PortalObjectURLFactory"
+ name="portal:urlFactory=PortalObject,type=Dashboard"
xmbean-dd=""
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
<xmbean/>
+ <attribute name="Namespace">dashboard</attribute>
<attribute name="Path">/dashboard</attribute>
- <attribute name="ClassNames">org.jboss.portal.core.model.portal.command.view.ViewDashboardCommand</attribute>
<depends
optional-attribute-name="Factory"
proxy-type="attribute">portal:urlFactory=Delegating</depends>
+ <depends
+ optional-attribute-name="Mapper"
+ proxy-type="attribute">portal:service=PortalObjectPathMapper,type=Dashboard</depends>
</mbean>
<!-- The federating portlet invoker -->
Modified: trunk/core/src/resources/portal-core-sar/conf/data/default-object.xml
===================================================================
--- trunk/core/src/resources/portal-core-sar/conf/data/default-object.xml 2007-05-15 12:35:46 UTC (rev 7251)
+++ trunk/core/src/resources/portal-core-sar/conf/data/default-object.xml 2007-05-15 15:02:38 UTC (rev 7252)
@@ -28,6 +28,11 @@
<deployments>
<deployment>
+ <context>
+ <context-name/>
+ </context>
+ </deployment>
+ <deployment>
<parent-ref/>
<if-exists>keep</if-exists>
<portal>
@@ -112,7 +117,6 @@
</portal>
</deployment>
<deployment>
- <parent-ref/>
<if-exists>keep</if-exists>
<context>
<context-name>dashboard</context-name>
@@ -143,14 +147,6 @@
</property>
<!--
- | Set the dashboard property
- -->
- <property>
- <name>dashboard</name>
- <value>true</value>
- </property>
-
- <!--
| Set the dnd property
-->
<property>
Modified: trunk/core/src/resources/portal-core-sar/conf/hibernate/portal/domain.hbm.xml
===================================================================
--- trunk/core/src/resources/portal-core-sar/conf/hibernate/portal/domain.hbm.xml 2007-05-15 12:35:46 UTC (rev 7251)
+++ trunk/core/src/resources/portal-core-sar/conf/hibernate/portal/domain.hbm.xml 2007-05-15 15:02:38 UTC (rev 7252)
@@ -42,7 +42,7 @@
<property
name="path"
column="PATH"
- type="org.jboss.portal.jems.hibernate.MagicString"
+ type="org.jboss.portal.core.impl.model.portal.PortalObjectIdUserType"
not-null="false"
unique="false"/>
</natural-id>
Modified: trunk/core/src/resources/portal-core-sar/dtd/portal-object_2_6.dtd
===================================================================
--- trunk/core/src/resources/portal-core-sar/dtd/portal-object_2_6.dtd 2007-05-15 12:35:46 UTC (rev 7251)
+++ trunk/core/src/resources/portal-core-sar/dtd/portal-object_2_6.dtd 2007-05-15 15:02:38 UTC (rev 7252)
@@ -62,7 +62,7 @@
3/ security-constraint : defines security configuration of the portal object.
-->
-<!ELEMENT deployment (parent-ref,if-exists?,(context|portal|page|window))>
+<!ELEMENT deployment (parent-ref?,if-exists?,(context|portal|page|window))>
<!--
Contains a reference to the parent object. The naming convention for naming object
Modified: trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/AdminPropertyResolver.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/AdminPropertyResolver.java 2007-05-15 12:35:46 UTC (rev 7251)
+++ trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/AdminPropertyResolver.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -39,6 +39,7 @@
import org.jboss.portal.core.model.instance.Instance;
import org.jboss.portal.core.model.portal.PortalObject;
import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.portal.PortalObjectPath;
import org.jboss.portal.core.model.content.ContentType;
import org.jboss.portal.core.model.content.spi.portlet.ContentPortlet;
import org.jboss.portal.core.impl.model.content.ContentProviderRegistryService;
@@ -247,7 +248,7 @@
{
PortalObject object = (PortalObject)bean;
PortalObjectId id = object.getId();
- return id.toString(PortalObjectId.LEGACY_BASE64_FORMAT);
+ return id.toString(PortalObjectPath.LEGACY_BASE64_FORMAT);
}
});
registerDecorator(PortalObject.class, portalObjectDecorator);
Modified: trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectIdConverter.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectIdConverter.java 2007-05-15 12:35:46 UTC (rev 7251)
+++ trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectIdConverter.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -23,6 +23,7 @@
package org.jboss.portal.core.admin.ui;
import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.portal.PortalObjectPath;
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
@@ -37,11 +38,11 @@
{
public Object getAsObject(FacesContext facesContext, UIComponent uiComponent, String string) throws ConverterException
{
- return string == null ? null : PortalObjectId.parse(string, PortalObjectId.LEGACY_BASE64_FORMAT);
+ return string == null ? null : PortalObjectId.parse(string, PortalObjectPath.LEGACY_BASE64_FORMAT);
}
public String getAsString(FacesContext facesContext, UIComponent uiComponent, Object object) throws ConverterException
{
- return object == null ? null : ((PortalObjectId)object).toString(PortalObjectId.LEGACY_BASE64_FORMAT);
+ return object == null ? null : ((PortalObjectId)object).toString(PortalObjectPath.LEGACY_BASE64_FORMAT);
}
}
Modified: trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java 2007-05-15 12:35:46 UTC (rev 7251)
+++ trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -37,6 +37,7 @@
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.portal.PortalObjectPermission;
import org.jboss.portal.core.model.portal.Window;
+import org.jboss.portal.core.model.portal.PortalObjectPath;
import org.jboss.portal.faces.component.portlet.PortletActionEvent;
import org.jboss.portal.identity.RoleModule;
import org.jboss.portal.portlet.PortletInvoker;
@@ -360,7 +361,7 @@
String id = (String)pmap.get("id");
// Set the state from the id
- PortalObjectId poid = PortalObjectId.parse(id, PortalObjectId.LEGACY_BASE64_FORMAT);
+ PortalObjectId poid = PortalObjectId.parse(id, PortalObjectPath.LEGACY_BASE64_FORMAT);
PortalObject object = portalObjectContainer.getObject(poid);
// Update state if possible
@@ -415,7 +416,7 @@
public void selectRootObject(ActionEvent ae)
{
- PortalObject root = portalObjectContainer.getRootObject();
+ PortalObject root = portalObjectContainer.getContext();
selectObject(root);
}
@@ -437,7 +438,7 @@
// Destroy the object
if (id != null)
{
- PortalObjectId poid = PortalObjectId.parse(id, PortalObjectId.LEGACY_BASE64_FORMAT);
+ PortalObjectId poid = PortalObjectId.parse(id, PortalObjectPath.LEGACY_BASE64_FORMAT);
PortalObject object = portalObjectContainer.getObject(poid);
selectObject(object.getParent());
@@ -468,7 +469,7 @@
//
if (selectedId == null)
{
- selectedId = new PortalObjectId();
+ selectedId = new PortalObjectId("", PortalObjectPath.ROOT_PATH);
}
//
@@ -553,7 +554,7 @@
public void pageCreated(Page page)
{
Set constraints = Collections.singleton(new RoleSecurityBinding(PortalObjectPermission.VIEW_RECURSIVE_ACTION, SecurityConstants.UNCHECKED_ROLE_NAME));
- getDomainConfigurator().setSecurityBindings(page.getId().toString(PortalObjectId.CANONICAL_FORMAT), constraints);
+ getDomainConfigurator().setSecurityBindings(page.getId().toString(PortalObjectPath.CANONICAL_FORMAT), constraints);
}
public class PortalObjectAuthorizationBean extends AuthorizationBean
@@ -569,7 +570,7 @@
PortalObject po = getSelectedObject();
if (po != null)
{
- return po.getId().toString(PortalObjectId.CANONICAL_FORMAT);
+ return po.getId().toString(PortalObjectPath.CANONICAL_FORMAT);
}
else
{
Modified: trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PortalAction.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PortalAction.java 2007-05-15 12:35:46 UTC (rev 7251)
+++ trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PortalAction.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -29,7 +29,7 @@
import org.jboss.portal.core.model.portal.Portal;
import org.jboss.portal.core.model.portal.PortalObject;
import org.jboss.portal.core.model.portal.PortalObjectPermission;
-import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.portal.PortalObjectPath;
import org.jboss.portal.core.admin.ui.PortalObjectManagerBean;
import org.jboss.portal.security.RoleSecurityBinding;
import org.jboss.portal.security.SecurityConstants;
@@ -146,7 +146,7 @@
actions.add(PortalObjectPermission.PERSONALIZE_RECURSIVE_ACTION);
RoleSecurityBinding binding = new RoleSecurityBinding(actions, SecurityConstants.UNCHECKED_ROLE_NAME);
Set constraints = Collections.singleton(binding);
- configurator.setSecurityBindings(portal.getId().toString(PortalObjectId.CANONICAL_FORMAT), constraints);
+ configurator.setSecurityBindings(portal.getId().toString(PortalObjectPath.CANONICAL_FORMAT), constraints);
// We need to add initial layout sets to avoid problems...
portal.setDeclaredProperty(ThemeConstants.PORTAL_PROP_LAYOUT, "generic");
@@ -166,7 +166,7 @@
// Create the default page
Page page = portal.createPage("default");
constraints = Collections.singleton(new RoleSecurityBinding(PortalObjectPermission.VIEW_RECURSIVE_ACTION, SecurityConstants.UNCHECKED_ROLE_NAME));
- configurator.setSecurityBindings(page.getId().toString(PortalObjectId.CANONICAL_FORMAT), constraints);
+ configurator.setSecurityBindings(page.getId().toString(PortalObjectPath.CANONICAL_FORMAT), constraints);
portal.setDeclaredProperty(PortalObject.PORTAL_PROP_DEFAULT_OBJECT_NAME, page.getName());
Modified: trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/RenameAction.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/RenameAction.java 2007-05-15 12:35:46 UTC (rev 7251)
+++ trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/RenameAction.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -32,6 +32,7 @@
import org.jboss.portal.core.model.portal.NoSuchPortalObjectException;
import org.jboss.portal.core.model.portal.PortalObject;
import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.portal.PortalObjectPath;
import org.jboss.portal.security.spi.provider.DomainConfigurator;
/**
@@ -89,8 +90,8 @@
PortalObject newObject = portalObject.copy(parent, newName, true);
// Copy security settings
- Set set = domainConfigurator.getSecurityBindings(portalObject.getId().toString(PortalObjectId.CANONICAL_FORMAT));
- domainConfigurator.setSecurityBindings(newObject.getId().toString(PortalObjectId.CANONICAL_FORMAT), set);
+ Set set = domainConfigurator.getSecurityBindings(portalObject.getId().toString(PortalObjectPath.CANONICAL_FORMAT));
+ domainConfigurator.setSecurityBindings(newObject.getId().toString(PortalObjectPath.CANONICAL_FORMAT), set);
String defaultObject = (String)parent.getDeclaredProperties().get(PortalObject.PORTAL_PROP_DEFAULT_OBJECT_NAME);
if (portalObject.getName().equals(defaultObject))
Modified: trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/dashboard/DashboardBean.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/dashboard/DashboardBean.java 2007-05-15 12:35:46 UTC (rev 7251)
+++ trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/dashboard/DashboardBean.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -28,6 +28,7 @@
import org.jboss.portal.core.model.portal.Page;
import org.jboss.portal.core.model.portal.PortalObject;
import org.jboss.portal.core.model.portal.NoSuchPortalObjectException;
+import org.jboss.portal.core.model.portal.PortalObjectPath;
import org.jboss.portal.core.model.instance.InstanceContainer;
import org.jboss.portal.core.admin.ui.common.PageManagerBean;
import org.jboss.portal.core.admin.ui.portlet.PortletDefinitionInvoker;
@@ -49,7 +50,7 @@
{
/** . */
- private static final PortalObjectId dashboardId = PortalObjectId.parse("/dashboard", PortalObjectId.CANONICAL_FORMAT);
+ private static final PortalObjectId dashboardId = PortalObjectId.parse("dashboard:/", PortalObjectPath.CANONICAL_FORMAT);
// Wired services
Modified: trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/wizard/NewWindowWizard.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/wizard/NewWindowWizard.java 2007-05-15 12:35:46 UTC (rev 7251)
+++ trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/wizard/NewWindowWizard.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -39,6 +39,7 @@
import org.jboss.portal.core.model.portal.PortalObjectContainer;
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.portal.Window;
+import org.jboss.portal.core.model.portal.PortalObjectPath;
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.PortletContext;
import org.jboss.portal.portlet.PortletInvoker;
@@ -138,7 +139,7 @@
FacesContext ctx = FacesContext.getCurrentInstance();
String id = (String)ctx.getExternalContext().getRequestParameterMap().get("id");
Page page = (Page)getObjectFromId(id);
- selectedParentPageId = page.getParent().getId().toString(PortalObjectId.LEGACY_BASE64_FORMAT);
+ selectedParentPageId = page.getParent().getId().toString(PortalObjectPath.LEGACY_BASE64_FORMAT);
currentStep = 2;
return (String)steps.get(currentStep);
}
@@ -189,7 +190,7 @@
public PortalObject getObjectFromId(String id)
{
- PortalObjectId objectId = PortalObjectId.parse(id, PortalObjectId.LEGACY_BASE64_FORMAT);
+ PortalObjectId objectId = PortalObjectId.parse(id, PortalObjectPath.LEGACY_BASE64_FORMAT);
return getObjectFromId(objectId);
}
@@ -200,7 +201,7 @@
public List getPortals()
{
- PortalObject root = portalObjectContainer.getRootObject();
+ PortalObject root = portalObjectContainer.getContext();
return new ArrayList(root.getChildren(PortalObject.PORTAL_MASK));
}
Modified: trunk/core-cms/src/main/org/jboss/portal/core/cms/CMSObjectCommandFactoryService.java
===================================================================
--- trunk/core-cms/src/main/org/jboss/portal/core/cms/CMSObjectCommandFactoryService.java 2007-05-15 12:35:46 UTC (rev 7251)
+++ trunk/core-cms/src/main/org/jboss/portal/core/cms/CMSObjectCommandFactoryService.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -26,6 +26,7 @@
import org.jboss.portal.core.controller.ControllerCommand;
import org.jboss.portal.core.controller.ControllerContext;
import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.portal.PortalObjectPath;
import org.jboss.portal.core.model.portal.command.action.InvokePortletWindowRenderCommand;
import org.jboss.portal.core.cms.command.StreamContentCommand;
import org.jboss.portal.core.cms.ui.CMSPortlet;
@@ -98,7 +99,7 @@
protected void startService() throws Exception
{
- targetWindowId = PortalObjectId.parse(targetWindowRef, PortalObjectId.LEGACY_FORMAT);
+ targetWindowId = PortalObjectId.parse(targetWindowRef, PortalObjectPath.LEGACY_FORMAT);
//
super.startService();
Modified: trunk/jems/src/main/org/jboss/portal/jems/hibernate/StringWrapperUserType.java
===================================================================
--- trunk/jems/src/main/org/jboss/portal/jems/hibernate/StringWrapperUserType.java 2007-05-15 12:35:46 UTC (rev 7251)
+++ trunk/jems/src/main/org/jboss/portal/jems/hibernate/StringWrapperUserType.java 2007-05-15 15:02:38 UTC (rev 7252)
@@ -40,6 +40,16 @@
private static final int[] SQL_TYPES = {Types.VARCHAR};
+ public Object fromNull()
+ {
+ return null;
+ }
+
+ public String toNull()
+ {
+ return null;
+ }
+
public abstract Object fromString(String name);
public abstract String toString(Object value);
@@ -72,24 +82,31 @@
public Object nullSafeGet(ResultSet resultSet, String[] names, Object owner) throws HibernateException, SQLException
{
- String value = resultSet.getString(names[0]);
+ String string = resultSet.getString(names[0]);
+
+ //
if (resultSet.wasNull())
{
- return null;
+ return fromNull();
}
- return fromString(value);
+ else
+ {
+ return fromString(string);
+ }
}
public void nullSafeSet(PreparedStatement statement, Object value, int index) throws HibernateException, SQLException
{
- if (value == null)
+ String string = value == null ? toNull(): toString(value);
+
+ //
+ if (string == null)
{
statement.setNull(index, Types.VARCHAR);
}
else
{
- String name = toString(value);
- statement.setString(index, name);
+ statement.setString(index, string);
}
}
18 years, 11 months
JBoss Portal SVN: r7251 - trunk/core-samples/src/resources/portal-samples-war/WEB-INF/jsp/event.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2007-05-15 08:35:46 -0400 (Tue, 15 May 2007)
New Revision: 7251
Modified:
trunk/core-samples/src/resources/portal-samples-war/WEB-INF/jsp/event/view.jsp
Log:
Make it fit the window width on small resolutions
Modified: trunk/core-samples/src/resources/portal-samples-war/WEB-INF/jsp/event/view.jsp
===================================================================
--- trunk/core-samples/src/resources/portal-samples-war/WEB-INF/jsp/event/view.jsp 2007-05-15 12:23:32 UTC (rev 7250)
+++ trunk/core-samples/src/resources/portal-samples-war/WEB-INF/jsp/event/view.jsp 2007-05-15 12:35:46 UTC (rev 7251)
@@ -22,20 +22,8 @@
~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~--%>
-<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>
-<%@ page isELIgnored="false" %>
-
-<portlet:defineObjects/>
-
-<table border="0" cellspacing="2" cellpadding="2">
- <tr>
- <td class="portlet-section-alternate">
- <font class="portlet-font">This is simple showcase of Portal Node Event Listener. For this portal page it ensures
- that in every column, only one portlet window is in <b>NORMAL</b> state. Try to change window state of other
- portlets and see what happens. To learn more read <b>InterPortlet Communication (IPC)</b> chapter in
- <b>JBoss Portal Reference Guide</b>, or check source code of
- <i><b>org.jboss.portal.core.portlet.test.event.WindowConstraintEventListener</b></i> class .
- </font>
- </td>
- </tr>
-</table>
+<font class="portlet-font">This is a simple showcase of Portal Node Event Listener. For this portal page it ensures
+that in every column, only one portlet window is in <b>NORMAL</b> state. Try to change the window state of other
+portlets and see what happens. To learn more, read <b>InterPortlet Communication (IPC)</b> chapter in
+<b>JBoss Portal Reference Guide.</b>
+</font>
18 years, 11 months
JBoss Portal SVN: r7250 - trunk/core-samples/src/resources/portal-samples-war/WEB-INF/jsp/news.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2007-05-15 08:23:32 -0400 (Tue, 15 May 2007)
New Revision: 7250
Modified:
trunk/core-samples/src/resources/portal-samples-war/WEB-INF/jsp/news/edit.jsp
Log:
Minor
Modified: trunk/core-samples/src/resources/portal-samples-war/WEB-INF/jsp/news/edit.jsp
===================================================================
--- trunk/core-samples/src/resources/portal-samples-war/WEB-INF/jsp/news/edit.jsp 2007-05-14 13:56:59 UTC (rev 7249)
+++ trunk/core-samples/src/resources/portal-samples-war/WEB-INF/jsp/news/edit.jsp 2007-05-15 12:23:32 UTC (rev 7250)
@@ -29,12 +29,9 @@
<div align="center">
<br/>
<font class="portlet-font">Change News Feed URL:</font>
-
<form method="post" action="
<portlet:actionURL></portlet:actionURL>">
- <font class="portlet-font">URL:</font><br/>
- <input class="portlet-form-input-field" type="text" value="" size="12" name="newurl">
- <br/>
- <input class="portlet-form-input-field" type="submit" name="submit" value="submit">
+ <input class="portlet-form-input-field" type="text" value="<%= renderRequest.getPreferences().getValue("RssXml", "") %>" size="25" name="newurl">
+ <input class="portlet-form-button" type="submit" name="submit" value="submit">
</form>
</div>
\ No newline at end of file
18 years, 11 months
JBoss Portal SVN: r7249 - in trunk/core-cms/src: main/org/jboss/portal/core/cms and 1 other directory.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2007-05-14 09:56:59 -0400 (Mon, 14 May 2007)
New Revision: 7249
Modified:
trunk/core-cms/src/bin/portal-cms-sar/portal/cms/conf/default-content/default/project.html
trunk/core-cms/src/main/org/jboss/portal/core/cms/CMSObjectCommandFactoryService.java
Log:
Fix JBPORTAL-1398: CMS content redirecting to index page after failure in streaming content
Modified: trunk/core-cms/src/bin/portal-cms-sar/portal/cms/conf/default-content/default/project.html
===================================================================
--- trunk/core-cms/src/bin/portal-cms-sar/portal/cms/conf/default-content/default/project.html 2007-05-12 22:10:34 UTC (rev 7248)
+++ trunk/core-cms/src/bin/portal-cms-sar/portal/cms/conf/default-content/default/project.html 2007-05-14 13:56:59 UTC (rev 7249)
@@ -1,9 +1,8 @@
<table width="100%" border="0" cellpadding="2">
<tr>
- <td valign="top" align="left" class="portlet-section-body"><font class="portlet-font">JBoss Inc. delivers the
+ <td valign="top" align="left" class="portlet-section-body" colspan="2"><font class="portlet-font">JBoss Inc. delivers the
Professional Support, Consulting, and Training that you need whether you are testing a proof of concept,
deploying a mission-critical application, or rolling out JEMS across your enterprise. </font></td>
- <td valign="top" align="right"><img src="default/images/jboss_logo.gif"></td>
</tr>
<tr>
<td colspan="2">
Modified: trunk/core-cms/src/main/org/jboss/portal/core/cms/CMSObjectCommandFactoryService.java
===================================================================
--- trunk/core-cms/src/main/org/jboss/portal/core/cms/CMSObjectCommandFactoryService.java 2007-05-12 22:10:34 UTC (rev 7248)
+++ trunk/core-cms/src/main/org/jboss/portal/core/cms/CMSObjectCommandFactoryService.java 2007-05-14 13:56:59 UTC (rev 7249)
@@ -134,7 +134,7 @@
File file = getFile(requestPath, requestLocale);
// Redirect to default content if nothing found (and WTF the content is prefixed by /default ???)
- if (file == null && "/default/index.html".equals(path) == false)
+ if (file == null && "/default/index.html".equals(path) == false && !isStreamable(path))
{
path = "/default/index.html";
file = getFile(path, requestLocale);
@@ -144,17 +144,10 @@
if (file != null)
{
Content content = file.getContent();
-
if (content != null)
{
- boolean isStreamable = false;
- if (!"text/html".equalsIgnoreCase(content.getMimeType()) && !"text/plain".equalsIgnoreCase(content.getMimeType()))
+ if (isStreamable(content.getMimeType()))
{
- isStreamable = true;
- }
-
- if (isStreamable)
- {
return new StreamContentCommand(requestPath);
}
else
@@ -185,4 +178,9 @@
return null; // TODO: 404?
}
+
+ private boolean isStreamable(String mimeType)
+ {
+ return (!"text/html".equalsIgnoreCase(mimeType) && !"text/plain".equalsIgnoreCase(mimeType));
+ }
}
18 years, 11 months