Author: chris.laprun(a)jboss.com
Date: 2006-12-21 14:15:13 -0500 (Thu, 21 Dec 2006)
New Revision: 5926
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducerImpl.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/MarkupTestCase.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/NeedPortletHandleTest.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/ReleaseSessionTestCase.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPProducer.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPTypeFactory.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java
trunk/wsrp/src/resources/tests/test-wsrp-producer-markup-sar/META-INF/jboss-service.xml
Log:
- Implemented setPortletProperties on Consumer. NOT TESTED!!!
- Removed unused session management code.
- Integrated (with modifications) Matt's patch for session handling testing.
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducerImpl.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducerImpl.java 2006-12-21
16:07:08 UTC (rev 5925)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducerImpl.java 2006-12-21
19:15:13 UTC (rev 5926)
@@ -360,12 +360,6 @@
this.sessionExpirationTime = sessionExpirationTime;
}
- public boolean isSessionValid(String sessionId)
- {
- // todo: implement
- return true;
- }
-
public ProducerRegistrationRequirements getProducerRegistrationRequirements()
{
throw new UnsupportedOperationException("getProducerRegistrationRequirements
not implemented");
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-12-21
16:07:08 UTC (rev 5925)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/MarkupTestCase.java 2006-12-21
19:15:13 UTC (rev 5926)
@@ -39,6 +39,8 @@
import org.jboss.portal.wsrp.core.NamedString;
import org.jboss.portal.wsrp.core.OperationFailedFault;
import org.jboss.portal.wsrp.core.PerformBlockingInteraction;
+import org.jboss.portal.wsrp.core.RuntimeContext;
+import org.jboss.portal.wsrp.core.SessionContext;
import org.jboss.portal.wsrp.core.UnsupportedModeFault;
import org.jboss.portal.wsrp.core.UpdateResponse;
@@ -84,6 +86,28 @@
}
}
+ /**
+ * The consumer should never have access to or be able to set a sessionID. Sessions
are handled by the Producer using
+ * cookies.
+ *
+ * @throws Exception
+ */
+ public void testGetMarkupWithSessionID() throws Exception
+ {
+ GetMarkup getMarkup = createMarkupRequest();
+ getMarkup.getRuntimeContext().setSessionID("Hello World");
+
+ try
+ {
+ markupService.getMarkup(getMarkup);
+ ExtendedAssert.fail("A sessionID should not be allowed to be passed in
GetMarkup()");
+ }
+ catch (OperationFailedFault operationFailedFault)
+ {
+ // expected fault.
+ }
+ }
+
public void testGetMarkupEditNoSession() throws Exception
{
GetMarkup getMarkup = createMarkupRequest();
@@ -223,6 +247,32 @@
checkMarkupResponse(response, "<p>" + symbol + " stock value:
123.45</p>");
}
+ /**
+ * The consumer should never have access to or be able to set a sessionID. The
sessions are handled by the producer
+ * using cookies.
+ *
+ * @throws Exception
+ */
+ public void testPBIWithSessionID() throws Exception
+ {
+ String portletHandle = getDefaultHandle();
+ PerformBlockingInteraction performBlockingInteraction =
WSRPTypeFactory.createDefaultPerformBlockingInteraction(portletHandle);
+
+ RuntimeContext runtimeContext = performBlockingInteraction.getRuntimeContext();
+ //the sessionID should never be set by the consumer. Sessions are handled by
cookies instead
+ runtimeContext.setSessionID("Hello World");
+
+ try
+ {
+ markupService.performBlockingInteraction(performBlockingInteraction);
+ ExtendedAssert.fail("Should not be able to pass a sessionID in a
PerformBlockingInteraction()");
+ }
+ catch (OperationFailedFault operationFailedFault)
+ {
+ // expected failure
+ }
+ }
+
public void testMarkupCaching() throws Exception
{
GetMarkup getMarkup = createMarkupRequest();
@@ -426,6 +476,8 @@
ExtendedAssert.assertNotNull(updateResponse);
// request was readOnly so no updated portlet context
ExtendedAssert.assertNull(updateResponse.getPortletContext());
+ // check that no sessionId is getting passed.
+ ExtendedAssert.assertNull(updateResponse.getSessionContext());
String navigationalState = updateResponse.getNavigationalState();
ExtendedAssert.assertNotNull(navigationalState);
@@ -462,6 +514,11 @@
ExtendedAssert.assertTrue(markupContext.getRequiresUrlRewriting().booleanValue());
ExtendedAssert.assertEquals(markupString, markupContext.getMarkupString());
+ // Session context
+ SessionContext sessionContext = response.getSessionContext();
+ // The session information is should never be sent to the consumer, Cookies are
used instead.
+ ExtendedAssert.assertNull(sessionContext);
+
return markupContext;
}
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/NeedPortletHandleTest.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/NeedPortletHandleTest.java 2006-12-21
16:07:08 UTC (rev 5925)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/NeedPortletHandleTest.java 2006-12-21
19:15:13 UTC (rev 5926)
@@ -34,6 +34,7 @@
import org.jboss.portal.wsrp.core.OperationFailedFault;
import org.jboss.portal.wsrp.core.PortletDescription;
import org.jboss.portal.wsrp.core.ServiceDescription;
+import org.jboss.portal.wsrp.core.SessionContext;
import org.jboss.portal.wsrp.handler.RequestHeaderClientHandler;
import java.rmi.RemoteException;
@@ -177,5 +178,9 @@
ProducerSessionInformation sessionInfo =
RequestHeaderClientHandler.getCurrentProducerSessionInformation();
ExtendedAssert.assertNotNull(sessionInfo);
ExtendedAssert.assertTrue(sessionInfo.getUserCookie().lastIndexOf("JSESSIONID")
!= -1);
+
+ // Check that we are not sending sessionID's
+ SessionContext sessionContext = response.getSessionContext();
+ ExtendedAssert.assertNull(sessionContext);
}
}
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/ReleaseSessionTestCase.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/ReleaseSessionTestCase.java 2006-12-21
16:07:08 UTC (rev 5925)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/ReleaseSessionTestCase.java 2006-12-21
19:15:13 UTC (rev 5926)
@@ -26,17 +26,11 @@
import org.jboss.logging.Logger;
import org.jboss.portal.common.junit.ExtendedAssert;
import org.jboss.portal.wsrp.WSRPTypeFactory;
-import org.jboss.portal.wsrp.consumer.ProducerSessionInformation;
-import org.jboss.portal.wsrp.core.GetMarkup;
-import org.jboss.portal.wsrp.core.InvalidRegistrationFault;
-import org.jboss.portal.wsrp.core.MarkupResponse;
-import org.jboss.portal.wsrp.core.MissingParametersFault;
import org.jboss.portal.wsrp.core.OperationFailedFault;
import org.jboss.portal.wsrp.core.RegistrationContext;
import org.jboss.portal.wsrp.core.ReleaseSessions;
-import org.jboss.portal.wsrp.handler.RequestHeaderClientHandler;
-import java.rmi.RemoteException;
+import java.util.Arrays;
/**
* Tests the behavior of the ReleaseSession method.
@@ -70,232 +64,86 @@
log.debug("Instantiating ReleaseSessionTestCase");
}
- public void testNullRegistrationContextWithRegistration() throws Exception
- {
- RegistrationContext regContext = null;
-
- Class exceptionClass = InvalidRegistrationFault.class;
- String message = "A null RegistrationContext when a registration is required
should produce an InvalidRegistrationFault";
-
- releaseSessionsWithRegistration(regContext, null, exceptionClass, message);
- }
-
- public void testNullRegistrationContext() throws Exception
+ public void testReleaseSession() throws Exception
{
- RegistrationContext regContext = null;
+ // possible registration contexts are: actual RegistrationContext, null, and a made
up value
+ RegistrationContext fakeRegContext =
WSRPTypeFactory.createRegistrationContext("Fake Registration Handle");
+ RegistrationContext[] regContexts = new
RegistrationContext[]{getRegistrationContext(), null, fakeRegContext};
- GetMarkup getMarkup = createMarkupRequest();
- MarkupResponse response = markupService.getMarkup(getMarkup);
- checkSessionForCurrentlyDeployedPortlet(response);
+ // possible types of sessionIDs include null and a made up value.
+ // Note: a valid session id cannot be used since the sessionID should never be sent
to the consumer
+ String nullSessionID = null;
+ String fakeSessionID = "Fake Session ID";
- // Since no registration is required, a null RegistrationContext should be
acceptable
- releaseSessions(regContext, null, null, null);
- }
+ String[][] sessionIDs = new String[][]{{nullSessionID},
+ {nullSessionID, nullSessionID},
+ {fakeSessionID},
+ {fakeSessionID, fakeSessionID},
+ {fakeSessionID, nullSessionID},
+ {nullSessionID, fakeSessionID}};
- public void testNullSessionIDWithRegistration() throws Exception
- {
-
- RegistrationContext regContext = getRegistrationContext();
- String[] sessionIDs = null;
-
- Class exceptionClass = MissingParametersFault.class;
- String message = "SessionIDs are required. Null SessionIDs should produce a
MissingParameterFault";
-
- releaseSessionsWithRegistration(regContext, sessionIDs, exceptionClass, message);
+ for (int i = 0; i < regContexts.length; i++)
+ {
+ for (int j = 0; j < sessionIDs.length; j++)
+ {
+ ReleaseSessions releaseSession = new ReleaseSessions(regContexts[i],
sessionIDs[j]);
+ releaseSessions(releaseSession, false);
+ releaseSessions(releaseSession, true);
+ }
+ }
}
- public void testNullSessionID() throws Exception
+ private RegistrationContext getRegistrationContext() throws Exception
{
-
- RegistrationContext regContext = getRegistrationContext();
- String[] sessionIDs = null;
-
- Class exceptionClass = MissingParametersFault.class;
- String message = "SessionIDs are required. Null SessionIDs should produce a
MissingParameterFault";
-
- releaseSessions(regContext, sessionIDs, exceptionClass, message);
+ return registerConsumer();
}
- public void testInvalidRegistrationContextWithRegistration() throws Exception
+ private void releaseSessions(ReleaseSessions releaseSessions, boolean useRegistration)
throws Exception
{
- RegistrationContext regContext =
WSRPTypeFactory.createRegistrationContext("Fake Registration Handle");
-
- Class exceptionClass = InvalidRegistrationFault.class;
- String message = "An invalid RegistrationContext when a registration is
required should produce an InvalidRegistrationFault";
-
- releaseSessionsWithRegistration(regContext, getSessionIDs(), exceptionClass,
message);
- }
-
- public void testInvalidRegistrationContext() throws Exception
- {
- RegistrationContext regContext =
WSRPTypeFactory.createRegistrationContext("Fake Registration Handle");
-
- Class exceptionClass = InvalidRegistrationFault.class;
- String message = "An invalid RegistrationContext when a registration is not
required should still produce an InvalidRegistrationFault";
-
- releaseSessions(regContext, getSessionIDs(), exceptionClass, message);
- }
-
- public void testInvalidSessionIDsWithRegistration() throws Exception
- {
- RegistrationContext regContext = getRegistrationContext();
- String[] sessionIDs = new String[]
- {"fake session id"};
-
- Class exceptionClass = OperationFailedFault.class;
- String message = "An invalid SessionIDs should produce an
OperationFailedFault";
-
- releaseSessionsWithRegistration(regContext, sessionIDs, exceptionClass, message);
- }
-
- public void testInvalidSessionIDs() throws Exception
- {
- RegistrationContext regContext = getRegistrationContext();
- String[] sessionIDs = new String[]
- {"fake session id"};
-
- Class exceptionClass = OperationFailedFault.class;
- String message = "An invalid SessionIDs should produce an
OperationFailedFault";
-
- releaseSessions(regContext, sessionIDs, exceptionClass, message);
- }
-
- public void testNullParametersWithRegistration() throws Exception
- {
- RegistrationContext regContext = null;
- String[] sessionIDs = null;
-
- // This method can potentially throw two different fault methods
- // (InvalidRegistration and MissingParameters) for the given parameters.
- Class exceptionClass = InvalidRegistrationFault.class;
- String message = "Null RegistrationContext when registration is reguired
should produce an InvalidRegistrationFault";
-
- releaseSessionsWithRegistration(regContext, sessionIDs, exceptionClass, message);
- }
-
- public void testNullParameters() throws Exception
- {
- RegistrationContext regContext = null;
- String[] sessionIDs = null;
-
- Class exceptionClass = MissingParametersFault.class;
- String message = "Null SessionIDs should produce a
MissingParameterFault";
-
- releaseSessions(regContext, sessionIDs, exceptionClass, message);
- }
-
- public void testValidParametersWithRegistration() throws Exception
- {
- RegistrationContext regContext = getRegistrationContext();
- String[] sessionIDs = getSessionIDs();
- releaseSessionsWithRegistration(regContext, sessionIDs, null, null);
- }
-
- public void testValidParameters() throws Exception
- {
- RegistrationContext regContext = getRegistrationContext();
- String[] sessionIDs = getSessionIDs();
- releaseSessions(regContext, sessionIDs, null, null);
- }
-
- public void testReleasedSession() throws Exception
- {
- RegistrationContext regContext = getRegistrationContext();
- String[] sessionIDs = getSessionIDs();
-
- ReleaseSessions relSession = new ReleaseSessions(regContext, sessionIDs);
-
- markupService.releaseSessions(relSession);
-
+ setUp();
try
{
- markupService.releaseSessions(relSession);
- ExtendedAssert.fail("Trying to release an already released session should
produce an OperationFailedFault");
+ log.info(getSetupString(releaseSessions));
+ if (useRegistration)
+ {
+ configureRegistrationSettings(false);
+ }
+ markupService.releaseSessions(releaseSessions);
+ ExtendedAssert.fail("ReleaseSessions did not thrown an OperationFailed
Fault." + getSetupString(releaseSessions));
}
catch (OperationFailedFault operationFailedFault)
{
- // expected failure
+ // expected error;
}
-
+ finally
+ {
+ tearDown();
+ }
}
- public void testReleasedSessionWithRegistration() throws Exception
+ private String getSetupString(ReleaseSessions releaseSessions)
{
- configureRegistrationSettings(false);
- testReleasedSession();
- registrationService.deregister(getRegistrationContext());
- }
+ String message = "ReleaseSessions Setup:\n";
- public void testNullReleaseSessions() throws Exception
- {
- ReleaseSessions relSession = null;
- try
+ if (releaseSessions == null)
{
- markupService.releaseSessions(relSession);
- ExtendedAssert.fail("A null ReleaseSessions should produce an
OperationFailedFault");
+ message += " ReleaseSessions : null";
}
- catch (OperationFailedFault operationFailedFault)
+ else
{
- // expected
+ RegistrationContext regContext = releaseSessions.getRegistrationContext();
+ String[] sessionIDs = releaseSessions.getSessionIDs();
+ message += " RegistrationContext : " + (regContext != null ?
regContext.getRegistrationHandle() : null);
+ message += " | SessionIDs : " + Arrays.toString(sessionIDs);
}
- }
- public void testNullReleaseSessionsWithRegistration() throws Exception
- {
- configureRegistrationSettings(false);
- testNullReleaseSessions();
- registrationService.deregister(getRegistrationContext());
- }
-
-
//*************************************************************************************************
-
-
- private String[] getSessionIDs() throws RemoteException, InvalidRegistrationFault,
OperationFailedFault
- {
- ProducerSessionInformation sessionInfo =
RequestHeaderClientHandler.getCurrentProducerSessionInformation();
- // session ids are portlet session, not portal session so we cannot rely on the
JSESSIONID cookie
- String sessionID = sessionInfo.getSessionIdForPortlet(getDefaultHandle());
- return new String[]
- {sessionID};
- }
-
- private RegistrationContext getRegistrationContext() throws Exception
- {
- return registerConsumer();
- }
-
- private void releaseSessions(RegistrationContext regContext, String[] sessionIDs,
Class exceptionClass,
- String message) throws Exception
- {
- ReleaseSessions relSession = new ReleaseSessions(regContext, sessionIDs);
- try
+ if (producer.getProducerRegistrationRequirements().requiresRegistration())
{
- markupService.releaseSessions(relSession);
- if (exceptionClass != null)
- {
- ExtendedAssert.fail(message);
- }
+ message += " | with registration required.";
}
- catch (Exception e)
- {
- if (e.getClass() == exceptionClass && exceptionClass != null)
- {
- //expected exception
- }
- else
- {
- throw e;
- }
- }
- }
- private void releaseSessionsWithRegistration(RegistrationContext regContext, String[]
sessionIDs,
- Class exceptionClass, String message)
throws Exception
- {
- configureRegistrationSettings(false);
- releaseSessions(regContext, sessionIDs, exceptionClass, message);
- registrationService.deregister(regContext);
+ return message;
}
-}
+}
\ No newline at end of file
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPProducer.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPProducer.java 2006-12-21 16:07:08 UTC
(rev 5925)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPProducer.java 2006-12-21 19:15:13 UTC
(rev 5926)
@@ -90,14 +90,6 @@
*/
void setSessionExpirationTime(int sessionExpirationTime);
- /**
- * Checks that the session identified with the specified id is valid.
- *
- * @param sessionId
- * @return <code>true</code> if the session associated with the given id
is valid, <code>false</code> otherwise.
- */
- boolean isSessionValid(String sessionId);
-
ProducerRegistrationRequirements getProducerRegistrationRequirements();
RegistrationManager getRegistrationManager();
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPTypeFactory.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPTypeFactory.java 2006-12-21 16:07:08 UTC
(rev 5925)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPTypeFactory.java 2006-12-21 19:15:13 UTC
(rev 5926)
@@ -62,6 +62,7 @@
import org.jboss.portal.wsrp.core.PropertyList;
import org.jboss.portal.wsrp.core.RegistrationContext;
import org.jboss.portal.wsrp.core.RegistrationData;
+import org.jboss.portal.wsrp.core.ResetProperty;
import org.jboss.portal.wsrp.core.RuntimeContext;
import org.jboss.portal.wsrp.core.ServiceDescription;
import org.jboss.portal.wsrp.core.SessionContext;
@@ -837,4 +838,18 @@
{
return new PropertyList();
}
+
+ /**
+ * EMPTY, @name(xsd:string)
+ *
+ * @param name
+ * @return
+ * @since 2.6
+ */
+ public static ResetProperty createResetProperty(String name)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(name, "Property
name", "ResetProperty");
+
+ return new ResetProperty(name);
+ }
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java 2006-12-21
16:07:08 UTC (rev 5925)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java 2006-12-21
19:15:13 UTC (rev 5926)
@@ -62,8 +62,10 @@
import org.jboss.portal.wsrp.core.PropertyList;
import org.jboss.portal.wsrp.core.RegistrationContext;
import org.jboss.portal.wsrp.core.RegistrationData;
+import org.jboss.portal.wsrp.core.ResetProperty;
import org.jboss.portal.wsrp.core.RuntimeContext;
import org.jboss.portal.wsrp.core.ServiceDescription;
+import org.jboss.portal.wsrp.core.SetPortletProperties;
import org.jboss.portal.wsrp.core.WSRP_v1_Markup_PortType;
import org.jboss.portal.wsrp.core.WSRP_v1_PortletManagement_PortType;
import org.jboss.portal.wsrp.core.WSRP_v1_Registration_PortType;
@@ -318,9 +320,48 @@
return getProperties(portletContext, (String[])null);
}
- public PortletContext setProperties(PortletContext portletContext, PropertyChange[]
changes) throws IllegalArgumentException, PortletInvokerException,
UnsupportedOperationException
+ public PortletContext setProperties(PortletContext portletContext, PropertyChange[]
changes) throws IllegalArgumentException,
+ PortletInvokerException, UnsupportedOperationException
{
- throw new UnsupportedOperationException("setProperties currently
unsupported.");
+ ParameterValidation.throwIllegalArgExceptionIfNull(portletContext,
"PortletContext");
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(changes, "Property
changes");
+
+ registerIfNeeded();
+
+ PropertyList propertyList = WSRPTypeFactory.createPropertyList();
+ int changesNumber = changes.length;
+ List updates = new ArrayList(changesNumber);
+ List resets = new ArrayList(changesNumber);
+ for (int i = 0; i < changesNumber; i++)
+ {
+ PropertyChange change = changes[i];
+ switch (change.getType())
+ {
+ case PropertyChange.PREF_RESET:
+ resets.add(WSRPTypeFactory.createResetProperty(change.getKey()));
+ break;
+
+ case PropertyChange.PREF_UPDATE:
+ updates.add(WSRPTypeFactory.createProperty(change.getKey(), null,
change.getValue().asString())); // todo: deal with language
+ break;
+
+ default:
+ throw new IllegalArgumentException("Unexpected property change type:
" + change.getType());
+ }
+ }
+ propertyList.setProperties((Property[])updates.toArray(new Property[0]));
+ propertyList.setResetProperties((ResetProperty[])resets.toArray(new
ResetProperty[0]));
+ SetPortletProperties setPortletProperties =
+
WSRPTypeFactory.createSetPortletProperties(WSRPUtils.convertToWSRPPortletContext(portletContext),
propertyList);
+
+ try
+ {
+ return
WSRPUtils.convertToPortalPortletContext(getPortletManagementService().setPortletProperties(setPortletProperties));
+ }
+ catch (Exception e)
+ {
+ throw new PortletInvokerException("Unable to set properties for portlet
'" + portletContext.getId() + "'", e);
+ }
}
// Accessors
********************************************************************************************************
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java 2006-12-21
16:07:08 UTC (rev 5925)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java 2006-12-21
19:15:13 UTC (rev 5926)
@@ -77,7 +77,6 @@
import org.jboss.portal.wsrp.core.PortletContext;
import org.jboss.portal.wsrp.core.PortletDescription;
import org.jboss.portal.wsrp.core.PortletStateChangeRequiredFault;
-import org.jboss.portal.wsrp.core.RegistrationContext;
import org.jboss.portal.wsrp.core.ReleaseSessions;
import org.jboss.portal.wsrp.core.ReturnAny;
import org.jboss.portal.wsrp.core.RuntimeContext;
@@ -142,6 +141,8 @@
final RuntimeContext runtimeContext = getMarkup.getRuntimeContext();
WSRPUtils.throwMissingParametersFaultIfValueIsMissing(runtimeContext,
"RuntimeContext", GET_MARKUP);
+ checkForSessionIDs(runtimeContext);
+
// get markup parameters
final MarkupParams params = getMarkup.getMarkupParams();
WSRPUtils.throwMissingParametersFaultIfValueIsMissing(params,
"MarkupParams", GET_MARKUP);
@@ -251,6 +252,20 @@
return new MarkupResponse(markupContext, null, null);
}
+ private void checkForSessionIDs(RuntimeContext runtimeContext) throws
OperationFailedFault
+ {
+ if (runtimeContext.getSessionID() != null)
+ {
+ throwOperationFaultOnSessionOperation();
+ }
+ }
+
+ private void throwOperationFaultOnSessionOperation() throws OperationFailedFault
+ {
+ throw WSRPUtils.createOperationFailedFault(new IllegalArgumentException("JBoss
Portal's Producer manages " +
+ "sessions completely on the server side, passing or trying to release
sessionIDs is therefore an error."));
+ }
+
public BlockingInteractionResponse
performBlockingInteraction(PerformBlockingInteraction performBlockingInteraction)
throws InvalidSessionFault, UnsupportedModeFault, UnsupportedMimeTypeFault,
OperationFailedFault,
UnsupportedWindowStateFault, UnsupportedLocaleFault, AccessDeniedFault,
PortletStateChangeRequiredFault,
@@ -457,53 +472,10 @@
public ReturnAny releaseSessions(ReleaseSessions releaseSessions)
throws InvalidRegistrationFault, OperationFailedFault, MissingParametersFault,
AccessDeniedFault, RemoteException
{
- WSRPUtils.throwOperationFailedFaultIfValueIsMissing(releaseSessions,
"ReleaseSessions");
-
- RegistrationContext rc = releaseSessions.getRegistrationContext();
- producer.checkRegistration(rc);
-
- String regHandle;
- if (rc == null)
- {
- regHandle = null;
- }
- else
- {
- regHandle = rc.getRegistrationHandle();
- }
-
- String[] sessionIDs = releaseSessions.getSessionIDs();
- WSRPUtils.throwMissingParametersFaultIfValueIsMissing(sessionIDs, "session
IDs", "ReleaseSessions");
-
- for (int i = 0; i < sessionIDs.length; i++)
- {
- String sessionID = sessionIDs[i];
- try
- {
- releaseSession(regHandle, sessionID);
- }
- catch (IllegalStateException e)
- {
- log.warn("session with id: " + sessionID + " had already been
released.", e);
- }
- }
-
- return new ReturnAny();
+ throwOperationFaultOnSessionOperation();
+ return null;
}
- /**
- * Releases the resources associated to the specified session for the specified
consumer.
- *
- * @param registrationHandle the registration handle identifying the consumer
- * @param sessionID the id of the session which resources are to be released
- * @throws IllegalStateException if the specified session had already been released
- */
- private void releaseSession(String registrationHandle, String sessionID) throws
IllegalStateException, OperationFailedFault
- {
- //fix-me: do we need to pass registration handle?
- producer.releaseSession(sessionID);
- }
-
public ReturnAny initCookie(InitCookie initCookie)
throws AccessDeniedFault, OperationFailedFault, InvalidRegistrationFault,
RemoteException
{
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java 2006-12-21
16:07:08 UTC (rev 5925)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java 2006-12-21
19:15:13 UTC (rev 5926)
@@ -77,14 +77,10 @@
import org.jboss.portal.wsrp.producer.config.ProducerConfiguration;
import org.jboss.portal.wsrp.producer.config.ProducerRegistrationRequirements;
import org.jboss.portal.wsrp.producer.config.impl.ProducerRegistrationRequirementsImpl;
-import org.jboss.portal.wsrp.servlet.ServletAccess;
-import javax.servlet.http.HttpSession;
import java.rmi.RemoteException;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
-import java.util.Map;
import java.util.Set;
/**
@@ -128,16 +124,12 @@
/** Supported locales. */
private String[] supportedLocales = new String[]{"en", "en-US"};
- /** Manages the sessions. */
- private SessionManager sessionManager;
-
public WSRPProducerImpl()
{
markupHandler = new MarkupHandler(this);
serviceDescriptionHandler = new ServiceDescriptionHandler(this);
registrationHandler = new RegistrationHandler(this);
portletManagementHandler = new PortletManagementHandler(this);
- sessionManager = new SessionManager();
}
public ProducerRegistrationRequirements getProducerRegistrationRequirements()
@@ -368,26 +360,6 @@
this.sessionExpirationTime = sessionExpirationTime;
}
- public boolean isSessionValid(String sessionId)
- {
- return sessionManager.isSessionValid(sessionId);
- }
-
- public void addSession(HttpSession session)
- {
- sessionManager.addSession(session);
- }
-
- HttpSession getSession()
- {
- return ServletAccess.getRequest().getSession(false);
- }
-
- public void releaseSession(String sessionID) throws IllegalStateException,
OperationFailedFault
- {
- sessionManager.invalidateSession(sessionID);
- }
-
public PortletInvoker getInvoker()
{
return invoker;
@@ -503,78 +475,4 @@
return supportedLocales; // todo: avoid hardcoding this at some point...
}
- private class SessionManager
- {
- private Map sessions = new HashMap();
-
- void addSession(HttpSession session)
- {
- if (session != null)
- {
- log.debug("Storing session in SessionManager instance: " +
session.getId());
-
session.setMaxInactiveInterval(WSRPProducerImpl.this.getSessionExpirationTime());
- sessions.put(session.getId(), session);
- }
- }
-
- boolean isSessionValid(String sessionId)
- {
- log.debug("Getting HttpSession using provided Id: " + sessionId);
- HttpSession session = getSession(sessionId);
- if (session != null)
- {
- log.debug("Got the session");
- if (hasSessionExpired(session))
- {
- sessions.remove(session.getId());
- return false;
- }
-
- return true;
- }
- return false;
- }
-
- HttpSession getSession(String sessionId)
- {
- if (sessionId == null)
- {
- return null;
- }
-
- return (HttpSession)sessions.get(sessionId);
- }
-
- void invalidateSession(String sessionId) throws IllegalStateException,
OperationFailedFault
- {
- HttpSession session = getSession(sessionId);
- if (session != null)
- {
- sessions.remove(sessionId);
- if (!hasSessionExpired(session))
- {
- session.invalidate();
- }
- }
- else
- {
- //the sessionID does not exist for any session
- throw WSRPUtils.createOperationFailedFault(new
IllegalArgumentException("'" + sessionId + "' is not a valid
session id!"));
- }
- }
-
- private boolean hasSessionExpired(HttpSession session)
- {
- try
- {
- // try to access info on the session if this throws an exception it means the
session had expired
- session.getLastAccessedTime();
- }
- catch (Exception e)
- {
- return true;
- }
- return false;
- }
- }
}
Modified:
trunk/wsrp/src/resources/tests/test-wsrp-producer-markup-sar/META-INF/jboss-service.xml
===================================================================
---
trunk/wsrp/src/resources/tests/test-wsrp-producer-markup-sar/META-INF/jboss-service.xml 2006-12-21
16:07:08 UTC (rev 5925)
+++
trunk/wsrp/src/resources/tests/test-wsrp-producer-markup-sar/META-INF/jboss-service.xml 2006-12-21
19:15:13 UTC (rev 5926)
@@ -34,7 +34,7 @@
proxy-type="attribute">portal.wsrp:service=CachingServiceFactory</depends>
<depends optional-attribute-name="Producer"
proxy-type="attribute">portal.wsrp:service=WSRPProducer</depends>
</mbean>
- <!--<mbean
+ <mbean
code="org.jboss.portal.test.wsrp.v1.producer.ReleaseSessionTestCase"
name="portal.test:test=ReleaseSession"
xmbean-dd=""
@@ -44,5 +44,5 @@
<depends optional-attribute-name="ServiceFactory"
proxy-type="attribute">portal.wsrp:service=CachingServiceFactory</depends>
<depends optional-attribute-name="Producer"
proxy-type="attribute">portal.wsrp:service=WSRPProducer</depends>
- </mbean>-->
+ </mbean>
</server>