[jboss-svn-commits] JBoss Portal SVN: r5618 - in trunk/wsrp/src: main/org/jboss/portal/test/wsrp/framework main/org/jboss/portal/test/wsrp/framework/support main/org/jboss/portal/test/wsrp/v1/producer main/org/jboss/portal/wsrp main/org/jboss/portal/wsrp/producer main/org/jboss/portal/wsrp/producer/registration main/org/jboss/portal/wsrp/producer/registration/impl main/org/jboss/portal/wsrp/producer/registration/policies resources/portal-wsrp-sar/META-INF resources/tests/test-wsrp-producer-sar/META-INF
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Nov 10 02:41:38 EST 2006
Author: chris.laprun at jboss.com
Date: 2006-11-10 02:41:15 -0500 (Fri, 10 Nov 2006)
New Revision: 5618
Added:
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/LocalizedString.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/RegistrationPropertyDescription.java
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducerImpl.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/ServiceObjectFactory.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/RegistrationTestCase.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/ServiceDescriptionTestCase.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/V1ProducerBaseTest.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/WSRPUtils.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/PortletManagementHandler.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/Registration.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/RegistrationMetaData.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/RegistrationPolicy.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationImpl.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationMetaDataImpl.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/policies/BasicRegistrationPolicy.java
trunk/wsrp/src/resources/portal-wsrp-sar/META-INF/jboss-service.xml
trunk/wsrp/src/resources/tests/test-wsrp-producer-sar/META-INF/jboss-service.xml
Log:
More registration work:
- RegistrationPolicy implementation is now injected via a MBean.
- Starting to take shape but still doesn't pass tests.
Next steps:
- Make the tests pass.
- Examine admin use case.
- Extract API.
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-11-09 23:09:50 UTC (rev 5617)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducerImpl.java 2006-11-10 07:41:15 UTC (rev 5618)
@@ -58,7 +58,6 @@
import org.jboss.portal.wsrp.core.PortletDescriptionResponse;
import org.jboss.portal.wsrp.core.PortletPropertyDescriptionResponse;
import org.jboss.portal.wsrp.core.PortletStateChangeRequiredFault;
-import org.jboss.portal.wsrp.core.PropertyDescription;
import org.jboss.portal.wsrp.core.PropertyList;
import org.jboss.portal.wsrp.core.RegistrationContext;
import org.jboss.portal.wsrp.core.RegistrationData;
@@ -71,6 +70,7 @@
import org.jboss.portal.wsrp.core.UnsupportedMimeTypeFault;
import org.jboss.portal.wsrp.core.UnsupportedModeFault;
import org.jboss.portal.wsrp.core.UnsupportedWindowStateFault;
+import org.jboss.portal.wsrp.producer.registration.RegistrationMetaData;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;
@@ -337,17 +337,6 @@
// Producer implementation ******************************************************************************************
- public void setRequiresRegistration(boolean requiresRegistration)
- {
- this.requiresRegistration = requiresRegistration;
- getServiceDescriptionBehavior().setRequiresRegistration(requiresRegistration);
- }
-
- public boolean isRequiresRegistration()
- {
- return requiresRegistration;
- }
-
public CookieProtocol getRequiresInitCookie()
{
return requiresInitCookie;
@@ -369,31 +358,14 @@
this.sessionExpirationTime = sessionExpirationTime;
}
- public void addRegistrationProperty(PropertyDescription propertyDescription)
- {
- PropertyDescription[] descriptions = requiredRegistrationInfo.getPropertyDescriptions();
- if (descriptions == null)
- {
- descriptions = new PropertyDescription[]{propertyDescription};
- requiredRegistrationInfo.setPropertyDescriptions(descriptions);
- }
- else
- {
- PropertyDescription[] newDescs = new PropertyDescription[descriptions.length + 1];
- System.arraycopy(descriptions, 0, newDescs, 0, descriptions.length);
- newDescs[descriptions.length] = propertyDescription;
- requiredRegistrationInfo.setPropertyDescriptions(newDescs);
- }
- }
-
- public void clearRegistrationProperties()
- {
- requiredRegistrationInfo.setPropertyDescriptions(null);
- }
-
public boolean isSessionValid(String sessionId)
{
// todo: implement
return true;
}
+
+ public RegistrationMetaData getRegistrationMetaData()
+ {
+ return null; // todo: implement
+ }
}
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/ServiceObjectFactory.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/ServiceObjectFactory.java 2006-11-09 23:09:50 UTC (rev 5617)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/ServiceObjectFactory.java 2006-11-10 07:41:15 UTC (rev 5618)
@@ -23,6 +23,7 @@
package org.jboss.portal.test.wsrp.framework.support;
+import org.jboss.portal.wsrp.WSRPTypeFactory;
import org.jboss.portal.wsrp.core.LocalizedString;
/**
@@ -50,7 +51,7 @@
*/
public static LocalizedString createLocalizedString(String value)
{
- return new LocalizedString("en", null, value);
+ return WSRPTypeFactory.createLocalizedString(value);
}
/** Produces String from LocalizedString */
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/RegistrationTestCase.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/RegistrationTestCase.java 2006-11-09 23:09:50 UTC (rev 5617)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/RegistrationTestCase.java 2006-11-10 07:41:15 UTC (rev 5618)
@@ -23,18 +23,19 @@
package org.jboss.portal.test.wsrp.v1.producer;
+import org.jboss.portal.common.junit.ExtendedAssert;
+import org.jboss.portal.wsrp.WSRPConstants;
+import org.jboss.portal.wsrp.WSRPUtils;
import org.jboss.portal.wsrp.core.GetServiceDescription;
import org.jboss.portal.wsrp.core.InvalidRegistrationFault;
-import org.jboss.portal.wsrp.core.LocalizedString;
import org.jboss.portal.wsrp.core.ModelDescription;
import org.jboss.portal.wsrp.core.ModifyRegistration;
import org.jboss.portal.wsrp.core.OperationFailedFault;
-import org.jboss.portal.wsrp.core.Property;
import org.jboss.portal.wsrp.core.PropertyDescription;
import org.jboss.portal.wsrp.core.RegistrationContext;
import org.jboss.portal.wsrp.core.RegistrationData;
import org.jboss.portal.wsrp.core.ServiceDescription;
-import org.jboss.portal.common.junit.ExtendedAssert;
+import org.jboss.portal.wsrp.producer.registration.RegistrationPropertyDescription;
import javax.xml.namespace.QName;
@@ -51,6 +52,46 @@
super("RegistrationTestCase");
}
+ /**
+ * R355: The portal MUST pass a name for itself that uniquely identifies it.
+ *
+ * @throws Exception
+ */
+ public void testUniqueNameRegistration() throws Exception
+ {
+ // not sure how to test this...
+ }
+
+ /**
+ * R356: The portal MAY pass information describing the portal [vendor] type and version.
+ * <p/>
+ * However, WSRP v1 7.1.1 states: The consumerAgent value MUST start with "productName.majorVersion.minorVersion"
+ * where "productName" identifies the product the Consumer installed for its deployment, and majorVersion and
+ * minorVersion are vendor-defined indications of the version of its product. This string can then contain any
+ * additional characters/words the product or Consumer wish to supply.
+ *
+ * @throws Exception
+ */
+ public void testConsumerAgent() throws Exception
+ {
+ initRegistrationInfo();
+ RegistrationData regData = createBaseRegData();
+ regData.setConsumerAgent("invalid consumer agent");
+
+ try
+ {
+ registrationService.register(regData);
+ ExtendedAssert.fail("Trying to register with an invalid consumer agent String should fail.");
+ }
+ catch (OperationFailedFault operationFailedFault)
+ {
+ // expected
+ }
+
+ regData.setConsumerAgent(WSRPConstants.CONSUMER_AGENT);
+ registrationService.register(regData);
+ }
+
public void testDeregister() throws Exception
{
// initiate registration
@@ -60,8 +101,7 @@
// deregister
registrationService.deregister(rc);
- // try to get service description with the deregistered context
- // Try to get service description
+ // Try to get service description with the deregistered context
GetServiceDescription gs = getNoRegistrationServiceDescriptionRequest();
gs.setRegistrationContext(rc);
@@ -83,9 +123,9 @@
RegistrationContext rc = registerConsumer();
// now modify Producer's set of required registration info
- PropertyDescription regProp = new PropertyDescription("new prop", new QName("xsd:string"),
- new LocalizedString("en", null, "New Registration Property"), null, null);
- producer.addRegistrationProperty(regProp);
+ RegistrationPropertyDescription regProp = new RegistrationPropertyDescription("new prop", new QName("xsd:string"));
+ regProp.setDefaultLabel("New Registration Property");
+ producer.getRegistrationMetaData().addRegistrationProperty(regProp);
// Try to get service description
GetServiceDescription gs = getNoRegistrationServiceDescriptionRequest();
@@ -108,14 +148,14 @@
PropertyDescription[] pds = serviceDescriptionService.getServiceDescription(gs)
.getRegistrationPropertyDescription().getPropertyDescriptions();
ExtendedAssert.assertEquals(2, pds.length);
- assertEquals(regProp, pds[1]);
+ assertEquals(WSRPUtils.convertToPropertyDescription(regProp), pds[1]);
// Update registration data
RegistrationData regData = createBaseRegData();
- Property[] props = regData.getRegistrationProperties();
- Property[] newProps = new Property[props.length + 1];
+ org.jboss.portal.wsrp.core.Property[] props = regData.getRegistrationProperties();
+ org.jboss.portal.wsrp.core.Property[] newProps = new org.jboss.portal.wsrp.core.Property[props.length + 1];
System.arraycopy(props, 0, newProps, 0, props.length);
- newProps[props.length] = new Property("new prop", "en", "blah", null);
+ newProps[props.length] = new org.jboss.portal.wsrp.core.Property("new prop", "en", "blah", null);
// Modify registration and get service description
registrationService.modifyRegistration(new ModifyRegistration(rc, regData));
@@ -125,7 +165,7 @@
public void testRegister() throws Exception
{
- PropertyDescription regProp = initRegistrationInfo();
+ RegistrationPropertyDescription regProp = initRegistrationInfo();
// service description request without registration info
GetServiceDescription gs = getNoRegistrationServiceDescriptionRequest();
@@ -142,7 +182,7 @@
PropertyDescription[] propertyDescriptions = registrationPropertyDescription.getPropertyDescriptions();
ExtendedAssert.assertNotNull(propertyDescriptions);
ExtendedAssert.assertEquals(1, propertyDescriptions.length);
- assertEquals(regProp, propertyDescriptions[0]);
+ assertEquals(WSRPUtils.convertToPropertyDescription(regProp), propertyDescriptions[0]);
// No offered portlets without registration!
ExtendedAssert.assertNull(sd.getOfferedPortlets());
@@ -156,7 +196,7 @@
public void tearDown() throws Exception
{
- producer.clearRegistrationProperties();
+ producer.getRegistrationMetaData().clearRegistrationProperties();
super.tearDown();
}
}
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/ServiceDescriptionTestCase.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/ServiceDescriptionTestCase.java 2006-11-09 23:09:50 UTC (rev 5617)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/ServiceDescriptionTestCase.java 2006-11-10 07:41:15 UTC (rev 5618)
@@ -29,10 +29,9 @@
*/
package org.jboss.portal.test.wsrp.v1.producer;
+import org.jboss.portal.common.junit.ExtendedAssert;
import org.jboss.portal.wsrp.core.GetServiceDescription;
import org.jboss.portal.wsrp.core.ServiceDescription;
-import org.jboss.portal.common.NotYetImplemented;
-import org.jboss.portal.common.junit.ExtendedAssert;
/**
* Tests WSRP Service Description
@@ -52,7 +51,7 @@
public void testGetServiceDescriptionNoRegistration() throws Throwable
{
- producer.setRequiresRegistration(false);
+ producer.getRegistrationMetaData().setRequiresRegistration(false);
GetServiceDescription gs = getNoRegistrationServiceDescriptionRequest();
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/V1ProducerBaseTest.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/V1ProducerBaseTest.java 2006-11-09 23:09:50 UTC (rev 5617)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/V1ProducerBaseTest.java 2006-11-10 07:41:15 UTC (rev 5618)
@@ -40,6 +40,7 @@
import org.jboss.portal.wsrp.core.WSRP_v1_PortletManagement_PortType;
import org.jboss.portal.wsrp.core.WSRP_v1_Registration_PortType;
import org.jboss.portal.wsrp.core.WSRP_v1_ServiceDescription_PortType;
+import org.jboss.portal.wsrp.producer.registration.RegistrationPropertyDescription;
import javax.xml.namespace.QName;
@@ -77,12 +78,14 @@
markupService = (WSRP_v1_Markup_PortType)serviceFactory.getService(WSRP_v1_Markup_PortType.class);
registrationService = (WSRP_v1_Registration_PortType)serviceFactory.getService(WSRP_v1_Registration_PortType.class);
portletManagementService = (WSRP_v1_PortletManagement_PortType)serviceFactory.getService(WSRP_v1_PortletManagement_PortType.class);
+
+ resetRegistrationInfo();
}
public void tearDown() throws Exception
{
+ resetRegistrationInfo();
super.tearDown();
- resetRegistrationInfo();
}
/**
@@ -150,26 +153,24 @@
return regData;
}
- protected PropertyDescription initRegistrationInfo()
+ protected RegistrationPropertyDescription initRegistrationInfo()
{
// define expected registration infos
- producer.setRequiresRegistration(true);
+ producer.getRegistrationMetaData().setRequiresRegistration(true);
// fix-me: http://jira.jboss.com/jira/browse/JBPORTAL-821
- /*
- PropertyDescription regProp = new PropertyDescription("regProp", new QName("urn:oasis:names:tc:wsrp:v1:types",
- "LocalizedString", "ns1"), new LocalizedString("en", null, "Registration Property"), null, null);
- */
- PropertyDescription regProp = new PropertyDescription("regProp", new QName("ns1:LocalizedString"),
- new LocalizedString("en", null, "Registration Property"), null, null);
- producer.addRegistrationProperty(regProp);
+ RegistrationPropertyDescription regProp = new RegistrationPropertyDescription("regProp",
+ new QName("urn:oasis:names:tc:wsrp:v1:types", "LocalizedString", "ns1"));
+ regProp.setDefaultLabel("Registration Property");
+ producer.getRegistrationMetaData().addRegistrationProperty(regProp);
+
return regProp;
}
protected void resetRegistrationInfo()
{
- producer.setRequiresRegistration(false);
- producer.clearRegistrationProperties();
+ producer.getRegistrationMetaData().setRequiresRegistration(false);
+ producer.getRegistrationMetaData().clearRegistrationProperties();
}
protected GetServiceDescription getNoRegistrationServiceDescriptionRequest()
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPProducer.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPProducer.java 2006-11-09 23:09:50 UTC (rev 5617)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPProducer.java 2006-11-10 07:41:15 UTC (rev 5618)
@@ -24,11 +24,11 @@
package org.jboss.portal.wsrp;
import org.jboss.portal.wsrp.core.CookieProtocol;
-import org.jboss.portal.wsrp.core.PropertyDescription;
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;
import org.jboss.portal.wsrp.core.WSRP_v1_ServiceDescription_PortType;
+import org.jboss.portal.wsrp.producer.registration.RegistrationMetaData;
/**
* @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
@@ -46,20 +46,6 @@
int INFINITE_SESSION_EXPIRATION_TIME = -1;
/**
- * Specifies whether this Producer requires clients to be registered or not.
- *
- * @param requiresRegistration <code>true</code> if registration is required, <code>false</code> otherwise.
- */
- public void setRequiresRegistration(boolean requiresRegistration);
-
- /**
- * Determines whether registration is required to access this Producer's information and services.
- *
- * @return <code>true</code> if registration is required, <code>false</code> otherwise.
- */
- public boolean isRequiresRegistration();
-
- /**
* Indicates whether or not the Producer requires the Consumer to assist with cookie support of the HTTP protocol.
* Supported values and semantics: <ul> <li>{@link org.jboss.portal.wsrp.core.CookieProtocol#none}: The Producer does
* not need the Consumer to ever invoke {@link org.jboss.portal.wsrp.core.WSRP_v1_Markup_PortType#initCookie(org.jboss.portal.wsrp.core.InitCookie)}.</li>
@@ -87,7 +73,7 @@
/**
* Maximum number of seconds between invocations referencing a session ID before this Producer will schedule
- * releasing the related resources. {@link INFINITE_SESSION_EXPIRATION_TIME} indicates that the sessionID will never
+ * releasing the related resources. {@link #INFINITE_SESSION_EXPIRATION_TIME} indicates that the sessionID will never
* expire.
*
* @return the expiration time (in seconds) of session associated resources
@@ -99,7 +85,7 @@
*
* @param sessionExpirationTime the maximum number of seconds between invocations referencing a session ID before
* this Producer will schedule releasing the related resources. If {@link
- * INFINITE_SESSION_EXPIRATION_TIME} is passed, then the session will never expire.
+ * #INFINITE_SESSION_EXPIRATION_TIME} is passed, then the session will never expire.
*/
void setSessionExpirationTime(int sessionExpirationTime);
@@ -111,14 +97,5 @@
*/
boolean isSessionValid(String sessionId);
- /**
- * Adds a registration property to the set of required information for Consumers to provide when registering with
- * this Producer
- *
- * @param propertyDescription
- */
- void addRegistrationProperty(PropertyDescription propertyDescription);
-
- /** Remove all existing registration properties. */
- void clearRegistrationProperties();
+ RegistrationMetaData getRegistrationMetaData();
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPTypeFactory.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPTypeFactory.java 2006-11-09 23:09:50 UTC (rev 5617)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPTypeFactory.java 2006-11-10 07:41:15 UTC (rev 5618)
@@ -41,14 +41,17 @@
import org.jboss.portal.wsrp.core.GetServiceDescription;
import org.jboss.portal.wsrp.core.InitCookie;
import org.jboss.portal.wsrp.core.InteractionParams;
+import org.jboss.portal.wsrp.core.LocalizedString;
import org.jboss.portal.wsrp.core.MarkupContext;
import org.jboss.portal.wsrp.core.MarkupParams;
import org.jboss.portal.wsrp.core.MarkupResponse;
import org.jboss.portal.wsrp.core.MarkupType;
+import org.jboss.portal.wsrp.core.ModelDescription;
import org.jboss.portal.wsrp.core.PerformBlockingInteraction;
import org.jboss.portal.wsrp.core.PortletContext;
import org.jboss.portal.wsrp.core.PortletDescription;
import org.jboss.portal.wsrp.core.Property;
+import org.jboss.portal.wsrp.core.PropertyDescription;
import org.jboss.portal.wsrp.core.RegistrationContext;
import org.jboss.portal.wsrp.core.RegistrationData;
import org.jboss.portal.wsrp.core.RuntimeContext;
@@ -59,6 +62,8 @@
import org.jboss.portal.wsrp.core.UpdateResponse;
import org.jboss.portal.wsrp.core.UserContext;
+import javax.xml.namespace.QName;
+
/**
* Creates minimally valid instances of WSRP types, populated with default values where possible, as per
* wsrp_v1_types.xsd. See <a href="http://jira.jboss.com/jira/browse/JBPORTAL-808">JBPORTAL-808</a> for more
@@ -625,6 +630,54 @@
*/
public static RegistrationContext createRegistrationContext(String registrationHandle)
{
+ ParameterValidation.throwIllegalArgExceptionIfNull(registrationHandle, "Registration handle");
return new RegistrationContext(registrationHandle, null, null);
}
+
+ /**
+ * propertyDescriptions(PropertyDescription)*, modelTypes(ModelTypes)?, extensions(Extension)*
+ *
+ * @return
+ * @since 2.6
+ */
+ public static ModelDescription createModelDescription(PropertyDescription[] propertyDescriptions)
+ {
+ return new ModelDescription(propertyDescriptions, null, null);
+ }
+
+ /**
+ * label(LocalizedString)?, hint(LocalizedString)?, extensions(Extension)*, @name(xsd:string), @type(xsd:QName)
+ *
+ * @return
+ * @since 2.6
+ */
+ public static PropertyDescription createPropertyDescription(String name, QName type)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(name, "PropertyDescription name");
+ ParameterValidation.throwIllegalArgExceptionIfNull(type, "PropertyDescription type");
+ return new PropertyDescription(name, type, null, null, null);
+ }
+
+ /**
+ * value(xsd:string), @xml:lang, @resourceName(xsd:string)?
+ *
+ * @return
+ */
+ public static LocalizedString createLocalizedString(String lang, String resourceName, String value)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(lang, "LocalizedString language");
+ ParameterValidation.throwIllegalArgExceptionIfNull(value, "LocalizedString value");
+ return new LocalizedString(lang, resourceName, value);
+ }
+
+ /**
+ * Same as createLocalizedString("en", null, value)
+ *
+ * @param value
+ * @return
+ */
+ public static LocalizedString createLocalizedString(String value)
+ {
+ return createLocalizedString("en", null, value);
+ }
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPUtils.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPUtils.java 2006-11-09 23:09:50 UTC (rev 5617)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPUtils.java 2006-11-10 07:41:15 UTC (rev 5618)
@@ -35,8 +35,12 @@
import org.jboss.portal.portlet.state.AccessMode;
import org.jboss.portal.wsrp.core.Fault;
import org.jboss.portal.wsrp.core.MissingParametersFault;
+import org.jboss.portal.wsrp.core.ModelDescription;
import org.jboss.portal.wsrp.core.OperationFailedFault;
+import org.jboss.portal.wsrp.core.PropertyDescription;
import org.jboss.portal.wsrp.core.StateChange;
+import org.jboss.portal.wsrp.producer.registration.LocalizedString;
+import org.jboss.portal.wsrp.producer.registration.RegistrationPropertyDescription;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
@@ -271,7 +275,7 @@
{
if (valueToCheck == null)
{
- throw(MissingParametersFault)
+ throw (MissingParametersFault)
createFaultFrom(MissingParametersFault.class, new NullPointerException("Missing required " + valueName
+ (context != null ? " in " + context : "")));
}
@@ -282,8 +286,54 @@
{
if (valueToCheck == null)
{
- throw(OperationFailedFault)
+ throw (OperationFailedFault)
createFaultFrom(OperationFailedFault.class, new NullPointerException("Missing required " + valueName));
}
}
+
+ public static ModelDescription convertRegistrationPropertiesToModelDescription(Map registrationInfo)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(registrationInfo, "registration info");
+ if (registrationInfo.isEmpty())
+ {
+ return WSRPTypeFactory.createModelDescription(null);
+ }
+
+ int size = registrationInfo.size();
+ PropertyDescription[] propertyDescriptions = new PropertyDescription[size];
+ int i = 0;
+ for (Iterator props = registrationInfo.values().iterator(); props.hasNext();)
+ {
+ RegistrationPropertyDescription property = (RegistrationPropertyDescription)props.next();
+ propertyDescriptions[i++] = convertToPropertyDescription(property);
+ }
+
+ return WSRPTypeFactory.createModelDescription(propertyDescriptions);
+ }
+
+ public static PropertyDescription convertToPropertyDescription(RegistrationPropertyDescription propertyDescription)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(propertyDescription, "RegistrationPropertyDescription");
+ PropertyDescription propDesc = WSRPTypeFactory.createPropertyDescription(propertyDescription.getName().toString(),
+ propertyDescription.getType());
+
+ // todo: deal with languages properly!!
+ LocalizedString hint = propertyDescription.getHint();
+ if (hint != null)
+ {
+ propDesc.setHint(convertToWSRPLocalizedString(hint));
+ }
+ LocalizedString label = propertyDescription.getLabel();
+ if (label != null)
+ {
+ propDesc.setLabel(convertToWSRPLocalizedString(label));
+ }
+ return propDesc;
+ }
+
+ public static org.jboss.portal.wsrp.core.LocalizedString convertToWSRPLocalizedString(LocalizedString regLocalizedString)
+ {
+ return WSRPTypeFactory.createLocalizedString(LocaleInfo.getRFC3066LanguageTagFor(regLocalizedString.getLocale()),
+ regLocalizedString.getResourceName(), regLocalizedString.getValue());
+ }
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/PortletManagementHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/PortletManagementHandler.java 2006-11-09 23:09:50 UTC (rev 5617)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/PortletManagementHandler.java 2006-11-10 07:41:15 UTC (rev 5618)
@@ -84,17 +84,29 @@
MissingParametersFault, InvalidRegistrationFault, OperationFailedFault, RemoteException
{
WSRPUtils.throwOperationFailedFaultIfValueIsMissing(getPortletDescription, "getPortletDescription");
+ producer.checkRegistration(getPortletDescription.getRegistrationContext());
- if (producer.isRegistrationValid(getPortletDescription.getRegistrationContext()))
- {
- String handle = getPortletDescription.getPortletContext().getPortletHandle();
- return new PortletDescriptionResponse(
- producer.getPortletDescription(handle, getPortletDescription.getDesiredLocales()),
- null, null);
- }
- return null; // shouldn't happen
+ String handle = getPortletDescription.getPortletContext().getPortletHandle();
+ return new PortletDescriptionResponse(
+ producer.getPortletDescription(handle, getPortletDescription.getDesiredLocales()),
+ null, null);
}
+ public PortletPropertyDescriptionResponse getPortletPropertyDescription(GetPortletPropertyDescription getPortletPropertyDescription) throws MissingParametersFault, InconsistentParametersFault, InvalidUserCategoryFault, InvalidRegistrationFault, AccessDeniedFault, InvalidHandleFault, OperationFailedFault, RemoteException
+ {
+ WSRPUtils.throwOperationFailedFaultIfValueIsMissing(getPortletPropertyDescription, GET_PORTLET_PROPERTY_DESCRIPTION);
+
+ PortletContext portletContext = getPortletPropertyDescription.getPortletContext();
+ WSRPUtils.throwMissingParametersFaultIfValueIsMissing(portletContext, PORTLET_CONTEXT, GET_PORTLET_PROPERTY_DESCRIPTION);
+
+ producer.checkRegistration(getPortletPropertyDescription.getRegistrationContext());
+
+ Portlet portlet = getPortletFrom(portletContext);
+ PortletInfo info = portlet.getInfo();
+
+ return null; // todo: implement
+ }
+
public PortletContext clonePortlet(ClonePortlet clonePortlet) throws InvalidUserCategoryFault, AccessDeniedFault, OperationFailedFault, InvalidHandleFault, InvalidRegistrationFault, InconsistentParametersFault, MissingParametersFault, RemoteException
{
return null; // todo: implement
@@ -117,65 +129,61 @@
PortletContext portletContext = getPortletProperties.getPortletContext();
WSRPUtils.throwMissingParametersFaultIfValueIsMissing(portletContext, PORTLET_CONTEXT, GET_PORTLET_PROPERTIES);
- if (producer.isRegistrationValid(getPortletProperties.getRegistrationContext()))
+ producer.checkRegistration(getPortletProperties.getRegistrationContext());
+
+ String[] names = getPortletProperties.getNames();
+ Set keys = getKeysFromNames(names);
+
+ try
{
- String[] names = getPortletProperties.getNames();
- Set keys = getKeysFromNames(names);
+ PropertyMap properties;
+ org.jboss.portal.portlet.PortletContext jbpContext =
+ WSRPUtils.convertWSRPPortletContextToPortalPortletContext(portletContext);
- try
+ if (keys != null)
{
- PropertyMap properties;
- org.jboss.portal.portlet.PortletContext jbpContext =
- WSRPUtils.convertWSRPPortletContextToPortalPortletContext(portletContext);
+ properties = producer.getInvoker().getProperties(jbpContext, keys);
+ }
+ else
+ {
+ properties = producer.getInvoker().getProperties(jbpContext);
+ }
- if (keys != null)
- {
- properties = producer.getInvoker().getProperties(jbpContext, keys);
- }
- else
- {
- properties = producer.getInvoker().getProperties(jbpContext);
- }
+ Portlet portlet = getPortletFrom(portletContext);
+ PortletInfo info = portlet.getInfo();
- Portlet portlet = getPortletFrom(portletContext);
- PortletInfo info = portlet.getInfo();
+ PropertyList result = new PropertyList();
+ int propertyNb = properties.size();
- PropertyList result = new PropertyList();
- int propertyNb = properties.size();
+ if (propertyNb > 0)
+ {
+ Property[] resProperties = new Property[propertyNb];
+ int i = 0;
+ PreferenceInfo prefInfo;
+ String key;
+ Value value;
+ LocalizedString displayName;
- if (propertyNb > 0)
+ for (Iterator entries = properties.entrySet().iterator(); entries.hasNext(); i++)
{
- Property[] resProperties = new Property[propertyNb];
- int i = 0;
- PreferenceInfo prefInfo;
- String key;
- Value value;
- LocalizedString displayName;
-
- for (Iterator entries = properties.entrySet().iterator(); entries.hasNext(); i++)
- {
- Map.Entry entry = (Map.Entry)entries.next();
- key = (String)entry.getKey();
- value = (Value)entry.getValue();
- prefInfo = info.getPreferences().getPreference(key);
- displayName = prefInfo.getDisplayName();
- String lang = LocaleInfo.getRFC3066LanguageTagFor(displayName.getDefaultLocale());
- resProperties[i] = WSRPTypeFactory.createProperty(displayName.getDefaultString(), lang, value.asString());
- }
-
- result.setProperties(resProperties);
+ Map.Entry entry = (Map.Entry)entries.next();
+ key = (String)entry.getKey();
+ value = (Value)entry.getValue();
+ prefInfo = info.getPreferences().getPreference(key);
+ displayName = prefInfo.getDisplayName();
+ String lang = LocaleInfo.getRFC3066LanguageTagFor(displayName.getDefaultLocale());
+ resProperties[i] = WSRPTypeFactory.createProperty(displayName.getDefaultString(), lang, value.asString());
}
- return result;
+ result.setProperties(resProperties);
}
- catch (PortletInvokerException e)
- {
- throw(InvalidHandleFault)WSRPUtils.createFaultFrom(InvalidHandleFault.class, e);
- }
+ return result;
}
-
- return null; // shouldn't happen
+ catch (PortletInvokerException e)
+ {
+ throw (InvalidHandleFault)WSRPUtils.createFaultFrom(InvalidHandleFault.class, e);
+ }
}
private Set getKeysFromNames(String[] names)
@@ -208,21 +216,6 @@
return keys;
}
- public PortletPropertyDescriptionResponse getPortletPropertyDescription(GetPortletPropertyDescription getPortletPropertyDescription) throws MissingParametersFault, InconsistentParametersFault, InvalidUserCategoryFault, InvalidRegistrationFault, AccessDeniedFault, InvalidHandleFault, OperationFailedFault, RemoteException
- {
- WSRPUtils.throwOperationFailedFaultIfValueIsMissing(getPortletPropertyDescription, GET_PORTLET_PROPERTY_DESCRIPTION);
-
- PortletContext portletContext = getPortletPropertyDescription.getPortletContext();
- WSRPUtils.throwMissingParametersFaultIfValueIsMissing(portletContext, PORTLET_CONTEXT, GET_PORTLET_PROPERTY_DESCRIPTION);
-
- if (producer.isRegistrationValid(getPortletPropertyDescription.getRegistrationContext()))
- {
- Portlet portlet = getPortletFrom(portletContext);
- PortletInfo info = portlet.getInfo();
- }
- return null; // shouldn't happen
- }
-
private Portlet getPortletFrom(PortletContext portletContext) throws InvalidHandleFault
{
Portlet portlet;
@@ -232,7 +225,7 @@
}
catch (PortletInvokerException e)
{
- throw(InvalidHandleFault)WSRPUtils.createFaultFrom(InvalidHandleFault.class, e);
+ throw (InvalidHandleFault)WSRPUtils.createFaultFrom(InvalidHandleFault.class, e);
}
return portlet;
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java 2006-11-09 23:09:50 UTC (rev 5617)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java 2006-11-10 07:41:15 UTC (rev 5618)
@@ -35,9 +35,9 @@
import org.jboss.portal.wsrp.core.RegistrationState;
import org.jboss.portal.wsrp.core.ReturnAny;
import org.jboss.portal.wsrp.core.WSRP_v1_Registration_PortType;
-import org.jboss.portal.wsrp.producer.registration.Consumer;
import org.jboss.portal.wsrp.producer.registration.Registration;
import org.jboss.portal.wsrp.producer.registration.RegistrationConversionException;
+import org.jboss.portal.wsrp.producer.registration.RegistrationConverter;
import org.jboss.portal.wsrp.producer.registration.RegistrationException;
import org.jboss.portal.wsrp.producer.registration.RegistrationPolicy;
@@ -75,42 +75,49 @@
WSRPUtils.throwOperationFailedFaultIfValueIsMissing(registrationData, "RegistrationData");
String consumerName = registrationData.getConsumerName();
WSRPUtils.throwMissingParametersFaultIfValueIsMissing(consumerName, "consumer name", "RegistrationData");
+
String consumerAgent = registrationData.getConsumerAgent();
WSRPUtils.throwMissingParametersFaultIfValueIsMissing(consumerAgent, "consumer agent", "RegistrationData");
+ throwOperationFailedFaultIfInvalid(consumerAgent);
- Consumer consumer;
Registration registration;
try
{
+ log.debug("Attempting to register consumer named '" + consumerName + "', agent '" + consumerAgent + "'.");
// delegate to the policy the details on how to handle the registration
registration = policy.registerConsumerWith(registrationData);
}
catch (RegistrationException e)
{
+ log.debug(e);
throw WSRPUtils.createOperationFailedFault(e);
}
RegistrationContext registrationContext = WSRPTypeFactory.createRegistrationContext(registration.getRegistrationHandle());
-
- if (policy.requireRegistrationMarshalling())
+ if (policy.getRegistrationMetaData().requiresMarshalling())
{
try
{
+ log.debug("Marshalling state.");
byte[] registrationState = policy.getRegistrationConverter().marshall(registration);
registrationContext.setRegistrationState(registrationState);
}
catch (RegistrationConversionException e)
{
+ log.debug(e);
throw WSRPUtils.createOperationFailedFault(e);
}
}
+ log.debug("Registration completed without error.");
return registrationContext;
}
public ReturnAny deregister(RegistrationContext deregister) throws OperationFailedFault, InvalidRegistrationFault,
RemoteException
{
+ WSRPUtils.throwOperationFailedFaultIfValueIsMissing(deregister, "RegistrationContext");
+
return null; // todo: implement
}
@@ -119,4 +126,86 @@
{
return null; // todo: implement
}
+
+ public boolean isRegistrationValid(RegistrationContext registrationContext) throws InvalidRegistrationFault
+ {
+ if (policy.getRegistrationMetaData().requiresRegistration())
+ {
+ log.debug("registration required: checking registration");
+ if (registrationContext == null)
+ {
+ log.debug("registration is required yet no RegistrationContext was provided!");
+ return false;
+ }
+
+ String regHandle = registrationContext.getRegistrationHandle();
+ if (regHandle == null)
+ {
+ throwInvalidRegistrationFault("missing required registration handle!");
+ }
+
+ if (policy.getRegistrationMetaData().requiresMarshalling())
+ {
+ byte[] state = registrationContext.getRegistrationState();
+ if (state == null)
+ {
+ throwInvalidRegistrationFault("missing required registration state!");
+ }
+
+ RegistrationConverter converter = policy.getRegistrationConverter();
+ try
+ {
+ Registration registration = converter.unmarshall(state);
+ Registration expected = policy.getRegistrationRegistry().getRegistration(regHandle);
+ if (!expected.equals(registration))
+ {
+ throwInvalidRegistrationFault("unmarshalled state is not the expected one!");
+ }
+ }
+ catch (RegistrationConversionException e)
+ {
+ throwInvalidRegistrationFault("could not unmarshall state (" + e.getLocalizedMessage() + ")!");
+ }
+ catch (RegistrationException e)
+ {
+ throwInvalidRegistrationFault("could not retrieve registration with handle '" + regHandle
+ + "' from the registry (" + e.getLocalizedMessage() + ")!");
+ }
+ }
+
+ return true;
+ }
+ else
+ {
+ if (registrationContext != null)
+ {
+ throwInvalidRegistrationFault("no registration necessary yet one was provided!");
+ }
+ return true;
+ }
+ }
+
+ private boolean throwInvalidRegistrationFault(String message) throws InvalidRegistrationFault
+ {
+ throw (InvalidRegistrationFault)WSRPUtils.createFaultFrom(InvalidRegistrationFault.class,
+ new Exception("Invalid registration: " + message));
+ }
+
+ private void throwOperationFailedFaultIfInvalid(String consumerAgent) throws OperationFailedFault
+ {
+ char periodChar = '.';
+ int period = consumerAgent.indexOf(periodChar);
+ if (period != -1)
+ {
+ consumerAgent = consumerAgent.substring(period);
+ period = consumerAgent.indexOf(periodChar);
+
+ if (period != -1)
+ {
+ return;
+ }
+ }
+ throw WSRPUtils.createOperationFailedFault(new IllegalArgumentException(consumerAgent
+ + " is not a valid Consumer Agent."));
+ }
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java 2006-11-09 23:09:50 UTC (rev 5617)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java 2006-11-10 07:41:15 UTC (rev 5618)
@@ -44,6 +44,7 @@
import org.jboss.portal.wsrp.core.PortletDescription;
import org.jboss.portal.wsrp.core.ServiceDescription;
import org.jboss.portal.wsrp.core.WSRP_v1_ServiceDescription_PortType;
+import org.jboss.portal.wsrp.producer.registration.RegistrationMetaData;
import java.rmi.RemoteException;
import java.util.Collection;
@@ -63,14 +64,9 @@
private final Logger log = Logger.getLogger(getClass());
- /** The ServiceDescription when the Consumer is allowed to access it or when registration is not required. */
- private final ServiceDescription serviceDescription;
-
ServiceDescriptionHandler(WSRPProducerImpl producer)
{
super(producer);
- serviceDescription = WSRPTypeFactory.createServiceDescription(producer.isRequiresRegistration());
- serviceDescription.setRequiresInitCookie(CookieProtocol.none);
}
public ServiceDescription getServiceDescription(GetServiceDescription gs)
@@ -78,31 +74,16 @@
{
WSRPUtils.throwOperationFailedFaultIfValueIsMissing(gs, "GetServiceDescription");
- if (producer.isRegistrationValid(gs.getRegistrationContext()))
+ RegistrationMetaData metadata = producer.getRegistrationPolicy().getRegistrationMetaData();
+ if (metadata.fullServiceDescriptionRequiresRegistration() && !producer.isRegistrationValid(gs.getRegistrationContext()))
{
- log.debug("Returning service description for registered consumers");
- refreshServiceDescription(gs.getDesiredLocales());
- return serviceDescription;
+ return getRegistrationNotProvidedServiceDescription();
}
- else
- {
- return producer.getRegistrationNotProvidedServiceDescription();
- }
+ log.debug("Returning complete service description");
+ return refreshServiceDescription(gs.getDesiredLocales());
}
- /**
- * Refreshes the service description by asking the portal container about contained portlets.
- *
- * @param desiredLocales
- */
- private void refreshServiceDescription(String[] desiredLocales)
- {
- PortletDescription[] descriptions = (PortletDescription[])getOfferedPortletDescriptions(desiredLocales)
- .toArray(new PortletDescription[]{});
- serviceDescription.setOfferedPortlets(descriptions);
- }
-
public Set getOfferedPortletDescriptions(String[] desiredLocales)
{
Set portlets;
@@ -143,6 +124,39 @@
}
/**
+ * Refreshes the service description by asking the portal container about contained portlets.
+ *
+ * @param desiredLocales the desired locales for the service description
+ * @return the updated service description
+ */
+ private ServiceDescription refreshServiceDescription(String[] desiredLocales)
+ {
+ // todo: find out how to cache this
+ RegistrationMetaData metaData = producer.getRegistrationPolicy().getRegistrationMetaData();
+ ServiceDescription serviceDescription = WSRPTypeFactory.createServiceDescription(metaData.requiresRegistration());
+ serviceDescription.setRequiresInitCookie(CookieProtocol.none);
+ PortletDescription[] descriptions = (PortletDescription[])getOfferedPortletDescriptions(desiredLocales)
+ .toArray(new PortletDescription[]{});
+ serviceDescription.setOfferedPortlets(descriptions);
+ return serviceDescription;
+ }
+
+ /**
+ * Retrieves the service description offered to unregistered consumers when registration is required.
+ *
+ * @return the service description offered to unregistered consumers when registration is required
+ */
+ protected ServiceDescription getRegistrationNotProvidedServiceDescription()
+ {
+ // todo: find out how to cache this
+ log.debug("Using service description offered for unregistered consumers");
+ RegistrationMetaData metaData = producer.getRegistrationPolicy().getRegistrationMetaData();
+ return new ServiceDescription(true, null, null, null, null, null, CookieProtocol.none,
+ WSRPUtils.convertRegistrationPropertiesToModelDescription(metaData.getRegistrationProperties()),
+ producer.getSupportedLocales(), null, null);
+ }
+
+ /**
* Creates a PortletDescription based on the user desired locales (ordered according to user preferences) for the
* specified component.
*
@@ -209,7 +223,7 @@
new org.jboss.portal.wsrp.core.LocalizedString[keywordArray.length];
for (int i = 0; i < keywordArray.length; i++)
{
- keywords[i] = new org.jboss.portal.wsrp.core.LocalizedString(lang, null, keywordArray[i].trim()); // fix-me: resource name
+ keywords[i] = WSRPTypeFactory.createLocalizedString(lang, null, keywordArray[i].trim()); // fix-me: resource name
}
desc.setKeywords(keywords);
}
@@ -272,11 +286,6 @@
return result;
}
- private org.jboss.portal.wsrp.core.LocalizedString createWSRPLocalizedString(String language, String resourceName, String value)
- {
- return new org.jboss.portal.wsrp.core.LocalizedString(language, resourceName, value);
- }
-
/**
* Retrieves the best (according to the specified desired locales) value for the given localized portlet metadata.
*
@@ -298,7 +307,7 @@
Locale locale = bestMapping.getLocale();
String value = bestMapping.getString();
String language = LocaleInfo.decodeLocaleInfo(locale).getRFC3066LanguageTag();
- return createWSRPLocalizedString(language, null, value);
+ return WSRPTypeFactory.createLocalizedString(language, null, value);
}
return null;
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java 2006-11-09 23:09:50 UTC (rev 5617)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java 2006-11-10 07:41:15 UTC (rev 5618)
@@ -23,7 +23,6 @@
package org.jboss.portal.wsrp.producer;
-import org.jboss.invocation.Invocation;
import org.jboss.logging.Logger;
import org.jboss.portal.jems.as.system.AbstractJBossService;
import org.jboss.portal.portlet.NoSuchPortletException;
@@ -63,7 +62,6 @@
import org.jboss.portal.wsrp.core.PortletDescriptionResponse;
import org.jboss.portal.wsrp.core.PortletPropertyDescriptionResponse;
import org.jboss.portal.wsrp.core.PortletStateChangeRequiredFault;
-import org.jboss.portal.wsrp.core.PropertyDescription;
import org.jboss.portal.wsrp.core.PropertyList;
import org.jboss.portal.wsrp.core.RegistrationContext;
import org.jboss.portal.wsrp.core.RegistrationData;
@@ -76,10 +74,11 @@
import org.jboss.portal.wsrp.core.UnsupportedMimeTypeFault;
import org.jboss.portal.wsrp.core.UnsupportedModeFault;
import org.jboss.portal.wsrp.core.UnsupportedWindowStateFault;
+import org.jboss.portal.wsrp.producer.registration.RegistrationMetaData;
+import org.jboss.portal.wsrp.producer.registration.RegistrationPolicy;
import org.jboss.portal.wsrp.servlet.ServletAccess;
import javax.servlet.http.HttpSession;
-import java.lang.reflect.Method;
import java.rmi.RemoteException;
import java.util.HashMap;
import java.util.HashSet;
@@ -112,6 +111,9 @@
/** Handles Portlet Management interface calls. */
private PortletManagementHandler portletManagementHandler;
+ /** The RegistrationPolicy to be used by the registration handler. */
+ private RegistrationPolicy registrationPolicy;
+
/**
* The ServiceDescription that is returned to an unregistred Consumer when registration is required: no information
* is provided apart from the fact that registration is required and what information is required to sucessfully
@@ -121,12 +123,6 @@
*/
private final ServiceDescription requiredRegistrationNotProvidedSD;
- /**
- * <code>true</code> if registration is required to access this Producer's information and services,
- * <code>false</code> otherwise. Note: server-side registration is not supported in 2.4
- */
- private boolean requiresRegistration;
-
private int sessionExpirationTime = DEFAULT_SESSION_EXPIRATION_TIME;
private CookieProtocol requiresInitCookie = CookieProtocol.none;
@@ -142,7 +138,6 @@
public WSRPProducerImpl()
{
- requiresRegistration = false;
requiredRegistrationInfo = initRequiredRegistrationInfo();
requiredRegistrationNotProvidedSD = initRegistrationNotProvidedServiceDescription();
markupHandler = new MarkupHandler(this);
@@ -152,6 +147,11 @@
sessionManager = new SessionManager();
}
+ public RegistrationMetaData getRegistrationMetaData()
+ {
+ return registrationPolicy.getRegistrationMetaData();
+ }
+
// ServiceDescription implementation ********************************************************************************
public ServiceDescription getServiceDescription(GetServiceDescription gs)
@@ -252,6 +252,17 @@
return registrationState;
}
+ public RegistrationPolicy getRegistrationPolicy()
+ {
+ return registrationPolicy;
+ }
+
+ public void setRegistrationPolicy(RegistrationPolicy registrationPolicy)
+ {
+ this.registrationPolicy = registrationPolicy;
+ registrationHandler.setPolicy(registrationPolicy);
+ }
+
// PortletManagement implementation *********************************************************************************
public PortletDescriptionResponse getPortletDescription(GetPortletDescription getPortletDescription)
@@ -315,16 +326,6 @@
// Producer implementation ******************************************************************************************
- public void setRequiresRegistration(boolean requiresRegistration)
- {
- this.requiresRegistration = requiresRegistration;
- }
-
- public boolean isRequiresRegistration()
- {
- return requiresRegistration;
- }
-
public CookieProtocol getRequiresInitCookie()
{
return requiresInitCookie;
@@ -385,12 +386,12 @@
}
catch (NoSuchPortletException e)
{
- throw(InvalidHandleFault)WSRPUtils.createFaultFrom(InvalidHandleFault.class,
+ throw (InvalidHandleFault)WSRPUtils.createFaultFrom(InvalidHandleFault.class,
new IllegalArgumentException("Couldn't find portlet with handle: " + handle));
}
if (!isRemotable(portlet))
{
- throw(InvalidHandleFault)WSRPUtils.createFaultFrom(InvalidHandleFault.class,
+ throw (InvalidHandleFault)WSRPUtils.createFaultFrom(InvalidHandleFault.class,
new IllegalArgumentException("Portlet with handle: " + handle + " is not remotely available."));
}
@@ -420,38 +421,16 @@
return serviceDescriptionHandler.getPortletDescription(handle, locales);
}
- public void addRegistrationProperty(PropertyDescription propertyDescription)
- {
- PropertyDescription[] descriptions = requiredRegistrationInfo.getPropertyDescriptions();
- if (descriptions == null)
- {
- descriptions = new PropertyDescription[]{propertyDescription};
- requiredRegistrationInfo.setPropertyDescriptions(descriptions);
- }
- else
- {
- PropertyDescription[] newDescs = new PropertyDescription[descriptions.length + 1];
- System.arraycopy(descriptions, 0, newDescs, 0, descriptions.length);
- newDescs[descriptions.length] = propertyDescription;
- requiredRegistrationInfo.setPropertyDescriptions(newDescs);
- }
- }
-
- public void clearRegistrationProperties()
- {
- requiredRegistrationInfo.setPropertyDescriptions(null);
- }
-
// Contract with Invoker implementation *****************************************************************************
/** Dispatch the invocation to the target by reflection */
- public Object invoke(Invocation invocation) throws Exception
+ /*public Object invoke(Invocation invocation) throws Exception
{
Method method = invocation.getMethod();
Object[] args = invocation.getArguments();
log.debug("invoke invoked: method=" + method + " args=" + args);
return method.invoke(this, args);
- }
+ }*/
// Protected methods ************************************************************************************************
@@ -464,34 +443,17 @@
*/
protected boolean isRegistrationValid(RegistrationContext registrationContext) throws InvalidRegistrationFault
{
- if (isRequiresRegistration())
- {
- log.debug("registration required: checking registration");
- // todo: implement more completely
- if (registrationContext == null)
- {
- log.debug("Registration is invalid");
- return false;
- }
-
- String regHandle = registrationContext.getRegistrationHandle();
- if (regHandle == null)
- {
- throw(InvalidRegistrationFault)WSRPUtils.createFaultFrom(InvalidRegistrationFault.class,
- new IllegalArgumentException("Missing required registration handle is not a valid registration."));
- }
- log.debug("registration is valid");
- }
- return true;
+ return registrationHandler.isRegistrationValid(registrationContext);
}
- protected void checkRegistration(RegistrationContext registrationContext)
- throws InvalidRegistrationFault
+ protected void checkRegistration(RegistrationContext registrationContext) throws InvalidRegistrationFault
{
if (!isRegistrationValid(registrationContext))
{
- throw(InvalidRegistrationFault)WSRPUtils.createFaultFrom(InvalidRegistrationFault.class,
- new IllegalArgumentException(registrationContext + " is not a valid registration."));
+ IllegalArgumentException cause = new IllegalArgumentException(registrationContext + " is not a valid registration.");
+ log.debug(cause);
+ throw (InvalidRegistrationFault)WSRPUtils.createFaultFrom(InvalidRegistrationFault.class,
+ cause);
}
}
@@ -565,6 +527,11 @@
return false;
}
+ public String[] getSupportedLocales()
+ {
+ return supportedLocales; // todo: avoid hardcoding this at some point...
+ }
+
private class SessionManager
{
private Map sessions = new HashMap();
Added: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/LocalizedString.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/LocalizedString.java 2006-11-09 23:09:50 UTC (rev 5617)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/LocalizedString.java 2006-11-10 07:41:15 UTC (rev 5618)
@@ -0,0 +1,82 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.wsrp.producer.registration;
+
+import java.util.Locale;
+
+/**
+ * @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class LocalizedString
+{
+ private String value;
+ private Locale locale;
+ private String resourceName;
+
+
+ public LocalizedString(String value, Locale locale)
+ {
+ this.value = value;
+ this.locale = locale;
+ }
+
+
+ public LocalizedString(String value)
+ {
+ this.value = value;
+ this.locale = Locale.getDefault();
+ }
+
+ public String getValue()
+ {
+ return value;
+ }
+
+ public void setValue(String value)
+ {
+ this.value = value;
+ }
+
+ public Locale getLocale()
+ {
+ return locale;
+ }
+
+ public void setLocale(Locale locale)
+ {
+ this.locale = locale;
+ }
+
+ public String getResourceName()
+ {
+ return resourceName;
+ }
+
+ public void setResourceName(String resourceName)
+ {
+ this.resourceName = resourceName;
+ }
+}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/Registration.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/Registration.java 2006-11-09 23:09:50 UTC (rev 5617)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/Registration.java 2006-11-10 07:41:15 UTC (rev 5618)
@@ -23,7 +23,8 @@
package org.jboss.portal.wsrp.producer.registration;
-import org.jboss.portal.portlet.state.PropertyMap;
+import javax.xml.namespace.QName;
+import java.util.Map;
/**
* A class representing an association between a consumer and a producer.
@@ -52,10 +53,18 @@
/**
* Retrieve the properties associated with this Registration.
*
- * @return a PropertyMap containing the associated properties
+ * @return a Map containing the associated properties
*/
- PropertyMap getProperties();
+ Map getProperties();
+ void setPropertyValueFor(QName propertyName, Object value);
+
+ void setPropertyValueFor(String propertyName, Object value);
+
+ boolean hasEqualProperties(Registration registration);
+
+ boolean hasEqualProperties(Map properties);
+
/**
* Return the status of this specific registration.
*
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/RegistrationMetaData.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/RegistrationMetaData.java 2006-11-09 23:09:50 UTC (rev 5617)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/RegistrationMetaData.java 2006-11-10 07:41:15 UTC (rev 5618)
@@ -23,6 +23,9 @@
package org.jboss.portal.wsrp.producer.registration;
+import javax.xml.namespace.QName;
+import java.util.Map;
+
/**
* @author <a href="mailto:chris.laprun at jboss.com?subject=org.jboss.portal.wsrp.producer.registration.RegistrationMetadata">Chris
* Laprun</a>
@@ -32,4 +35,28 @@
public interface RegistrationMetaData
{
boolean requiresMarshalling();
+
+ void setRequiresMarshalling(boolean requiresMarshalling);
+
+ boolean requiresRegistration();
+
+ void setRequiresRegistration(boolean requiresRegistration);
+
+ boolean fullServiceDescriptionRequiresRegistration();
+
+ void setFullServiceDescriptionRequiresRegistration(boolean fullServiceDescriptionRequiresRegistration);
+
+ Map getRegistrationProperties();
+
+ void addRegistrationProperty(RegistrationPropertyDescription propertyDescription);
+
+ void removeRegistrationProperty(String propertyName);
+
+ void removeRegistrationProperty(QName propertyName);
+
+ void clearRegistrationProperties();
+
+ boolean acceptValueFor(Object value, QName propertyName);
+
+ boolean acceptValueFor(Object value, String propertyName);
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/RegistrationPolicy.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/RegistrationPolicy.java 2006-11-09 23:09:50 UTC (rev 5617)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/RegistrationPolicy.java 2006-11-10 07:41:15 UTC (rev 5618)
@@ -45,13 +45,6 @@
*/
Registration registerConsumerWith(RegistrationData registrationData) throws RegistrationException;
- /**
- * Determines whether Registrations administered by this RegistrationPolicy needs to be marshalled to the Consumer.
- *
- * @return <code>true</code> if Registrations need to be marshalled, <code>false</code> otherwise.
- */
- boolean requireRegistrationMarshalling();
-
ConsumerRegistry getConsumerRegistry();
void setConsumerRegistry(ConsumerRegistry consumerRegistry);
Added: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/RegistrationPropertyDescription.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/RegistrationPropertyDescription.java 2006-11-09 23:09:50 UTC (rev 5617)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/RegistrationPropertyDescription.java 2006-11-10 07:41:15 UTC (rev 5618)
@@ -0,0 +1,151 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.wsrp.producer.registration;
+
+import javax.xml.namespace.QName;
+import java.net.URI;
+
+/**
+ * @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class RegistrationPropertyDescription
+{
+ private QName name;
+ private QName type;
+ private URI schemaLocation;
+ private LocalizedString description;
+ private LocalizedString hint;
+ private LocalizedString label;
+ private String[] usages;
+ private QName[] aliases;
+
+
+ public RegistrationPropertyDescription(QName name, QName type)
+ {
+ this.name = name;
+ this.type = type;
+ }
+
+ public RegistrationPropertyDescription(String name, QName type)
+ {
+ this(new QName(name), type);
+ }
+
+ public QName getName()
+ {
+ return name;
+ }
+
+ public void setName(QName name)
+ {
+ this.name = name;
+ }
+
+ public QName getType()
+ {
+ return type;
+ }
+
+ public void setType(QName type)
+ {
+ this.type = type;
+ }
+
+ public URI getSchemaLocation()
+ {
+ return schemaLocation;
+ }
+
+ public void setSchemaLocation(URI schemaLocation)
+ {
+ this.schemaLocation = schemaLocation;
+ }
+
+ public LocalizedString getDescription()
+ {
+ return description;
+ }
+
+ public void setDescription(LocalizedString description)
+ {
+ this.description = description;
+ }
+
+ public void setDefaultDescription(String value)
+ {
+ setDescription(new LocalizedString(value));
+ }
+
+ public LocalizedString getHint()
+ {
+ return hint;
+ }
+
+ public void setHint(LocalizedString hint)
+ {
+ this.hint = hint;
+ }
+
+ public void setDefaultHint(String value)
+ {
+ setHint(new LocalizedString(value));
+ }
+
+ public LocalizedString getLabel()
+ {
+ return label;
+ }
+
+ public void setLabel(LocalizedString label)
+ {
+ this.label = label;
+ }
+
+ public void setDefaultLabel(String value)
+ {
+ setLabel(new LocalizedString(value));
+ }
+
+ public String[] getUsages()
+ {
+ return usages;
+ }
+
+ public void setUsages(String[] usages)
+ {
+ this.usages = usages;
+ }
+
+ public QName[] getAliases()
+ {
+ return aliases;
+ }
+
+ public void setAliases(QName[] aliases)
+ {
+ this.aliases = aliases;
+ }
+}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationImpl.java 2006-11-09 23:09:50 UTC (rev 5617)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationImpl.java 2006-11-10 07:41:15 UTC (rev 5618)
@@ -24,12 +24,17 @@
package org.jboss.portal.wsrp.producer.registration.impl;
import org.jboss.portal.common.util.ParameterValidation;
-import org.jboss.portal.portlet.state.PropertyMap;
import org.jboss.portal.wsrp.producer.registration.Consumer;
import org.jboss.portal.wsrp.producer.registration.Registration;
import org.jboss.portal.wsrp.producer.registration.RegistrationMetaData;
import org.jboss.portal.wsrp.producer.registration.RegistrationStatus;
+import javax.xml.namespace.QName;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
/**
* @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
* @version $Revision$
@@ -41,7 +46,7 @@
private Consumer consumer;
private RegistrationStatus status;
private RegistrationMetaData metadata;
- private PropertyMap properties;
+ private Map properties;
public RegistrationImpl(String handle, Consumer consumer, RegistrationStatus status, RegistrationMetaData metadata)
@@ -50,6 +55,7 @@
this.consumer = consumer;
this.status = status;
this.metadata = metadata;
+ properties = new HashMap(7);
}
public String getRegistrationHandle()
@@ -62,11 +68,75 @@
return consumer;
}
- public PropertyMap getProperties()
+ public Map getProperties()
{
- return null; //To change body of implemented methods use File | Settings | File Templates.
+ return Collections.unmodifiableMap(properties);
}
+ public void setPropertyValueFor(QName propertyName, Object value)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(propertyName, "Property name");
+ ParameterValidation.throwIllegalArgExceptionIfNull(value, "Property value");
+
+ if (metadata.acceptValueFor(value, propertyName))
+ {
+ properties.put(propertyName, value);
+ }
+ else
+ {
+ throw new IllegalArgumentException(value + " is not an acceptable value for property named '" + propertyName + "'");
+ }
+ }
+
+ public void setPropertyValueFor(String propertyName, Object value)
+ {
+ setPropertyValueFor(new QName(propertyName), value);
+ }
+
+ public boolean hasEqualProperties(Registration registration)
+ {
+ if (registration == null)
+ {
+ return false;
+ }
+
+ Map other = registration.getProperties();
+ return hasEqualProperties(other);
+ }
+
+ public boolean hasEqualProperties(Map registrationProperties)
+ {
+ if (registrationProperties == null)
+ {
+ return false;
+ }
+
+ if (properties.size() != registrationProperties.size())
+ {
+ return false;
+ }
+
+ // check properties
+ for (Iterator props = properties.entrySet().iterator(); props.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry)props.next();
+
+ // we should have a 1-1 match between name/value pair
+ QName name = (QName)entry.getKey();
+ if (!entry.getValue().equals(registrationProperties.get(name)))
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ public void setRegistrationPropertyValueFor(String propertyName, Object value)
+ {
+ setPropertyValueFor(new QName(propertyName), value);
+ }
+
public RegistrationStatus getStatus()
{
return status;
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationMetaDataImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationMetaDataImpl.java 2006-11-09 23:09:50 UTC (rev 5617)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationMetaDataImpl.java 2006-11-10 07:41:15 UTC (rev 5618)
@@ -23,8 +23,15 @@
package org.jboss.portal.wsrp.producer.registration.impl;
+import org.jboss.portal.common.util.ParameterValidation;
import org.jboss.portal.wsrp.producer.registration.RegistrationMetaData;
+import org.jboss.portal.wsrp.producer.registration.RegistrationPropertyDescription;
+import javax.xml.namespace.QName;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
/**
* @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
* @version $Revision$
@@ -33,14 +40,91 @@
public class RegistrationMetaDataImpl implements RegistrationMetaData
{
private boolean requiresMarshalling;
+ private boolean requiresRegistration;
+ private boolean fullServiceDescriptionRequiresRegistration;
- public RegistrationMetaDataImpl(boolean requiresMarshalling)
+ /** property name (QName) -> PropertyDescription */
+ private Map registrationProperties;
+
+ public RegistrationMetaDataImpl(boolean requiresMarshalling, boolean requiresRegistration, boolean fullServiceDescriptionRequiresRegistration)
{
this.requiresMarshalling = requiresMarshalling;
+ this.requiresRegistration = requiresRegistration;
+ this.fullServiceDescriptionRequiresRegistration = fullServiceDescriptionRequiresRegistration;
+ registrationProperties = new HashMap(7);
}
public boolean requiresMarshalling()
{
return requiresMarshalling;
}
+
+ public void setRequiresMarshalling(boolean requiresMarshalling)
+ {
+ this.requiresMarshalling = requiresMarshalling;
+ }
+
+ public boolean requiresRegistration()
+ {
+ return requiresRegistration;
+ }
+
+ public void setRequiresRegistration(boolean requiresRegistration)
+ {
+ this.requiresRegistration = requiresRegistration;
+ }
+
+ public boolean fullServiceDescriptionRequiresRegistration()
+ {
+ return fullServiceDescriptionRequiresRegistration;
+ }
+
+ public void setFullServiceDescriptionRequiresRegistration(boolean fullServiceDescriptionRequiresRegistration)
+ {
+ this.fullServiceDescriptionRequiresRegistration = fullServiceDescriptionRequiresRegistration;
+ }
+
+ public Map getRegistrationProperties()
+ {
+ return Collections.unmodifiableMap(registrationProperties);
+ }
+
+ public void addRegistrationProperty(RegistrationPropertyDescription propertyDescription)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(propertyDescription, "PropertyDescription");
+ registrationProperties.put(propertyDescription.getName(), propertyDescription);
+ }
+
+ public boolean acceptValueFor(Object value, QName propertyName)
+ {
+ QName type = getPropertyDescription(propertyName).getType();
+ // todo: decide if type is actually compatible with value...
+ return true;
+ }
+
+ public boolean acceptValueFor(Object value, String propertyName)
+ {
+ return acceptValueFor(value, new QName(propertyName));
+ }
+
+ private RegistrationPropertyDescription getPropertyDescription(QName propertyName)
+ {
+ return (RegistrationPropertyDescription)registrationProperties.get(propertyName);
+ }
+
+ public void removeRegistrationProperty(QName propertyName)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(propertyName, "Property name");
+ registrationProperties.remove(propertyName);
+ }
+
+ public void clearRegistrationProperties()
+ {
+ registrationProperties.clear();
+ }
+
+ public void removeRegistrationProperty(String propertyName)
+ {
+ removeRegistrationProperty(new QName(propertyName));
+ }
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/policies/BasicRegistrationPolicy.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/policies/BasicRegistrationPolicy.java 2006-11-09 23:09:50 UTC (rev 5617)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/policies/BasicRegistrationPolicy.java 2006-11-10 07:41:15 UTC (rev 5618)
@@ -24,9 +24,7 @@
package org.jboss.portal.wsrp.producer.registration.policies;
import org.jboss.portal.common.util.ParameterValidation;
-import org.jboss.portal.common.value.StringValue;
-import org.jboss.portal.portlet.state.PropertyMap;
-import org.jboss.portal.portlet.state.SimplePropertyMap;
+import org.jboss.portal.jems.as.system.AbstractJBossService;
import org.jboss.portal.wsrp.core.Property;
import org.jboss.portal.wsrp.core.RegistrationData;
import org.jboss.portal.wsrp.producer.registration.Consumer;
@@ -40,11 +38,19 @@
import org.jboss.portal.wsrp.producer.registration.RegistrationStatus;
import org.jboss.portal.wsrp.producer.registration.impl.ConsumerImpl;
import org.jboss.portal.wsrp.producer.registration.impl.ConsumerMetaDataImpl;
+import org.jboss.portal.wsrp.producer.registration.impl.ConsumerRegistryImpl;
import org.jboss.portal.wsrp.producer.registration.impl.RegistrationImpl;
+import org.jboss.portal.wsrp.producer.registration.impl.RegistrationMetaDataImpl;
+import org.jboss.portal.wsrp.producer.registration.impl.RegistrationRegistryImpl;
+import javax.xml.namespace.QName;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
/**
* @author <a href="mailto:chris.laprun at jboss.com?subject=org.jboss.portal.wsrp.producer.registration.policies.BasicRegistrationPolicy">Chris
@@ -52,7 +58,7 @@
* @version $Revision$
* @since 2.6
*/
-public class BasicRegistrationPolicy implements RegistrationPolicy
+public class BasicRegistrationPolicy extends AbstractJBossService implements RegistrationPolicy
{
protected RegistrationRegistry registrationRegistry;
protected ConsumerRegistry consumerRegistry;
@@ -60,6 +66,14 @@
protected RegistrationMetaData metadata;
private static long lastHandle = 0;
+
+ public BasicRegistrationPolicy()
+ {
+ consumerRegistry = new ConsumerRegistryImpl();
+ registrationRegistry = new RegistrationRegistryImpl();
+ metadata = new RegistrationMetaDataImpl(false, true, false);
+ }
+
public Registration registerConsumerWith(RegistrationData registrationData) throws RegistrationException
{
Registration registration = createRegistrationFor(registrationData);
@@ -78,12 +92,6 @@
return registration;
}
- public boolean requireRegistrationMarshalling()
- {
- return metadata.requiresMarshalling();
- }
-
-
public ConsumerRegistry getConsumerRegistry()
{
return consumerRegistry;
@@ -139,7 +147,8 @@
// a consumer already exists with that name, we need to check that we can allow a new registration
if (consumer != null)
{
- PropertyMap properties = createProperties(registrationData);
+ log.debug("Consumer named '" + name + "' already exists. Checking that we can add a new Registration.");
+ Map props = createRegistrationProperties(registrationData);
// allow the new registration only if the registration properties are different that existing registrations
// for this consumer...
@@ -147,7 +156,7 @@
for (Iterator iterator = registrations.iterator(); iterator.hasNext();)
{
Registration registration = (Registration)iterator.next();
- if (registration.getProperties().equals(properties)) // todo: need to implement equals on TypedMap
+ if (registration.hasEqualProperties(props))
{
throw new RegistrationException("Consumer named '" + name
+ "' has already been registered with the same set of registration properties. Registration rejected!");
@@ -157,9 +166,10 @@
else
{
ConsumerMetaDataImpl metadata = new ConsumerMetaDataImpl(registrationData.getConsumerAgent(),
- registrationData.isMethodGetSupported(), Arrays.asList(registrationData.getConsumerModes()),
- Arrays.asList(registrationData.getConsumerWindowStates()), Arrays.asList(registrationData.getConsumerUserScopes()),
- Arrays.asList(registrationData.getCustomUserProfileData()));
+ registrationData.isMethodGetSupported(), getListFromArray(registrationData.getConsumerModes()),
+ getListFromArray(registrationData.getConsumerWindowStates()),
+ getListFromArray(registrationData.getConsumerUserScopes()),
+ getListFromArray(registrationData.getCustomUserProfileData()));
consumer = new ConsumerImpl(name, metadata);
consumerRegistry.addConsumer(consumer);
@@ -180,17 +190,27 @@
return "" + lastHandle++;
}
- private PropertyMap createProperties(RegistrationData registrationData)
+ private Map createRegistrationProperties(RegistrationData registrationData)
{
Property[] regProperties = registrationData.getRegistrationProperties();
- PropertyMap properties = new SimplePropertyMap();
+ Map properties = new HashMap(regProperties.length);
for (int i = 0; i < regProperties.length; i++)
{
Property property = regProperties[i];
// todo: should be more detailed here... use the language, allow other value types...
- properties.setProperty(property.getName(), new StringValue(property.getStringValue()));
+ properties.put(new QName(property.getName()), property.getStringValue());
}
+
return properties;
}
+
+ private List getListFromArray(String[] array)
+ {
+ if (array == null)
+ {
+ return Collections.EMPTY_LIST;
+ }
+ return Arrays.asList(array);
+ }
}
Modified: trunk/wsrp/src/resources/portal-wsrp-sar/META-INF/jboss-service.xml
===================================================================
--- trunk/wsrp/src/resources/portal-wsrp-sar/META-INF/jboss-service.xml 2006-11-09 23:09:50 UTC (rev 5617)
+++ trunk/wsrp/src/resources/portal-wsrp-sar/META-INF/jboss-service.xml 2006-11-10 07:41:15 UTC (rev 5618)
@@ -77,6 +77,7 @@
xmbean-dd=""
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
<xmbean/>
+ <depends optional-attribute-name="RegistrationPolicy" proxy-type="attribute">portal.wsrp:service=RegistrationPolicy</depends>
<depends optional-attribute-name="Invoker"
proxy-type="attribute">portal:service=PortletInvoker,type=WSRPProducer</depends>
</mbean>
@@ -88,5 +89,12 @@
<attribute name="DefaultWSRPLocation">default-wsrp.xml</attribute>
<depends optional-attribute-name="FederatingPortletInvoker" proxy-type="attribute">portal:service=PortletInvoker,type=Federating</depends>
</mbean>
+
+ <!-- Registration policy -->
+ <mbean code="org.jboss.portal.wsrp.producer.registration.policies.BasicRegistrationPolicy"
+ name="portal.wsrp:service=RegistrationPolicy" xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ </mbean>
</server>
Modified: trunk/wsrp/src/resources/tests/test-wsrp-producer-sar/META-INF/jboss-service.xml
===================================================================
--- trunk/wsrp/src/resources/tests/test-wsrp-producer-sar/META-INF/jboss-service.xml 2006-11-09 23:09:50 UTC (rev 5617)
+++ trunk/wsrp/src/resources/tests/test-wsrp-producer-sar/META-INF/jboss-service.xml 2006-11-10 07:41:15 UTC (rev 5618)
@@ -174,9 +174,17 @@
<depends
optional-attribute-name="Invoker"
proxy-type="attribute">portal:service=PortletInvoker,type=Stateful</depends>
+ <depends optional-attribute-name="RegistrationPolicy" proxy-type="attribute">portal.wsrp:service=RegistrationPolicy</depends>
<attribute name="RemotableByDefault">true</attribute>
</mbean>
+ <!-- Use BasicRegistrationPolicy for registration -->
+ <mbean code="org.jboss.portal.wsrp.producer.registration.policies.BasicRegistrationPolicy"
+ name="portal.wsrp:service=RegistrationPolicy" xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ </mbean>
+
<!-- Hack to get access to req/resp -->
<mbean
code="org.jboss.portal.wsrp.servlet.ServletAccessService"
More information about the jboss-svn-commits
mailing list