// add regex support
Pattern namePattern = Pattern.compile(name);
// looking for bundle using only the name
for (String bundle : clusterBundles.keySet()) {
BundleState state = clusterBundles.get(bundle);
if (state.getName() != null) {
// bundle name is populated, check if it matches the regex
Matcher matcher = namePattern.matcher(state.getName());
if (matcher.find()) {
key = bundle;
break;
} else {
// not matched on bundle name, fall back to symbolic name and check if it matches the regex
String split[] = bundle.split("/");
matcher = namePattern.matcher(split[0]);
if (matcher.find()) {
key = bundle;
break;
}
}
} else {
// no bundle name, fall back to symbolic name and check if it matches the regex
String split[] = bundle.split("/");
System.out.println("Bundle-SymbolicName: " + split[0]);
Matcher matcher = namePattern.matcher(split[0]);
if (matcher.find()) {
key = bundle;
break;
}
}
}
}
} else {
// looking for the bundle using name and version
// add regex support of the name
Pattern namePattern = Pattern.compile(name);
for (String bundle : clusterBundles.keySet()) {
String[] split = bundle.split("/");
BundleState state = clusterBundles.get(bundle);
if (split[1].equals(version)) {
if (state.getName() != null) {
// bundle name is populated, check if it matches the regex
Matcher matcher = namePattern.matcher(state.getName());
if (matcher.find()) {
key = bundle;
break;
} else {
// no match on bundle name, fall back to symbolic name and check if it matches the regex