Author: ips
Date: 2008-12-03 17:36:59 -0500 (Wed, 03 Dec 2008)
New Revision: 64
Modified:
trunk/core/src/main/java/org/jboss/on/embedded/ui/configuration/resource/ResourceConfigurationUIBean.java
Log:
for config-based resource create and update, the Seam conversation should only be ended on
"success" or "cancel" outcomes
(
https://jira.jboss.org/jira/browse/EMBJOPR-46)
Modified:
trunk/core/src/main/java/org/jboss/on/embedded/ui/configuration/resource/ResourceConfigurationUIBean.java
===================================================================
---
trunk/core/src/main/java/org/jboss/on/embedded/ui/configuration/resource/ResourceConfigurationUIBean.java 2008-12-03
22:12:24 UTC (rev 63)
+++
trunk/core/src/main/java/org/jboss/on/embedded/ui/configuration/resource/ResourceConfigurationUIBean.java 2008-12-03
22:36:59 UTC (rev 64)
@@ -20,7 +20,6 @@
package org.jboss.on.embedded.ui.configuration.resource;
import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.resource.Resource;
@@ -42,7 +41,6 @@
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Out;
import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.core.Events;
import org.jboss.seam.faces.FacesMessages;
import javax.faces.application.FacesMessage;
@@ -159,7 +157,7 @@
*
* @return String Results of the save success or failure.
*/
- @End
+ @End(ifOutcome={"success, cancel"}, beforeRedirect = true)
public String saveConfiguration()
{
String result = Constants.OUTCOME_FAILURE;
@@ -181,32 +179,36 @@
private String updateConfiguration()
{
- String result = Constants.OUTCOME_FAILURE;
- Configuration configuration = getConfiguration();
+ String result;
+ Configuration resourceConfig = getConfiguration();
ConfigurationUpdateResponse updateResponse =
configurationManager.updateResource(this.listItem.getResource(),
- configuration);
+ resourceConfig);
- if (updateResponse.getStatus() == ConfigurationUpdateStatus.FAILURE)
- {
- String baseMessage =
this.messages.getString("resource.status.update.failure");
- addActionFailureMessageToFacesMessages(baseMessage,
updateResponse.getErrorMessage());
- addPropertyErrorsToFacesMessages(updateResponse.getConfiguration());
+ switch (updateResponse.getStatus()) {
+ case SUCCESS:
+ {
+ facesMessages.addFromResourceBundle(FacesMessage.SEVERITY_INFO,
"resource.status.update.success",
+ this.listItem.getResource().getResourceType().getName(),
this.listItem.getResource().getName());
+ result = Constants.OUTCOME_SUCCESS;
+ break;
+ }
+ default:
+ {
+ String baseMessage =
this.messages.getString("resource.status.update.failure");
+ addActionFailureMessageToFacesMessages(baseMessage,
updateResponse.getErrorMessage());
+ addPropertyErrorsToFacesMessages(updateResponse.getConfiguration());
+ result = Constants.OUTCOME_FAILURE;
+ }
}
- else
- {
- facesMessages.addFromResourceBundle(FacesMessage.SEVERITY_INFO,
"resource.status.update.success",
- this.listItem.getResource().getResourceType().getName(),
this.listItem.getResource().getName());
- result = Constants.OUTCOME_SUCCESS;
- }
return result;
}
private String createConfiguration()
{
- String result = Constants.OUTCOME_CANCEL;
- Configuration configuration = getConfiguration();
+ String result;
+ Configuration resourceConfig = getConfiguration();
Configuration pluginConfig = null;
if (serviceType != null)
@@ -217,21 +219,23 @@
pluginConfig = configDef.getDefaultTemplate().getConfiguration();
}
}
- CreateResourceResponse response =
configurationManager.createResource("newResource", serviceType,
ancestorResource, pluginConfig, configuration);
+ CreateResourceResponse response =
configurationManager.createResource("newResource", serviceType,
+ ancestorResource, pluginConfig, resourceConfig);
switch (response.getStatus())
{
case SUCCESS:
{
- facesMessages.addFromResourceBundle(FacesMessage.SEVERITY_INFO,
"resource.status.create.success", serviceType.getName());
+ facesMessages.addFromResourceBundle(FacesMessage.SEVERITY_INFO,
"resource.status.create.success",
+ serviceType.getName());
result = Constants.OUTCOME_SUCCESS;
break;
}
- case TIMED_OUT:
- case FAILURE:
+ default:
{
String baseMessage =
this.messages.getString("resource.status.create.failure");
addActionFailureMessageToFacesMessages(baseMessage,
response.getErrorMessage());
addPropertyErrorsToFacesMessages(response.getResourceConfiguration());
+ result = Constants.OUTCOME_FAILURE;
break;
}
}