[portal-commits] JBoss Portal SVN: r8966 - in branches/JBoss_Portal_Branch_2_6: core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF and 12 other directories.

portal-commits at lists.jboss.org portal-commits at lists.jboss.org
Fri Nov 16 03:00:38 EST 2007


Author: chris.laprun at jboss.com
Date: 2007-11-16 03:00:38 -0500 (Fri, 16 Nov 2007)
New Revision: 8966

Added:
   branches/JBoss_Portal_Branch_2_6/registration/src/main/org/jboss/portal/registration/RegistrationPolicyChangeListener.java
Modified:
   branches/JBoss_Portal_Branch_2_6/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/BeanContext.java
   branches/JBoss_Portal_Branch_2_6/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java
   branches/JBoss_Portal_Branch_2_6/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ProducerBean.java
   branches/JBoss_Portal_Branch_2_6/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/faces-config.xml
   branches/JBoss_Portal_Branch_2_6/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/jsf/consumers/consumerTemplate.xhtml
   branches/JBoss_Portal_Branch_2_6/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/jsf/consumers/editConsumer.xhtml
   branches/JBoss_Portal_Branch_2_6/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/jsf/producer.xhtml
   branches/JBoss_Portal_Branch_2_6/registration/src/main/org/jboss/portal/registration/RegistrationManager.java
   branches/JBoss_Portal_Branch_2_6/registration/src/main/org/jboss/portal/registration/impl/RegistrationManagerImpl.java
   branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/other/RegistrationPropertyDescriptionTestCase.java
   branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/V1ProducerBaseTest.java
   branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/WSRPExceptionFactory.java
   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/producer/RegistrationHandler.java
   branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java
   branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/config/ProducerRegistrationRequirements.java
   branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/config/impl/ProducerConfigurationImpl.java
   branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/config/impl/ProducerRegistrationRequirementsImpl.java
   branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/registration/RegistrationPropertyDescription.java
Log:
- JBPORTAL-1567: Removed confusing portions of the consumer configuration screen. Needs more testing.
- Use h:message id="status" instead of h:messages for information as is done in other pages.
- JBPORTAL-1802: Added possibility to erase local registration data. Need to protect it with a confirmation screen as it's a 
  dangerous operation.
- JBPORTAL-1803: Added new "Producer Data" tab (currently inactive).
- JBPORTAL-1715: 
  + Tried alternate implementation (trying to only pass strings instead of QName and avoid using QNameConverter) but no dice... 
    Added ProducerRegistrationRequirements.addEmptyRegistrationProperty method and RegistrationPropertyDescription.nameAsString 
    property for that purpose.
  + Properly update the registration policy when the producer configuration is updated. This requires propagating the new policy 
    to the registration manager (done via RegistrationPolicyChangeListener)
- JBPORTAL-1804: RegistrationManager now set the status of registrations to PENDING instead of INVALID if registration properties 
  in the producer configuration have changed. RegistrationHandler.isRegistrationValid changed to support this.
- Optimization: Do not force a refresh of registration info when we register (as this was just done) in ProducerInfo.internalRefresh.
- Properly reset registration data if we receive an InvalidRegistrationFault when trying to retrieve the service description.
- Properly create a ProducerRegistrationRequirements if none exist instead of using a static variable (to avoid modifying the class 
  variable).
- Moved ProducerRegistrationRequirements code to Java 5, added support for RegistrationPolicyChangeListener, renamed 
  addRegistrationPropertyChangeListeners to addRegistrationPropertyChangeListener.


Modified: branches/JBoss_Portal_Branch_2_6/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/BeanContext.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/BeanContext.java	2007-11-16 02:50:10 UTC (rev 8965)
+++ branches/JBoss_Portal_Branch_2_6/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/BeanContext.java	2007-11-16 08:00:38 UTC (rev 8966)
@@ -30,6 +30,8 @@
  */
 public abstract class BeanContext
 {
+   private static final String STATUS = "status";
+
    protected abstract String getParameter(String key);
 
    protected abstract void createMessage(String target, String message, Object severity);
@@ -40,7 +42,7 @@
 
    protected void createErrorMessage(String message)
    {
-      createMessage(null, message, getErrorSeverity());
+      createMessage(STATUS, message, getErrorSeverity());
    }
 
    protected void createErrorMessage(String target, String message)
@@ -50,7 +52,7 @@
 
    protected void createErrorMessageFrom(Exception e)
    {
-      createErrorMessageFrom(null, e);
+      createErrorMessageFrom(STATUS, e);
    }
 
    protected void createErrorMessageFrom(String target, Exception e)

Modified: branches/JBoss_Portal_Branch_2_6/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java	2007-11-16 02:50:10 UTC (rev 8965)
+++ branches/JBoss_Portal_Branch_2_6/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java	2007-11-16 08:00:38 UTC (rev 8966)
@@ -307,16 +307,22 @@
 
    public String refreshConsumer()
    {
-      if (isModified())
+      if (consumer != null)
       {
-         String updateResult = update();
-         if (updateResult == null)
+         if (isModified())
          {
-            return null;
+            String updateResult = update();
+            if (updateResult == null)
+            {
+               return null;
+            }
          }
+
+         return manager.refreshConsumer();
       }
 
-      return manager.refreshConsumer();
+      beanContext.createErrorMessage("Couldn't save Consumer!");
+      return null;
    }
 
    public String refreshRegistrationInfo()
@@ -387,6 +393,18 @@
       return null;
    }
 
+   public String eraseLocalRegistration()
+   {
+      if (consumer != null)
+      {
+         getProducerInfo().eraseRegistrationInfo();
+         return null;
+      }
+
+      beanContext.createErrorMessage("Couldn't erase local Registration!");
+      return null;
+   }
+
    private Object modifyIfNeeded(Object oldValue, Object newValue, String target, boolean checkURL)
    {
       if ((oldValue != null && !oldValue.equals(newValue)) || (oldValue == null && newValue != null))

Modified: branches/JBoss_Portal_Branch_2_6/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ProducerBean.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ProducerBean.java	2007-11-16 02:50:10 UTC (rev 8965)
+++ branches/JBoss_Portal_Branch_2_6/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ProducerBean.java	2007-11-16 08:00:38 UTC (rev 8966)
@@ -25,7 +25,6 @@
 
 import org.jboss.portal.registration.RegistrationPolicy;
 import org.jboss.portal.registration.policies.DefaultRegistrationPolicy;
-import org.jboss.portal.wsrp.WSRPConstants;
 import org.jboss.portal.wsrp.producer.config.ProducerConfiguration;
 import org.jboss.portal.wsrp.producer.config.ProducerConfigurationService;
 import org.jboss.portal.wsrp.producer.config.ProducerRegistrationRequirements;
@@ -154,6 +153,10 @@
    {
       try
       {
+         if (!ProducerRegistrationRequirements.DEFAULT_POLICY_CLASS_NAME.equals(policyClassName))
+         {
+            getRegRequirements().reloadPolicyFrom(policyClassName, validatorClassName);
+         }
          configurationService.saveConfiguration();
       }
       catch (Exception e)
@@ -166,7 +169,7 @@
 
    public String addRegistrationProperty()
    {
-      getRegRequirements().addRegistrationProperty(new RegistrationPropertyDescription(PROPERTY + counter++, WSRPConstants.XSD_STRING));
+      getRegRequirements().addEmptyRegistrationProperty(PROPERTY + counter++);
       return PRODUCER;
    }
 }

Modified: branches/JBoss_Portal_Branch_2_6/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/faces-config.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/faces-config.xml	2007-11-16 02:50:10 UTC (rev 8965)
+++ branches/JBoss_Portal_Branch_2_6/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/faces-config.xml	2007-11-16 08:00:38 UTC (rev 8966)
@@ -36,10 +36,10 @@
       <converter-for-class>org.jboss.portal.wsrp.registration.LocalizedString</converter-for-class>
       <converter-class>org.jboss.portal.wsrp.admin.ui.LocalizedStringConverter</converter-class>
    </converter>
-   <converter>
+   <!--<converter>
       <converter-for-class>javax.xml.namespace.QName</converter-for-class>
       <converter-class>org.jboss.portal.wsrp.admin.ui.QNameConverter</converter-class>
-   </converter>
+   </converter>-->
 
    <managed-bean>
       <managed-bean-name>beanContext</managed-bean-name>
@@ -113,5 +113,5 @@
          <from-outcome>producer</from-outcome>
          <to-view-id>/WEB-INF/jsf/producer.xhtml</to-view-id>
       </navigation-case>
-   </navigation-rule>  
+   </navigation-rule>
 </faces-config>

Modified: branches/JBoss_Portal_Branch_2_6/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/jsf/consumers/consumerTemplate.xhtml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/jsf/consumers/consumerTemplate.xhtml	2007-11-16 02:50:10 UTC (rev 8965)
+++ branches/JBoss_Portal_Branch_2_6/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/jsf/consumers/consumerTemplate.xhtml	2007-11-16 08:00:38 UTC (rev 8966)
@@ -8,9 +8,8 @@
    <h:form>
       <ul class="topnav">
          <li id="currentTab">Consumers</li>
-         <li>
-            <h:commandLink value="Producer" action="producer"/>
-         </li>
+         <li><h:commandLink value="Producer Configuration" action="producer"/></li>
+         <li>Producer Data</li>
       </ul>
    </h:form>
 

Modified: branches/JBoss_Portal_Branch_2_6/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/jsf/consumers/editConsumer.xhtml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/jsf/consumers/editConsumer.xhtml	2007-11-16 02:50:10 UTC (rev 8965)
+++ branches/JBoss_Portal_Branch_2_6/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/jsf/consumers/editConsumer.xhtml	2007-11-16 08:00:38 UTC (rev 8966)
@@ -14,7 +14,6 @@
 <hr/>
 
 <h:form>
-<h:messages errorClass="portlet-msg-error" infoClass="portlet-msg-success"/>
 <table width="100%" class="portlet-table-body #{consumer.active ? 'active' : 'inactive'}">
 <tr>
    <th>Producer id:</th>
@@ -78,7 +77,7 @@
       </c:choose>
    </td>
 </tr>
-<c:if test="#{consumer.localInfoPresent or !consumer.refreshNeeded}">
+<c:if test="#{consumer.localInfoPresent}">
    <tr>
       <th>Registration information</th>
       <td>
@@ -120,40 +119,14 @@
    <c:if test="#{!empty consumer.producerInfo.registrationInfo.registrationHandle}">
       <tr>
          <th>Registration context:</th>
-         <td>Handle:
-            <h:outputText value="#{consumer.producerInfo.registrationInfo.registrationHandle}"/>
+         <td>
+            Handle: <h:outputText value="#{consumer.producerInfo.registrationInfo.registrationHandle}"/>
+            <h:commandLink action="#{consumer.eraseLocalRegistration}" value="Erase local registration"
+                           title="Erase local registration information (potentially dangerous!)"
+                           styleClass="portlet-form-button"/>
          </td>
       </tr>
    </c:if>
-   <c:choose>
-      <c:when test="#{consumer.registrationCheckNeeded}">
-         <tr>
-            <td colspan="2">
-               <p class="portlet-msg-alert">Registration information hasn't been validated with the Producer. You should
-                  validate
-                  it.</p>
-               <h:commandLink action="#{consumer.refreshRegistrationInfo}" value="Validate"
-                              title="Validate registration info from Producer" styleClass="portlet-form-button">
-                  <f:param name="mergeLocalInfo" value="true"/>
-               </h:commandLink>
-            </td>
-         </tr>
-      </c:when>
-      <c:otherwise>
-         <c:if
-            test="#{!empty consumer.producerInfo.registrationInfo.registrationHandle and !consumer.registrationValid}">
-            <tr>
-               <td colspan="2">
-                  <p class="portlet-msg-error">Registration is not valid. You can try to fix the problems and modify the
-                     registration.</p>
-                  <h:commandLink action="#{consumer.modifyRegistration}" value="Modify registration"
-                                 title="Modify the registration held with this Producer"
-                                 styleClass="portlet-form-button"/>
-               </td>
-            </tr>
-         </c:if>
-      </c:otherwise>
-   </c:choose>
    <c:if test="#{consumer.registrationModified}">
       <tr>
          <td colspan="2">
@@ -166,10 +139,7 @@
 </c:if>
 <tr>
    <td colspan="2" style="padding: 1em 1em 1em 0;">
-      <h:commandButton action="#{consumer.update}" value="Save" styleClass="portlet-form-button">
-         <f:param name="id" value="#{consumer.id}"/>
-      </h:commandButton>
-      <h:commandLink action="#{consumer.refreshConsumer}" value="Save &amp; Refresh"
+      <h:commandLink action="#{consumer.refreshConsumer}" value="Refresh &amp; Save"
                      title="Save changes and refresh information from Producer"
                      styleClass="portlet-form-button">
          <f:param name="id" value="#{consumer.id}"/>

Modified: branches/JBoss_Portal_Branch_2_6/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/jsf/producer.xhtml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/jsf/producer.xhtml	2007-11-16 02:50:10 UTC (rev 8965)
+++ branches/JBoss_Portal_Branch_2_6/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/jsf/producer.xhtml	2007-11-16 08:00:38 UTC (rev 8966)
@@ -7,8 +7,9 @@
 
    <h:form>
       <ul class="topnav">
-         <li><h:commandLink action="#{consumersMgr.listConsumers}" value="Consumers"/></li>
+         <li><h:commandLink action="#{consumersMgr.listConsumers}" value="Consumers Configuration"/></li>
          <li id="currentTab">Producer</li>
+         <li>Producer Data</li>
       </ul>
    </h:form>
 
@@ -56,7 +57,7 @@
                                         headerClass="portlet-section-header">
                               <h:column>
                                  <f:facet name="header">Name</f:facet>
-                                 <h:inputText value="#{property.name}" size="30"/>
+                                 <h:inputText value="#{property.nameAsString}" size="30"/>
                               </h:column>
                               <h:column>
                                  <f:facet name="header">Type</f:facet>

Modified: branches/JBoss_Portal_Branch_2_6/registration/src/main/org/jboss/portal/registration/RegistrationManager.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/registration/src/main/org/jboss/portal/registration/RegistrationManager.java	2007-11-16 02:50:10 UTC (rev 8965)
+++ branches/JBoss_Portal_Branch_2_6/registration/src/main/org/jboss/portal/registration/RegistrationManager.java	2007-11-16 08:00:38 UTC (rev 8966)
@@ -31,7 +31,7 @@
  * @version $Revision$
  * @since 2.6
  */
-public interface RegistrationManager extends RegistrationPropertyChangeListener
+public interface RegistrationManager extends RegistrationPropertyChangeListener, RegistrationPolicyChangeListener
 {
    RegistrationPolicy getPolicy();
 

Added: branches/JBoss_Portal_Branch_2_6/registration/src/main/org/jboss/portal/registration/RegistrationPolicyChangeListener.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/registration/src/main/org/jboss/portal/registration/RegistrationPolicyChangeListener.java	                        (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/registration/src/main/org/jboss/portal/registration/RegistrationPolicyChangeListener.java	2007-11-16 08:00:38 UTC (rev 8966)
@@ -0,0 +1,15 @@
+/*
+ * Copyright (c) 2007, Your Corporation. All Rights Reserved.
+ */
+
+package org.jboss.portal.registration;
+
+/**
+ * @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ * @since 2.6.3
+ */
+public interface RegistrationPolicyChangeListener
+{
+   void policyUpdatedTo(RegistrationPolicy policy);
+}


Property changes on: branches/JBoss_Portal_Branch_2_6/registration/src/main/org/jboss/portal/registration/RegistrationPolicyChangeListener.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Modified: branches/JBoss_Portal_Branch_2_6/registration/src/main/org/jboss/portal/registration/impl/RegistrationManagerImpl.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/registration/src/main/org/jboss/portal/registration/impl/RegistrationManagerImpl.java	2007-11-16 02:50:10 UTC (rev 8965)
+++ branches/JBoss_Portal_Branch_2_6/registration/src/main/org/jboss/portal/registration/impl/RegistrationManagerImpl.java	2007-11-16 08:00:38 UTC (rev 8966)
@@ -272,7 +272,7 @@
       }
       else
       {
-         return getConsumer ? (Object)registration.getConsumer() : registration;
+         return getConsumer ? registration.getConsumer() : registration;
       }
    }
 
@@ -321,7 +321,8 @@
 
    /**
     * We listen to registration property changes on the producer configuration so that we can invalidate the current
-    * registrations. Consumers will need to call modifyRegistration since properties have changed...
+    * registrations. Consumers will need to call modifyRegistration since properties have changed... which requires
+    * throwing an OperationFailedFault... not an InvalidRegistrationFault!
     */
    public void propertiesHaveChanged()
    {
@@ -329,9 +330,21 @@
       for (Iterator regs = persistenceManager.getRegistrations().iterator(); regs.hasNext();)
       {
          Registration reg = (Registration)regs.next();
-         reg.setStatus(RegistrationStatus.INVALID);
-//         reg.clearAssociatedState(); //todo: do we need to clear the associateed state? If we do, should we wait until current operations are done?
+
+         // pending instead of invalid as technically, the registration is not yet invalid
+         reg.setStatus(RegistrationStatus.PENDING);
+//         reg.clearAssociatedState(); //todo: do we need to clear the associated state? If we do, should we wait until current operations are done?
       }
    }
 
+   /**
+    * We listen for RegistrationPolicy changes so that we can provide the proper behavior at all time if the policy has
+    * been changed by users since this RegistrationManager was initialized...
+    *
+    * @param policy
+    */
+   public void policyUpdatedTo(RegistrationPolicy policy)
+   {
+      setPolicy(policy);
+   }
 }

Modified: branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/other/RegistrationPropertyDescriptionTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/other/RegistrationPropertyDescriptionTestCase.java	2007-11-16 02:50:10 UTC (rev 8965)
+++ branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/other/RegistrationPropertyDescriptionTestCase.java	2007-11-16 08:00:38 UTC (rev 8966)
@@ -25,6 +25,7 @@
 
 import junit.framework.TestCase;
 import org.jboss.portal.registration.RegistrationPolicy;
+import org.jboss.portal.registration.RegistrationPolicyChangeListener;
 import org.jboss.portal.registration.RegistrationPropertyChangeListener;
 import org.jboss.portal.wsrp.WSRPConstants;
 import org.jboss.portal.wsrp.producer.config.ProducerRegistrationRequirements;
@@ -171,7 +172,7 @@
          notifyCalled = true;
       }
 
-      public void addRegistrationPropertyChangeListeners(RegistrationPropertyChangeListener listener)
+      public void addRegistrationPropertyChangeListener(RegistrationPropertyChangeListener listener)
       {
       }
 
@@ -206,5 +207,25 @@
             propName = propertyDescription.getName().getLocalPart();
          }
       }
+
+      public void addEmptyRegistrationProperty(String name)
+      {
+         //To change body of implemented methods use File | Settings | File Templates.
+      }
+
+      public void addRegistrationPolicyChangeListener(RegistrationPolicyChangeListener listener)
+      {
+         //To change body of implemented methods use File | Settings | File Templates.
+      }
+
+      public void removeRegistrationPolicyChangeListener(RegistrationPolicyChangeListener listener)
+      {
+         //To change body of implemented methods use File | Settings | File Templates.
+      }
+
+      public void clearRegistrationPolicyChangeListeners()
+      {
+         //To change body of implemented methods use File | Settings | File Templates.
+      }
    }
 }

Modified: branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/V1ProducerBaseTest.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/V1ProducerBaseTest.java	2007-11-16 02:50:10 UTC (rev 8965)
+++ branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/V1ProducerBaseTest.java	2007-11-16 08:00:38 UTC (rev 8966)
@@ -24,13 +24,12 @@
 package org.jboss.portal.test.wsrp.v1.producer;
 
 import org.jboss.portal.common.junit.ExtendedAssert;
+import org.jboss.portal.registration.RegistrationManager;
 import org.jboss.portal.registration.policies.DefaultRegistrationPolicy;
 import org.jboss.portal.registration.policies.DefaultRegistrationPropertyValidator;
-import org.jboss.portal.registration.RegistrationManager;
 import org.jboss.portal.test.wsrp.WSRPProducerBaseTest;
 import org.jboss.portal.wsrp.WSRPConstants;
 import org.jboss.portal.wsrp.WSRPTypeFactory;
-import org.jboss.portal.wsrp.producer.config.ProducerRegistrationRequirements;
 import org.jboss.portal.wsrp.core.GetServiceDescription;
 import org.jboss.portal.wsrp.core.LocalizedString;
 import org.jboss.portal.wsrp.core.MarkupType;
@@ -44,6 +43,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.config.ProducerRegistrationRequirements;
 import org.jboss.portal.wsrp.registration.RegistrationPropertyDescription;
 
 import javax.xml.namespace.QName;
@@ -188,7 +188,7 @@
          producer.getProducerRegistrationRequirements().setPolicy(defaultRegistrationPolicy);
          RegistrationManager registrationManager = producer.getRegistrationManager();
          registrationManager.setPolicy(defaultRegistrationPolicy);
-         producer.getProducerRegistrationRequirements().addRegistrationPropertyChangeListeners(registrationManager);
+         producer.getProducerRegistrationRequirements().addRegistrationPropertyChangeListener(registrationManager);
 
          return regProp;
       }

Modified: branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/WSRPExceptionFactory.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/WSRPExceptionFactory.java	2007-11-16 02:50:10 UTC (rev 8965)
+++ branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/WSRPExceptionFactory.java	2007-11-16 08:00:38 UTC (rev 8966)
@@ -92,7 +92,7 @@
          String causeMessage = cause.getLocalizedMessage();
          if (causeMessage != null)
          {
-            message += " " + causeMessage;
+            message += ". " + causeMessage;
          }
       }
 

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	2007-11-16 02:50:10 UTC (rev 8965)
+++ branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java	2007-11-16 08:00:38 UTC (rev 8966)
@@ -35,11 +35,11 @@
 import org.jboss.portal.wsrp.consumer.portlet.WSRPPortlet;
 import org.jboss.portal.wsrp.consumer.portlet.info.WSRPPortletInfo;
 import org.jboss.portal.wsrp.core.CookieProtocol;
-import org.jboss.portal.wsrp.core.Fault;
 import org.jboss.portal.wsrp.core.GetPortletDescription;
 import org.jboss.portal.wsrp.core.GetPortletPropertyDescription;
 import org.jboss.portal.wsrp.core.GetServiceDescription;
 import org.jboss.portal.wsrp.core.InvalidHandleFault;
+import org.jboss.portal.wsrp.core.InvalidRegistrationFault;
 import org.jboss.portal.wsrp.core.ModifyRegistration;
 import org.jboss.portal.wsrp.core.PortletDescription;
 import org.jboss.portal.wsrp.core.PortletDescriptionResponse;
@@ -106,6 +106,7 @@
    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!";
 
    /*protected org.jboss.portal.wsrp.core.ItemDescription[] userCategoryDescriptions;
    protected org.jboss.portal.wsrp.core.ItemDescription[] customUserProfileItemDescriptions;
@@ -306,7 +307,7 @@
 
             if (!registrationResult.hasIssues())
             {
-               registrationResult = register(serviceDescription, forceRefresh);
+               registrationResult = register(serviceDescription, false);
                if (registrationResult.specificCode())
                {
                   // registration occurred, so we should ask for a new service description
@@ -595,6 +596,11 @@
       {
          log.debug("Caught Exception in getServiceDescription:\n", e);
 
+         if (e instanceof InvalidRegistrationFault)
+         {
+            resetRegistration();
+         }
+
          // de-activate
          setActiveAndSave(false);
 
@@ -659,7 +665,7 @@
       {
          throw new IllegalArgumentException("Unknown portlet '" + portletHandle + "'");
       }
-      catch (org.jboss.portal.wsrp.core.InvalidRegistrationFault invalidRegistrationFault)
+      catch (InvalidRegistrationFault invalidRegistrationFault)
       {
          try
          {
@@ -885,4 +891,14 @@
       ccpsMap.remove(portletHandle);
       popsMap.remove(portletHandle);
    }
+
+   public void eraseRegistrationInfo()
+   {
+      persistentRegistrationInfo = null;
+
+      registry.updateProducerInfo(this);
+
+      log.warn(ERASED_LOCAL_REGISTRATION_INFORMATION);
+      log.debug(ERASED_LOCAL_REGISTRATION_INFORMATION);
+   }
 }

Modified: branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java	2007-11-16 02:50:10 UTC (rev 8965)
+++ branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java	2007-11-16 08:00:38 UTC (rev 8966)
@@ -236,12 +236,12 @@
 
    /**
     * @param reg
-    * @param throwExceptionIfExistsAndInvalid
+    * @param throwExceptionIfExistsAndNotValid
     *
     * @return
     * @since 2.6.2
     */
-   boolean isRegistrationValid(Registration reg, boolean throwExceptionIfExistsAndInvalid)
+   boolean isRegistrationValid(Registration reg, boolean throwExceptionIfExistsAndNotValid)
    {
       if (reg == null)
       {
@@ -256,15 +256,27 @@
       }
       else
       {
-         boolean result = RegistrationStatus.VALID.equals(reg.getStatus());
-         log.debug("Registration required: registration is " + (result ? "valid!" : "invalid!"));
+         boolean isValid = RegistrationStatus.VALID.equals(reg.getStatus());
+         boolean isPending = RegistrationStatus.PENDING.equals(reg.getStatus());
+         log.debug("Registration required: registration is " + (isValid ? "valid!" : (isPending ? "pending!" : "invalid!")));
 
-         if (throwExceptionIfExistsAndInvalid && !result)
+         if (throwExceptionIfExistsAndNotValid)
          {
-            throwInvalidRegistrationFault("registration with handle '" + reg.getRegistrationHandle() + "' is not valid!");
+            if (isPending)
+            {
+               throwOperationFailedFault("Registration with handle '" + reg.getRegistrationHandle()
+                  + "' is pending. Consumer needs to call modifyRegistration().", null);
+            }
+            else
+            {
+               if (!isValid)
+               {
+                  throwInvalidRegistrationFault("Registration with handle '" + reg.getRegistrationHandle() + "' is not valid!");
+               }
+            }
          }
 
-         return result;
+         return isValid;
       }
    }
 
@@ -296,8 +308,8 @@
          }
          catch (RegistrationException e)
          {
-            throw WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.OPERATION_FAILED,
-               "Failed to retrieve registration information associated with handle " + regHandle, e);
+            throwOperationFailedFault("Failed to retrieve registration information associated with handle " + regHandle, e);
+            return null;
          }
       }
       else
@@ -310,6 +322,11 @@
       }
    }
 
+   private void throwOperationFailedFault(String message, RegistrationException e)
+   {
+      throw WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.OPERATION_FAILED, message, e);
+   }
+
    boolean throwInvalidRegistrationFault(String message)
    {
       throw WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.INVALID_REGISTRATION,

Modified: branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java	2007-11-16 02:50:10 UTC (rev 8965)
+++ branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java	2007-11-16 08:00:38 UTC (rev 8966)
@@ -271,12 +271,16 @@
    protected void startService() throws Exception
    {
       super.startService();
+
       producerConfiguration = configurationService.getConfiguration();
+
       ProducerRegistrationRequirements registrationRequirements = getProducerRegistrationRequirements();
+      registrationRequirements.addRegistrationPolicyChangeListener(registrationManager);
+
       if (registrationRequirements.isRegistrationRequired())
       {
          registrationManager.setPolicy(registrationRequirements.getPolicy());
-         registrationRequirements.addRegistrationPropertyChangeListeners(registrationManager);
+         registrationRequirements.addRegistrationPropertyChangeListener(registrationManager);
       }
    }
 
@@ -287,6 +291,8 @@
       {
          registrationRequirements.removeRegistrationPropertyChangeListener(registrationManager);
       }
+      registrationRequirements.removeRegistrationPolicyChangeListener(registrationManager);
+
       super.stopService();
    }
 

Modified: branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/config/ProducerRegistrationRequirements.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/config/ProducerRegistrationRequirements.java	2007-11-16 02:50:10 UTC (rev 8965)
+++ branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/config/ProducerRegistrationRequirements.java	2007-11-16 08:00:38 UTC (rev 8966)
@@ -24,6 +24,7 @@
 package org.jboss.portal.wsrp.producer.config;
 
 import org.jboss.portal.registration.RegistrationPolicy;
+import org.jboss.portal.registration.RegistrationPolicyChangeListener;
 import org.jboss.portal.registration.RegistrationPropertyChangeListener;
 import org.jboss.portal.wsrp.registration.RegistrationPropertyDescription;
 
@@ -68,7 +69,7 @@
 
    void notifyRegistrationPropertyChangeListeners();
 
-   void addRegistrationPropertyChangeListeners(RegistrationPropertyChangeListener listener);
+   void addRegistrationPropertyChangeListener(RegistrationPropertyChangeListener listener);
 
    void clearRegistrationPropertyChangeListeners();
 
@@ -80,5 +81,31 @@
 
    void reloadPolicyFrom(String policyClassName, String validatorClassName);
 
+   /**
+    * @param propertyDescription
+    * @param oldName
+    * @since 2.6.3
+    */
    void propertyHasBeenRenamed(RegistrationPropertyDescription propertyDescription, QName oldName);
+
+   /**
+    * @param name
+    * @since 2.6.3
+    */
+   void addEmptyRegistrationProperty(String name);
+
+   /**
+    * @param listener
+    * @since 2.6.3
+    */
+   void addRegistrationPolicyChangeListener(RegistrationPolicyChangeListener listener);
+
+   /**
+    * @param listener
+    * @since 2.6.3
+    */
+   void removeRegistrationPolicyChangeListener(RegistrationPolicyChangeListener listener);
+
+   /** @since 2.6.3 */
+   void clearRegistrationPolicyChangeListeners();
 }

Modified: branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/config/impl/ProducerConfigurationImpl.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/config/impl/ProducerConfigurationImpl.java	2007-11-16 02:50:10 UTC (rev 8965)
+++ branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/config/impl/ProducerConfigurationImpl.java	2007-11-16 08:00:38 UTC (rev 8966)
@@ -34,14 +34,12 @@
 public class ProducerConfigurationImpl implements ProducerConfiguration
 {
    private ProducerRegistrationRequirements requirements;
-   private static final ProducerRegistrationRequirements DEFAULT_REGISTRATION_REQUIREMENTS =
-      new ProducerRegistrationRequirementsImpl(false, false, false);
 
    public ProducerRegistrationRequirements getRegistrationRequirements()
    {
       if (requirements == null)
       {
-         requirements = DEFAULT_REGISTRATION_REQUIREMENTS;
+         requirements = new ProducerRegistrationRequirementsImpl(false, false, false);
       }
 
       return requirements;

Modified: branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/config/impl/ProducerRegistrationRequirementsImpl.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/config/impl/ProducerRegistrationRequirementsImpl.java	2007-11-16 02:50:10 UTC (rev 8965)
+++ branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/config/impl/ProducerRegistrationRequirementsImpl.java	2007-11-16 08:00:38 UTC (rev 8966)
@@ -26,10 +26,12 @@
 import org.jboss.logging.Logger;
 import org.jboss.portal.common.util.ParameterValidation;
 import org.jboss.portal.registration.RegistrationPolicy;
+import org.jboss.portal.registration.RegistrationPolicyChangeListener;
 import org.jboss.portal.registration.RegistrationPropertyChangeListener;
 import org.jboss.portal.registration.policies.DefaultRegistrationPolicy;
 import org.jboss.portal.registration.policies.DefaultRegistrationPropertyValidator;
 import org.jboss.portal.registration.policies.RegistrationPropertyValidator;
+import org.jboss.portal.wsrp.WSRPConstants;
 import org.jboss.portal.wsrp.producer.config.ProducerRegistrationRequirements;
 import org.jboss.portal.wsrp.registration.RegistrationPropertyDescription;
 
@@ -37,7 +39,6 @@
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
 
@@ -48,18 +49,19 @@
  */
 public class ProducerRegistrationRequirementsImpl implements ProducerRegistrationRequirements
 {
-   private final Logger log = Logger.getLogger(getClass());
+   private static final Logger log = Logger.getLogger(ProducerRegistrationRequirementsImpl.class);
 
    private boolean requiresRegistration;
    private boolean fullServiceDescriptionRequiresRegistration;
-   private transient Set listeners = new HashSet(3);
    private RegistrationPolicy policy;
    private String policyClassName;
    private String validatorClassName;
-
    /** property name (QName) -> PropertyDescription */
-   private Map registrationProperties;
+   private Map<QName, RegistrationPropertyDescription> registrationProperties;
 
+   private Set<RegistrationPropertyChangeListener> propertyChangeListeners = new HashSet<RegistrationPropertyChangeListener>(3);
+   private Set<RegistrationPolicyChangeListener> policyChangeListeners = new HashSet<RegistrationPolicyChangeListener>(3);
+
    public ProducerRegistrationRequirementsImpl(boolean requiresMarshalling, boolean requiresRegistration, boolean fullServiceDescriptionRequiresRegistration)
    {
       this();
@@ -69,7 +71,7 @@
 
    public ProducerRegistrationRequirementsImpl()
    {
-      registrationProperties = new HashMap(7);
+      registrationProperties = new HashMap<QName, RegistrationPropertyDescription>(7);
    }
 
    public boolean isRegistrationRequired()
@@ -108,6 +110,14 @@
       notifyRegistrationPropertyChangeListeners();
    }
 
+   public void addEmptyRegistrationProperty(String name)
+   {
+      ParameterValidation.throwIllegalArgExceptionIfNull(name, "Property name");
+      RegistrationPropertyDescription reg = new RegistrationPropertyDescription(name, WSRPConstants.XSD_STRING);
+
+      addRegistrationProperty(reg);
+   }
+
    public boolean acceptValueFor(QName propertyName, Object value)
    {
       ParameterValidation.throwIllegalArgExceptionIfNull(propertyName, "Property name");
@@ -132,13 +142,13 @@
    public RegistrationPropertyDescription getRegistrationPropertyWith(QName name)
    {
       ParameterValidation.throwIllegalArgExceptionIfNull(name, "Property name");
-      return (RegistrationPropertyDescription)registrationProperties.get(name);
+      return registrationProperties.get(name);
    }
 
    private RegistrationPropertyDescription getPropertyDescription(QName propertyName)
    {
       // copy to ensure immutability
-      return new RegistrationPropertyDescription((RegistrationPropertyDescription)registrationProperties.get(propertyName));
+      return new RegistrationPropertyDescription(registrationProperties.get(propertyName));
    }
 
    public void removeRegistrationProperty(QName propertyName)
@@ -159,32 +169,65 @@
       removeRegistrationProperty(new QName(propertyName));
    }
 
+   /*
+   * == RegistrationPropertyChangeListeners handling ==
+   */
+
    public void notifyRegistrationPropertyChangeListeners()
    {
-      for (Iterator iterator = listeners.iterator(); iterator.hasNext();)
+      for (RegistrationPropertyChangeListener listener : propertyChangeListeners)
       {
-         RegistrationPropertyChangeListener listener = (RegistrationPropertyChangeListener)iterator.next();
          listener.propertiesHaveChanged();
       }
    }
 
    public void clearRegistrationPropertyChangeListeners()
    {
-      listeners.clear();
+      propertyChangeListeners.clear();
    }
 
-   public void addRegistrationPropertyChangeListeners(RegistrationPropertyChangeListener listener)
+   public void addRegistrationPropertyChangeListener(RegistrationPropertyChangeListener listener)
    {
       ParameterValidation.throwIllegalArgExceptionIfNull(listener, "RegistrationPropertyChangeListener");
-      listeners.add(listener);
+      propertyChangeListeners.add(listener);
    }
 
    public void removeRegistrationPropertyChangeListener(RegistrationPropertyChangeListener listener)
    {
       ParameterValidation.throwIllegalArgExceptionIfNull(listener, "RegistrationPropertyChangeListener");
-      listeners.remove(listener);
+      propertyChangeListeners.remove(listener);
    }
 
+   /*
+   * == RegistrationPolicyChangeListeners handling
+   */
+
+   public void addRegistrationPolicyChangeListener(RegistrationPolicyChangeListener listener)
+   {
+      ParameterValidation.throwIllegalArgExceptionIfNull(listener, "RegistrationPolicyChangeListener");
+      policyChangeListeners.add(listener);
+   }
+
+   public void removeRegistrationPolicyChangeListener(RegistrationPolicyChangeListener listener)
+   {
+      ParameterValidation.throwIllegalArgExceptionIfNull(listener, "RegistrationPolicyChangeListener");
+      policyChangeListeners.remove(listener);
+   }
+
+   public void clearRegistrationPolicyChangeListeners()
+   {
+      policyChangeListeners.clear();
+   }
+
+   public void notifyRegistrationPolicyChangeListeners()
+   {
+      for (RegistrationPolicyChangeListener listener : policyChangeListeners)
+      {
+         listener.policyUpdatedTo(policy);
+      }
+   }
+
+
    public void setPolicy(RegistrationPolicy policy)
    {
       this.policy = policy;
@@ -199,9 +242,10 @@
             validatorClassName = registrationPolicy.getValidator().getClass().getName();
          }
       }
+
+      notifyRegistrationPolicyChangeListeners();
    }
 
-
    public RegistrationPolicy getPolicy()
    {
       if (policy == null && requiresRegistration)

Modified: branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/registration/RegistrationPropertyDescription.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/registration/RegistrationPropertyDescription.java	2007-11-16 02:50:10 UTC (rev 8965)
+++ branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/registration/RegistrationPropertyDescription.java	2007-11-16 08:00:38 UTC (rev 8966)
@@ -178,6 +178,16 @@
       }
    }
 
+   public void setNameAsString(String name)
+   {
+      setName(new QName(name));
+   }
+
+   public String getNameAsString()
+   {
+      return getName().getLocalPart();
+   }
+
    public QName getType()
    {
       return type;




More information about the portal-commits mailing list