HttpServletResponse response = (HttpServletResponse) FacesContextUtility.getFacesContext().getExternalContext()
.getResponse();
String path = "";
if (node.getData() instanceof ResourceFlyweight) {
ResourceFlyweight flyweight = (ResourceFlyweight) node.getData();
if (flyweight.isLocked()) {
FacesContext.getCurrentInstance().addMessage(
"leftNavTreeForm:leftNavTree",
new FacesMessage(FacesMessage.SEVERITY_WARN,
"You have not been granted view access to this resource", null));
return false;
} else {
path = FacesContextUtility.getRequest().getRequestURI();
//Resource resource = this.resourceManager.getResourceById(subject, ((Resource) node.getData()).getId());
ResourceFacets facets = this.resourceTypeManager.getResourceFacets(flyweight.getResourceType()
.getId());
String fallbackPath = FunctionTagLibrary.getDefaultResourceTabURL();
// Switching from a auto group view... default to monitor page
if (!path.startsWith("/rhq/resource")) {
path = fallbackPath;
} else {
if ((path.startsWith("/rhq/resource/configuration/") && !facets.isConfiguration())
|| (path.startsWith("/rhq/resource/content/") && !facets.isContent())
|| (path.startsWith("/rhq/resource/operation") && !facets.isOperation())
|| (path.startsWith("/rhq/resource/events") && !facets.isEvent())) {
// This resource doesn't support those facets
path = fallbackPath;
} else if ((path.startsWith("/rhq/resource/configuration/view-map.xhtml")
|| path.startsWith("/rhq/resource/configuration/edit-map.xhtml")
|| path.startsWith("/rhq/resource/configuration/add-map.xhtml") || path
.startsWith("/rhq/resource/configuration/edit.xhtml")
&& facets.isConfiguration())) {
path = "/rhq/resource/configuration/view.xhtml";
} else if (!path.startsWith("/rhq/resource/content/view.xhtml")
&& path.startsWith("/rhq/resource/content/") && facets.isContent()) {
path = "/rhq/resource/content/view.xhtml";
} else if (path.startsWith("/rhq/resource/inventory/")
&& !(path.startsWith("/rhq/resource/inventory/view.xhtml")
|| (facets.isPluginConfiguration() && path
.startsWith("/rhq/resource/inventory/view-connection.xhtml")) || path
.startsWith("/rhq/resource/inventory/view-agent.xhtml"))) {
path = "/rhq/resource/inventory/view.xhtml";
} else if (path.startsWith("/rhq/resource/operation/resourceOperationHistoryDetails.xhtml")) {
path = "/rhq/resource/operation/resourceOperationHistory.xhtml";
} else if (path.startsWith("/rhq/resource/operation/resourceOperationScheduleDetails.xhtml")) {
path = "/rhq/resource/operation/resourceOperationSchedules.xhtml";
} else if (path.startsWith("/rhq/resource/monitor/response.xhtml") && !facets.isCallTime()) {
path = fallbackPath;
}
}
path += ("?id=" + flyweight.getId());
}
} else if (node.getData() instanceof AutoGroupCompositeFlyweight) {
AutoGroupCompositeFlyweight ag = (AutoGroupCompositeFlyweight) node.getData();
if (ag.getResourceType() == null) {
//XXX this is a temporary measure. The subcategories will get the content page in the end.