Author: ips
Date: 2008-11-14 18:42:49 -0500 (Fri, 14 Nov 2008)
New Revision: 52
Modified:
trunk/core/src/main/java/org/jboss/on/embedded/ui/SingleResourceAction.java
trunk/core/src/main/webapp/WEB-INF/classes/messages.properties
Log:
display an error message when a delete-resource request fails
Modified: trunk/core/src/main/java/org/jboss/on/embedded/ui/SingleResourceAction.java
===================================================================
--- trunk/core/src/main/java/org/jboss/on/embedded/ui/SingleResourceAction.java 2008-11-14
21:49:42 UTC (rev 51)
+++ trunk/core/src/main/java/org/jboss/on/embedded/ui/SingleResourceAction.java 2008-11-14
23:42:49 UTC (rev 52)
@@ -39,6 +39,8 @@
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.clientapi.agent.inventory.DeleteResourceResponse;
+
import org.jboss.on.embedded.Constants;
import org.jboss.on.embedded.manager.ResourceManager;
import org.jboss.on.embedded.manager.ResourceManagerFactory;
@@ -55,7 +57,7 @@
{
private static final Log log = LogFactory.getLog(SingleResourceAction.class);
- private ResourceManager manager;
+ private ResourceManager resourceManager;
@In
private NavigationAction navigationAction;
@@ -90,7 +92,7 @@
@Create
public void create()
{
- manager = ResourceManagerFactory.resourceManager();
+ resourceManager = ResourceManagerFactory.resourceManager();
}
@Destroy
@@ -104,17 +106,13 @@
public String removeResourceAction()
{
- Resource resourceToBeDeleted = manager.getResource(resourceId);
-
+ Resource resourceToBeDeleted = resourceManager.getResource(resourceId);
if (resourceToBeDeleted == null)
{
facesMessages.add(FacesMessage.SEVERITY_ERROR, "Resource with id ["
+ resourceId + "] not found.");
return Constants.OUTCOME_FAILURE;
}
-
- removeResourceAction(resourceToBeDeleted);
-
- return Constants.OUTCOME_SUCCESS;
+ return removeResourceAction(resourceToBeDeleted);
}
/**
@@ -125,14 +123,21 @@
*/
public String removeResourceAction(@NotNull Resource resource)
{
- log.info("resource to be removed: " + resource);
-
- manager.removeResource(resource);
- facesMessages.addFromResourceBundle(FacesMessage.SEVERITY_INFO,
"resource.status.remove.success", resource.getResourceType().getName(),
resource.getName());
- Events.instance().raiseEvent("resourceDeleted", resource);
-
- // TODO remove this, not used
- return Constants.OUTCOME_SUCCESS;
+ log.debug("Removing Resource " + resource + "...");
+ DeleteResourceResponse deleteResourceResponse =
resourceManager.removeResource(resource);
+ switch (deleteResourceResponse.getStatus()) {
+ case SUCCESS:
+ facesMessages.addFromResourceBundle(FacesMessage.SEVERITY_INFO,
"resource.status.remove.success",
+ resource.getResourceType().getName(), resource.getName());
+ Events.instance().raiseEvent("resourceDeleted", resource);
+ return Constants.OUTCOME_SUCCESS;
+ default:
+ String details = (deleteResourceResponse.getErrorMessage() != null) ?
+ deleteResourceResponse.getErrorMessage() : "Check server log
for more details.";
+ facesMessages.addFromResourceBundle(FacesMessage.SEVERITY_ERROR,
"resource.status.remove.failure",
+ resource.getResourceType().getName(), resource.getName(),
details);
+ return Constants.OUTCOME_FAILURE;
+ }
}
// TODO just a test
Modified: trunk/core/src/main/webapp/WEB-INF/classes/messages.properties
===================================================================
--- trunk/core/src/main/webapp/WEB-INF/classes/messages.properties 2008-11-14 21:49:42 UTC
(rev 51)
+++ trunk/core/src/main/webapp/WEB-INF/classes/messages.properties 2008-11-14 23:42:49 UTC
(rev 52)
@@ -53,7 +53,7 @@
resource.status.update.validationErrors=An invalid value was specified for one or more
properties. See below for details.
resource.status.update.failure=Failed to update Resource (see app server log for
additional details):
resource.status.update.success=Successfully updated {0} '{1}'.
-resource.status.remove.failure=Failed to delete Resource, please see app server log for
more information.
+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.
Show replies by date