Author: chris.laprun(a)jboss.com
Date: 2010-10-22 06:27:10 -0400 (Fri, 22 Oct 2010)
New Revision: 4765
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java
Log:
- GTNPORTAL-1583: Added resourceId to error message.
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java 2010-10-22
09:18:26 UTC (rev 4764)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java 2010-10-22
10:27:10 UTC (rev 4765)
@@ -1,5 +1,9 @@
-/**
- * Copyright (C) 2009 eXo Platform SAS.
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2010, 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
@@ -59,7 +63,6 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.namespace.QName;
-
import java.io.IOException;
import java.io.OutputStream;
import java.io.Serializable;
@@ -98,16 +101,18 @@
setupPublicRenderParams(uiPortlet, request.getParameterMap());
// set the navigational state
- String navState
=prcontext.getRequestParameter(ExoPortletInvocationContext.NAVIGATIONAL_STATE_PARAM_NAME);
+ String navState =
prcontext.getRequestParameter(ExoPortletInvocationContext.NAVIGATIONAL_STATE_PARAM_NAME);
if (navState != null)
{
uiPortlet.setNavigationalState(ParametersStateString.create(navState));
}
-
+
//
ActionInvocation actionInvocation = uiPortlet.create(ActionInvocation.class,
prcontext);
if (actionInvocation == null)
+ {
return;
+ }
//
PortletInvocationResponse portletResponse = uiPortlet.invoke(actionInvocation);
@@ -138,7 +143,7 @@
uiPortlet.update((C)wsrp);
}
}
-
+
if (portletResponse instanceof UpdateNavigationalStateResponse)
{
handleUpdateNavigationalStateResponse((UpdateNavigationalStateResponse)portletResponse,
uiPortlet, prcontext);
@@ -158,17 +163,17 @@
else
{
throw new Exception("Unexpected response type [" + portletResponse
+ "]. Expected an UpdateNavigationResponse" +
- ", a HTTPRedirectionResponse or an ErrorResponse.");
+ ", a HTTPRedirectionResponse or an ErrorResponse.");
}
}
-
-
+
+
private void handleRedirectionResponse(HTTPRedirectionResponse redirectionResponse,
HttpServletResponse response) throws IOException
{
String redirectionURL = redirectionResponse.getLocation();
response.sendRedirect(redirectionURL);
}
-
+
private void handleUpdateNavigationalStateResponse(UpdateNavigationalStateResponse
navStateResponse, UIPortlet<S, C> uiPortlet, PortalRequestContext prcontext) throws
Exception
{
/*
@@ -258,12 +263,12 @@
}
}
-
+
private void handleErrorResponse(ErrorResponse response) throws Exception
{
- throw (Exception)response.getCause();
+ throw (Exception)response.getCause();
}
-
+
private void handleSecurityResponse(SecurityResponse response) throws Exception
{
if (response instanceof SecurityErrorResponse)
@@ -354,6 +359,8 @@
{
UIPortlet<S, C> uiPortlet = event.getSource();
log.trace("Serve Resource for portlet: " +
uiPortlet.getPortletContext());
+ String resourceId = null;
+
try
{
PortalRequestContext context =
(PortalRequestContext)event.getRequestContext();
@@ -365,10 +372,13 @@
{
uiPortlet.setNavigationalState(ParametersStateString.create(navState));
}
-
+
//
ResourceInvocation resourceInvocation =
uiPortlet.create(ResourceInvocation.class, context);
+ // set the resourceId to be used in case of a problem
+ resourceId = resourceInvocation.getResourceId();
+
//
PortletInvocationResponse portletResponse =
uiPortlet.invoke(resourceInvocation);
@@ -425,29 +435,29 @@
response.setContentType(contentType);
if (piResponse.getBytes() != null)
{
- OutputStream stream = response.getOutputStream();
- stream.write(piResponse.getBytes());
+ OutputStream stream = response.getOutputStream();
+ stream.write(piResponse.getBytes());
}
else
{
- if (piResponse.getChars() != null)
- {
- log.error("Received a content type of " + contentType + "
but it contains no bytes of data. Chars were unexpectantly returned instead : " +
piResponse.getChars());
- }
- else
- {
- log.error("Received a content type of " + contentType + "
but it contains no bytes of data.");
- }
+ if (piResponse.getChars() != null)
+ {
+ log.error("Received a content type of " + contentType +
" but it contains no bytes of data. Chars were unexpectantly returned instead :
" + piResponse.getChars());
+ }
+ else
+ {
+ log.error("Received a content type of " + contentType +
" but it contains no bytes of data.");
+ }
}
-
-
+
+
}
context.getResponse().flushBuffer();
}
catch (Exception e)
{
- log.error("Problem while serving resource for the portlet: " +
uiPortlet.getPortletContext().getId(), e);
+ log.error("Problem while serving resource " + (resourceId != null ?
resourceId : "") + " for the portlet: " +
uiPortlet.getPortletContext().getId(), e);
}
finally
{
@@ -526,7 +536,7 @@
* ProcessEventsActionListener once again
*/
public static <S, C extends Serializable, I> List<javax.portlet.Event>
processEvent(UIPortlet<S, C> uiPortlet,
- javax.portlet.Event event)
+
javax.portlet.Event event)
{
log.trace("Process Event: " + event.getName() + " for portlet:
" + uiPortlet.getState());
try
@@ -584,7 +594,7 @@
// update the portlet with the next mode to display
PortletMode mode = new PortletMode(getPortletModeOrDefault(navResponse));
setNextMode(uiPortlet, mode);
-
+
StateString navState = navResponse.getNavigationalState();
if (navState != null)
{
@@ -811,11 +821,11 @@
}
else if (portletMode.equals(PortletMode.VIEW.toString()))
{
- uiPortlet.setCurrentPortletMode(PortletMode.VIEW);
+ uiPortlet.setCurrentPortletMode(PortletMode.VIEW);
}
else
{
- PortletMode customMode = new PortletMode(portletMode);
+ PortletMode customMode = new PortletMode(portletMode);
uiPortlet.setCurrentPortletMode(customMode);
}
event.getRequestContext().addUIComponentToUpdateByAjax(uiPortlet);