Author: chris.laprun(a)jboss.com
Date: 2008-07-10 07:58:54 -0400 (Thu, 10 Jul 2008)
New Revision: 11405
Modified:
branches/JBoss_Portal_Branch_2_6/registration/src/main/org/jboss/portal/registration/RegistrationPolicy.java
branches/JBoss_Portal_Branch_2_6/registration/src/main/org/jboss/portal/registration/policies/DefaultRegistrationPolicy.java
branches/JBoss_Portal_Branch_2_6/registration/src/main/org/jboss/portal/test/registration/RegistrationTestCase.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/config/TestRegistrationPolicy.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
Log:
- Do not check for duplicate registration if the registration is currently pending.
- Transparently call modifyRegistration if we detect a rare situation where it might be
needed.
- Generification.
Modified:
branches/JBoss_Portal_Branch_2_6/registration/src/main/org/jboss/portal/registration/RegistrationPolicy.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/registration/src/main/org/jboss/portal/registration/RegistrationPolicy.java 2008-07-10
11:51:37 UTC (rev 11404)
+++
branches/JBoss_Portal_Branch_2_6/registration/src/main/org/jboss/portal/registration/RegistrationPolicy.java 2008-07-10
11:58:54 UTC (rev 11405)
@@ -49,8 +49,8 @@
* @throws IllegalArgumentException if any of the registration properties is invalid
for the specified Consumer
* @throws RegistrationException if an exception occured in the registration
service
*/
- void validateRegistrationDataFor(Map registrationProperties, String consumerIdentity)
- throws IllegalArgumentException, RegistrationException;
+ void validateRegistrationDataFor(Map<QName, ? extends PropertyDescription>
registrationProperties, String consumerIdentity)
+ throws IllegalArgumentException, RegistrationException;
/**
* Generates a registration handle based on the database identity of the Registration.
This allows users to customize
@@ -90,7 +90,7 @@
* @throws IllegalArgumentException if the specified Consumer name if
<code>null</code> or empty
*/
String getConsumerIdFrom(String consumerName, Map registrationProperties)
- throws IllegalArgumentException, InvalidConsumerDataException;
+ throws IllegalArgumentException, InvalidConsumerDataException;
/**
* Determines if the specified Consumer name is acceptable. This method is called
before a Consumer is created and
@@ -102,7 +102,7 @@
* @throws RegistrationException if an exception occurred in the Registration
service
*/
void validateConsumerName(String consumerName)
- throws IllegalArgumentException, RegistrationException;
+ throws IllegalArgumentException, RegistrationException;
/**
* Determines if the specified ConsumerGroup name is acceptable. This method is called
before a ConsumerGroup is
Modified:
branches/JBoss_Portal_Branch_2_6/registration/src/main/org/jboss/portal/registration/policies/DefaultRegistrationPolicy.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/registration/src/main/org/jboss/portal/registration/policies/DefaultRegistrationPolicy.java 2008-07-10
11:51:37 UTC (rev 11404)
+++
branches/JBoss_Portal_Branch_2_6/registration/src/main/org/jboss/portal/registration/policies/DefaultRegistrationPolicy.java 2008-07-10
11:58:54 UTC (rev 11405)
@@ -33,6 +33,7 @@
import org.jboss.portal.registration.RegistrationException;
import org.jboss.portal.registration.RegistrationManager;
import org.jboss.portal.registration.RegistrationPolicy;
+import org.jboss.portal.registration.RegistrationStatus;
import javax.xml.namespace.QName;
import java.util.Collections;
@@ -77,8 +78,8 @@
* @throws DuplicateRegistrationException if a Consumer with the same identity has
already registered with the same
* registration properties.
*/
- public void validateRegistrationDataFor(Map registrationProperties, String
consumerIdentity)
- throws IllegalArgumentException, RegistrationException,
DuplicateRegistrationException
+ public void validateRegistrationDataFor(Map<QName, ? extends
PropertyDescription> registrationProperties, String consumerIdentity)
+ throws IllegalArgumentException, RegistrationException
{
ParameterValidation.throwIllegalArgExceptionIfNull(registrationProperties,
"Registration properties");
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(consumerIdentity,
"Consumer identity", null);
@@ -98,7 +99,7 @@
{
consistentWithExpectations = false;
message.append("Consumer '").append(consumerIdentity)
- .append("' provided values for unexpected registration
properties:\n");
+ .append("' provided values for unexpected registration
properties:\n");
for (QName name : unexpected)
{
message.append("\t- ").append(name).append("\n");
@@ -127,9 +128,9 @@
}
}
- // check that this is not a duplicate registration
+ // check that this is not a duplicate registration if the status is not pending
Consumer consumer = manager.getConsumerByIdentity(consumerIdentity);
- if (consumer != null)
+ if (consumer != null &&
!RegistrationStatus.PENDING.equals(consumer.getStatus()))
{
// allow the new registration only if the registration properties are different
that existing registrations
// for this consumer...
@@ -139,7 +140,7 @@
if (registration.hasEqualProperties(registrationProperties))
{
throw new DuplicateRegistrationException("Consumer named '"
+ consumer.getName()
- + "' has already been registered with the same set of
registration properties. Registration rejected!");
+ + "' has already been registered with the same set of
registration properties. Registration rejected!");
}
}
}
Modified:
branches/JBoss_Portal_Branch_2_6/registration/src/main/org/jboss/portal/test/registration/RegistrationTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/registration/src/main/org/jboss/portal/test/registration/RegistrationTestCase.java 2008-07-10
11:51:37 UTC (rev 11404)
+++
branches/JBoss_Portal_Branch_2_6/registration/src/main/org/jboss/portal/test/registration/RegistrationTestCase.java 2008-07-10
11:58:54 UTC (rev 11405)
@@ -25,6 +25,7 @@
import junit.framework.TestCase;
import org.jboss.portal.registration.DuplicateRegistrationException;
+import org.jboss.portal.registration.PropertyDescription;
import org.jboss.portal.registration.Registration;
import org.jboss.portal.registration.RegistrationException;
import org.jboss.portal.registration.RegistrationManager;
@@ -52,7 +53,7 @@
RegistrationManager manager = new RegistrationManagerImpl();
RegistrationPolicy policy = new DefaultRegistrationPolicy()
{
- public void validateRegistrationDataFor(Map registrationProperties, String
consumerIdentity) throws IllegalArgumentException, RegistrationException,
DuplicateRegistrationException
+ public void validateRegistrationDataFor(Map<QName, ? extends
PropertyDescription> registrationProperties, String consumerIdentity) throws
IllegalArgumentException, RegistrationException, DuplicateRegistrationException
{
// accept any registration data here
}
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/config/TestRegistrationPolicy.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/config/TestRegistrationPolicy.java 2008-07-10
11:51:37 UTC (rev 11404)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/config/TestRegistrationPolicy.java 2008-07-10
11:58:54 UTC (rev 11405)
@@ -39,7 +39,7 @@
*/
public class TestRegistrationPolicy implements RegistrationPolicy
{
- public void validateRegistrationDataFor(Map registrationProperties, String
consumerIdentity) throws IllegalArgumentException, RegistrationException
+ public void validateRegistrationDataFor(Map<QName, ? extends
PropertyDescription> registrationProperties, String consumerIdentity) throws
IllegalArgumentException, RegistrationException
{
}
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2008-07-10
11:51:37 UTC (rev 11404)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2008-07-10
11:58:54 UTC (rev 11405)
@@ -108,8 +108,6 @@
private boolean isModifyRegistrationRequired;
private ConsumerRegistry registry;
- private static final String REGISTER_MEANING = "Should clients ask for a new
service description?";
- private static final String REFRESH_MEANING = "Did just refresh?";
private static final String ERASED_LOCAL_REGISTRATION_INFORMATION = "Erased local
registration information!";
private Map<String, ItemDescription> customModes;
@@ -340,6 +338,13 @@
isModifyRegistrationRequired = true;
setActiveAndSave(false);
}
+ else
+ {
+ // we might be in a situation where the producer changed the
registration back to the initial state
+ // which is, granted, pretty rare... attempt modifyRegistration
+ log.debug("modifyRegistration was called after
OperationFailedFault when a check of registration data didn't reveal any
issue...");
+ modifyRegistration();
+ }
result.setRegistrationResult(registrationResult);
return result;
@@ -702,7 +707,7 @@
{
Throwable cause = e.getCause();
throw new InvokerUnavailableException("Problem getting service description for
producer "
- + persistentId + ", please see the logs for more information.",
cause == null ? e : cause);
+ + persistentId + ", please see the logs for more information. ",
cause == null ? e : cause);
}
private GetServiceDescription getServiceDescriptionRequest(boolean asUnregistred)
throws PortletInvokerException
@@ -835,11 +840,9 @@
String msg = "Consumer with id '" + persistentId +
"' successfully registered with handle: '"
+ registrationContext.getRegistrationHandle() +
"'";
log.debug(msg);
-// result.appendToStatus(msg);
RefreshResult res = new RefreshResult();
res.setRegistrationResult(result);
return res;
-// return new RefreshResult(result, true, REGISTER_MEANING);
}
catch (Exception e)
{
@@ -988,6 +991,5 @@
registry.updateProducerInfo(this);
log.warn(ERASED_LOCAL_REGISTRATION_INFORMATION);
- log.debug(ERASED_LOCAL_REGISTRATION_INFORMATION);
}
}