Author: julien(a)jboss.com
Date: 2007-01-10 08:42:44 -0500 (Wed, 10 Jan 2007)
New Revision: 5975
Modified:
trunk/core/src/main/org/jboss/portal/core/cms/CMSObjectCommandFactory.java
trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicController.java
trunk/core/src/main/org/jboss/portal/core/controller/command/mapper/AbstractCommandFactory.java
trunk/core/src/main/org/jboss/portal/core/controller/command/mapper/CommandFactory.java
trunk/core/src/main/org/jboss/portal/core/controller/command/mapper/CommandFactoryDelegate.java
trunk/core/src/main/org/jboss/portal/core/controller/command/mapper/DelegatingCommandFactoryService.java
trunk/core/src/main/org/jboss/portal/core/controller/command/mapper/SimpleCommandFactory.java
trunk/core/src/main/org/jboss/portal/core/model/instance/InstanceCommandFactory.java
trunk/core/src/main/org/jboss/portal/core/model/portal/DashboardCommandFactory.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/server/src/main/org/jboss/portal/server/ServerInvocationContext.java
trunk/server/src/main/org/jboss/portal/server/impl/ServerInvocationContextImpl.java
trunk/server/src/main/org/jboss/portal/server/servlet/PortalServlet.java
Log:
applied the portal host idea from JBPORTAL-1004
Modified: trunk/core/src/main/org/jboss/portal/core/cms/CMSObjectCommandFactory.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/cms/CMSObjectCommandFactory.java 2007-01-10
04:44:22 UTC (rev 5974)
+++ trunk/core/src/main/org/jboss/portal/core/cms/CMSObjectCommandFactory.java 2007-01-10
13:42:44 UTC (rev 5975)
@@ -92,7 +92,7 @@
targetWindowId = null;
}
- public ControllerCommand doMapping(ServerInvocation invocation, String
portalContextPath, String portalRequestPath)
+ public ControllerCommand doMapping(ServerInvocation invocation, String host, String
contextPath, String requestPath)
{
try
{
@@ -110,11 +110,11 @@
getCMD =
CMSService.getCommandFactory().createFileGetCommand(portalRequestPath, new
Locale(CMSService.getDefaultLocale()));
}
*/
- Command getCMD =
CMSService.getCommandFactory().createFileGetCommand(portalRequestPath,
invocation.getRequest().getLocale());
+ Command getCMD =
CMSService.getCommandFactory().createFileGetCommand(requestPath,
invocation.getRequest().getLocale());
File file = (File)CMSService.execute(getCMD);
if (file == null)
{
- getCMD =
CMSService.getCommandFactory().createFileGetCommand(portalRequestPath, new
Locale(CMSService.getDefaultLocale()));
+ getCMD = CMSService.getCommandFactory().createFileGetCommand(requestPath, new
Locale(CMSService.getDefaultLocale()));
file = (File)CMSService.execute(getCMD);
}
@@ -132,13 +132,13 @@
if (isStreamable)
{
- return new StreamContentCommand(portalRequestPath);
+ return new StreamContentCommand(requestPath);
}
else
{
//Set the content as a render parameter
ParametersStateString parameters = new ParametersStateString();
- parameters.setValue("path", portalRequestPath);
+ parameters.setValue("path", requestPath);
// Perform a render URL on the target window
return new InvokePortletWindowRenderCommand(targetWindowId, Mode.VIEW,
null, parameters);
@@ -151,7 +151,7 @@
if(e.toString().indexOf("Access to this resource is denied")!=-1)
{
ParametersStateString parameters = new ParametersStateString();
- parameters.setValue("path", portalRequestPath);
+ parameters.setValue("path", requestPath);
return new InvokePortletWindowRenderCommand(targetWindowId, Mode.VIEW,
null, parameters);
}
else
Modified:
trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicController.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicController.java 2007-01-10
04:44:22 UTC (rev 5974)
+++
trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicController.java 2007-01-10
13:42:44 UTC (rev 5975)
@@ -66,7 +66,7 @@
ControllerContext ctx = new ControllerContext(invocation, this);
// Invoke the chain that creates the initial command
- ControllerCommand cmd = commandFactory.doMapping(invocation,
invocation.getServerContext().getPortalContextPath(),
invocation.getServerContext().getPortalRequestPath());
+ ControllerCommand cmd = commandFactory.doMapping(invocation,
invocation.getServerContext().getPortalHost(),
invocation.getServerContext().getPortalContextPath(),
invocation.getServerContext().getPortalRequestPath());
//
if (cmd == null)
Modified:
trunk/core/src/main/org/jboss/portal/core/controller/command/mapper/AbstractCommandFactory.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/controller/command/mapper/AbstractCommandFactory.java 2007-01-10
04:44:22 UTC (rev 5974)
+++
trunk/core/src/main/org/jboss/portal/core/controller/command/mapper/AbstractCommandFactory.java 2007-01-10
13:42:44 UTC (rev 5975)
@@ -35,6 +35,6 @@
public abstract ControllerCommand doMapping(
ServerInvocation invocation,
- String portalContextPath,
- String portalRequestPath);
+ String host, String contextPath,
+ String requestPath);
}
Modified:
trunk/core/src/main/org/jboss/portal/core/controller/command/mapper/CommandFactory.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/controller/command/mapper/CommandFactory.java 2007-01-10
04:44:22 UTC (rev 5974)
+++
trunk/core/src/main/org/jboss/portal/core/controller/command/mapper/CommandFactory.java 2007-01-10
13:42:44 UTC (rev 5975)
@@ -37,13 +37,15 @@
/**
* Create a command.
*
- * @param invocation the invocation
- * @param portalContextPath
- * @param portalRequestPath
+ * @param invocation the invocation
+ * @param host the host
+ * @param contextPath the context path
+ * @param requestPath the request path
* @return the command or null if no command is recognized
*/
ControllerCommand doMapping(
ServerInvocation invocation,
- String portalContextPath,
- String portalRequestPath);
+ String host,
+ String contextPath,
+ String requestPath);
}
Modified:
trunk/core/src/main/org/jboss/portal/core/controller/command/mapper/CommandFactoryDelegate.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/controller/command/mapper/CommandFactoryDelegate.java 2007-01-10
04:44:22 UTC (rev 5974)
+++
trunk/core/src/main/org/jboss/portal/core/controller/command/mapper/CommandFactoryDelegate.java 2007-01-10
13:42:44 UTC (rev 5975)
@@ -81,8 +81,8 @@
delegatingFactory.unregister(path);
}
- public ControllerCommand doMapping(ServerInvocation invocation, String
portalContextPath, String portalRequestPath)
+ public ControllerCommand doMapping(ServerInvocation invocation, String host, String
contextPath, String requestPath)
{
- return delegateFactory.doMapping(invocation, portalContextPath,
portalRequestPath);
+ return delegateFactory.doMapping(invocation, host, contextPath, requestPath);
}
}
Modified:
trunk/core/src/main/org/jboss/portal/core/controller/command/mapper/DelegatingCommandFactoryService.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/controller/command/mapper/DelegatingCommandFactoryService.java 2007-01-10
04:44:22 UTC (rev 5974)
+++
trunk/core/src/main/org/jboss/portal/core/controller/command/mapper/DelegatingCommandFactoryService.java 2007-01-10
13:42:44 UTC (rev 5975)
@@ -122,29 +122,29 @@
}
}
- public ControllerCommand doMapping(ServerInvocation invocation, String
portalContextPath, String portalRequestPath)
+ public ControllerCommand doMapping(ServerInvocation invocation, String host, String
contextPath, String requestPath)
{
//
- if (portalRequestPath.length() == 0)
+ if (requestPath.length() == 0)
{
return null;
}
//
- PathMappingResult result = parser.map(mapping, portalRequestPath);
+ PathMappingResult result = parser.map(mapping, requestPath);
Object target = result.getTarget();
ControllerCommand cmd = null;
if (target instanceof CommandFactory)
{
CommandFactory delegate = (CommandFactory)target;
String remainingPath = result.getRemainingPath();
- cmd = delegate.doMapping(invocation, portalContextPath +
result.getMatchedPath(), remainingPath);
+ cmd = delegate.doMapping(invocation, host, contextPath +
result.getMatchedPath(), remainingPath);
}
//
if (cmd == null && nextFactory != null)
{
- cmd = nextFactory.doMapping(invocation, portalContextPath, portalRequestPath);
+ cmd = nextFactory.doMapping(invocation, host, contextPath, requestPath);
}
return cmd;
Modified:
trunk/core/src/main/org/jboss/portal/core/controller/command/mapper/SimpleCommandFactory.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/controller/command/mapper/SimpleCommandFactory.java 2007-01-10
04:44:22 UTC (rev 5974)
+++
trunk/core/src/main/org/jboss/portal/core/controller/command/mapper/SimpleCommandFactory.java 2007-01-10
13:42:44 UTC (rev 5975)
@@ -66,7 +66,7 @@
commandClass = null;
}
- public ControllerCommand doMapping(ServerInvocation invocation, String
portalContextPath, String portalRequestPath)
+ public ControllerCommand doMapping(ServerInvocation invocation, String host, String
contextPath, String requestPath)
{
try
{
Modified:
trunk/core/src/main/org/jboss/portal/core/model/instance/InstanceCommandFactory.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/instance/InstanceCommandFactory.java 2007-01-10
04:44:22 UTC (rev 5974)
+++
trunk/core/src/main/org/jboss/portal/core/model/instance/InstanceCommandFactory.java 2007-01-10
13:42:44 UTC (rev 5975)
@@ -49,7 +49,7 @@
this.instanceId = instanceId;
}
- public ControllerCommand doMapping(ServerInvocation invocation, String
portalContextPath, String portalRequestPath)
+ public ControllerCommand doMapping(ServerInvocation invocation, String host, String
contextPath, String requestPath)
{
PortletRequestDecoder decoder = new PortletRequestDecoder();
decoder.decode(invocation.getServerContext().getQueryParameterMap(),
invocation.getServerContext().getBodyParameterMap());
Modified:
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-01-10
04:44:22 UTC (rev 5974)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/DashboardCommandFactory.java 2007-01-10
13:42:44 UTC (rev 5975)
@@ -33,7 +33,7 @@
*/
public class DashboardCommandFactory extends AbstractCommandFactory
{
- public ControllerCommand doMapping(ServerInvocation invocation, String
portalContextPath, String portalRequestPath)
+ public ControllerCommand doMapping(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-01-10
04:44:22 UTC (rev 5974)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/DefaultPortalCommandFactory.java 2007-01-10
13:42:44 UTC (rev 5975)
@@ -63,9 +63,9 @@
this.nextFactory = nextFactory;
}
- public ControllerCommand doMapping(ServerInvocation invocation, String
portalContextPath, String portalRequestPath)
+ public ControllerCommand doMapping(ServerInvocation invocation, String host, String
contextPath, String requestPath)
{
- ControllerCommand cmd = nextFactory.doMapping(invocation, portalContextPath,
portalRequestPath);
+ ControllerCommand cmd = nextFactory.doMapping(invocation, host, contextPath,
requestPath);
if (cmd == null)
{
Portal portal = (Portal)container.getObject(defaultPortalPath);
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-01-10
04:44:22 UTC (rev 5974)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectCommandFactory.java 2007-01-10
13:42:44 UTC (rev 5975)
@@ -38,8 +38,6 @@
import org.jboss.portal.server.servlet.PathParser;
import org.jboss.portal.theme.navigation.WindowNavigationalState;
-import java.util.Map;
-
/**
* This command mapper is used to map portal objects living in a container to
<code>org.jboss.portal.core.command.RenderPageCommand</code>
*
@@ -86,22 +84,22 @@
this.container = container;
}
- public ControllerCommand doMapping(ServerInvocation invocation, String
portalContextPath, String portalRequestPath)
+ public ControllerCommand doMapping(ServerInvocation invocation, String host, String
contextPath, String requestPath)
{
- if (portalRequestPath == null)
+ if (requestPath == null)
{
return null;
}
//
Object target;
- if (portalRequestPath.length() == 0)
+ if (requestPath.length() == 0)
{
target = container.getRootObject();
}
else
{
- PathMappingResult result = pathParser.map(mapping, portalRequestPath);
+ PathMappingResult result = pathParser.map(mapping, requestPath);
target = result.getTarget();
}
Modified: trunk/server/src/main/org/jboss/portal/server/ServerInvocationContext.java
===================================================================
--- trunk/server/src/main/org/jboss/portal/server/ServerInvocationContext.java 2007-01-10
04:44:22 UTC (rev 5974)
+++ trunk/server/src/main/org/jboss/portal/server/ServerInvocationContext.java 2007-01-10
13:42:44 UTC (rev 5975)
@@ -97,6 +97,13 @@
String getPortalContextPath();
/**
+ * Return the portal host value for this request.
+ *
+ * @return the portal host
+ */
+ String getPortalHost();
+
+ /**
* @param url
* @param context
* @param format
Modified:
trunk/server/src/main/org/jboss/portal/server/impl/ServerInvocationContextImpl.java
===================================================================
---
trunk/server/src/main/org/jboss/portal/server/impl/ServerInvocationContextImpl.java 2007-01-10
04:44:22 UTC (rev 5974)
+++
trunk/server/src/main/org/jboss/portal/server/impl/ServerInvocationContextImpl.java 2007-01-10
13:42:44 UTC (rev 5975)
@@ -60,6 +60,9 @@
/** The portal request path. */
private String portalRequestPath;
+ /** The portal host. */
+ private String portalHost;
+
/** . */
private String mediaType;
@@ -84,6 +87,7 @@
public ServerInvocationContextImpl(
HttpServletRequest req,
HttpServletResponse resp,
+ String portalHost,
String portalRequestPath,
String portalContextPath,
Map queryParameterMap,
@@ -105,6 +109,7 @@
this.resp = resp;
this.portalRequestPath = portalRequestPath;
this.portalContextPath = portalContextPath;
+ this.portalHost = portalHost;
this.queryParameterMap = new InternalParameterMap(queryParameterMap);
this.bodyParameterMap = bodyParameterMap != null ? new
InternalParameterMap(bodyParameterMap) : null;
this.urlContext = urlContext;
@@ -178,6 +183,11 @@
return portalContextPath;
}
+ public String getPortalHost()
+ {
+ return portalHost;
+ }
+
public String renderURL(ServerURL url, URLContext context, URLFormat format)
{
int index = context.getMask() << 2 | format.getMask();
Modified: trunk/server/src/main/org/jboss/portal/server/servlet/PortalServlet.java
===================================================================
--- trunk/server/src/main/org/jboss/portal/server/servlet/PortalServlet.java 2007-01-10
04:44:22 UTC (rev 5974)
+++ trunk/server/src/main/org/jboss/portal/server/servlet/PortalServlet.java 2007-01-10
13:42:44 UTC (rev 5975)
@@ -29,7 +29,6 @@
import org.jboss.portal.common.invocation.InvocationException;
import org.jboss.portal.common.util.Exceptions;
import org.jboss.portal.common.util.URLTools;
-import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.server.PortalConstants;
import org.jboss.portal.server.RequestController;
import org.jboss.portal.server.RequestControllerDispatcher;
@@ -251,6 +250,9 @@
}
}
+ // Determine the host for this request
+ String portalHost = req.getServerName();
+
// Determine the request path
String portalRequestPath = null;
String portalContextPath = null;
@@ -348,6 +350,7 @@
ServerInvocationContext invocationCtx = new ServerInvocationContextImpl(
req,
resp,
+ portalHost,
portalRequestPath,
portalContextPath,
queryParameterMap,