Author: chris.laprun(a)jboss.com
Date: 2009-04-10 07:04:35 -0400 (Fri, 10 Apr 2009)
New Revision: 13202
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java
Log:
- Producer can now validate registration properties. Of course, current implementation of
acceptValueFor is no-op, so...
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java 2009-04-10
08:50:44 UTC (rev 13201)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java 2009-04-10
11:04:35 UTC (rev 13202)
@@ -1,6 +1,6 @@
/******************************************************************************
* JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * Copyright 2009, 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. *
@@ -256,7 +256,7 @@
if (producer.getProducerRegistrationRequirements().isRegistrationRequired())
{
log.debug("Registration is required yet no RegistrationContext was
provided: registration invalid!");
- if(throwExceptionIfInvalid)
+ if (throwExceptionIfInvalid)
{
throwInvalidRegistrationFault("registration is required yet no
RegistrationContext was provided!");
}
@@ -348,23 +348,32 @@
"Invalid registration: " + message, null);
}
- private Map createRegistrationProperties(RegistrationData registrationData)
+ private Map<QName, Object> createRegistrationProperties(RegistrationData
registrationData)
{
Property[] regProperties = registrationData.getRegistrationProperties();
- Map properties;
+ Map<QName, Object> properties;
if (regProperties != null)
{
- properties = new HashMap(regProperties.length);
- for (int i = 0; i < regProperties.length; i++)
+ properties = new HashMap<QName, Object>(regProperties.length);
+ for (Property property : regProperties)
{
- Property property = regProperties[i];
// todo: should be more detailed here... use the language, allow other value
types...
- properties.put(new QName(property.getName()), property.getStringValue());
+ QName propName = new QName(property.getName());
+ String propValue = property.getStringValue();
+ if (producer.getProducerRegistrationRequirements().acceptValueFor(propName,
propValue))
+ {
+ properties.put(propName, propValue);
+ }
+ else
+ {
+ throw new IllegalArgumentException("Registration properties named
'" + propName + "' with value '"
+ + propValue + "' was rejected by the WSRP producer.");
+ }
}
}
else
{
- properties = Collections.EMPTY_MAP;
+ properties = Collections.emptyMap();
}
return properties;