[jboss-svn-commits] JBoss Portal SVN: r5224 - in trunk/wsrp/src/main/org/jboss/portal: test/wsrp/v1/producer wsrp/consumer wsrp/producer
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Sep 18 18:15:58 EDT 2006
Author: chris.laprun at jboss.com
Date: 2006-09-18 18:15:55 -0400 (Mon, 18 Sep 2006)
New Revision: 5224
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/MarkupTestCase.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/InvocationHandler.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java
Log:
- JBPORTAL-1041: de-activated fragment processing. Needs to be converted to interceptor. Adapted test case.
- JBPORTAL-1039: first implementation. If no namespace prefix is provided by the consumer, use the portlet handle for now.
Need better implementation. Add namespacePrefix and portletInstanceKey to markup request in consumer.
- Improved logging.
- Minor code improvements.
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/MarkupTestCase.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/MarkupTestCase.java 2006-09-18 22:02:54 UTC (rev 5223)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/MarkupTestCase.java 2006-09-18 22:15:55 UTC (rev 5224)
@@ -90,8 +90,13 @@
getMarkup.getMarkupParams().setMode(WSRPConstants.EDIT_MODE);
MarkupResponse response = markupService.getMarkup(getMarkup);
+ /*
+ // commented out because fails with fragment processing de-activation
checkMarkupResponse(response, "<form method='post' action='wsrp_rewrite?wsrp-urlType=blockingAction&wsrp" +
"-interactionState=JBPNS_/wsrp_rewrite' id='wsrp_rewrite_portfolioManager'><table><tr><td>Stock symbol</t" +
+ "d><td><input name='symbol'/></td></tr><tr><td><input type='submit' value='Submit'></td></tr></table></form>");*/
+ checkMarkupResponse(response, "<form method='post' action='wsrp_rewrite?wsrp-urlType=blockingAction&wsrp" +
+ "-interactionState=JBPNS_/wsrp_rewrite' id='portfolioManager'><table><tr><td>Stock symbol</t" +
"d><td><input name='symbol'/></td></tr><tr><td><input type='submit' value='Submit'></td></tr></table></form>");
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/InvocationHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/InvocationHandler.java 2006-09-18 22:02:54 UTC (rev 5223)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/InvocationHandler.java 2006-09-18 22:15:55 UTC (rev 5224)
@@ -27,6 +27,8 @@
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.result.ErrorResult;
+import org.jboss.portal.portlet.spi.InstanceContext;
+import org.jboss.portal.portlet.spi.WindowContext;
import org.jboss.portal.wsrp.core.InvalidCookieFault;
import org.jboss.portal.wsrp.core.InvalidRegistrationFault;
import org.jboss.portal.wsrp.core.InvalidSessionFault;
@@ -104,6 +106,13 @@
sessionHandler.initCookieIfNeeded(invocation);
updateRegistrationContext(request);
RuntimeContext runtimeContext = getRuntimeContextFrom(request);
+
+ WindowContext windowContext = invocation.getWindowContext();
+ runtimeContext.setNamespacePrefix(windowContext == null ? null : windowContext.getId());
+
+ InstanceContext instanceContext = invocation.getInstanceContext();
+ runtimeContext.setPortletInstanceKey(instanceContext == null ? null : instanceContext.getId());
+
updateUserContext(request, consumer.getUserContextFrom(invocation, runtimeContext));
consumer.setTemplatesIfNeeded(invocation, runtimeContext);
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java 2006-09-18 22:02:54 UTC (rev 5223)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java 2006-09-18 22:15:55 UTC (rev 5224)
@@ -25,7 +25,6 @@
import org.jboss.logging.Logger;
import org.jboss.portal.common.MediaType;
import org.jboss.portal.common.util.LocaleInfo;
-import org.jboss.portal.common.util.Tools;
import org.jboss.portal.portlet.OpaqueStateString;
import org.jboss.portal.portlet.Parameters;
import org.jboss.portal.portlet.Portlet;
@@ -51,7 +50,6 @@
import org.jboss.portal.server.util.HTTPStreamInfo;
import org.jboss.portal.wsrp.UserContextConverter;
import org.jboss.portal.wsrp.WSRPConstants;
-import org.jboss.portal.wsrp.WSRPRewritingConstants;
import org.jboss.portal.wsrp.WSRPTypeFactory;
import org.jboss.portal.wsrp.WSRPUtils;
import org.jboss.portal.wsrp.core.AccessDeniedFault;
@@ -182,7 +180,7 @@
PortalContext portalContext = createPortalContext(params, markupRequest);
UserContext userContext = createUserContext(wsrpUserContext, markupRequest.getLocale(), desiredLocales);
InstanceContext instanceContext = createInstanceContext(portletHandle, AccessMode.READ_ONLY);
- WindowContext windowContext = createWindowContext(runtimeContext);
+ WindowContext windowContext = createWindowContext(portletHandle, runtimeContext);
// prepare the invocation
WSRPRenderContext renderContext = new WSRPRenderContext(navigationalState, securityContext, streamInfo,
@@ -191,11 +189,14 @@
WSRPUtils.getJSR168WindowStateFromWSRPName(markupRequest.getWindowState()));
RenderInvocation render = new RenderInvocation(renderContext);
renderContext.contextualize(render);
- render.setAttribute(PortletInvocation.REQUEST_SCOPE, PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE, new org.jboss.portal.portlet.PortletContext(portlet.getId()));
+ render.setAttribute(PortletInvocation.REQUEST_SCOPE, PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE,
+ new org.jboss.portal.portlet.PortletContext(portlet.getId()));
try
{
+ log.debug("RenderInvocation on portlet '" + portletHandle + "'");
producer.getInvoker().invoke(render);
+ log.debug("RenderInvocation done");
}
catch (PortletInvokerException e)
{
@@ -211,7 +212,7 @@
switch (fragment.getType())
{
case FragmentResult.TYPE_CHARS:
- markupString = processFragmentString(fragment.getChars().toString());
+ markupString = fragment.getChars().toString();
break;
case FragmentResult.TYPE_BYTES:
markupBinary = fragment.getBytes().toByteArray(); // fix-me: might need to convert to Base64?
@@ -249,24 +250,6 @@
return new MarkupResponse(markupContext, null, null);
}
- /**
- * Process String returned from RenderResult to add rewriting token if necessary. Right now, only id attributes are
- * being marked for rewriting when rewriting needs to occur. fix-me: need to check for producer rewriting
- *
- * @param renderString the String to be processed for rewriting marking
- * @return a String processed to add rewriting tokens as necessary
- */
- private String processFragmentString(String renderString)
- {
- if (renderString != null)
- {
- String result = Tools.replace(renderString, "id='", "id='" + WSRPRewritingConstants.WSRP_REWRITE_TOKEN);
- result = Tools.replace(result, "id=\"", "id=\"" + WSRPRewritingConstants.WSRP_REWRITE_TOKEN);
- return result;
- }
- return null;
- }
-
public BlockingInteractionResponse performBlockingInteraction(PerformBlockingInteraction performBlockingInteraction)
throws InvalidSessionFault, UnsupportedModeFault, UnsupportedMimeTypeFault, OperationFailedFault,
UnsupportedWindowStateFault, UnsupportedLocaleFault, AccessDeniedFault, PortletStateChangeRequiredFault,
@@ -288,8 +271,8 @@
PortletContext portletContext = performBlockingInteraction.getPortletContext();
WSRPUtils.throwMissingParametersFaultIfValueIsMissing(portletContext, "PortletContext", PBI);
- String handle = portletContext.getPortletHandle();
- WSRPUtils.throwMissingParametersFaultIfValueIsMissing(handle, "portlet handle", "PortletContext");
+ String portletHandle = portletContext.getPortletHandle();
+ WSRPUtils.throwMissingParametersFaultIfValueIsMissing(portletHandle, "portlet handle", "PortletContext");
RuntimeContext runtimeContext = performBlockingInteraction.getRuntimeContext();
WSRPUtils.throwMissingParametersFaultIfValueIsMissing(runtimeContext, "RuntimeContext", PBI);
@@ -301,7 +284,7 @@
final Portlet portlet;
try
{
- portlet = invoker.getPortlet(handle);
+ portlet = invoker.getPortlet(portletHandle);
}
catch (PortletInvokerException e)
{
@@ -312,7 +295,7 @@
// get portlet description for the desired portlet...
final String[] desiredLocales = markupParams.getLocales();
- PortletDescription portletDescription = producer.getPortletDescription(handle, desiredLocales);
+ PortletDescription portletDescription = producer.getPortletDescription(portletHandle, desiredLocales);
if (Boolean.TRUE.equals(portletDescription.getUsesMethodGet()))
{
throw WSRPUtils.createOperationFailedFault(
@@ -329,11 +312,11 @@
HTTPStreamInfo streamInfo = createStreamInfo(markupRequest);
PortalContext portalContext = createPortalContext(markupParams, markupRequest);
UserContext userContext = createUserContext(wsrpUserContext, markupRequest.getLocale(), desiredLocales);
- WindowContext windowContext = createWindowContext(runtimeContext);
+ WindowContext windowContext = createWindowContext(portletHandle, runtimeContext);
StateChange stateChange = interactionParams.getPortletStateChange();
WSRPUtils.throwMissingParametersFaultIfValueIsMissing(stateChange, "portletStateChange", "InteractionParams");
- InstanceContext instanceContext = createInstanceContext(handle, WSRPUtils.getAccessModeFromStateChange(stateChange));
+ InstanceContext instanceContext = createInstanceContext(portletHandle, WSRPUtils.getAccessModeFromStateChange(stateChange));
Parameters parameters;
@@ -368,6 +351,7 @@
{
parameters = new Parameters();
}
+ log.debug("form parameters:\n" + parameters);
StateString interactionState = createNavigationalState(interactionParams.getInteractionState());
@@ -378,11 +362,14 @@
markupRequest.getCharacterSet(), markupRequest.getMimeType());
ActionInvocation invocation = new ActionInvocation(context);
context.contextualize(invocation);
- invocation.setAttribute(PortletInvocation.REQUEST_SCOPE, PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE, new org.jboss.portal.portlet.PortletContext(portlet.getId()));
+ invocation.setAttribute(PortletInvocation.REQUEST_SCOPE, PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE,
+ new org.jboss.portal.portlet.PortletContext(portlet.getId()));
try
{
+ log.debug("ActionInvocation on portlet '" + portletHandle + "'");
producer.getInvoker().invoke(invocation);
+ log.debug("ActionInvocation done");
}
catch (PortletInvokerException e)
{
@@ -506,21 +493,6 @@
// Parameter checking methods ***************************************************************************************
- private String checkSessionId(RuntimeContext runtimeContext) throws InvalidSessionFault
- {
- String sessionId = null;
- if (runtimeContext != null)
- {
- sessionId = runtimeContext.getSessionID();
- if (sessionId != null && !producer.isSessionValid(sessionId))
- {
- throw(InvalidSessionFault)WSRPUtils.createFaultFrom(InvalidSessionFault.class,
- new IllegalStateException("Session with id: " + sessionId + " is invalid."));
- }
- }
- return sessionId;
- }
-
private void checkUserContext(org.jboss.portal.wsrp.core.UserContext wsrpUserContext) throws MissingParametersFault
{
if (wsrpUserContext != null)
@@ -560,13 +532,22 @@
};
}
- private WindowContext createWindowContext(final RuntimeContext runtimeContext)
+ private WindowContext createWindowContext(final String portletHandle, final RuntimeContext runtimeContext)
{
return new WindowContext()
{
public String getId()
{
- return runtimeContext.getNamespacePrefix();
+ String prefix = runtimeContext.getNamespacePrefix();
+ if (prefix != null && prefix.length() > 0)
+ {
+ return prefix;
+ }
+ else
+ {
+ log.debug("No provided namespace prefix for portlet '" + portletHandle + "'. Using portlet handle as namespace.");
+ return portletHandle;
+ }
}
};
}
@@ -905,4 +886,4 @@
return result;
}
}
-}
\ No newline at end of file
+}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java 2006-09-18 22:02:54 UTC (rev 5223)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java 2006-09-18 22:15:55 UTC (rev 5224)
@@ -156,7 +156,7 @@
public ServiceDescription getServiceDescription(GetServiceDescription gs)
throws InvalidRegistrationFault, OperationFailedFault, RemoteException
{
- log.debug("getServiceDescription() invoked");
+ log.debug("getServiceDescription invoked");
ServiceDescription sd = serviceDescriptionHandler.getServiceDescription(gs);
//to avoid unnesessary processing
@@ -174,6 +174,7 @@
}
}
+ log.debug("end getServiceDescription");
return sd;
}
@@ -185,8 +186,10 @@
OperationFailedFault, MissingParametersFault, InvalidUserCategoryFault, InvalidRegistrationFault,
UnsupportedMimeTypeFault, RemoteException
{
- log.info("getMarkup() invoked");
- return markupHandler.getMarkup(getMarkup);
+ log.debug("getMarkup invoked");
+ MarkupResponse response = markupHandler.getMarkup(getMarkup);
+ log.debug("end getMarkup");
+ return response;
}
public BlockingInteractionResponse performBlockingInteraction(PerformBlockingInteraction performBlockingInteraction)
@@ -195,22 +198,28 @@
InvalidRegistrationFault, MissingParametersFault, InvalidUserCategoryFault, InconsistentParametersFault,
InvalidHandleFault, InvalidCookieFault, RemoteException
{
- log.info("performBlockingInteraction() invoked");
- return markupHandler.performBlockingInteraction(performBlockingInteraction);
+ log.debug("performBlockingInteraction invoked");
+ BlockingInteractionResponse interactionResponse = markupHandler.performBlockingInteraction(performBlockingInteraction);
+ log.debug("end performBlockingInteraction");
+ return interactionResponse;
}
public ReturnAny releaseSessions(ReleaseSessions releaseSessions)
throws InvalidRegistrationFault, OperationFailedFault, MissingParametersFault, AccessDeniedFault, RemoteException
{
- log.info("releaseSessions() invoked");
- return markupHandler.releaseSessions(releaseSessions);
+ log.debug("releaseSessions invoked");
+ ReturnAny returnAny = markupHandler.releaseSessions(releaseSessions);
+ log.debug("end releaseSessions");
+ return returnAny;
}
public ReturnAny initCookie(InitCookie initCookie)
throws AccessDeniedFault, OperationFailedFault, InvalidRegistrationFault, RemoteException
{
- log.info("initCookie() invoked");
- return markupHandler.initCookie(initCookie);
+ log.debug("initCookie invoked");
+ ReturnAny returnAny = markupHandler.initCookie(initCookie);
+ log.debug("end initCookie");
+ return returnAny;
}
// Registration implementation **************************************************************************************
@@ -218,22 +227,28 @@
public RegistrationContext register(RegistrationData register) throws MissingParametersFault, OperationFailedFault,
RemoteException
{
- log.info("register() invoked");
- return registrationHandler.register(register);
+ log.debug("register invoked");
+ RegistrationContext registrationContext = registrationHandler.register(register);
+ log.debug("end register");
+ return registrationContext;
}
public ReturnAny deregister(RegistrationContext deregister) throws OperationFailedFault, InvalidRegistrationFault,
RemoteException
{
- log.info("deregister() invoked");
- return registrationHandler.deregister(deregister);
+ log.debug("deregister invoked");
+ ReturnAny returnAny = registrationHandler.deregister(deregister);
+ log.debug("end deregister");
+ return returnAny;
}
public RegistrationState modifyRegistration(ModifyRegistration modifyRegistration) throws MissingParametersFault,
OperationFailedFault, InvalidRegistrationFault, RemoteException
{
- log.info("modifyRegistration() invoked");
- return registrationHandler.modifyRegistration(modifyRegistration);
+ log.debug("modifyRegistration invoked");
+ RegistrationState registrationState = registrationHandler.modifyRegistration(modifyRegistration);
+ log.debug("end modifyRegistration");
+ return registrationState;
}
// PortletManagement implementation *********************************************************************************
@@ -242,47 +257,59 @@
throws AccessDeniedFault, InvalidHandleFault, InvalidUserCategoryFault, InconsistentParametersFault,
MissingParametersFault, InvalidRegistrationFault, OperationFailedFault, RemoteException
{
- log.info("getPortletDescription() invoked");
- return portletManagementHandler.getPortletDescription(getPortletDescription);
+ log.debug("getPortletDescription invoked");
+ PortletDescriptionResponse description = portletManagementHandler.getPortletDescription(getPortletDescription);
+ log.debug("end getPortletDescription");
+ return description;
}
public PortletContext clonePortlet(ClonePortlet clonePortlet) throws InvalidUserCategoryFault, AccessDeniedFault,
OperationFailedFault, InvalidHandleFault, InvalidRegistrationFault, InconsistentParametersFault,
MissingParametersFault, RemoteException
{
- log.info("clonePortlet() invoked");
- return portletManagementHandler.clonePortlet(clonePortlet);
+ log.debug("clonePortlet invoked");
+ PortletContext portletContext = portletManagementHandler.clonePortlet(clonePortlet);
+ log.debug("end clonePortlet");
+ return portletContext;
}
public DestroyPortletsResponse destroyPortlets(DestroyPortlets destroyPortlets) throws InconsistentParametersFault,
MissingParametersFault, InvalidRegistrationFault, OperationFailedFault, RemoteException
{
- log.info("destroyPortlets() invoked");
- return portletManagementHandler.destroyPortlets(destroyPortlets);
+ log.debug("destroyPortlets invoked");
+ DestroyPortletsResponse destroyPortletsResponse = portletManagementHandler.destroyPortlets(destroyPortlets);
+ log.debug("end destroyPortlets");
+ return destroyPortletsResponse;
}
public PortletContext setPortletProperties(SetPortletProperties setPortletProperties) throws OperationFailedFault,
InvalidHandleFault, MissingParametersFault, InconsistentParametersFault, InvalidUserCategoryFault,
AccessDeniedFault, InvalidRegistrationFault, RemoteException
{
- log.info("setPortletProperties() invoked");
- return portletManagementHandler.setPortletProperties(setPortletProperties);
+ log.debug("setPortletProperties invoked");
+ PortletContext portletContext = portletManagementHandler.setPortletProperties(setPortletProperties);
+ log.debug("end setPortletProperties");
+ return portletContext;
}
public PropertyList getPortletProperties(GetPortletProperties getPortletProperties) throws InvalidHandleFault,
MissingParametersFault, InvalidRegistrationFault, AccessDeniedFault, OperationFailedFault,
InconsistentParametersFault, InvalidUserCategoryFault, RemoteException
{
- log.info("getPortletProperties() invoked");
- return portletManagementHandler.getPortletProperties(getPortletProperties);
+ log.debug("getPortletProperties invoked");
+ PropertyList list = portletManagementHandler.getPortletProperties(getPortletProperties);
+ log.debug("end getPortletProperties");
+ return list;
}
public PortletPropertyDescriptionResponse getPortletPropertyDescription(GetPortletPropertyDescription getPortletPropertyDescription)
throws MissingParametersFault, InconsistentParametersFault, InvalidUserCategoryFault, InvalidRegistrationFault,
AccessDeniedFault, InvalidHandleFault, OperationFailedFault, RemoteException
{
- log.info("getPortletPropertyDescription() invoked");
- return portletManagementHandler.getPortletPropertyDescription(getPortletPropertyDescription);
+ log.debug("getPortletPropertyDescription invoked");
+ PortletPropertyDescriptionResponse descriptionResponse = portletManagementHandler.getPortletPropertyDescription(getPortletPropertyDescription);
+ log.debug("end getPortletPropertyDescription");
+ return descriptionResponse;
}
// Producer implementation ******************************************************************************************
@@ -323,14 +350,14 @@
return sessionManager.isSessionValid(sessionId);
}
- HttpSession getSession()
+ public void addSession(HttpSession session)
{
- return ServletAccess.getRequest().getSession(false);
+ sessionManager.addSession(session);
}
- public void addSession(HttpSession session)
+ HttpSession getSession()
{
- sessionManager.addSession(session);
+ return ServletAccess.getRequest().getSession(false);
}
public void releaseSession(String sessionID) throws IllegalStateException
@@ -350,8 +377,7 @@
Portlet getPortletWith(String handle) throws InvalidHandleFault, PortletInvokerException
{
-
- Portlet portlet = null;
+ Portlet portlet;
try
{
portlet = invoker.getPortlet(handle);
@@ -372,7 +398,7 @@
Set getRemotablePortlets() throws PortletInvokerException
{
- log.debug("Picking up remotable portlets");
+ log.debug("Retrieving remotable portlets");
Set allPortlets = invoker.getPortlets();
Set remotablePortlets = new HashSet(allPortlets.size());
for (Iterator iterator = allPortlets.iterator(); iterator.hasNext();)
@@ -382,7 +408,7 @@
if (isRemotable(portlet))
{
remotablePortlets.add(portlet);
- log.debug("Adding remotable portet to set: " + portlet.getId());
+ log.debug("Adding remotable portlet to set: " + portlet.getId());
}
}
return remotablePortlets;
@@ -420,9 +446,9 @@
/** Dispatch the invocation to the target by reflection */
public Object invoke(Invocation invocation) throws Exception
{
- log.debug("invoke() invoked");
Method method = invocation.getMethod();
Object[] args = invocation.getArguments();
+ log.debug("invoke invoked: method=" + method + " args=" + args);
return method.invoke(this, args);
}
@@ -437,9 +463,9 @@
*/
protected boolean isRegistrationValid(RegistrationContext registrationContext) throws InvalidRegistrationFault
{
- log.debug("checking isRegistrationValid()");
if (isRequiresRegistration())
{
+ log.debug("registration required: checking registration");
// todo: implement more completely
if (registrationContext == null)
{
@@ -453,8 +479,8 @@
throw(InvalidRegistrationFault)WSRPUtils.createFaultFrom(InvalidRegistrationFault.class,
new IllegalArgumentException("Missing required registration handle is not a valid registration."));
}
+ log.debug("registration is valid");
}
- log.debug("registration is valid");
return true;
}
More information about the jboss-svn-commits
mailing list