[gatein-commits] gatein SVN: r8147 - in components/wsrp/trunk: consumer/src/test/java/org/gatein/wsrp/consumer and 2 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Fri Nov 25 11:29:52 EST 2011


Author: chris.laprun at jboss.com
Date: 2011-11-25 11:29:52 -0500 (Fri, 25 Nov 2011)
New Revision: 8147

Added:
   components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v2/behaviors/SupportedOptionsServiceDescriptionBehavior.java
Modified:
   components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/ProducerInfo.java
   components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/consumer/ProducerInfoTestCase.java
   components/wsrp/trunk/wsrp-producer-war/src/main/java/org/gatein/wsrp/endpoints/v2/ServiceDescriptionEndpoint.java
Log:
- GTNWSRP-262: several pieces of information (in particular, supportedOptions) from the service description weren't properly transmitted by the producer, nor properly handled on the consumer. :(

Modified: components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/ProducerInfo.java
===================================================================
--- components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/ProducerInfo.java	2011-11-25 15:23:47 UTC (rev 8146)
+++ components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/ProducerInfo.java	2011-11-25 16:29:52 UTC (rev 8147)
@@ -882,6 +882,8 @@
          Holder<List<String>> supportedOptions = new Holder<List<String>>();
          Holder<ExportDescription> exportDescription = new Holder<ExportDescription>();
          Holder<Boolean> mayReturnRegistrationState = new Holder<Boolean>();
+         final Holder<List<ExtensionDescription>> extensionDescriptions = new Holder<List<ExtensionDescription>>();
+         final Holder<List<Extension>> extensions = new Holder<List<Extension>>();
 
          // invocation
          persistentEndpointInfo.getServiceDescriptionService().getServiceDescription(
@@ -892,7 +894,7 @@
             requiresRegistration,
             offeredPortlets,
             userCategoryDescriptions,
-            new Holder<List<ExtensionDescription>>(),
+            extensionDescriptions,
             windowStateDescriptions,
             modeDescriptions,
             requiresInitCookie,
@@ -904,13 +906,17 @@
             supportedOptions,
             exportDescription,
             mayReturnRegistrationState,
-            new Holder<List<Extension>>());
+            extensions);
 
          // TODO: fix-me
          serviceDescription = WSRPTypeFactory.createServiceDescription(requiresRegistration.value);
          serviceDescription.setRegistrationPropertyDescription(registrationPropertyDescription.value);
          serviceDescription.setRequiresInitCookie(requiresInitCookie.value);
          serviceDescription.setResourceList(resourceList.value);
+         serviceDescription.setSchemaType(schemaTypes.value);
+         serviceDescription.setExportDescription(exportDescription.value);
+         serviceDescription.setMayReturnRegistrationState(mayReturnRegistrationState.value);
+
          if (ParameterValidation.existsAndIsNotEmpty(modeDescriptions.value))
          {
             serviceDescription.getCustomModeDescriptions().addAll(modeDescriptions.value);
@@ -931,6 +937,22 @@
          {
             serviceDescription.getUserCategoryDescriptions().addAll(userCategoryDescriptions.value);
          }
+         if (ParameterValidation.existsAndIsNotEmpty(eventDescriptions.value))
+         {
+            serviceDescription.getEventDescriptions().addAll(eventDescriptions.value);
+         }
+         if (ParameterValidation.existsAndIsNotEmpty(extensionDescriptions.value))
+         {
+            serviceDescription.getExtensionDescriptions().addAll(extensionDescriptions.value);
+         }
+         if (ParameterValidation.existsAndIsNotEmpty(extensions.value))
+         {
+            serviceDescription.getExtensions().addAll(extensions.value);
+         }
+         if (ParameterValidation.existsAndIsNotEmpty(supportedOptions.value))
+         {
+            serviceDescription.getSupportedOptions().addAll(supportedOptions.value);
+         }
 
          return serviceDescription;
       }

Modified: components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/consumer/ProducerInfoTestCase.java
===================================================================
--- components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/consumer/ProducerInfoTestCase.java	2011-11-25 15:23:47 UTC (rev 8146)
+++ components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/consumer/ProducerInfoTestCase.java	2011-11-25 16:29:52 UTC (rev 8147)
@@ -26,12 +26,14 @@
 import junit.framework.TestCase;
 import org.gatein.pc.api.Portlet;
 import org.gatein.pc.api.PortletInvokerException;
+import org.gatein.wsrp.spec.v2.WSRP2Constants;
 import org.gatein.wsrp.spec.v2.WSRP2ExceptionFactory;
 import org.gatein.wsrp.test.protocol.v2.BehaviorBackedServiceFactory;
 import org.gatein.wsrp.test.protocol.v2.PortletManagementBehavior;
 import org.gatein.wsrp.test.protocol.v2.RegistrationBehavior;
 import org.gatein.wsrp.test.protocol.v2.ServiceDescriptionBehavior;
 import org.gatein.wsrp.test.protocol.v2.behaviors.GroupedPortletsServiceDescriptionBehavior;
+import org.gatein.wsrp.test.protocol.v2.behaviors.SupportedOptionsServiceDescriptionBehavior;
 import org.gatein.wsrp.test.support.MockConsumerRegistry;
 import org.oasis.wsrp.v2.AccessDenied;
 import org.oasis.wsrp.v2.CookieProtocol;
@@ -58,6 +60,7 @@
 import javax.xml.namespace.QName;
 import javax.xml.ws.Holder;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.List;
 
 /**
@@ -465,6 +468,19 @@
       assertEquals(CookieProtocol.PER_GROUP, info.getRequiresInitCookie());
    }
 
+   public void testSupportedOptions() throws PortletInvokerException
+   {
+      ServiceDescriptionBehavior sdb = new SupportedOptionsServiceDescriptionBehavior();
+      serviceFactory.getRegistry().setServiceDescriptionBehavior(sdb);
+
+      info.refresh(false);
+
+      final Collection<String> supportedOptions = info.getSupportedOptions();
+      assertEquals(2, supportedOptions.size());
+      assertTrue(supportedOptions.contains(WSRP2Constants.OPTIONS_EXPORT));
+      assertTrue(supportedOptions.contains(WSRP2Constants.OPTIONS_IMPORT));
+   }
+
    private static class TestPortletManagementBehavior extends PortletManagementBehavior
    {
 

Added: components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v2/behaviors/SupportedOptionsServiceDescriptionBehavior.java
===================================================================
--- components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v2/behaviors/SupportedOptionsServiceDescriptionBehavior.java	                        (rev 0)
+++ components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v2/behaviors/SupportedOptionsServiceDescriptionBehavior.java	2011-11-25 16:29:52 UTC (rev 8147)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2011, 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.gatein.wsrp.test.protocol.v2.behaviors;
+
+import org.gatein.wsrp.spec.v2.WSRP2Constants;
+import org.gatein.wsrp.test.protocol.v2.ServiceDescriptionBehavior;
+import org.oasis.wsrp.v2.CookieProtocol;
+import org.oasis.wsrp.v2.EventDescription;
+import org.oasis.wsrp.v2.ExportDescription;
+import org.oasis.wsrp.v2.Extension;
+import org.oasis.wsrp.v2.ExtensionDescription;
+import org.oasis.wsrp.v2.InvalidRegistration;
+import org.oasis.wsrp.v2.ItemDescription;
+import org.oasis.wsrp.v2.ModelDescription;
+import org.oasis.wsrp.v2.ModelTypes;
+import org.oasis.wsrp.v2.ModifyRegistrationRequired;
+import org.oasis.wsrp.v2.OperationFailed;
+import org.oasis.wsrp.v2.PortletDescription;
+import org.oasis.wsrp.v2.RegistrationContext;
+import org.oasis.wsrp.v2.ResourceList;
+import org.oasis.wsrp.v2.ResourceSuspended;
+import org.oasis.wsrp.v2.UserContext;
+
+import javax.jws.WebParam;
+import javax.xml.ws.Holder;
+import java.util.ArrayList;
+import java.util.List;
+
+/** @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a> */
+public class SupportedOptionsServiceDescriptionBehavior extends ServiceDescriptionBehavior
+{
+   @Override
+   public void getServiceDescription(@WebParam(name = "registrationContext", targetNamespace = "urn:oasis:names:tc:wsrp:v2:types") RegistrationContext registrationContext, @WebParam(name = "desiredLocales", targetNamespace = "urn:oasis:names:tc:wsrp:v2:types") List<String> desiredLocales, @WebParam(name = "portletHandles", targetNamespace = "urn:oasis:names:tc:wsrp:v2:types") List<String> portletHandles, @WebParam(name = "userContext", targetNamespace = "urn:oasis:names:tc:wsrp:v2:types") UserContext userContext, @WebParam(name = "requiresRegistration", targetNamespace = "urn:oasis:names:tc:wsrp:v2:types", mode = WebParam.Mode.OUT) Holder<Boolean> requiresRegistration, @WebParam(name = "offeredPortlets", targetNamespace = "urn:oasis:names:tc:wsrp:v2:types", mode = WebParam.Mode.OUT) Holder<List<PortletDescription>> offeredPortlets, @WebParam(name = "userCategoryDescriptions", targetNamespace = "urn:oasis:names:tc:wsrp:v2:types", mode = WebParam.Mode.OUT) Holder<List<ItemDes!
 cription>> userCategoryDescriptions, @WebParam(name = "extensionDescriptions", targetNamespace = "urn:oasis:names:tc:wsrp:v2:types", mode = WebParam.Mode.OUT) Holder<List<ExtensionDescription>> extensionDescriptions, @WebParam(name = "customWindowStateDescriptions", targetNamespace = "urn:oasis:names:tc:wsrp:v2:types", mode = WebParam.Mode.OUT) Holder<List<ItemDescription>> customWindowStateDescriptions, @WebParam(name = "customModeDescriptions", targetNamespace = "urn:oasis:names:tc:wsrp:v2:types", mode = WebParam.Mode.OUT) Holder<List<ItemDescription>> customModeDescriptions, @WebParam(name = "requiresInitCookie", targetNamespace = "urn:oasis:names:tc:wsrp:v2:types", mode = WebParam.Mode.OUT) Holder<CookieProtocol> requiresInitCookie, @WebParam(name = "registrationPropertyDescription", targetNamespace = "urn:oasis:names:tc:wsrp:v2:types", mode = WebParam.Mode.OUT) Holder<ModelDescription> registrationPropertyDescription, @WebParam(name = "locales", targetNamespace = "urn:!
 oasis:names:tc:wsrp:v2:types", mode = WebParam.Mode.OUT) Holde!
 r<List<S
tring>> locales, @WebParam(name = "resourceList", targetNamespace = "urn:oasis:names:tc:wsrp:v2:types", mode = WebParam.Mode.OUT) Holder<ResourceList> resourceList, @WebParam(name = "eventDescriptions", targetNamespace = "urn:oasis:names:tc:wsrp:v2:types", mode = WebParam.Mode.OUT) Holder<List<EventDescription>> eventDescriptions, @WebParam(name = "schemaType", targetNamespace = "urn:oasis:names:tc:wsrp:v2:types", mode = WebParam.Mode.OUT) Holder<ModelTypes> schemaType, @WebParam(name = "supportedOptions", targetNamespace = "urn:oasis:names:tc:wsrp:v2:types", mode = WebParam.Mode.OUT) Holder<List<String>> supportedOptions, @WebParam(name = "exportDescription", targetNamespace = "urn:oasis:names:tc:wsrp:v2:types", mode = WebParam.Mode.OUT) Holder<ExportDescription> exportDescription, @WebParam(name = "mayReturnRegistrationState", targetNamespace = "urn:oasis:names:tc:wsrp:v2:types", mode = WebParam.Mode.OUT) Holder<Boolean> mayReturnRegistrationState, @WebParam(name = "extens!
 ions", targetNamespace = "urn:oasis:names:tc:wsrp:v2:types", mode = WebParam.Mode.OUT) Holder<List<Extension>> extensions) throws InvalidRegistration, ModifyRegistrationRequired, OperationFailed, ResourceSuspended
+   {
+      super.getServiceDescription(registrationContext, desiredLocales, portletHandles, userContext, requiresRegistration, offeredPortlets, userCategoryDescriptions, extensionDescriptions, customWindowStateDescriptions, customModeDescriptions, requiresInitCookie, registrationPropertyDescription, locales, resourceList, eventDescriptions, schemaType, supportedOptions, exportDescription, mayReturnRegistrationState, extensions);
+      supportedOptions.value = new ArrayList<String>(2);
+      supportedOptions.value.add(WSRP2Constants.OPTIONS_EXPORT);
+      supportedOptions.value.add(WSRP2Constants.OPTIONS_IMPORT);
+   }
+}

Modified: components/wsrp/trunk/wsrp-producer-war/src/main/java/org/gatein/wsrp/endpoints/v2/ServiceDescriptionEndpoint.java
===================================================================
--- components/wsrp/trunk/wsrp-producer-war/src/main/java/org/gatein/wsrp/endpoints/v2/ServiceDescriptionEndpoint.java	2011-11-25 15:23:47 UTC (rev 8146)
+++ components/wsrp/trunk/wsrp-producer-war/src/main/java/org/gatein/wsrp/endpoints/v2/ServiceDescriptionEndpoint.java	2011-11-25 16:29:52 UTC (rev 8147)
@@ -1,6 +1,6 @@
 /*
  * JBoss, a division of Red Hat
- * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * Copyright 2011, 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.
@@ -62,7 +62,7 @@
    wsdlLocation = "/WEB-INF/wsdl/wsrp-2.0-services.wsdl",
    endpointInterface = "org.oasis.wsrp.v2.WSRPV2ServiceDescriptionPortType"
 )
- at HandlerChain(file="../producer-handler-chains.xml")
+ at HandlerChain(file = "../producer-handler-chains.xml")
 public class ServiceDescriptionEndpoint extends WSRPBaseEndpoint implements WSRPV2ServiceDescriptionPortType
 {
    public void getServiceDescription(
@@ -98,12 +98,18 @@
       offeredPortlets.value = description.getOfferedPortlets();
       userCategoryDescriptions.value = description.getUserCategoryDescriptions();
 //      customUserProfileItemDescriptions.value = description.getCustomUserProfileItemDescriptions();
+      extensionDescriptions.value = description.getExtensionDescriptions();
       customWindowStateDescriptions.value = description.getCustomWindowStateDescriptions();
       customModeDescriptions.value = description.getCustomModeDescriptions();
       requiresInitCookie.value = description.getRequiresInitCookie();
       registrationPropertyDescription.value = description.getRegistrationPropertyDescription();
       locales.value = description.getLocales();
       resourceList.value = description.getResourceList();
+      eventDescriptions.value = description.getEventDescriptions();
+      schemaType.value = description.getSchemaType();
+      supportedOptions.value = description.getSupportedOptions();
+      exportDescription.value = description.getExportDescription();
+      mayReturnRegistrationState.value = description.isMayReturnRegistrationState();
       extensions.value = description.getExtensions();
    }
 }



More information about the gatein-commits mailing list