Author: ips
Date: 2009-04-23 16:08:03 -0400 (Thu, 23 Apr 2009)
New Revision: 327
Modified:
trunk/core/src/main/java/org/jboss/on/embedded/ui/configuration/resource/ResourceConfigurationUIBean.java
trunk/core/src/main/webapp/WEB-INF/classes/messages.properties
Log:
on config create/update pages, don't show plugin-generated property-specific errors at
the top of the page, since they are already shown next to the corresponding properties
(
https://jira.jboss.org/jira/browse/EMBJOPR-162)
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 2009-04-23
19:46:16 UTC (rev 326)
+++
trunk/core/src/main/java/org/jboss/on/embedded/ui/configuration/resource/ResourceConfigurationUIBean.java 2009-04-23
20:08:03 UTC (rev 327)
@@ -31,9 +31,10 @@
import org.jboss.on.embedded.ui.CommonActionUtil;
import org.rhq.core.gui.configuration.ConfigHelperUIBean;
import org.rhq.core.gui.util.IdChunkGeneratorUIBean;
-import org.rhq.core.gui.util.PropertyIdGeneratorUtility;
import org.rhq.core.clientapi.agent.inventory.CreateResourceResponse;
import org.rhq.core.clientapi.server.configuration.ConfigurationUpdateResponse;
+import org.jetbrains.annotations.NotNull;
+
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Begin;
import org.jboss.seam.annotations.In;
@@ -109,9 +110,7 @@
public void setTemplateConfiguration(Configuration template)
{
if (template != null)
- {
- setConfiguration(template);
- }
+ setConfiguration(template);
}
//Instance Variables used by this class but not bijected
@@ -175,9 +174,8 @@
}
}
- if (result == "success") {
+ if (result.equals("success"))
Conversation.instance().end(false);
- }
return result;
}
@@ -186,10 +184,10 @@
String result;
Configuration resourceConfig = getConfiguration();
- ConfigurationUpdateResponse updateResponse =
configurationManager.updateResource(this.listItem.getResource(),
+ ConfigurationUpdateResponse pluginResponse =
configurationManager.updateResource(this.listItem.getResource(),
resourceConfig);
- switch (updateResponse.getStatus()) {
+ switch (pluginResponse.getStatus()) {
case SUCCESS:
{
facesMessages.addFromResourceBundle(FacesMessage.SEVERITY_INFO,
"resource.status.update.success",
@@ -200,8 +198,8 @@
default:
{
String baseMessage =
this.messages.getString("resource.status.update.failure");
- addActionFailureMessageToFacesMessages(baseMessage,
updateResponse.getErrorMessage());
- addPropertyErrorsToFacesMessages(updateResponse.getConfiguration());
+ addActionFailureMessageToFacesMessages(baseMessage,
pluginResponse.getErrorMessage(),
+ pluginResponse.getConfiguration());
result = Constants.OUTCOME_FAILURE;
}
}
@@ -223,9 +221,9 @@
pluginConfig = configDef.getDefaultTemplate().getConfiguration();
}
}
- CreateResourceResponse response =
configurationManager.createResource("newResource", serviceType,
+ CreateResourceResponse pluginResponse =
configurationManager.createResource("newResource", serviceType,
ancestorResource, pluginConfig, resourceConfig);
- switch (response.getStatus())
+ switch (pluginResponse.getStatus())
{
case SUCCESS:
{
@@ -237,8 +235,8 @@
default:
{
String baseMessage =
this.messages.getString("resource.status.create.failure");
- addActionFailureMessageToFacesMessages(baseMessage,
response.getErrorMessage());
- addPropertyErrorsToFacesMessages(response.getResourceConfiguration());
+ addActionFailureMessageToFacesMessages(baseMessage,
pluginResponse.getErrorMessage(),
+ pluginResponse.getResourceConfiguration());
result = Constants.OUTCOME_FAILURE;
break;
}
@@ -268,36 +266,36 @@
return configHelperUIBean;
}
- private void addActionFailureMessageToFacesMessages(String baseMessage, String
errorDetails)
+ private void addActionFailureMessageToFacesMessages(@NotNull String baseMessage,
String errorDetails,
+ Configuration
resourceConfiguration)
{
- if (baseMessage != null && !baseMessage.trim().equals(""))
- {
- if (errorDetails == null || errorDetails.trim().equals(""))
+ if (errorDetails == null || errorDetails.trim().equals("")) {
+ if (containsPropertyErrors(resourceConfiguration))
errorDetails =
this.messages.getString("resource.status.invalidProps");
- // TODO When this is internationalized, the method call "add" will
change to addFromResourceBundle
- this.facesMessages.add(new FacesMessage(FacesMessage.SEVERITY_ERROR,
baseMessage + " " + errorDetails, null));
+ else
+ errorDetails =
this.messages.getString("resource.status.failedForUnknownReason");
}
+ // TODO When this is internationalized, the method call "add" will
change to addFromResourceBundle
+ this.facesMessages.add(new FacesMessage(FacesMessage.SEVERITY_ERROR, baseMessage
+ " " + errorDetails, null));
}
- private void addPropertyErrorsToFacesMessages(Configuration configuration)
+ private static boolean containsPropertyErrors(Configuration configuration)
{
if (configuration == null)
- return;
- // TODO: This only handles top-level simples. What about simples within lists and
maps?
+ return false;
+ // TODO: This only handles top-level simples. It should recurse into lists and
maps.
Map<String, PropertySimple> properties =
configuration.getSimpleProperties();
- Set<String> keys = properties.keySet();
- for (String key : keys)
+ Set<String> propNames = properties.keySet();
+ for (String propName : propNames)
{
- PropertySimple property = properties.get(key);
+ PropertySimple property = properties.get(propName);
if (property != null)
{
String error = property.getErrorMessage();
if (error != null && !error.equals(""))
- {
- // TODO When this is internationalized, the method call
"addToControl" will change to addToControlFromResourceBundle
-
this.facesMessages.addToControl(PropertyIdGeneratorUtility.getIdentifier(property, null),
FacesMessage.SEVERITY_ERROR, error);
- }
+ return true;
}
}
+ return false;
}
}
Modified: trunk/core/src/main/webapp/WEB-INF/classes/messages.properties
===================================================================
--- trunk/core/src/main/webapp/WEB-INF/classes/messages.properties 2009-04-23 19:46:16 UTC
(rev 326)
+++ trunk/core/src/main/webapp/WEB-INF/classes/messages.properties 2009-04-23 20:08:03 UTC
(rev 327)
@@ -56,6 +56,7 @@
resource.status.remove.failure=Failed to delete {0} '{1}' - {2}
resource.status.remove.success=Successfully deleted {0} '{1}'.
resource.status.invalidProps=One or more property values was invalid - see below for
details.
+resource.status.failedForUnknownReason=Failed for unknown reason.
resource.edit.title=Edit Resource