Author: julien(a)jboss.com
Date: 2006-11-28 09:10:12 -0500 (Tue, 28 Nov 2006)
New Revision: 5735
Modified:
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxInterceptor.java
trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicController.java
trunk/core/src/main/org/jboss/portal/core/controller/command/info/CommandInfo.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPageCommand.java
Log:
- fixed redirect on https when a portlet declares transport garantees that mandates it
Modified: trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxInterceptor.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxInterceptor.java 2006-11-28
11:54:55 UTC (rev 5734)
+++
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxInterceptor.java 2006-11-28
14:10:12 UTC (rev 5735)
@@ -48,34 +48,29 @@
if (response instanceof PageRendition && cmd instanceof RenderPageCommand)
{
RenderPageCommand rpc = (RenderPageCommand)cmd;
- PageRendition rendition = (PageRendition)response;
- Map pageProps = rendition.getPageResult().getPageProperties();
-
- //
- pageProps.put(ThemeConstants.PORTAL_AJAX_JAVASCRIPT_BASE,
"/portal-ajax");
-
// If user is logged in and is on dashboard we enable ajax
- if
(cmd.getControllerContext().getServerInvocation().getServerContext().getClientRequest().getRemoteUser()
!= null)
+ if
(rpc.getControllerContext().getServerInvocation().getServerContext().getClientRequest().getRemoteUser()
!= null &&
+ rpc.isDashboard())
{
- if (rpc.isDashboard())
+ // Compute the url for the ajax servlet
+ HttpServletRequest req =
cmd.getControllerContext().getServerInvocation().getServerContext().getClientRequest();
+ StringBuffer url = new StringBuffer();
+ url.append(req.getScheme()).append("://");
+ url.append(req.getServerName());
+ if (("http".equals(req.getScheme()) && req.getServerPort()
!= 80) || ("https".equals(req.getScheme()) && req.getServerPort() !=
443))
{
- pageProps.put(ThemeConstants.PORTAL_AJAX_OBJECT_ENABLED,
"true");
+ url.append(':').append(req.getServerPort());
}
- }
+ url.append(req.getContextPath()).append("/ajax");
- // Compute the url for the ajax servlet
- HttpServletRequest req =
cmd.getControllerContext().getServerInvocation().getServerContext().getClientRequest();
- StringBuffer url = new StringBuffer();
- url.append(req.getScheme()).append("://");
- url.append(req.getServerName());
- if (("http".equals(req.getScheme()) && req.getServerPort() !=
80) || ("https".equals(req.getScheme()) && req.getServerPort() != 443))
- {
- url.append(':').append(req.getServerPort());
+ //
+ PageRendition rendition = (PageRendition)response;
+ Map pageProps = rendition.getPageResult().getPageProperties();
+ pageProps.put(ThemeConstants.PORTAL_AJAX_JAVASCRIPT_BASE,
"/portal-ajax");
+ pageProps.put(ThemeConstants.PORTAL_AJAX_OBJECT_ENABLED, "true");
+ pageProps.put(ThemeConstants.PORTAL_AJAX_REMOTE_URL, url.toString());
}
- url.append(req.getContextPath()).append("/ajax");
-
- pageProps.put(ThemeConstants.PORTAL_AJAX_REMOTE_URL, url.toString());
}
//
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 2006-11-28
11:54:55 UTC (rev 5734)
+++
trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicController.java 2006-11-28
14:10:12 UTC (rev 5735)
@@ -103,7 +103,7 @@
}
// Find out if we can execute in the same server invocation
- if (requiresRedirect(urlContext, cmd, invocation))
+ if (requiresRedirect(urlContext, forward))
{
String url = ctx.renderURL(forward.getCommand(), forward.getURLContext(),
null);
if (url == null)
@@ -172,24 +172,25 @@
return null;
}
- public boolean requiresRedirect(URLContext urlCtx, ControllerCommand cmd,
ServerInvocation invocation)
+ public boolean requiresRedirect(URLContext currentURLCtx, CommandForward forward)
{
- CommandInfo cmdInfo = cmd.getInfo();
+ CommandInfo cmdInfo = forward.getCommand().getInfo();
+ URLContext nextURLCtx = forward.getURLContext();
if (cmdInfo instanceof ActionCommandInfo &&
!((ActionCommandInfo)cmdInfo).isIdempotent())
{
return true;
}
else
{
- boolean currentAuthenticated =
invocation.getServerContext().getURLContext().isAuthenticated();
- if (urlCtx != null && currentAuthenticated != urlCtx.isAuthenticated())
+ boolean currentAuthenticated = currentURLCtx.isAuthenticated();
+ if (nextURLCtx != null && currentAuthenticated !=
nextURLCtx.isAuthenticated())
{
return true;
}
else
{
- boolean currentSecure =
invocation.getServerContext().getURLContext().getSecure();
- if (urlCtx != null && urlCtx.getSecure() && !currentSecure)
+ boolean currentSecure = currentURLCtx.getSecure();
+ if (nextURLCtx != null && nextURLCtx.getSecure() &&
!currentSecure)
{
return true;
}
Modified:
trunk/core/src/main/org/jboss/portal/core/controller/command/info/CommandInfo.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/controller/command/info/CommandInfo.java 2006-11-28
11:54:55 UTC (rev 5734)
+++
trunk/core/src/main/org/jboss/portal/core/controller/command/info/CommandInfo.java 2006-11-28
14:10:12 UTC (rev 5735)
@@ -55,7 +55,7 @@
return secured;
}
- /** @return the associated action of this command for security checks (is the user
allowed to call this action...) */
+ /** @return the associated action of this command for security checks (is the user
allowed to call this action...). */
public String getAction()
{
return action;
Modified:
trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPageCommand.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPageCommand.java 2006-11-28
11:54:55 UTC (rev 5734)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPageCommand.java 2006-11-28
14:10:12 UTC (rev 5735)
@@ -424,7 +424,6 @@
String contentChars = "";
String headerChars = null;
Map actionMap = new HashMap();
- Properties responseProps;
Map windowProps = window.getDeclaredProperties();
String navStateKey = window.getId() + "_window";
@@ -438,18 +437,10 @@
try
{
RenderPortletWindowCommand renderCmd = new
RenderPortletWindowCommand(windowRef);
-
- //
PortletResponse portletResponse = (PortletResponse)context.execute(renderCmd);
PortletInvocationResponse response = portletResponse.getResult();
//
- if (response instanceof InsufficientTransportGuaranteeResponse)
- {
- return response;
- }
-
- //
if (response instanceof FragmentResponse)
{
FragmentResponse fragment = (FragmentResponse)response;
@@ -459,8 +450,6 @@
windowTitle = window.getName();
}
headerChars = fragment.getHeader();
-// responseProps = fragment.getProperties();
- responseProps = new Properties(); // remove me
//
Instance instance = renderCmd.getInstance();
@@ -505,7 +494,15 @@
contentChars = fragment.getContent();
//
- return new WindowResult(windowTitle, contentChars, actionMap, windowProps,
responseProps, headerChars, windowNavState.getWindowState(), windowNavState.getMode());
+ return new WindowResult(
+ windowTitle,
+ contentChars,
+ actionMap,
+ windowProps,
+ new Properties(),
+ headerChars,
+ windowNavState.getWindowState(),
+ windowNavState.getMode());
}
else if (response instanceof ErrorResponse)
{
@@ -516,14 +513,13 @@
if (!HIDE.equals(property))
{
windowTitle = "An error occured while rendering window '" +
windowRef + "'";
- responseProps = new Properties();
contentChars = errorResult.getMessage();
Throwable t = errorResult.getThrowable();
if (t != null && SHOW.equals(property))
{
contentChars = Exceptions.toHTML(t, true);
}
- return new WindowResult(windowTitle, contentChars, actionMap, windowProps,
responseProps, headerChars, windowNavState.getWindowState(), windowNavState.getMode());
+ return new WindowResult(windowTitle, contentChars, actionMap, windowProps,
new Properties(), headerChars, windowNavState.getWindowState(),
windowNavState.getMode());
}
}
else if (response instanceof UnavailableResponse)
@@ -535,8 +531,7 @@
actionMap = new HashMap();
actionMap.put(WindowResult.MODES_KEY, Collections.EMPTY_LIST);
actionMap.put(WindowResult.WINDOWSTATES_KEY, Collections.EMPTY_LIST);
- responseProps = new Properties();
- return new WindowResult(windowTitle, contentChars, actionMap, windowProps,
responseProps, headerChars, windowNavState.getWindowState(), windowNavState.getMode());
+ return new WindowResult(windowTitle, contentChars, actionMap, windowProps,
new Properties(), headerChars, windowNavState.getWindowState(),
windowNavState.getMode());
}
}
else if (response instanceof InsufficientPrivilegesResponse)
@@ -546,7 +541,7 @@
}
else
{
- throw new NotYetImplemented("Unexpected result from a portlet invocation
" + response);
+ return portletResponse;
}
}
catch (ResourceAccessDeniedException e)
@@ -561,8 +556,7 @@
actionMap.put(WindowResult.WINDOWSTATES_KEY, Collections.EMPTY_LIST);
windowTitle = "Access denied";
contentChars = "Access denied";
- responseProps = new Properties();
- return new WindowResult(windowTitle, contentChars, actionMap, windowProps,
responseProps, headerChars, windowNavState.getWindowState(), windowNavState.getMode());
+ return new WindowResult(windowTitle, contentChars, actionMap, windowProps,
new Properties(), headerChars, windowNavState.getWindowState(),
windowNavState.getMode());
}
}
catch (ResourceNotFoundException e)
@@ -577,8 +571,7 @@
actionMap.put(WindowResult.WINDOWSTATES_KEY, Collections.EMPTY_LIST);
windowTitle = "Cannot render";
contentChars = "Object not found " + e.getRef();
- responseProps = new Properties();
- return new WindowResult(windowTitle, contentChars, actionMap, windowProps,
responseProps, headerChars, windowNavState.getWindowState(), windowNavState.getMode());
+ return new WindowResult(windowTitle, contentChars, actionMap, windowProps,
new Properties(), headerChars, windowNavState.getWindowState(),
windowNavState.getMode());
}
}
catch (ControllerException e)
@@ -593,12 +586,12 @@
if (SHOW.equals(property))
{
windowTitle = "An internal error occured while rendering window
'" + window + "'";
- responseProps = new Properties();
contentChars = Exceptions.toHTML(e, true);
- return new WindowResult(windowTitle, contentChars, actionMap, windowProps,
responseProps, headerChars, windowNavState.getWindowState(), windowNavState.getMode());
+ return new WindowResult(windowTitle, contentChars, actionMap, windowProps,
new Properties(), headerChars, windowNavState.getWindowState(),
windowNavState.getMode());
}
}
+ //
return null;
}