Jeff_Morse
Level 6

ProductRegistryService in custom panel

Hi,

I have a custom panel I want to display a list of install location(s) of one of our products, specified by name and version. I am trying to use the ProductRegistryService to read the zerog registry. I read kb article Q204835) and came up with some code that works in a custom action, but fails in a custom panel with a java.lang.NullPointerException in a getProducts() call.

The custom action that works:[CODE]
public class GetInstalledProductsAction extends CustomCodeAction
{
public void install ( InstallerProxy ip ) throws InstallException
{
String productName = ip.substitute("$PRODUCT_NAME$");
String productVersion = ip.substitute("$PRODUCT_VERSION$");

ProductRegistryService prs = (ProductRegistryService) ip.getService(ProductRegistryService.class);
SoftwareObjectSearchCriteria sc = new SoftwareObjectSearchCriteria(SoftwareObjectSearchCriteria.COMPARISON_TYPE_OR);
sc.setName(productName);
sc.setVersion(productVersion);

Product[] installedProducts = prs.getProducts(sc); // <== Works here
String installedProductsStr = "";
for ( int i=0; i {
if ( installedProducts.getName().equals(productName) &&
installedProducts.getVersion().equals(productVersion) )
{
installedProductsStr = installedProductsStr + installedProducts.getName() + ";";
installedProductsStr = installedProductsStr + installedProducts.getLocation() + "|";
}
}

ip.setVariable("INSTALLED_PRODUCTS", installedProductsListStr);
}

// ...
}
[/CODE]

The custom panel that does NOT work:[CODE]
public class ProductIntegrationPanel extends CustomCodePanel
{
private CustomCodePanelProxy ccpp;
private Product[] installedProducts = new Product[10];

public boolean setupUI ( CustomCodePanelProxy proxy )
{
ccpp = proxy;
// ...
installedProducts = getProductFromZerogReg(PRODUCT_NAME, PRODUCT_VERSION);
// ...
}

private Product[] getProductFromZerogReg ( String productName, String productVersion )
{
Product[] foundProducts = new Product[10];
ProductRegistryService prs = (ProductRegistryService) ccpp.getService(ProductRegistryService.class);
SoftwareObjectSearchCriteria sc = new SoftwareObjectSearchCriteria(SoftwareObjectSearchCriteria.COMPARISON_TYPE_OR);
sc.setName(productName);
sc.setVersion(productVersion);
Product[] installedProducts = prs.getProducts(sc); // <== FAILS HERE
for ( int i=0,j=0; i {
if ( installedProducts.getName().equals(productName) &&
installedProducts.getVersion().equals(productVersion) )
{
File propertiesFile = new File(installedProducts.getLocation() +
System.getProperty("file.separator") +
PROPERTIES_FILE);
if ( propertiesFile.exists() )
foundProducts[j++] = installedProducts;
propertiesFile = null;
}
}
return foundProducts;
}
}
[/CODE]

Can anyone tell me what I am doing wrong?

-Jeff
Labels (1)
0 Kudos
2 Replies
purcellk24
Level 7

In your custom panel I see
installedProducts = getProductFromZerogReg(PRODUCT_NAME, PRODUCT_VERSION);

. Make sure that PRODUCT_NAME and PRODUCT_VERSION variables are set to
proxy.substitute("$PRODUCT_NAME$") and proxy.substitute("$PRODUCT_VERSION$")
0 Kudos
Jeff_Morse
Level 6

I have an update on this.

I entered an incident report with Tech Support and Engineering has determined this is a bug:

This problem has been reproduced and determined to be an issue in our software. This issue has been submitted to our Engineering team as Issue #IOA-000049603. Currently, there is no workaround.

But there is a workaround: Create an action that will set variable(s) or write to a properties file that your panel reads. At least that worked in my case.

-Jeff
0 Kudos