public Set<ResourcePackageDetails> discoverInstalledSoftware(PackageType type) {
Set<ResourcePackageDetails> installedSoftware = new HashSet<ResourcePackageDetails>();
try {
String uninstallList = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall";
RegistryKey key = RegistryKey.LocalMachine;
RegistryKey uninstall = key.openSubKey(uninstallList);
String[] packages = uninstall.getSubKeyNames();
for (String packageName : packages) {
RegistryKey packageKey = uninstall.openSubKey(packageName);
String installDateString = getStringValue(packageKey, "InstallDate");
String displayName = getStringValue(packageKey, "DisplayName");
String version = getStringValue(packageKey, "DisplayVersion");
if (displayName != null && installDateString != null && version != null) {
if (version.length() == 0) {
version = "1";
}
try {
ResourcePackageDetails details = new ResourcePackageDetails(new PackageDetailsKey(displayName,
version, type.getName(), "noarch"));
details.setFileCreatedDate(getDate(installDateString));
details.setInstallationTimestamp(getDate(installDateString));
details.setFileSize((long) packageKey.getIntValue("EstimatedSize", 0));
details.setDeploymentTimeConfiguration(getConfigurations(packageKey));
installedSoftware.add(details);
} catch (IllegalArgumentException e) {
if (log.isDebugEnabled()) {
log.debug("Skipping windows package discovery for illegal entry [name=" + displayName