Author: chris.laprun(a)jboss.com
Date: 2007-04-27 00:18:41 -0400 (Fri, 27 Apr 2007)
New Revision: 7095
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockWSRPConsumer.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ProducerInfoTestCase.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPConsumer.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ManagedBean.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java
trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/jsf/consumers/consumers.xhtml
trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/jsf/consumers/editConsumer.xhtml
Log:
- JBPORTAL-715: Initial support for validating/replacing local registration properties by
producer values and improved status reporting.
- Added WSRPConsumer.refreshRegistrationInfo method and implementation.
- Renamed ProducerInfo.requiresRegistration to isRegistrationRequired.
- Fixed isRegistered implementation.
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockWSRPConsumer.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockWSRPConsumer.java 2007-04-27
04:11:52 UTC (rev 7094)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockWSRPConsumer.java 2007-04-27
04:18:41 UTC (rev 7095)
@@ -35,6 +35,7 @@
import org.jboss.portal.wsrp.WSRPConsumer;
import org.jboss.portal.wsrp.consumer.ProducerInfo;
import org.jboss.portal.wsrp.consumer.ProducerSessionInformation;
+import org.jboss.portal.wsrp.consumer.RegistrationInfo;
import org.jboss.portal.wsrp.services.ServiceFactory;
import javax.servlet.http.HttpSession;
@@ -105,6 +106,11 @@
{
}
+ public RegistrationInfo.RegistrationRefreshResult refreshRegistrationInfo(boolean
eraseLocalData) throws PortletInvokerException
+ {
+ return null;
+ }
+
public Set getPortlets() throws PortletInvokerException
{
return null;
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ProducerInfoTestCase.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ProducerInfoTestCase.java 2007-04-27
04:11:52 UTC (rev 7094)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/other/ProducerInfoTestCase.java 2007-04-27
04:18:41 UTC (rev 7095)
@@ -56,7 +56,6 @@
private ProducerInfo info;
private BehaviorBackedServiceFactory serviceFactory;
-
protected void setUp() throws Exception
{
info = new ProducerInfo();
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPConsumer.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPConsumer.java 2007-04-27 04:11:52 UTC
(rev 7094)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPConsumer.java 2007-04-27 04:18:41 UTC
(rev 7095)
@@ -28,6 +28,7 @@
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.wsrp.consumer.ProducerInfo;
import org.jboss.portal.wsrp.consumer.ProducerSessionInformation;
+import org.jboss.portal.wsrp.consumer.RegistrationInfo;
import org.jboss.system.Service;
import javax.servlet.http.HttpSession;
@@ -105,4 +106,15 @@
* @since 2.6
*/
void deactivate() throws Exception;
+
+ /**
+ * Refreshes the Registration information required by the remote producer.
+ *
+ * @param eraseLocalData <code>true</code> if the local data should be
used and validated, <code>false</code> if the
+ * local data should be ignored and replaced by empty values for
each of the required
+ * properties.
+ * @return
+ * @since 2.6
+ */
+ RegistrationInfo.RegistrationRefreshResult refreshRegistrationInfo(boolean
eraseLocalData) throws PortletInvokerException;
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java 2007-04-27
04:11:52 UTC (rev 7094)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java 2007-04-27
04:18:41 UTC (rev 7095)
@@ -27,6 +27,7 @@
import org.jboss.portal.wsrp.consumer.ConsumerException;
import org.jboss.portal.wsrp.consumer.ConsumerRegistry;
import org.jboss.portal.wsrp.consumer.ProducerInfo;
+import org.jboss.portal.wsrp.consumer.RegistrationInfo;
import javax.faces.context.FacesContext;
import javax.faces.event.ValueChangeEvent;
@@ -163,9 +164,9 @@
return getProducerInfo().isRegistered();
}
- public boolean isRequiresRegistration()
+ public boolean isRegistrationRequired()
{
- return getProducerInfo().requiresRegistration();
+ return getProducerInfo().isRegistrationRequired();
}
public ProducerInfo getProducerInfo()
@@ -196,6 +197,36 @@
return null;
}
+ public String refreshRegistrationInfo()
+ {
+ if (consumer != null)
+ {
+ String param = getParameter("eraseLocalData");
+ boolean eraseLocalData = Boolean.valueOf(param).booleanValue();
+ try
+ {
+ RegistrationInfo.RegistrationRefreshResult result =
consumer.refreshRegistrationInfo(eraseLocalData);
+ if (!result.isValid())
+ {
+ createErrorMessage(result.getStatus());
+ }
+ else
+ {
+ createInfoMessage(null, result.getStatus());
+ }
+ }
+ catch (Exception e)
+ {
+ createErrorMessageFrom(e);
+ return null;
+ }
+ return null;
+ }
+
+ createErrorMessage("Couldn't refresh Registration info!");
+ return null;
+ }
+
// Listeners
public void useWSDLListener(ValueChangeEvent event)
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ManagedBean.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ManagedBean.java 2007-04-27
04:11:52 UTC (rev 7094)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ManagedBean.java 2007-04-27
04:18:41 UTC (rev 7095)
@@ -42,15 +42,15 @@
protected void createErrorMessage(String message)
{
- createErrorMessage(null, message, FacesMessage.SEVERITY_ERROR);
+ createMessage(null, message, FacesMessage.SEVERITY_ERROR);
}
protected void createErrorMessage(String target, String message)
{
- createErrorMessage(target, message, FacesMessage.SEVERITY_ERROR);
+ createMessage(target, message, FacesMessage.SEVERITY_ERROR);
}
- protected void createErrorMessage(String target, String message, FacesMessage.Severity
severity)
+ protected void createMessage(String target, String message, FacesMessage.Severity
severity)
{
FacesMessage msg = new FacesMessage(severity, message, message);
FacesContext.getCurrentInstance().addMessage(target, msg);
@@ -67,4 +67,9 @@
String message = e.getLocalizedMessage() + (cause != null ? "\nCause: " +
cause.getLocalizedMessage() : "");
createErrorMessage(target, message);
}
+
+ protected void createInfoMessage(String target, String message)
+ {
+ createMessage(target, message, FacesMessage.SEVERITY_INFO);
+ }
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2007-04-27
04:11:52 UTC (rev 7094)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2007-04-27
04:18:41 UTC (rev 7095)
@@ -163,10 +163,10 @@
public boolean isRegistered()
{
- return persistentRegistrationInfo != null &&
persistentRegistrationInfo.isRegistrationValid();
+ return isRegistrationRequired() &&
persistentRegistrationInfo.isRegistrationValid();
}
- public boolean requiresRegistration()
+ public boolean isRegistrationRequired()
{
return persistentRegistrationInfo != null &&
persistentRegistrationInfo.isRequiresRegistration();
@@ -234,7 +234,7 @@
if (forceRefresh || isCacheExpired())
{
log.debug("ProducerInfo refresh needed for producer '" +
persistentId + "'");
- serviceDescription = getServiceDescription();
+ serviceDescription = getServiceDescription(false);
// do we need to call initCookie or not?
requiresInitCookie = serviceDescription.getRequiresInitCookie();
@@ -246,7 +246,7 @@
if (register(serviceDescription))
{
// registration occurred, so we should ask for a new service description
- serviceDescription = getServiceDescription();
+ serviceDescription = getServiceDescription(false);
}
// extract the POPs
@@ -457,10 +457,18 @@
this.persistentExpirationCacheSeconds = expirationCacheSeconds;
}
- private ServiceDescription getServiceDescription() throws PortletInvokerException
+ private ServiceDescription getServiceDescription(boolean asUnregistered) throws
PortletInvokerException
{
- GetServiceDescription request = getServiceDescriptionRequest();
- request.setRegistrationContext(getRegistrationContext());
+ GetServiceDescription request;
+ if (asUnregistered)
+ {
+ request = getUnregisteredServiceDescriptionRequest();
+ }
+ else
+ {
+ request = getServiceDescriptionRequest();
+ request.setRegistrationContext(getRegistrationContext());
+ }
ServiceDescription serviceDescription;
@@ -608,7 +616,7 @@
if (serviceDescription == null)
{
- serviceDescription = getServiceDescription();
+ serviceDescription = getServiceDescription(false);
}
if (serviceDescription.isRequiresRegistration())
@@ -670,4 +678,25 @@
}
}
+
+ public RegistrationInfo.RegistrationRefreshResult refreshRegistrationInfo(boolean
eraseLocalData) throws PortletInvokerException
+ {
+ if (persistentRegistrationInfo == null)
+ {
+ persistentRegistrationInfo = new RegistrationInfo(this);
+ }
+
+ // if we want to erase the local data, we need to deregister
+ if (eraseLocalData)
+ {
+ deregister();
+ }
+
+ RegistrationInfo.RegistrationRefreshResult result =
+
persistentRegistrationInfo.refreshRegistrationRequirementsFor(getServiceDescription(true),
persistentId, eraseLocalData);
+ registry.updateProducerInfo(this);
+ log.info("Refreshed registration information for consumer with id '"
+ persistentId + "'");
+
+ return result;
+ }
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java 2007-04-27
04:11:52 UTC (rev 7094)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java 2007-04-27
04:18:41 UTC (rev 7095)
@@ -258,7 +258,8 @@
{
requiresRegistration = true;
StringBuffer message = new StringBuffer("Producer
'").append(producerId).append("' requires registration.");
- log.info(message);
+ result.appendToStatus(message.toString());
+ log.debug(message);
// check if the configured registration properties match the producer
expectations
ModelDescription regPropDescs =
serviceDescription.getRegistrationPropertyDescription();
@@ -299,7 +300,7 @@
if (missingProps.length() > 0)
{
- log.info(missingProps);
+ log.debug(missingProps);
result.appendToStatus(missingProps.toString());
resetRegistration();
result.setValid(false);
@@ -318,13 +319,17 @@
}
else
{
- log.info("Producer '" + producerId + "' doesn't
require registration.");
+ String msg = "Producer '" + producerId + "' doesn't
require registration.";
+ log.debug(msg);
+ result.appendToStatus(msg);
requiresRegistration = false;
result.setValid(true);
}
result.setRegistrationProperties(registrationProperties);
- log.debug("Registration configuration is " + (result.isValid() ?
"" : "NOT") + " valid");
+ String msg = "Registration configuration is " + (result.isValid() ?
"" : "NOT") + " valid";
+ result.appendToStatus(msg);
+ log.debug(msg);
return result;
}
@@ -483,7 +488,7 @@
}
else
{
- status.append(message);
+ status.append(message).append(" ");
}
}
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java 2007-04-27
04:11:52 UTC (rev 7094)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java 2007-04-27
04:18:41 UTC (rev 7095)
@@ -488,6 +488,11 @@
}
}
+ public RegistrationInfo.RegistrationRefreshResult refreshRegistrationInfo(boolean
eraseLocalData) throws PortletInvokerException
+ {
+ return producerInfo.refreshRegistrationInfo(eraseLocalData);
+ }
+
// Service implementation
*******************************************************************************************
protected void startService() throws Exception
Modified: trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/jsf/consumers/consumers.xhtml
===================================================================
---
trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/jsf/consumers/consumers.xhtml 2007-04-27
04:11:52 UTC (rev 7094)
+++
trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/jsf/consumers/consumers.xhtml 2007-04-27
04:18:41 UTC (rev 7095)
@@ -52,7 +52,7 @@
<f:param name="activate"
value="#{!consumer.producerInfo.active}"/>
<h:outputText value="#{consumer.producerInfo.active ?
'Deactivate' : 'Activate'}"/>
</h:commandLink>
- <c:if test="#{consumer.producerInfo.active}"> |
+ <c:if test="#{consumer.producerInfo.active and
consumer.producerInfo.registrationRequired}"> |
<h:commandLink
action="#{consumersMgr.registerConsumer}">
<f:param name="id"
value="#{consumer.producerId}"/>
Modified:
trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/jsf/consumers/editConsumer.xhtml
===================================================================
---
trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/jsf/consumers/editConsumer.xhtml 2007-04-27
04:11:52 UTC (rev 7094)
+++
trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/jsf/consumers/editConsumer.xhtml 2007-04-27
04:18:41 UTC (rev 7095)
@@ -14,7 +14,7 @@
</h:commandLink>
<h:commandLink action="#{consumersMgr.registerConsumer}"
styleClass="portlet-form-button"
- rendered="#{consumer.active}"
+ rendered="#{consumer.active and
consumer.registrationRequired}"
value="#{consumer.registered ? 'Deregister' :
'Register'}">
<f:param name="id" value="#{consumer.id}"/>
<f:param name="register"
value="#{!consumer.registered}"/>
@@ -91,10 +91,17 @@
</td>
</tr>
<tr>
- <th>Registration information</th>
+ <th>Registration information<br/><br/>
+ <h:commandLink action="#{consumer.refreshRegistrationInfo}"
value="Validate" styleClass="portlet-form-button">
+ <f:param name="eraseLocalData" value="false"/>
+ </h:commandLink>
+ <h:commandLink action="#{consumer.refreshRegistrationInfo}"
value="Replace" styleClass="portlet-form-button">
+ <f:param name="eraseLocalData" value="true"/>
+ </h:commandLink>
+ </th>
<td>
<c:choose>
- <c:when test="#{consumer.requiresRegistration}">
+ <c:when test="#{consumer.registrationRequired}">
<c:choose>
<c:when test="#{!empty
consumer.producerInfo.registrationInfo.registrationPropertyNames}">
<table border='1' cellspacing='0'
class='registration-prop-table'>
@@ -102,8 +109,7 @@
<th>Name</th>
<th>Value</th>
</tr>
- <c:forEach
items="#{consumer.producerInfo.registrationInfo.registrationProperties}"
- var="prop">
+ <c:forEach
items="#{consumer.producerInfo.registrationInfo.registrationProperties}"
var="prop">
<tr title="#{prop.description.label.value}">
<td>
<h:inputText value="#{prop.name}"
size="40"/>