Author: chris.laprun(a)jboss.com
Date: 2007-04-30 15:02:38 -0400 (Mon, 30 Apr 2007)
New Revision: 7153
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ManagedBean.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
Log:
- JBPORTAL-1370: handle null consumer id gracefully.
- Better error handling and messages.
- Make sure that Consumer is marked as non-active if an error occurs during activation
process.
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-30
14:59:57 UTC (rev 7152)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java 2007-04-30
19:02:38 UTC (rev 7153)
@@ -24,7 +24,6 @@
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.context.FacesContext;
@@ -93,7 +92,7 @@
registry.deactivateConsumerWith(selectedId);
}
}
- catch (ConsumerException e)
+ catch (Exception e)
{
createErrorMessageFrom(e);
}
@@ -120,7 +119,7 @@
setConsumerIdInSession(false);
return CONFIGURE_CONSUMER;
}
- catch (ConsumerException e)
+ catch (Exception e)
{
createErrorMessageFrom(e);
return null;
@@ -143,7 +142,7 @@
setConsumerIdInSession(false);
return CONFIGURE_CONSUMER;
}
- catch (ConsumerException e)
+ catch (Exception e)
{
createErrorMessageFrom(e);
return null;
@@ -165,7 +164,7 @@
registry.destroyConsumer(selectedId);
return listConsumers();
}
- catch (ConsumerException e)
+ catch (Exception e)
{
createErrorMessageFrom(e);
return null;
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-30
14:59:57 UTC (rev 7152)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ManagedBean.java 2007-04-30
19:02:38 UTC (rev 7153)
@@ -64,10 +64,21 @@
protected void createErrorMessageFrom(String target, Exception e)
{
Throwable cause = e.getCause();
- String message = e.getLocalizedMessage() + (cause != null ? "\nCause: " +
cause.getLocalizedMessage() : "");
+ String localizedMessage = getLocalizedMessageOrExceptionName(e);
+ String message = localizedMessage + (cause != null ? "\nCause: " +
getLocalizedMessageOrExceptionName(cause) : "");
createErrorMessage(target, message);
}
+ private String getLocalizedMessageOrExceptionName(Throwable e)
+ {
+ String localizedMessage = e.getLocalizedMessage();
+ if (localizedMessage == null)
+ {
+ localizedMessage = "An unexpected error occured: " +
e.getClass().getName();
+ }
+ return localizedMessage;
+ }
+
protected void createInfoMessage(String target, String message)
{
createMessage(target, message, FacesMessage.SEVERITY_INFO);
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-30
14:59:57 UTC (rev 7152)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistryService.java 2007-04-30
19:02:38 UTC (rev 7153)
@@ -75,7 +75,7 @@
public WSRPConsumer createConsumer(String id, Integer expirationCacheSeconds)
{
- ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(id, "Consumer
identifier", "createConsumer");
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(id, "Consumer
identifier", "Creating a Consumer");
if (getConsumer(id) != null)
{
@@ -105,7 +105,7 @@
public void destroyConsumer(String id)
{
- ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(id, "Consumer
identifier", "destroyConsumer");
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(id, "Consumer
identifier", "Destroying a Consumer");
WSRPConsumer consumer = getConsumer(id);
if (consumer != null)
@@ -211,7 +211,7 @@
public void activateConsumerWith(String id) throws ConsumerException
{
- ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(id, "Consumer
identifier", "activateConsumerWith");
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(id, "Consumer
identifier", "Activating a Consumer");
// if the consumer associated with the given id is already registered, don't do
anything
if (federatingPortletInvoker.getFederatedInvoker(id) == null)
@@ -222,7 +222,7 @@
public void deactivateConsumerWith(String id) throws ConsumerException
{
- ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(id, "Consumer
identifier", "deactivateConsumerWith");
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(id, "Consumer
identifier", "Deactivating a Consumer");
// only process if there is a registered Consumer with the specified id
if (federatingPortletInvoker.getFederatedInvoker(id) != null)
@@ -281,7 +281,7 @@
public void registerOrDeregisterConsumerWith(String id, boolean register)
{
- ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(id, "Consumer
identifier", "registerConsumerWith");
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(id, "Consumer
identifier", "Registering or deregistering a Consumer");
WSRPConsumer consumer = getConsumer(id);
@@ -309,7 +309,7 @@
private void startOrStopConsumer(String id, boolean start)
{
- WSRPConsumer consumer;
+ WSRPConsumer consumer = null;
try
{
@@ -352,6 +352,10 @@
}
catch (Exception e)
{
+ if (consumer != null)
+ {
+ consumer.getProducerInfo().setActive(false);
+ }
throw new ConsumerException("Couldn't " + (start ?
"start" : "stop") + " Consumer service '" + id +
"'", e);
}
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-30
14:59:57 UTC (rev 7152)
+++
trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/jsf/consumers/consumers.xhtml 2007-04-30
19:02:38 UTC (rev 7153)
@@ -13,7 +13,8 @@
<h:form>
Create a consumer named:
- <h:inputText value="#{consumersMgr.selectedId}"/>
+ <h:inputText value="#{consumersMgr.selectedId}"
id="consumerName"/><h:message styleClass="error"
+
for="consumerName"/>
<h:commandButton action="#{consumersMgr.createConsumer}"
value="Create Consumer"/>
</h:form>