JBoss ON CLI script returning too many results when using "name" criteria
Environment
- Red Hat JBoss Operations Network (ON) 3.1.2
- JBoss ON CLI
- search criteria includes criteria based on the name of an object (for example, a plugin name, resource name, group name, etc)
Issue
- Using "criteria.addFilterName("abc")" is returning results other than those named "abc"
- criteria including a name outputs any resources that include the name criteria string
Resolution
"addFilterName" on criteria will match any name that contains the string specified. It is treated as if there is a wildcard both prefixing and suffixing the submitted filter string. If the submitted criteria name is "abc", valid results are "abc", "abcd", "abc123", "123abcd", and any other name that contains the substring "abc". If you need an exact match to the name, you will need to add additional structures to evaluate the results to match the expected name, such as the "if(groups.get(i).name==groupName)" structure in the below example:
var groupName = "abc";
groupcriteria = new ResourceGroupCriteria();
groupcriteria.addFilterName(groupName);
var groups = ResourceGroupManager.findResourceGroupsByCriteria(groupcriteria);
for( i = 0; i < groups.size(); i++) {
if(groups.get(i).name==groupName) {
... do stuff ...
}
}
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
