Author: chris.laprun(a)jboss.com
Date: 2007-04-13 17:56:09 -0400 (Fri, 13 Apr 2007)
New Revision: 6975
Added:
trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ManagedBean.java
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/ConsumerRegistryService.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/EndpointConfigurationInfo.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPDeploymentFactory.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java
trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/faces-config.xml
trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/jsf/consumers/editConsumer.xhtml
Log:
- JBPORTAL-715:
+ Re-activated immediate status of useWSDL.
+ More error messages.
+ ConsumerBean is now session-scoped and properly refreshes.
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-12
11:41:31 UTC (rev 6974)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java 2007-04-13
21:56:09 UTC (rev 6975)
@@ -24,9 +24,11 @@
package org.jboss.portal.wsrp.admin.ui;
import org.jboss.portal.wsrp.WSRPConsumer;
+import org.jboss.portal.wsrp.consumer.ConsumerException;
import org.jboss.portal.wsrp.consumer.ConsumerRegistry;
import org.jboss.portal.wsrp.consumer.ProducerInfo;
+import javax.faces.context.FacesContext;
import javax.faces.event.ValueChangeEvent;
/**
@@ -34,11 +36,12 @@
* @version $Revision$
* @since 2.6
*/
-public class ConsumerBean
+public class ConsumerBean extends ManagedBean
{
private WSRPConsumer consumer;
private ConsumerRegistry registry;
private Boolean useWSDL = null;
+ private ConsumerManagerBean manager;
public void setRegistry(ConsumerRegistry registry)
@@ -46,7 +49,10 @@
this.registry = registry;
}
- // Properties
+ public void setManager(ConsumerManagerBean manager)
+ {
+ this.manager = manager;
+ }
public boolean isUseWSDL()
{
@@ -137,7 +143,14 @@
public void setWsdl(String wsdlURL)
{
- getProducerInfo().getEndpointConfigurationInfo().setWsdlDefinitionURL(wsdlURL);
+ try
+ {
+ getProducerInfo().getEndpointConfigurationInfo().setWsdlDefinitionURL(wsdlURL);
+ }
+ catch (RuntimeException e)
+ {
+ createErrorMessageFrom("wsdl", e);
+ }
}
public boolean isActive()
@@ -166,11 +179,20 @@
{
if (consumer != null)
{
- registry.updateProducerInfo(getProducerInfo());
- return ConsumerManagerBean.INDEX;
+ try
+ {
+ registry.updateProducerInfo(getProducerInfo());
+ }
+ catch (ConsumerException e)
+ {
+ createErrorMessageFrom(e);
+ return null;
+ }
+
+ return manager.listConsumers();
}
- // todo: error message
+ createErrorMessage("Couldn't update Consumer!");
return null;
}
@@ -179,5 +201,7 @@
public void useWSDLListener(ValueChangeEvent event)
{
useWSDL = (Boolean)event.getNewValue();
+ // bypass the rest of the life cycle and re-display page
+ FacesContext.getCurrentInstance().renderResponse();
}
}
\ No newline at end of file
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-12
11:41:31 UTC (rev 6974)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java 2007-04-13
21:56:09 UTC (rev 6975)
@@ -27,9 +27,7 @@
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;
import java.util.Collection;
import java.util.Map;
@@ -39,11 +37,10 @@
* @version $Revision$
* @since 2.6
*/
-public class ConsumerManagerBean
+public class ConsumerManagerBean extends ManagedBean
{
private ConsumerRegistry registry;
private String selectedId;
- private Boolean useWSDL = null;
private static final String CONSUMER_ID = "consumerId";
static final String CONFIGURE_CONSUMER = "configureConsumer";
@@ -154,34 +151,11 @@
}
else
{
- createErrorMessage("Need a non-null, non-empty name for the new
Consumer", FacesMessage.SEVERITY_ERROR);
+ createErrorMessage("Need a non-null, non-empty name for the new
Consumer");
return null;
}
}
- public String updateConsumer()
- {
- WSRPConsumer consumer = getSelectedConsumer();
- if (consumer != null)
- {
- try
- {
- registry.updateProducerInfo(consumer.getProducerInfo());
- return listConsumers();
- }
- catch (ConsumerException e)
- {
- createErrorMessageFrom(e);
- return null;
- }
- }
- else
- {
- noSelectedConsumerError();
- return null;
- }
- }
-
public String destroyConsumer()
{
if (refreshConsumerId() != null)
@@ -221,36 +195,20 @@
public String listConsumers()
{
setConsumerIdInSession(true);
- useWSDL = null;
selectedId = null;
return INDEX;
}
- public void useWSDLListener(ValueChangeEvent event)
- {
- useWSDL = (Boolean)event.getNewValue();
- }
-
- public boolean isUseWSDL()
- {
- if (useWSDL != null)
- {
- return useWSDL.booleanValue();
- }
-
- return
getSelectedConsumer().getProducerInfo().getEndpointConfigurationInfo().usesWSDL();
- }
-
private String refreshConsumerId()
{
selectedId = getParameter("id");
- useWSDL = null;
return selectedId;
}
private void setConsumerIdInSession(boolean remove)
{
Map sessionMap =
FacesContext.getCurrentInstance().getExternalContext().getSessionMap();
+ sessionMap.remove("consumer");
if (!remove)
{
sessionMap.put(CONSUMER_ID, selectedId);
@@ -261,25 +219,8 @@
}
}
- private String getParameter(String key)
- {
- Map pmap =
FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
- return (String)pmap.get(key);
- }
-
- private void createErrorMessage(String message, FacesMessage.Severity severity)
- {
- FacesMessage msg = new FacesMessage(severity, message, 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);
+ createErrorMessage("No Consumer was selected!");
}
}
\ No newline at end of file
Added: trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ManagedBean.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ManagedBean.java
(rev 0)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ManagedBean.java 2007-04-13
21:56:09 UTC (rev 6975)
@@ -0,0 +1,70 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2007, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+
+package org.jboss.portal.wsrp.admin.ui;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.context.FacesContext;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class ManagedBean
+{
+ protected String getParameter(String key)
+ {
+ Map pmap =
FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
+ return (String)pmap.get(key);
+ }
+
+ protected void createErrorMessage(String message)
+ {
+ createErrorMessage(null, message, FacesMessage.SEVERITY_ERROR);
+ }
+
+ protected void createErrorMessage(String target, String message)
+ {
+ createErrorMessage(target, message, FacesMessage.SEVERITY_ERROR);
+ }
+
+ protected void createErrorMessage(String target, String message, FacesMessage.Severity
severity)
+ {
+ FacesMessage msg = new FacesMessage(severity, message, message);
+ FacesContext.getCurrentInstance().addMessage(target, msg);
+ }
+
+ protected void createErrorMessageFrom(Exception e)
+ {
+ createErrorMessageFrom(null, e);
+ }
+
+ protected void createErrorMessageFrom(String target, Exception e)
+ {
+ Throwable cause = e.getCause();
+ String message = e.getLocalizedMessage() + (cause != null ? "\nCause: " +
cause.getLocalizedMessage() : "");
+ createErrorMessage(target, message);
+ }
+}
Property changes on: trunk/wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ManagedBean.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
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-12
11:41:31 UTC (rev 6974)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ConsumerRegistryService.java 2007-04-13
21:56:09 UTC (rev 6975)
@@ -322,9 +322,9 @@
throw new IllegalArgumentException(CONSUMER_WITH_ID + id + "'
doesn't exist!");
}
+ consumer.activate();
federatingPortletInvoker.registerInvoker(id, consumer);
portalEventListenerRegistry.registerListener(getListenerIdFrom(id),
consumer);
- consumer.activate();
}
else
{
@@ -335,9 +335,9 @@
if (invoker instanceof WSRPConsumer)
{
consumer = (WSRPConsumer)invoker;
+ consumer.deactivate();
federatingPortletInvoker.unregisterInvoker(id);
portalEventListenerRegistry.unregisterListener(getListenerIdFrom(id));
- consumer.deactivate();
}
else
{
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/EndpointConfigurationInfo.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/EndpointConfigurationInfo.java 2007-04-12
11:41:31 UTC (rev 6974)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/EndpointConfigurationInfo.java 2007-04-13
21:56:09 UTC (rev 6975)
@@ -176,7 +176,7 @@
this.portletManagementURL = portletManagementURL;
}
- public void setWsdlDefinitionURL(String wsdlDefinitionURL)
+ public void setWsdlDefinitionURL(String wsdlDefinitionURL) throws RuntimeException
{
this.wsdlDefinitionURL = wsdlDefinitionURL;
@@ -187,18 +187,32 @@
{
serviceFactory = new RemoteSOAPInvokerServiceFactory();
}
-
((RemoteSOAPInvokerServiceFactory)serviceFactory).setWsdlDefinitionURL(wsdlDefinitionURL);
+ try
+ {
+
((RemoteSOAPInvokerServiceFactory)serviceFactory).setWsdlDefinitionURL(wsdlDefinitionURL);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
}
}
- public void initServiceFactoryIfNeeded()
+ private void initServiceFactoryIfNeeded() throws RuntimeException
{
if (serviceFactory == null)
{
if (usesWSDL())
{
serviceFactory = new RemoteSOAPInvokerServiceFactory();
-
((RemoteSOAPInvokerServiceFactory)serviceFactory).setWsdlDefinitionURL(wsdlDefinitionURL);
+ try
+ {
+
((RemoteSOAPInvokerServiceFactory)serviceFactory).setWsdlDefinitionURL(wsdlDefinitionURL);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
}
else
{
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-12
11:41:31 UTC (rev 6974)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java 2007-04-13
21:56:09 UTC (rev 6975)
@@ -461,7 +461,17 @@
{
if (!started)
{
- start();
+ try
+ {
+ start();
+ }
+ catch (Exception e)
+ {
+ // mark the consumer as inactive if it cannot be started
+ producerInfo.setActive(false);
+ throw e;
+ }
+
log.info("Consumer with id '" + getProducerId() + "'
activated");
}
producerInfo.setActive(getServiceFactory().isAvailable());
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPDeploymentFactory.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPDeploymentFactory.java 2007-04-12
11:41:31 UTC (rev 6974)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/deployment/WSRPDeploymentFactory.java 2007-04-13
21:56:09 UTC (rev 6975)
@@ -253,7 +253,14 @@
else if ("endpoint-wsdl-url".equals(localName))
{
value = StringPropertyReplacer.replaceProperties(value);
- endpointInfo.setWsdlDefinitionURL(value);
+ try
+ {
+ endpointInfo.setWsdlDefinitionURL(value);
+ }
+ catch (RuntimeException e)
+ {
+ // ignore at this point if the WSDL cannot be retrieved, another attempt will
be made before persisting
+ }
}
}
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java 2007-04-12
11:41:31 UTC (rev 6974)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java 2007-04-13
21:56:09 UTC (rev 6975)
@@ -72,7 +72,7 @@
return wsdlDefinitionURL;
}
- public void setWsdlDefinitionURL(String wsdlDefinitionURL) throws RuntimeException
+ public void setWsdlDefinitionURL(String wsdlDefinitionURL) throws RuntimeException,
Exception
{
if (wsdlDefinitionURL == null || wsdlDefinitionURL.length() == 0)
{
@@ -96,6 +96,7 @@
{
log.info("Couldn't access WSDL information. Service won't be
available", e);
available = false;
+ throw e;
}
}
Modified: trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/faces-config.xml
===================================================================
--- trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/faces-config.xml 2007-04-12 11:41:31
UTC (rev 6974)
+++ trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/faces-config.xml 2007-04-13 21:56:09
UTC (rev 6975)
@@ -45,7 +45,7 @@
<managed-bean>
<managed-bean-name>consumer</managed-bean-name>
<managed-bean-class>org.jboss.portal.wsrp.admin.ui.ConsumerBean</managed-bean-class>
- <managed-bean-scope>request</managed-bean-scope>
+ <managed-bean-scope>session</managed-bean-scope>
<managed-property>
<property-name>registry</property-name>
<property-class>org.jboss.portal.wsrp.consumer.ConsumerRegistry</property-class>
@@ -54,7 +54,11 @@
<managed-property>
<property-name>id</property-name>
<value>#{sessionScope.consumerId}</value>
- </managed-property>
+ </managed-property>
+ <managed-property>
+ <property-name>manager</property-name>
+ <value>#{consumersMgr}</value>
+ </managed-property>
</managed-bean>
<navigation-rule>
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-12
11:41:31 UTC (rev 6974)
+++
trunk/wsrp/src/resources/portal-wsrp-war/WEB-INF/jsf/consumers/editConsumer.xhtml 2007-04-13
21:56:09 UTC (rev 6975)
@@ -5,7 +5,6 @@
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jstl/core">
-<f:view>
<h:form>
<h1 class="portlet">Consumer '#{consumer.id}'
configuration</h1>
<h:commandLink action="#{consumersMgr.activateConsumer}"
styleClass="portlet-form-button"
@@ -31,6 +30,7 @@
<hr/>
<h:form>
+<h:messages styleClass="error"/>
<table width="100%" class="portlet-table-body">
<tr>
<th>Producer id:</th>
@@ -48,7 +48,8 @@
<tr>
<th>Endpoint configuration:</th>
<td>
- <h:selectBooleanCheckbox id="useWSDL"
value="#{consumer.useWSDL}"/>Use WSDL?
+ <h:selectBooleanCheckbox id="useWSDL"
value="#{consumer.useWSDL}" onchange="this.form.submit()"
+
valueChangeListener="#{consumer.useWSDLListener}"
immediate="true"/>Use WSDL?
<h:message styleClass="error" for="useWSDL"/>
<c:choose>
<c:when test="#{consumer.useWSDL}">
@@ -142,5 +143,4 @@
<hr/>
</h:form>
-</f:view>
</div>
\ No newline at end of file