Author: chris.laprun(a)jboss.com
Date: 2007-04-11 14:28:52 -0400 (Wed, 11 Apr 2007)
New Revision: 6973
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistry.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistryService.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
trunk/wsrp/src/resources/portal-wsrp-war/style.css
Log:
- JBPORTAL-715:
+ Update consumer now works (was missing setter on ConsumerBean)
+ Added error messages support.
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-11
10:46:34 UTC (rev 6972)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java 2007-04-11
18:28:52 UTC (rev 6973)
@@ -58,6 +58,11 @@
return getProducerInfo().getEndpointConfigurationInfo().usesWSDL();
}
+ public void setUseWSDL(boolean useWSDL)
+ {
+ this.useWSDL = useWSDL ? Boolean.TRUE : Boolean.FALSE;
+ }
+
public String getId()
{
return consumer.getProducerId();
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java 2007-04-11
10:46:34 UTC (rev 6972)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java 2007-04-11
18:28:52 UTC (rev 6973)
@@ -24,8 +24,10 @@
import org.jboss.portal.common.util.ParameterValidation;
import org.jboss.portal.wsrp.WSRPConsumer;
+import org.jboss.portal.wsrp.consumer.ConsumerException;
import org.jboss.portal.wsrp.consumer.ConsumerRegistry;
+import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.faces.event.ValueChangeEvent;
import java.util.ArrayList;
@@ -83,23 +85,29 @@
if (refreshConsumerId() != null)
{
boolean activate =
Boolean.valueOf(getParameter("activate")).booleanValue();
- if (activate)
+ try
{
- registry.activateConsumerWith(selectedId);
+ if (activate)
+ {
+ registry.activateConsumerWith(selectedId);
+ }
+ else
+ {
+ registry.deactivateConsumerWith(selectedId);
+ }
}
- else
+ catch (ConsumerException e)
{
- registry.deactivateConsumerWith(selectedId);
+ createErrorMessageFrom(e);
}
return listConsumers();
}
else
{
- // todo: error message
+ noSelectedConsumerError();
+ return listConsumers();
}
-
- return listConsumers();
}
public String registerConsumer()
@@ -108,30 +116,47 @@
{
boolean register =
Boolean.valueOf(getParameter("register")).booleanValue();
- registry.registerOrDeregisterConsumerWith(selectedId, register);
-
- // show consumer configuration
- setConsumerIdInSession(false);
- return CONFIGURE_CONSUMER;
+ try
+ {
+ registry.registerOrDeregisterConsumerWith(selectedId, register);
+ // show consumer configuration
+ setConsumerIdInSession(false);
+ return CONFIGURE_CONSUMER;
+ }
+ catch (ConsumerException e)
+ {
+ createErrorMessageFrom(e);
+ return null;
+ }
}
else
{
- // todo: error message
+ noSelectedConsumerError();
+ return null;
}
-
- return null;
}
public String createConsumer()
{
if (selectedId != null)
{
- registry.createConsumer(selectedId, null);
- setConsumerIdInSession(false);
- return CONFIGURE_CONSUMER;
+ try
+ {
+ registry.createConsumer(selectedId, null);
+ setConsumerIdInSession(false);
+ return CONFIGURE_CONSUMER;
+ }
+ catch (ConsumerException e)
+ {
+ createErrorMessageFrom(e);
+ return null;
+ }
}
-
- return null;
+ else
+ {
+ createErrorMessage("Need a non-null, non-empty name for the new
Consumer", FacesMessage.SEVERITY_ERROR);
+ return null;
+ }
}
public String updateConsumer()
@@ -139,24 +164,44 @@
WSRPConsumer consumer = getSelectedConsumer();
if (consumer != null)
{
- registry.updateProducerInfo(consumer.getProducerInfo());
- return listConsumers();
+ try
+ {
+ registry.updateProducerInfo(consumer.getProducerInfo());
+ return listConsumers();
+ }
+ catch (ConsumerException e)
+ {
+ createErrorMessageFrom(e);
+ return null;
+ }
}
-
- // todo: error message
- return null;
+ else
+ {
+ noSelectedConsumerError();
+ return null;
+ }
}
public String destroyConsumer()
{
if (refreshConsumerId() != null)
{
- registry.destroyConsumer(selectedId);
- return listConsumers();
+ try
+ {
+ registry.destroyConsumer(selectedId);
+ return listConsumers();
+ }
+ catch (ConsumerException e)
+ {
+ createErrorMessageFrom(e);
+ return null;
+ }
}
-
- //todo: error message
- return null;
+ else
+ {
+ noSelectedConsumerError();
+ return null;
+ }
}
public String configureConsumer()
@@ -166,20 +211,10 @@
setConsumerIdInSession(false);
return CONFIGURE_CONSUMER;
}
- // todo: error message
- return null;
- }
-
- private void setConsumerIdInSession(boolean remove)
- {
- Map sessionMap =
FacesContext.getCurrentInstance().getExternalContext().getSessionMap();
- if (!remove)
- {
- sessionMap.put(CONSUMER_ID, selectedId);
- }
else
{
- sessionMap.remove(CONSUMER_ID);
+ noSelectedConsumerError();
+ return null;
}
}
@@ -213,15 +248,38 @@
return selectedId;
}
+ private void setConsumerIdInSession(boolean remove)
+ {
+ Map sessionMap =
FacesContext.getCurrentInstance().getExternalContext().getSessionMap();
+ if (!remove)
+ {
+ sessionMap.put(CONSUMER_ID, selectedId);
+ }
+ else
+ {
+ sessionMap.remove(CONSUMER_ID);
+ }
+ }
+
private String getParameter(String key)
{
Map pmap =
FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
return (String)pmap.get(key);
}
- /*private void createErrorMessage(String message, FacesMessage.Severity severity)
+ private void createErrorMessage(String message, FacesMessage.Severity severity)
{
FacesMessage msg = new FacesMessage(severity, message, message);
- FacesContext.getCurrentInstance().addMessage(messageTarget, message);
- }*/
+ FacesContext.getCurrentInstance().addMessage(null, msg);
+ }
+
+ private void createErrorMessageFrom(ConsumerException e)
+ {
+ createErrorMessage(e.getLocalizedMessage(), FacesMessage.SEVERITY_ERROR);
+ }
+
+ private void noSelectedConsumerError()
+ {
+ createErrorMessage("No Consumer was selected!",
FacesMessage.SEVERITY_ERROR);
+ }
}
\ No newline at end of file
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistry.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistry.java 2007-04-11
10:46:34 UTC (rev 6972)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistry.java 2007-04-11
18:28:52 UTC (rev 6973)
@@ -40,9 +40,9 @@
FederatingPortletInvoker getFederatingPortletInvoker();
- WSRPConsumer createConsumer(String id, Integer expirationCacheSeconds);
+ WSRPConsumer createConsumer(String id, Integer expirationCacheSeconds) throws
ConsumerException;
- void persistConsumer(WSRPConsumer consumer);
+ void persistConsumer(WSRPConsumer consumer) throws ConsumerException;
/**
* Activates the consumer associated with the specified identifier if and only if
access to the remote producer is
@@ -53,11 +53,11 @@
*/
void activateConsumerWith(String id) throws ConsumerException;
- void updateProducerInfo(ProducerInfo producerInfo);
+ void updateProducerInfo(ProducerInfo producerInfo) throws ConsumerException;
void deactivateConsumerWith(String id) throws ConsumerException;
- void registerOrDeregisterConsumerWith(String id, boolean register);
+ void registerOrDeregisterConsumerWith(String id, boolean register) throws
ConsumerException;
- void destroyConsumer(String id);
+ void destroyConsumer(String id) throws ConsumerException;
}
\ No newline at end of file
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistryService.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistryService.java 2007-04-11
10:46:34 UTC (rev 6972)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistryService.java 2007-04-11
18:28:52 UTC (rev 6973)
@@ -142,8 +142,15 @@
ProducerInfo info = consumer.getProducerInfo();
- Session session = sessionFactory.getCurrentSession();
- session.persist(info);
+ try
+ {
+ Session session = sessionFactory.getCurrentSession();
+ session.persist(info);
+ }
+ catch (HibernateException e)
+ {
+ throw new ConsumerException(CONSUMER_WITH_ID + info.getId() + "'
couldn't be persisted!");
+ }
createConsumerFrom(info);
}
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-11
10:46:34 UTC (rev 6972)
+++
trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/jsf/consumers/consumers.xhtml 2007-04-11
18:28:52 UTC (rev 6973)
@@ -9,10 +9,10 @@
<hr/>
- <h:messages/>
+ <h:messages styleClass="error"/>
<h:form>
- Create a consumer:
+ Create a consumer named:
<h:inputText value="#{consumersMgr.selectedId}"/>
<h:commandButton action="#{consumersMgr.createConsumer}"
value="Create Consumer"/>
</h:form>
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-11
10:46:34 UTC (rev 6972)
+++
trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/jsf/consumers/editConsumer.xhtml 2007-04-11
18:28:52 UTC (rev 6973)
@@ -7,139 +7,140 @@
<f:view>
<h:form>
- <h1 class="portlet">Consumer '#{consumer.id}' configuration
- <h:commandLink action="#{consumersMgr.activateConsumer}"
styleClass="portlet-form-button"
- value="#{consumer.active ? 'Deactivate' :
'Activate'}">
- <f:param name="id" value="#{consumer.id}"/>
- <f:param name="activate"
value="#{!consumer.active}"/>
- </h:commandLink>
+ <h1 class="portlet">Consumer '#{consumer.id}'
configuration</h1>
+ <h:commandLink action="#{consumersMgr.activateConsumer}"
styleClass="portlet-form-button"
+ value="#{consumer.active ? 'Deactivate' :
'Activate'}">
+ <f:param name="id" value="#{consumer.id}"/>
+ <f:param name="activate" value="#{!consumer.active}"/>
+ </h:commandLink>
- <h:commandLink action="#{consumersMgr.registerConsumer}"
styleClass="portlet-form-button"
- rendered="#{consumer.active}"
- value="#{consumer.registered ? 'Deregister' :
'Register'}">
- <f:param name="id" value="#{consumer.id}"/>
- <f:param name="register"
value="#{!consumer.registered}"/>
- </h:commandLink>
+ <h:commandLink action="#{consumersMgr.registerConsumer}"
styleClass="portlet-form-button"
+ rendered="#{consumer.active}"
+ value="#{consumer.registered ? 'Deregister' :
'Register'}">
+ <f:param name="id" value="#{consumer.id}"/>
+ <f:param name="register"
value="#{!consumer.registered}"/>
+ </h:commandLink>
- <h:commandLink action="#{consumersMgr.destroyConsumer}"
value="Destroy" styleClass="portlet-form-button">
- <f:param name="id" value="#{consumer.id}"/>
- </h:commandLink>
+ <h:commandLink action="#{consumersMgr.destroyConsumer}"
value="Destroy" styleClass="portlet-form-button">
+ <f:param name="id" value="#{consumer.id}"/>
+ </h:commandLink>
- <h:commandLink action="#{consumersMgr.listConsumers}"
value="Return to list" styleClass="portlet-form-button"/>
- </h1>
+ <h:commandLink action="#{consumersMgr.listConsumers}" value="Return
to list" styleClass="portlet-form-button"/>
</h:form>
<hr/>
<h:form>
- <table width="100%" class="portlet-table-body">
- <tr>
- <th>Producer id:</th>
- <td>
- <h:inputText value="#{consumer.id}"/>
- </td>
- </tr>
- <tr>
- <th>Cache expiration:</th>
- <td>
- <h:inputText value="#{consumer.cache}"/>
- (seconds before expiration)
- </td>
- </tr>
- <tr>
- <th>Endpoint configuration:</th>
- <td>
- <h:selectBooleanCheckbox value="#{consumer.useWSDL}"/>
- Use WSDL?
+<table width="100%" class="portlet-table-body">
+<tr>
+ <th>Producer id:</th>
+ <td>
+ <h:inputText id="id" value="#{consumer.id}"/>
<h:message styleClass="error" for="id"/>
+ </td>
+</tr>
+<tr>
+ <th>Cache expiration:</th>
+ <td>
+ <h:inputText id="cache" value="#{consumer.cache}"/>
(seconds before expiration) <h:message styleClass="error"
+
for="cache"/>
+ </td>
+</tr>
+<tr>
+ <th>Endpoint configuration:</th>
+ <td>
+ <h:selectBooleanCheckbox id="useWSDL"
value="#{consumer.useWSDL}"/>Use WSDL?
+ <h:message styleClass="error" for="useWSDL"/>
+ <c:choose>
+ <c:when test="#{consumer.useWSDL}">
+ <h:inputText id="wsdl" size="70"
value="#{consumer.wsdl}"/> <h:message styleClass="error"
for="wsdl"/>
+ </c:when>
+ <c:otherwise>
+ <table border="0" class='portlet-table-body'>
+ <tr>
+ <th>Service Description URL:</th>
+ <td>
+ <h:inputText id="sd" size="70"
value="#{consumer.serviceDescription}"/> <h:message
+ styleClass="error" for="sd"/>
+ </td>
+ </tr>
+ <tr>
+ <th>Markup URL:</th>
+ <td>
+ <h:inputText id="m" size="70"
value="#{consumer.markup}"/> <h:message styleClass="error"
for="m"/>
+ </td>
+ </tr>
+ <tr>
+ <th>Registration URL:</th>
+ <td>
+ <h:inputText id="r" size="70"
value="#{consumer.registration}"/> <h:message
styleClass="error"
+
for="r"/>
+ </td>
+ </tr>
+ <tr>
+ <th>Portlet Management URL:</th>
+ <td>
+ <h:inputText id="pm" size="70"
value="#{consumer.portletManagement}"/> <h:message
+ styleClass="error" for="pm"/>
+ </td>
+ </tr>
+ </table>
+ </c:otherwise>
+ </c:choose>
+ </td>
+</tr>
+<tr>
+ <th>Registration information</th>
+ <td>
+ <c:choose>
+ <c:when test="#{consumer.requiresRegistration}">
<c:choose>
- <c:when test="#{consumer.useWSDL}">
- <h:inputText size="70"
value="#{consumer.wsdl}"/>
- </c:when>
-
- <c:otherwise>
- <table border="0" class='portlet-table-body'>
+ <c:when test="#{!empty
consumer.producerInfo.registrationInfo.registrationPropertyNames}">
+ <table border='1' cellspacing='0'
class='registration-prop-table'>
<tr>
- <th>Service Description URL:</th>
- <td>
- <h:inputText size="70"
value="#{consumer.serviceDescription}"/>
- </td>
+ <th>Name</th>
+ <th>Value</th>
</tr>
- <tr>
- <th>Markup URL:</th>
- <td>
- <h:inputText size="70"
value="#{consumer.markup}"/>
- </td>
- </tr>
- <tr>
- <th>Registration URL:</th>
- <td>
- <h:inputText size="70"
value="#{consumer.registration}"/>
- </td>
- </tr>
- <tr>
- <th>Portlet Management URL:</th>
- <td>
- <h:inputText size="70"
value="#{consumer.portletManagement}"/>
- </td>
- </tr>
+ <c:forEach
items="#{consumer.producerInfo.registrationInfo.registrationProperties}"
+ var="prop">
+ <tr title="#{prop.description.label.value}">
+ <td>
+ <h:inputText value="#{prop.name}"
size="40"/>
+ </td>
+ <td>
+ <h:inputText value="#{prop.value}"
size="40"/>
+ </td>
+ </tr>
+ </c:forEach>
</table>
- </c:otherwise>
- </c:choose>
- </td>
- </tr>
- <tr>
- <th>Registration information</th>
- <td>
- <c:choose>
- <c:when test="#{consumer.requiresRegistration}">
- <c:choose>
- <c:when test="#{!empty
consumer.producerInfo.registrationInfo.registrationPropertyNames}">
- <table border='1' cellspacing='0'
class='registration-prop-table'>
- <tr>
- <th>Name</th>
- <th>Value</th>
- </tr>
- <c:forEach
items="#{consumer.producerInfo.registrationInfo.registrationProperties}"
- var="prop">
- <tr
title="#{prop.description.label.value}">
- <td>
- <h:inputText value="#{prop.name}"
size="40"/>
- </td>
- <td>
- <h:inputText value="#{prop.value}"
size="40"/>
- </td>
- </tr>
- </c:forEach>
- </table>
- </c:when>
- <c:otherwise>
- No required registration properties.
- </c:otherwise>
- </c:choose>
</c:when>
<c:otherwise>
- Producer doesn't require registration.
+ No required registration properties.
</c:otherwise>
</c:choose>
- </td>
- </tr>
- <c:if
test="#{consumer.producerInfo.registrationInfo.registrationValid}">
- <tr>
- <th>Registration context:</th>
- <td>Handle:
- <h:outputText
value="#{consumer.producerInfo.registrationInfo.registrationContext.registrationHandle}"/>
- </td>
- </tr>
- </c:if>
- <tr>
- <td colspan="2">
- <h:commandButton action="#{consumer.update}"
value="Save" styleClass="portlet-form-button"/>
- </td>
- </tr>
- </table>
+ </c:when>
+ <c:otherwise>
+ Producer doesn't require registration.
+ </c:otherwise>
+ </c:choose>
+ </td>
+</tr>
+<c:if
test="#{consumer.producerInfo.registrationInfo.registrationValid}">
+ <tr>
+ <th>Registration context:</th>
+ <td>Handle:
+ <h:outputText
value="#{consumer.producerInfo.registrationInfo.registrationContext.registrationHandle}"/>
+ </td>
+ </tr>
+</c:if>
+<tr>
+ <td colspan="2">
+ <h:commandButton action="#{consumer.update}" value="Save"
styleClass="portlet-form-button"/>
+ </td>
+</tr>
+</table>
- <hr/>
+<hr/>
</h:form>
</f:view>
</div>
\ No newline at end of file
Modified: trunk/wsrp/src/resources/portal-wsrp-war/style.css
===================================================================
--- trunk/wsrp/src/resources/portal-wsrp-war/style.css 2007-04-11 10:46:34 UTC (rev 6972)
+++ trunk/wsrp/src/resources/portal-wsrp-war/style.css 2007-04-11 18:28:52 UTC (rev 6973)
@@ -50,4 +50,9 @@
.wsrp-consumer-ui .portlet-form-button {
padding: .2em;
margin: .3em;
+}
+
+.error {
+ font-weight: bold;
+ color: red;
}
\ No newline at end of file