Author: ips
Date: 2008-12-19 00:33:47 -0500 (Fri, 19 Dec 2008)
New Revision: 78
Modified:
trunk/core/src/main/java/org/jboss/on/embedded/Constants.java
trunk/core/src/main/java/org/jboss/on/embedded/EmbeddedInventoryEventListener.java
trunk/core/src/main/java/org/jboss/on/embedded/ui/CommonActionUtil.java
trunk/core/src/main/java/org/jboss/on/embedded/ui/NavigationAction.java
trunk/core/src/main/java/org/jboss/on/embedded/ui/SummaryAction.java
trunk/core/src/main/webapp/WEB-INF/pages.xml
Log:
handle user clicking on a stale resource instance link gracefully (fix for
https://jira.jboss.org/jira/browse/EMBJOPR-54)
Modified: trunk/core/src/main/java/org/jboss/on/embedded/Constants.java
===================================================================
--- trunk/core/src/main/java/org/jboss/on/embedded/Constants.java 2008-12-18 18:30:13 UTC
(rev 77)
+++ trunk/core/src/main/java/org/jboss/on/embedded/Constants.java 2008-12-19 05:33:47 UTC
(rev 78)
@@ -63,6 +63,10 @@
*/
public static final String OUTCOME_RESOURCE_INSTANCE = "resourceInstance";
/**
+ * action outcome indicating that the summary page for the Platform resource instance
should be displayed
+ */
+ public static final String OUTCOME_PLATFORM = "platform";
+ /**
* navigation key used to store all the datasources in the nav
*/
public static final String RESOURCE_CATEGORY_DATASOURCE = "datasource";
Modified:
trunk/core/src/main/java/org/jboss/on/embedded/EmbeddedInventoryEventListener.java
===================================================================
---
trunk/core/src/main/java/org/jboss/on/embedded/EmbeddedInventoryEventListener.java 2008-12-18
18:30:13 UTC (rev 77)
+++
trunk/core/src/main/java/org/jboss/on/embedded/EmbeddedInventoryEventListener.java 2008-12-19
05:33:47 UTC (rev 78)
@@ -83,8 +83,7 @@
{
if (this.navTreeInitialized)
for (Resource resource : resources)
- Events.instance().raiseEvent(ResourceManager.RESOURCE_DELETED_EVENT,
resource.getResourceType(),
- resource.getParentResource());
+ Events.instance().raiseEvent(ResourceManager.RESOURCE_DELETED_EVENT,
resource);
}
public void resourceActivated(Resource resource)
Modified: trunk/core/src/main/java/org/jboss/on/embedded/ui/CommonActionUtil.java
===================================================================
--- trunk/core/src/main/java/org/jboss/on/embedded/ui/CommonActionUtil.java 2008-12-18
18:30:13 UTC (rev 77)
+++ trunk/core/src/main/java/org/jboss/on/embedded/ui/CommonActionUtil.java 2008-12-19
05:33:47 UTC (rev 78)
@@ -19,29 +19,26 @@
*/
package org.jboss.on.embedded.ui;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import javax.faces.model.SelectItem;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jetbrains.annotations.NotNull;
import org.rhq.core.domain.measurement.Availability;
import org.rhq.core.domain.resource.Resource;
+
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Name;
+
import org.jboss.on.embedded.bean.ResourceListItem;
import org.jboss.on.embedded.manager.ResourceManager;
import org.jboss.on.embedded.manager.ResourceManagerFactory;
import org.jboss.on.embedded.ui.nav.JONTreeNode;
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Name;
-import org.jetbrains.annotations.NotNull;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.faces.model.SelectItem;
-
-import java.util.AbstractList;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.RandomAccess;
-
/**
* Class to hold common methods used by Seam Action classes
*
Modified: trunk/core/src/main/java/org/jboss/on/embedded/ui/NavigationAction.java
===================================================================
--- trunk/core/src/main/java/org/jboss/on/embedded/ui/NavigationAction.java 2008-12-18
18:30:13 UTC (rev 77)
+++ trunk/core/src/main/java/org/jboss/on/embedded/ui/NavigationAction.java 2008-12-19
05:33:47 UTC (rev 78)
@@ -454,16 +454,15 @@
public void updateNavWithDeletedResource(Resource deletedResource)
{
log.info("Resource [" + deletedResource + "] deleted.");
- // TODO need to determine if this can ever return null
- JONTreeNode node = findNode(getResourcePath(deletedResource));
- // TODO need to determine if this can ever return null
+ JONTreeNode node = findNode(getResourcePath(deletedResource));
if (node == null)
{
- log.warn("Unable to find node for deleted Resource + '" +
deletedResource.getName() + "'.");
+ log.warn("Unable to find node for deleted " +
deletedResource.getResourceType().getName() + " '"
+ + deletedResource.getName() + "'.");
return;
}
- JONTreeNode parent = node.getParent();
- parent.reInitializeChildrenMap();
+ JONTreeNode parentNode = node.getParent();
+ parentNode.reInitializeChildrenMap();
}
@Observer(ResourceManager.RESOURCE_UPDATED_EVENT)
Modified: trunk/core/src/main/java/org/jboss/on/embedded/ui/SummaryAction.java
===================================================================
--- trunk/core/src/main/java/org/jboss/on/embedded/ui/SummaryAction.java 2008-12-18
18:30:13 UTC (rev 77)
+++ trunk/core/src/main/java/org/jboss/on/embedded/ui/SummaryAction.java 2008-12-19
05:33:47 UTC (rev 78)
@@ -37,14 +37,18 @@
import org.jboss.on.embedded.manager.ResourceManager;
import org.jboss.on.embedded.manager.ResourceManagerFactory;
import org.jboss.seam.ScopeType;
+import org.jboss.seam.faces.FacesMessages;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Out;
import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.Outcome;
+
import org.jetbrains.annotations.NotNull;
import javax.faces.event.ValueChangeEvent;
import javax.faces.context.FacesContext;
+import javax.faces.application.FacesMessage;
import java.util.ArrayList;
import java.util.List;
@@ -60,6 +64,9 @@
@Scope(ScopeType.EVENT)
public class SummaryAction
{
+ @In
+ private transient FacesMessages facesMessages;
+
/**
* the category that was selected based on the path request parameter
*/
@@ -131,6 +138,18 @@
}
public String getOutcome() {
+ ResourceManager resourceManager = ResourceManagerFactory.resourceManager();
+ if (resourceManager.getResource(this.resource.getId()) == null) {
+ SummaryAction.this.facesMessages.add(FacesMessage.SEVERITY_WARN,
+ "#0 '#1' no longer exists.",
this.resource.getResourceType().getName(),
+ this.resource.getName());
+ // Reset the current node to the stale Resource node's parent node.
+ JONTreeNode parentNode =
SummaryAction.this.navigationAction.getSelectedNode().getParent();
+
SummaryAction.this.navigationAction.setCurrentPath(parentNode.getPath());
+ // And refresh the parent node's children to remove the stale
Resource node.
+ parentNode.reInitializeChildrenMap();
+ return Constants.OUTCOME_ERROR;
+ }
setResourceAndSummaryInfo(this.resource);
return Constants.OUTCOME_RESOURCE_INSTANCE;
}
Modified: trunk/core/src/main/webapp/WEB-INF/pages.xml
===================================================================
--- trunk/core/src/main/webapp/WEB-INF/pages.xml 2008-12-18 18:30:13 UTC (rev 77)
+++ trunk/core/src/main/webapp/WEB-INF/pages.xml 2008-12-19 05:33:47 UTC (rev 78)
@@ -42,7 +42,7 @@
</page>
<!-- summary.xhtml is a placeholder view-id, the page doesn't actually
-exist. Instead the navigation rules below determine which actual page is rendered-->
+ exist. Instead the navigation rules below determine which actual page is
rendered-->
<page view-id="/secure/summary.xhtml">
<!-- map the path request parameter to a session scoped variable -->
<param name="path"
value="#{navigationAction.currentPath}"/>
@@ -66,6 +66,9 @@
<rule if-outcome="resourceInstance">
<render
view-id="/secure/resourceInstanceSummary.xhtml"/>
</rule>
+ <rule if-outcome="error">
+ <redirect view-id="/secure/summary.xhtml"/>
+ </rule>
</navigation>
</page>