[portal-commits] JBoss Portal SVN: r5990 - in trunk/wsrp: src/main/org/jboss/portal/test/wsrp/portlet and 5 other directories.

portal-commits at lists.jboss.org portal-commits at lists.jboss.org
Thu Jan 11 00:54:01 EST 2007


Author: chris.laprun at jboss.com
Date: 2007-01-11 00:53:57 -0500 (Thu, 11 Jan 2007)
New Revision: 5990

Added:
   trunk/wsrp/src/main/org/jboss/portal/test/wsrp/portlet/ImplicitCloningPortlet.java
   trunk/wsrp/src/resources/tests/test-implicitcloning-portlet-war/
   trunk/wsrp/src/resources/tests/test-implicitcloning-portlet-war/WEB-INF/
   trunk/wsrp/src/resources/tests/test-implicitcloning-portlet-war/WEB-INF/portlet.xml
   trunk/wsrp/src/resources/tests/test-implicitcloning-portlet-war/WEB-INF/web.xml
Modified:
   trunk/wsrp/build.xml
   trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/MarkupTestCase.java
   trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ActionRequestProcessor.java
   trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RenderRequestProcessor.java
   trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RequestProcessor.java
   trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java
   trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPInstanceContext.java
   trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java
Log:
- Implicit cloning should now work on the producer.
- More fixes to use portlet context where appropriate instead of handle.

Modified: trunk/wsrp/build.xml
===================================================================
--- trunk/wsrp/build.xml	2007-01-11 00:47:25 UTC (rev 5989)
+++ trunk/wsrp/build.xml	2007-01-11 05:53:57 UTC (rev 5990)
@@ -522,6 +522,9 @@
 
       <!-- MultiValuedContext test portlet -->
       <package-test-portlet archiveName="multivalued" portletName="MultiValued"/>
+
+      <!-- ImplicitCloning test portlet -->
+      <package-test-portlet archiveName="implicitcloning" portletName="ImplicitCloning"/>
    </target>
 
    <!-- Packages all the test related artifacts. Note that compilation should have been already executed -->

Added: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/portlet/ImplicitCloningPortlet.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/portlet/ImplicitCloningPortlet.java	2007-01-11 00:47:25 UTC (rev 5989)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/portlet/ImplicitCloningPortlet.java	2007-01-11 05:53:57 UTC (rev 5990)
@@ -0,0 +1,65 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat                                               *
+ * Copyright 2007, 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                *
+ * published by the Free Software Foundation; either version 2.1 of           *
+ * the License, or (at your option) any later version.                        *
+ *                                                                            *
+ * This software is distributed in the hope that it will be useful,           *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
+ * Lesser General Public License for more details.                            *
+ *                                                                            *
+ * You should have received a copy of the GNU Lesser General Public           *
+ * License along with this software; if not, write to the Free                *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
+ ******************************************************************************/
+
+package org.jboss.portal.test.wsrp.portlet;
+
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.GenericPortlet;
+import javax.portlet.PortletException;
+import javax.portlet.PortletPreferences;
+import javax.portlet.PortletSecurityException;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class ImplicitCloningPortlet extends GenericPortlet
+{
+
+   public void processAction(ActionRequest request, ActionResponse response) throws PortletException, PortletSecurityException, IOException
+   {
+      String value = request.getParameter("value");
+      if (value == null)
+      {
+         value = "default";
+      }
+
+      PortletPreferences pp = request.getPreferences();
+      pp.setValue("name", value);
+      pp.store();
+   }
+
+
+   protected void doView(RenderRequest request, RenderResponse response) throws PortletException, PortletSecurityException, IOException
+   {
+      response.setContentType("text/html");
+      PortletPreferences pp = request.getPreferences();
+      String value = pp.getValue("name", "default");
+      response.getWriter().write(value);
+   }
+}


Property changes on: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/portlet/ImplicitCloningPortlet.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

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	2007-01-11 00:47:25 UTC (rev 5989)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/MarkupTestCase.java	2007-01-11 05:53:57 UTC (rev 5990)
@@ -39,8 +39,10 @@
 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.PortletContext;
 import org.jboss.portal.wsrp.core.RuntimeContext;
 import org.jboss.portal.wsrp.core.SessionContext;
+import org.jboss.portal.wsrp.core.StateChange;
 import org.jboss.portal.wsrp.core.UnsupportedModeFault;
 import org.jboss.portal.wsrp.core.UpdateResponse;
 
@@ -86,14 +88,9 @@
       }
    }
 
-   /**
-    * 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
    {
+      // The consumer should never have access to or be able to set a sessionID. Sessions are handled by the Producer using cookies.
       GetMarkup getMarkup = createMarkupRequest();
       getMarkup.getRuntimeContext().setSessionID("Hello World");
 
@@ -114,12 +111,12 @@
       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&amp;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&amp;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&amp;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>");
    }
@@ -193,17 +190,16 @@
       checkMarkupResponseWithSession(response, 1);
 
       // fix-me: try to reuse the old session id: what should happen?
-      /*runtimeContext.setSessionID(sessionID);
-      getMarkup.setRuntimeContext(runtimeContext);
-      try
-      {
-         markupService.getMarkup(getMarkup);
-         fail("The session should be invalid...");
-      }
-      catch (InvalidSessionFault fault)
-      {
-         // expected
-      }*/
+//      runtimeContext.setSessionID(sessionID);
+//      getMarkup.setRuntimeContext(runtimeContext);
+//      try
+//      {
+//         markupService.getMarkup(getMarkup);
+//         fail("The session should be invalid...");
+//      }
+//      catch (InvalidSessionFault expected)
+//      {
+//      }
 
       // reset state
       undeploy(sessionPortletArchive);
@@ -247,12 +243,7 @@
       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();
@@ -267,9 +258,8 @@
          markupService.performBlockingInteraction(performBlockingInteraction);
          ExtendedAssert.fail("Should not be able to pass a sessionID in a PerformBlockingInteraction()");
       }
-      catch (OperationFailedFault operationFailedFault)
+      catch (OperationFailedFault expected)
       {
-         // expected failure
       }
    }
 
@@ -296,50 +286,6 @@
       undeploy(sessionPortletArchive);
    }
 
-   /*public void testReleaseSessions() throws Exception
-   {
-      undeploy(DEFAULT_MARKUP_PORTLET_WAR);
-      String sessionPortletArchive = "test-session-portlet.war";
-      deploy(sessionPortletArchive);
-
-      initRegistrationInfo();
-      RegistrationContext rc = registerConsumer();
-
-      GetMarkup gm = createMarkupRequest(sessionPortletArchive);
-      gm.setRegistrationContext(rc);
-      MarkupResponse res = markupService.getMarkup(gm);
-
-      ReleaseSessions releaseSessions = new ReleaseSessions(rc, null);
-
-      try
-      {
-         markupService.releaseSessions(releaseSessions);
-         fail("No session IDs provided when some were expected.");
-      }
-      catch (MissingParametersFault missingParametersFault)
-      {
-         //expected
-      }
-
-      String sessionID = res.getSessionContext().getSessionID();
-      releaseSessions.setSessionIDs(new String[]{sessionID});
-      markupService.releaseSessions(releaseSessions);
-
-      gm.getRuntimeContext().setSessionID(sessionID);
-      try
-      {
-         markupService.getMarkup(gm);
-         fail("Should have failed: try to get markup using a released session id.");
-      }
-      catch (InvalidSessionFault invalidSessionFault)
-      {
-         // expected
-      }
-
-      undeploy(sessionPortletArchive);
-      resetRegistrationInfo();
-   }*/
-
    public void testGetMarkupWithDispatcherPortlet() throws Exception
    {
 
@@ -385,9 +331,8 @@
          //fail("Should have trown an UnsupportetLocaleFault"); // ideally cf http://jira.jboss.com/jira/browse/JBPORTAL-857
          ExtendedAssert.fail("Should have trown an exception"); // right now
       }
-      catch (Exception e)
+      catch (Exception expected)
       {
-         // expected
       }
       // checkMarkupResponse(response, "GetLocalesPortlet"); // should we return try to generate markup regardless?
 
@@ -457,6 +402,44 @@
       undeploy(multiValuedPortletArchive);
    }
 
+   public void testImplicitCloning() throws Exception
+   {
+      undeploy(DEFAULT_MARKUP_PORTLET_WAR);
+      String archiveName = "test-implicitcloning-portlet.war";
+      deploy(archiveName);
+
+      // check the initial value
+      GetMarkup gm = createMarkupRequestForCurrentlyDeployedPortlet();
+      MarkupResponse res = markupService.getMarkup(gm);
+      String markupString = res.getMarkupContext().getMarkupString();
+      ExtendedAssert.assertEquals("initial", markupString);
+
+      // modify the preference value
+      PerformBlockingInteraction pbi = WSRPTypeFactory.createDefaultPerformBlockingInteraction(getHandleForCurrentlyDeployedArchive());
+      pbi.getInteractionParams().setPortletStateChange(StateChange.cloneBeforeWrite); // request cloning if needed
+      String value = "new value";
+      pbi.getInteractionParams().setFormParameters(new NamedString[]{new NamedString("value", value)});
+      BlockingInteractionResponse response = markupService.performBlockingInteraction(pbi);
+      ExtendedAssert.assertNotNull(response);
+
+      // check that we got a new portlet context
+      PortletContext pc = response.getUpdateResponse().getPortletContext();
+      ExtendedAssert.assertNotNull(pc);
+
+      // get the markup again and check that we still get the initial value with the initial portlet context
+      res = markupService.getMarkup(gm);
+      markupString = res.getMarkupContext().getMarkupString();
+      ExtendedAssert.assertEquals("initial", markupString);
+
+      // retrieving the markup with the new portlet context should return the new value
+      gm.setPortletContext(pc);
+      res = markupService.getMarkup(gm);
+      markupString = res.getMarkupContext().getMarkupString();
+      ExtendedAssert.assertEquals(value, markupString);
+
+      undeploy(archiveName);
+   }
+
    private String checkPBIAndGetNavigationalState(String symbol) throws Exception
    {
       PerformBlockingInteraction performBlockingInteraction =

Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ActionRequestProcessor.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ActionRequestProcessor.java	2007-01-11 00:47:25 UTC (rev 5989)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ActionRequestProcessor.java	2007-01-11 05:53:57 UTC (rev 5990)
@@ -119,8 +119,8 @@
    void initInvocation(StateString navigationalState, SecurityContext securityContext,
                        HTTPStreamInfo streamInfo, PortalContext portalContext,
                        UserContext userContext,
-                       WindowContext windowContext
-   )
+                       WindowContext windowContext,
+                       org.jboss.portal.portlet.PortletContext portletContext)
    {
       PortletParameters parameters;
       NamedString[] formParams = interactionParams.getFormParameters();
@@ -164,7 +164,7 @@
          markupRequest.getCharacterSet(), markupRequest.getMimeType());
       setInvocation(new ActionInvocation(actionContext));
       actionContext.contextualize(invocation);
-      invocation.setAttribute(PortletInvocation.REQUEST_SCOPE, PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE, portlet.getContext());
+      invocation.setAttribute(PortletInvocation.REQUEST_SCOPE, PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE, portletContext);
    }
 
    Object processResponse(PortletInvocationResponse response)

Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RenderRequestProcessor.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RenderRequestProcessor.java	2007-01-11 00:47:25 UTC (rev 5989)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RenderRequestProcessor.java	2007-01-11 05:53:57 UTC (rev 5990)
@@ -111,8 +111,8 @@
    void initInvocation(StateString navigationalState, SecurityContext securityContext,
                        HTTPStreamInfo streamInfo, PortalContext portalContext,
                        UserContext userContext,
-                       WindowContext windowContext
-   )
+                       WindowContext windowContext,
+                       org.jboss.portal.portlet.PortletContext portletContext)
    {
       WSRPRenderContext renderContext = new WSRPRenderContext(navigationalState, securityContext, streamInfo,
          portalContext, userContext, instanceContext, windowContext,
@@ -121,7 +121,7 @@
       setInvocation(new RenderInvocation(renderContext));
       renderContext.contextualize(invocation);
 
-      invocation.setAttribute(PortletInvocation.REQUEST_SCOPE, PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE, portlet.getContext());
+      invocation.setAttribute(PortletInvocation.REQUEST_SCOPE, PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE, portletContext);
    }
 
    Object processResponse(PortletInvocationResponse response)

Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RequestProcessor.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RequestProcessor.java	2007-01-11 00:47:25 UTC (rev 5989)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RequestProcessor.java	2007-01-11 05:53:57 UTC (rev 5990)
@@ -102,14 +102,12 @@
       // get portlet handle
       PortletContext wsrpPC = getPortletContext();
       WSRPUtils.throwMissingParametersFaultIfValueIsMissing(wsrpPC, "PortletContext", getContextName());
-      final String portletHandle = wsrpPC.getPortletHandle();
-      WSRPUtils.throwMissingParametersFaultIfValueIsMissing(portletHandle, "portlet handle", "PortletContext");
-      org.jboss.portal.portlet.PortletContext originalPortletContext = WSRPUtils.convertToPortalPortletContext(wsrpPC);
+      org.jboss.portal.portlet.PortletContext portletContext = WSRPUtils.convertToPortalPortletContext(wsrpPC);
 
       // retrieve the portlet
       try
       {
-         portlet = producer.getPortletWith(originalPortletContext);
+         portlet = producer.getPortletWith(portletContext);
       }
       catch (PortletInvokerException e)
       {
@@ -118,7 +116,7 @@
 
       // get portlet description for the desired portlet...
       final String[] desiredLocales = params.getLocales();
-      portletDescription = producer.getPortletDescription(wsrpPC, desiredLocales);
+      portletDescription = producer.getPortletDescription(portlet, desiredLocales);
       if (Boolean.TRUE.equals(portletDescription.getUsesMethodGet()))
       {
          throw WSRPUtils.createOperationFailedFault(
@@ -139,11 +137,12 @@
       HTTPStreamInfo streamInfo = createStreamInfo(markupRequest);
       PortalContext portalContext = createPortalContext(params, markupRequest);
       UserContext userContext = createUserContext(wsrpUserContext, markupRequest.getLocale(), desiredLocales);
-      instanceContext = createInstanceContext(portletHandle, getAccessMode());
-      WindowContext windowContext = createWindowContext(portletHandle, runtimeContext);
+      instanceContext = createInstanceContext(portletContext, getAccessMode());
+      WindowContext windowContext = createWindowContext(portletContext.getId(), runtimeContext);
 
       // prepare the invocation
-      initInvocation(navigationalState, securityContext, streamInfo, portalContext, userContext, windowContext);
+      // TODO: must pass the portlet context since the retrieved portlet points to the POP, not clones: is it expected?
+      initInvocation(navigationalState, securityContext, streamInfo, portalContext, userContext, windowContext, portletContext);
    }
 
    abstract RegistrationContext getRegistrationContext();
@@ -162,7 +161,7 @@
 
    abstract void initInvocation(StateString navigationalState, SecurityContext securityContext,
                                 HTTPStreamInfo streamInfo, PortalContext portalContext, UserContext userContext,
-                                WindowContext windowContext);
+                                WindowContext windowContext, org.jboss.portal.portlet.PortletContext portletContext);
 
    abstract Object processResponse(PortletInvocationResponse response);
 
@@ -310,9 +309,9 @@
       }
    }
 
-   private WSRPInstanceContext createInstanceContext(final String portletHandle, final AccessMode accessMode)
+   private WSRPInstanceContext createInstanceContext(org.jboss.portal.portlet.PortletContext portletContext, final AccessMode accessMode)
    {
-      return new WSRPInstanceContext(portletHandle, accessMode);
+      return new WSRPInstanceContext(portletContext, accessMode);
    }
 
    private WindowContext createWindowContext(final String portletHandle, final RuntimeContext runtimeContext)

Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java	2007-01-11 00:47:25 UTC (rev 5989)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java	2007-01-11 05:53:57 UTC (rev 5990)
@@ -104,7 +104,7 @@
       for (Iterator iterator = portlets.iterator(); iterator.hasNext();)
       {
          Portlet portlet = (Portlet)iterator.next();
-         PortletDescription desc = createPortletDescriptionFrom(portlet.getInfo(), desiredLocales, portlet.getContext().getId());
+         PortletDescription desc = getPortletDescription(portlet, desiredLocales);
          offeredPortletDescriptions.add(desc);
       }
 
@@ -123,7 +123,7 @@
       {
          throw WSRPUtils.createOperationFailedFault(e);
       }
-      return createPortletDescriptionFrom(portlet.getInfo(), desiredLocales, portlet.getContext().getId());
+      return getPortletDescription(portlet, desiredLocales);
    }
 
    /**
@@ -185,16 +185,17 @@
     * Creates a PortletDescription based on the user desired locales (ordered according to user preferences) for the
     * specified component.
     *
-    * @param portletInfo
+    * @param portlet
     * @param desiredLocales the user desired locales (ordered according to user preferences) to use for the description
-    * @param id
     * @return a PortletDescription describing the specified portlet
     */
-   private PortletDescription createPortletDescriptionFrom(PortletInfo portletInfo, String[] desiredLocales, String id)
+   PortletDescription getPortletDescription(Portlet portlet, String[] desiredLocales)
    {
+      String id = portlet.getContext().getId();
+      PortletInfo info = portlet.getInfo();
       log.debug("Constructing portlet description for: " + id);
 
-      CapabilitiesInfo capInfo = portletInfo.getCapabilities();
+      CapabilitiesInfo capInfo = info.getCapabilities();
       Collection allMimeTypes = capInfo.getMimeTypes();
       MarkupType[] markupTypes = new MarkupType[allMimeTypes.size()];
       Iterator mimeTypes = allMimeTypes.iterator();
@@ -214,7 +215,7 @@
 
       // todo: group ID
 
-      MetaInfo metaInfo = portletInfo.getMeta();
+      MetaInfo metaInfo = info.getMeta();
 
       // description
       desc.setDescription(WSRPUtils.convertToWSRPLocalizedString(metaInfo.getMetaValue(MetaInfo.DESCRIPTION), desiredLocales));

Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPInstanceContext.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPInstanceContext.java	2007-01-11 00:47:25 UTC (rev 5989)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPInstanceContext.java	2007-01-11 05:53:57 UTC (rev 5990)
@@ -24,6 +24,7 @@
 package org.jboss.portal.wsrp.producer;
 
 import org.jboss.portal.common.util.ParameterValidation;
+import org.jboss.portal.portlet.PortletContext;
 import org.jboss.portal.portlet.StateEvent;
 import org.jboss.portal.portlet.spi.InstanceContext;
 import org.jboss.portal.portlet.state.AccessMode;
@@ -35,23 +36,22 @@
  */
 class WSRPInstanceContext implements InstanceContext
 {
-   private String id;
-   private byte[] state;
+   private PortletContext context;
    private final AccessMode accessMode;
    private boolean wasModified = false;
 
-   public WSRPInstanceContext(String portletHandle, AccessMode accessMode)
+   public WSRPInstanceContext(PortletContext portletContext, AccessMode accessMode)
    {
-      ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(portletHandle, "portlet handle", "InstanceContext");
+      ParameterValidation.throwIllegalArgExceptionIfNull(portletContext, "portlet context");
       ParameterValidation.throwIllegalArgExceptionIfNull(accessMode, "AccessMode");
 
-      this.id = portletHandle;
+      this.context = portletContext;
       this.accessMode = accessMode;
    }
 
    public String getId()
    {
-      return id;
+      return context.getId();
    }
 
    public AccessMode getAccessMode()
@@ -61,11 +61,10 @@
 
    public void onStateEvent(StateEvent event)
    {
-      org.jboss.portal.portlet.PortletContext portletContext = event.getPortletContext();
+      PortletContext portletContext = event.getPortletContext();
       ParameterValidation.throwIllegalArgExceptionIfNull(portletContext, "PortletContext");
       wasModified = true;
-      id = portletContext.getId();
-      state = portletContext.getState();
+      context = portletContext;
    }
 
    public boolean wasModified()
@@ -75,6 +74,6 @@
 
    public byte[] getState()
    {
-      return state;
+      return context.getState();
    }
 }

Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java	2007-01-11 00:47:25 UTC (rev 5989)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java	2007-01-11 05:53:57 UTC (rev 5990)
@@ -414,6 +414,11 @@
       return serviceDescriptionHandler.getPortletDescription(portletContext, locales);
    }
 
+   public PortletDescription getPortletDescription(Portlet portlet, String[] locales)
+   {
+      return serviceDescriptionHandler.getPortletDescription(portlet, locales);
+   }
+
    /**
     * Checks that the specified registration information is valid if this Producer requires registration.
     *

Added: trunk/wsrp/src/resources/tests/test-implicitcloning-portlet-war/WEB-INF/portlet.xml
===================================================================
--- trunk/wsrp/src/resources/tests/test-implicitcloning-portlet-war/WEB-INF/portlet.xml	2007-01-11 00:47:25 UTC (rev 5989)
+++ trunk/wsrp/src/resources/tests/test-implicitcloning-portlet-war/WEB-INF/portlet.xml	2007-01-11 05:53:57 UTC (rev 5990)
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  ~ JBoss, a division of Red Hat                                              ~
+  ~ Copyright 2007, 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               ~
+  ~ published by the Free Software Foundation; either version 2.1 of          ~
+  ~ the License, or (at your option) any later version.                       ~
+  ~                                                                           ~
+  ~ This software is distributed in the hope that it will be useful,          ~
+  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of            ~
+  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU          ~
+  ~ Lesser General Public License for more details.                           ~
+  ~                                                                           ~
+  ~ You should have received a copy of the GNU Lesser General Public          ~
+  ~ License along with this software; if not, write to the Free               ~
+  ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA        ~
+  ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.                  ~
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
+             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+             xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd" version="1.0">
+   <portlet>
+      <portlet-name>Implicit Cloning Test Portlet</portlet-name>
+      <portlet-class>org.jboss.portal.test.wsrp.portlet.ImplicitCloningPortlet</portlet-class>
+
+      <supports>
+         <mime-type>text/html</mime-type>
+         <portlet-mode>view</portlet-mode>
+      </supports>
+
+      <portlet-info>
+         <title>title</title>
+      </portlet-info>
+
+      <portlet-preferences>
+         <preference>
+            <name>name</name>
+            <value>initial</value>
+         </preference>
+      </portlet-preferences>
+   </portlet>
+
+</portlet-app>
\ No newline at end of file

Added: trunk/wsrp/src/resources/tests/test-implicitcloning-portlet-war/WEB-INF/web.xml
===================================================================
--- trunk/wsrp/src/resources/tests/test-implicitcloning-portlet-war/WEB-INF/web.xml	2007-01-11 00:47:25 UTC (rev 5989)
+++ trunk/wsrp/src/resources/tests/test-implicitcloning-portlet-war/WEB-INF/web.xml	2007-01-11 05:53:57 UTC (rev 5990)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  ~ JBoss, a division of Red Hat                                              ~
+  ~ Copyright 2007, 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               ~
+  ~ published by the Free Software Foundation; either version 2.1 of          ~
+  ~ the License, or (at your option) any later version.                       ~
+  ~                                                                           ~
+  ~ This software is distributed in the hope that it will be useful,          ~
+  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of            ~
+  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU          ~
+  ~ Lesser General Public License for more details.                           ~
+  ~                                                                           ~
+  ~ You should have received a copy of the GNU Lesser General Public          ~
+  ~ License along with this software; if not, write to the Free               ~
+  ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA        ~
+  ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.                  ~
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<web-app version="2.4"
+         xmlns="http://java.sun.com/xml/ns/j2ee"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
+</web-app>
\ No newline at end of file




More information about the portal-commits mailing list