Set<ManagedComponent> vdbs = ProfileServiceUtil
.getManagedComponents(connection, new ComponentType(
PluginConstants.ComponentType.VDB.TYPE,
PluginConstants.ComponentType.VDB.SUBTYPE));
PropertySimple displayPreviewVdbs = ((PlatformComponent)discoveryContext.getParentResourceComponent()).getResourceConfiguration().getSimple("displayPreviewVDBS");
for (ManagedComponent mcVdb : vdbs) {
boolean skipVdb = false;
if (!displayPreviewVdbs.getBooleanValue()){
MetaValue[] propsArray = ((CollectionValueSupport)mcVdb.getProperty("JAXBProperties").getValue()).getElements();
String isPreview = "false";
for (MetaValue propertyMetaData : propsArray) {
GenericValueSupport genValueSupport = (GenericValueSupport) propertyMetaData;
ManagedObjectImpl managedObject = (ManagedObjectImpl) genValueSupport
.getValue();
String propertyName = ProfileServiceUtil.getSimpleValue(
managedObject, "name", String.class);
if (propertyName.equals("preview")){
isPreview =ProfileServiceUtil.getSimpleValue(
managedObject, "value", String.class);
if (Boolean.valueOf(isPreview)) skipVdb=true;
break;
}
}
}
//If this is a Preview VDB and displayPreviewVdbs is false, skip this VDB
if (skipVdb) continue;
String vdbKey = (String)mcVdb.getName();
String vdbName = vdbKey;
String fullName = ProfileServiceUtil.getSimpleValue(mcVdb, "fullName",
String.class);
Integer vdbVersion = ProfileServiceUtil.getSimpleValue(mcVdb,
"version", Integer.class);
String vdbDescription = ProfileServiceUtil.getSimpleValue(mcVdb,
"description", String.class);
String vdbStatus = ProfileServiceUtil.getSimpleValue(mcVdb,
"status", String.class);
String vdbURL = ProfileServiceUtil.getSimpleValue(mcVdb, "url",
String.class);
/**
*
* A discovered resource must have a unique key, that must stay the
* same when the resource is discovered the next time
*/
DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
discoveryContext.getResourceType(), // ResourceType
vdbKey, // Resource Key
vdbName, // Resource Name
vdbVersion.toString(), // Version
PluginConstants.ComponentType.VDB.DESCRIPTION, // Description
discoveryContext.getDefaultPluginConfiguration(), // Plugin
// Config
null // Process info from a process scan
);
// Get plugin config map for properties
Configuration configuration = detail.getPluginConfiguration();
configuration.put(new PropertySimple("name", vdbName));
configuration.put(new PropertySimple("fullName", fullName));
configuration.put(new PropertySimple("version", vdbVersion));
configuration
.put(new PropertySimple("description", vdbDescription));
configuration.put(new PropertySimple("status", vdbStatus));
configuration.put(new PropertySimple("url", vdbURL));
detail.setPluginConfiguration(configuration);
// Add to return values
discoveredResources.add(detail);