modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/ResourceCompositeSearchView.java | 44 +---------
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/type/ResourceTypeRepository.java | 33 +++++--
2 files changed, 31 insertions(+), 46 deletions(-)
New commits:
commit cb023c1565b0dd622e362c4ecdf30d48c6c98ae1
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Thu Oct 31 13:00:40 2013 -0400
[BZ 1021929] - Import context menu does not show plugin resource types when accessing by URL
Fix corner case where our implicit platform child types were not being
applied to platform types on initial entry of the type into the type respository.
This also reverts the prior fix which worked for the bug but did not solve
the root problem.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/ResourceCompositeSearchView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/ResourceCompositeSearchView.java
index 42f33d8..e26d94f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/ResourceCompositeSearchView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/ResourceCompositeSearchView.java
@@ -23,7 +23,6 @@
package org.rhq.coregui.client.inventory.resource;
import java.util.ArrayList;
-import java.util.EnumSet;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
@@ -52,7 +51,6 @@ import org.rhq.coregui.client.gwt.GWTServiceLookup;
import org.rhq.coregui.client.gwt.ResourceGWTServiceAsync;
import org.rhq.coregui.client.inventory.resource.factory.ResourceFactoryCreateWizard;
import org.rhq.coregui.client.inventory.resource.factory.ResourceFactoryImportWizard;
-import org.rhq.coregui.client.inventory.resource.type.ResourceTypeRepository;
import org.rhq.coregui.client.util.Log;
import org.rhq.coregui.client.util.RPCDataSource;
import org.rhq.coregui.client.util.TableUtility;
@@ -65,7 +63,6 @@ import org.rhq.coregui.client.util.message.Message.Severity;
public class ResourceCompositeSearchView extends ResourceSearchView {
private final ResourceComposite parentResourceComposite;
- private ResourceType parentResourceType;
private boolean initialized;
private List<Resource> singletonChildren;
private Set<ResourceType> creatableChildTypes;
@@ -89,28 +86,20 @@ public class ResourceCompositeSearchView extends ResourceSearchView {
@Override
protected void onInit() {
- initMenus(true);
- }
-
- private void initMenus(boolean firstCall) {
+
// To properly filter Create Child and Import menus we need existing singleton child resources. If the
// user has create permission and the parent type has singleton child types and creatable or importable child
// types, perform an async call to fetch the singleton children. If we make the async call don't declare this
// instance initialized until after it completes as we must have the children before the menu buttons can be drawn.
final Resource parentResource = parentResourceComposite.getResource();
- if (parentResourceType == null && firstCall) {
- fetchResourceType();
- return;
- } else if (parentResourceType == null) {
- Log.error("Failed to load resources type for resource [" + parentResource + "]");
- return;
- }
- creatableChildTypes = getCreatableChildTypes(parentResourceType);
- importableChildTypes = getImportableChildTypes(parentResourceType);
+ ResourceType parentType = parentResource.getResourceType();
+ creatableChildTypes = getCreatableChildTypes(parentType);
+ importableChildTypes = getImportableChildTypes(parentType);
hasCreatableTypes = !creatableChildTypes.isEmpty();
hasImportableTypes = !importableChildTypes.isEmpty();
refreshSingletons(parentResource, new AsyncCallback<PageList<Resource>>() {
+
public void onFailure(Throwable caught) {
ResourceCompositeSearchView.super.onInit();
initialized = true;
@@ -120,7 +109,9 @@ public class ResourceCompositeSearchView extends ResourceSearchView {
ResourceCompositeSearchView.super.onInit();
initialized = true;
}
+
});
+
}
private void refreshSingletons(final Resource parentResource, final AsyncCallback<PageList<Resource>> callback) {
@@ -176,7 +167,7 @@ public class ResourceCompositeSearchView extends ResourceSearchView {
new AbstractTableAction(TableActionEnablement.ANY) {
// only enabled if all selected are a deletable type and if the user has delete permission
- // on the resources.
+ // on the resources.
public boolean isEnabled(ListGridRecord[] selection) {
boolean isEnabled = super.isEnabled(selection);
@@ -410,23 +401,4 @@ public class ResourceCompositeSearchView extends ResourceSearchView {
});
}
-
- public void fetchResourceType() {
- // make sure we have all the Type information necessary to render the menus
- ResourceType type = parentResourceComposite.getResource().getResourceType();
- ResourceTypeRepository.Cache.getInstance().getResourceTypes(
- type.getId(),
- EnumSet.of(ResourceTypeRepository.MetadataType.operations, ResourceTypeRepository.MetadataType.children,
- ResourceTypeRepository.MetadataType.subCategory,
- ResourceTypeRepository.MetadataType.pluginConfigurationDefinition,
- ResourceTypeRepository.MetadataType.resourceConfigurationDefinition,
- ResourceTypeRepository.MetadataType.measurements), new ResourceTypeRepository.TypeLoadedCallback() {
-
- public void onTypesLoaded(ResourceType type) {
- parentResourceType = type;
- initMenus(false);
- }
- });
- }
-
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/type/ResourceTypeRepository.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/type/ResourceTypeRepository.java
index 9c591c7..8f5b0be 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/type/ResourceTypeRepository.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/type/ResourceTypeRepository.java
@@ -63,8 +63,8 @@ public class ResourceTypeRepository {
/**
* The following MetadadaTypes are subject to change and are always fetched from the database:<br/>
* driftDefinitionTemplates
- *
- * @author Jay Shaughnessy
+ *
+ * @author Jay Shaughnessy
*/
public enum MetadataType {
children, operations, measurements, content, events, pluginConfigurationDefinition, resourceConfigurationDefinition, subCategory, parentTypes, processScans, productVersions, driftDefinitionTemplates(
@@ -78,7 +78,7 @@ public class ResourceTypeRepository {
/**
* @param isFetchAlways if true then the cache for this metadata will be refreshed each time it is requested.
- * Meaning, the db will always be called because this metadata is subject to change.
+ * Meaning, the db will always be called because this metadata is subject to change.
*/
private MetadataType(boolean isFetchAlways) {
this.isFetchAlways = isFetchAlways;
@@ -221,8 +221,8 @@ public class ResourceTypeRepository {
// 2. we have the basic resource type but no additional metadata, but the caller is asking for additional metadata
// 3. we have the resource type and some additional metadata, but the caller is asking for metadata that we don't have
if (!typeCache.containsKey(typeId) // 1.
- || (!metadataTypes.isEmpty() && (!typeCacheLevel.containsKey(typeId) // 2.
- || !typeCacheLevel.get(typeId).containsAll(metadataTypes)))) // 3.
+ || (!metadataTypes.isEmpty() && (!typeCacheLevel.containsKey(typeId) // 2.
+ || !typeCacheLevel.get(typeId).containsAll(metadataTypes)))) // 3.
{
// add this type to the types we need to fetch
typesNeeded.add(typeId);
@@ -297,7 +297,7 @@ public class ResourceTypeRepository {
case bundleConfiguration:
criteria.fetchBundleConfiguration(true);
break;
-
+
default:
Log.error("Metadata type [" + metadataType.name() + "] not incorporated into ResourceType criteria.");
}
@@ -398,8 +398,7 @@ public class ResourceTypeRepository {
cachedType.setParentResourceTypes(type.getParentResourceTypes());
break;
case pluginConfigurationDefinition:
- cachedType
- .setPluginConfigurationDefinition(type.getPluginConfigurationDefinition());
+ cachedType.setPluginConfigurationDefinition(type.getPluginConfigurationDefinition());
break;
case processScans:
cachedType.setProcessScans(type.getProcessScans());
@@ -418,16 +417,30 @@ public class ResourceTypeRepository {
cachedType.setDriftDefinitionTemplates(type.getDriftDefinitionTemplates());
break;
case bundleConfiguration:
- cachedType.setResourceTypeBundleConfiguration(type.getResourceTypeBundleConfiguration());
+ cachedType.setResourceTypeBundleConfiguration(type
+ .getResourceTypeBundleConfiguration());
break;
default:
Log.error("ERROR: metadataType " + metadataType.name()
- + " not merged into cached ResourceType.");
+ + " not merged into cached ResourceType.");
}
}
}
cachedTypes.put(type.getId(), cachedType);
+
} else {
+ if (type.getCategory() == ResourceCategory.PLATFORM && topLevelServerAndServiceTypes != null
+ && metadataTypes.contains(MetadataType.children)) {
+ // Add server and service types with no parent types to the list of child types.
+ // These types are implicitly children of all platform types, even though they
+ // are not included in the platform types' childResourceTypes field.
+ if (null == type.getChildResourceTypes()) {
+ type.setChildResourceTypes(topLevelServerAndServiceTypes);
+ } else {
+ type.getChildResourceTypes().addAll(topLevelServerAndServiceTypes);
+ }
+ }
+
typeCache.put(type.getId(), type);
cachedTypes.put(type.getId(), type);
}